NetBSD Problem Report #30349

From www@netbsd.org  Fri May 27 04:56:24 2005
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
	id 64D5D63B104; Fri, 27 May 2005 04:56:24 +0000 (UTC)
Message-Id: <20050527045624.64D5D63B104@narn.netbsd.org>
Date: Fri, 27 May 2005 04:56:24 +0000 (UTC)
From: umezawa@iij.ad.jp
Reply-To: umezawa@iij.ad.jp
To: gnats-bugs@netbsd.org
Subject: Input error counter of wm(4) doesn't count error frames
X-Send-Pr-Version: www-1.0

>Number:         30349
>Category:       kern
>Synopsis:       Input error counter of wm(4) doesn't count error frames
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    msaitoh
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 27 04:57:00 +0000 2005
>Closed-Date:    Mon Apr 30 23:55:42 +0000 2012
>Last-Modified:  Mon Apr 30 23:55:42 +0000 2012
>Originator:     UMEZAWA Takeshi
>Release:        1.6.2
>Organization:
Internet Initiative Japan
>Environment:
NetBSD idgw07.iij.ad.jp 1.6.2_STABLE NetBSD 1.6.2_STABLE (GENERIC) #0: Mon May  2 11:40:58 JST 2005     root@idgw07.iij.ad.jp:/usr/src/sys/arch/i386/compile/GENERIC i386
>Description:
if_ierrors of wm(4) is incremented only when wm_add_rxbuf() failed, and is
not incremented when hardware received error frames.

There is the code that increments if_ierrors according to error status of
RX descriptors. But error frames are never stored to RX buffer because
RCTL_SBP (Store Bad Packets) bit of WMREG_RCTL is not set.

>How-To-Repeat:
Connect with duplex mismatch, and receive packets.
There must be many input errors, but if_ierrors is not (or rarely)
incremented.
>Fix:
There are two ways to count error frames.

The first way is, as written in Full Description, setting RCTL_SBP bit.
And the second way is correcting error counts from hardware statistics
registers periodically.

The advantage of the first way is:
  1. If the number of error frames is small, the impact for performance
     is also small.
The advantages of the second way is:
  1. Regardless of the number of error frames, the impact for
     performance is constant.
  2. Regardless of the number of received (or error) frames, error
     counter can be correctly incremented.

I have written a patch that implements the second way. Note that this
patch requires the patch which is submitted in PR kern/30221.

diff -u old/if_wm.c new/if_wm.c
--- old/if_wm.c	Fri May 27 13:52:32 2005
+++ new/if_wm.c	Fri May 27 13:52:44 2005
@@ -1749,7 +1749,6 @@
 		 */
 		if (errors &
 		     (WRX_ER_CE|WRX_ER_SE|WRX_ER_SEQ|WRX_ER_CXE|WRX_ER_RXE)) {
-			ifp->if_ierrors++;
 			if (errors & WRX_ER_SE)
 				printf("%s: symbol error\n",
 				    sc->sc_dev.dv_xname);
@@ -1943,6 +1942,15 @@
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;

 	ifp->if_collisions += CSR_READ(sc, WMREG_COLC);
+
+	ifp->if_ierrors += 0ULL + /* ensure quad_t */
+	    CSR_READ(sc, WMREG_CRCERRS) +
+	    CSR_READ(sc, WMREG_ALGNERRC) +
+	    CSR_READ(sc, WMREG_SYMERRC) +
+	    CSR_READ(sc, WMREG_RXERRC) +
+	    CSR_READ(sc, WMREG_SEC) +
+	    CSR_READ(sc, WMREG_CEXTERR) +
+	    CSR_READ(sc, WMREG_RLEC);
 }

 /*
diff -u old/if_wmreg.h new/if_wmreg.h
--- old/if_wmreg.h	Fri May 27 13:52:32 2005
+++ new/if_wmreg.h	Fri May 27 13:52:44 2005
@@ -514,7 +514,14 @@
 #define	TSPMT_TSMT(x)	(x)		/* TCP seg min transfer */
 #define	TSPMT_TSPBP(x)	((x) << 16)	/* TCP seg pkt buf padding */

+#define	WMREG_CRCERRS	0x4000	/* CRC Error Count */
+#define	WMREG_ALGNERRC	0x4004	/* Alignment Error Count */
+#define	WMREG_SYMERRC	0x4008	/* Symbol Error Count */
+#define	WMREG_RXERRC	0x400c	/* RX Error Count */
 #define	WMREG_COLC	0x4028	/* Collision Count */
