NetBSD Problem Report #32643

From pcah8322@artax.karlin.mff.cuni.cz  Thu Jan 26 21:57:18 2006
Return-Path: <pcah8322@artax.karlin.mff.cuni.cz>
Received: from mail.casablanca.cz (mail.casablanca.cz [82.208.31.182])
	by narn.netbsd.org (Postfix) with ESMTP id 16C6C63B879
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 26 Jan 2006 21:57:18 +0000 (UTC)
Message-Id: <200601262156.k0QLuvck001903@beta.martani.n2.repy.czf>
Date: Thu, 26 Jan 2006 22:56:57 +0100 (CET)
From: Pavel Cahyna <pcah8322@artax.karlin.mff.cuni.cz>
Reply-To: pavel.cahyna@st.mff.cuni.cz
To: gnats-bugs@netbsd.org
Subject: re(4) has problems with HW VLAN tagging
X-Send-Pr-Version: 3.95

>Number:         32643
>Category:       kern
>Synopsis:       re(4) has problems with HW VLAN tagging
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    tsutsui
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 26 22:00:01 +0000 2006
>Closed-Date:    Sat Dec 16 02:54:11 +0000 2006
>Last-Modified:  Wed Dec 20 22:30:00 +0000 2006
>Originator:     Pavel Cahyna
>Release:        NetBSD 3.0
>Organization:
>Environment:
System: NetBSD beta.imc.cas.cz 3.0 NetBSD 3.0 (GENERIC-RLPHY) #3: Thu Jan 26 16:18:14 CET 2006 cahyna@beta.imc.cas.cz:/usr/src/sys/arch/i386/compile/GENERIC-RLPHY i386
Architecture: i386
Machine: i386
>Description:
I configured a VLAN device on this re NIC:

re0 at pci1 dev 3 function 0: RealTek 8169S Single-chip Gigabit Ethernet
re0: interrupting at irq 5
re0: Ethernet address 00:01:6c:34:87:14
re0: using 256 tx descriptors
ukphy0 at re0 phy 7: Generic IEEE 802.3u media interface
ukphy0: RTL8169S/8110S 1000BASE-T media interface (OUI 0x00e04c, model 0x0011), rev. 0
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto

The tagged VLAN itself is working fine. But packets going to the untagged
VLAN are often incorrectly tagged with the tag of the tagged VLAN. This
breaks communication over the untagged VLAN. After a reset of the device
with ifconfig re0 down up, it gets better, but after several minutes of
using both VLANs, the problem is back.
>How-To-Repeat:
ifconfig re0 inet xxx
ifconfig vlan0 create; ifconfig vlan0 vlan 4 vlanif re0
ifconfig vlan0 inet 192.168.1.1
now watch the ethernet segment with tcpdump -e on another machine and
observe that some packets with source address xxx are sent with a VLAN
tag.
>Fix:
OpenBSD has a similar HW VLAN tagging code, but it has been always
commented out. Maybe it is a hardware bug? Until a better fix is found, I
propose the following, which disables HW VLAN tagging and works for me.
(NB VLANs in OpenBSD on re do not work - they forgot to disable tag
stripping on input. This problem is corrected in the following diff.
Otherwise the diff is taken from OpenBSD.)

Index: rtl8169.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v
retrieving revision 1.14.2.4
diff -u -r1.14.2.4 rtl8169.c
--- rtl8169.c	18 Aug 2005 20:40:38 -0000	1.14.2.4
+++ rtl8169.c	26 Jan 2006 21:05:22 -0000
@@ -745,8 +745,10 @@
 	ifp->if_mtu = ETHERMTU;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = re_ioctl;
-	sc->ethercom.ec_capabilities |=
-	    ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING;
+	sc->ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
+#ifdef RE_VLAN
+	sc->ethercom.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING;
+#endif
 	ifp->if_start = re_start;
 	ifp->if_stop = re_stop;
 	ifp->if_capabilities |=
@@ -1269,11 +1271,13 @@
 				m->m_pkthdr.csum_flags |= M_CSUM_TCP_UDP_BAD;
 		}

