From nobody@FreeBSD.org  Wed Dec 27 23:04:09 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 9D21916A407
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Dec 2006 23:04:09 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 568F013C480
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Dec 2006 23:04:09 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id kBRN49pN052466
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Dec 2006 23:04:09 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id kBRN486A052465;
	Wed, 27 Dec 2006 23:04:09 GMT
	(envelope-from nobody)
Message-Id: <200612272304.kBRN486A052465@www.freebsd.org>
Date: Wed, 27 Dec 2006 23:04:09 GMT
From: Mike Hibler<mike@flux.utah.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [bge] unrecognized Broadcom PHY causes panic from bge driver
X-Send-Pr-Version: www-3.0

>Number:         107257
>Category:       kern
>Synopsis:       [bge] unrecognized Broadcom PHY causes panic from bge driver
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jkim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 27 23:10:11 GMT 2006
>Closed-Date:    Wed Mar 21 23:14:04 GMT 2007
>Last-Modified:  Wed Mar 21 23:14:04 GMT 2007
>Originator:     Mike Hibler
>Release:        FreeBSD 7.0-CURRENT
>Organization:
University of Utah, Flux research group
>Environment:
FreeBSD node.newimage-ii.emulab-ops.emulab.net 7.0-CURRENT FreeBSD 7.0-CURRENT #8: Wed Dec 27 13:20:11 MST 2006 root@pc194.oddball.emulab-ops.emulab.net:/mnt/obj/usr/src/sys/TESTBED i386

>Description:
Booting FreeBSD current on a Dell PowerEdge SC440 with a builtin
Broadcom 5754 NIC causes a panic when dhclient runs:
----

Emulab looking for control net among:  bge0 fxp0 ...
fxp0: link state changed to UP
panic: invalid ife->ifm_data (0xa) in mii_phy_setmedia
cpuid = 1
KDB: enter: panic
[thread pid 182 tid 100089 ]
Stopped at      kdb_enter+0x2b: nop
db> bt
Tracing pid 182 tid 100089 td 0xc513fbd0
kdb_enter(c071d290) at kdb_enter+0x2b
panic(c070a3a2,a,974f42d3,18,95e1f439,...) at panic+0x127
mii_phy_setmedia(c4dc1740) at mii_phy_setmedia+0x83
ukphy_service(c4dc1740,c4dc4140,2) at ukphy_service+0xfd
mii_mediachg(c4dc4140,8803,c4dc4140,c4dc8400,c4dcb000,...) at mii_mediachg+0x27 
bge_stop(c4dcb000,c4dcb000,c4dcb008,0,e7877904,...) at bge_stop+0x58b
bge_init_locked(c4dcb000,c4dcb008,0,c0707af3,dee,...) at bge_init_locked+0x36   
bge_init(c4dcb000) at bge_init+0x23
ether_ioctl(c4dc8400,8020690c,c4eab400,0,1,...) at ether_ioctl+0x64
bge_ioctl(c4dc8400,8020690c,c4eab400,0,20000,...) at bge_ioctl+0x262
in6_ifinit(c4dc8400,c4eab400,e7877aa0,1,2,...) at in6_ifinit+0x8c
in6_update_ifa(c4dc8400,e7877a90,0,1) at in6_update_ifa+0x4de
in6_ifattach_linklocal(c4dc8400,0) at in6_ifattach_linklocal+0xf7
in6_ifattach(c4dc8400,0,0,0,e7877b74,...) at in6_ifattach+0xc3
in6_if_up(c4dc8400,c4dc8400,80206910,c505e800,0,...) at in6_if_up+0x4b
if_route(c4dc8400,1,0,e7877bcc,c05d4048,...) at if_route+0x69
if_up(c4dc8400) at if_up+0xf
ifhwioctl(80206910,c4dc8400,c505e800,c513fbd0) at ifhwioctl+0x2f8
ifioctl(c51423e4,80206910,c505e800,c513fbd0,0,...) at ifioctl+0x101
soo_ioctl(c50906c0,80206910,c505e800,c4ce3a80,c513fbd0) at soo_ioctl+0x2db
kern_ioctl(c513fbd0,4,80206910,c505e800) at kern_ioctl+0x296
ioctl(c513fbd0,e7877d00) at ioctl+0xf1
syscall(e7877d38) at syscall+0x256
Xint0x80_syscall() at Xint0x80_syscall+0x20
--- syscall (0, FreeBSD ELF32, nosys), eip = 0x2, esp = 0x247, ebp = 0x1 ---

----
Boot time messages reveal that the PHY is not recognized by the Broadcom code:
----

