Subject: kern/35041: RealTek 8168B broken.
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <dieter.NetBSD@pandora.be>
List: netbsd-bugs
Date: 11/12/2006 15:05:00
>Number:         35041
>Category:       kern
>Synopsis:       RealTek 8168B broken.
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 12 15:05:00 +0000 2006
>Originator:     dieter roelants
>Release:        NetBSD 4.99.3
>Organization:
>Environment:
System: NetBSD simult.amelgem.be 4.99.3 NetBSD 4.99.3 (GENERIC.MPACPI) #8: Sun Nov 12 11:37:55 CET 2006 dieter@simult.amelgem.be:/build/obj.i386.current/sys/arch/i386/compile/GENERIC.MPACPI i386
Architecture: i386
Machine: i386
re0 at pci3 dev 0 function 0: RealTek 8168B/8111B Gigabit Ethernet
>Description:
	My on-board RealTek 8168B doesn't work anymore in -current.
	Incoming packets are shifted 2 bytes. This is easy to see
	by running tcpdump while trying to get an IP address with
	dhclient:
15:13:13.010463 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:15:f2:d9:18:19, length: 300
15:13:13.017757 20:20:ab:b4:08:00 > f2:d9:18:19:08:00, ethertype Unknown (0x4510)
	
	I had the same problem (PR 33763) a few months ago. It was
	fixed by changing RTK_ETHER_ALIGN on i386 and amd64. This
	fix is still there, but it's now called RE_ETHER_ALIGN (and
	now __NO_STRICT_ALIGNMENT is checked instead of the port).

	It seems that not all instances of RTK_ETHER_ALIGN where
	renamed or maybe the RTK_ETHER_ALIGN definition needs to
	be in the ifdef? I can make my nic work again with the
	patch below. I have no clue if it breaks anything.
>How-To-Repeat:
	Boot a current kernel with this nic.
>Fix:
Index: rtl8169.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v
retrieving revision 1.59
diff -u -r1.59 rtl8169.c
--- rtl8169.c	12 Nov 2006 03:09:37 -0000	1.59
+++ rtl8169.c	12 Nov 2006 14:55:36 -0000
@@ -1044,8 +1044,8 @@
 	 * alignment so that the frame payload is
 	 * longword aligned.
 	 */
-	m->m_len = m->m_pkthdr.len = MCLBYTES - RTK_ETHER_ALIGN;
-	m->m_data += RTK_ETHER_ALIGN;
+	m->m_len = m->m_pkthdr.len = MCLBYTES - RE_ETHER_ALIGN;
+	m->m_data += RE_ETHER_ALIGN;
 
 	rxs = &sc->re_ldata.re_rxsoft[idx];
 	map = rxs->rxs_dmamap;