+#ifdef RE_VLAN
 		if (rxvlan & RTK_RDESC_VLANCTL_TAG) {
 			VLAN_INPUT_TAG(ifp, m,
 			     be16toh(rxvlan & RTK_RDESC_VLANCTL_DATA),
 			     continue);
 		}
+#endif
 #if NBPFILTER > 0
 		if (ifp->if_bpf)
 			bpf_mtap(ifp->if_bpf, m);
@@ -1511,7 +1515,9 @@
 {
 	bus_dmamap_t		map;
 	int			error, i, startidx, curidx;
+#ifdef RE_VLAN
 	struct m_tag		*mtag;
+#endif
 	struct rtk_desc		*d;
 	u_int32_t		cmdstat, rtk_flags;
 	struct rtk_txq		*txq;
@@ -1625,11 +1631,13 @@
 	 * transmission attempt.
 	 */

+#ifdef RE_VLAN
 	if ((mtag = VLAN_OUTPUT_TAG(&sc->ethercom, m)) != NULL) {
 		sc->rtk_ldata.rtk_tx_list[startidx].rtk_vlanctl =
 		    htole32(htons(VLAN_TAG_VALUE(mtag)) |
 		    RTK_TDESC_VLANCTL_TAG);
 	}
+#endif

 	/* Transfer ownership of packet to the chip. */

@@ -1781,7 +1789,10 @@
 		reg |= (0x1 << 14) | RTK_CPLUSCMD_PCI_MRW;;

 	if (1)  {/* not for 8169S ? */
-		reg |= RTK_CPLUSCMD_VLANSTRIP |
+		reg |= 
+#ifdef RE_VLAN
+		    RTK_CPLUSCMD_VLANSTRIP |
+#endif
 		    (ifp->if_capenable &
 		    (IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4) ?
 		    RTK_CPLUSCMD_RXCSUM_ENB : 0);

>Release-Note:

>Audit-Trail:
From: Pavel Cahyna <pcah8322@artax.karlin.mff.cuni.cz>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Fri, 27 Jan 2006 13:56:56 +0100

 Please DO NOT apply this patch yet. I noticed some very strange effects in
 OpenBSD while attempting to correct the VLAN stripping in their driver in
 the same way. I want to make sure that is is not related to this attempt.

From: Pavel Cahyna <pavel@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/32643 CVS commit: src/sys/dev/ic
Date: Tue, 16 May 2006 22:39:24 +0000 (UTC)

 Module Name:	src
 Committed By:	pavel
 Date:		Tue May 16 22:39:24 UTC 2006

 Modified Files:
 	src/sys/dev/ic: rtl8169.c

 Log Message:
 Disable hw VLAN tagging, in a similar way that it was done in OpenBSD
 (src/sys/dev/ic/re.c rev. 1.15). The disabled VLAN stripping is mine.
 (The OpenBSD driver forgot to do this.)

 The reason is that untagged packets get sometimes tagged incorrectly.
 PR 32643.

 Approved by martin@.


 To generate a diff of this commit:
 cvs rdiff -r1.22 -r1.23 src/sys/dev/ic/rtl8169.c

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

From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/32643 CVS commit: [netbsd-3] src/sys/dev/ic
Date: Wed, 31 May 2006 21:32:56 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Wed May 31 21:32:56 UTC 2006

 Modified Files:
 	src/sys/dev/ic [netbsd-3]: rtl8169.c

 Log Message:
 Pull up following revision(s) (requested by pavel in ticket #1340):
 	sys/dev/ic/rtl8169.c: revision 1.23
 Disable hw VLAN tagging, in a similar way that it was done in OpenBSD
 (src/sys/dev/ic/re.c rev. 1.15). The disabled VLAN stripping is mine.
 (The OpenBSD driver forgot to do this.)
 The reason is that untagged packets get sometimes tagged incorrectly.
 PR 32643.
 Approved by martin@.


 To generate a diff of this commit:
 cvs rdiff -r1.14.2.4 -r1.14.2.5 src/sys/dev/ic/rtl8169.c

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

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: martin@netbsd.org, kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
	tsutsui@ceres.dti.ne.jp
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Sun, 19 Nov 2006 12:46:04 +0900

 > Maybe it is a hardware bug?

 This looks a software bug.
 (re_vlanctl in the DMA descriptors are not cleared)

 Could you try the attached patch?
 VLAN seems working on both i386 and macppc with this patch.
 ---
 Izumi Tsutsui


 Index: rtl8169.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v
 retrieving revision 1.68
 diff -u -r1.68 rtl8169.c
 --- rtl8169.c	18 Nov 2006 17:39:44 -0000	1.68
 +++ rtl8169.c	19 Nov 2006 03:33:11 -0000
 @@ -759,16 +759,8 @@
  	ifp->if_mtu = ETHERMTU;
  	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
  	ifp->if_ioctl = re_ioctl;
 -	sc->ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
 -
 -	/*
 -	 * This is a way to disable hw VLAN tagging by default
 -	 * (RE_VLAN is undefined), as it is problematic. PR 32643
 -	 */
 -
 -#ifdef RE_VLAN
 -	sc->ethercom.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING;
 -#endif
 +	sc->ethercom.ec_capabilities |=
 +	    ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING;
  	ifp->if_start = re_start;
  	ifp->if_stop = re_stop;

 @@ -1083,6 +1075,7 @@

  	rxs->rxs_mbuf = m;

 +	d->re_vlanctl = 0;
  	cmdstat = map->dm_segs[0].ds_len;
  	if (idx == (RE_RX_DESC_CNT - 1))
  		cmdstat |= RE_RDESC_CMD_EOR;
 @@ -1287,13 +1280,11 @@
  				m->m_pkthdr.csum_flags |= M_CSUM_TCP_UDP_BAD;
  		}

 -#ifdef RE_VLAN
  		if (rxvlan & RE_RDESC_VLANCTL_TAG) {
  			VLAN_INPUT_TAG(ifp, m,
 -			     be16toh(rxvlan & RE_RDESC_VLANCTL_DATA),
 +			     bswap16(rxvlan & RE_RDESC_VLANCTL_DATA),
  			     continue);
  		}
 -#endif
  #if NBPFILTER > 0
  		if (ifp->if_bpf)
  			bpf_mtap(ifp->if_bpf, m);
 @@ -1517,9 +1508,7 @@
  	bus_dmamap_t		map;
  	struct re_txq		*txq;
  	struct re_desc		*d;
 -#ifdef RE_VLAN
  	struct m_tag		*mtag;
 -#endif
  	uint32_t		cmdstat, re_flags;
  	int			ofree, idx, error, nsegs, seg;
  	int			startdesc, curdesc, lastdesc;
 @@ -1645,6 +1634,7 @@
  			}
  #endif

 +			d->re_vlanctl = 0;
  			re_set_bufaddr(d, map->dm_segs[seg].ds_addr);
  			cmdstat = re_flags | map->dm_segs[seg].ds_len;
  			if (seg == 0)
 @@ -1665,6 +1655,7 @@
  			bus_addr_t paddaddr;

  			d = &sc->re_ldata.re_tx_list[curdesc];
 +			d->re_vlanctl = 0;
  			paddaddr = RE_TXPADDADDR(sc);
  			re_set_bufaddr(d, paddaddr);
  			cmdstat = re_flags |
 @@ -1685,14 +1676,11 @@
  		 * appear in the first descriptor of a multi-descriptor
  		 * transmission attempt.
  		 */
 -
 -#ifdef RE_VLAN
  		if ((mtag = VLAN_OUTPUT_TAG(&sc->ethercom, m)) != NULL) {
  			sc->re_ldata.re_tx_list[startdesc].re_vlanctl =
 -			    htole32(htons(VLAN_TAG_VALUE(mtag)) |
 +			    htole32(bswap16(VLAN_TAG_VALUE(mtag)) |
  			    RE_TDESC_VLANCTL_TAG);
  		}
 -#endif

  		/* Transfer ownership of packet to the chip. */

 @@ -1795,9 +1783,7 @@

  	if (1)  {/* not for 8169S ? */
  		reg |=
 -#ifdef RE_VLAN
  		    RTK_CPLUSCMD_VLANSTRIP |
 -#endif
  		    (ifp->if_capenable &
  		    (IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Rx |
  		     IFCAP_CSUM_UDPv4_Rx) ?

From: Pavel Cahyna <pavel@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Sun, 19 Nov 2006 10:40:29 +0100

 On Sun, Nov 19, 2006 at 03:50:03AM +0000, Izumi Tsutsui wrote:
 > The following reply was made to PR kern/32643; it has been noted by GNATS.
 > 
 > From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
 > To: gnats-bugs@netbsd.org
 > Cc: martin@netbsd.org, kern-bug-people@netbsd.org,
 > 	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
 > 	tsutsui@ceres.dti.ne.jp
 > Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
 > Date: Sun, 19 Nov 2006 12:46:04 +0900
 > 
 >  > Maybe it is a hardware bug?
 >  
 >  This looks a software bug.
 >  (re_vlanctl in the DMA descriptors are not cleared)
 >  
 >  Could you try the attached patch?
 >  VLAN seems working on both i386 and macppc with this patch.

 Were you able to repeat my problem without your change?

 Pavel

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: pavel@netbsd.org
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Sun, 19 Nov 2006 18:53:15 +0900

 pavel@netbsd.org wrote:

 > >  VLAN seems working on both i386 and macppc with this patch.
 > 
 > Were you able to repeat my problem without your change?

 I have not tried, but it could happen by stale re_vlanctl values.
 (non VLAN packets could be tagged when DMA descs were reused)

 I'll check it later.
 ---
 Izumi Tsutsui

From: Pavel Cahyna <pavel@NetBSD.org>
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@netbsd.org
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Sun, 19 Nov 2006 10:02:25 +0000

 On Sun, Nov 19, 2006 at 06:53:15PM +0900, Izumi Tsutsui wrote:
 > > Were you able to repeat my problem without your change?
 > 
 > I have not tried, but it could happen by stale re_vlanctl values.
 > (non VLAN packets could be tagged when DMA descs were reused)

 yamt suggested something similar, and it did not work for me.
 see Message-Id: <1147820216.470989.3258.nullmailer@yamt.dyndns.org> on
 source-changes.

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: pavel@netbsd.org
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Sun, 19 Nov 2006 19:49:02 +0900

 pavel@netbsd.org wrote:

 > yamt suggested something similar, and it did not work for me.
 > see Message-Id: <1147820216.470989.3258.nullmailer@yamt.dyndns.org> on
 > source-changes.

 His patch cleared only vlanctl in the first DMA desc on TX,
 but I guess all descs should be cleared both on TX and RX.
 (though I'm not sure what will happen when only trailing descs
  have vlanctl values on TX with multiple descs)


 ---
 With -current rtl8169.c with #define RE_VLAN:
 (byteswap ops should also be fixed for big endian machines though)

 --- commands on re(4) host ---
 # ifconfig re0 192.168.20.4 ip4csump udp4csum tcp4csum
 # ifconfig vlan0 create
 # ifconfig vlan0 vlan 4 vlanif re0
 # ifconfig vlan0 192.168.200.2
 # ping -c 256 -fn 192.168.20.1
  :
 # ping -c 256 -fn 192.168.200.1
  :
 # ping -c 256 -fn 192.168.20.1
  :
 --- end of commands ---

 --- tcpdump output on host 192.168.20.1 aka 192.168.200.1 ---
 19:31:10.918941 00:0d:0b:4b:af:1b > 00:50:04:65:51:1a, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 15357, offset 0, flags [none], length: 84) 192.168.20.4 > 192.168.20.1: icmp 64: echo request seq 0
 19:31:10.918988 00:50:04:65:51:1a > 00:0d:0b:4b:af:1b, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 22507, offset 0, flags [none], length: 84) 192.168.20.1 > 192.168.20.4: icmp 64: echo reply seq 0

  :

 19:31:17.576561 00:0d:0b:4b:af:1b > 00:50:04:65:51:1a, ethertype 802.1Q (0x8100), length 102: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 15613, offset 0, flags [none], length: 84) 192.168.200.2 > 192.168.200.1: icmp 64: echo request seq 0
 19:31:17.576615 00:50:04:65:51:1a > 00:0d:0b:4b:af:1b, ethertype 802.1Q (0x8100), length 102: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 22767, offset 0, flags [none], length: 84) 192.168.200.1 > 192.168.200.2: icmp 64: echo reply seq 0

  :

 19:31:28.920271 00:0d:0b:4b:af:1b > 00:50:04:65:51:1a, ethertype 802.1Q (0x8100), length 102: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 15869, offset 0, flags [none], length: 84) 192.168.20.4 > 192.168.20.1: icmp 64: echo request seq 0
 19:31:28.920325 00:50:04:65:51:1a > 00:0d:0b:4b:af:1b, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 23034, offset 0, flags [none], length: 84) 192.168.20.1 > 192.168.20.4: icmp 64: echo reply seq 0

  :
 --- end of tcpdump output ---


 With my patch:

 --- commands on re(4) host ---
 # ifconfig re0 192.168.20.4 ip4csump udp4csum tcp4csum
 # ifconfig vlan0 create
 # ifconfig vlan0 vlan 4 vlanif re0
 # ifconfig vlan0 192.168.200.2
 # ping -c 256 -fn 192.168.20.1
  :
 # ping -c 256 -fn 192.168.200.1
  :
 # ping -c 256 -fn 192.168.20.1
  :
 --- end of commands ---

 --- tcpdump output on host 192.168.20.1 aka 192.168.200.1 ---
 19:37:01.564851 00:0d:0b:4b:af:1b > 00:50:04:65:51:1a, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 1, offset 0, flags [none], length: 84) 192.168.20.4 > 192.168.20.1: icmp 64: echo request seq 0
 19:37:01.564875 00:50:04:65:51:1a > 00:0d:0b:4b:af:1b, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 23498, offset 0, flags [none], length: 84) 192.168.20.1 > 192.168.20.4: icmp 64: echo reply seq 0

  :

 19:37:14.011127 00:0d:0b:4b:af:1b > 00:50:04:65:51:1a, ethertype 802.1Q (0x8100), length 102: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 257, offset 0, flags [none], length: 84) 192.168.200.2 > 192.168.200.1: icmp 64: echo request seq 0
 19:37:14.011154 00:50:04:65:51:1a > 00:0d:0b:4b:af:1b, ethertype 802.1Q (0x8100), length 102: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 23760, offset 0, flags [none], length: 84) 192.168.200.1 > 192.168.200.2: icmp 64: echo reply seq 0

  :

 19:37:21.142618 00:0d:0b:4b:af:1b > 00:50:04:65:51:1a, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 513, offset 0, flags [none], length: 84) 192.168.20.4 > 192.168.20.1: icmp 64: echo request seq 0
 19:37:21.142674 00:50:04:65:51:1a > 00:0d:0b:4b:af:1b, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 24026, offset 0, flags [none], length: 84) 192.168.20.1 > 192.168.20.4: icmp 64: echo reply seq 0

  :
 --- end of tcpdump output ---

 ---
 Izumi Tsutsui

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, pavel.cahyna@st.mff.cuni.cz
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Mon, 20 Nov 2006 07:15:43 +0900 (JST)

 > The following reply was made to PR kern/32643; it has been noted by GNATS.
 > 
 > From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
 > To: pavel@netbsd.org
 > Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
 > Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
 > Date: Sun, 19 Nov 2006 19:49:02 +0900
 > 
 >  pavel@netbsd.org wrote:
 >  
 >  > yamt suggested something similar, and it did not work for me.
 >  > see Message-Id: <1147820216.470989.3258.nullmailer@yamt.dyndns.org> on
 >  > source-changes.
 >  
 >  His patch cleared only vlanctl in the first DMA desc on TX,
 >  but I guess all descs should be cleared both on TX and RX.
 >  (though I'm not sure what will happen when only trailing descs
 >   have vlanctl values on TX with multiple descs)

 i was not able to reproduce his problem (scp) even with my patch.
 ie. there is no way to confirm it working without letting him try.

 YAMAMOTO Takashi

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: yamt@mwd.biglobe.ne.jp
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
	pavel.cahyna@st.mff.cuni.cz, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Mon, 20 Nov 2006 22:18:03 +0900

 yamt@mwd.biglobe.ne.jp wrote:

 > >  His patch cleared only vlanctl in the first DMA desc on TX,
 > >  but I guess all descs should be cleared both on TX and RX.
 > >  (though I'm not sure what will happen when only trailing descs
 > >   have vlanctl values on TX with multiple descs)
 > 
 > i was not able to reproduce his problem (scp) even with my patch.
 > ie. there is no way to confirm it working without letting him try.

 It seems reproducible with your patch even by ping(8).

 --- commands on re(4) hosts ---
 # ifconfig re0 192.168.20.4 ip4csum udp4csum tcp4csum
 # ifconfig vlan0 create
 # ifconfig vlan0 vlan 4 vlanif re0
 # ifconfig vlan0 192.168.200.2
 # ping -fn -c 256 192.168.20.28 >& /dev/null
 # ping -fn -c 256 192.168.200.4 >& /dev/null
 # ping -fn -c 8 192.168.20.28 >& /dev/null
 # ping -fn -c 8 -s 1473 192.168.20.28 >& /dev/null
 --- end of commands ---

 --- tcpdump -evn output on 192.168.20.28 aka 192.168.200.4 ---
 21:56:13.219800 00:0d:0b:4b:af:1b > 00:10:e0:00:5e:95, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 60103, offset 0, flags [none], length: 84) 192.168.20.4 > 192.168.20.28: icmp 64: echo request seq 0
 21:56:13.220052 00:10:e0:00:5e:95 > 00:0d:0b:4b:af:1b, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 338, offset 0, flags [none], length: 84) 192.168.20.28 > 192.168.20.4: icmp 64: echo reply seq 0

  :

 21:56:37.540102 00:0d:0b:4b:af:1b > 00:10:e0:00:5e:95, ethertype 802.1Q (0x8100), length 102: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 60360, offset 0, flags [none], length: 84) 192.168.200.2 > 192.168.200.4: icmp 64: echo request seq 0
 21:56:37.540270 00:10:e0:00:5e:95 > 00:0d:0b:4b:af:1b, ethertype 802.1Q (0x8100), length 102: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 601, offset 0, flags [none], length: 84) 192.168.200.4 > 192.168.200.2: icmp 64: echo reply seq 0

  :

 21:57:04.950385 00:0d:0b:4b:af:1b > 00:10:e0:00:5e:95, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 60618, offset 0, flags [none], length: 84) 192.168.20.4 > 192.168.20.28: icmp 64: echo request seq 0
 21:57:04.950638 00:10:e0:00:5e:95 > 00:0d:0b:4b:af:1b, ethertype IPv4 (0x0800), length 98: IP (tos 0x0, ttl 255, id 861, offset 0, flags [none], length: 84) 192.168.20.28 > 192.168.20.4: icmp 64: echo reply seq 0

  :

 21:57:22.539100 00:0d:0b:4b:af:1b > 00:10:e0:00:5e:95, ethertype 802.1Q (0x8100), length 1518: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 60626, offset 0, flags [+], length: 1500) 192.168.20.4 > 192.168.20.28: icmp 1480: echo request seq 0
 21:57:22.539174 00:0d:0b:4b:af:1b > 00:10:e0:00:5e:95, ethertype 802.1Q (0x8100), length 64: vlan 4, p 0, ethertype IPv4, IP (tos 0x0, ttl 255, id 60626, offset 1480, flags [none], length: 21) 192.168.20.4 > 192.168.20.28: icmp
 21:57:22.539615 00:10:e0:00:5e:95 > 00:0d:0b:4b:af:1b, ethertype IPv4 (0x0800), length 1514: IP (tos 0x0, ttl 255, id 870, offset 0, flags [+], length: 1500) 192.168.20.28 > 192.168.20.4: icmp 1480: echo reply seq 0
 21:57:22.539649 00:10:e0:00:5e:95 > 00:0d:0b:4b:af:1b, ethertype IPv4 (0x0800), length 35: IP (tos 0x0, ttl 255, id 870, offset 1480, flags [none], length: 21) 192.168.20.28 > 192.168.20.4: icmp

  :
 --- end of tcpdump ---

 i.e. it looks we have to clear re_vlanctl in all fragmented descs
 since my patch still works fine in this test.
 ---
 Izumi Tsutsui

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: tsutsui@ceres.dti.ne.jp
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
	pavel.cahyna@st.mff.cuni.cz
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Tue, 21 Nov 2006 15:17:34 +0900 (JST)

 > > >  His patch cleared only vlanctl in the first DMA desc on TX,
 > > >  but I guess all descs should be cleared both on TX and RX.
 > > >  (though I'm not sure what will happen when only trailing descs
 > > >   have vlanctl values on TX with multiple descs)
 > > 
 > > i was not able to reproduce his problem (scp) even with my patch.
 > > ie. there is no way to confirm it working without letting him try.
 > 
 > It seems reproducible with your patch even by ping(8).

 > i.e. it looks we have to clear re_vlanctl in all fragmented descs
 > since my patch still works fine in this test.
 > ---
 > Izumi Tsutsui

 hm.  i guess i was not careful enough when testing.
 thanks for confirming.

 YAMAMOTO Takashi

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: pavel@netbsd.org
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Thu, 23 Nov 2006 20:19:46 +0900

 pavel@netbsd.org wrote:

 > yamt suggested something similar, and it did not work for me.
 > see Message-Id: <1147820216.470989.3258.nullmailer@yamt.dyndns.org> on
 > source-changes.

 Could you try to confirm my patch on your environment?
 It isn't the same with yamt's one.
 ---
 Izumi Tsutsui

