From nobody@FreeBSD.org  Sun Apr 27 02:03:23 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 06F29106568E
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 27 Apr 2008 02:03:23 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id EA9C18FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 27 Apr 2008 02:03:22 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m3R22oN8058363
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 27 Apr 2008 02:02:50 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m3R22ojp058362;
	Sun, 27 Apr 2008 02:02:50 GMT
	(envelope-from nobody)
Message-Id: <200804270202.m3R22ojp058362@www.freebsd.org>
Date: Sun, 27 Apr 2008 02:02:50 GMT
From: "Peter C. Lai" <cowbert@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [re] Realtek RTL8111C detection and failure
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         123123
>Category:       kern
>Synopsis:       [re] [patch] Realtek RTL8111C detection and failure
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 27 02:10:01 UTC 2008
>Closed-Date:    Mon Feb 09 11:59:14 UTC 2009
>Last-Modified:  Mon Feb 09 11:59:14 UTC 2009
>Originator:     Peter C. Lai
>Release:        7.0-RELEASE
>Organization:
Hyperfine Informatics Enterprises
>Environment:
FreeBSD chemokine.mcb.uconn.edu 7.0-RELEASE FreeBSD 7.0-RELEASE #2: Sat Apr 26 20:51:10 UTC 2008 root@chemokine.mcb.uconn.edu:/usr/obj/usr/src/sys/COWBERT i386
>Description:
New motherboards (i.e. Gigabyte GA-G31M-S2L) now ship with RealTek RTL8111C PCI-E gigE NICs. These aren't currently picked up by the re(4) driver.

With pciconf -lv:

none0@pci0:2:0:0: class=0x020000 card=0xe0001458 chip=0x816810ec rev=0x02 hdr=0x00
vendor = 'Realtek Semiconductor'
device = 'RTL8168/8111 PCI-E Gigabit Ethernet NIC'
class = network
subclass = ethernet

After a multihour google hunt, I was able to find the appropriate HWREV string from a netbsd mailing list (see http://archive.netbsd.se/?ml=netbsd-tech-net&a=2008-03&m=6632278). I patched sys/pci/if_rlreg.h to define an 8168 card with HWREV of 0x3c000000 and added this constant to sys/dev/re/if_re.c underneath the other RL_HWREV_8168_* entries.

re(4) now sees the card, and it can detect link level changes (properly detects no carrier vs. link up), but it cannot seem to set media type correctly and will not read the station ID (MAC Address) from the EEPROM properly.

relevant post-patch dmesg segment:
dmesg --snip--

pci2: <ACPI PCI bus> on pcib2
pci2: domain=0, physical bus=2
found->	vendor=0x10ec, dev=0x8168, revid=0x02
	domain=0, bus=2, slot=0, func=0
	class=02-00-00, hdrtype=0x00, mfdev=0
	cmdreg=0x0007, statreg=0x0010, cachelnsz=8 (dwords)
	lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
	intpin=a, irq=10
	powerspec 3  supports D0 D1 D2 D3  current D0
	MSI supports 2 messages, 64 bit
	MSI-X supports 2 messages in map 0x20
	map[10]: type I/O Port, range 32, base 0xd000, size  8, enabled
pcib2: requested I/O range 0xd000-0xd0ff: in range
	map[18]: type Prefetchable Memory, range 64, base 0xe1110000, size 12, enabled
pcib2: requested memory range 0xe1110000-0xe1110fff: good
	map[20]: type Prefetchable Memory, range 64, base 0xe1100000, size 16, enabled
pcib2: requested memory range 0xe1100000-0xe110ffff: good
pcib2: matched entry for 2.0.INTA
pcib2: slot 0 INTA hardwired to IRQ 17
re0: Reserved 0x100 bytes for rid 0x10 type 4 at 0xd000
pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
re0: <RealTek 8168/8111C PCIe Gigabit Ethernet> port 0xd000-0xd0ff mem 0xe1110000-0xe1110fff,0xe1100000-0xe110ffff irq 17 at device 0.0 on pci2
pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
re0: MSI count : 2
re0: attempting to allocate 2 MSI vectors (2 supported)
msi: routing MSI IRQ 256 to vector 50
msi: routing MSI IRQ 257 to vector 51
re0: using IRQs 256-257 for MSI
re0: Using 2 MSI messages
miibus0: <MII bus> on re0
rgephy0: <RTL8169S/8110S/8211B media interface> PHY 1 on miibus0
rgephy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
re0: bpf attached
re0: [MPSAFE]
re0: [FILTER]
re0: [MPSAFE]
re0: [FILTER]

dmesg -- snip --

ifconfig
re0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
	ether 00:00:00:00:00:00
	media: Ethernet 100baseTX (10baseT/UTP <half-duplex>)
	status: active

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- sys/pci/if_rlreg.h.dist	2007-12-15 02:57:18.000000000 +0000
+++ sys/pci/if_rlreg.h	2008-04-26 20:34:32.000000000 +0000
@@ -153,6 +153,7 @@
 #define RL_HWREV_8169_8110SB	0x10000000
 #define RL_HWREV_8169_8110SC	0x18000000
 #define RL_HWREV_8168_SPIN1	0x30000000
+#define RL_HWREV_8168_8111C	0x3c000000
 #define RL_HWREV_8100E		0x30800000
 #define RL_HWREV_8101E		0x34000000
 #define RL_HWREV_8168_SPIN2	0x38000000
--- sys/dev/re/if_re.c.dist	2007-12-15 02:57:18.000000000 +0000
+++ sys/dev/re/if_re.c	2008-04-26 13:23:25.000000000 +0000
@@ -184,6 +184,8 @@
 		"RealTek 8168/8111B PCIe Gigabit Ethernet" },
 	{ RT_VENDORID, RT_DEVICEID_8168, RL_HWREV_8168_SPIN3,
 		"RealTek 8168/8111B PCIe Gigabit Ethernet" },
