From nobody@FreeBSD.org  Mon Feb 14 23:59:20 2011
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 2BE3F106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 14 Feb 2011 23:59:20 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 1999D8FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 14 Feb 2011 23:59:20 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p1ENxJkj049868
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 14 Feb 2011 23:59:19 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p1ENxJrA049867;
	Mon, 14 Feb 2011 23:59:19 GMT
	(envelope-from nobody)
Message-Id: <201102142359.p1ENxJrA049867@red.freebsd.org>
Date: Mon, 14 Feb 2011 23:59:19 GMT
From: Thophile Studer <theo.studer@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: FreeBSD doesn't recognise RTL8101E
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         154789
>Category:       kern
>Synopsis:       [re] FreeBSD doesn't recognise RTL8101E
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 15 00:00:21 UTC 2011
>Closed-Date:    Tue Mar 01 02:01:41 UTC 2011
>Last-Modified:  Tue Mar 01 02:01:41 UTC 2011
>Originator:     Thophile Studer
>Release:        FreeBSD 8.1-RELEASE amd64, FreeBSD 8.2RC3 amd64, FreeBSD 9-CURRENT amd64,
>Organization:
EPFL
>Environment:
FreeBSD 8.1-RELEASE FreeBSD 8.1-RELEASE  #0: Mon Jul 19 02:36:49 UTC 2010 root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
I have a RealTek 8101E ethernet card, which is supposed to work under FreeBSD using re driver.

The ethernet card is recognised during boot, here is the output of `dmesg | grep re0` :

re0: <RealTek 8101E/8102E/8102EL/8103E PCIe 10/100baseTX> ...
re0: Using 1 MSI messages
re0: Chip rev. 0x24000000
re0: MAC rev. 0x00000000
re0: Unknown H/W revision rev. 0x24000000
device_attach: re0 attach returned 6

But when I do `ifconfig -a`, only lo0 is printed.
>How-To-Repeat:
 - Install FreeBSD 8.1, 8.2RC3 or 9-CURRENT
 - ifconfig -a
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Tue Feb 15 02:54:37 UTC 2011 
Responsible-Changed-Why:  
re(4) calls me again. 

According to the Chip/MAC revision number shown by re(4), the 
controller in question is RTL8401E PCIe Fast Ethernet controller. 
re(4) has no support for the controller at this moment. I don't 
have RTL8401E hardware but I'll let you know when I have an 
experimental patch. 

BTW, It's strange that the controller works with NetBSD/OpenBSD. 
Maybe their driver has a bug in recognizing Chip/MAC revision. The 
controller is fairly recent one and it may need to poke other 
undocumented registers to wake up from power down. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154789 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Tue Feb 15 18:23:30 UTC 2011 
State-Changed-Why:  
Would try the patch at the following URL? 
http://people.freebsd.org/~yongari/re/re.RTL8401.diff 
Note, the patch was generated against HEAD. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/154789: commit references a PR
Date: Wed, 16 Feb 2011 21:59:52 +0000 (UTC)

 Author: yongari
 Date: Wed Feb 16 21:59:42 2011
 New Revision: 218760
 URL: http://svn.freebsd.org/changeset/base/218760
 
 Log:
   Add initial support for RTL8401E PCIe Fast Ethernet.
   
   PR:	154789
 
 Modified:
   head/sys/dev/re/if_re.c
   head/sys/pci/if_rlreg.h
 
 Modified: head/sys/dev/re/if_re.c
 ==============================================================================
 --- head/sys/dev/re/if_re.c	Wed Feb 16 21:46:03 2011	(r218759)
 +++ head/sys/dev/re/if_re.c	Wed Feb 16 21:59:42 2011	(r218760)
 @@ -217,6 +217,7 @@ static struct rl_hwrev re_hwrevs[] = {
  	{ RL_HWREV_8102EL, RL_8169, "8102EL", RL_MTU },
  	{ RL_HWREV_8102EL_SPIN1, RL_8169, "8102EL", RL_MTU },
  	{ RL_HWREV_8103E, RL_8169, "8103E", RL_MTU },
 +	{ RL_HWREV_8401E, RL_8169, "8401E", RL_MTU },
  	{ RL_HWREV_8105E, RL_8169, "8105E", RL_MTU },
  	{ RL_HWREV_8168B_SPIN2, RL_8169, "8168", RL_JUMBO_MTU },
  	{ RL_HWREV_8168B_SPIN3, RL_8169, "8168", RL_JUMBO_MTU },
 @@ -1377,6 +1378,7 @@ re_attach(device_t dev)
  		    RL_FLAG_MACSTAT | RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP |
  		    RL_FLAG_AUTOPAD | RL_FLAG_MACSLEEP;
  		break;
 +	case RL_HWREV_8401E:
  	case RL_HWREV_8105E:
  		sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM |
  		    RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
 @@ -1502,8 +1504,11 @@ re_attach(device_t dev)
  	}
  
  	/* Take PHY out of power down mode. */
 -	if ((sc->rl_flags & RL_FLAG_PHYWAKE_PM) != 0)
 +	if ((sc->rl_flags & RL_FLAG_PHYWAKE_PM) != 0) {
  		CSR_WRITE_1(sc, RL_PMCH, CSR_READ_1(sc, RL_PMCH) | 0x80);
 +		if (hw_rev->rl_rev == RL_HWREV_8401E)
 +			CSR_WRITE_1(sc, 0xD1, CSR_READ_1(sc, 0xD1) & ~0x08);
 +	}
  	if ((sc->rl_flags & RL_FLAG_PHYWAKE) != 0) {
  		re_gmii_writereg(dev, 1, 0x1f, 0);
  		re_gmii_writereg(dev, 1, 0x0e, 0);
 
 Modified: head/sys/pci/if_rlreg.h
 ==============================================================================
 --- head/sys/pci/if_rlreg.h	Wed Feb 16 21:46:03 2011	(r218759)
 +++ head/sys/pci/if_rlreg.h	Wed Feb 16 21:59:42 2011	(r218760)
 @@ -160,6 +160,7 @@
  #define	RL_HWREV_8110S		0x04000000
  #define	RL_HWREV_8169_8110SB	0x10000000
  #define	RL_HWREV_8169_8110SC	0x18000000
 +#define	RL_HWREV_8401E		0x24000000
  #define	RL_HWREV_8102EL		0x24800000
  #define	RL_HWREV_8102EL_SPIN1	0x24C00000
  #define	RL_HWREV_8168D		0x28000000
 _______________________________________________
 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: feedback->patched 
State-Changed-By: yongari 
State-Changed-When: Wed Feb 16 22:10:33 UTC 2011 
State-Changed-Why:  
Fix committed to HEAD(r218760). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154789 
State-Changed-From-To: patched->closed 
State-Changed-By: yongari 
State-Changed-When: Tue Mar 1 02:01:10 UTC 2011 
State-Changed-Why:  
Fix merged to both stable/8 and stable/7. 
Thanks a lot for testing and reporting! 

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