+#define	WMREG_SEC	0x4038	/* Sequence Error Count */
+#define	WMREG_CEXTERR	0x403c	/* Carrier Extension Error Count */
+#define	WMREG_RLEC	0x4040	/* Receive Length Error Count */

 #define	WMREG_RXCSUM	0x5000	/* Receive Checksum register */
 #define	RXCSUM_PCSS	0x000000ff	/* Packet Checksum Start */

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->msaitoh
Responsible-Changed-By: msaitoh@NetBSD.org
Responsible-Changed-When: Wed, 03 Feb 2010 06:28:44 +0000
Responsible-Changed-Why:
mine


From: SAITOH Masanobu <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/30349 CVS commit: src/sys/dev/pci
Date: Thu, 4 Feb 2010 09:13:23 +0000

 Module Name:	src
 Committed By:	msaitoh
 Date:		Thu Feb  4 09:13:23 UTC 2010

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

 Log Message:
 - Count Receive error, CRC error, Alignment error, Symbol error, Sequence
   error, Carrier extension error and Receive length error into ierror.
   Fixes PR#30349 reported by UMEZAWA Takeshi.
 - Count Missed packet (rx fifo overflow) and Receive no buffers (rx ring full)
   into iqdrops.


 To generate a diff of this commit:
 cvs rdiff -u -r1.195 -r1.196 src/sys/dev/pci/if_wm.c
 cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/if_wmreg.h

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

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/30349 CVS commit: [netbsd-5] src/sys/dev
Date: Fri, 19 Nov 2010 23:40:29 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Fri Nov 19 23:40:29 UTC 2010

 Modified Files:
 	src/sys/dev/mii [netbsd-5]: igphy.c inbmphyreg.h
 	src/sys/dev/pci [netbsd-5]: if_wm.c if_wmreg.h if_wmvar.h pcidevs
 	    pcireg.h
 Added Files:
 	src/sys/dev/mii [netbsd-5]: igphyvar.h

 Log Message:
 Pull up revisions (requested by msaitoh in ticket #1358):
 	sys/dev/pci/if_wm.c		1.196-1.199,1.202,1.205
 	sys/dev/pci/if_wmvar.h		1.9
 	sys/dev/pci/if_wmreg.h		1.36-1.39
 	sys/dev/pci/pcireg.h		1.61-1.64
 	sys/dev/pci/pcidevs		1.1023
 	sys/dev/pci/pcidevs.h		regen
 	sys/dev/pci/pcidevs_data.h	regen
 	mii/igphy.c			1.21
 	mii/igphyvar.h			1.1
 	mii/inbmphyreg.h		1.2

 - Count Receive error, CRC error, Alignment error, Symbol error, Sequence
   error, Carrier extension error and Receive length error into ierror.
   Fixes PR#30349 reported by UMEZAWA Takeshi.
 - Add support for 82575, 82576 and 82580(ER).
   - Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
     only one RX ring and with the legacy mode.
   - Add support for 82576.
   - Partial support for 82580.
   - Partial support for the serdes systems.
 - Add two workarounds for ICH8 with igp3.
   - Workaround for 82566 Kumeran PCS lock loss.
   - WOL from S5 stops working.
 - (pcireg.h) Add PCIe config register definitions.
 - Note that the changes to count Missed packet (rx fifo overflow) and Receive
   no buffers (rx ring full) into iqdrops in rev. 1.196 of if_wm.c is not
   pulled up.


 To generate a diff of this commit:
 cvs rdiff -u -r1.16.10.1 -r1.16.10.2 src/sys/dev/mii/igphy.c
 cvs rdiff -u -r0 -r1.1.8.2 src/sys/dev/mii/igphyvar.h
 cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/dev/mii/inbmphyreg.h
 cvs rdiff -u -r1.162.4.13 -r1.162.4.14 src/sys/dev/pci/if_wm.c
 cvs rdiff -u -r1.24.20.4 -r1.24.20.5 src/sys/dev/pci/if_wmreg.h
 cvs rdiff -u -r1.2.46.3 -r1.2.46.4 src/sys/dev/pci/if_wmvar.h
 cvs rdiff -u -r1.962.4.11 -r1.962.4.12 src/sys/dev/pci/pcidevs
 cvs rdiff -u -r1.57 -r1.57.20.1 src/sys/dev/pci/pcireg.h

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

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 20 Nov 2010 17:56:30 +0000
State-Changed-Why:
A fix has been committed to current and to netbsd-5. Does that solve the
problem?


State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 30 Apr 2012 23:55:42 +0000
State-Changed-Why:
17-month feedback timeout (fix was committed November 2010)


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.