From nobody@FreeBSD.org  Tue Jan 19 17:57:32 2010
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 E695E106568B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Jan 2010 17:57:32 +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 BC61C8FC28
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Jan 2010 17:57:32 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0JHvWEL058266
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Jan 2010 17:57:32 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0JHvWcj058265;
	Tue, 19 Jan 2010 17:57:32 GMT
	(envelope-from nobody)
Message-Id: <201001191757.o0JHvWcj058265@www.freebsd.org>
Date: Tue, 19 Jan 2010 17:57:32 GMT
From: Shteryana Shopova <syrinx@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch][net][if_re] Teach the if_re driver to properly recognize hardware revisions with non-zero MAC rev. bits 
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         142974
>Category:       kern
>Synopsis:       [patch][net][if_re] Teach the if_re driver to properly recognize hardware revisions with non-zero MAC rev. bits
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 19 18:00:19 UTC 2010
>Closed-Date:    Tue Feb 02 21:23:58 UTC 2010
>Last-Modified:  Tue Feb 02 21:23:58 UTC 2010
>Originator:     Shteryana Shopova
>Release:        FreeBSD 9.0-CURRENT r202292
>Organization:
>Environment:
>Description:
Attached patch fixed a problem with the if_re driver properly recognizing my Realtek 8102E chip (and possibly others), which have any of the three MAC TX config register bits set to a non-zero value. Before patch driver reported

Chip rev. 0x34800000
MAC rev. 0x00400000
Unknown H/W revision: 0x:34c00000

After patch is applied, driver attaches fine, interface works correctly.
>How-To-Repeat:

>Fix:
Make sure the MAC rev. bits are zeroed when comparing the hardware revision read from the chip and each entry in the list of known chip hardware revisions.

Patch attached with submission follows:

Index: pci/if_rlreg.h
===================================================================
--- pci/if_rlreg.h	(revision 202292)
+++ pci/if_rlreg.h	(working copy)
@@ -146,6 +146,7 @@
 #define RL_TXCFG_IFG2		0x00080000	/* 8169 only */
 #define RL_TXCFG_IFG		0x03000000	/* interframe gap */
 #define RL_TXCFG_HWREV		0x7CC00000
+#define	RL_TXCFG_MACMODE	0x00700000
 
 #define RL_LOOPTEST_OFF		0x00000000
 #define RL_LOOPTEST_ON		0x00020000
Index: dev/re/if_re.c
===================================================================
--- dev/re/if_re.c	(revision 202292)
+++ dev/re/if_re.c	(working copy)
@@ -1236,9 +1236,9 @@
 		hwrev &= RL_TXCFG_HWREV;
 		break;
 	}
