If you want the number of HW errors like you are counting, it is simply the device HW - NMW
Avalon device HW is bad nonces + NMW
No need to change anything.
What/where is NMW?
That's an Avalon added stat
(No Matching Work)
If your version of the code isn't adding HW but just calling submit_nonce() with each one, then the HW counter will just be the number of submitted that were no good (and Diff1 Work will be the number submitted - that includes HW)