Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Fix wm(4) input drop packet counter.



details:   https://anonhg.NetBSD.org/src/rev/046c6712e1e1
branches:  trunk
changeset: 348591:046c6712e1e1
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Fri Oct 28 05:29:11 2016 +0000

description:
Fix wm(4) input drop packet counter.

WMREG_RNBC is incremented when there is no available buffers in host
memory. However, ethernet controller can receive packets in such case
if there is space in phy's FIFO. That is, ethernet controller drops
packet only if there is no available buffers *and* there is no space
in phy's FIFO.
So, the number of dropped packets should be added WMREG_MPC only.

ok by msaitoh@n.o

diffstat:

 sys/dev/pci/if_wm.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 339ccc8c21dc -r 046c6712e1e1 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Fri Oct 28 05:21:48 2016 +0000
+++ b/sys/dev/pci/if_wm.c       Fri Oct 28 05:29:11 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.430 2016/10/28 05:21:48 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.431 2016/10/28 05:29:11 knakahara Exp $    */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.430 2016/10/28 05:21:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.431 2016/10/28 05:29:11 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2866,7 +2866,16 @@
            + CSR_READ(sc, WMREG_SEC)
            + CSR_READ(sc, WMREG_CEXTERR)
            + CSR_READ(sc, WMREG_RLEC);
-       ifp->if_iqdrops += CSR_READ(sc, WMREG_MPC) + CSR_READ(sc, WMREG_RNBC);
+       /*
+        * WMREG_RNBC is incremented when there is no available buffers in host
+        * memory. It does not mean the number of dropped packet. Because
+        * ethernet controller can receive packets in such case if there is
+        * space in phy's FIFO.
+        *
+        * If you want to know the nubmer of WMREG_RMBC, you should use such as
+        * own EVCNT instead of if_iqdrops.
+        */
+       ifp->if_iqdrops += CSR_READ(sc, WMREG_MPC);
 
        if (sc->sc_flags & WM_F_HAS_MII)
                mii_tick(&sc->sc_mii);



Home | Main Index | Thread Index | Old Index