-	device_printf(dev, "MAC rev. 0x%08x\n", hwrev & 0x00700000);
+	device_printf(dev, "MAC rev. 0x%08x\n", hwrev & RL_TXCFG_MACMODE);
 	while (hw_rev->rl_desc != NULL) {
-		if (hw_rev->rl_rev == hwrev) {
+		if (hw_rev->rl_rev == (hwrev & ~RL_TXCFG_MACMODE)) {
 			sc->rl_type = hw_rev->rl_type;
 			sc->rl_hwrev = hw_rev->rl_rev;
 			break;
@@ -1279,7 +1279,7 @@
 		sc->rl_flags |= RL_FLAG_MACSLEEP;
 		/* FALLTHROUGH */
 	case RL_HWREV_8168C:
-		if ((hwrev & 0x00700000) == 0x00200000)
+		if ((hwrev & RL_TXCFG_MACMODE) == 0x00200000)
 			sc->rl_flags |= RL_FLAG_MACSLEEP;
 		/* FALLTHROUGH */
 	case RL_HWREV_8168CP:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->freebsd-net 
Responsible-Changed-By: syrinx 
Responsible-Changed-When: Thu Jan 21 09:17:40 UTC 2010 
Responsible-Changed-Why:  
Not i386 specific 

http://www.freebsd.org/cgi/query-pr.cgi?pr=142974 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Fri Jan 22 19:57:19 UTC 2010 
State-Changed-Why:  
It looks like you have second generation RTL8168C PCIe controller. 
I guess hwrev variable would have value 0x34c00000 and I don't see 
reason why it can't match an entry in re_hwrevs table which already 
has that entry. 
Would you show me the output of "CSR_READ_4(sc, RL_TXCFG)"? 


Responsible-Changed-From-To: freebsd-net->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Fri Jan 22 19:57:19 UTC 2010 
Responsible-Changed-Why:  
Grab. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/142974: commit references a PR
Date: Wed, 27 Jan 2010 17:49:38 +0000 (UTC)

 Author: yongari
 Date: Wed Jan 27 17:49:27 2010
 New Revision: 203082
 URL: http://svn.freebsd.org/changeset/base/203082
 
 Log:
   Add initial support for RTL8103E PCIe fastethernet.
   
   PR:	kern/142974
 
 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 Jan 27 17:35:58 2010	(r203081)
 +++ head/sys/dev/re/if_re.c	Wed Jan 27 17:49:27 2010	(r203082)
 @@ -172,7 +172,7 @@ static struct rl_type re_devs[] = {
  	{ RT_VENDORID, RT_DEVICEID_8139, 0,
  	    "RealTek 8139C+ 10/100BaseTX" },
  	{ RT_VENDORID, RT_DEVICEID_8101E, 0,
 -	    "RealTek 8101E/8102E/8102EL PCIe 10/100baseTX" },
 +	    "RealTek 8101E/8102E/8102EL/8103E PCIe 10/100baseTX" },
  	{ RT_VENDORID, RT_DEVICEID_8168, 0,
  	    "RealTek 8168/8168B/8168C/8168CP/8168D/8168DP/"
  	    "8111B/8111C/8111CP/8111DP PCIe Gigabit Ethernet" },
 @@ -212,6 +212,7 @@ static struct rl_hwrev re_hwrevs[] = {
  	{ RL_HWREV_8102E, RL_8169, "8102E"},
  	{ RL_HWREV_8102EL, RL_8169, "8102EL"},
  	{ RL_HWREV_8102EL_SPIN1, RL_8169, "8102EL"},
 +	{ RL_HWREV_8103E, RL_8169, "8103E"},
  	{ RL_HWREV_8168_SPIN2, RL_8169, "8168"},
  	{ RL_HWREV_8168_SPIN3, RL_8169, "8168"},
  	{ RL_HWREV_8168C, RL_8169, "8168C/8111C"},
 @@ -1268,6 +1269,12 @@ re_attach(device_t dev)
  		    RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
  		    RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
  		break;
 +	case RL_HWREV_8103E:
 +		sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_PHYWAKE |
 +		    RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
 +		    RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD |
 +		    RL_FLAG_MACSLEEP;
 +		break;
  	case RL_HWREV_8168_SPIN1:
  	case RL_HWREV_8168_SPIN2:
  		sc->rl_flags |= RL_FLAG_WOLRXENB;
 
 Modified: head/sys/pci/if_rlreg.h
 ==============================================================================
 --- head/sys/pci/if_rlreg.h	Wed Jan 27 17:35:58 2010	(r203081)
 +++ head/sys/pci/if_rlreg.h	Wed Jan 27 17:49:27 2010	(r203082)
 @@ -166,6 +166,7 @@
  #define RL_HWREV_8100E		0x30800000
  #define RL_HWREV_8101E		0x34000000
  #define RL_HWREV_8102E		0x34800000
 +#define RL_HWREV_8103E		0x34C00000
  #define RL_HWREV_8168_SPIN2	0x38000000
  #define RL_HWREV_8168_SPIN3	0x38400000
  #define RL_HWREV_8168C		0x3C000000
 _______________________________________________
 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 Jan 27 18:54:47 UTC 2010 
State-Changed-Why:  
Slightly modified version committed(r203082). 
Thank you for testing! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/142974: commit references a PR
Date: Mon,  1 Feb 2010 23:57:53 +0000 (UTC)

 Author: yongari
 Date: Mon Feb  1 23:57:42 2010
 New Revision: 203364
 URL: http://svn.freebsd.org/changeset/base/203364
 
 Log:
   MFC r203082:
     Add initial support for RTL8103E PCIe fastethernet.
   
     PR:	kern/142974
 
 Modified:
   stable/8/sys/dev/re/if_re.c
   stable/8/sys/pci/if_rlreg.h
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/dev/xen/xenpci/   (props changed)
 
 Modified: stable/8/sys/dev/re/if_re.c
 ==============================================================================
 --- stable/8/sys/dev/re/if_re.c	Mon Feb  1 23:32:43 2010	(r203363)
 +++ stable/8/sys/dev/re/if_re.c	Mon Feb  1 23:57:42 2010	(r203364)
 @@ -172,7 +172,7 @@ static struct rl_type re_devs[] = {
  	{ RT_VENDORID, RT_DEVICEID_8139, 0,
  	    "RealTek 8139C+ 10/100BaseTX" },
  	{ RT_VENDORID, RT_DEVICEID_8101E, 0,
 -	    "RealTek 8101E/8102E/8102EL PCIe 10/100baseTX" },
 +	    "RealTek 8101E/8102E/8102EL/8103E PCIe 10/100baseTX" },
  	{ RT_VENDORID, RT_DEVICEID_8168, 0,
  	    "RealTek 8168/8168B/8168C/8168CP/8168D/8168DP/"
  	    "8111B/8111C/8111CP/8111DP PCIe Gigabit Ethernet" },
 @@ -212,6 +212,7 @@ static struct rl_hwrev re_hwrevs[] = {
  	{ RL_HWREV_8102E, RL_8169, "8102E"},
  	{ RL_HWREV_8102EL, RL_8169, "8102EL"},
  	{ RL_HWREV_8102EL_SPIN1, RL_8169, "8102EL"},
 +	{ RL_HWREV_8103E, RL_8169, "8103E"},
  	{ RL_HWREV_8168_SPIN2, RL_8169, "8168"},
  	{ RL_HWREV_8168_SPIN3, RL_8169, "8168"},
  	{ RL_HWREV_8168C, RL_8169, "8168C/8111C"},
 @@ -1268,6 +1269,12 @@ re_attach(device_t dev)
  		    RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
  		    RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
  		break;
 +	case RL_HWREV_8103E:
 +		sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_PHYWAKE |
 +		    RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
 +		    RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD |
 +		    RL_FLAG_MACSLEEP;
 +		break;
  	case RL_HWREV_8168_SPIN1:
  	case RL_HWREV_8168_SPIN2:
  		sc->rl_flags |= RL_FLAG_WOLRXENB;
 
 Modified: stable/8/sys/pci/if_rlreg.h
 ==============================================================================
 --- stable/8/sys/pci/if_rlreg.h	Mon Feb  1 23:32:43 2010	(r203363)
 +++ stable/8/sys/pci/if_rlreg.h	Mon Feb  1 23:57:42 2010	(r203364)
 @@ -166,6 +166,7 @@
  #define RL_HWREV_8100E		0x30800000
  #define RL_HWREV_8101E		0x34000000
  #define RL_HWREV_8102E		0x34800000
 +#define RL_HWREV_8103E		0x34C00000
  #define RL_HWREV_8168_SPIN2	0x38000000
  #define RL_HWREV_8168_SPIN3	0x38400000
  #define RL_HWREV_8168C		0x3C000000
 _______________________________________________
 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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/142974: commit references a PR
Date: Tue,  2 Feb 2010 17:28:59 +0000 (UTC)

 Author: yongari
 Date: Tue Feb  2 17:28:50 2010
 New Revision: 203383
 URL: http://svn.freebsd.org/changeset/base/203383
 
 Log:
   MFC r203082:
     Add initial support for RTL8103E PCIe fastethernet.
   
     PR:	kern/142974
     Approved by:	re (kensmith)
 
 Modified:
   stable/7/sys/dev/re/if_re.c
   stable/7/sys/pci/if_rlreg.h
 Directory Properties:
   stable/7/sys/   (props changed)
   stable/7/sys/cddl/contrib/opensolaris/   (props changed)
   stable/7/sys/contrib/dev/acpica/   (props changed)
   stable/7/sys/contrib/pf/   (props changed)
 
 Modified: stable/7/sys/dev/re/if_re.c
 ==============================================================================
 --- stable/7/sys/dev/re/if_re.c	Tue Feb  2 16:18:51 2010	(r203382)
 +++ stable/7/sys/dev/re/if_re.c	Tue Feb  2 17:28:50 2010	(r203383)
 @@ -172,7 +172,7 @@ static struct rl_type re_devs[] = {
  	{ RT_VENDORID, RT_DEVICEID_8139, 0,
  	    "RealTek 8139C+ 10/100BaseTX" },
  	{ RT_VENDORID, RT_DEVICEID_8101E, 0,
 -	    "RealTek 8101E/8102E/8102EL PCIe 10/100baseTX" },
 +	    "RealTek 8101E/8102E/8102EL/8103E PCIe 10/100baseTX" },
  	{ RT_VENDORID, RT_DEVICEID_8168, 0,
  	    "RealTek 8168/8168B/8168C/8168CP/8168D/8168DP/"
  	    "8111B/8111C/8111CP/8111DP PCIe Gigabit Ethernet" },
 @@ -212,6 +212,7 @@ static struct rl_hwrev re_hwrevs[] = {
  	{ RL_HWREV_8102E, RL_8169, "8102E"},
  	{ RL_HWREV_8102EL, RL_8169, "8102EL"},
  	{ RL_HWREV_8102EL_SPIN1, RL_8169, "8102EL"},
 +	{ RL_HWREV_8103E, RL_8169, "8103E"},
  	{ RL_HWREV_8168_SPIN2, RL_8169, "8168"},
  	{ RL_HWREV_8168_SPIN3, RL_8169, "8168"},
  	{ RL_HWREV_8168C, RL_8169, "8168C/8111C"},
 @@ -1269,6 +1270,12 @@ re_attach(device_t dev)
  		    RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
  		    RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
  		break;
 +	case RL_HWREV_8103E:
 +		sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_PHYWAKE |
 +		    RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
 +		    RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD |
 +		    RL_FLAG_MACSLEEP;
 +		break;
  	case RL_HWREV_8168_SPIN1:
  	case RL_HWREV_8168_SPIN2:
  		sc->rl_flags |= RL_FLAG_WOLRXENB;
 
 Modified: stable/7/sys/pci/if_rlreg.h
 ==============================================================================
 --- stable/7/sys/pci/if_rlreg.h	Tue Feb  2 16:18:51 2010	(r203382)
 +++ stable/7/sys/pci/if_rlreg.h	Tue Feb  2 17:28:50 2010	(r203383)
 @@ -166,6 +166,7 @@
  #define RL_HWREV_8100E		0x30800000
  #define RL_HWREV_8101E		0x34000000
  #define RL_HWREV_8102E		0x34800000
 +#define RL_HWREV_8103E		0x34C00000
  #define RL_HWREV_8168_SPIN2	0x38000000
  #define RL_HWREV_8168_SPIN3	0x38400000
  #define RL_HWREV_8168C		0x3C000000
 _______________________________________________
 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: Tue Feb 2 21:23:14 UTC 2010 
State-Changed-Why:  
MFC to stable/8 and stable/7 done. 
Thank you for testing/reporting! 

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