Module Name:    src
Committed By:   knakahara
Date:           Fri Oct 28 05:29:11 UTC 2016

Modified Files:
        src/sys/dev/pci: if_wm.c

Log Message:
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 [email protected]


To generate a diff of this commit:
cvs rdiff -u -r1.430 -r1.431 src/sys/dev/pci/if_wm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.430 src/sys/dev/pci/if_wm.c:1.431
--- src/sys/dev/pci/if_wm.c:1.430	Fri Oct 28 05:21:48 2016
+++ src/sys/dev/pci/if_wm.c	Fri Oct 28 05:29:11 2016
@@ -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 @@ wm_tick(void *arg)
 	    + 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);

Reply via email to