From: Pavel Cahyna <pavel.cahyna@matfyz.cz>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Thu, 23 Nov 2006 12:24:33 +0100

 >  Could you try to confirm my patch on your environment?

 I'll try. But it will take some time.

State-Changed-From-To: open->feedback
State-Changed-By: tsutsui@netbsd.org
State-Changed-When: Sat, 25 Nov 2006 23:49:43 +0900
State-Changed-Why:
fix provided.


From: Pavel Cahyna <pavel.cahyna@matfyz.cz>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/32643: re(4) has problems with HW VLAN tagging
Date: Fri, 15 Dec 2006 09:29:46 +0100

 >  Could you try to confirm my patch on your environment?
 >  It isn't the same with yamt's one.

 It works fine so far. Thanks.

 Pavel

Responsible-Changed-From-To: kern-bug-people->tsutsui
Responsible-Changed-By: tsutsui@netbsd.org
Responsible-Changed-When: Sat, 16 Dec 2006 11:54:11 +0900
Responsible-Changed-Why:
I've committed fix.


State-Changed-From-To: feedback->closed
State-Changed-By: tsutsui@netbsd.org
State-Changed-When: Sat, 16 Dec 2006 11:54:11 +0900
State-Changed-Why:
Fix confirmed and committed.


From: Izumi Tsutsui <tsutsui@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/32643 CVS commit: src/sys/dev/ic
Date: Sat, 16 Dec 2006 02:52:17 +0000 (UTC)

 Module Name:	src
 Committed By:	tsutsui
 Date:		Sat Dec 16 02:52:17 UTC 2006

 Modified Files:
 	src/sys/dev/ic: rtl8169.c

 Log Message:
 Fix and reenable HW VLAN tagging on re(4):
 - clear re_vlanctl in DMA descriptors before starting TX and RX
   to avoid stale tags
 - use bswap16() rather than be16toh() or htons() on VLAN tag access
   since we already use htole32()

 Closes PR kern/32643 and also fixes HW VLAN tagging on big endian machines.


 To generate a diff of this commit:
 cvs rdiff -r1.73 -r1.74 src/sys/dev/ic/rtl8169.c

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

From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/32643 CVS commit: [netbsd-4] src
Date: Wed, 20 Dec 2006 22:27:58 +0000 (UTC)

 Module Name:	src
 Committed By:	bouyer
 Date:		Wed Dec 20 22:27:57 UTC 2006

 Modified Files:
 	src/share/man/man4 [netbsd-4]: re.4
 	src/sys/dev/ic [netbsd-4]: rtl8169.c

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #283):
 	share/man/man4/re.4: revision 1.11
 	sys/dev/ic/rtl8169.c: revision 1.74
 Fix and reenable HW VLAN tagging on re(4).
 Closes PR kern/32643 and also fixes HW VLAN tagging on big endian machines.


 To generate a diff of this commit:
 cvs rdiff -r1.10 -r1.10.4.1 src/share/man/man4/re.4
 cvs rdiff -r1.72 -r1.72.2.1 src/sys/dev/ic/rtl8169.c

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.