+	{ RT_VENDORID, RT_DEVICEID_8168, RL_HWREV_8168_8111C,
+		"RealTek 8168/8111C PCIe Gigabit Ethernet"},
 	{ RT_VENDORID, RT_DEVICEID_8169, RL_HWREV_8169,
 		"RealTek 8169 Gigabit Ethernet" },
 	{ RT_VENDORID, RT_DEVICEID_8169, RL_HWREV_8169S,
@@ -226,6 +228,7 @@
 	{ RL_HWREV_8101E, RL_8169, "8101E"},
 	{ RL_HWREV_8168_SPIN2, RL_8169, "8168"},
 	{ RL_HWREV_8168_SPIN3, RL_8169, "8168"},
+	{ RL_HWREV_8168_8111C, RL_8169, "8168"},
 	{ 0, 0, NULL }
 };
 
@@ -692,6 +695,7 @@
 	case RL_HWREV_8168_SPIN1:
 	case RL_HWREV_8168_SPIN2:
 	case RL_HWREV_8168_SPIN3:
+	case RL_HWREV_8168_8111C:
 		CSR_WRITE_4(sc, RL_MAR0, bswap32(hashes[1]));
 		CSR_WRITE_4(sc, RL_MAR4, bswap32(hashes[0]));
 		break;
@@ -1330,6 +1334,7 @@
 			case RL_HWREV_8169_8110SC:
 			case RL_HWREV_8168_SPIN2:
 			case RL_HWREV_8168_SPIN3:
+			case RL_HWREV_8168_8111C:
 				re_gmii_writereg(dev, 1, 0x1f, 0);
 				re_gmii_writereg(dev, 1, 0x0e, 0);
 				break;


>Release-Note:
>Audit-Trail:

From: "Peter Lai" <cowbert@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/123123: [re] Realtek RTL8111C detection and failure
Date: Sat, 26 Apr 2008 22:40:15 -0400

 Ok now I'm running into the same problem post-reboot as Quan Qiu did
 back in November 2007. See
 http://docs.freebsd.org/cgi/getmsg.cgi?fetch=94551+0+/usr/local/www/db/text/2007/freebsd-current/20071125.freebsd-current
 
 re0: Reserved 0x100 bytes for rid 0x10 type 4 at 0xd000
 pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
 pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
 pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
 pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
 pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
 pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
 pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
 re0: <RealTek 8168/8111C PCIe Gigabit Ethernet> port 0xd000-0xd0ff mem
 0xe1110000-0xe1110fff,0xe1100000-0xe110ffff irq 17 at device 0.0 on
 pci2
 pcib2: re0 requested I/O range 0xd000-0xd0ff: in range
 re0: MSI count : 2
 re0: attempting to allocate 2 MSI vectors (2 supported)
 msi: routing MSI IRQ 256 to vector 50
 msi: routing MSI IRQ 257 to vector 51
 re0: using IRQs 256-257 for MSI
 re0: Using 2 MSI messages
 re0: MII without any phy!
 device_attach: re0 attach returned 6
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Mon Apr 28 20:49:41 UTC 2008 
Responsible-Changed-Why:  

this is looking like a PHY problem. 
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123123 
Responsible-Changed-From-To: freebsd-net->rpaulo 
Responsible-Changed-By: rpaulo 
Responsible-Changed-When: Wed May 21 10:36:18 UTC 2008 
Responsible-Changed-Why:  
I'm working on a patch since NetBSD seems to support this card. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123123 