bge0: <Broadcom NetXtreme Gigabit Ethernet Controller, ASIC rev. 0xb002> mem 0xe
fcf0000-0xefcfffff irq 17 at device 0.0 on pci4
miibus0: <MII bus> on bge0
ukphy0: <Generic IEEE 802.3u media interface> on miibus0
ukphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FD
X, auto
bge0: Ethernet address: 00:13:72:2f:2a:2d

----
Is it necessary that it be specifically recognized?  Apparently, see below.
This is possibly related to kern/105005, but there are deeper problems with
this NIC and the 6.x driver.

>How-To-Repeat:
Try to run dhclient on an SC440!

>Fix:
Add ID(s) for the PHY (from OpenBSD) and no panic and the interface works fine.
Diff:
----

cvs diff: Diffing .
Index: brgphy.c
===================================================================
RCS file: /share/freebsd/CVS/src/sys/dev/mii/brgphy.c,v
retrieving revision 1.52
diff -u -r1.52 brgphy.c
--- brgphy.c	20 Dec 2006 00:34:12 -0000	1.52
+++ brgphy.c	27 Dec 2006 18:41:21 -0000
@@ -112,6 +112,7 @@
 	MII_PHY_DESC(xxBROADCOM, BCM5752),
 	MII_PHY_DESC(xxBROADCOM, BCM5754),
 	MII_PHY_DESC(xxBROADCOM, BCM5780),
+	MII_PHY_DESC(xxBROADCOM2, BCM5787),
 	MII_PHY_END
 };
 
Index: miidevs
===================================================================
RCS file: /share/freebsd/CVS/src/sys/dev/mii/miidevs,v
retrieving revision 1.37
diff -u -r1.37 miidevs
--- miidevs	11 Dec 2006 10:42:04 -0000	1.37
+++ miidevs	27 Dec 2006 18:42:13 -0000
@@ -93,6 +93,7 @@
 
 /* Don't know what's going on here. */
 oui xxDAVICOM			0x006040	Davicom Semiconductor
+oui xxBROADCOM2			0x0050ef	Broadcom Corporation
 
 /* This is the OUI of the gigE PHY in the RealTek 8169S/8110S chips */
 oui xxREALTEK			0x000732
@@ -131,6 +132,7 @@
 model xxBROADCOM BCM5780	0x0035 BCM5780 10/100/1000baseTX PHY
 model xxBROADCOM BCM5706C	0x0015 BCM5706C 10/100/1000baseTX PHY
 model xxBROADCOM BCM5708C	0x0036 BCM5708C 10/100/1000baseTX PHY
+model xxBROADCOM2 BCM5787	0x000e BCM5787 10/100/1000baseT PHY
 
 /* Cicada Semiconductor PHYs (now owned by Vitesse?) */
 model CICADA CS8201		0x0001 Cicada CS8201 10/100/1000TX PHY




>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->davidch 
Responsible-Changed-By: remko 
Responsible-Changed-When: Thu Dec 28 06:34:35 UTC 2006 
Responsible-Changed-Why:  
Hello David, can you have a look at this please? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=107257 
Responsible-Changed-From-To: davidch->jkim 
Responsible-Changed-By: jkim 
Responsible-Changed-When: Mon Jan 15 21:29:52 UTC 2007 
Responsible-Changed-Why:  
I will take this since I have a working patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=107257 
State-Changed-From-To: open->patched 
State-Changed-By: jkim 
State-Changed-When: Mon Jan 15 21:44:44 UTC 2007 
State-Changed-Why:  
More complete patch committed to -CURRENT.  Thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/107257: commit references a PR
Date: Mon, 15 Jan 2007 21:43:58 +0000 (UTC)

 jkim        2007-01-15 21:43:43 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/dev/bge          if_bge.c if_bgereg.h 
     sys/dev/mii          brgphy.c miidevs 
   Log:
   - Fix BCM5754 support found in Dell PowerEdge SC440.
   - Move some PHY bug detections from brgphy.c to if_bge.c.
   - Do not penalize working PHYs.
   - Re-arrange bge_flags roughly by their categories.
   - Fix minor style(9) nits.
   
   PR:             kern/107257
   Obtained from:  OpenBSD
   Tested by:      Mike Hibler <mike at flux dot utah dot edu>
   
   Revision  Changes    Path
   1.173     +18 -7     src/sys/dev/bge/if_bge.c
   1.67      +18 -12    src/sys/dev/bge/if_bgereg.h
   1.53      +48 -22    src/sys/dev/mii/brgphy.c
   1.39      +1 -0      src/sys/dev/mii/miidevs
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: jkim 
State-Changed-When: Wed Mar 21 23:13:16 UTC 2007 
State-Changed-Why:  
MFC'd to RELENG_6. 

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