From nobody@FreeBSD.org  Tue Oct 12 15:33:26 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 7892A106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Oct 2010 15:33:26 +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 666DC8FC28
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Oct 2010 15:33:26 +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 o9CFXQ1b094253
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Oct 2010 15:33:26 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o9CFXPDw094252;
	Tue, 12 Oct 2010 15:33:25 GMT
	(envelope-from nobody)
Message-Id: <201010121533.o9CFXPDw094252@www.freebsd.org>
Date: Tue, 12 Oct 2010 15:33:25 GMT
From: Steve Cochran <steve@more.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Problem with Marvell driver, e1000phy.c
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         151409
>Category:       kern
>Synopsis:       [e1000] Problem with Marvell driver, e1000phy.c
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    yongari
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 12 15:40:07 UTC 2010
>Closed-Date:    
>Last-Modified:  Sat Jan 22 00:53:51 UTC 2011
>Originator:     Steve Cochran
>Release:        8.1R
>Organization:
University of Missouri System
>Environment:
FreeBSD shaggy.netsys.more.net 8.1-RELEASE-p1 FreeBSD 8.1-RELEASE-p1 #12: Sun Oct 10 14:29:31 CDT 2010     root@shaggy.netsys.more.net:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:

After upgrading from 7.2R to 8.1R I had serious problems with the build-in Ethernet ports on my server. As soon as the OS initialized the port the LEDs looked wrong: activity LED on solid and speed indicator off.  It would come up in half-duplex regardless of the setting on the connected switch and any attempt to force full-duplex operation would apparently cause the port to hang completely. Sometimes it would pass traffic in half-duplex mode (but at low speeds and with errors), sometimes it wouldn't pass traffic at all.

I couldn't find any mention of similar problems on Google so I compared some kernel files between 7.2 and 8.1 and found that dev/mii/e1000phy.c had some significant differences. I tried iteratively backing out some changes but didn't have much luck building a working driver. I'm not a kernel hacker and know very little about Ethernet drivers or Marvell hardware so I only had a dim idea of what I was doing. Eventually I just modified the driver in 8.1 to match the one from 7.2 ( __FBSDID("$FreeBSD: src/sys/dev/mii/e1000phy.c,v 1.18.2.4.2.1 2009/04/15 03:14:26 kensmith Exp $") ) as much as possible.  This finally gave me a working driver.

Here are the relevant lines from dmesg.

Copyright (c) 1992-2010 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 8.1-RELEASE-p1 #12: Sun Oct 10 14:29:31 CDT 2010
    root@shaggy.netsys.more.net:/usr/obj/usr/src/sys/GENERIC amd64
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Quad-Core AMD Opteron(tm) Processor 1354 (2200.10-MHz K8-class CPU)
  Origin = "AuthenticAMD"  Id = 0x100f23  Family = 10  Model = 2  Stepping = 3
  Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0x802009<SSE3,MON,CX16,POPCNT>
  AMD Features=0xee500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM,3DNow!+,3DNow!>
  AMD Features2=0x7ff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,OSVW,IBS>
  TSC: P-state invariant
real memory  = 4294967296 (4096 MB)
avail memory = 4110999552 (3920 MB)
ACPI APIC Table: <061908 APIC1103>
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
FreeBSD/SMP: 1 package(s) x 4 core(s)
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
 cpu2 (AP): APIC ID:  2
 cpu3 (AP): APIC ID:  3
..
nfe0: <NVIDIA nForce MCP55 Networking Adapter> port 0xb400-0xb407 mem 0xfeaf6000-0xfeaf6fff,0xfeafa800-0xfeafa8ff,0xfeafa400-0xfeafa40f irq 22 at device 8.0 on pci0
miibus0: <MII bus> on nfe0
e1000phy0: <Marvell 88E1116 Gigabit PHY> PHY 2 on miibus0
e1000phy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
nfe0: Ethernet address: 00:e0:81:b5:f1:04
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe0: [FILTER]
nfe1: <NVIDIA nForce MCP55 Networking Adapter> port 0xb080-0xb087 mem 0xfeaf5000-0xfeaf5fff,0xfeafa000-0xfeafa0ff,0xfeaf4c00-0xfeaf4c0f irq 23 at device 9.0 on pci0
miibus1: <MII bus> on nfe1
e1000phy1: <Marvell 88E1116 Gigabit PHY> PHY 3 on miibus1
e1000phy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
nfe1: Ethernet address: 00:e0:81:b5:f1:05
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
nfe1: [FILTER]
..
>How-To-Repeat:
The server showing the problem has a Tyan Tomcat n3400B Opteron motherboard with NVIDIA nForce MCP55 chipset and Marvell 88E1116 Ethernet controller. I assume any server with similar hardware would show the same problem. Given the lack of cries in the mailing lists I'm guessing this isn't all that common a setup.
>Fix:
I'd submit the working version of e1000phy.c that I came up with but I'm pretty sure I broke support for some newer Marvell chipsets in the process of fixing my own.  It is mostly identical to src/sys/dev/mii/e1000phy.c,v 1.18.2.4.2.1 but with the necessary changes to make it work with the 8.1 kernel.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-amd64->freebsd-bugs 
Responsible-Changed-By: avg 
Responsible-Changed-When: Mon Oct 18 05:24:14 UTC 2010 
Responsible-Changed-Why:  
I don't see any indication that this is amd64-specific bug; this 
is a problem with network driver. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151409 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Mon Nov 22 00:35:15 UTC 2010 
State-Changed-Why:  
Could you try the patch at the following URL? 
http://people.freebsd.org/~yongari/msk/e1000phy.88E1116.diff 


Responsible-Changed-From-To: freebsd-bugs->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Mon Nov 22 00:35:15 UTC 2010 
Responsible-Changed-Why:  
Grab. 

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

From: "Cochran, Steve A." <steve@more.net>
To: "'bug-followup@FreeBSD.org'" <bug-followup@FreeBSD.org>,
	"'yongari@FreeBSD.org'" <yongari@FreeBSD.org>
Cc:  
Subject: Re: kern/151409: [e1000] Problem with Marvell driver, e1000phy.c
Date: Tue, 23 Nov 2010 10:52:01 -0600

 Hi there,
 
 Thanks for investigating this problem. I'm afraid the behavior of the Ether=
 net port with the patch was identical to the unpatched version. The LEDs lo=
 ok wrong (activity LED on solid, speed indicator completely off), I can't p=
 ing out and the port does not show any packets being received.=20
 
 I'm still working fine when using the 7.2 version of e1000phy.c.
 
 Below is the output of dmesg when booting with the patched kernel. Any othe=
 r details I can provide?
 
 ----
 
 
 Copyright (c) 1992-2010 The FreeBSD Project.
 Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
         The Regents of the University of California. All rights reserved.
 FreeBSD is a registered trademark of The FreeBSD Foundation.
 FreeBSD 8.1-RELEASE-p1 #2: Mon Nov 22 17:55:55 CST 2010
     root@daphne.netsys.more.net:/usr/obj/usr/src/sys/GENERIC amd64
 Timecounter "i8254" frequency 1193182 Hz quality 0
 CPU: Quad-Core AMD Opteron(tm) Processor 1354 (2200.10-MHz K8-class CPU)
   Origin =3D "AuthenticAMD"  Id =3D 0x100f23  Family =3D 10  Model =3D 2  S=
 tepping =3D 3
   Features=3D0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PG=
 E,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
   Features2=3D0x802009<SSE3,MON,CX16,POPCNT>
   AMD Features=3D0xee500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM,3DNow!+=
 ,3DNow!>
   AMD Features2=3D0x7ff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,OSV=
 W,IBS>
   TSC: P-state invariant
 real memory  =3D 4294967296 (4096 MB)
 avail memory =3D 4110999552 (3920 MB)
 ACPI APIC Table: <061908 APIC1103>
 FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
 FreeBSD/SMP: 1 package(s) x 4 core(s)
  cpu0 (BSP): APIC ID:  0
  cpu1 (AP): APIC ID:  1
  cpu2 (AP): APIC ID:  2
  cpu3 (AP): APIC ID:  3
 ioapic0 <Version 1.1> irqs 0-23 on motherboard
 kbd1 at kbdmux0
 acpi0: <061908 XSDT1103> on motherboard
 acpi0: [ITHREAD]
 acpi0: Power Button (fixed)
 acpi0: reservation of fec00000, 1000 (3) failed
 acpi0: reservation of fee00000, 1000 (3) failed
 acpi0: reservation of 0, a0000 (3) failed
 acpi0: reservation of 100000, d7f00000 (3) failed
 Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
 acpi_timer0: <24-bit timer at 3.579545MHz> port 0x2008-0x200b on acpi0
 cpu0: <ACPI CPU> on acpi0
 cpu1: <ACPI CPU> on acpi0
 cpu2: <ACPI CPU> on acpi0
 cpu3: <ACPI CPU> on acpi0
 acpi_hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acp=
 i0
 Timecounter "HPET" frequency 25000000 Hz quality 900
 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
 pci0: <ACPI PCI bus> on pcib0
 pci0: <memory, RAM> at device 0.0 (no driver attached)
 isab0: <PCI-ISA bridge> port 0x2f00-0x2f7f at device 1.0 on pci0
 isa0: <ISA bus> on isab0
 pci0: <serial bus, SMBus> at device 1.1 (no driver attached)
 ohci0: <nVidia nForce MCP55 USB Controller> mem 0xfeafb000-0xfeafbfff irq 2=
 1 at device 2.0 on pci0
 ohci0: [ITHREAD]
 usbus0: <nVidia nForce MCP55 USB Controller> on ohci0
 ehci0: <NVIDIA nForce MCP55 USB 2.0 controller> mem 0xfeafac00-0xfeafacff i=
 rq 22 at device 2.1 on pci0
 ehci0: [ITHREAD]
 usbus1: EHCI version 1.0
 usbus1: <NVIDIA nForce MCP55 USB 2.0 controller> on ehci0
 atapci0: <nVidia nForce MCP55 UDMA133 controller> port 0x1f0-0x1f7,0x3f6,0x=
 170-0x177,0x376,0xffa0-0xffaf at device 4.0 on pci0
 ata0: <ATA channel 0> on atapci0
 ata0: [ITHREAD]
 ata1: <ATA channel 1> on atapci0
 ata1: [ITHREAD]
 atapci1: <nVidia nForce MCP55 SATA300 controller> port 0xd480-0xd487,0xd400=
 -0xd403,0xd080-0xd087,0xd000-0xd003,0xcc00-0xcc0f mem 0xfeaf9000-0xfeaf9fff=
  irq 23 at device 5.0 on pci0
 atapci1: [ITHREAD]
 ata2: <ATA channel 0> on atapci1
 ata2: [ITHREAD]
 ata3: <ATA channel 1> on atapci1
 ata3: [ITHREAD]
 atapci2: <nVidia nForce MCP55 SATA300 controller> port 0xc880-0xc887,0xc800=
 -0xc803,0xc480-0xc487,0xc400-0xc403,0xc080-0xc08f mem 0xfeaf8000-0xfeaf8fff=
  irq 20 at device 5.1 on pci0
 atapci2: [ITHREAD]
 ata4: <ATA channel 0> on atapci2
 ata4: [ITHREAD]
 ata5: <ATA channel 1> on atapci2
 ata5: [ITHREAD]
 atapci3: <nVidia nForce MCP55 SATA300 controller> port 0xc000-0xc007,0xbc00=
 -0xbc03,0xb880-0xb887,0xb800-0xb803,0xb480-0xb48f mem 0xfeaf7000-0xfeaf7fff=
  irq 21 at device 5.2 on pci0
 atapci3: [ITHREAD]
 ata6: <ATA channel 0> on atapci3
 ata6: [ITHREAD]
 ata7: <ATA channel 1> on atapci3
 ata7: [ITHREAD]
 pcib1: <ACPI PCI-PCI bridge> at device 6.0 on pci0
 pci1: <ACPI PCI bus> on pcib1
 vgapci0: <VGA-compatible display> port 0xec00-0xec7f mem 0xf8000000-0xfbfff=
 fff,0xfebc0000-0xfebfffff at device 10.0 on pci1
 nfe0: <NVIDIA nForce MCP55 Networking Adapter> port 0xb400-0xb407 mem 0xfea=
 f6000-0xfeaf6fff,0xfeafa800-0xfeafa8ff,0xfeafa400-0xfeafa40f irq 22 at devi=
 ce 8.0 on pci0
 miibus0: <MII bus> on nfe0
 e1000phy0: <Marvell 88E1116 Gigabit PHY> PHY 2 on miibus0
 e1000phy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000=
 baseT-FDX, auto
 nfe0: Ethernet address: 00:e0:81:b7:57:98
 nfe0: [FILTER]
 nfe0: [FILTER]
 nfe0: [FILTER]
 nfe0: [FILTER]
 nfe0: [FILTER]
 nfe0: [FILTER]
 nfe0: [FILTER]
 nfe0: [FILTER]
 nfe1: <NVIDIA nForce MCP55 Networking Adapter> port 0xb080-0xb087 mem 0xfea=
 f5000-0xfeaf5fff,0xfeafa000-0xfeafa0ff,0xfeaf4c00-0xfeaf4c0f irq 23 at devi=
 ce 9.0 on pci0
 miibus1: <MII bus> on nfe1
 e1000phy1: <Marvell 88E1116 Gigabit PHY> PHY 3 on miibus1
 e1000phy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000=
 baseT-FDX, auto
 nfe1: Ethernet address: 00:e0:81:b7:57:99
 nfe1: [FILTER]
 nfe1: [FILTER]
 nfe1: [FILTER]
 nfe1: [FILTER]
 nfe1: [FILTER]
 nfe1: [FILTER]
 nfe1: [FILTER]
 nfe1: [FILTER]
 pcib2: <ACPI PCI-PCI bridge> at device 10.0 on pci0
 pci2: <ACPI PCI bus> on pcib2
 pcib3: <ACPI PCI-PCI bridge> at device 11.0 on pci0
 pci3: <ACPI PCI bus> on pcib3
 pcib4: <ACPI PCI-PCI bridge> at device 12.0 on pci0
 pci4: <ACPI PCI bus> on pcib4
 pcib5: <ACPI PCI-PCI bridge> at device 13.0 on pci0
 pci5: <ACPI PCI bus> on pcib5
 pcib6: <ACPI PCI-PCI bridge> at device 14.0 on pci0
 pci6: <ACPI PCI bus> on pcib6
 pcib7: <ACPI PCI-PCI bridge> at device 15.0 on pci0
 pci7: <ACPI PCI bus> on pcib7
 acpi_button0: <Power Button> on acpi0
 atrtc0: <AT realtime clock> port 0x70-0x71 irq 8 on acpi0
 uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
 uart0: [FILTER]
 uart1: <16550 or compatible> port 0x2f8-0x2ff irq 3 drq 0 on acpi0
 uart1: [FILTER]
 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
 atkbd0: <AT Keyboard> irq 1 on atkbdc0
 kbd0 at atkbd0
 atkbd0: [GIANT-LOCKED]
 atkbd0: [ITHREAD]
 orm0: <ISA Option ROMs> at iomem 0xc0000-0xc7fff,0xc8000-0xc97ff on isa0
 sc0: <System console> at flags 0x100 on isa0
 sc0: VGA <16 virtual consoles, flags=3D0x300>
 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
 ppc0: cannot reserve I/O port range
 hwpstate0: <Cool`n'Quiet 2.0> on cpu0
 Timecounters tick every 1.000 msec
 usbus0: 12Mbps Full Speed USB v1.0
 usbus1: 480Mbps High Speed USB v2.0
 ugen0.1: <nVidia> at usbus0
 uhub0: <nVidia OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
 ugen1.1: <nVidia> at usbus1
 uhub1: <nVidia EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
 acd0: CDROM <CD-224E-R/1.CA> at ata0-slave UDMA33
 ad4: 715404MB <WDC WD7500AYYS-01RCA0 30.04G30> at ata2-master UDMA100 SATA =
 3Gb/s
 ad6: 715404MB <WDC WD7500AYYS-01RCA0 30.04G30> at ata3-master UDMA100 SATA =
 3Gb/s
 SMP: AP CPU #2 Launched!
 SMP: AP CPU #1 Launched!
 SMP: AP CPU #3 Launched!
 Root mount waiting for: usbus1 usbus0
 uhub0: 10 ports with 10 removable, self powered
 Root mount waiting for: usbus1
 Root mount waiting for: usbus1
 Root mount waiting for: usbus1
 uhub1: 10 ports with 10 removable, self powered
 Root mount waiting for: usbus1
 Trying to mount root from ufs:/dev/ad4s1a
 ugen0.2: <Dell> at usbus0
 ukbd0: <Dell Dell USB Keyboard, class 0/0, rev 1.10/3.01, addr 2> on usbus0
 kbd2 at ukbd0
State-Changed-From-To: feedback->open 
State-Changed-By: yongari 
State-Changed-When: Sat Jan 22 00:53:33 UTC 2011 
State-Changed-Why:  
Feedback received. 

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