From: Rui Paulo <rpaulo@fnop.net>
To: bug-followup@FreeBSD.org, cowbert@gmail.com
Cc:  
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Wed, 21 May 2008 12:37:59 +0100

 This is a multi-part message in MIME format.
 --------------020309070502040802020800
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Hi,
 The attached patch should fix the MAC detection problem.
 I don't know about the rest. Could you please test it?
 
 Thanks,
 -- 
 Rui Paulo
 
 --------------020309070502040802020800
 Content-Type: text/plain;
  name="patch.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="patch.txt"
 
 Index: pci/if_rlreg.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/pci/if_rlreg.h,v
 retrieving revision 1.74
 diff -u -p -r1.74 if_rlreg.h
 --- pci/if_rlreg.h	31 Mar 2008 04:03:14 -0000	1.74
 +++ pci/if_rlreg.h	20 May 2008 18:52:36 -0000
 @@ -157,6 +157,7 @@
  #define RL_HWREV_8169_8110SB	0x10000000
  #define RL_HWREV_8169_8110SC	0x18000000
  #define RL_HWREV_8168_SPIN1	0x30000000
 +#define RL_HWREV_8168_8111C	0x3c000000
  #define RL_HWREV_8100E		0x30800000
  #define RL_HWREV_8101E		0x34000000
  #define RL_HWREV_8168_SPIN2	0x38000000
 Index: dev/re/if_re.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/re/if_re.c,v
 retrieving revision 1.114
 diff -u -p -r1.114 if_re.c
 --- dev/re/if_re.c	15 Apr 2008 00:46:15 -0000	1.114
 +++ dev/re/if_re.c	20 May 2008 18:55:05 -0000
 @@ -184,6 +184,8 @@ static struct rl_type re_devs[] = {
  		"RealTek 8168/8111B PCIe Gigabit Ethernet" },
  	{ RT_VENDORID, RT_DEVICEID_8168, RL_HWREV_8168_SPIN3,
  		"RealTek 8168/8111B PCIe Gigabit Ethernet" },
 +	{ RT_VENDORID, RT_DEVICEID_8168, RL_HWREV_8168_8111C,
 +		"RealTek 8168/8111C PCIe Gigabit Ethernet"},
  	{ RT_VENDORID, RT_DEVICEID_8169, RL_HWREV_8169,
  		"RealTek 8169 Gigabit Ethernet" },
  	{ RT_VENDORID, RT_DEVICEID_8169, RL_HWREV_8169S,
 @@ -225,6 +227,7 @@ static struct rl_hwrev re_hwrevs[] = {
  	{ RL_HWREV_8101E, RL_8169, "8101E"},
  	{ RL_HWREV_8168_SPIN2, RL_8169, "8168"},
  	{ RL_HWREV_8168_SPIN3, RL_8169, "8168"},
 +	{ RL_HWREV_8168_8111C, RL_8169, "8168"},
  	{ 0, 0, NULL }
  };
  
 @@ -697,6 +700,7 @@ re_setmulti(sc)
  	case RL_HWREV_8168_SPIN1:
  	case RL_HWREV_8168_SPIN2:
  	case RL_HWREV_8168_SPIN3:
 +	case RL_HWREV_8168_8111C:
  		CSR_WRITE_4(sc, RL_MAR0, bswap32(hashes[1]));
  		CSR_WRITE_4(sc, RL_MAR4, bswap32(hashes[0]));
  		break;
 @@ -1246,12 +1250,21 @@ re_attach(dev)
  	        sc->rl_eewidth = RL_9346_ADDR_LEN;
  
  	/*
 -	 * Get station address from the EEPROM.
 +	 * Get station address from ID registers.
  	 */
 -	re_read_eeprom(sc, (caddr_t)as, RL_EE_EADDR, 3);
 -	for (i = 0; i < ETHER_ADDR_LEN / 2; i++)
 -		as[i] = le16toh(as[i]);
 -	bcopy(as, eaddr, sizeof(eaddr));
 +	if (hwrev == RL_HWREV_8168_8111C) {
 +		device_printf(dev, "reading stations address\n");
 +		for (i = 0; i < ETHER_ADDR_LEN; i++)
 +			eaddr[i] = CSR_READ_1(sc, RL_IDR0 + i);
 +	} else {
 +		/*
 +		 * Get station address from the EEPROM.
 +		 */
 +		re_read_eeprom(sc, (caddr_t)as, RL_EE_EADDR, 3);
 +		for (i = 0; i < ETHER_ADDR_LEN / 2; i++)
 +			as[i] = le16toh(as[i]);
 +		bcopy(as, eaddr, sizeof(eaddr));
 +	}
  
  	if (sc->rl_type == RL_8169) {
  		/* Set RX length mask and number of descriptors. */
 @@ -1305,6 +1318,7 @@ re_attach(dev)
  			case RL_HWREV_8169_8110SC:
  			case RL_HWREV_8168_SPIN2:
  			case RL_HWREV_8168_SPIN3:
 +			case RL_HWREV_8168_8111C:
  				re_gmii_writereg(dev, 1, 0x1f, 0);
  				re_gmii_writereg(dev, 1, 0x0e, 0);
  				break;
 
 --------------020309070502040802020800--

From: Venture37 <venture37@geeklan.co.uk>
To: bug-followup@FreeBSD.org, cowbert@gmail.com, rpaulo@fnop.net
Cc:  
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Fri, 30 May 2008 03:18:22 +0100

 I have the same issue with my Dell Vostro 1310
 after applying the patch above & recompiling a new kernel I need to boot 
 the system with a ethernet cable attached otherwise the kernel winges about
 re0: MII without any phy
 
 you need to specify -rxcsum -txcsum to disable the hardware offloading 
 otherwise it wont work, tcpdump shows checksum errors.
 Once the card is configured & up there are the watchdog timeout errors!
 

From: "Peter Lai" <cowbert@gmail.com>
To: Venture37 <venture37@geeklan.co.uk>
Cc: bug-followup@freebsd.org, rpaulo@fnop.net
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Thu, 29 May 2008 23:06:41 -0400

 I am currently working with yongari@ on re(4).
 Please stay tuned.
 
 If you are itching for something new, cvsup to -STABLE and apply
 http://people.freebsd.org/~yongari/re/re.HEAD.20080528
 
 The watchdog timeouts are caused by a previous version of the above
 patch not working with TSO4, which is one of the issues we are trying
 to address with 20080528 right now (among some other stuff).
 
 On Thu, May 29, 2008 at 10:18 PM, Venture37 <venture37@geeklan.co.uk> wrote:
 > I have the same issue with my Dell Vostro 1310
 > after applying the patch above & recompiling a new kernel I need to boot the
 > system with a ethernet cable attached otherwise the kernel winges about
 > re0: MII without any phy
 >
 > you need to specify -rxcsum -txcsum to disable the hardware offloading
 > otherwise it wont work, tcpdump shows checksum errors.
 > Once the card is configured & up there are the watchdog timeout errors!
 >
 >

From: Venture37 <venture37@geeklan.co.uk>
To: bug-followup@FreeBSD.org, cowbert@gmail.com
Cc:  
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Fri, 30 May 2008 16:53:16 +0100

 I installed the i386 200805 snapshot of STABLE, updated src via cvsup, 
 applied the patch & attempted to build a new kernel
 the build process bombs out with:
 
 cc -c -O -pipe  -std=c99 -g -Wall -Wredundant-decls -Wnested-externs 
 -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline 
 -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -nostdinc 
 -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL 
 -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
 -finline-limit=8000 --param inline-unit-growth=100 --param 
 large-function-growth=1000  -mno-align-long-strings 
 -mpreferred-stack-boundary=2  -mno-mmx -mno-3dnow -mno-sse -mno-sse2 
 -mno-sse3 -ffreestanding -Werror  /usr/src/sys/dev/re/if_re.c
 
 /usr/src/sys/dev/re/if_re.c: In function 're_attach':
 
 /usr/src/sys/dev/re/if_re.c:1308: error: 'offset' undeclared (first use 
 in this function)
 
 /usr/src/sys/dev/re/if_re.c:1308: error: (Each undeclared identifier is 
 reported only once
 
 /usr/src/sys/dev/re/if_re.c:1308: error: for each function it appears in.)
 
 cc1: warnings being treated as errors
 
 /usr/src/sys/dev/re/if_re.c:1305: warning: unused variable 'offet'
 *** Error code 1
 
 
 
 Stop in /usr/obj/usr/src/sys/GENERIC.
 
 *** Error code 1
 
 
 
 Stop in /usr/src.
 
 *** Error code 1
 
 
 
 Stop in /usr/src.

From: Venture37 <venture37@geeklan.co.uk>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Fri, 30 May 2008 17:01:45 +0100

 snippet of pciconf -lv from the kernel built using the 1st patch
 
 re0@pci0:7:0:0:	class=0x020000 card=0x026f1028 chip=0x816810ec rev=0x02 
 hdr=0x00
      vendor     = 'Realtek Semiconductor'
      device     = 'RTL8168/8111 PCI-E Gigabit Ethernet NIC'
      class      = network
      subclass   = ethernet
 

From: "Peter Lai" <cowbert@gmail.com>
To: Venture37 <venture37@geeklan.co.uk>
Cc: bug-followup@freebsd.org
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Fri, 30 May 2008 13:37:46 -0400

 This is a due to a typo in the patch. After patching, run
 /usr/src/sys/dev/re/if_re.c through sed -i bak -e 's/offet/offset/'
 (or sed the patch itself :)
 
 WIth this patch TSO is still broken so you will have to run it
 ifconfig re0 -tso for now.
 
 HTH
 
 On Fri, May 30, 2008 at 11:53 AM, Venture37 <venture37@geeklan.co.uk> wrote:
 > I installed the i386 200805 snapshot of STABLE, updated src via cvsup,
 > applied the patch & attempted to build a new kernel
 > the build process bombs out with:
 >
 > cc -c -O -pipe  -std=c99 -g -Wall -Wredundant-decls -Wnested-externs
 > -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline
 > -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -nostdinc -I.
 > -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL
 > -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common
 > -finline-limit=8000 --param inline-unit-growth=100 --param
 > large-function-growth=1000  -mno-align-long-strings
 > -mpreferred-stack-boundary=2  -mno-mmx -mno-3dnow -mno-sse -mno-sse2
 > -mno-sse3 -ffreestanding -Werror  /usr/src/sys/dev/re/if_re.c
 >
 > /usr/src/sys/dev/re/if_re.c: In function 're_attach':
 >
 > /usr/src/sys/dev/re/if_re.c:1308: error: 'offset' undeclared (first use in
 > this function)
 >
 > /usr/src/sys/dev/re/if_re.c:1308: error: (Each undeclared identifier is
 > reported only once
 >
 > /usr/src/sys/dev/re/if_re.c:1308: error: for each function it appears in.)
 >
 > cc1: warnings being treated as errors
 >
 > /usr/src/sys/dev/re/if_re.c:1305: warning: unused variable 'offet'
 > *** Error code 1
 >
 >
 >
 > Stop in /usr/obj/usr/src/sys/GENERIC.
 >
 > *** Error code 1
 >
 >
 >
 > Stop in /usr/src.
 >
 > *** Error code 1
 >
 >
 >
 > Stop in /usr/src.
 >

From: "Peter Lai" <cowbert@gmail.com>
To: Venture37 <venture37@geeklan.co.uk>, mm@freebsd.org
Cc: bug-followup@freebsd.org
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Thu, 5 Jun 2008 09:59:23 -0400

 http://people.freebsd.org/~yongari/re/re.HEAD.20080531
 yongari@ is about to commit it so please test for functionality.
 Ignore VPD address access nops for now (see explanation below).
 
 For mm@ : This is the most current patch for new RTL8168 cards
 (specifically chip id 0x3c000000 revid 0x02). In it, TSO4 has been
 disabled by default, since there is apparently some register magic
 that nobody seems to be able to resolve at this time to get that
 working. The rest of the card does appear to work (well at least it
 passes traffic ok otherwise :).
 
 Features untested by me (card passes packets in normal environments
 that don't contain these packet types, so if you can stick the card
 into environments that *do* contain these packets that would be
 great):
 VLAN_MTU
 VLAN_HWTAGGING
 VLAN_HWCSUM
 WOL_UCAST
 WOL_MCAST
 WOL_MAGIC

From: Martin Matuska <mm@FreeBSD.org>
To: bug-followup@FreeBSD.org, cowbert@gmail.com
Cc:  
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Thu, 05 Jun 2008 16:39:41 +0200

 re0@pci0:3:0:0: class=0x020000 card=0x82c61043 chip=0x816810ec rev=0x02 
 hdr=0x00
     vendor     = 'Realtek Semiconductor'
     device     = 'RTL8168/8111 PCI-E Gigabit Ethernet NIC'
     class      = network
     subclass   = ethernet
 
 Here is what is written on the chip:
 Realtek RTL8111C
 7C690Q1 G801B

From: Venture37 <venture37@geeklan.co.uk>
To: Peter Lai <cowbert@gmail.com>
Cc: mm@freebsd.org, bug-followup@freebsd.org
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Tue, 17 Jun 2008 00:10:28 +0100

 I updated my sources last night & rolled a new kernel after reapplying 
 the patch to src, the system now hangs after re0 is detected.
 
 

From: "Peter Lai" <cowbert@gmail.com>
To: Venture37 <venture37@geeklan.co.uk>, pyunyh@gmail.com, 
	"Rui Paulo" <rpaulo@fnop.net>
Cc: mm@freebsd.org, bug-followup@freebsd.org
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Tue, 17 Jun 2008 04:07:38 -0400

 I also noticed this, however it doesn't hang if you select option 5
 during the boot (option 5 being the verbosity option). Perhaps this
 has something to do with the broken VPD register access, or ACPI or
 something.
 
 I no longer have a box with this hardware in it, so I am unavailable
 to test anymore.
 
 On Mon, Jun 16, 2008 at 7:10 PM, Venture37 <venture37@geeklan.co.uk> wrote:
 > I updated my sources last night & rolled a new kernel after reapplying the
 > patch to src, the system now hangs after re0 is detected.
 >
 >
 >

From: Venture37 <venture37@geeklan.co.uk>
To: Peter Lai <cowbert@gmail.com>
Cc: pyunyh@gmail.com, Rui Paulo <rpaulo@fnop.net>, mm@freebsd.org,
        bug-followup@freebsd.org
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Wed, 18 Jun 2008 05:18:29 +0100

 Actually, the system still hangs when using option 5 for verbose output 
 when booting. :(
Responsible-Changed-From-To: rpaulo->yongari 
Responsible-Changed-By: rpaulo 
Responsible-Changed-When: Mon Jul 7 11:47:26 UTC 2008 
Responsible-Changed-Why:  
Pyun committed a new version of the re driver. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123123 
State-Changed-From-To: open->feedback 
State-Changed-By: rpaulo 
State-Changed-When: Mon Jul 7 11:50:12 UTC 2008 
State-Changed-Why:  
Please test the new re driver. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123123 

From: Jaroslav Pavlicek <jara@pavrda.cz>
To: bug-followup@FreeBSD.org, cowbert@gmail.com
Cc:  
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Mon, 11 Aug 2008 19:48:23 +0200

 Hi!
 After downloading latest driver sources
 if_re.c (Revision 1.95.2.34)
 rl_reg.h (Revision 1.67.2.14)
 the problem persists:
 
 re0: <RealTek 8168/8168B/8168C/8168CP/8111B/8111C/8111CP PCIe Gigabit 
 Ethernet> port 0xe800-0xe8ff mem 
 0xeefff000-0xeeffffff,0xefff0000-0xefffffff irq 16 at device 0.0 on pci2
 re0: Chip rev. 0x3c000000
 re0: MAC rev. 0x00200000
 re0: PHY write failed
 re0: PHY write failed
 re0: MII without any phy!
 
  > ifconfig re0
 ifconfig: interface re0 does not exist
 
 May I help somehow?
 
 --- Jaroslav
 

From: Pyun YongHyeon <pyunyh@gmail.com>
To: Jaroslav Pavlicek <jara@pavrda.cz>
Cc: yongari@FreeBSD.org, bug-followup@FreeBSD.org
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Tue, 12 Aug 2008 17:21:46 +0900

 On Mon, Aug 11, 2008 at 06:10:08PM +0000, Jaroslav Pavlicek wrote:
  > The following reply was made to PR kern/123123; it has been noted by GNATS.
  > 
  > From: Jaroslav Pavlicek <jara@pavrda.cz>
  > To: bug-followup@FreeBSD.org, cowbert@gmail.com
  > Cc:  
  > Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
  > Date: Mon, 11 Aug 2008 19:48:23 +0200
  > 
  >  Hi!
  >  After downloading latest driver sources
  >  if_re.c (Revision 1.95.2.34)
  >  rl_reg.h (Revision 1.67.2.14)
  >  the problem persists:
  >  
  >  re0: <RealTek 8168/8168B/8168C/8168CP/8111B/8111C/8111CP PCIe Gigabit 
  >  Ethernet> port 0xe800-0xe8ff mem 
  >  0xeefff000-0xeeffffff,0xefff0000-0xefffffff irq 16 at device 0.0 on pci2
  >  re0: Chip rev. 0x3c000000
  >  re0: MAC rev. 0x00200000
  >  re0: PHY write failed
  >  re0: PHY write failed
  >  re0: MII without any phy!
  >  
  >   > ifconfig re0
  >  ifconfig: interface re0 does not exist
  >  
  >  May I help somehow?
  >  
 
 I know this issue which seems to happen on second generation of
 RTL8168/8111. I guess it might be related with power-saving
 feature of hardware. Unfortunately I have no fix for this issue.
 Several users reported multiple rebooting fixed the issue.
 
  >  --- Jaroslav
  >  
 
 -- 
 Regards,
 Pyun YongHyeon

From: Pyun YongHyeon <pyunyh@gmail.com>
To: Jaroslav Pavlicek <jara@pavrda.cz>
Cc: yongari@FreeBSD.org, bug-followup@FreeBSD.org
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Thu, 11 Dec 2008 16:19:33 +0900

 On Tue, Aug 12, 2008 at 05:21:46PM +0900, To Jaroslav Pavlicek wrote:
  > On Mon, Aug 11, 2008 at 06:10:08PM +0000, Jaroslav Pavlicek wrote:
  >  > The following reply was made to PR kern/123123; it has been noted by GNATS.
  >  > 
  >  > From: Jaroslav Pavlicek <jara@pavrda.cz>
  >  > To: bug-followup@FreeBSD.org, cowbert@gmail.com
  >  > Cc:  
  >  > Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
  >  > Date: Mon, 11 Aug 2008 19:48:23 +0200
  >  > 
  >  >  Hi!
  >  >  After downloading latest driver sources
  >  >  if_re.c (Revision 1.95.2.34)
  >  >  rl_reg.h (Revision 1.67.2.14)
  >  >  the problem persists:
  >  >  
  >  >  re0: <RealTek 8168/8168B/8168C/8168CP/8111B/8111C/8111CP PCIe Gigabit 
  >  >  Ethernet> port 0xe800-0xe8ff mem 
  >  >  0xeefff000-0xeeffffff,0xefff0000-0xefffffff irq 16 at device 0.0 on pci2
  >  >  re0: Chip rev. 0x3c000000
  >  >  re0: MAC rev. 0x00200000
  >  >  re0: PHY write failed
  >  >  re0: PHY write failed
  >  >  re0: MII without any phy!
  >  >  
  >  >   > ifconfig re0
  >  >  ifconfig: interface re0 does not exist
  >  >  
  >  >  May I help somehow?
  >  >  
  > 
  > I know this issue which seems to happen on second generation of
  > RTL8168/8111. I guess it might be related with power-saving
  > feature of hardware. Unfortunately I have no fix for this issue.
  > Several users reported multiple rebooting fixed the issue.
  > 
 
 If you're running 7.1-PRERELEASE or 7.1-RC1 would you try
 re(4) in HEAD and apply the patch at the following URL?
 To get the re(4) of HEAD you may have to get fowlloing files
 from HEAD.
 http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/re/if_re.c
 http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/pci/if_rlreg.h
 http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/pci/if_rl.c
 
 Select latest revision of the files and then apply patch at
 the following URL.
 http://people.freebsd.org/~yongari/re/re.8168C.sleep.patch
 
 -- 
 Regards,
 Pyun YongHyeon

From: Jaroslav Pavlicek <jara@pavrda.cz>
To: pyunyh@gmail.com
Cc: yongari@FreeBSD.org, bug-followup@FreeBSD.org
Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
Date: Thu, 11 Dec 2008 22:21:03 +0100

 Hi!
 
 Thank you for the provided patch. I tested it and cad detection seems to
 work nice:
 
 re0: <RealTek 8168/8168B/8168C/8168CP/8168D/8111B/8111C/8111CP PCIe
 Gigabit Ethernet> port 0xe800-0xe8ff mem
 0xeefff000-0xeeffffff,0xefff0000-0xefffffff irq 16 at device 0.0 on pci2
 re0: Chip rev. 0x3c000000
 re0: MAC rev. 0x00200000
 miibus0: <MII bus> on re0
 rgephy0: <RTL8169S/8110S/8211B media interface> PHY 1 on miibus0
 rgephy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT,
 1000baseT-FDX, auto
 re0: Ethernet address: 00:1d:60:c9:6c:05
 re0: [FILTER]
 
 I have no access to machine now, so I restarted it 3 times and checked
 the interface re0 was detected. I did no complete shutdown of the server.
 
 I also didn't test data transfers yet, I will do it next week and I will
 let You know.
 
 --- Jaroslav
 
 
 Pyun YongHyeon wrote:
 > On Tue, Aug 12, 2008 at 05:21:46PM +0900, To Jaroslav Pavlicek wrote:
 >  > On Mon, Aug 11, 2008 at 06:10:08PM +0000, Jaroslav Pavlicek wrote:
 >  >  > The following reply was made to PR kern/123123; it has been noted by GNATS.
 >  >  > 
 >  >  > From: Jaroslav Pavlicek <jara@pavrda.cz>
 >  >  > To: bug-followup@FreeBSD.org, cowbert@gmail.com
 >  >  > Cc:  
 >  >  > Subject: Re: kern/123123: [re][patch] Realtek RTL8111C detection and failure
 >  >  > Date: Mon, 11 Aug 2008 19:48:23 +0200
 >  >  > 
 >  >  >  Hi!
 >  >  >  After downloading latest driver sources
 >  >  >  if_re.c (Revision 1.95.2.34)
 >  >  >  rl_reg.h (Revision 1.67.2.14)
 >  >  >  the problem persists:
 >  >  >  
 >  >  >  re0: <RealTek 8168/8168B/8168C/8168CP/8111B/8111C/8111CP PCIe Gigabit 
 >  >  >  Ethernet> port 0xe800-0xe8ff mem 
 >  >  >  0xeefff000-0xeeffffff,0xefff0000-0xefffffff irq 16 at device 0.0 on pci2
 >  >  >  re0: Chip rev. 0x3c000000
 >  >  >  re0: MAC rev. 0x00200000
 >  >  >  re0: PHY write failed
 >  >  >  re0: PHY write failed
 >  >  >  re0: MII without any phy!
 >  >  >  
 >  >  >   > ifconfig re0
 >  >  >  ifconfig: interface re0 does not exist
 >  >  >  
 >  >  >  May I help somehow?
 >  >  >  
 >  > 
 >  > I know this issue which seems to happen on second generation of
 >  > RTL8168/8111. I guess it might be related with power-saving
 >  > feature of hardware. Unfortunately I have no fix for this issue.
 >  > Several users reported multiple rebooting fixed the issue.
 >  > 
 > 
 > If you're running 7.1-PRERELEASE or 7.1-RC1 would you try
 > re(4) in HEAD and apply the patch at the following URL?
 > To get the re(4) of HEAD you may have to get fowlloing files
 > from HEAD.
 > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/re/if_re.c
 > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/pci/if_rlreg.h
 > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/pci/if_rl.c
 > 
 > Select latest revision of the files and then apply patch at
 > the following URL.
 > http://people.freebsd.org/~yongari/re/re.8168C.sleep.patch
 > 
State-Changed-From-To: feedback->patched 
State-Changed-By: yongari 
State-Changed-When: Wed Dec 17 07:24:25 UTC 2008 
State-Changed-Why:  
Thanks for testing! Patch committed to HEAD(SVN r186210). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123123 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/123123: commit references a PR
Date: Mon,  9 Feb 2009 01:30:25 +0000 (UTC)

 Author: yongari
 Date: Mon Feb  9 01:30:14 2009
 New Revision: 188358
 URL: http://svn.freebsd.org/changeset/base/188358
 
 Log:
   MFC r186210:
     For RTL8168C SPIN2 controllers, make sure to take the controller
     out of sleep mode prior to accessing to PHY. This should fix device
     attach failure seen on these controllers. Also enable the sleep
     mode when device is put into sleep state.
   
     PR:	kern/123123, kern/123053
 
 Modified:
   stable/7/sys/   (props changed)
   stable/7/sys/contrib/pf/   (props changed)
   stable/7/sys/dev/cxgb/   (props changed)
   stable/7/sys/dev/re/if_re.c
   stable/7/sys/pci/if_rlreg.h
 
 Modified: stable/7/sys/dev/re/if_re.c
 ==============================================================================
 --- stable/7/sys/dev/re/if_re.c	Mon Feb  9 01:26:31 2009	(r188357)
 +++ stable/7/sys/dev/re/if_re.c	Mon Feb  9 01:30:14 2009	(r188358)
 @@ -1262,8 +1262,13 @@ re_attach(device_t dev)
  		sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE |
  		    RL_FLAG_MACSTAT;
  		break;
 -	case RL_HWREV_8168C:
  	case RL_HWREV_8168C_SPIN2:
 +		sc->rl_flags |= RL_FLAG_MACSLEEP;
 +		/* FALLTHROUGH */
 +	case RL_HWREV_8168C:
 +		if ((hwrev & 0x00700000) == 0x00200000)
 +			sc->rl_flags |= RL_FLAG_MACSLEEP;
 +		/* FALLTHROUGH */
  	case RL_HWREV_8168CP:
  	case RL_HWREV_8168D:
  		sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE |
 @@ -1351,6 +1356,16 @@ re_attach(device_t dev)
  		goto fail;
  	}
  
 +	/* Take controller out of deep sleep mode. */
 +	if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) {
 +		if ((CSR_READ_1(sc, RL_MACDBG) & 0x80) == 0x80)
 +			CSR_WRITE_1(sc, RL_GPIO,
 +			    CSR_READ_1(sc, RL_GPIO) | 0x01);
 +		else
 +			CSR_WRITE_1(sc, RL_GPIO,
 +			    CSR_READ_1(sc, RL_GPIO) & ~0x01);
 +	}
 +
  	/* Take PHY out of power down mode. */
  	if ((sc->rl_flags & RL_FLAG_PHYWAKE) != 0) {
  		re_gmii_writereg(dev, 1, 0x1f, 0);
 @@ -2963,6 +2978,12 @@ re_resume(device_t dev)
  	RL_LOCK(sc);
  
  	ifp = sc->rl_ifp;
 +	/* Take controller out of sleep mode. */
 +	if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) {
 +		if ((CSR_READ_1(sc, RL_MACDBG) & 0x80) == 0x80)
 +			CSR_WRITE_1(sc, RL_GPIO,
 +			    CSR_READ_1(sc, RL_GPIO) | 0x01);
 +	}
  
  	/* reinitialize interface if necessary */
  	if (ifp->if_flags & IFF_UP)
 @@ -3018,6 +3039,12 @@ re_setwol(struct rl_softc *sc)
  		return;
  
  	ifp = sc->rl_ifp;
 +	/* Put controller into sleep mode. */
 +	if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) {
 +		if ((CSR_READ_1(sc, RL_MACDBG) & 0x80) == 0x80)
 +			CSR_WRITE_1(sc, RL_GPIO,
 +			    CSR_READ_1(sc, RL_GPIO) & ~0x01);
 +	}
  	if ((ifp->if_capenable & IFCAP_WOL) != 0 &&
  	    (sc->rl_flags & RL_FLAG_WOLRXENB) != 0)
  		CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_RX_ENB);
 
 Modified: stable/7/sys/pci/if_rlreg.h
 ==============================================================================
 --- stable/7/sys/pci/if_rlreg.h	Mon Feb  9 01:26:31 2009	(r188357)
 +++ stable/7/sys/pci/if_rlreg.h	Mon Feb  9 01:30:14 2009	(r188358)
 @@ -131,6 +131,8 @@
  #define RL_TBI_ANAR		0x0068
  #define RL_TBI_LPAR		0x006A
  #define RL_GMEDIASTAT		0x006C	/* 8 bits */
 +#define RL_MACDBG		0x006D	/* 8 bits, 8168C SPIN2 only */
 +#define RL_GPIO			0x006E	/* 8 bits, 8168C SPIN2 only */
  #define RL_MAXRXPKTLEN		0x00DA	/* 16 bits, chip multiplies by 8 */
  #define RL_GTXSTART		0x0038	/* 8 bits */
  
 @@ -861,6 +863,7 @@ struct rl_softc {
  #define	RL_FLAG_PHY8169		0x0400
  #define	RL_FLAG_PHY8110S	0x0800
  #define	RL_FLAG_WOLRXENB	0x1000
 +#define	RL_FLAG_MACSLEEP	0x2000
  #define	RL_FLAG_LINK		0x8000
  };
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: yongari 
State-Changed-When: Mon Feb 9 11:58:30 UTC 2009 
State-Changed-Why:  
MFC done. Thanks for reporting/testing! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123123 
>Unformatted:
