From freebsd-bugs@mikhailov.org  Sat Jun 26 02:07:17 2004
Return-Path: <freebsd-bugs@mikhailov.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id A3D2916A4CE; Sat, 26 Jun 2004 02:07:16 +0000 (GMT)
Received: from smtp-relay2.palmone.com (palmone-64-28-152-193.palmone.com [64.28.152.193])
	by mx1.FreeBSD.org (Postfix) with SMTP
	id 413B543D2F; Sat, 26 Jun 2004 02:07:14 +0000 (GMT)
	(envelope-from freebsd-bugs@mikhailov.org)
Received: from unknown(148.92.223.30) by smtp-relay2.palmone.com via csmap 
	 id 06c11eb0_c71d_11d8_89b7_00304811ff5e_31214;
	Fri, 25 Jun 2004 20:00:51 -0700 (PDT)
Received: from vortex.palm1.palmone.com (vortex.palm1.palmone.com [172.31.13.225])
	by saspcp17.palmone.com (8.11.6+Sun/8.11.4) with ESMTP id i5Q26UD10220;
	Fri, 25 Jun 2004 19:06:30 -0700 (PDT)
Received: by vortex.palm1.palmone.com (Postfix, from userid 1000)
	id 636CA17040; Fri, 25 Jun 2004 19:06:26 -0700 (PDT)
Message-Id: <20040626020626.636CA17040@vortex.palm1.palmone.com>
Date: Fri, 25 Jun 2004 19:06:26 -0700 (PDT)
From: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
Reply-To: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: imp@freebsd.org
Subject: bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         68351
>Category:       kern
>Synopsis:       [bge] bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jun 26 02:10:23 GMT 2004
>Closed-Date:    Thu Aug 10 11:16:15 GMT 2006
>Last-Modified:  Thu Aug 10 11:16:15 GMT 2006
>Originator:     Vadim Mikhailov
>Release:        FreeBSD 5.2.1-RELEASE-p8 i386
>Organization:
>Environment:
System: FreeBSD vortex.xxx.com 5.2.1-RELEASE-p8 FreeBSD 5.2.1-RELEASE-p8 #0: Thu Jun 25 11:57:42 PST 2003 xxx@vortex.xxx.com:/usr/obj/usr/src/sys/VORTEX i386

>Description:

I have a Dell PowerEdge 1750 server with 2 Xeon 3.0 GHZ CPUs, 4 GB RAM and 2 onboard gigabit ethernet ports:

bge0: <Broadcom BCM5704C Dual Gigabit Ethernet, ASIC rev. 0x2002> mem 0xfcd20000-0xfcd2ffff,0xfcd30000-0xfcd3ffff irq 17 at device 0.0 on pci2
bge1: <Broadcom BCM5704C Dual Gigabit Ethernet, ASIC rev. 0x2002> mem 0xfcd00000-0xfcd0ffff,0xfcd10000-0xfcd1ffff irq 18 at device 0.1 on pci2
      
Only bge0 is used, with jumbo frames (my gigabit switch PowerConnect 5224 supports them):

bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 9000
    options=1b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING>
    inet 172.xx.xx.xx netmask 0xfffff800 broadcast 172.xx.xx.255
    ether 00:06:5b:ef:63:e6
    media: Ethernet autoselect (1000baseTX <full-duplex>)
    status: active

This box has two dualport SCSI adapters:

mpt0: <LSILogic 1030 Ultra4 Adapter> port 0xbc00-0xbcff mem 0xfcb20000-0xfcb2ffff,0xfcb30000-0xfcb3ffff irq 13 at device 5.0 on pci4
mpt1: <LSILogic 1030 Ultra4 Adapter> port 0xb800-0xb8ff mem 0xfcb00000-0xfcb0ffff,0xfcb10000-0xfcb1ffff irq 16 at device 5.1 on pci4
ahc0: <Adaptec 3960D Ultra160 SCSI adapter> port 0xdc00-0xdcff mem 0xfcf01000-0xfcf01fff irq 19 at device 4.0 on pci1
ahc1: <Adaptec 3960D Ultra160 SCSI adapter> port 0xd800-0xd8ff mem 0xfcf00000-0xfcf00fff irq 20 at device 4.1 on pci1

Each adapter has disks attached to them. Firmware on motherboard and all peripherial
devices is upgraded to the very latest versions from Dell.
This setup works more or less ok under FreeBSD 5.1-RELEASE-p8 (GENERIC kernel with SMP enabled),
but once a month or two machine reboots under load, so I want to upgrade it to 5.2.1-RELEASE.
But when I boot 5.2.1-RELEASE or later kernel (-current) on this box, network adapter locks up.
I see these messages on console and in the logs:

Jun 25 15:25:22 vortex kernel: bge0: watchdog timeout -- resetting
						   
If I do "ifconfig bge0 down up", network becomes available for few seconds and then
machine is not pingable again. I ran "systat -v" and have noticed that ping stops
working exactly when I see any interrupt coming to mpt or ahc (i.e. on any disk activity).
						   
One visible difference between 5.1 (where it works) and 5.2.1/current (where it doesn't)
is that interrupts to PCI devices are getting assigned differently:

IRQ map under 5.1: mpt0 13, mpt1 16, bge0 17, bge0 18, ahc0 19, ahc1 20,
  and under 5.2.1: mpt0 18, mpt1 19, bge0 16, bge1 17, ahc0 20, ahc1 21.

I have tried to change IRQ assignment to PCI devices in the BIOS, but it didn't change
anything from FreeBSD point of view. I have also tried to boot 5.2.1 with ACPI disabled -
result is the same. Disabling jumbo frames does not seem to have any effect either.
Also I tried this on another identical 1750 box (I have few of them) - same result.
It works fine under Linux kernel 2.4.18.

>How-To-Repeat:
      Install FreeBSD 5.2.1-RELEASE (or -current) on Dell PowerEdge 1750,
connect bge0 to gigabit switch and you will see bge0 watchdog timeouts.
FreeBSD 5.1-RELEASE and Linux 2.4.18 work fine on the same hardware.

>Fix:

>Release-Note:
>Audit-Trail:

From: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
To: John Baldwin <jhb@FreeBSD.org>
Cc: current@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org,
	freebsd-bugs@mikhailov.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1
 is ok
Date: Wed, 30 Jun 2004 18:57:39 -0700

 On Tuesday, 6/29/2004 8:58 AM, John Baldwin wrote:
 > On Monday 28 June 2004 01:32 pm, Vadim Mikhailov wrote:
 >>  I have a Dell PowerEdge 1750 server with 2 Xeon 3.0 GHZ CPUs,
  >> 4 GB RAM and 2 onboard gigabit ethernet ports:
 >>
 >> bge0: <Broadcom BCM5704C Dual Gigabit Ethernet, ASIC rev.
 >> This setup works more or less ok under FreeBSD 5.1-RELEASE-p8
  >> (GENERIC kernel with SMP enabled), but once a month or two
  >> machine reboots under load, so I want to upgrade it to
  >> 5.2.1-RELEASE.
 >> But when I boot 5.2.1-RELEASE or later kernel (-current) on
  >> this box, network adapter locks up.
 >> I see these messages on console and in the logs:
 >>
 >>Jun 25 15:25:22 vortex kernel: bge0: watchdog timeout -- resetting
 >>
 >>  If I do "ifconfig bge0 down up", network becomes available
  >> for few seconds and then machine is not pingable again.
  >>  I ran "systat -v" and have noticed that ping stops working
  >> exactly when I see any interrupt coming to mpt or ahc
  >> (i.e. on any disk activity).
 >>
 >>  One visible difference between 5.1 (where it works) and
  >> 5.2.1/current (where it doesn't) is that interrupts to PCI
  >> devices are getting assigned differently:
 >>
 >>IRQ map under 5.1: mpt0 13, mpt1 16, bge0 17, bge0 18, ahc0 19, ahc1 20,
 >>  and under 5.2.1: mpt0 18, mpt1 19, bge0 16, bge1 17, ahc0 20, ahc1 21.
 > 
 > The numbers mean different things under 5.1 and 5.2.1.  Can you try booting a 
 > kernel from a recent snapshot of current to see if current works better?  
 > There have been various APIC and ACPI fixes since 5.2.1.
 
    I tried this with 10 days old -current kernel that time - didn't help.
 In any case, running -current on this production box is out of question,
 but I will try to boot fresh -current on it as soon as I have a chance
 to bring it down painlessly just to confirm if it works.
    Today I picked up Intel Pro/1000 MT Desktop 32bit card at local store 
 ($45) and installed it into available PCI slot. While FreeBSD 5.1 cannot
 recognize it, FreeBSD 5.2.1 sees it as em0 and everything works just
 fine, jumbo frames ok! So using this cheap Intel card is workaround for
 this problem, but I'd would very much prefer to have a real fix for
 onboard bge0. Because, when Broadcom works (under 5.1),
 sustained network transfer speed is 104 MB/sec - jumbo frames rock!
 With Intel card it is only 76 MB/sec because it is only 32bit.
 So I have 2 options to solve this problem in full - either to have bge0
 driver fixed, or purchase Intel PRO/1000 XT Server adapter (64bit) -
 that's $130 extra and the only free PCI slot occupied for nothing :-(
    BTW, when it is booted to 5.2.1 and em0 works fine, attempt to
 ifconfig bge0 or bge1 gives watchdog timeout on it (no surprise here).
 Bring bge0/bge1 down, ifconfig em0 - and everything is good again
 without rebooting...
 
 Thanks,
 
 Vadim Mikhailov

From: John Baldwin <jhb@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, freebsd-bugs@mikhailov.org
Cc:  
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Mon, 2 Aug 2004 16:46:35 -0400

 Have you tried disabling ACPI to see if it works better?  Also, can you 
 provide mptable output?
 
 -- 
 John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
 "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org

From: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
To: John Baldwin <jhb@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1
 is ok
Date: Fri, 06 Aug 2004 11:02:29 -0700

 John Baldwin wrote:
  > Have you tried disabling ACPI to see if it works better?
 
    Can not try it now - this is production server under load,
 and it is working fine since I installed Intel Pro/1000 XT card to overcome 
 bge problems.
    But, as stated in my original report, I did try it disabling ACPI about 
 month ago with current - didn't make any difference.
 
  > Also, can you provide mptable output?
 
    Here it is:
 
 ===============================================================================
 
 MPTable, version 2.0.15
 
 -------------------------------------------------------------------------------
 
 MP Floating Pointer Structure:
 
    location:                     BIOS
    physical address:             0x000fe710
    signature:                    '_MP_'
    length:                       16 bytes
    version:                      1.4
    checksum:                     0x91
    mode:                         Virtual Wire
 
 -------------------------------------------------------------------------------
 
 MP Config Table Header:
 
    physical address:             0x000f0000
    signature:                    'PCMP'
    base table length:            412
    version:                      1.4
    checksum:                     0x8a
    OEM ID:                       'DELL    '
    Product ID:                   'PE 014A     '
    OEM table pointer:            0x00000000
    OEM table size:               0
    entry count:                  43
    local APIC address:           0xfee00000
    extended table length:        248
    extended table checksum:      77
 
 -------------------------------------------------------------------------------
 
 MP Config Base Table Entries:
 
 --
 Processors:     APIC ID Version State           Family  Model   Step    Flags
                   0       0x14    BSP, usable     15      2       7       0xbfebf
 bff
                   6       0x14    AP, usable      15      2       7       0xbfebf
 bff
 --
 Bus:            Bus ID  Type
                   0       PCI
                   1       PCI
                   2       PCI
                   3       PCI
                   4       PCI
                   5       ISA
 --
 I/O APICs:      APIC ID Version State           Address
                   8       0x11    usable          0xfec00000
                   9       0x11    usable          0xfec01000
                  10       0x11    usable          0xfec02000
 --
 I/O Ints:       Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#
                  ExtINT  active-hi        edge        5     0          8    0
                  INT      conforms    conforms        5     1          8    1
                  INT      conforms    conforms        5     0          8    2
                  INT      conforms    conforms        5     3          8    3
                  INT      conforms    conforms        5     4          8    4
                  INT     active-lo       level        5     5          8    5
                  INT      conforms    conforms        5     6          8    6
                  INT      conforms    conforms        5     8          8    8
                  INT      conforms    conforms        5     9          8    9
                  INT      conforms    conforms        5    10          8   10
                  INT      conforms    conforms        5    12          8   12
                  INT      conforms    conforms        5    14          8   14
                  INT      conforms    conforms        5    15          8   15
                  INT      conforms    conforms        0   8:A          9   12
                  INT      conforms    conforms        0   8:B          9   13
                  INT      conforms    conforms        0   8:C          9   14
                  INT      conforms    conforms        2   0:A          9    0
                  INT      conforms    conforms        2   0:B          9    1
                  INT      conforms    conforms        4   3:A          9    2
                  INT      conforms    conforms        4   3:B          9    3
                  INT      conforms    conforms        4   5:A          9    2
                  INT      conforms    conforms        4   5:B          9    3
                  INT      conforms    conforms        1   4:A          9    4
                  INT      conforms    conforms        1   4:B          9    5
                  INT      conforms    conforms        1   4:C          9    6
                  INT      conforms    conforms        1   4:D          9    7
                  INT      conforms    conforms        3   6:A          9    8
                  INT      conforms    conforms        3   6:B          9    9
                  INT      conforms    conforms        3   6:C          9   10
                  INT      conforms    conforms        3   6:D          9   11
 --
 Local Ints:     Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#
                  ExtINT  active-hi        edge        5     0        255    0
                  NMI     active-hi        edge        5     0        255    1
 
 -------------------------------------------------------------------------------
 
 MP Config Extended Table Entries:
 
 --
 System Address Space
   bus ID: 0 address type: I/O address
   address base: 0xe000
   address range: 0x1000
 --
 System Address Space
   bus ID: 0 address type: memory address
   address base: 0xfd000000
   address range: 0x1c00000
 --
 System Address Space
   bus ID: 0 address type: I/O address
   address base: 0x0
   address range: 0x1000
 --
 System Address Space
   bus ID: 0 address type: memory address
   address base: 0xa0000
   address range: 0x20000
 --
 System Address Space
   bus ID: 1 address type: I/O address
   address base: 0xd000
   address range: 0x1000
 --
 System Address Space
   bus ID: 1 address type: memory address
   address base: 0xfce00000
   address range: 0x200000
 --
 System Address Space
   bus ID: 2 address type: I/O address
   address base: 0xc000
   address range: 0x1000
 --
 System Address Space
   bus ID: 2 address type: memory address
   address base: 0xfcc00000
   address range: 0x200000
 --
 System Address Space
   bus ID: 3 address type: I/O address
   address base: 0xb000
   address range: 0x1000
 --
 System Address Space
   bus ID: 3 address type: memory address
   address base: 0xfca00000
   address range: 0x200000
 --
 System Address Space
   bus ID: 4 address type: I/O address
   address base: 0xa000
   address range: 0x1000
 --
 System Address Space
   bus ID: 4 address type: memory address
   address base: 0xfc800000
   address range: 0x200000
 --
 Bus Heirarchy
   bus ID: 5 bus info: 0x01 parent bus ID: 0
 
 ===============================================================================
 

From: John Baldwin <jhb@FreeBSD.org>
To: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Fri, 6 Aug 2004 14:15:21 -0400

 On Friday 06 August 2004 02:02 pm, Vadim Mikhailov wrote:
 > John Baldwin wrote:
 >  > Have you tried disabling ACPI to see if it works better?
 >
 >    Can not try it now - this is production server under load,
 > and it is working fine since I installed Intel Pro/1000 XT card to overcome
 > bge problems.
 >    But, as stated in my original report, I did try it disabling ACPI about
 > month ago with current - didn't make any difference.
 >
 >  > Also, can you provide mptable output?
 >
 >    Here it is:
 
 Thanks, can you also provide a full dmesg output?  The two bge's are routed to 
 pins 0 and 1 of the second I/O APIC which should be IRQs 16 and 17 if the 
 first I/O APIC has 16 interrupt pins (dmesg will tell me that).
 
 -- 
 John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
 "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org

From: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
To: John Baldwin <jhb@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1
 is ok
Date: Fri, 06 Aug 2004 12:10:16 -0700

 John Baldwin wrote:
 > On Friday 06 August 2004 02:02 pm, Vadim Mikhailov wrote:
 > 
 >>John Baldwin wrote:
 >> > Have you tried disabling ACPI to see if it works better?
 >>
 >>   Can not try it now - this is production server under load,
 >>and it is working fine since I installed Intel Pro/1000 XT card to overcome
 >>bge problems.
 >>   But, as stated in my original report, I did try it disabling ACPI about
 >>month ago with current - didn't make any difference.
 >>
 >> > Also, can you provide mptable output?
 >>
 >>   Here it is:
 > 
 > 
 > Thanks, can you also provide a full dmesg output?  The two bge's are routed to 
 > pins 0 and 1 of the second I/O APIC which should be IRQs 16 and 17 if the 
 > first I/O APIC has 16 interrupt pins (dmesg will tell me that).
 > 
 
    This is /var/run/dmesg.boot from verbose boot. Oddly enough, it does not 
 start with standard FreeBSD copyrights, probably because of dmesg buffer 
 overflow, however I didn't think this limit applies to /var/run/dmesg.boot 
 file. Hopefully it still has enough information about APIC and interrupts.
 
 %uname -sr
 FreeBSD 5.2.1-RELEASE-p9
 
 %grep -v ^$ /usr/src/sys/i386/conf/VORTEX | awk '{print $1,$2}' | grep -v ^#
 machine i386
 cpu I686_CPU
 ident VORTEX
 options SCHED_4BSD
 options INET
 options FFS
 options SOFTUPDATES
 options UFS_ACL
 options UFS_DIRHASH
 options MD_ROOT
 options NFSCLIENT
 options NFSSERVER
 options NFS_ROOT
 options MSDOSFS
 options CD9660
 options PROCFS
 options PSEUDOFS
 options COMPAT_43
 options COMPAT_FREEBSD4
 options SCSI_DELAY=10000
 options KTRACE
 options SYSVSHM
 options SYSVMSG
 options SYSVSEM
 options _KPOSIX_PRIORITY_SCHEDULING
 options KBD_INSTALL_CDEV
 options AHC_REG_PRETTY_PRINT
 options AHD_REG_PRETTY_PRINT
 options PFIL_HOOKS
 options SMP
 device apic
 device isa
 device pci
 device fdc
 device ata
 device atadisk
 device atapicd
 options ATA_STATIC_ID
 device ahc
 device mpt
 device sym
 device scbus
 device ch
 device da
 device sa
 device cd
 device pass
 device atkbdc
 device atkbd
 device psm
 device vga
 device splash
 device sc
 device agp
 device npx
 device pmtimer
 device sio
 device miibus
 device bge
 device random
 device loop
 device ether
 device ppp
 device tun
 device pty
 device md
 device gif
 device bpf
 device uhci
 device ohci
 device usb
 device ugen
 device uhid
 device ukbd
 device ulpt
 device umass
 device ums
 device urio
 device uscanner
 options IPFIREWALL
 options IPFIREWALL_VERBOSE
 options IPFIREWALL_VERBOSE_LIMIT=100
 options IPFIREWALL_DEFAULT_TO_ACCEPT
 options IPDIVERT
 options DUMMYNET
 options HZ=1000
 options BRIDGE
 options ACCEPT_FILTER_HTTP
 options ACCEPT_FILTER_DATA
 options RANDOM_IP_ID
 options SHMMAXPGS=32768
 options SHMSEG=256
 options SEMMNI=256
 options SEMMNS=512
 options SEMMNU=256
 options SEMMAP=256
 
 % cat /var/run/dmesg.boot
 intpin 7 -> irq 7 (edge, activehi)
 ioapic0: intpin 8 -> irq 8 (edge, activehi)
 ioapic0: intpin 9 -> irq 9 (edge, activehi)
 ioapic0: intpin 10 -> irq 10 (edge, activehi)
 ioapic0: intpin 11 -> irq 11 (edge, activehi)
 ioapic0: intpin 12 -> irq 12 (edge, activehi)
 ioapic0: intpin 13 -> irq 13 (edge, activehi)
 ioapic0: intpin 14 -> irq 14 (edge, activehi)
 ioapic0: intpin 15 -> irq 15 (edge, activehi)
 MADT: Found IO APIC ID 9, Vector 16 at 0xfec01000
 ioapic1: Changing APIC ID to 9
 ioapic1: intpin 0 -> irq 16 (level, activelo)
 ioapic1: intpin 1 -> irq 17 (level, activelo)
 ioapic1: intpin 2 -> irq 18 (level, activelo)
 ioapic1: intpin 3 -> irq 19 (level, activelo)
 ioapic1: intpin 4 -> irq 20 (level, activelo)
 ioapic1: intpin 5 -> irq 21 (level, activelo)
 ioapic1: intpin 6 -> irq 22 (level, activelo)
 ioapic1: intpin 7 -> irq 23 (level, activelo)
 ioapic1: intpin 8 -> irq 24 (level, activelo)
 ioapic1: intpin 9 -> irq 25 (level, activelo)
 ioapic1: intpin 10 -> irq 26 (level, activelo)
 ioapic1: intpin 11 -> irq 27 (level, activelo)
 ioapic1: intpin 12 -> irq 28 (level, activelo)
 ioapic1: intpin 13 -> irq 29 (level, activelo)
 ioapic1: intpin 14 -> irq 30 (level, activelo)
 ioapic1: intpin 15 -> irq 31 (level, activelo)
 MADT: Found IO APIC ID 10, Vector 32 at 0xfec02000
 ioapic2: Changing APIC ID to 10
 ioapic2: intpin 0 -> irq 32 (level, activelo)
 ioapic2: intpin 1 -> irq 33 (level, activelo)
 ioapic2: intpin 2 -> irq 34 (level, activelo)
 ioapic2: intpin 3 -> irq 35 (level, activelo)
 ioapic2: intpin 4 -> irq 36 (level, activelo)
 ioapic2: intpin 5 -> irq 37 (level, activelo)
 ioapic2: intpin 6 -> irq 38 (level, activelo)
 ioapic2: intpin 7 -> irq 39 (level, activelo)
 ioapic2: intpin 8 -> irq 40 (level, activelo)
 ioapic2: intpin 9 -> irq 41 (level, activelo)
 ioapic2: intpin 10 -> irq 42 (level, activelo)
 ioapic2: intpin 11 -> irq 43 (level, activelo)
 ioapic2: intpin 12 -> irq 44 (level, activelo)
 ioapic2: intpin 13 -> irq 45 (level, activelo)
 ioapic2: intpin 14 -> irq 46 (level, activelo)
 ioapic2: intpin 15 -> irq 47 (level, activelo)
 lapic0: Routing NMI -> LINT1
 lapic0: LINT1 trigger: edge
 lapic0: LINT1 polarity: active-hi
 lapic6: Routing NMI -> LINT1
 lapic6: LINT1 trigger: edge
 lapic6: LINT1 polarity: active-hi
 lapic1: Routing NMI -> LINT1
 lapic1: LINT1 trigger: edge
 lapic1: LINT1 polarity: active-hi
 lapic7: Routing NMI -> LINT1
 lapic7: LINT1 trigger: edge
 lapic7: LINT1 polarity: active-hi
 MADT: intr override: source 10, irq 10
 ioapic0: intpin 10 trigger: edge
 ioapic0: intpin 10 polarity: active-hi
 ioapic0 <Version 1.1> irqs 0-15 on motherboard
 ioapic1 <Version 1.1> irqs 16-31 on motherboard
 ioapic2 <Version 1.1> irqs 32-47 on motherboard
 cpu0 BSP:
       ID: 0x00000000   VER: 0x00050014 LDR: 0x01000000 DFR: 0x0fffffff
    lint0: 0x00010700 lint1: 0x00000400 TPR: 0x00000000 SVR: 0x000001ff
 random: <entropy source>
 mem: <memory & I/O>
 Pentium Pro MTRR support enabled
 null: <null device, zero device>
 npx0: [FAST]
 npx0: <math processor> on motherboard
 npx0: INT 16 interface
 acpi0: <DELL   PE1750  > on motherboard
 acpi0: Power Button (fixed)
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 ACPI timer looks BAD  min = 3, max = 6, width = 3
 Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000
 pci_open(1):    mode 1 addr port (0x0cf8) is 0x80008af0
 pci_open(1a):   mode1res=0x80000000 (0x80000000)
 pci_cfgcheck:   device 0 [class=060000] [hdr=80] is there (id=00141166)
 pcibios: BIOS version 2.10
 Using $PIR table, 7 entries at 0xc00fc4a0
 PCI-Only Interrupts: none
 Location  Bus Device Pin  Link  IRQs
 embedded    0    8    A   0x6c  4 5 6 7 11 14 15
 embedded    0    8    B   0x6d  4 5 6 7 11 14 15
 embedded    0    8    C   0x6e  4 5 6 7 11 14 15
 embedded    0   15    A   0x81  4 5 6 7 11 14 15
 embedded    2    0    A   0x60  4 5 6 7 11 14 15
 embedded    2    0    B   0x61  4 5 6 7 11 14 15
 slot 1      3    6    A   0x68  4 5 6 7 11 14 15
 slot 1      3    6    B   0x69  4 5 6 7 11 14 15
 slot 1      3    6    C   0x6a  4 5 6 7 11 14 15
 slot 1      3    6    D   0x6b  4 5 6 7 11 14 15
 embedded    4    3    A   0x62  4 5 6 7 11 14 15
 embedded    4    3    B   0x63  4 5 6 7 11 14 15
 embedded    4    5    A   0x62  4 5 6 7 11 14 15
 embedded    4    5    B   0x63  4 5 6 7 11 14 15
 slot 2      1    4    A   0x64  4 5 6 7 11 14 15
 slot 2      1    4    B   0x65  4 5 6 7 11 14 15
 slot 2      1    4    C   0x66  4 5 6 7 11 14 15
 slot 2      1    4    D   0x67  4 5 6 7 11 14 15
 AcpiOsDerivePciId: bus 0 dev 0 func 0
 acpi_timer0: <32-bit timer at 3.579545MHz> port 0x808-0x80b on acpi0
 acpi_cpu0: <CPU> on acpi0
 acpi_cpu1: <CPU> on acpi0
 acpi_cpu2: <CPU> on acpi0
 acpi_cpu3: <CPU> on acpi0
 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
 ---- initial configuration ------------------------
 \\_SB_.LUSB irq   5: [  4  5  6  7 10 11 12] low,level,sharable 0.15.0
 ---- before setting priority for links ------------
 ---- before fixup boot-disabled links -------------
 ---- after fixup boot-disabled links --------------
 ---- arbitrated configuration ---------------------
 \\_SB_.LUSB irq   5: [  4  5  6  7 10 11 12] low,level,sharable 0.15.0
 pci0: <ACPI PCI bus> on pcib0
 pci0: physical bus=0
 found-> vendor=0x1166, dev=0x0014, revid=0x31
          bus=0, slot=0, func=0
          class=06-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0000, statreg=0x0000, cachelnsz=16 (dwords)
          lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
 found-> vendor=0x1166, dev=0x0014, revid=0x00
          bus=0, slot=0, func=1
          class=06-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0000, statreg=0x0000, cachelnsz=16 (dwords)
          lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
 found-> vendor=0x1166, dev=0x0014, revid=0x00
          bus=0, slot=0, func=2
          class=06-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0000, statreg=0x0000, cachelnsz=16 (dwords)
          lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
          map[10]: type 3, range 32, base feb80000, size 12, enabled
          map[14]: type 4, range 32, base 0000ecf8, size  3, enabled
          map[18]: type 4, range 32, base 0000ece8, size  3, enabled
 pcib0: matched entry for 0.8.INTA (source )
 pcib0: device is hardwired to IRQ 28
 found-> vendor=0x1028, dev=0x000c, revid=0x00
          bus=0, slot=8, func=0
          class=ff-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0117, statreg=0x0290, cachelnsz=16 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
          intpin=a, irq=28
          powerspec 2  supports D0 D3  current D0
          map[10]: type 1, range 32, base fe102000, size 12, enabled
          map[14]: type 4, range 32, base 0000ec80, size  6, enabled
          map[18]: type 3, range 32, base feb00000, size 19, enabled
 pcib0: matched entry for 0.8.INTB (source )
 pcib0: device is hardwired to IRQ 29
 found-> vendor=0x1028, dev=0x0008, revid=0x00
          bus=0, slot=8, func=1
          class=ff-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0103, statreg=0x0290, cachelnsz=16 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
          intpin=b, irq=29
          powerspec 2  supports D0 D3  current D0
          map[10]: type 4, range 32, base 0000ecf4, size  2, enabled
 pcib0: matched entry for 0.8.INTC (source )
 pcib0: device is hardwired to IRQ 30
 found-> vendor=0x1028, dev=0x0009, revid=0x00
          bus=0, slot=8, func=2
          class=ff-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0103, statreg=0x0290, cachelnsz=16 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
          intpin=c, irq=30
          powerspec 2  supports D0 D3  current D0
          map[10]: type 1, range 32, base fd000000, size 24, enabled
          map[14]: type 4, range 32, base 0000e800, size  8, enabled
          map[18]: type 1, range 32, base fe101000, size 12, enabled
 found-> vendor=0x1002, dev=0x4752, revid=0x27
          bus=0, slot=14, func=0
          class=03-00-00, hdrtype=0x00, mfdev=0
          cmdreg=0x00a7, statreg=0x0290, cachelnsz=16 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x08 (2000 ns), maxlat=0x00 (0 ns)
          powerspec 2  supports D0 D1 D2 D3  current D0
 found-> vendor=0x1166, dev=0x0201, revid=0x93
          bus=0, slot=15, func=0
          class=06-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0147, statreg=0x2200, cachelnsz=0 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
          map[10]: type 4, range 32, base 000001f0, size  3, enabled
          map[14]: type 4, range 32, base 000003f4, size  2, enabled
          map[18]: type 4, range 32, base 00000170, size  3, enabled
          map[1c]: type 4, range 32, base 00000374, size  2, enabled
          map[20]: type 4, range 32, base 000008b0, size  4, enabled
 found-> vendor=0x1166, dev=0x0212, revid=0x93
          bus=0, slot=15, func=1
          class=01-01-8a, hdrtype=0x00, mfdev=1
          cmdreg=0x0145, statreg=0x0200, cachelnsz=0 (dwords)
          lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
          map[10]: type 1, range 32, base fe100000, size 12, enabled
 pcib0: matched entry for 0.15.INTA (source \\_SB_.LUSB)
 pcib0: slot 15 INTA is routed to irq 5
 found-> vendor=0x1166, dev=0x0220, revid=0x05
          bus=0, slot=15, func=2
          class=0c-03-10, hdrtype=0x00, mfdev=1
          cmdreg=0x0157, statreg=0x0280, cachelnsz=0 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x50 (20000 ns)
          intpin=a, irq=5
 found-> vendor=0x1166, dev=0x0225, revid=0x00
          bus=0, slot=15, func=3
          class=06-01-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0005, statreg=0x0200, cachelnsz=0 (dwords)
          lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
 found-> vendor=0x1166, dev=0x0110, revid=0x12
          bus=0, slot=16, func=0
          class=06-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0142, statreg=0x22b0, cachelnsz=0 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
 found-> vendor=0x1166, dev=0x0110, revid=0x12
          bus=0, slot=16, func=2
          class=06-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0142, statreg=0x0230, cachelnsz=0 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
 found-> vendor=0x1166, dev=0x0101, revid=0x03
          bus=0, slot=17, func=0
          class=06-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0142, statreg=0x22b0, cachelnsz=0 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
 found-> vendor=0x1166, dev=0x0101, revid=0x03
          bus=0, slot=17, func=2
          class=06-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0142, statreg=0x0230, cachelnsz=0 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
 pci0: <unknown> at device 8.0 (no driver attached)
 pci0: <unknown> at device 8.1 (no driver attached)
 pci0: <unknown> at device 8.2 (no driver attached)
 pci0: <display, VGA> at device 14.0 (no driver attached)
 atapci0: <ServerWorks CSB5 UDMA100 controller> port 
 0x8b0-0x8bf,0x374-0x377,0x170-0x177,0x3f4-0x3f7,0x1f0-0x1f7 at device 15.1 on pci0
 ata0: at 0x1f0 irq 14 on atapci0
 ata0: [MPSAFE]
 ata1: simplex device, DMA on primary only
 ata1: reset tp1 mask=03 ostat0=50 ostat1=01
 ata1-master: stat=0x00 err=0x01 lsb=0x14 msb=0xeb
 ata1-slave:  stat=0x01 err=0x04 lsb=0x14 msb=0xeb
 ata1: reset tp2 mask=03 stat0=00 stat1=01 devices=0x4<ATAPI_MASTER>
 ata1: at 0x170 irq 15 on atapci0
 ata1: [MPSAFE]
 ohci0: <OHCI (generic) USB controller> mem 0xfe100000-0xfe100fff irq 5 at 
 device 15.2 on pci0
 ohci0: (New OHCI DeviceId=0x02201166)
 usb0: OHCI version 1.0, legacy support
 usb0: <OHCI (generic) USB controller> on ohci0
 usb0: USB revision 1.0
 uhub0: (0x1166) OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub0: 4 ports with 4 removable, self powered
 isab0: <PCI-ISA bridge> at device 15.3 on pci0
 isa0: <ISA bus> on isab0
 pcib1: <ACPI Host-PCI bridge> on acpi0
 ---- initial configuration ------------------------
 ---- before setting priority for links ------------
 ---- before fixup boot-disabled links -------------
 ---- after fixup boot-disabled links --------------
 ---- arbitrated configuration ---------------------
 pci4: <ACPI PCI bus> on pcib1
 pci4: physical bus=4
          map[10]: type 4, range 32, base 0000ac00, size  8, enabled
          map[14]: type 1, range 64, base fc930000, size 16, enabled
          map[1c]: type 1, range 64, base fc920000, size 16, enabled
 pcib1: matched entry for 4.5.INTA (source )
 pcib1: device is hardwired to IRQ 18
 found-> vendor=0x1000, dev=0x0030, revid=0x07
          bus=4, slot=5, func=0
          class=01-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0117, statreg=0x0230, cachelnsz=16 (dwords)
          lattimer=0x48 (2160 ns), mingnt=0x11 (4250 ns), maxlat=0x12 (4500 ns)
          intpin=a, irq=18
          powerspec 2  supports D0 D1 D2 D3  current D0
          MSI supports 1 message, 64 bit
          map[10]: type 4, range 32, base 0000a800, size  8, enabled
          map[14]: type 1, range 64, base fc910000, size 16, enabled
          map[1c]: type 1, range 64, base fc900000, size 16, enabled
 pcib1: matched entry for 4.5.INTB (source )
 pcib1: device is hardwired to IRQ 19
 found-> vendor=0x1000, dev=0x0030, revid=0x07
          bus=4, slot=5, func=1
          class=01-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0117, statreg=0x0230, cachelnsz=16 (dwords)
          lattimer=0x48 (2160 ns), mingnt=0x11 (4250 ns), maxlat=0x12 (4500 ns)
          intpin=b, irq=19
          powerspec 2  supports D0 D1 D2 D3  current D0
          MSI supports 1 message, 64 bit
 mpt0: <LSILogic 1030 Ultra4 Adapter> port 0xac00-0xacff mem 
 0xfc920000-0xfc92ffff,0xfc930000-0xfc93ffff irq 18 at device 5.0 on pci4
 mpt0: soft reset
 mpt1: <LSILogic 1030 Ultra4 Adapter> port 0xa800-0xa8ff mem 
 0xfc900000-0xfc90ffff,0xfc910000-0xfc91ffff irq 19 at device 5.1 on pci4
 mpt1: linking with peer (mpt0)
 mpt1: soft reset
 pcib2: <ACPI Host-PCI bridge> on acpi0
 ---- initial configuration ------------------------
 ---- before setting priority for links ------------
 ---- before fixup boot-disabled links -------------
 ---- after fixup boot-disabled links --------------
 ---- arbitrated configuration ---------------------
 pci3: <ACPI PCI bus> on pcib2
 pci3: physical bus=3
          map[10]: type 1, range 32, base fcb20000, size 17, enabled
          map[14]: type 1, range 32, base fcb00000, size 17, enabled
          map[18]: type 4, range 32, base 0000bce0, size  5, enabled
 pcib2: matched entry for 3.6.INTA (source )
 pcib2: device is hardwired to IRQ 24
 found-> vendor=0x8086, dev=0x1008, revid=0x02
          bus=3, slot=6, func=0
          class=02-00-00, hdrtype=0x00, mfdev=0
          cmdreg=0x0117, statreg=0x0230, cachelnsz=16 (dwords)
          lattimer=0x20 (960 ns), mingnt=0xff (63750 ns), maxlat=0x00 (0 ns)
          intpin=a, irq=24
          powerspec 2  supports D0 D3  current D0
          MSI supports 1 message, 64 bit
 em0: <Intel(R) PRO/1000 Network Connection, Version - 1.7.19> port 
 0xbce0-0xbcff mem 0xfcb00000-0xfcb1ffff,0xfcb20000-0xfcb3ffff irq 24 at device 
 6.0 on pci3
 em0: bpf attached
 em0:  Speed:N/A  Duplex:N/A
 pcib3: <ACPI Host-PCI bridge> on acpi0
 ---- initial configuration ------------------------
 ---- before setting priority for links ------------
 ---- before fixup boot-disabled links -------------
 ---- after fixup boot-disabled links --------------
 ---- arbitrated configuration ---------------------
 pci2: <ACPI PCI bus> on pcib3
 pci2: physical bus=2
          map[10]: type 1, range 64, base fcd30000, size 16, enabled
          map[18]: type 1, range 64, base fcd20000, size 16, enabled
 pcib3: matched entry for 2.0.INTA (source )
 pcib3: device is hardwired to IRQ 16
 found-> vendor=0x14e4, dev=0x1648, revid=0x02
          bus=2, slot=0, func=0
          class=02-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0116, statreg=0x02b0, cachelnsz=0 (dwords)
          lattimer=0x40 (1920 ns), mingnt=0x40 (16000 ns), maxlat=0x00 (0 ns)
          intpin=a, irq=16
          powerspec 2  supports D0 D3  current D0
          MSI supports 8 messages, 64 bit
          map[10]: type 1, range 64, base fcd10000, size 16, enabled
          map[18]: type 1, range 64, base fcd00000, size 16, enabled
 pcib3: matched entry for 2.0.INTB (source )
 pcib3: device is hardwired to IRQ 17
 found-> vendor=0x14e4, dev=0x1648, revid=0x02
          bus=2, slot=0, func=1
          class=02-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0116, statreg=0x02b0, cachelnsz=0 (dwords)
          lattimer=0x40 (1920 ns), mingnt=0x40 (16000 ns), maxlat=0x00 (0 ns)
          intpin=b, irq=17
          powerspec 2  supports D0 D3  current D0
          MSI supports 8 messages, 64 bit
 bge0: <Broadcom BCM5704C Dual Gigabit Ethernet, ASIC rev. 0x2002> mem 
 0xfcd20000-0xfcd2ffff,0xfcd30000-0xfcd3ffff irq 16 at device 0.0 on pci2
 bge0: Ethernet address: 00:06:5b:ef:63:e6
 miibus0: <MII bus> on bge0
 brgphy0: <BCM5704 10/100/1000baseTX PHY> on miibus0
 brgphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX, 
 1000baseTX-FDX, auto
 bge0: bpf attached
 bge1: <Broadcom BCM5704C Dual Gigabit Ethernet, ASIC rev. 0x2002> mem 
 0xfcd00000-0xfcd0ffff,0xfcd10000-0xfcd1ffff irq 17 at device 0.1 on pci2
 bge1: Ethernet address: 00:06:5b:ef:63:e7
 miibus1: <MII bus> on bge1
 brgphy1: <BCM5704 10/100/1000baseTX PHY> on miibus1
 brgphy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX, 
 1000baseTX-FDX, auto
 bge1: bpf attached
 pcib4: <ACPI Host-PCI bridge> on acpi0
 ---- initial configuration ------------------------
 ---- before setting priority for links ------------
 ---- before fixup boot-disabled links -------------
 ---- after fixup boot-disabled links --------------
 ---- arbitrated configuration ---------------------
 pci1: <ACPI PCI bus> on pcib4
 pci1: physical bus=1
          map[10]: type 4, range 32, base 0000dc00, size  8, enabled
          map[14]: type 1, range 64, base fcf01000, size 12, enabled
 pcib4: matched entry for 1.4.INTA (source )
 pcib4: device is hardwired to IRQ 20
 found-> vendor=0x9005, dev=0x00c0, revid=0x01
          bus=1, slot=4, func=0
          class=01-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0117, statreg=0x02b0, cachelnsz=16 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x28 (10000 ns), maxlat=0x19 (6250 ns)
          intpin=a, irq=20
          powerspec 2  supports D0 D3  current D0
          map[10]: type 4, range 32, base 0000d800, size  8, enabled
          map[14]: type 1, range 64, base fcf00000, size 12, enabled
 pcib4: matched entry for 1.4.INTB (source )
 pcib4: device is hardwired to IRQ 21
 found-> vendor=0x9005, dev=0x00c0, revid=0x01
          bus=1, slot=4, func=1
          class=01-00-00, hdrtype=0x00, mfdev=1
          cmdreg=0x0117, statreg=0x02b0, cachelnsz=16 (dwords)
          lattimer=0x20 (960 ns), mingnt=0x28 (10000 ns), maxlat=0x19 (6250 ns)
          intpin=b, irq=21
          powerspec 2  supports D0 D3  current D0
 ahc0: <Adaptec 3960D Ultra160 SCSI adapter> port 0xdc00-0xdcff mem 
 0xfcf01000-0xfcf01fff irq 20 at device 4.0 on pci1
 ahc0: Defaulting to MEMIO off
 ahc0: Reading SEEPROM...done.
 ahc0: BIOS eeprom is present
 ahc0: Secondary High byte termination Enabled
 ahc0: Secondary Low byte termination Enabled
 ahc0: Primary Low Byte termination Enabled
 ahc0: Primary High Byte termination Enabled
 ahc0: Downloading Sequencer Program... 422 instructions downloaded
 ahc0: Features 0x1fef6, Bugs 0x40, Flags 0x20485540
 aic7899: Ultra160 Wide Channel A, SCSI Id=7, 32/253 SCBs
 ahc1: <Adaptec 3960D Ultra160 SCSI adapter> port 0xd800-0xd8ff mem 
 0xfcf00000-0xfcf00fff irq 21 at device 4.1 on pci1
 ahc1: Defaulting to MEMIO off
 ahc1: Reading SEEPROM...done.
 ahc1: BIOS eeprom is present
 ahc1: Secondary High byte termination Enabled
 ahc1: Secondary Low byte termination Enabled
 ahc1: Primary Low Byte termination Enabled
 ahc1: Primary High Byte termination Enabled
 ahc1: Downloading Sequencer Program... 422 instructions downloaded
 ahc1: Features 0x1fef6, Bugs 0x40, Flags 0x20485540
 aic7899: Ultra160 Wide Channel B, SCSI Id=7, 32/253 SCBs
 fdc0: <Enhanced floppy controller (i82077, NE72065 or clone)> port 
 0x3f7,0x3f0-0x3f5 irq 6 drq 2 on acpi0
 fdc0: FIFO enabled, 8 bytes threshold
 fd0: <1440-KB 3.5" drive> on fdc0 drive 0
 atkbdc0: <Keyboard controller (i8042)> port 0x64,0x60 irq 1 on acpi0
 atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
 atkbd: the current kbd controller command byte 0065
 atkbd: keyboard ID 0x41ab (2)
 kbd0 at atkbd0
 kbd0: atkbd0, AT 101/102 (2), config:0x1, flags:0x3d0000
 psm0: unable to allocate IRQ
 psmcpnp0 irq 12 on acpi0
 psm0: current command byte:0065
 psm0: <PS/2 Mouse> flags 0x100 irq 12 on atkbdc0
 psm0: model VersaPad, device ID 0-00, 2 buttons
 psm0: config:00006100, flags:00000000, packet size:6
 psm0: syncmask:00, syncbits:00
 sio0: irq maps: 0xa001 0xa011 0xa001 0xa001
 sio0 port 0x3f8-0x3ff irq 4 on acpi0
 sio0: type 16550A
 ata: ata0 already exists; skipping it
 ata: ata1 already exists; skipping it
 atkbdc: atkbdc0 already exists; skipping it
 fdc: fdc0 already exists; skipping it
 sc: sc0 already exists; skipping it
 sio: sio0 already exists; skipping it
 vga: vga0 already exists; skipping it
 Trying Read_Port at 203
 Trying Read_Port at 243
 Trying Read_Port at 283
 Trying Read_Port at 2c3
 Trying Read_Port at 303
 Trying Read_Port at 343
 Trying Read_Port at 383
 Trying Read_Port at 3c3
 isa_probe_children: disabling PnP devices
 isa_probe_children: probing non-PnP devices
 pmtimer0 on isa0
 orm0: <Option ROMs> at iomem 0xec000-0xeffff,0xc8000-0xcbfff,0xc0000-0xc7fff 
 on isa0
 sc0: <System console> on isa0
 sc0: VGA <16 virtual consoles, flags=0x200>
 sc0: fb0, kbd0, terminal emulator: sc (syscons terminal)
 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
 fb0: vga0, vga, type:VGA (5), flags:0x7007f
 fb0: port:0x3c0-0x3df, crtc:0x3d4, mem:0xa0000 0x20000
 fb0: init mode:24, bios mode:3, current mode:24
 fb0: window:0xc00b8000 size:32k gran:32k, buf:0 size:32k
 VGA parameters upon power-up
 50 18 10 00 00 00 03 00 02 67 5f 4f 50 82 55 81
 bf 1f 00 4f 0d 0e 00 00 07 80 9c 8e 8f 28 1f 96
 b9 a3 ff 00 01 02 03 04 05 14 07 38 39 3a 3b 3c
 3d 3e 3f 0c 00 0f 08 00 00 00 00 00 10 0e 00 ff
 VGA parameters in BIOS for mode 24
 50 18 10 00 10 00 03 00 02 67 5f 4f 50 82 55 81
 bf 1f 00 4f 0d 0e 00 00 00 00 9c 8e 8f 28 1f 96
 b9 a3 ff 00 01 02 03 04 05 14 07 38 39 3a 3b 3c
 3d 3e 3f 0c 00 0f 08 00 00 00 00 00 10 0e 00 ff
 EGA/VGA parameters to be used for mode 24
 50 18 10 00 10 00 03 00 02 67 5f 4f 50 82 55 81
 bf 1f 00 4f 0d 0e 00 00 00 00 9c 8e 8f 28 1f 96
 b9 a3 ff 00 01 02 03 04 05 14 07 38 39 3a 3b 3c
 3d 3e 3f 0c 00 0f 08 00 00 00 00 00 10 0e 00 ff
 adv0: not probed (disabled)
 aha0: not probed (disabled)
 aic0: not probed (disabled)
 bt0: not probed (disabled)
 cs0: not probed (disabled)
 ed0: not probed (disabled)
 fe0: not probed (disabled)
 ie0: not probed (disabled)
 le0: not probed (disabled)
 lnc0: not probed (disabled)
 pcic0 failed to probe at port 0x3e0 iomem 0xd0000 on isa0
 pcic1: not probed (disabled)
 ppc0 failed to probe at irq 7 on isa0
 sio1: irq maps: 0xa001 0xa009 0xa001 0xa001
 sio1 at port 0x2f8-0x2ff irq 3 on isa0
 sio1: type 16550A
 sio2: not probed (disabled)
 sio3: not probed (disabled)
 sn0: not probed (disabled)
 vt0: not probed (disabled)
 isa_probe_children: probing PnP devices
 Device configuration finished.
 procfs registered
 Timecounter "TSC" frequency 2990325276 Hz quality -100
 Timecounters tick every 1.000 msec
 DUMMYNET initialized (011031)
 ipfw2 initialized, divert enabled, rule-based forwarding enabled, default to 
 accept, logging limited to 100 packets/entry by default
 BRIDGE $Revision$ $Date$ loaded
 lo0: bpf attached
 ata1-master: pio=0x0c wdma=0x22 udma=0x42 cable=40pin
 ata1-master: setting PIO4 on ServerWorks CSB5 chip
 acd0: <TEAC CD-ROM CD-224E/K.9A> CDROM drive at ata1 as master
 acd0: read 4134KB/s (4134KB/s), 128KB buffer, PIO4
 acd0: Reads: CDR, CDRW, CDDA stream, packet
 acd0: Writes:
 acd0: Audio: play, 256 volume levels
 acd0: Mechanism: ejectable tray, unlocked
 acd0: Medium: no/blank disc
 Waiting 10 seconds for SCSI devices to settle
 (noperiph:ahc0:0:-1:-1): SCSI bus reset delivered. 0 SCBs aborted.
 (noperiph:ahc1:0:-1:-1): SCSI bus reset delivered. 0 SCBs aborted.
 (probe3:mpt0:0:3:0): error 22
 (probe3:mpt0:0:3:0): Unretryable Error
 (probe15:mpt1:0:0:0): error 22
 (probe15:mpt1:0:0:0): Unretryable Error
 (probe9:mpt0:0:10:0): error 22
 (probe9:mpt0:0:10:0): Unretryable Error
 (probe12:mpt0:0:13:0): error 22
 (probe12:mpt0:0:13:0): Unretryable Error
 (probe1:mpt0:0:1:0): error 22
 (probe1:mpt0:0:1:0): Unretryable Error
 (probe2:mpt0:0:2:0): error 22
 (probe2:mpt0:0:2:0): Unretryable Error
 (probe4:mpt0:0:4:0): error 22
 (probe4:mpt0:0:4:0): Unretryable Error
 (probe5:mpt0:0:5:0): error 22
 (probe5:mpt0:0:5:0): Unretryable Error
 (probe16:mpt1:0:1:0): error 22
 (probe16:mpt1:0:1:0): Unretryable Error
 (probe7:mpt0:0:8:0): error 22
 (probe7:mpt0:0:8:0): Unretryable Error
 (probe17:mpt1:0:2:0): error 22
 (probe17:mpt1:0:2:0): Unretryable Error
 (probe8:mpt0:0:9:0): error 22
 (probe8:mpt0:0:9:0): Unretryable Error
 (probe18:mpt1:0:3:0): error 22
 (probe18:mpt1:0:3:0): Unretryable Error
 (probe10:mpt0:0:11:0): error 22
 (probe10:mpt0:0:11:0): Unretryable Error
 (probe19:mpt1:0:4:0): error 22
 (probe19:mpt1:0:4:0): Unretryable Error
 (probe11:mpt0:0:12:0): error 22
 (probe11:mpt0:0:12:0): Unretryable Error
 (probe20:mpt1:0:5:0): error 22
 (probe20:mpt1:0:5:0): Unretryable Error
 (probe13:mpt0:0:14:0): error 22
 (probe13:mpt0:0:14:0): Unretryable Error
 (probe21:mpt1:0:6:0): error 22
 (probe21:mpt1:0:6:0): Unretryable Error
 (probe14:mpt0:0:15:0): error 22
 (probe14:mpt0:0:15:0): Unretryable Error
 (probe22:mpt1:0:8:0): error 22
 (probe22:mpt1:0:8:0): Unretryable Error
 (probe23:mpt1:0:9:0): error 22
 (probe23:mpt1:0:9:0): Unretryable Error
 (probe0:mpt0:0:0:0): Retrying Command
 (probe24:mpt1:0:10:0): error 22
 (probe24:mpt1:0:10:0): Unretryable Error
 (probe25:mpt1:0:11:0): error 22
 (probe25:mpt1:0:11:0): Unretryable Error
 (probe26:mpt1:0:12:0): error 22
 (probe26:mpt1:0:12:0): Unretryable Error
 (probe27:mpt1:0:13:0): error 22
 (probe27:mpt1:0:13:0): Unretryable Error
 (probe28:mpt1:0:14:0): error 22
 (probe28:mpt1:0:14:0): Unretryable Error
 (probe30:ahc0:0:0:0): Retrying Command
 (probe30:ahc0:0:0:0): error 22
 (probe30:ahc0:0:0:0): Unretryable Error
 (ahc0:A:0:0): Sending PPR bus_width 1, period 9, offset 7f, ppr_options 2
 (ahc0:A:0:0): Received PPR width 1, period 9, offset 3e,options 2
          Filtered to width 1, period 9, offset 3e, options 2
 ahc0: target 0 using 16bit transfers
 ahc0: target 0 synchronous at 80.0MHz DT, offset = 0x3e
 (probe29:mpt1:0:15:0): error 22
 (probe29:mpt1:0:15:0): Unretryable Error
 pass0 at mpt0 bus 0 target 0 lun 0
 pass0: <SEAGATE ST336753LC DX09> Fixed Direct Access SCSI-3 device
 pass0: Serial Number 3HX0WHV0
 pass0: 320.000MB/s transfers (160.000MHz, offset 63, 16bit), Tagged Queueing 
 Enabled
 pass1 at mpt0 bus 0 target 6 lun 0
 pass1: <PE/PV 1x3 SCSI BP 1.1> Fixed Processor SCSI-2 device
 pass1: Serial Number 1
 pass1: 3.300MB/s transfers
 pass2 at ahc0 bus 0 target 0 lun 0
 pass2: <Promise 4 Disk RAID5 1.10> Fixed Direct Access SCSI-3 device
 pass2: Serial Number
 pass2: 160.000MB/s transfers (80.000MHz, offset 62, 16bit), Tagged Queueing 
 Enabled
 GEOM: create disk da0 dp=0xcb8ab050
 GEOM: create disk da1 dp=0xcb8cc850
 pass1 at mpt0 bus 0 target 6 lun 0
 pass1: <PE/PV 1x3 SCSI BP 1.1> Fixed Processor SCSI-2 device
 pass1: Serial Number 1
 pass1: 3.300MB/s transfers
 da0 at mpt0 bus 0 target 0 lun 0
 da0: <SEAGATE ST336753LC DX09> Fixed Direct Access SCSI-3 device
 da0: Serial Number 3HX0WHV0
 da0: 320.000MB/s transfers (160.000MHz, offset 63, 16bit), Tagged Queueing Enabled
 da0: 34732MB (71132959 512 byte sectors: 255H 63S/T 4427C)
 da1 at ahc0 bus 0 target 0 lun 0
 da1: <Promise 4 Disk RAID5 1.10> Fixed Direct Access SCSI-3 device
 da1: Serial Number
 da1: 160.000MB/s transfers (80.000MHz, offset 62, 16bit), Tagged Queueing Enabled
 da1: 572204MB (1171874688 512 byte sectors: 255H 63S/T 72945C)
 GEOM: new disk da0
 GEOM: new disk da1
 SMP: AP CPU #1 Launched!
 cpu1 AP:
       ID: 0x01000000   VER: 0x00050014 LDR: 0x02000000 DFR: 0x0fffffff
    lint0: 0x00010700 lint1: 0x00010400 TPR: 0x00000000 SVR: 0x000001ff
 SMP: AP CPU #3 Launched!
 cpu3 AP:
       ID: 0x07000000   VER: 0x00050014 LDR: 0x08000000 DFR: 0x0fffffff
    lint0: 0x00010700 lint1: 0x00010400 TPR: 0x00000000 SVR: 0x000001ff
 SMP: AP CPU #2 Launched!
 cpu2 AP:
       ID: 0x06000000   VER: 0x00050014 LDR: 0x04000000 DFR: 0x0fffffff
    lint0: 0x00010700 lint1: 0x00010400 TPR: 0x00000000 SVR: 0x000001ff
 ioapic0: routing intpin 1 (IRQ 1) to cluster 0
 ioapic0: routing intpin 3 (IRQ 3) to cluster 0
 ioapic0: routing intpin 4 (IRQ 4) to cluster 0
 ioapic0: routing intpin 5 (IRQ 5) to cluster 0
 ioapic0: routing intpin 6 (IRQ 6) to cluster 0
 ioapic0: routing intpin 8 (IRQ 8) to cluster 0
 ioapic0: routing intpin 9 (IRQ 9) to cluster 0
 ioapic0: routing intpin 12 (IRQ 12) to cluster 0
 ioapic0: routing intpin 13 (IRQ 13) to cluster 0
 ioapic0: routing intpin 14 (IRQ 14) to cluster 0
 ioapic0: routing intpin 15 (IRQ 15) to cluster 0
 ioapic1: routing intpin 0 (IRQ 16) to cluster 0
 ioapic1: routing intpin 1 (IRQ 17) to cluster 0
 ioapic1: routing intpin 2 (IRQ 18) to cluster 0
 ioapic1: routing intpin 3 (IRQ 19) to cluster 0
 ioapic1: routing intpin 4 (IRQ 20) to cluster 0
 ioapic1: routing intpin 5 (IRQ 21) to cluster 0
 ioapic1: routing intpin 8 (IRQ 24) to cluster 0
 [0] f:00 typ:222 s(CHS):0/1/1 e(CHS):3/254/63 s:63 l:64197
 [1] f:80 typ:165 s(CHS):4/0/1 e(CHS):1023/254/63 s:64260 l:71055495
 [2] f:00 typ:0 s(CHS):0/0/0 e(CHS):0/0/0 s:0 l:0
 [3] f:00 typ:0 s(CHS):0/0/0 e(CHS):0/0/0 s:0 l:0
 GEOM: Configure da0s1, start 32256 length 32868864 end 32901119
 GEOM: Configure da0s2, start 32901120 length 36380413440 end 36413314559
 [0] f:00 typ:165 s(CHS):0/1/1 e(CHS):1023/254/63 s:63 l:1171861362
 [1] f:00 typ:0 s(CHS):0/0/0 e(CHS):0/0/0 s:0 l:0
 [2] f:00 typ:0 s(CHS):0/0/0 e(CHS):0/0/0 s:0 l:0
 [3] f:00 typ:0 s(CHS):0/0/0 e(CHS):0/0/0 s:0 l:0
 GEOM: Configure da1s1, start 32256 length 599993017344 end 599993049599
 GEOM: Configure da0s2a, start 0 length 268435456 end 268435455
 GEOM: Configure da0s2b, start 268435456 length 2125168640 end 2393604095
 GEOM: Configure da0s2c, start 0 length 36380413440 end 36380413439
 GEOM: Configure da0s2d, start 2393604096 length 3221225472 end 5614829567
 GEOM: Configure da0s2e, start 5614829568 length 536870912 end 6151700479
 GEOM: Configure da0s2f, start 6151700480 length 30228712960 end 36380413439
 GEOM: Configure da1s1a, start 0 length 1073741824 end 1073741823
 GEOM: Configure da1s1b, start 1073741824 length 4294967296 end 5368709119
 GEOM: Configure da1s1c, start 0 length 599993017344 end 599993017343
 GEOM: Configure da1s1e, start 5368709120 length 1073741824 end 6442450943
 GEOM: Configure da1s1f, start 6442450944 length 32212254720 end 38654705663
 GEOM: Configure da1s1h, start 38654705664 length 561338311680 end 599993017343
 Mounting root from ufs:/dev/da0s2a
 start_init: trying /sbin/init
 em0: Link is up 1000 Mbps Full Duplex
 
 Thank you!
 
 Vadim Mikhailov

From: John Baldwin <jhb@FreeBSD.org>
To: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Fri, 6 Aug 2004 15:44:46 -0400

 On Friday 06 August 2004 03:10 pm, Vadim Mikhailov wrote:
 > John Baldwin wrote:
 > > On Friday 06 August 2004 02:02 pm, Vadim Mikhailov wrote:
 > >>John Baldwin wrote:
 > >> > Have you tried disabling ACPI to see if it works better?
 > >>
 > >>   Can not try it now - this is production server under load,
 > >>and it is working fine since I installed Intel Pro/1000 XT card to
 > >> overcome bge problems.
 > >>   But, as stated in my original report, I did try it disabling ACPI
 > >> about month ago with current - didn't make any difference.
 > >>
 > >> > Also, can you provide mptable output?
 > >>
 > >>   Here it is:
 > >
 > > Thanks, can you also provide a full dmesg output?  The two bge's are
 > > routed to pins 0 and 1 of the second I/O APIC which should be IRQs 16 and
 > > 17 if the first I/O APIC has 16 interrupt pins (dmesg will tell me that).
 >
 >    This is /var/run/dmesg.boot from verbose boot. Oddly enough, it does not
 > start with standard FreeBSD copyrights, probably because of dmesg buffer
 > overflow, however I didn't think this limit applies to /var/run/dmesg.boot
 > file. Hopefully it still has enough information about APIC and interrupts.
 
 Thanks.  It looks like the interrupts are routed just as both ACPI and the MP 
 Table say they should be.  Have you tried using cvs to change the sys/dev/bge 
 source back to 5.1 sources with the rest of the kernel being 5.2.1 to see if 
 it works ok?
 
 -- 
 John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
 "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org

From: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
To: John Baldwin <jhb@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1
 is ok
Date: Fri, 06 Aug 2004 13:22:00 -0700

 John Baldwin wrote:
 
 > On Friday 06 August 2004 03:10 pm, Vadim Mikhailov wrote:
 > 
 >>John Baldwin wrote:
 >>
 >>>On Friday 06 August 2004 02:02 pm, Vadim Mikhailov wrote:
 >>>
 >>>>John Baldwin wrote:
 >>>>
 >>>>>Have you tried disabling ACPI to see if it works better?
 >>>>
 >>>>  Can not try it now - this is production server under load,
 >>>>and it is working fine since I installed Intel Pro/1000 XT card to
 >>>>overcome bge problems.
 >>>>  But, as stated in my original report, I did try it disabling ACPI
 >>>>about month ago with current - didn't make any difference.
 >>>>
 >>>>
 >>>>>Also, can you provide mptable output?
 >>>>
 >>>>  Here it is:
 >>>
 >>>Thanks, can you also provide a full dmesg output?  The two bge's are
 >>>routed to pins 0 and 1 of the second I/O APIC which should be IRQs 16 and
 >>>17 if the first I/O APIC has 16 interrupt pins (dmesg will tell me that).
 >>
 >>   This is /var/run/dmesg.boot from verbose boot. Oddly enough, it does not
 >>start with standard FreeBSD copyrights, probably because of dmesg buffer
 >>overflow, however I didn't think this limit applies to /var/run/dmesg.boot
 >>file. Hopefully it still has enough information about APIC and interrupts.
 > 
 > 
 > Thanks.  It looks like the interrupts are routed just as both ACPI and the MP 
 > Table say they should be.  Have you tried using cvs to change the sys/dev/bge 
 > source back to 5.1 sources with the rest of the kernel being 5.2.1 to see if 
 > it works ok?
 > 
 
    Yes I did. Unfortunately difference between 5.1 and 5.2.1 is just too big:
 http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/bge/if_bge.c.diff?f=h&r1=1.41&r2=1.60
    With 5.2.1-p9 sources when I replace if_bge.c rev. 1.60 (5_2_1_RELEASE) 
 with rev. 1.41 (5_1_0_RELEASE) kernel would not compile at all:
 
 /usr/src/sys/dev/bge/if_bge.c:107:24: pci/pcireg.h: No such file or directory
 /usr/src/sys/dev/bge/if_bge.c:108:24: pci/pcivar.h: No such file or directory
 mkdep: compile failed
 *** Error code 1
 
 Thanks,
 
 Vadim Mikhailov
 

From: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
To: Paul Saab <ps@freebsd.org>, freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1
 is ok
Date: Fri, 06 Aug 2004 18:30:21 -0700

 Paul Saab wrote:
 
 > Vadim Mikhailov wrote:
 >>    Yes I did. Unfortunately difference between 5.1 and 5.2.1 is just
 >> too big:
 >> http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/bge/if_bge.c.diff?f=h&r1=1.41&r2=1.60 
 >>
 >>    With 5.2.1-p9 sources when I replace if_bge.c rev. 1.60 
 >> (5_2_1_RELEASE) with rev. 1.41 (5_1_0_RELEASE) kernel would not 
 >> compile at all:
 >>
 >> /usr/src/sys/dev/bge/if_bge.c:107:24: pci/pcireg.h: No such file or 
 >> directory
 >> /usr/src/sys/dev/bge/if_bge.c:108:24: pci/pcivar.h: No such file or 
 >> directory
 >> mkdep: compile failed
 >> *** Error code 1
 >>
 > Just edit if_bge.c and change
 > pci/pcireg.h -> dev/pci/pcireg.h
 > pci/pcivar.h -> dev/pci/pcivar.h
 
    If it would be that easy... After doing what you suggested,
 "make buildkernel" gets this:
 
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_alloc_jumbo_mem':
 /usr/src/sys/dev/bge/if_bge.c:618: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c:621: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c:633: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c:640: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c:642: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_free_jumbo_mem':
 /usr/src/sys/dev/bge/if_bge.c:668: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_jfree':
 /usr/src/sys/dev/bge/if_bge.c:715: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_newbuf_std':
 /usr/src/sys/dev/bge/if_bge.c:764: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_newbuf_jumbo':
 /usr/src/sys/dev/bge/if_bge.c:818: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_free_rx_ring_std':
 /usr/src/sys/dev/bge/if_bge.c:862: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_init_rx_ring_jumbo':
 /usr/src/sys/dev/bge/if_bge.c:883: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_free_rx_ring_jumbo':
 /usr/src/sys/dev/bge/if_bge.c:903: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_free_tx_ring':
 /usr/src/sys/dev/bge/if_bge.c:916: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:924: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_blockinit':
 /usr/src/sys/dev/bge/if_bge.c:1198: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1199: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1199: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1218: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1219: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1219: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1235: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1266: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1266: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1299: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1299: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1360: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1366: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1368: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1369: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_attach':
 /usr/src/sys/dev/bge/if_bge.c:1608: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1611: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1618: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1639: error: structure has no member named `if_unit'
 /usr/src/sys/dev/bge/if_bge.c:1640: error: structure has no member named `if_name'
 /usr/src/sys/dev/bge/if_bge.c:1732: warning: passing arg 1 of 
 `callout_handle_init' from incompatible pointer type
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_release_resources':
 /usr/src/sys/dev/bge/if_bge.c:1796: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1797: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_rxeof':
 /usr/src/sys/dev/bge/if_bge.c:1906: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1915: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_txeof':
 /usr/src/sys/dev/bge/if_bge.c:2021: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:2025: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_intr':
 /usr/src/sys/dev/bge/if_bge.c:2054: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:2083: error: incompatible type for argument 3 of 
 `untimeout'
 /usr/src/sys/dev/bge/if_bge.c:2095: error: incompatible type for argument 3 of 
 `untimeout'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_tick':
 /usr/src/sys/dev/bge/if_bge.c:2141: error: incompatible types in assignment
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_stats_update':
 /usr/src/sys/dev/bge/if_bge.c:2193: error: structure has no member named 
 `dot3StatsSingleCollisionFrames'
 /usr/src/sys/dev/bge/if_bge.c:2194: error: structure has no member named 
 `dot3StatsMultipleCollisionFrames'
 /usr/src/sys/dev/bge/if_bge.c:2195: error: structure has no member named 
 `dot3StatsExcessiveCollisions'
 /usr/src/sys/dev/bge/if_bge.c:2196: error: structure has no member named 
 `dot3StatsLateCollisions'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_encap':
 /usr/src/sys/dev/bge/if_bge.c:2250: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:2281: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_init':
 /usr/src/sys/dev/bge/if_bge.c:2452: error: incompatible types in assignment
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_stop':
 /usr/src/sys/dev/bge/if_bge.c:2668: error: incompatible type for argument 3 of 
 `untimeout'
 *** Error code 1
 
 
    Probably it would be easier to understand what is happening with bge
 under 5.2.1 without rolling if_bge.c back to 5.1. Unfortunately, I don't know 
 how to debug this. How do I get kernel and/or bge0 internal state when it is 
 stuck?
 
 Still, thanks for advice!
 
 Vadim Mikhailov
 

From: John Baldwin <jhb@FreeBSD.org>
To: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Mon, 9 Aug 2004 15:06:32 -0400

 On Friday 06 August 2004 04:22 pm, Vadim Mikhailov wrote:
 > John Baldwin wrote:
 > > On Friday 06 August 2004 03:10 pm, Vadim Mikhailov wrote:
 > >>John Baldwin wrote:
 > >>>On Friday 06 August 2004 02:02 pm, Vadim Mikhailov wrote:
 > >>>>John Baldwin wrote:
 > >>>>>Have you tried disabling ACPI to see if it works better?
 > >>>>
 > >>>>  Can not try it now - this is production server under load,
 > >>>>and it is working fine since I installed Intel Pro/1000 XT card to
 > >>>>overcome bge problems.
 > >>>>  But, as stated in my original report, I did try it disabling ACPI
 > >>>>about month ago with current - didn't make any difference.
 > >>>>
 > >>>>>Also, can you provide mptable output?
 > >>>>
 > >>>>  Here it is:
 > >>>
 > >>>Thanks, can you also provide a full dmesg output?  The two bge's are
 > >>>routed to pins 0 and 1 of the second I/O APIC which should be IRQs 16
 > >>> and 17 if the first I/O APIC has 16 interrupt pins (dmesg will tell me
 > >>> that).
 > >>
 > >>   This is /var/run/dmesg.boot from verbose boot. Oddly enough, it does
 > >> not start with standard FreeBSD copyrights, probably because of dmesg
 > >> buffer overflow, however I didn't think this limit applies to
 > >> /var/run/dmesg.boot file. Hopefully it still has enough information
 > >> about APIC and interrupts.
 > >
 > > Thanks.  It looks like the interrupts are routed just as both ACPI and
 > > the MP Table say they should be.  Have you tried using cvs to change the
 > > sys/dev/bge source back to 5.1 sources with the rest of the kernel being
 > > 5.2.1 to see if it works ok?
 >
 >    Yes I did. Unfortunately difference between 5.1 and 5.2.1 is just too
 > big:
 > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/bge/if_bge.c.diff?f=h&r1=
 >1.41&r2=1.60 With 5.2.1-p9 sources when I replace if_bge.c rev. 1.60
 > (5_2_1_RELEASE) with rev. 1.41 (5_1_0_RELEASE) kernel would not compile at
 > all:
 >
 > /usr/src/sys/dev/bge/if_bge.c:107:24: pci/pcireg.h: No such file or
 > directory /usr/src/sys/dev/bge/if_bge.c:108:24: pci/pcivar.h: No such file
 > or directory mkdep: compile failed
 > *** Error code 1
 
 Just change the files to say '#include <dev/pci/pcifoo.h>', that is, add the 
 'dev/' to the start of the filename and that should fix that problem.  If you 
 could try with those changes I'd appreciate it.
 
 -- 
 John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
 "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org

From: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
To: John Baldwin <jhb@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1
 is ok
Date: Tue, 10 Aug 2004 17:04:48 -0700

 John Baldwin wrote:
 >>> It looks like the interrupts are routed just as both ACPI and
 >>>the MP Table say they should be.  Have you tried using cvs to change the
 >>>sys/dev/bge source back to 5.1 sources with the rest of the kernel being
 >>>5.2.1 to see if it works ok?
 >>   Yes I did. Unfortunately difference between 5.1 and 5.2.1 is just too
 >>big:
 >>http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/bge/if_bge.c.diff?f=h&r1=
 >>1.41&r2=1.60 With 5.2.1-p9 sources when I replace if_bge.c rev. 1.60
 >>(5_2_1_RELEASE) with rev. 1.41 (5_1_0_RELEASE) kernel would not compile at
 >>all:
 >>
 >>/usr/src/sys/dev/bge/if_bge.c:107:24: pci/pcireg.h: No such file or
 >>directory /usr/src/sys/dev/bge/if_bge.c:108:24: pci/pcivar.h: No such file
 >>or directory mkdep: compile failed
 >>*** Error code 1
 > 
 > Just change the files to say '#include <dev/pci/pcifoo.h>', that is, add the 
 > 'dev/' to the start of the filename and that should fix that problem.  If you 
 > could try with those changes I'd appreciate it.
 
 Still no go. As I said before, difference between 5.1 and 5.2.1 is just too 
 big. When I change #includes to <dev/pci/*.h>, I get this on make buildkernel:
 
 error  /usr/src/sys/dev/bge/if_bge.c
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_alloc_jumbo_mem':
 /usr/src/sys/dev/bge/if_bge.c:618: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c:621: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c:633: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c:640: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c:642: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_free_jumbo_mem':
 /usr/src/sys/dev/bge/if_bge.c:668: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_jfree':
 /usr/src/sys/dev/bge/if_bge.c:715: error: structure has no member named 
 `bge_jumbo_buf'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_newbuf_std':
 /usr/src/sys/dev/bge/if_bge.c:764: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_newbuf_jumbo':
 /usr/src/sys/dev/bge/if_bge.c:818: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_free_rx_ring_std':
 /usr/src/sys/dev/bge/if_bge.c:862: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_init_rx_ring_jumbo':
 /usr/src/sys/dev/bge/if_bge.c:883: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_free_rx_ring_jumbo':
 /usr/src/sys/dev/bge/if_bge.c:903: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_free_tx_ring':
 /usr/src/sys/dev/bge/if_bge.c:916: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:924: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_blockinit':
 /usr/src/sys/dev/bge/if_bge.c:1198: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1199: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1199: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1218: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1219: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1219: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1235: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1266: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1266: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1299: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1299: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1360: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1366: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1368: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1369: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_attach':
 /usr/src/sys/dev/bge/if_bge.c:1608: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1611: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1618: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1639: error: structure has no member named `if_unit'
 /usr/src/sys/dev/bge/if_bge.c:1640: error: structure has no member named `if_name'
 /usr/src/sys/dev/bge/if_bge.c:1732: warning: passing arg 1 of 
 `callout_handle_init' from incompatible pointer type
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_release_resources':
 /usr/src/sys/dev/bge/if_bge.c:1796: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1797: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_rxeof':
 /usr/src/sys/dev/bge/if_bge.c:1906: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:1915: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_txeof':
 /usr/src/sys/dev/bge/if_bge.c:2021: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:2025: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_intr':
 /usr/src/sys/dev/bge/if_bge.c:2054: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:2083: error: incompatible type for argument 3 of 
 `untimeout'
 /usr/src/sys/dev/bge/if_bge.c:2095: error: incompatible type for argument 3 of 
 `untimeout'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_tick':
 /usr/src/sys/dev/bge/if_bge.c:2141: error: incompatible types in assignment
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_stats_update':
 /usr/src/sys/dev/bge/if_bge.c:2193: error: structure has no member named 
 `dot3StatsSingleCollisionFrames'
 /usr/src/sys/dev/bge/if_bge.c:2194: error: structure has no member named 
 `dot3StatsMultipleCollisionFrames'
 /usr/src/sys/dev/bge/if_bge.c:2195: error: structure has no member named 
 `dot3StatsExcessiveCollisions'
 /usr/src/sys/dev/bge/if_bge.c:2196: error: structure has no member named 
 `dot3StatsLateCollisions'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_encap':
 /usr/src/sys/dev/bge/if_bge.c:2250: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c:2281: error: structure has no member named 
 `bge_rdata'
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_init':
 /usr/src/sys/dev/bge/if_bge.c:2452: error: incompatible types in assignment
 /usr/src/sys/dev/bge/if_bge.c: In function `bge_stop':
 /usr/src/sys/dev/bge/if_bge.c:2668: error: incompatible type for argument 3 of 
 `untimeout'
 *** Error code 1
 
 Stop in /usr/obj/usr/src/sys/VORTEX.
 *** Error code 1
 
 Thanks,
 
 Vadim Mikhailov

From: John Baldwin <jhb@FreeBSD.org>
To: Vadim Mikhailov <freebsd-bugs@mikhailov.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Wed, 11 Aug 2004 17:25:46 -0400

 On Tuesday 10 August 2004 08:04 pm, Vadim Mikhailov wrote:
 > John Baldwin wrote:
 > >>> It looks like the interrupts are routed just as both ACPI and
 > >>>the MP Table say they should be.  Have you tried using cvs to change the
 > >>>sys/dev/bge source back to 5.1 sources with the rest of the kernel being
 > >>>5.2.1 to see if it works ok?
 > >>
 > >>   Yes I did. Unfortunately difference between 5.1 and 5.2.1 is just too
 > >>big:
 > >>http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/bge/if_bge.c.diff?f=h&r
 > >>1= 1.41&r2=1.60 With 5.2.1-p9 sources when I replace if_bge.c rev. 1.60
 > >> (5_2_1_RELEASE) with rev. 1.41 (5_1_0_RELEASE) kernel would not compile
 > >> at all:
 > >>
 > >>/usr/src/sys/dev/bge/if_bge.c:107:24: pci/pcireg.h: No such file or
 > >>directory /usr/src/sys/dev/bge/if_bge.c:108:24: pci/pcivar.h: No such
 > >> file or directory mkdep: compile failed
 > >>*** Error code 1
 > >
 > > Just change the files to say '#include <dev/pci/pcifoo.h>', that is, add
 > > the 'dev/' to the start of the filename and that should fix that problem.
 > >  If you could try with those changes I'd appreciate it.
 >
 > Still no go. As I said before, difference between 5.1 and 5.2.1 is just too
 > big. When I change #includes to <dev/pci/*.h>, I get this on make
 > buildkernel:
 
 Ok.  Hmm.  I'm not sure what else to look at on this one as I do think it is a 
 problem in bge(4) but don't know how to track those down.
 
 -- 
 John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
 "Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/
State-Changed-From-To: open->feedback 
State-Changed-By: glebius 
State-Changed-When: Thu Dec 8 20:26:47 GMT 2005 
State-Changed-Why:  
Does the problem appear when you use Jumbo frames or always? 
Have you tries running modern versions of FreeBSD, for example 6.0-RELEASE? 


Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Thu Dec 8 20:26:47 GMT 2005 
Responsible-Changed-Why:  
I'll work on this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=68351 
State-Changed-From-To: feedback->open 
State-Changed-By: glebius 
State-Changed-When: Fri Dec 16 08:05:01 UTC 2005 
State-Changed-Why:  
Feedback received. 

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

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: kern/68351 : [bge] bge0 watchdog timeout
Date: Fri, 16 Dec 2005 11:06:04 +0300

 ----- Forwarded message from Piotr KUCHARSKI <chopin@sgh.waw.pl> -----
 
 Just wanted to add that on 6.0-STABLE I also get
 
 bge0: watchdog timeout -- resetting
 bge0: link state changed to DOWN
 bge0: link state changed to UP
 
 bge0: <Broadcom BCM5704C Dual Gigabit Ethernet, ASIC rev. 0x2100>
 mem 0xfdef0000-0xfdefffff irq 25 at device 1.0 on pci3
 
 ----- End forwarded message -----
Responsible-Changed-From-To: glebius->freebsd-bugs 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Thu Mar 23 09:40:02 UTC 2006 
Responsible-Changed-Why:  
I can't work on this PR until I get the hardware. 

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

From: Pavel Merdin <freebsd-bugs@merdin.com>
To: bug-followup@FreeBSD.org, freebsd-bugs@mikhailov.org
Cc:  
Subject: Re: kern/68351: [bge] bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Fri, 2 Jun 2006 18:08:17 +0300

 Hello.
 
   The following patch seems to work:
   
 ==============================================================
 --- if_bge.c.orig    Fri Jun  2 08:05:57 2006
 +++ if_bge.c.new        Fri Jun  2 08:06:39 2006
 @@ -1085,11 +1085,21 @@
                                 (0x3F000F);
         } else {
                 /* PCI-X bus */
 +           if (sc->bge_asicrev == BGE_ASICREV_BCM5750) {
 +                       dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD;
 +                       dma_rw_ctl &= ~BGE_PCIDMARWCTL_ONEDMA_ATONCE; /* XXX */
 +                       device_printf(sc->bge_dev, "Gotcha\n");
 +
 +                       if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5780)
 +                               dma_rw_ctl |= (1 << 20) | (1 << 18) |
 +                                           BGE_PCIDMARWCTL_ONEDMA_ATONCE;
 +                       else
 +                               dma_rw_ctl |= (1<<20) | (1<<18) | (1<<15);
 +           } else if (sc->bge_asicrev == BGE_ASICREV_BCM5704 || BGE_ASICREV_BCM5703)
                 /*
                  * The 5704 uses a different encoding of read/write
                  * watermarks.
                  */
 -               if (sc->bge_asicrev == BGE_ASICREV_BCM5704 || BGE_ASICREV_BCM5703)
                         dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
                             (0x9F0000);
                 else if (sc->bge_asicrev == BGE_ASICREV_BCM5780)
 ==============================================================
 
 It   was   imported   from  OpenBSD.  I  think  that  somebody  could
 import their changes into FreeBSD :)
 
 The full patch with 5780 support:
 
 ==============================================================
 --- if_bge.c.orig       Sat Mar  4 04:34:48 2006
 +++ if_bge.c    Fri Jun  2 08:06:39 2006
 @@ -152,16 +152,28 @@
                 "Broadcom BCM5704C Dual Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5704S,
                 "Broadcom BCM5704S Dual Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5704S_2,
 +               "Broadcom BCM5704S v2 Dual Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5705,
                 "Broadcom BCM5705 Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5705K,
                 "Broadcom BCM5705K Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5705F,
 +               "Broadcom BCM5705F Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5705M,
                 "Broadcom BCM5705M Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5705M_ALT,
                 "Broadcom BCM5705M Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5714C,
                 "Broadcom BCM5714C Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5714S,
 +               "Broadcom BCM5714S Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5715,
 +               "Broadcom BCM5715 Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5715S,
 +               "Broadcom BCM5715S Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5720,
 +               "Broadcom BCM5720 Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5721,
                 "Broadcom BCM5721 Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5750,
 @@ -170,10 +182,22 @@
                 "Broadcom BCM5750M Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5751,
                 "Broadcom BCM5751 Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5751F,
 +               "Broadcom BCM5751F Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5751M,
                 "Broadcom BCM5751M Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5752,
                 "Broadcom BCM5752 Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5753F,
 +               "Broadcom BCM5753F Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5753M,
 +               "Broadcom BCM5753M Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5780,
 +               "Broadcom BCM5780 Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5780S,
 +               "Broadcom BCM5780S Gigabit Ethernet" },
 +       { BCOM_VENDORID, BCOM_DEVICEID_BCM5781,
 +               "Broadcom BCM5781 Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5782,
                 "Broadcom BCM5782 Gigabit Ethernet" },
         { BCOM_VENDORID, BCOM_DEVICEID_BCM5788,
 @@ -1048,30 +1072,45 @@
         /* Set up the PCI DMA control register. */
         if (sc->bge_pcie) {
                 dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 -                   (0xf << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
 -                   (0x2 << BGE_PCIDMARWCTL_WR_WAT_SHIFT);
 +                   (0x180000);
         } else if (pci_read_config(sc->bge_dev, BGE_PCI_PCISTATE, 4) &
             BGE_PCISTATE_PCI_BUSMODE) {
                 /* Conventional PCI bus */
 +                       if (sc->bge_asicrev == BGE_ASICREV_BCM5705 ||
 +                                       BGE_ASICREV_BCM5750) {
 +                          dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 +                                (0x3F0000); }
 +         else
                 dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 -                   (0x7 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
 -                   (0x7 << BGE_PCIDMARWCTL_WR_WAT_SHIFT) |
 -                   (0x0F);
 +                               (0x3F000F);
         } else {
                 /* PCI-X bus */
 +           if (sc->bge_asicrev == BGE_ASICREV_BCM5750) {
 +                       dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD;
 +                       dma_rw_ctl &= ~BGE_PCIDMARWCTL_ONEDMA_ATONCE; /* XXX */
 +                       device_printf(sc->bge_dev, "Gotcha\n");
 +
 +                       if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5780)
 +                               dma_rw_ctl |= (1 << 20) | (1 << 18) |
 +                                           BGE_PCIDMARWCTL_ONEDMA_ATONCE;
 +                       else
 +                               dma_rw_ctl |= (1<<20) | (1<<18) | (1<<15);
 +           } else if (sc->bge_asicrev == BGE_ASICREV_BCM5704 || BGE_ASICREV_BCM5703)
                 /*
                  * The 5704 uses a different encoding of read/write
                  * watermarks.
                  */
 -               if (sc->bge_asicrev == BGE_ASICREV_BCM5704)
                         dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 -                           (0x7 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
 -                           (0x3 << BGE_PCIDMARWCTL_WR_WAT_SHIFT);
 +                           (0x9F0000);
 +               else if (sc->bge_asicrev == BGE_ASICREV_BCM5780)
 +                       dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 +                           (0x144000);
 +               else if (sc->bge_asicrev == BGE_ASICREV_BCM5714)
 +                       dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 +                           (0x148000);
                 else
                         dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 -                           (0x3 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
 -                           (0x3 << BGE_PCIDMARWCTL_WR_WAT_SHIFT) |
 -                           (0x0F);
 +                           (0x1B000F);
 
                 /*
                  * 5703 and 5704 need ONEDMA_AT_ONCE as a workaround
 @@ -2103,7 +2142,8 @@
          * on this chip.
          */
         if (sc->bge_asicrev == BGE_ASICREV_BCM5714 ||
 -            sc->bge_asicrev == BGE_ASICREV_BCM5752)
 +            sc->bge_asicrev == BGE_ASICREV_BCM5752 ||
 +            sc->bge_asicrev == BGE_ASICREV_BCM5780)
                 sc->bge_asicrev = BGE_ASICREV_BCM5750;
 
         /*
 
 ==============================================================
 
 
 -- 
 / Pavel Merdin
 Fotki Inc.
 

From: Lucas Nussbaum <lucas.nussbaum@imag.fr>
To: bug-followup@freebsd.org, glebius@FreeBSD.org,
	freebsd-bugs@merdin.com
Cc:  
Subject: Re: kern/68351: [bge] bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Mon, 12 Jun 2006 11:21:24 +0200

 Hi,
 
 I was trying to use FreeBSD on an IBM e326m (BCM 5780), and ran into those
 problems. I managed to get a working setup by using Yoshiaki Uchikawa's
 patch reported in kern/96806. I then added the change suggested by Pavel
 merdin around /* PCI-X bus */.
 
 This works well, and I get reasonable Gigabit performance (~900 mbps).
 
 Pavel Merdin's patch didn't apply because of tabs->spaces conversion.
 
 I'm available for testing patches on FreeBSD 6-STABLE if somebody want
 to merge this into FreeBSD.
 
 Lucas
 
 -- 
 | Lucas Nussbaum
 | lucas.nussbaum@imag.fr   jabber: lucas@nussbaum.fr |
 | Doctorant                      Laboratoire ID-IMAG |

From: Pavel Merdin <freebsd-bugs@merdin.com>
To: bug-followup@FreeBSD.org, freebsd-bugs@mikhailov.org
Cc:  
Subject: Re: kern/68351: [bge] bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Mon, 12 Jun 2006 12:43:36 +0300

 There's  not  problem  in  tabs/spaces  difference, please read manual
 before using 'patch', it has --ignore-whitespace option for that.
 
 -- 
 / Pavel Merdin
 

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: Lucas Nussbaum <lucas.nussbaum@imag.fr>
Cc: bug-followup@FreeBSD.org, freebsd-bugs@merdin.com
Subject: Re: kern/68351: [bge] bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Mon, 12 Jun 2006 19:25:32 +0400

 On Mon, Jun 12, 2006 at 11:21:24AM +0200, Lucas Nussbaum wrote:
 L> I was trying to use FreeBSD on an IBM e326m (BCM 5780), and ran into those
 L> problems. I managed to get a working setup by using Yoshiaki Uchikawa's
 L> patch reported in kern/96806. I then added the change suggested by Pavel
 L> merdin around /* PCI-X bus */.
 L> 
 L> This works well, and I get reasonable Gigabit performance (~900 mbps).
 L> 
 L> Pavel Merdin's patch didn't apply because of tabs->spaces conversion.
 L> 
 L> I'm available for testing patches on FreeBSD 6-STABLE if somebody want
 L> to merge this into FreeBSD.
 
 I have prepared quite a big patch merging some stuff from OpenBSD
 driver and posted it here:
 
 http://lists.freebsd.org/pipermail/freebsd-current/2006-June/063758.html
 
 This patch applies to HEAD. THe driver from HEAD should compile
 on RELENG_6 after small tweak to VLAN_INPUT_TAG() macro, quite
 obvious tweak. If you fail to compile HEAD driver on RELENG_6,
 mail me, I will post a patch applicable to RELENG_6.
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: Lucas Nussbaum <lucas.nussbaum@imag.fr>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/68351: [bge] bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Tue, 13 Jun 2006 00:00:49 +0400

 --61jdw2sOBCFtR2d/
 Content-Type: text/plain; charset=koi8-r
 Content-Disposition: inline
 
 On Mon, Jun 12, 2006 at 08:19:02PM +0200, Lucas Nussbaum wrote:
 L> The patched HEAD driver indeed doesn't compile on RELENG_6. I tried
 L> commenting some VLAN-related stuff, but couldn't get it to compile.
 L> 
 L> I could easily upgrade this box to HEAD this week, but if it's not
 L> too difficult for you to send me a patch applicable to RELENG_6, we
 L> could go with this solution too.
 
 Here it is.
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE
 
 --61jdw2sOBCFtR2d/
 Content-Type: text/plain; charset=koi8-r
 Content-Disposition: attachment; filename="bge.patch.RELENG_6"
 
 Index: if_bge.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/bge/if_bge.c,v
 retrieving revision 1.91.2.14
 diff -u -r1.91.2.14 if_bge.c
 --- if_bge.c	19 May 2006 19:15:05 -0000	1.91.2.14
 +++ if_bge.c	12 Jun 2006 19:59:22 -0000
 @@ -95,7 +95,6 @@
  #include <netinet/in.h>
  #include <netinet/ip.h>
  
 -#include <machine/clock.h>      /* for DELAY */
  #include <machine/bus.h>
  #include <machine/resource.h>
  #include <sys/bus.h>
 @@ -111,8 +110,6 @@
  
  #include <dev/bge/if_bgereg.h>
  
 -#include "opt_bge.h"
 -
  #define BGE_CSUM_FEATURES	(CSUM_IP | CSUM_TCP | CSUM_UDP)
  #define ETHER_MIN_NOPAD		(ETHER_MIN_LEN - ETHER_CRC_LEN) /* i.e., 60 */
  
 @@ -129,150 +126,328 @@
   * ID burned into it, though it will always be overriden by the vendor
   * ID in the EEPROM. Just to be safe, we cover all possibilities.
   */
 -#define BGE_DEVDESC_MAX		64	/* Maximum device description length */
 -
  static struct bge_type bge_devs[] = {
 -	{ ALT_VENDORID,	ALT_DEVICEID_BCM5700,
 -		"Broadcom BCM5700 Gigabit Ethernet" },
 -	{ ALT_VENDORID,	ALT_DEVICEID_BCM5701,
 -		"Broadcom BCM5701 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5700,
 -		"Broadcom BCM5700 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5701,
 -		"Broadcom BCM5701 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5702,
 -		"Broadcom BCM5702 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5702X,
 -		"Broadcom BCM5702X Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5703,
 -		"Broadcom BCM5703 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5703X,
 -		"Broadcom BCM5703X Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5704C,
 -		"Broadcom BCM5704C Dual Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5704S,
 -		"Broadcom BCM5704S Dual Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5705,
 -		"Broadcom BCM5705 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5705K,
 -		"Broadcom BCM5705K Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5705M,
 -		"Broadcom BCM5705M Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5705M_ALT,
 -		"Broadcom BCM5705M Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5714C,
 -		"Broadcom BCM5714C Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5721,
 -		"Broadcom BCM5721 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5750,
 -		"Broadcom BCM5750 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5750M,
 -		"Broadcom BCM5750M Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5751,
 -		"Broadcom BCM5751 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5751M,
 -		"Broadcom BCM5751M Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5752,
 -		"Broadcom BCM5752 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5782,
 -		"Broadcom BCM5782 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5788,
 -		"Broadcom BCM5788 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5789,
 -		"Broadcom BCM5789 Gigabit Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5901,
 -		"Broadcom BCM5901 Fast Ethernet" },
 -	{ BCOM_VENDORID, BCOM_DEVICEID_BCM5901A2,
 -		"Broadcom BCM5901A2 Fast Ethernet" },
 -	{ SK_VENDORID, SK_DEVICEID_ALTIMA,
 -		"SysKonnect Gigabit Ethernet" },
 -	{ ALTIMA_VENDORID, ALTIMA_DEVICE_AC1000,
 -		"Altima AC1000 Gigabit Ethernet" },
 -	{ ALTIMA_VENDORID, ALTIMA_DEVICE_AC1002,
 -		"Altima AC1002 Gigabit Ethernet" },
 -	{ ALTIMA_VENDORID, ALTIMA_DEVICE_AC9100,
 -		"Altima AC9100 Gigabit Ethernet" },
 -	{ 0, 0, NULL }
 +	{ ALTEON_VENDORID,	ALTEON_DEVICEID_BCM5700 },
 +	{ ALTEON_VENDORID,	ALTEON_DEVICEID_BCM5701 },
 +
 +	{ ALTIMA_VENDORID,	ALTIMA_DEVICE_AC1000 },
 +	{ ALTIMA_VENDORID,	ALTIMA_DEVICE_AC1002 },
 +	{ ALTIMA_VENDORID,	ALTIMA_DEVICE_AC9100 },
 +
 +	{ APPLE_VENDORID,	APPLE_DEVICE_BCM5701 },
 +
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5700 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5701 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5702 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5702_ALT },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5702X },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5703 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5703_ALT },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5703X },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5704C },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5704S },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5704S_ALT },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5705 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5705F },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5705K },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5705M },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5705M_ALT },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5714C },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5714S },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5715 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5715S },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5720 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5721 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5750 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5750M },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5751 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5751F },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5751M },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5752 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5752M },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5753 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5753F },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5753M },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5780 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5780S },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5781 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5782 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5788 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5789 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5901 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5901A2 },
 +	{ BCOM_VENDORID,	BCOM_DEVICEID_BCM5903M },
 +
 +	{ SK_VENDORID,		SK_DEVICEID_ALTIMA },
 +
 +	{ TC_VENDORID,		TC_DEVICEID_3C985 },
 +	{ TC_VENDORID,		TC_DEVICEID_3C996 },
 +
 +	{ 0, 0 }
  };
  
 -static int bge_probe		(device_t);
 -static int bge_attach		(device_t);
 -static int bge_detach		(device_t);
 -static int bge_suspend		(device_t);
 -static int bge_resume		(device_t);
 -static void bge_release_resources
 -				(struct bge_softc *);
 -static void bge_dma_map_addr	(void *, bus_dma_segment_t *, int, int);
 -static int bge_dma_alloc	(device_t);
 -static void bge_dma_free	(struct bge_softc *);
 -
 -static void bge_txeof		(struct bge_softc *);
 -static void bge_rxeof		(struct bge_softc *);
 -
 -static void bge_tick_locked	(struct bge_softc *);
 -static void bge_tick		(void *);
 -static void bge_stats_update	(struct bge_softc *);
 -static void bge_stats_update_regs
 -				(struct bge_softc *);
 -static int bge_encap		(struct bge_softc *, struct mbuf *,
 -					u_int32_t *);
 -
 -static void bge_intr		(void *);
 -static void bge_start_locked	(struct ifnet *);
 -static void bge_start		(struct ifnet *);
 -static int bge_ioctl		(struct ifnet *, u_long, caddr_t);
 -static void bge_init_locked	(struct bge_softc *);
 -static void bge_init		(void *);
 -static void bge_stop		(struct bge_softc *);
 -static void bge_watchdog		(struct ifnet *);
 -static void bge_shutdown		(device_t);
 -static int bge_ifmedia_upd	(struct ifnet *);
 -static void bge_ifmedia_sts	(struct ifnet *, struct ifmediareq *);
 -
 -static u_int8_t	bge_eeprom_getbyte	(struct bge_softc *, int, u_int8_t *);
 -static int bge_read_eeprom	(struct bge_softc *, caddr_t, int, int);
 -
 -static void bge_setmulti	(struct bge_softc *);
 -
 -static int bge_newbuf_std	(struct bge_softc *, int, struct mbuf *);
 -static int bge_newbuf_jumbo	(struct bge_softc *, int, struct mbuf *);
 -static int bge_init_rx_ring_std	(struct bge_softc *);
 -static void bge_free_rx_ring_std	(struct bge_softc *);
 -static int bge_init_rx_ring_jumbo	(struct bge_softc *);
 -static void bge_free_rx_ring_jumbo	(struct bge_softc *);
 -static void bge_free_tx_ring	(struct bge_softc *);
 -static int bge_init_tx_ring	(struct bge_softc *);
 +#define BGE_IS_5705_OR_BEYOND(sc)			   \
 +	((sc)->bge_asicrev == BGE_ASICREV_BCM5705	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5750	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5714_A0	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5780	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5714	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5752)
 +
 +#define BGE_IS_575X_PLUS(sc)				   \
 +	((sc)->bge_asicrev == BGE_ASICREV_BCM5750	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5714_A0	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5780	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5714	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5752)
 +
 +#define BGE_IS_5714_FAMILY(sc)				   \
 +	((sc)->bge_asicrev == BGE_ASICREV_BCM5714_A0	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5780	|| \
 +	 (sc)->bge_asicrev == BGE_ASICREV_BCM5714)
 +
 +#define BGE_IS_JUMBO_CAPABLE(sc)			   \
 +	((sc)->bge_asicrev != BGE_ASICREV_BCM5705	&& \
 +	 (sc)->bge_asicrev != BGE_ASICREV_BCM5750)
 +
 +static const struct bge_revision {
 +	uint32_t		br_chipid;
 +	const char		*br_name;
 +} bge_revisions[] = {
 +	{ BGE_CHIPID_BCM5700_A0,
 +	  "BCM5700 A0" },
 +
 +	{ BGE_CHIPID_BCM5700_A1,
 +	  "BCM5700 A1" },
 +
 +	{ BGE_CHIPID_BCM5700_B0,
 +	  "BCM5700 B0" },
 +
 +	{ BGE_CHIPID_BCM5700_B1,
 +	  "BCM5700 B1" },
 +
 +	{ BGE_CHIPID_BCM5700_B2,
 +	  "BCM5700 B2" },
 +
 +	{ BGE_CHIPID_BCM5700_B3,
 +	  "BCM5700 B3" },
 +
 +	/* This is treated like a BCM5700 Bx */
 +	{ BGE_CHIPID_BCM5700_ALTIMA,
 +	  "BCM5700 Altima" },
 +
 +	{ BGE_CHIPID_BCM5700_C0,
 +	  "BCM5700 C0" },
 +
 +	{ BGE_CHIPID_BCM5701_A0,
 +	  "BCM5701 A0" },
 +
 +	{ BGE_CHIPID_BCM5701_B0,
 +	  "BCM5701 B0" },
 +
 +	{ BGE_CHIPID_BCM5701_B2,
 +	  "BCM5701 B2" },
 +
 +	{ BGE_CHIPID_BCM5701_B5,
 +	  "BCM5701 B5" },
 +
 +	{ BGE_CHIPID_BCM5703_A0,
 +	  "BCM5703 A0" },
 +
 +	{ BGE_CHIPID_BCM5703_A1,
 +	  "BCM5703 A1" },
 +
 +	{ BGE_CHIPID_BCM5703_A2,
 +	  "BCM5703 A2" },
 +
 +	{ BGE_CHIPID_BCM5703_A3,
 +	  "BCM5703 A3" },
 +
 +	{ BGE_CHIPID_BCM5704_A0,
 +	  "BCM5704 A0" },
 +
 +	{ BGE_CHIPID_BCM5704_A1,
 +	  "BCM5704 A1" },
 +
 +	{ BGE_CHIPID_BCM5704_A2,
 +	  "BCM5704 A2" },
 +
 +	{ BGE_CHIPID_BCM5704_A3,
 +	  "BCM5704 A3" },
 +
 +	{ BGE_CHIPID_BCM5704_B0,
 +	  "BCM5704 B0" },
 +
 +	{ BGE_CHIPID_BCM5705_A0,
 +	  "BCM5705 A0" },
 +
 +	{ BGE_CHIPID_BCM5705_A1,
 +	  "BCM5705 A1" },
 +
 +	{ BGE_CHIPID_BCM5705_A2,
 +	  "BCM5705 A2" },
 +
 +	{ BGE_CHIPID_BCM5705_A3,
 +	  "BCM5705 A3" },
  
 -static int bge_chipinit		(struct bge_softc *);
 -static int bge_blockinit	(struct bge_softc *);
 +	{ BGE_CHIPID_BCM5750_A0,
 +	  "BCM5750 A0" },
 +
 +	{ BGE_CHIPID_BCM5750_A1,
 +	  "BCM5750 A1" },
 +
 +	{ BGE_CHIPID_BCM5750_A3,
 +	  "BCM5750 A3" },
 +
 +	{ BGE_CHIPID_BCM5750_B0,
 +	  "BCM5750 B0" },
 +
 +	{ BGE_CHIPID_BCM5750_B1,
 +	  "BCM5750 B1" },
 +
 +	{ BGE_CHIPID_BCM5750_C0,
 +	  "BCM5750 C0" },
 +
 +	{ BGE_CHIPID_BCM5750_C1,
 +	  "BCM5750 C1" },
 +
 +	{ BGE_CHIPID_BCM5714_A0,
 +	  "BCM5714 A0" },
 +
 +	{ BGE_CHIPID_BCM5752_A0,
 +	  "BCM5752 A0" },
 +
 +	{ BGE_CHIPID_BCM5752_A1,
 +	  "BCM5752 A1" },
 +
 +	{ BGE_CHIPID_BCM5752_A2,
 +	  "BCM5752 A2" },
 +
 +	{ BGE_CHIPID_BCM5714_B0,
 +	  "BCM5714 B0" },
 +
 +	{ BGE_CHIPID_BCM5714_B3,
 +	  "BCM5714 B3" },
 +
 +	{ BGE_CHIPID_BCM5715_A0,
 +	  "BCM5715 A0" },
 +
 +	{ BGE_CHIPID_BCM5715_A1,
 +	  "BCM5715 A1" },
 +
 +	{ 0,
 +	  NULL }
 +};
 +
 +/*
 + * Some defaults for major revisions, so that newer steppings
 + * that we don't know about have a shot at working.
 + */
 +static const struct bge_revision bge_majorrevs[] = {
 +	{ BGE_ASICREV_BCM5700,
 +	  "unknown BCM5700" },
 +
 +	{ BGE_ASICREV_BCM5701,
 +	  "unknown BCM5701" },
 +
 +	{ BGE_ASICREV_BCM5703,
 +	  "unknown BCM5703" },
 +
 +	{ BGE_ASICREV_BCM5704,
 +	  "unknown BCM5704" },
 +
 +	{ BGE_ASICREV_BCM5705,
 +	  "unknown BCM5705" },
 +
 +	{ BGE_ASICREV_BCM5750,
 +	  "unknown BCM5750" },
 +
 +	{ BGE_ASICREV_BCM5714_A0,
 +	  "unknown BCM5714" },
 +
 +	{ BGE_ASICREV_BCM5752,
 +	  "unknown BCM5752" },
 +
 +	{ BGE_ASICREV_BCM5780,
 +	  "unknown BCM5780" },
 +
 +	{ BGE_ASICREV_BCM5714,
 +	  "unknown BCM5714" },
 +
 +	{ 0, NULL }
 +};
 +
 +const struct bge_revision * bge_lookup_rev(uint32_t);
 +static int bge_probe(device_t);
 +static int bge_attach(device_t);
 +static int bge_detach(device_t);
 +static int bge_suspend(device_t);
 +static int bge_resume(device_t);
 +static void bge_release_resources(struct bge_softc *);
 +static void bge_dma_map_addr(void *, bus_dma_segment_t *, int, int);
 +static int bge_dma_alloc(device_t);
 +static void bge_dma_free(struct bge_softc *);
 +
 +static void bge_txeof(struct bge_softc *);
 +static void bge_rxeof(struct bge_softc *);
 +
 +static void bge_tick_locked(struct bge_softc *);
 +static void bge_tick(void *);
 +static void bge_stats_update(struct bge_softc *);
 +static void bge_stats_update_regs(struct bge_softc *);
 +static int bge_encap(struct bge_softc *, struct mbuf *, uint32_t *);
 +
 +static void bge_intr(void *);
 +static void bge_start_locked(struct ifnet *);
 +static void bge_start(struct ifnet *);
 +static int bge_ioctl(struct ifnet *, u_long, caddr_t);
 +static void bge_init_locked(struct bge_softc *);
 +static void bge_init(void *);
 +static void bge_stop(struct bge_softc *);
 +static void bge_watchdog(struct ifnet *);
 +static void bge_shutdown(device_t);
 +static int bge_ifmedia_upd(struct ifnet *);
 +static void bge_ifmedia_sts(struct ifnet *, struct ifmediareq *);
 +
 +static uint8_t bge_eeprom_getbyte(struct bge_softc *, int, uint8_t *);
 +static int bge_read_eeprom(struct bge_softc *, caddr_t, int, int);
 +
 +static void bge_setmulti(struct bge_softc *);
 +
 +static int bge_newbuf_std(struct bge_softc *, int, struct mbuf *);
 +static int bge_newbuf_jumbo(struct bge_softc *, int, struct mbuf *);
 +static int bge_init_rx_ring_std(struct bge_softc *);
 +static void bge_free_rx_ring_std(struct bge_softc *);
 +static int bge_init_rx_ring_jumbo(struct bge_softc *);
 +static void bge_free_rx_ring_jumbo(struct bge_softc *);
 +static void bge_free_tx_ring(struct bge_softc *);
 +static int bge_init_tx_ring(struct bge_softc *);
 +
 +static int bge_chipinit(struct bge_softc *);
 +static int bge_blockinit(struct bge_softc *);
  
  #ifdef notdef
 -static u_int8_t bge_vpd_readbyte(struct bge_softc *, int);
 -static void bge_vpd_read_res	(struct bge_softc *, struct vpd_res *, int);
 -static void bge_vpd_read	(struct bge_softc *);
 +static uint8_t bge_vpd_readbyte(struct bge_softc *, int);
 +static void bge_vpd_read_res(struct bge_softc *, struct vpd_res *, int);
 +static void bge_vpd_read(struct bge_softc *);
  #endif
  
 -static u_int32_t bge_readmem_ind
 -				(struct bge_softc *, int);
 -static void bge_writemem_ind	(struct bge_softc *, int, int);
 +static uint32_t bge_readmem_ind(struct bge_softc *, int);
 +static void bge_writemem_ind(struct bge_softc *, int, int);
  #ifdef notdef
 -static u_int32_t bge_readreg_ind
 -				(struct bge_softc *, int);
 +static uint32_t bge_readreg_ind(struct bge_softc *, int);
  #endif
 -static void bge_writereg_ind	(struct bge_softc *, int, int);
 +static void bge_writereg_ind(struct bge_softc *, int, int);
  
 -static int bge_miibus_readreg	(device_t, int, int);
 -static int bge_miibus_writereg	(device_t, int, int, int);
 -static void bge_miibus_statchg	(device_t);
 +static int bge_miibus_readreg(device_t, int, int);
 +static int bge_miibus_writereg(device_t, int, int, int);
 +static void bge_miibus_statchg(device_t);
  #ifdef DEVICE_POLLING
 -static void bge_poll		(struct ifnet *ifp, enum poll_cmd cmd,
 -				    int count);
 -static void bge_poll_locked	(struct ifnet *ifp, enum poll_cmd cmd,
 -				    int count);
 +static void bge_poll(struct ifnet *ifp, enum poll_cmd cmd, int count);
  #endif
  
 -static void bge_reset		(struct bge_softc *);
 -static void bge_link_upd	(struct bge_softc *);
 +static void bge_reset(struct bge_softc *);
 +static void bge_link_upd(struct bge_softc *);
  
  static device_method_t bge_methods[] = {
  	/* Device interface */
 @@ -306,23 +481,22 @@
  DRIVER_MODULE(bge, pci, bge_driver, bge_devclass, 0, 0);
  DRIVER_MODULE(miibus, bge, miibus_driver, miibus_devclass, 0, 0);
  
 -static u_int32_t
 -bge_readmem_ind(sc, off)
 -	struct bge_softc *sc;
 -	int off;
 +static int bge_fake_autoneg = 0;
 +TUNABLE_INT("hw.bge.fake_autoneg", &bge_fake_autoneg);
 +
 +static uint32_t
 +bge_readmem_ind(struct bge_softc *sc, int off)
  {
  	device_t dev;
  
  	dev = sc->bge_dev;
  
  	pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4);
 -	return(pci_read_config(dev, BGE_PCI_MEMWIN_DATA, 4));
 +	return (pci_read_config(dev, BGE_PCI_MEMWIN_DATA, 4));
  }
  
  static void
 -bge_writemem_ind(sc, off, val)
 -	struct bge_softc *sc;
 -	int off, val;
 +bge_writemem_ind(struct bge_softc *sc, int off, int val)
  {
  	device_t dev;
  
 @@ -330,29 +504,23 @@
  
  	pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4);
  	pci_write_config(dev, BGE_PCI_MEMWIN_DATA, val, 4);
 -
 -	return;
  }
  
  #ifdef notdef
 -static u_int32_t
 -bge_readreg_ind(sc, off)
 -	struct bge_softc *sc;
 -	int off;
 +static uint32_t
 +bge_readreg_ind(struct bge_softc *sc, int off)
  {
  	device_t dev;
  
  	dev = sc->bge_dev;
  
  	pci_write_config(dev, BGE_PCI_REG_BASEADDR, off, 4);
 -	return(pci_read_config(dev, BGE_PCI_REG_DATA, 4));
 +	return (pci_read_config(dev, BGE_PCI_REG_DATA, 4));
  }
  #endif
  
  static void
 -bge_writereg_ind(sc, off, val)
 -	struct bge_softc *sc;
 -	int off, val;
 +bge_writereg_ind(struct bge_softc *sc, int off, int val)
  {
  	device_t dev;
  
 @@ -360,8 +528,6 @@
  
  	pci_write_config(dev, BGE_PCI_REG_BASEADDR, off, 4);
  	pci_write_config(dev, BGE_PCI_REG_DATA, val, 4);
 -
 -	return;
  }
  
  /*
 @@ -369,11 +535,7 @@
   */
  
  static void
 -bge_dma_map_addr(arg, segs, nseg, error)
 -	void *arg;
 -	bus_dma_segment_t *segs;
 -	int nseg;
 -	int error;
 +bge_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
  {
  	struct bge_dmamap_arg *ctx;
  
 @@ -388,19 +550,15 @@
  	}
  
  	ctx->bge_busaddr = segs->ds_addr;
 -
 -	return;
  }
  
  #ifdef notdef
 -static u_int8_t
 -bge_vpd_readbyte(sc, addr)
 -	struct bge_softc *sc;
 -	int addr;
 +static uint8_t
 +bge_vpd_readbyte(struct bge_softc *sc, int addr)
  {
  	int i;
  	device_t dev;
 -	u_int32_t val;
 +	uint32_t val;
  
  	dev = sc->bge_dev;
  	pci_write_config(dev, BGE_PCI_VPD_ADDR, addr, 2);
 @@ -412,36 +570,30 @@
  
  	if (i == BGE_TIMEOUT) {
  		device_printf(sc->bge_dev, "VPD read timed out\n");
 -		return(0);
 +		return (0);
  	}
  
  	val = pci_read_config(dev, BGE_PCI_VPD_DATA, 4);
  
 -	return((val >> ((addr % 4) * 8)) & 0xFF);
 +	return ((val >> ((addr % 4) * 8)) & 0xFF);
  }
  
  static void
 -bge_vpd_read_res(sc, res, addr)
 -	struct bge_softc *sc;
 -	struct vpd_res *res;
 -	int addr;
 +bge_vpd_read_res(struct bge_softc *sc, struct vpd_res *res, int addr)
  {
  	int i;
 -	u_int8_t *ptr;
 +	uint8_t *ptr;
  
 -	ptr = (u_int8_t *)res;
 +	ptr = (uint8_t *)res;
  	for (i = 0; i < sizeof(struct vpd_res); i++)
  		ptr[i] = bge_vpd_readbyte(sc, i + addr);
 -
 -	return;
  }
  
  static void
 -bge_vpd_read(sc)
 -	struct bge_softc *sc;
 +bge_vpd_read(struct bge_softc *sc)
  {
 -	int pos = 0, i;
  	struct vpd_res res;
 +	int i, pos = 0;
  
  	if (sc->bge_vpd_prodname != NULL)
  		free(sc->bge_vpd_prodname, M_DEVBUF);
 @@ -479,8 +631,6 @@
  	sc->bge_vpd_readonly = malloc(res.vr_len, M_DEVBUF, M_NOWAIT);
  	for (i = 0; i < res.vr_len + 1; i++)
  		sc->bge_vpd_readonly[i] = bge_vpd_readbyte(sc, i + pos);
 -
 -	return;
  }
  #endif
  
 @@ -490,14 +640,11 @@
   * auto access interface for reading the EEPROM. We use the auto
   * access method.
   */
 -static u_int8_t
 -bge_eeprom_getbyte(sc, addr, dest)
 -	struct bge_softc *sc;
 -	int addr;
 -	u_int8_t *dest;
 +static uint8_t
 +bge_eeprom_getbyte(struct bge_softc *sc, int addr, uint8_t *dest)
  {
  	int i;
 -	u_int32_t byte = 0;
 +	uint32_t byte = 0;
  
  	/*
  	 * Enable use of auto EEPROM access so we can avoid
 @@ -522,7 +669,7 @@
  
  	if (i == BGE_TIMEOUT) {
  		device_printf(sc->bge_dev, "EEPROM read timed out\n");
 -		return(1);
 +		return (1);
  	}
  
  	/* Get result. */
 @@ -530,39 +677,33 @@
  
  	*dest = (byte >> ((addr % 4) * 8)) & 0xFF;
  
 -	return(0);
 +	return (0);
  }
  
  /*
   * Read a sequence of bytes from the EEPROM.
   */
  static int
 -bge_read_eeprom(sc, dest, off, cnt)
 -	struct bge_softc *sc;
 -	caddr_t dest;
 -	int off;
 -	int cnt;
 +bge_read_eeprom(struct bge_softc *sc, caddr_t dest, int off, int cnt)
  {
 -	int err = 0, i;
 -	u_int8_t byte = 0;
 +	int i, error = 0;
 +	uint8_t byte = 0;
  
  	for (i = 0; i < cnt; i++) {
 -		err = bge_eeprom_getbyte(sc, off + i, &byte);
 -		if (err)
 +		error = bge_eeprom_getbyte(sc, off + i, &byte);
 +		if (error)
  			break;
  		*(dest + i) = byte;
  	}
  
 -	return(err ? 1 : 0);
 +	return (error ? 1 : 0);
  }
  
  static int
 -bge_miibus_readreg(dev, phy, reg)
 -	device_t dev;
 -	int phy, reg;
 +bge_miibus_readreg(device_t dev, int phy, int reg)
  {
  	struct bge_softc *sc;
 -	u_int32_t val, autopoll;
 +	uint32_t val, autopoll;
  	int i;
  
  	sc = device_get_softc(dev);
 @@ -577,7 +718,7 @@
  	 * special-cased.
  	 */
  	if (phy != 1)
 -		return(0);
 +		return (0);
  
  	/* Reading with autopolling on may trigger PCI errors */
  	autopoll = CSR_READ_4(sc, BGE_MI_MODE);
 @@ -610,18 +751,16 @@
  	}
  
  	if (val & BGE_MICOMM_READFAIL)
 -		return(0);
 +		return (0);
  
 -	return(val & 0xFFFF);
 +	return (val & 0xFFFF);
  }
  
  static int
 -bge_miibus_writereg(dev, phy, reg, val)
 -	device_t dev;
 -	int phy, reg, val;
 +bge_miibus_writereg(device_t dev, int phy, int reg, int val)
  {
  	struct bge_softc *sc;
 -	u_int32_t autopoll;
 +	uint32_t autopoll;
  	int i;
  
  	sc = device_get_softc(dev);
 @@ -648,15 +787,14 @@
  
  	if (i == BGE_TIMEOUT) {
  		if_printf(sc->bge_ifp, "PHY read timed out\n");
 -		return(0);
 +		return (0);
  	}
  
 -	return(0);
 +	return (0);
  }
  
  static void
 -bge_miibus_statchg(dev)
 -	device_t dev;
 +bge_miibus_statchg(device_t dev)
  {
  	struct bge_softc *sc;
  	struct mii_data *mii;
 @@ -665,39 +803,32 @@
  	mii = device_get_softc(sc->bge_miibus);
  
  	BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE);
 -	if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) {
 +	if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T)
  		BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_GMII);
 -	} else {
 +	else
  		BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_MII);
 -	}
  
 -	if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) {
 +	if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
  		BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_HALF_DUPLEX);
 -	} else {
 +	else
  		BGE_SETBIT(sc, BGE_MAC_MODE, BGE_MACMODE_HALF_DUPLEX);
 -	}
 -
 -	return;
  }
  
  /*
   * Intialize a standard receive ring descriptor.
   */
  static int
 -bge_newbuf_std(sc, i, m)
 -	struct bge_softc	*sc;
 -	int			i;
 -	struct mbuf		*m;
 -{
 -	struct mbuf		*m_new = NULL;
 -	struct bge_rx_bd	*r;
 -	struct bge_dmamap_arg	ctx;
 -	int			error;
 +bge_newbuf_std(struct bge_softc *sc, int i, struct mbuf *m)
 +{
 +	struct mbuf *m_new = NULL;
 +	struct bge_rx_bd *r;
 +	struct bge_dmamap_arg ctx;
 +	int error;
  
  	if (m == NULL) {
  		m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
  		if (m_new == NULL)
 -			return(ENOBUFS);
 +			return (ENOBUFS);
  		m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
  	} else {
  		m_new = m;
 @@ -719,7 +850,7 @@
  			sc->bge_cdata.bge_rx_std_chain[i] = NULL;
  			m_freem(m_new);
  		}
 -		return(ENOMEM);
 +		return (ENOMEM);
  	}
  	r->bge_addr.bge_addr_lo = BGE_ADDR_LO(ctx.bge_busaddr);
  	r->bge_addr.bge_addr_hi = BGE_ADDR_HI(ctx.bge_busaddr);
 @@ -731,7 +862,7 @@
  	    sc->bge_cdata.bge_rx_std_dmamap[i],
  	    BUS_DMASYNC_PREREAD);
  
 -	return(0);
 +	return (0);
  }
  
  /*
 @@ -739,10 +870,7 @@
   * a jumbo buffer from the pool managed internally by the driver.
   */
  static int
 -bge_newbuf_jumbo(sc, i, m)
 -	struct bge_softc *sc;
 -	int i;
 -	struct mbuf *m;
 +bge_newbuf_jumbo(struct bge_softc *sc, int i, struct mbuf *m)
  {
  	bus_dma_segment_t segs[BGE_NSEG_JUMBO];
  	struct bge_extrx_bd *r;
 @@ -753,12 +881,12 @@
  	if (m == NULL) {
  		MGETHDR(m_new, M_DONTWAIT, MT_DATA);
  		if (m_new == NULL)
 -			return(ENOBUFS);
 +			return (ENOBUFS);
  
  		m_cljget(m_new, M_DONTWAIT, MJUM9BYTES);
  		if (!(m_new->m_flags & M_EXT)) {
  			m_freem(m_new);
 -			return(ENOBUFS);
 +			return (ENOBUFS);
  		}
  		m_new->m_len = m_new->m_pkthdr.len = MJUM9BYTES;
  	} else {
 @@ -776,7 +904,7 @@
  	if (error) {
  		if (m == NULL)
  			m_freem(m_new);
 -		return(error);
 +		return (error);
  	}
  	sc->bge_cdata.bge_rx_jumbo_chain[i] = m_new;
  
 @@ -823,14 +951,13 @@
   * the NIC.
   */
  static int
 -bge_init_rx_ring_std(sc)
 -	struct bge_softc *sc;
 +bge_init_rx_ring_std(struct bge_softc *sc)
  {
  	int i;
  
  	for (i = 0; i < BGE_SSLOTS; i++) {
  		if (bge_newbuf_std(sc, i, NULL) == ENOBUFS)
 -			return(ENOBUFS);
 +			return (ENOBUFS);
  	};
  
  	bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
 @@ -840,12 +967,11 @@
  	sc->bge_std = i - 1;
  	CSR_WRITE_4(sc, BGE_MBX_RX_STD_PROD_LO, sc->bge_std);
  
 -	return(0);
 +	return (0);
  }
  
  static void
 -bge_free_rx_ring_std(sc)
 -	struct bge_softc *sc;
 +bge_free_rx_ring_std(struct bge_softc *sc)
  {
  	int i;
  
 @@ -862,20 +988,17 @@
  		bzero((char *)&sc->bge_ldata.bge_rx_std_ring[i],
  		    sizeof(struct bge_rx_bd));
  	}
 -
 -	return;
  }
  
  static int
 -bge_init_rx_ring_jumbo(sc)
 -	struct bge_softc *sc;
 +bge_init_rx_ring_jumbo(struct bge_softc *sc)
  {
  	struct bge_rcb *rcb;
  	int i;
  
  	for (i = 0; i < BGE_JUMBO_RX_RING_CNT; i++) {
  		if (bge_newbuf_jumbo(sc, i, NULL) == ENOBUFS)
 -			return(ENOBUFS);
 +			return (ENOBUFS);
  	};
  
  	bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
 @@ -891,12 +1014,11 @@
  
  	CSR_WRITE_4(sc, BGE_MBX_RX_JUMBO_PROD_LO, sc->bge_jumbo);
  
 -	return(0);
 +	return (0);
  }
  
  static void
 -bge_free_rx_ring_jumbo(sc)
 -	struct bge_softc *sc;
 +bge_free_rx_ring_jumbo(struct bge_softc *sc)
  {
  	int i;
  
 @@ -913,13 +1035,10 @@
  		bzero((char *)&sc->bge_ldata.bge_rx_jumbo_ring[i],
  		    sizeof(struct bge_extrx_bd));
  	}
 -
 -	return;
  }
  
  static void
 -bge_free_tx_ring(sc)
 -	struct bge_softc *sc;
 +bge_free_tx_ring(struct bge_softc *sc)
  {
  	int i;
  
 @@ -939,13 +1058,10 @@
  		bzero((char *)&sc->bge_ldata.bge_tx_ring[i],
  		    sizeof(struct bge_tx_bd));
  	}
 -
 -	return;
  }
  
  static int
 -bge_init_tx_ring(sc)
 -	struct bge_softc *sc;
 +bge_init_tx_ring(struct bge_softc *sc)
  {
  	sc->bge_txcnt = 0;
  	sc->bge_tx_saved_considx = 0;
 @@ -964,16 +1080,15 @@
  	if (sc->bge_chiprev == BGE_CHIPREV_5700_BX)
  		CSR_WRITE_4(sc, BGE_MBX_TX_NIC_PROD0_LO, 0);
  
 -	return(0);
 +	return (0);
  }
  
  static void
 -bge_setmulti(sc)
 -	struct bge_softc *sc;
 +bge_setmulti(struct bge_softc *sc)
  {
  	struct ifnet *ifp;
  	struct ifmultiaddr *ifma;
 -	u_int32_t hashes[4] = { 0, 0, 0, 0 };
 +	uint32_t hashes[4] = { 0, 0, 0, 0 };
  	int h, i;
  
  	BGE_LOCK_ASSERT(sc);
 @@ -1003,8 +1118,6 @@
  
  	for (i = 0; i < 4; i++)
  		CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), hashes[i]);
 -
 -	return;
  }
  
  /*
 @@ -1012,11 +1125,10 @@
   * self-test results.
   */
  static int
 -bge_chipinit(sc)
 -	struct bge_softc *sc;
 +bge_chipinit(struct bge_softc *sc)
  {
 -	int			i;
 -	u_int32_t		dma_rw_ctl;
 +	uint32_t dma_rw_ctl;
 +	int i;
  
  	/* Set endian type before we access any non-PCI registers. */
  	pci_write_config(sc->bge_dev, BGE_PCI_MISC_CTL, BGE_INIT, 4);
 @@ -1027,7 +1139,7 @@
  	 */
  	if (CSR_READ_4(sc, BGE_RXCPU_MODE) & BGE_RXCPUMODE_ROMFAIL) {
  		device_printf(sc->bge_dev, "RX CPU self-diagnostics failed!\n");
 -		return(ENODEV);
 +		return (ENODEV);
  	}
  
  	/* Clear the MAC control register */
 @@ -1038,32 +1150,36 @@
  	 * internal memory.
  	 */
  	for (i = BGE_STATS_BLOCK;
 -	    i < BGE_STATS_BLOCK_END + 1; i += sizeof(u_int32_t))
 +	    i < BGE_STATS_BLOCK_END + 1; i += sizeof(uint32_t))
  		BGE_MEMWIN_WRITE(sc, i, 0);
  
  	for (i = BGE_STATUS_BLOCK;
 -	    i < BGE_STATUS_BLOCK_END + 1; i += sizeof(u_int32_t))
 +	    i < BGE_STATUS_BLOCK_END + 1; i += sizeof(uint32_t))
  		BGE_MEMWIN_WRITE(sc, i, 0);
  
  	/* Set up the PCI DMA control register. */
  	if (sc->bge_pcie) {
 +		/* PCI Express bus */
  		dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
  		    (0xf << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
  		    (0x2 << BGE_PCIDMARWCTL_WR_WAT_SHIFT);
 -	} else if (pci_read_config(sc->bge_dev, BGE_PCI_PCISTATE, 4) &
 -	    BGE_PCISTATE_PCI_BUSMODE) {
 -		/* Conventional PCI bus */
 -		dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 -		    (0x7 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
 -		    (0x7 << BGE_PCIDMARWCTL_WR_WAT_SHIFT) |
 -		    (0x0F);
 -	} else {
 +	} else if (sc->bge_pcix) {
  		/* PCI-X bus */
 -		/*
 -		 * The 5704 uses a different encoding of read/write
 -		 * watermarks.
 -		 */
 -		if (sc->bge_asicrev == BGE_ASICREV_BCM5704)
 +		if (BGE_IS_5714_FAMILY(sc)) {
 +			dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD;
 +			dma_rw_ctl &= ~BGE_PCIDMARWCTL_ONEDMA_ATONCE; /* XXX */
 +			/* XXX magic values, Broadcom-supplied Linux driver */
 +			if (sc->bge_asicrev == BGE_ASICREV_BCM5780)
 +				dma_rw_ctl |= (1 << 20) | (1 << 18) | 
 +				    BGE_PCIDMARWCTL_ONEDMA_ATONCE;
 +			else
 +				dma_rw_ctl |= (1 << 20) | (1 << 18) | (1 << 15);
 +
 +		} else if (sc->bge_asicrev == BGE_ASICREV_BCM5704)
 +			/*
 +			 * The 5704 uses a different encoding of read/write
 +			 * watermarks.
 +			 */
  			dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
  			    (0x7 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
  			    (0x3 << BGE_PCIDMARWCTL_WR_WAT_SHIFT);
 @@ -1079,18 +1195,22 @@
  		 */
  		if (sc->bge_asicrev == BGE_ASICREV_BCM5703 ||
  		    sc->bge_asicrev == BGE_ASICREV_BCM5704) {
 -			u_int32_t tmp;
 +			uint32_t tmp;
  
  			tmp = CSR_READ_4(sc, BGE_PCI_CLKCTL) & 0x1f;
  			if (tmp == 0x6 || tmp == 0x7)
  				dma_rw_ctl |= BGE_PCIDMARWCTL_ONEDMA_ATONCE;
  		}
 -	}
 +	} else
 +		/* Conventional PCI bus */
 +		dma_rw_ctl = BGE_PCI_READ_CMD|BGE_PCI_WRITE_CMD |
 +		    (0x7 << BGE_PCIDMARWCTL_RD_WAT_SHIFT) |
 +		    (0x7 << BGE_PCIDMARWCTL_WR_WAT_SHIFT) |
 +		    (0x0F);
  
  	if (sc->bge_asicrev == BGE_ASICREV_BCM5703 ||
  	    sc->bge_asicrev == BGE_ASICREV_BCM5704 ||
 -	    sc->bge_asicrev == BGE_ASICREV_BCM5705 ||
 -	    sc->bge_asicrev == BGE_ASICREV_BCM5750)
 +	    sc->bge_asicrev == BGE_ASICREV_BCM5705)
  		dma_rw_ctl &= ~BGE_PCIDMARWCTL_MINDMA;
  	pci_write_config(sc->bge_dev, BGE_PCI_DMA_RW_CTL, dma_rw_ctl, 4);
  
 @@ -1121,12 +1241,11 @@
  	/* Set the timer prescaler (always 66Mhz) */
  	CSR_WRITE_4(sc, BGE_MISC_CFG, 65 << 1/*BGE_32BITTIME_66MHZ*/);
  
 -	return(0);
 +	return (0);
  }
  
  static int
 -bge_blockinit(sc)
 -	struct bge_softc *sc;
 +bge_blockinit(struct bge_softc *sc)
  {
  	struct bge_rcb *rcb;
  	bus_size_t vrcb;
 @@ -1143,8 +1262,7 @@
  
  	/* Note: the BCM5704 has a smaller mbuf space than other chips. */
  
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 +	if (!(BGE_IS_5705_OR_BEYOND(sc))) {
  		/* Configure mbuf memory pool */
  		if (sc->bge_extram) {
  			CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_BASEADDR,
 @@ -1169,8 +1287,7 @@
  	}
  
  	/* Configure mbuf pool watermarks */
 -	if (sc->bge_asicrev == BGE_ASICREV_BCM5705 ||
 -	    sc->bge_asicrev == BGE_ASICREV_BCM5750) {
 +	if (!(BGE_IS_5705_OR_BEYOND(sc))) {
  		CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0);
  		CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x10);
  	} else {
 @@ -1184,8 +1301,7 @@
  	CSR_WRITE_4(sc, BGE_BMAN_DMA_DESCPOOL_HIWAT, 10);
  
  	/* Enable buffer manager */
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 +	if (!(BGE_IS_5705_OR_BEYOND(sc))) {
  		CSR_WRITE_4(sc, BGE_BMAN_MODE,
  		    BGE_BMANMODE_ENABLE|BGE_BMANMODE_LOMBUF_ATTN);
  
 @@ -1199,7 +1315,7 @@
  		if (i == BGE_TIMEOUT) {
  			device_printf(sc->bge_dev,
  			    "buffer manager failed to start\n");
 -			return(ENXIO);
 +			return (ENXIO);
  		}
  	}
  
 @@ -1216,7 +1332,7 @@
  
  	if (i == BGE_TIMEOUT) {
  		device_printf(sc->bge_dev, "flow-through queue init failed\n");
 -		return(ENXIO);
 +		return (ENXIO);
  	}
  
  	/* Initialize the standard RX ring control block */
 @@ -1227,8 +1343,7 @@
  	    BGE_ADDR_HI(sc->bge_ldata.bge_rx_std_ring_paddr);
  	bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
  	    sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_PREREAD);
 -	if (sc->bge_asicrev == BGE_ASICREV_BCM5705 ||
 -	    sc->bge_asicrev == BGE_ASICREV_BCM5750)
 +	if (BGE_IS_5705_OR_BEYOND(sc))
  		rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(512, 0);
  	else
  		rcb->bge_maxlen_flags =
 @@ -1250,8 +1365,7 @@
  	 * using this ring (i.e. once we set the MTU
  	 * high enough to require it).
  	 */
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 +	if (BGE_IS_JUMBO_CAPABLE(sc)) {
  		rcb = &sc->bge_ldata.bge_info.bge_jumbo_rx_rcb;
  
  		rcb->bge_hostaddr.bge_addr_lo =
 @@ -1312,8 +1426,7 @@
  	RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_lo, taddr.bge_addr_lo);
  	RCB_WRITE_4(sc, vrcb, bge_nicaddr,
  	    BGE_NIC_TXRING_ADDR(0, BGE_TX_RING_CNT));
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (!(BGE_IS_5705_OR_BEYOND(sc)))
  		RCB_WRITE_4(sc, vrcb, bge_maxlen_flags,
  		    BGE_RCB_MAXLEN_FLAGS(BGE_TX_RING_CNT, 0));
  
 @@ -1327,7 +1440,7 @@
  		    BGE_RCB_FLAG_RING_DISABLED));
  		RCB_WRITE_4(sc, vrcb, bge_nicaddr, 0);
  		CSR_WRITE_4(sc, BGE_MBX_RX_CONS0_LO +
 -		    (i * (sizeof(u_int64_t))), 0);
 +		    (i * (sizeof(uint64_t))), 0);
  		vrcb += sizeof(struct bge_rcb);
  	}
  
 @@ -1352,9 +1465,9 @@
  
  	/* Set random backoff seed for TX */
  	CSR_WRITE_4(sc, BGE_TX_RANDOM_BACKOFF,
 -	    IFP2ENADDR(sc->bge_ifp)[0] + IFP2ENADDR(sc->bge_ifp)[1] +
 -	    IFP2ENADDR(sc->bge_ifp)[2] + IFP2ENADDR(sc->bge_ifp)[3] +
 -	    IFP2ENADDR(sc->bge_ifp)[4] + IFP2ENADDR(sc->bge_ifp)[5] +
 +	    IF_LLADDR(sc->bge_ifp)[0] + IF_LLADDR(sc->bge_ifp)[1] +
 +	    IF_LLADDR(sc->bge_ifp)[2] + IF_LLADDR(sc->bge_ifp)[3] +
 +	    IF_LLADDR(sc->bge_ifp)[4] + IF_LLADDR(sc->bge_ifp)[5] +
  	    BGE_TX_BACKOFF_SEED_MASK);
  
  	/* Set inter-packet gap */
 @@ -1389,7 +1502,7 @@
  	if (i == BGE_TIMEOUT) {
  		device_printf(sc->bge_dev,
  		    "host coalescing engine failed to idle\n");
 -		return(ENXIO);
 +		return (ENXIO);
  	}
  
  	/* Set up host coalescing defaults */
 @@ -1397,8 +1510,7 @@
  	CSR_WRITE_4(sc, BGE_HCC_TX_COAL_TICKS, sc->bge_tx_coal_ticks);
  	CSR_WRITE_4(sc, BGE_HCC_RX_MAX_COAL_BDS, sc->bge_rx_max_coal_bds);
  	CSR_WRITE_4(sc, BGE_HCC_TX_MAX_COAL_BDS, sc->bge_tx_max_coal_bds);
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 +	if (!(BGE_IS_5705_OR_BEYOND(sc))) {
  		CSR_WRITE_4(sc, BGE_HCC_RX_COAL_TICKS_INT, 0);
  		CSR_WRITE_4(sc, BGE_HCC_TX_COAL_TICKS_INT, 0);
  	}
 @@ -1406,8 +1518,7 @@
  	CSR_WRITE_4(sc, BGE_HCC_TX_MAX_COAL_BDS_INT, 0);
  
  	/* Set up address of statistics block */
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 +	if (!(BGE_IS_5705_OR_BEYOND(sc))) {
  		CSR_WRITE_4(sc, BGE_HCC_STATS_ADDR_HI,
  		    BGE_ADDR_HI(sc->bge_ldata.bge_stats_paddr));
  		CSR_WRITE_4(sc, BGE_HCC_STATS_ADDR_LO,
 @@ -1436,8 +1547,7 @@
  	CSR_WRITE_4(sc, BGE_RXLP_MODE, BGE_RXLPMODE_ENABLE);
  
  	/* Turn on RX list selector state machine. */
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (!(BGE_IS_5705_OR_BEYOND(sc)))
  		CSR_WRITE_4(sc, BGE_RXLS_MODE, BGE_RXLSMODE_ENABLE);
  
  	/* Turn on DMA, clear stats */
 @@ -1459,8 +1569,7 @@
  #endif
  
  	/* Turn on DMA completion state machine */
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (!(BGE_IS_5705_OR_BEYOND(sc)))
  		CSR_WRITE_4(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE);
  
  	/* Turn on write DMA state machine */
 @@ -1481,8 +1590,7 @@
  	CSR_WRITE_4(sc, BGE_RDBDI_MODE, BGE_RDBDIMODE_ENABLE);
  
  	/* Turn on Mbuf cluster free state machine */
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (!(BGE_IS_5705_OR_BEYOND(sc)))
  		CSR_WRITE_4(sc, BGE_MBCF_MODE, BGE_MBCFMODE_ENABLE);
  
  	/* Turn on send BD completion state machine */
 @@ -1516,7 +1624,7 @@
  	} else {
  		BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL|10<<16);
  		if (sc->bge_asicrev == BGE_ASICREV_BCM5700 &&
 -		    sc->bge_chipid != BGE_CHIPID_BCM5700_B1)
 +		    sc->bge_chipid != BGE_CHIPID_BCM5700_B2)
  			CSR_WRITE_4(sc, BGE_MAC_EVT_ENB,
  			    BGE_EVTENB_MI_INTERRUPT);
  	}
 @@ -1535,7 +1643,25 @@
  	/* Enable link state change attentions. */
  	BGE_SETBIT(sc, BGE_MAC_EVT_ENB, BGE_EVTENB_LINK_CHANGED);
  
 -	return(0);
 +	return (0);
 +}
 +
 +const struct bge_revision *
 +bge_lookup_rev(uint32_t chipid)
 +{
 +	const struct bge_revision *br;
 +
 +	for (br = bge_revisions; br->br_name != NULL; br++) {
 +		if (br->br_chipid == chipid)
 +			return (br);
 +	}
 +
 +	for (br = bge_majorrevs; br->br_name != NULL; br++) {
 +		if (br->br_chipid == BGE_ASICREV(chipid))
 +			return (br);
 +	}
 +
 +	return (NULL);
  }
  
  /*
 @@ -1547,69 +1673,65 @@
   * we'll always announce the right product name.
   */
  static int
 -bge_probe(dev)
 -	device_t dev;
 +bge_probe(device_t dev)
  {
 -	struct bge_type *t;
 -	struct bge_softc *sc;
 -	char *descbuf;
 +	struct bge_type *t = bge_devs;
 +	struct bge_softc *sc = device_get_softc(dev);
  
 -	t = bge_devs;
 -
 -	sc = device_get_softc(dev);
  	bzero(sc, sizeof(struct bge_softc));
  	sc->bge_dev = dev;
  
 -	while(t->bge_name != NULL) {
 +	while(t->bge_vid != 0) {
  		if ((pci_get_vendor(dev) == t->bge_vid) &&
  		    (pci_get_device(dev) == t->bge_did)) {
 +			char buf[64];
 +			const struct bge_revision *br;
 +			uint32_t id;
 +
  #ifdef notdef
  			bge_vpd_read(sc);
  			device_set_desc(dev, sc->bge_vpd_prodname);
  #endif
 -			descbuf = malloc(BGE_DEVDESC_MAX, M_TEMP, M_NOWAIT);
 -			if (descbuf == NULL)
 -				return(ENOMEM);
 -			snprintf(descbuf, BGE_DEVDESC_MAX,
 -			    "%s, ASIC rev. %#04x", t->bge_name,
 -			    pci_read_config(dev, BGE_PCI_MISC_CTL, 4) >> 16);
 -			device_set_desc_copy(dev, descbuf);
 +			id = pci_read_config(dev, BGE_PCI_MISC_CTL, 4) &
 +			    BGE_PCIMISCCTL_ASICREV;
 +			br = bge_lookup_rev(id);
 +			id >>= 16;
 +			if (br == NULL)
 +				snprintf(buf, 64, "unknown ASIC (%#04x)", id);
 +			else
 +				snprintf(buf, 64, "%s, ASIC rev. %#04x",
 +				    br->br_name, id);
 +			device_set_desc_copy(dev, buf);
  			if (pci_get_subvendor(dev) == DELL_VENDORID)
  				sc->bge_no_3_led = 1;
 -			free(descbuf, M_TEMP);
 -			return(0);
 +			return (0);
  		}
  		t++;
  	}
  
 -	return(ENXIO);
 +	return (ENXIO);
  }
  
  static void
 -bge_dma_free(sc)
 -	struct bge_softc *sc;
 +bge_dma_free(struct bge_softc *sc)
  {
  	int i;
  
 -
 -	/* Destroy DMA maps for RX buffers */
 -
 +	/* Destroy DMA maps for RX buffers. */
  	for (i = 0; i < BGE_STD_RX_RING_CNT; i++) {
  		if (sc->bge_cdata.bge_rx_std_dmamap[i])
  			bus_dmamap_destroy(sc->bge_cdata.bge_mtag,
  			    sc->bge_cdata.bge_rx_std_dmamap[i]);
  	}
  
 -	/* Destroy DMA maps for jumbo RX buffers */
 -
 +	/* Destroy DMA maps for jumbo RX buffers. */
  	for (i = 0; i < BGE_JUMBO_RX_RING_CNT; i++) {
  		if (sc->bge_cdata.bge_rx_jumbo_dmamap[i])
  			bus_dmamap_destroy(sc->bge_cdata.bge_mtag_jumbo,
  			    sc->bge_cdata.bge_rx_jumbo_dmamap[i]);
  	}
  
 -	/* Destroy DMA maps for TX buffers */
 -
 +	/* Destroy DMA maps for TX buffers. */
  	for (i = 0; i < BGE_TX_RING_CNT; i++) {
  		if (sc->bge_cdata.bge_tx_dmamap[i])
  			bus_dmamap_destroy(sc->bge_cdata.bge_mtag,
 @@ -1620,8 +1742,7 @@
  		bus_dma_tag_destroy(sc->bge_cdata.bge_mtag);
  
  
 -	/* Destroy standard RX ring */
 -
 +	/* Destroy standard RX ring. */
  	if (sc->bge_cdata.bge_rx_std_ring_map)
  		bus_dmamap_unload(sc->bge_cdata.bge_rx_std_ring_tag,
  		    sc->bge_cdata.bge_rx_std_ring_map);
 @@ -1633,8 +1754,7 @@
  	if (sc->bge_cdata.bge_rx_std_ring_tag)
  		bus_dma_tag_destroy(sc->bge_cdata.bge_rx_std_ring_tag);
  
 -	/* Destroy jumbo RX ring */
 -
 +	/* Destroy jumbo RX ring. */
  	if (sc->bge_cdata.bge_rx_jumbo_ring_map)
  		bus_dmamap_unload(sc->bge_cdata.bge_rx_jumbo_ring_tag,
  		    sc->bge_cdata.bge_rx_jumbo_ring_map);
 @@ -1648,8 +1768,7 @@
  	if (sc->bge_cdata.bge_rx_jumbo_ring_tag)
  		bus_dma_tag_destroy(sc->bge_cdata.bge_rx_jumbo_ring_tag);
  
 -	/* Destroy RX return ring */
 -
 +	/* Destroy RX return ring. */
  	if (sc->bge_cdata.bge_rx_return_ring_map)
  		bus_dmamap_unload(sc->bge_cdata.bge_rx_return_ring_tag,
  		    sc->bge_cdata.bge_rx_return_ring_map);
 @@ -1663,8 +1782,7 @@
  	if (sc->bge_cdata.bge_rx_return_ring_tag)
  		bus_dma_tag_destroy(sc->bge_cdata.bge_rx_return_ring_tag);
  
 -	/* Destroy TX ring */
 -
 +	/* Destroy TX ring. */
  	if (sc->bge_cdata.bge_tx_ring_map)
  		bus_dmamap_unload(sc->bge_cdata.bge_tx_ring_tag,
  		    sc->bge_cdata.bge_tx_ring_map);
 @@ -1677,8 +1795,7 @@
  	if (sc->bge_cdata.bge_tx_ring_tag)
  		bus_dma_tag_destroy(sc->bge_cdata.bge_tx_ring_tag);
  
 -	/* Destroy status block */
 -
 +	/* Destroy status block. */
  	if (sc->bge_cdata.bge_status_map)
  		bus_dmamap_unload(sc->bge_cdata.bge_status_tag,
  		    sc->bge_cdata.bge_status_map);
 @@ -1691,8 +1808,7 @@
  	if (sc->bge_cdata.bge_status_tag)
  		bus_dma_tag_destroy(sc->bge_cdata.bge_status_tag);
  
 -	/* Destroy statistics block */
 -
 +	/* Destroy statistics block. */
  	if (sc->bge_cdata.bge_stats_map)
  		bus_dmamap_unload(sc->bge_cdata.bge_stats_tag,
  		    sc->bge_cdata.bge_stats_map);
 @@ -1705,21 +1821,17 @@
  	if (sc->bge_cdata.bge_stats_tag)
  		bus_dma_tag_destroy(sc->bge_cdata.bge_stats_tag);
  
 -	/* Destroy the parent tag */
 -
 +	/* Destroy the parent tag. */
  	if (sc->bge_cdata.bge_parent_tag)
  		bus_dma_tag_destroy(sc->bge_cdata.bge_parent_tag);
 -
 -	return;
  }
  
  static int
 -bge_dma_alloc(dev)
 -	device_t dev;
 +bge_dma_alloc(device_t dev)
  {
 +	struct bge_dmamap_arg ctx;
  	struct bge_softc *sc;
  	int i, error;
 -	struct bge_dmamap_arg ctx;
  
  	sc = device_get_softc(dev);
  
 @@ -1756,32 +1868,29 @@
  		return (ENOMEM);
  	}
  
 -	/* Create DMA maps for RX buffers */
 -
 +	/* Create DMA maps for RX buffers. */
  	for (i = 0; i < BGE_STD_RX_RING_CNT; i++) {
  		error = bus_dmamap_create(sc->bge_cdata.bge_mtag, 0,
  			    &sc->bge_cdata.bge_rx_std_dmamap[i]);
  		if (error) {
  			device_printf(sc->bge_dev,
  			    "can't create DMA map for RX\n");
 -			return(ENOMEM);
 +			return (ENOMEM);
  		}
  	}
  
 -	/* Create DMA maps for TX buffers */
 -
 +	/* Create DMA maps for TX buffers. */
  	for (i = 0; i < BGE_TX_RING_CNT; i++) {
  		error = bus_dmamap_create(sc->bge_cdata.bge_mtag, 0,
  			    &sc->bge_cdata.bge_tx_dmamap[i]);
  		if (error) {
  			device_printf(sc->bge_dev,
  			    "can't create DMA map for RX\n");
 -			return(ENOMEM);
 +			return (ENOMEM);
  		}
  	}
  
 -	/* Create tag for standard RX ring */
 -
 +	/* Create tag for standard RX ring. */
  	error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
  	    PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
  	    NULL, BGE_STD_RX_RING_SZ, 1, BGE_STD_RX_RING_SZ, 0,
 @@ -1792,8 +1901,7 @@
  		return (ENOMEM);
  	}
  
 -	/* Allocate DMA'able memory for standard RX ring */
 -
 +	/* Allocate DMA'able memory for standard RX ring. */
  	error = bus_dmamem_alloc(sc->bge_cdata.bge_rx_std_ring_tag,
  	    (void **)&sc->bge_ldata.bge_rx_std_ring, BUS_DMA_NOWAIT,
  	    &sc->bge_cdata.bge_rx_std_ring_map);
 @@ -1802,8 +1910,7 @@
  
  	bzero((char *)sc->bge_ldata.bge_rx_std_ring, BGE_STD_RX_RING_SZ);
  
 -	/* Load the address of the standard RX ring */
 -
 +	/* Load the address of the standard RX ring. */
  	ctx.bge_maxsegs = 1;
  	ctx.sc = sc;
  
 @@ -1816,38 +1923,19 @@
  
  	sc->bge_ldata.bge_rx_std_ring_paddr = ctx.bge_busaddr;
  
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 -
 -		/*
 -		 * Create tag for jumbo mbufs.
 -		 * This is really a bit of a kludge. We allocate a special
 -		 * jumbo buffer pool which (thanks to the way our DMA
 -		 * memory allocation works) will consist of contiguous
 -		 * pages. This means that even though a jumbo buffer might
 -		 * be larger than a page size, we don't really need to
 -		 * map it into more than one DMA segment. However, the
 -		 * default mbuf tag will result in multi-segment mappings,
 -		 * so we have to create a special jumbo mbuf tag that
 -		 * lets us get away with mapping the jumbo buffers as
 -		 * a single segment. I think eventually the driver should
 -		 * be changed so that it uses ordinary mbufs and cluster
 -		 * buffers, i.e. jumbo frames can span multiple DMA
 -		 * descriptors. But that's a project for another day.
 -		 */
 -
 +	/* Create tags for jumbo mbufs. */
 +	if (BGE_IS_JUMBO_CAPABLE(sc)) {
  		error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
  		    1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
  		    NULL, MJUM9BYTES, BGE_NSEG_JUMBO, PAGE_SIZE,
  		    0, NULL, NULL, &sc->bge_cdata.bge_mtag_jumbo);
 -
  		if (error) {
  			device_printf(sc->bge_dev,
 -			    "could not allocate dma tag\n");
 +			    "could not allocate jumbo dma tag\n");
  			return (ENOMEM);
  		}
  
 -		/* Create tag for jumbo RX ring */
 +		/* Create tag for jumbo RX ring. */
  		error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
  		    PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
  		    NULL, BGE_JUMBO_RX_RING_SZ, 1, BGE_JUMBO_RX_RING_SZ, 0,
 @@ -1855,11 +1943,11 @@
  
  		if (error) {
  			device_printf(sc->bge_dev,
 -			    "could not allocate dma tag\n");
 +			    "could not allocate jumbo ring dma tag\n");
  			return (ENOMEM);
  		}
  
 -		/* Allocate DMA'able memory for jumbo RX ring */
 +		/* Allocate DMA'able memory for jumbo RX ring. */
  		error = bus_dmamem_alloc(sc->bge_cdata.bge_rx_jumbo_ring_tag,
  		    (void **)&sc->bge_ldata.bge_rx_jumbo_ring,
  		    BUS_DMA_NOWAIT | BUS_DMA_ZERO,
 @@ -1867,7 +1955,7 @@
  		if (error)
  			return (ENOMEM);
  
 -		/* Load the address of the jumbo RX ring */
 +		/* Load the address of the jumbo RX ring. */
  		ctx.bge_maxsegs = 1;
  		ctx.sc = sc;
  
 @@ -1881,22 +1969,20 @@
  
  		sc->bge_ldata.bge_rx_jumbo_ring_paddr = ctx.bge_busaddr;
  
 -		/* Create DMA maps for jumbo RX buffers */
 -
 +		/* Create DMA maps for jumbo RX buffers. */
  		for (i = 0; i < BGE_JUMBO_RX_RING_CNT; i++) {
  			error = bus_dmamap_create(sc->bge_cdata.bge_mtag_jumbo,
  				    0, &sc->bge_cdata.bge_rx_jumbo_dmamap[i]);
  			if (error) {
  				device_printf(sc->bge_dev,
 -				    "can't create DMA map for RX\n");
 -				return(ENOMEM);
 +				    "can't create DMA map for jumbo RX\n");
 +				return (ENOMEM);
  			}
  		}
  
  	}
  
 -	/* Create tag for RX return ring */
 -
 +	/* Create tag for RX return ring. */
  	error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
  	    PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
  	    NULL, BGE_RX_RTN_RING_SZ(sc), 1, BGE_RX_RTN_RING_SZ(sc), 0,
 @@ -1907,8 +1993,7 @@
  		return (ENOMEM);
  	}
  
 -	/* Allocate DMA'able memory for RX return ring */
 -
 +	/* Allocate DMA'able memory for RX return ring. */
  	error = bus_dmamem_alloc(sc->bge_cdata.bge_rx_return_ring_tag,
  	    (void **)&sc->bge_ldata.bge_rx_return_ring, BUS_DMA_NOWAIT,
  	    &sc->bge_cdata.bge_rx_return_ring_map);
 @@ -1918,8 +2003,7 @@
  	bzero((char *)sc->bge_ldata.bge_rx_return_ring,
  	    BGE_RX_RTN_RING_SZ(sc));
  
 -	/* Load the address of the RX return ring */
 -
 +	/* Load the address of the RX return ring. */
  	ctx.bge_maxsegs = 1;
  	ctx.sc = sc;
  
 @@ -1933,8 +2017,7 @@
  
  	sc->bge_ldata.bge_rx_return_ring_paddr = ctx.bge_busaddr;
  
 -	/* Create tag for TX ring */
 -
 +	/* Create tag for TX ring. */
  	error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
  	    PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
  	    NULL, BGE_TX_RING_SZ, 1, BGE_TX_RING_SZ, 0, NULL, NULL,
 @@ -1945,8 +2028,7 @@
  		return (ENOMEM);
  	}
  
 -	/* Allocate DMA'able memory for TX ring */
 -
 +	/* Allocate DMA'able memory for TX ring. */
  	error = bus_dmamem_alloc(sc->bge_cdata.bge_tx_ring_tag,
  	    (void **)&sc->bge_ldata.bge_tx_ring, BUS_DMA_NOWAIT,
  	    &sc->bge_cdata.bge_tx_ring_map);
 @@ -1955,8 +2037,7 @@
  
  	bzero((char *)sc->bge_ldata.bge_tx_ring, BGE_TX_RING_SZ);
  
 -	/* Load the address of the TX ring */
 -
 +	/* Load the address of the TX ring. */
  	ctx.bge_maxsegs = 1;
  	ctx.sc = sc;
  
 @@ -1969,8 +2050,7 @@
  
  	sc->bge_ldata.bge_tx_ring_paddr = ctx.bge_busaddr;
  
 -	/* Create tag for status block */
 -
 +	/* Create tag for status block. */
  	error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
  	    PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
  	    NULL, BGE_STATUS_BLK_SZ, 1, BGE_STATUS_BLK_SZ, 0,
 @@ -1981,8 +2061,7 @@
  		return (ENOMEM);
  	}
  
 -	/* Allocate DMA'able memory for status block */
 -
 +	/* Allocate DMA'able memory for status block. */
  	error = bus_dmamem_alloc(sc->bge_cdata.bge_status_tag,
  	    (void **)&sc->bge_ldata.bge_status_block, BUS_DMA_NOWAIT,
  	    &sc->bge_cdata.bge_status_map);
 @@ -1991,8 +2070,7 @@
  
  	bzero((char *)sc->bge_ldata.bge_status_block, BGE_STATUS_BLK_SZ);
  
 -	/* Load the address of the status block */
 -
 +	/* Load the address of the status block. */
  	ctx.sc = sc;
  	ctx.bge_maxsegs = 1;
  
 @@ -2005,8 +2083,7 @@
  
  	sc->bge_ldata.bge_status_block_paddr = ctx.bge_busaddr;
  
 -	/* Create tag for statistics block */
 -
 +	/* Create tag for statistics block. */
  	error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
  	    PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
  	    NULL, BGE_STATS_SZ, 1, BGE_STATS_SZ, 0, NULL, NULL,
 @@ -2017,8 +2094,7 @@
  		return (ENOMEM);
  	}
  
 -	/* Allocate DMA'able memory for statistics block */
 -
 +	/* Allocate DMA'able memory for statistics block. */
  	error = bus_dmamem_alloc(sc->bge_cdata.bge_stats_tag,
  	    (void **)&sc->bge_ldata.bge_stats, BUS_DMA_NOWAIT,
  	    &sc->bge_cdata.bge_stats_map);
 @@ -2027,8 +2103,7 @@
  
  	bzero((char *)sc->bge_ldata.bge_stats, BGE_STATS_SZ);
  
 -	/* Load the address of the statstics block */
 -
 +	/* Load the address of the statstics block. */
  	ctx.sc = sc;
  	ctx.bge_maxsegs = 1;
  
 @@ -2041,17 +2116,16 @@
  
  	sc->bge_ldata.bge_stats_paddr = ctx.bge_busaddr;
  
 -	return(0);
 +	return (0);
  }
  
  static int
 -bge_attach(dev)
 -	device_t dev;
 +bge_attach(device_t dev)
  {
  	struct ifnet *ifp;
  	struct bge_softc *sc;
 -	u_int32_t hwcfg = 0;
 -	u_int32_t mac_tmp = 0;
 +	uint32_t hwcfg = 0;
 +	uint32_t mac_tmp = 0;
  	u_char eaddr[6];
  	int error = 0, rid;
  
 @@ -2076,7 +2150,7 @@
  	sc->bge_btag = rman_get_bustag(sc->bge_res);
  	sc->bge_bhandle = rman_get_bushandle(sc->bge_res);
  
 -	/* Allocate interrupt */
 +	/* Allocate interrupt. */
  	rid = 0;
  
  	sc->bge_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
 @@ -2099,19 +2173,11 @@
  	sc->bge_chiprev = BGE_CHIPREV(sc->bge_chipid);
  
  	/*
 -	 * Treat the 5714 and the 5752 like the 5750 until we have more info
 -	 * on this chip.
 -	 */
 -	if (sc->bge_asicrev == BGE_ASICREV_BCM5714 || 
 -            sc->bge_asicrev == BGE_ASICREV_BCM5752)
 -		sc->bge_asicrev = BGE_ASICREV_BCM5750;
 -
 -	/*
  	 * XXX: Broadcom Linux driver.  Not in specs or eratta.
  	 * PCI-Express?
  	 */
 -	if (sc->bge_asicrev == BGE_ASICREV_BCM5750) {
 -		u_int32_t v;
 +	if (BGE_IS_5705_OR_BEYOND(sc)) {
 +		uint32_t v;
  
  		v = pci_read_config(dev, BGE_PCI_MSI_CAPID, 4);
  		if (((v >> 8) & 0xff) == BGE_PCIE_CAPID_REG) {
 @@ -2121,6 +2187,13 @@
  		}
  	}
  
 +	/*
 +	 * PCI-X ?
 +	 */
 +	if ((pci_read_config(sc->bge_dev, BGE_PCI_PCISTATE, 4) &
 +	    BGE_PCISTATE_PCI_BUSMODE) == 0)
 +		sc->bge_pcix = 1;
 +
  	/* Try to reset the chip. */
  	bge_reset(sc);
  
 @@ -2152,8 +2225,7 @@
  	}
  
  	/* 5705 limits RX return ring to 512 entries. */
 -	if (sc->bge_asicrev == BGE_ASICREV_BCM5705 ||
 -	    sc->bge_asicrev == BGE_ASICREV_BCM5750)
 +	if (BGE_IS_5705_OR_BEYOND(sc))
  		sc->bge_return_ring_cnt = BGE_RETURN_RING_CNT_5705;
  	else
  		sc->bge_return_ring_cnt = BGE_RETURN_RING_CNT;
 @@ -2200,7 +2272,7 @@
  	ifp->if_capabilities |= IFCAP_POLLING;
  #endif
  
 -        /*
 +	/*
  	 * 5700 B0 chips do not support checksumming correctly due
  	 * to hardware bugs.
  	 */
 @@ -2269,18 +2341,8 @@
  	 * which do not support unaligned accesses, we will realign the
  	 * payloads by copying the received packets.
  	 */
 -	switch (sc->bge_chipid) {
 -	case BGE_CHIPID_BCM5701_A0:
 -	case BGE_CHIPID_BCM5701_B0:
 -	case BGE_CHIPID_BCM5701_B2:
 -	case BGE_CHIPID_BCM5701_B5:
 -		/* If in PCI-X mode, work around the alignment bug. */
 -		if ((pci_read_config(dev, BGE_PCI_PCISTATE, 4) &
 -		    (BGE_PCISTATE_PCI_BUSMODE | BGE_PCISTATE_PCI_BUSSPEED)) ==
 -		    BGE_PCISTATE_PCI_BUSSPEED)
 -			sc->bge_rx_alignment_bug = 1;
 -		break;
 -	}
 +	if (sc->bge_asicrev == BGE_ASICREV_BCM5701 && sc->bge_pcix)
 +                sc->bge_rx_alignment_bug = 1;
  
  	/*
  	 * Call MI attach routine.
 @@ -2300,12 +2362,11 @@
  	}
  
  fail:
 -	return(error);
 +	return (error);
  }
  
  static int
 -bge_detach(dev)
 -	device_t dev;
 +bge_detach(device_t dev)
  {
  	struct bge_softc *sc;
  	struct ifnet *ifp;
 @@ -2334,12 +2395,11 @@
  
  	bge_release_resources(sc);
  
 -	return(0);
 +	return (0);
  }
  
  static void
 -bge_release_resources(sc)
 -	struct bge_softc *sc;
 +bge_release_resources(struct bge_softc *sc)
  {
  	device_t dev;
  
 @@ -2368,16 +2428,13 @@
  
  	if (mtx_initialized(&sc->bge_mtx))	/* XXX */
  		BGE_LOCK_DESTROY(sc);
 -
 -	return;
  }
  
  static void
 -bge_reset(sc)
 -	struct bge_softc *sc;
 +bge_reset(struct bge_softc *sc)
  {
  	device_t dev;
 -	u_int32_t cachesize, command, pcistate, reset;
 +	uint32_t cachesize, command, pcistate, reset;
  	int i, val = 0;
  
  	dev = sc->bge_dev;
 @@ -2422,7 +2479,7 @@
  		pci_write_config(dev, 0xd8, 0xf5000, 4);
  	}
  
 -	/* Reset some of the PCI state that got zapped by reset */
 +	/* Reset some of the PCI state that got zapped by reset. */
  	pci_write_config(dev, BGE_PCI_MISC_CTL,
  	    BGE_PCIMISCCTL_INDIRECT_ACCESS|BGE_PCIMISCCTL_MASK_PCI_INTR|
  	    BGE_HIF_SWAP_OPTIONS|BGE_PCIMISCCTL_PCISTATE_RW, 4);
 @@ -2431,8 +2488,12 @@
  	bge_writereg_ind(sc, BGE_MISC_CFG, (65 << 1));
  
  	/* Enable memory arbiter. */
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (BGE_IS_5714_FAMILY(sc)) {
 +		uint32_t val;
 +
 +		val = CSR_READ_4(sc, BGE_MARB_MODE);
 +		CSR_WRITE_4(sc, BGE_MARB_MODE, BGE_MARBMODE_ENABLE | val);
 +	} else
  		CSR_WRITE_4(sc, BGE_MARB_MODE, BGE_MARBMODE_ENABLE);
  
  	/*
 @@ -2472,7 +2533,7 @@
  		DELAY(10);
  	}
  
 -	/* Fix up byte swapping */
 +	/* Fix up byte swapping. */
  	CSR_WRITE_4(sc, BGE_MODE_CTL, BGE_DMA_SWAP_OPTIONS|
  	    BGE_MODECTL_BYTESWAP_DATA);
  
 @@ -2498,8 +2559,6 @@
  		CSR_WRITE_4(sc, 0x7c00, v | (1<<25));
  	}
  	DELAY(10000);
 -
 -	return;
  }
  
  /*
 @@ -2512,15 +2571,14 @@
   */
  
  static void
 -bge_rxeof(sc)
 -	struct bge_softc *sc;
 +bge_rxeof(struct bge_softc *sc)
  {
  	struct ifnet *ifp;
  	int stdcnt = 0, jumbocnt = 0;
  
  	BGE_LOCK_ASSERT(sc);
  
 -	/* Nothing to do */
 +	/* Nothing to do. */
  	if (sc->bge_rx_saved_considx ==
  	    sc->bge_ldata.bge_status_block->bge_idx[0].bge_rx_prod_idx)
  		return;
 @@ -2531,20 +2589,16 @@
  	    sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTREAD);
  	bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
  	    sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_POSTREAD);
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 +	if (BGE_IS_JUMBO_CAPABLE(sc))
  		bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
 -		    sc->bge_cdata.bge_rx_jumbo_ring_map,
 -		    BUS_DMASYNC_POSTREAD);
 -	}
 +		    sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_POSTREAD);
  
  	while(sc->bge_rx_saved_considx !=
  	    sc->bge_ldata.bge_status_block->bge_idx[0].bge_rx_prod_idx) {
  		struct bge_rx_bd	*cur_rx;
 -		u_int32_t		rxidx;
 -		struct ether_header	*eh;
 +		uint32_t		rxidx;
  		struct mbuf		*m = NULL;
 -		u_int16_t		vlan_tag = 0;
 +		uint16_t		vlan_tag = 0;
  		int			have_tag = 0;
  
  #ifdef DEVICE_POLLING
 @@ -2622,7 +2676,6 @@
  			m->m_data += ETHER_ALIGN;
  		}
  #endif
 -		eh = mtod(m, struct ether_header *);
  		m->m_pkthdr.len = m->m_len = cur_rx->bge_len - ETHER_CRC_LEN;
  		m->m_pkthdr.rcvif = ifp;
  
 @@ -2659,13 +2712,10 @@
  	if (stdcnt > 0)
  		bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
  		    sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_PREWRITE);
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 -		if (jumbocnt > 0)
 -			bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
 -			    sc->bge_cdata.bge_rx_jumbo_ring_map,
 -			    BUS_DMASYNC_PREWRITE);
 -	}
 +
 +	if (BGE_IS_JUMBO_CAPABLE(sc) && jumbocnt > 0)
 +		bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
 +		    sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_PREWRITE);
  
  	CSR_WRITE_4(sc, BGE_MBX_RX_CONS0_LO, sc->bge_rx_saved_considx);
  	if (stdcnt)
 @@ -2675,15 +2725,14 @@
  }
  
  static void
 -bge_txeof(sc)
 -	struct bge_softc *sc;
 +bge_txeof(struct bge_softc *sc)
  {
  	struct bge_tx_bd *cur_tx = NULL;
  	struct ifnet *ifp;
  
  	BGE_LOCK_ASSERT(sc);
  
 -	/* Nothing to do */
 +	/* Nothing to do. */
  	if (sc->bge_tx_saved_considx ==
  	    sc->bge_ldata.bge_status_block->bge_idx[0].bge_tx_cons_idx)
  		return;
 @@ -2699,7 +2748,7 @@
  	 */
  	while (sc->bge_tx_saved_considx !=
  	    sc->bge_ldata.bge_status_block->bge_idx[0].bge_tx_cons_idx) {
 -		u_int32_t		idx = 0;
 +		uint32_t		idx = 0;
  
  		idx = sc->bge_tx_saved_considx;
  		cur_tx = &sc->bge_ldata.bge_tx_ring[idx];
 @@ -2728,25 +2777,19 @@
  bge_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
  {
  	struct bge_softc *sc = ifp->if_softc;
 +	uint32_t statusword;
  	
  	BGE_LOCK(sc);
 -	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
 -		bge_poll_locked(ifp, cmd, count);
 -	BGE_UNLOCK(sc);
 -}
 -
 -static void
 -bge_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count)
 -{
 -	struct bge_softc *sc = ifp->if_softc;
 -	uint32_t statusword;
 -
 -	BGE_LOCK_ASSERT(sc);
 +	if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
 +		BGE_UNLOCK(sc);
 +		return;
 +	}
  
  	bus_dmamap_sync(sc->bge_cdata.bge_status_tag,
  	    sc->bge_cdata.bge_status_map, BUS_DMASYNC_POSTREAD);
  
 -	statusword = atomic_readandclear_32(&sc->bge_ldata.bge_status_block->bge_status);
 +	statusword = atomic_readandclear_32(
 +	    &sc->bge_ldata.bge_status_block->bge_status);
  
  	bus_dmamap_sync(sc->bge_cdata.bge_status_tag,
  	    sc->bge_cdata.bge_status_map, BUS_DMASYNC_PREREAD);
 @@ -2757,7 +2800,7 @@
  
  	if (cmd == POLL_AND_CHECK_STATUS)
  		if ((sc->bge_asicrev == BGE_ASICREV_BCM5700 &&
 -		    sc->bge_chipid != BGE_CHIPID_BCM5700_B1) ||
 +		    sc->bge_chipid != BGE_CHIPID_BCM5700_B2) ||
  		    sc->bge_link_evt || sc->bge_tbi)
  			bge_link_upd(sc);
  
 @@ -2766,12 +2809,13 @@
  	bge_txeof(sc);
  	if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
  		bge_start_locked(ifp);
 +
 +	BGE_UNLOCK(sc);
  }
  #endif /* DEVICE_POLLING */
  
  static void
 -bge_intr(xsc)
 -	void *xsc;
 +bge_intr(void *xsc)
  {
  	struct bge_softc *sc;
  	struct ifnet *ifp;
 @@ -2805,15 +2849,15 @@
  	    sc->bge_cdata.bge_status_map, BUS_DMASYNC_PREREAD);
  
  	if ((sc->bge_asicrev == BGE_ASICREV_BCM5700 &&
 -	    sc->bge_chipid != BGE_CHIPID_BCM5700_B1) ||
 +	    sc->bge_chipid != BGE_CHIPID_BCM5700_B2) ||
  	    statusword || sc->bge_link_evt)
  		bge_link_upd(sc);
  
  	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 -		/* Check RX return ring producer/consumer */
 +		/* Check RX return ring producer/consumer. */
  		bge_rxeof(sc);
  
 -		/* Check TX ring producer/consumer */
 +		/* Check TX ring producer/consumer. */
  		bge_txeof(sc);
  	}
  
 @@ -2825,20 +2869,16 @@
  		bge_start_locked(ifp);
  
  	BGE_UNLOCK(sc);
 -
 -	return;
  }
  
  static void
 -bge_tick_locked(sc)
 -	struct bge_softc *sc;
 +bge_tick_locked(struct bge_softc *sc)
  {
  	struct mii_data *mii = NULL;
  
  	BGE_LOCK_ASSERT(sc);
  
 -	if (sc->bge_asicrev == BGE_ASICREV_BCM5705 ||
 -	    sc->bge_asicrev == BGE_ASICREV_BCM5750)
 +	if (BGE_IS_5705_OR_BEYOND(sc))
  		bge_stats_update_regs(sc);
  	else
  		bge_stats_update(sc);
 @@ -2853,7 +2893,7 @@
  		 * and trigger interrupt.
  		 */
  #ifdef DEVICE_POLLING
 -		/* In polling mode we poll link state in bge_poll_locked() */
 +		/* In polling mode we poll link state in bge_poll(). */
  		if (!(sc->bge_ifp->if_capenable & IFCAP_POLLING))
  #endif
  		{
 @@ -2866,8 +2906,7 @@
  }
  
  static void
 -bge_tick(xsc)
 -	void *xsc;
 +bge_tick(void *xsc)
  {
  	struct bge_softc *sc;
  
 @@ -2879,18 +2918,17 @@
  }
  
  static void
 -bge_stats_update_regs(sc)
 -	struct bge_softc *sc;
 +bge_stats_update_regs(struct bge_softc *sc)
  {
 -	struct ifnet *ifp;
  	struct bge_mac_stats_regs stats;
 -	u_int32_t *s;
 -	u_long cnt;			/* current register value */
 +	struct ifnet *ifp;
 +	uint32_t *s;
 +	u_long cnt;	/* current register value */
  	int i;
  
  	ifp = sc->bge_ifp;
  
 -	s = (u_int32_t *)&stats;
 +	s = (uint32_t *)&stats;
  	for (i = 0; i < sizeof(struct bge_mac_stats_regs); i += 4) {
  		*s = CSR_READ_4(sc, BGE_RX_STATS + i);
  		s++;
 @@ -2906,12 +2944,11 @@
  }
  
  static void
 -bge_stats_update(sc)
 -	struct bge_softc *sc;
 +bge_stats_update(struct bge_softc *sc)
  {
  	struct ifnet *ifp;
  	bus_size_t stats;
 -	u_long cnt;			/* current register value */
 +	u_long cnt;	/* current register value */
  
  	ifp = sc->bge_ifp;
  
 @@ -2995,10 +3032,7 @@
   * pointers to descriptors.
   */
  static int
 -bge_encap(sc, m_head, txidx)
 -	struct bge_softc *sc;
 -	struct mbuf *m_head;
 -	uint32_t *txidx;
 +bge_encap(struct bge_softc *sc, struct mbuf *m_head, uint32_t *txidx)
  {
  	bus_dma_segment_t	segs[BGE_NSEG_NEW];
  	bus_dmamap_t		map;
 @@ -3028,7 +3062,7 @@
  	map = sc->bge_cdata.bge_tx_dmamap[idx];
  	error = bus_dmamap_load_mbuf_sg(sc->bge_cdata.bge_mtag, map,
  	    m_head, segs, &nsegs, BUS_DMA_NOWAIT);
 -        if (error) {
 +	if (error) {
  		if (error == EFBIG) {
  			struct mbuf *m0;
  
 @@ -3040,7 +3074,7 @@
  			    map, m_head, segs, &nsegs, BUS_DMA_NOWAIT);
  		}
  		if (error)
 -			return (error); 
 +			return (error);
  	}
  
  	/*
 @@ -3096,8 +3130,7 @@
   * to the mbuf data regions directly in the transmit descriptors.
   */
  static void
 -bge_start_locked(ifp)
 -	struct ifnet *ifp;
 +bge_start_locked(struct ifnet *ifp)
  {
  	struct bge_softc *sc;
  	struct mbuf *m_head = NULL;
 @@ -3158,12 +3191,11 @@
  		BPF_MTAP(ifp, m_head);
  	}
  
 -	if (count == 0) {
 -		/* no packets were dequeued */
 +	if (count == 0)
 +		/* No packets were dequeued. */
  		return;
 -	}
  
 -	/* Transmit */
 +	/* Transmit. */
  	CSR_WRITE_4(sc, BGE_MBX_TX_HOST_PROD0_LO, prodidx);
  	/* 5700 b2 errata */
  	if (sc->bge_chiprev == BGE_CHIPREV_5700_BX)
 @@ -3175,8 +3207,6 @@
  	 * Set a timeout in case the chip goes out to lunch.
  	 */
  	ifp->if_timer = 5;
 -
 -	return;
  }
  
  /*
 @@ -3184,8 +3214,7 @@
   * to the mbuf data regions directly in the transmit descriptors.
   */
  static void
 -bge_start(ifp)
 -	struct ifnet *ifp;
 +bge_start(struct ifnet *ifp)
  {
  	struct bge_softc *sc;
  
 @@ -3196,11 +3225,10 @@
  }
  
  static void
 -bge_init_locked(sc)
 -	struct bge_softc *sc;
 +bge_init_locked(struct bge_softc *sc)
  {
  	struct ifnet *ifp;
 -	u_int16_t *m;
 +	uint16_t *m;
  
  	BGE_LOCK_ASSERT(sc);
  
 @@ -3230,7 +3258,7 @@
  	    ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN);
  
  	/* Load our MAC address. */
 -	m = (u_int16_t *)&IFP2ENADDR(sc->bge_ifp)[0];
 +	m = (uint16_t *)IF_LLADDR(sc->bge_ifp);
  	CSR_WRITE_4(sc, BGE_MAC_ADDR1_LO, htons(m[0]));
  	CSR_WRITE_4(sc, BGE_MAC_ADDR1_HI, (htons(m[1]) << 16) | htons(m[2]));
  
 @@ -3253,7 +3281,7 @@
  	 * entry of the ring.
  	 */
  	if (sc->bge_chipid == BGE_CHIPID_BCM5705_A0) {
 -		u_int32_t		v, i;
 +		uint32_t		v, i;
  		for (i = 0; i < 10; i++) {
  			DELAY(20);
  			v = bge_readmem_ind(sc, BGE_STD_RX_RINGS + 8);
 @@ -3269,16 +3297,16 @@
  	if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
  		bge_init_rx_ring_jumbo(sc);
  
 -	/* Init our RX return ring index */
 +	/* Init our RX return ring index. */
  	sc->bge_rx_saved_considx = 0;
  
  	/* Init TX ring. */
  	bge_init_tx_ring(sc);
  
 -	/* Turn on transmitter */
 +	/* Turn on transmitter. */
  	BGE_SETBIT(sc, BGE_TX_MODE, BGE_TXMODE_ENABLE);
  
 -	/* Turn on receiver */
 +	/* Turn on receiver. */
  	BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE);
  
  	/* Tell firmware we're alive. */
 @@ -3311,24 +3339,20 @@
  }
  
  static void
 -bge_init(xsc)
 -	void *xsc;
 +bge_init(void *xsc)
  {
  	struct bge_softc *sc = xsc;
  
  	BGE_LOCK(sc);
  	bge_init_locked(sc);
  	BGE_UNLOCK(sc);
 -
 -	return;
  }
  
  /*
   * Set media options.
   */
  static int
 -bge_ifmedia_upd(ifp)
 -	struct ifnet *ifp;
 +bge_ifmedia_upd(struct ifnet *ifp)
  {
  	struct bge_softc *sc;
  	struct mii_data *mii;
 @@ -3340,16 +3364,16 @@
  	/* If this is a 1000baseX NIC, enable the TBI port. */
  	if (sc->bge_tbi) {
  		if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
 -			return(EINVAL);
 +			return (EINVAL);
  		switch(IFM_SUBTYPE(ifm->ifm_media)) {
  		case IFM_AUTO:
 -#ifndef BGE_FAKE_AUTONEG
  			/*
  			 * The BCM5704 ASIC appears to have a special
  			 * mechanism for programming the autoneg
  			 * advertisement registers in TBI mode.
  			 */
 -			if (sc->bge_asicrev == BGE_ASICREV_BCM5704) {
 +			if (bge_fake_autoneg == 0 &&
 +			    sc->bge_asicrev == BGE_ASICREV_BCM5704) {
  				uint32_t sgdig;
  				CSR_WRITE_4(sc, BGE_TX_TBI_AUTONEG, 0);
  				sgdig = CSR_READ_4(sc, BGE_SGDIG_CFG);
 @@ -3361,7 +3385,6 @@
  				DELAY(5);
  				CSR_WRITE_4(sc, BGE_SGDIG_CFG, sgdig);
  			}
 -#endif
  			break;
  		case IFM_1000_SX:
  			if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) {
 @@ -3373,9 +3396,9 @@
  			}
  			break;
  		default:
 -			return(EINVAL);
 +			return (EINVAL);
  		}
 -		return(0);
 +		return (0);
  	}
  
  	sc->bge_link_evt++;
 @@ -3388,16 +3411,14 @@
  	}
  	mii_mediachg(mii);
  
 -	return(0);
 +	return (0);
  }
  
  /*
   * Report current media status.
   */
  static void
 -bge_ifmedia_sts(ifp, ifmr)
 -	struct ifnet *ifp;
 -	struct ifmediareq *ifmr;
 +bge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
  {
  	struct bge_softc *sc;
  	struct mii_data *mii;
 @@ -3410,6 +3431,10 @@
  		if (CSR_READ_4(sc, BGE_MAC_STS) &
  		    BGE_MACSTAT_TBI_PCS_SYNCHED)
  			ifmr->ifm_status |= IFM_ACTIVE;
 +		else {
 +			ifmr->ifm_active |= IFM_NONE;
 +			return;
 +		}
  		ifmr->ifm_active |= IFM_1000_SX;
  		if (CSR_READ_4(sc, BGE_MAC_MODE) & BGE_MACMODE_HALF_DUPLEX)
  			ifmr->ifm_active |= IFM_HDX;
 @@ -3422,29 +3447,25 @@
  	mii_pollstat(mii);
  	ifmr->ifm_active = mii->mii_media_active;
  	ifmr->ifm_status = mii->mii_media_status;
 -
 -	return;
  }
  
  static int
 -bge_ioctl(ifp, command, data)
 -	struct ifnet *ifp;
 -	u_long command;
 -	caddr_t data;
 +bge_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
  {
  	struct bge_softc *sc = ifp->if_softc;
  	struct ifreq *ifr = (struct ifreq *) data;
 -	int mask, error = 0;
  	struct mii_data *mii;
 +	int mask, error = 0;
  
 -	switch(command) {
 +	switch (command) {
  	case SIOCSIFMTU:
 -		/* Disallow jumbo frames on 5705. */
 -		if (((sc->bge_asicrev == BGE_ASICREV_BCM5705 ||
 -		      sc->bge_asicrev == BGE_ASICREV_BCM5750) &&
 -		    ifr->ifr_mtu > ETHERMTU) || ifr->ifr_mtu > BGE_JUMBO_MTU)
 +		if (ifr->ifr_mtu < ETHERMIN ||
 +		    ((BGE_IS_JUMBO_CAPABLE(sc)) &&
 +		    ifr->ifr_mtu > BGE_JUMBO_MTU) ||
 +		    ((!BGE_IS_JUMBO_CAPABLE(sc)) &&
 +		    ifr->ifr_mtu > ETHERMTU))
  			error = EINVAL;
 -		else {
 +		else if (ifp->if_mtu != ifr->ifr_mtu) {
  			ifp->if_mtu = ifr->ifr_mtu;
  			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
  			bge_init(sc);
 @@ -3512,14 +3533,14 @@
  			if (ifr->ifr_reqcap & IFCAP_POLLING) {
  				error = ether_poll_register(bge_poll, ifp);
  				if (error)
 -					return(error);
 +					return (error);
  				BGE_LOCK(sc);
  				BGE_SETBIT(sc, BGE_PCI_MISC_CTL,
  				    BGE_PCIMISCCTL_MASK_PCI_INTR);
  				CSR_WRITE_4(sc, BGE_MBX_IRQ0_LO, 1);
  				CSR_WRITE_4(sc, BGE_HCC_RX_MAX_COAL_BDS_INT, 1);
  				CSR_WRITE_4(sc, BGE_HCC_TX_MAX_COAL_BDS_INT, 1);
 -				ifp->if_capenable |= IFCAP_POLLING;   
 +				ifp->if_capenable |= IFCAP_POLLING;
  				BGE_UNLOCK(sc);
  			} else {
  				error = ether_poll_deregister(ifp);
 @@ -3549,12 +3570,11 @@
  		break;
  	}
  
 -	return(error);
 +	return (error);
  }
  
  static void
 -bge_watchdog(ifp)
 -	struct ifnet *ifp;
 +bge_watchdog(struct ifnet *ifp)
  {
  	struct bge_softc *sc;
  
 @@ -3566,8 +3586,6 @@
  	bge_init(sc);
  
  	ifp->if_oerrors++;
 -
 -	return;
  }
  
  /*
 @@ -3575,8 +3593,7 @@
   * RX and TX lists.
   */
  static void
 -bge_stop(sc)
 -	struct bge_softc *sc;
 +bge_stop(struct bge_softc *sc)
  {
  	struct ifnet *ifp;
  	struct ifmedia_entry *ifm;
 @@ -3593,28 +3610,26 @@
  	callout_stop(&sc->bge_stat_ch);
  
  	/*
 -	 * Disable all of the receiver blocks
 +	 * Disable all of the receiver blocks.
  	 */
  	BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_RBDI_MODE, BGE_RBDIMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_RXLP_MODE, BGE_RXLPMODE_ENABLE);
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (!(BGE_IS_5705_OR_BEYOND(sc)))
  		BGE_CLRBIT(sc, BGE_RXLS_MODE, BGE_RXLSMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_RDBDI_MODE, BGE_RBDIMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_RDC_MODE, BGE_RDCMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_RBDC_MODE, BGE_RBDCMODE_ENABLE);
  
  	/*
 -	 * Disable all of the transmit blocks
 +	 * Disable all of the transmit blocks.
  	 */
  	BGE_CLRBIT(sc, BGE_SRS_MODE, BGE_SRSMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_SBDI_MODE, BGE_SBDIMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_SDI_MODE, BGE_SDIMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_RDMA_MODE, BGE_RDMAMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_SDC_MODE, BGE_SDCMODE_ENABLE);
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (!(BGE_IS_5705_OR_BEYOND(sc)))
  		BGE_CLRBIT(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_SBDC_MODE, BGE_SBDCMODE_ENABLE);
  
 @@ -3624,13 +3639,11 @@
  	 */
  	BGE_CLRBIT(sc, BGE_HCC_MODE, BGE_HCCMODE_ENABLE);
  	BGE_CLRBIT(sc, BGE_WDMA_MODE, BGE_WDMAMODE_ENABLE);
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (!(BGE_IS_5705_OR_BEYOND(sc)))
  		BGE_CLRBIT(sc, BGE_MBCF_MODE, BGE_MBCFMODE_ENABLE);
  	CSR_WRITE_4(sc, BGE_FTQ_RESET, 0xFFFFFFFF);
  	CSR_WRITE_4(sc, BGE_FTQ_RESET, 0);
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750) {
 +	if (!(BGE_IS_5705_OR_BEYOND(sc))) {
  		BGE_CLRBIT(sc, BGE_BMAN_MODE, BGE_BMANMODE_ENABLE);
  		BGE_CLRBIT(sc, BGE_MARB_MODE, BGE_MARBMODE_ENABLE);
  	}
 @@ -3648,8 +3661,7 @@
  	bge_free_rx_ring_std(sc);
  
  	/* Free jumbo RX list. */
 -	if (sc->bge_asicrev != BGE_ASICREV_BCM5705 &&
 -	    sc->bge_asicrev != BGE_ASICREV_BCM5750)
 +	if (BGE_IS_JUMBO_CAPABLE(sc))
  		bge_free_rx_ring_jumbo(sc);
  
  	/* Free TX buffers. */
 @@ -3696,8 +3708,7 @@
   * get confused by errant DMAs when rebooting.
   */
  static void
 -bge_shutdown(dev)
 -	device_t dev;
 +bge_shutdown(device_t dev)
  {
  	struct bge_softc *sc;
  
 @@ -3707,8 +3718,6 @@
  	bge_stop(sc);
  	bge_reset(sc);
  	BGE_UNLOCK(sc);
 -
 -	return;
  }
  
  static int
 @@ -3744,15 +3753,14 @@
  }
  
  static void
 -bge_link_upd(sc)
 -	struct bge_softc *sc;
 +bge_link_upd(struct bge_softc *sc)
  {
  	struct mii_data *mii;
  	uint32_t link, status;
  
  	BGE_LOCK_ASSERT(sc);
  
 -	/* Clear 'pending link event' flag */
 +	/* Clear 'pending link event' flag. */
  	sc->bge_link_evt = 0;
  
  	/*
 @@ -3767,11 +3775,11 @@
  	 * the interrupt handler.
  	 *
  	 * XXX: perhaps link state detection procedure used for
 -	 * BGE_CHIPID_BCM5700_B1 can be used for others BCM5700 revisions.
 +	 * BGE_CHIPID_BCM5700_B2 can be used for others BCM5700 revisions.
  	 */
  
  	if (sc->bge_asicrev == BGE_ASICREV_BCM5700 &&
 -	    sc->bge_chipid != BGE_CHIPID_BCM5700_B1) {
 +	    sc->bge_chipid != BGE_CHIPID_BCM5700_B2) {
  		status = CSR_READ_4(sc, BGE_MAC_STS);
  		if (status & BGE_MACSTAT_MI_INTERRUPT) {
  			callout_stop(&sc->bge_stat_ch);
 @@ -3792,7 +3800,7 @@
  					if_printf(sc->bge_ifp, "link DOWN\n");
  			}
  
 -			/* Clear the interrupt */
 +			/* Clear the interrupt. */
  			CSR_WRITE_4(sc, BGE_MAC_EVT_ENB,
  			    BGE_EVTENB_MI_INTERRUPT);
  			bge_miibus_readreg(sc->bge_dev, 1, BRGPHY_MII_ISR);
 @@ -3800,7 +3808,7 @@
  			    BRGPHY_INTRS);
  		}
  		return;
 -	} 
 +	}
  
  	if (sc->bge_tbi) {
  		status = CSR_READ_4(sc, BGE_MAC_STS);
 @@ -3813,7 +3821,8 @@
  				CSR_WRITE_4(sc, BGE_MAC_STS, 0xFFFFFFFF);
  				if (bootverbose)
  					if_printf(sc->bge_ifp, "link UP\n");
 -				if_link_state_change(sc->bge_ifp, LINK_STATE_UP);
 +				if_link_state_change(sc->bge_ifp,
 +				    LINK_STATE_UP);
  			}
  		} else if (sc->bge_link) {
  			sc->bge_link = 0;
 @@ -3823,7 +3832,7 @@
  		}
  	/* Discard link events for MII/GMII cards if MI auto-polling disabled */
  	} else if (CSR_READ_4(sc, BGE_MI_MODE) & BGE_MIMODE_AUTOPOLL) {
 -		/* 
 +		/*
  		 * Some broken BCM chips have BGE_STATFLAG_LINKSTATE_CHANGED bit
  		 * in status word always set. Workaround this bug by reading
  		 * PHY link status directly.
 @@ -3852,7 +3861,7 @@
  		}
  	}
  
 -	/* Clear the attention */
 +	/* Clear the attention. */
  	CSR_WRITE_4(sc, BGE_MAC_STS, BGE_MACSTAT_SYNC_CHANGED|
  	    BGE_MACSTAT_CFG_CHANGED|BGE_MACSTAT_MI_COMPLETE|
  	    BGE_MACSTAT_LINK_CHANGED);
 Index: if_bgereg.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/bge/if_bgereg.h,v
 retrieving revision 1.36.2.5
 diff -u -r1.36.2.5 if_bgereg.h
 --- if_bgereg.h	10 May 2006 07:27:42 -0000	1.36.2.5
 +++ if_bgereg.h	12 Jun 2006 19:57:54 -0000
 @@ -224,9 +224,12 @@
  
  #define BGE_CHIPID_TIGON_I		0x40000000
  #define BGE_CHIPID_TIGON_II		0x60000000
 +#define BGE_CHIPID_BCM5700_A0		0x70000000
 +#define BGE_CHIPID_BCM5700_A1		0x70010000
  #define BGE_CHIPID_BCM5700_B0		0x71000000
 -#define BGE_CHIPID_BCM5700_B1		0x71020000
 -#define BGE_CHIPID_BCM5700_B2		0x71030000
 +#define BGE_CHIPID_BCM5700_B1		0x71010000
 +#define BGE_CHIPID_BCM5700_B2		0x71020000
 +#define BGE_CHIPID_BCM5700_B3		0x71030000
  #define BGE_CHIPID_BCM5700_ALTIMA	0x71040000
  #define BGE_CHIPID_BCM5700_C0		0x72000000
  #define BGE_CHIPID_BCM5701_A0		0x00000000	/* grrrr */
 @@ -236,27 +239,44 @@
  #define BGE_CHIPID_BCM5703_A0		0x10000000
  #define BGE_CHIPID_BCM5703_A1		0x10010000
  #define BGE_CHIPID_BCM5703_A2		0x10020000
 +#define BGE_CHIPID_BCM5703_A3		0x10030000
  #define BGE_CHIPID_BCM5704_A0		0x20000000
  #define BGE_CHIPID_BCM5704_A1		0x20010000
  #define BGE_CHIPID_BCM5704_A2		0x20020000
 +#define BGE_CHIPID_BCM5704_A3		0x20030000
 +#define BGE_CHIPID_BCM5704_B0		0x21000000
  #define BGE_CHIPID_BCM5705_A0		0x30000000
  #define BGE_CHIPID_BCM5705_A1		0x30010000
  #define BGE_CHIPID_BCM5705_A2		0x30020000
  #define BGE_CHIPID_BCM5705_A3		0x30030000
  #define BGE_CHIPID_BCM5750_A0		0x40000000
  #define BGE_CHIPID_BCM5750_A1		0x40010000
 +#define BGE_CHIPID_BCM5750_A3		0x40030000
 +#define BGE_CHIPID_BCM5750_B0		0x40100000
 +#define BGE_CHIPID_BCM5750_B1		0x41010000
 +#define BGE_CHIPID_BCM5750_C0		0x42000000
 +#define BGE_CHIPID_BCM5750_C1		0x42010000
  #define BGE_CHIPID_BCM5714_A0		0x50000000
 +#define BGE_CHIPID_BCM5752_A0		0x60000000
 +#define BGE_CHIPID_BCM5752_A1		0x60010000
 +#define BGE_CHIPID_BCM5752_A2		0x60020000
 +#define BGE_CHIPID_BCM5714_B0		0x80000000
 +#define BGE_CHIPID_BCM5714_B3		0x80030000
 +#define BGE_CHIPID_BCM5715_A0		0x90000000
 +#define BGE_CHIPID_BCM5715_A1		0x90010000
  
  /* shorthand one */
  #define BGE_ASICREV(x)			((x) >> 28)
 -#define BGE_ASICREV_BCM5700		0x07
  #define BGE_ASICREV_BCM5701		0x00
  #define BGE_ASICREV_BCM5703		0x01
  #define BGE_ASICREV_BCM5704		0x02
  #define BGE_ASICREV_BCM5705		0x03
  #define BGE_ASICREV_BCM5750		0x04
 -#define BGE_ASICREV_BCM5714		0x05
 +#define BGE_ASICREV_BCM5714_A0		0x05
  #define BGE_ASICREV_BCM5752		0x06
 +#define BGE_ASICREV_BCM5700		0x07
 +#define BGE_ASICREV_BCM5780		0x08
 +#define BGE_ASICREV_BCM5714		0x09
  
  /* chip revisions */
  #define BGE_CHIPREV(x)			((x) >> 24)
 @@ -1752,26 +1772,26 @@
  #define BGE_MAGIC_NUMBER                0x4B657654
  
  typedef struct {
 -	u_int32_t		bge_addr_hi;
 -	u_int32_t		bge_addr_lo;
 +	uint32_t		bge_addr_hi;
 +	uint32_t		bge_addr_lo;
  } bge_hostaddr;
  
  #define BGE_HOSTADDR(x, y)						\
  	do {								\
 -		(x).bge_addr_lo = ((u_int64_t) (y) & 0xffffffff);	\
 -		(x).bge_addr_hi = ((u_int64_t) (y) >> 32);		\
 +		(x).bge_addr_lo = ((uint64_t) (y) & 0xffffffff);	\
 +		(x).bge_addr_hi = ((uint64_t) (y) >> 32);		\
  	} while(0)
  
  #define BGE_ADDR_LO(y)	\
 -	((u_int64_t) (y) & 0xFFFFFFFF)
 +	((uint64_t) (y) & 0xFFFFFFFF)
  #define BGE_ADDR_HI(y)	\
 -	((u_int64_t) (y) >> 32)
 +	((uint64_t) (y) >> 32)
  
  /* Ring control block structure */
  struct bge_rcb {
  	bge_hostaddr		bge_hostaddr;
 -	u_int32_t		bge_maxlen_flags;
 -	u_int32_t		bge_nicaddr;
 +	uint32_t		bge_maxlen_flags;
 +	uint32_t		bge_nicaddr;
  };
  
  #define	RCB_WRITE_4(sc, rcb, offset, val) \
 @@ -1785,15 +1805,15 @@
  struct bge_tx_bd {
  	bge_hostaddr		bge_addr;
  #if BYTE_ORDER == LITTLE_ENDIAN
 -	u_int16_t		bge_flags;
 -	u_int16_t		bge_len;
 -	u_int16_t		bge_vlan_tag;
 -	u_int16_t		bge_rsvd;
 +	uint16_t		bge_flags;
 +	uint16_t		bge_len;
 +	uint16_t		bge_vlan_tag;
 +	uint16_t		bge_rsvd;
  #else
 -	u_int16_t		bge_len;
 -	u_int16_t		bge_flags;
 -	u_int16_t		bge_rsvd;
 -	u_int16_t		bge_vlan_tag;
 +	uint16_t		bge_len;
 +	uint16_t		bge_flags;
 +	uint16_t		bge_rsvd;
 +	uint16_t		bge_vlan_tag;
  #endif
  };
  
 @@ -1817,26 +1837,26 @@
  struct bge_rx_bd {
  	bge_hostaddr		bge_addr;
  #if BYTE_ORDER == LITTLE_ENDIAN
 -	u_int16_t		bge_len;
 -	u_int16_t		bge_idx;
 -	u_int16_t		bge_flags;
 -	u_int16_t		bge_type;
 -	u_int16_t		bge_tcp_udp_csum;
 -	u_int16_t		bge_ip_csum;
 -	u_int16_t		bge_vlan_tag;
 -	u_int16_t		bge_error_flag;
 +	uint16_t		bge_len;
 +	uint16_t		bge_idx;
 +	uint16_t		bge_flags;
 +	uint16_t		bge_type;
 +	uint16_t		bge_tcp_udp_csum;
 +	uint16_t		bge_ip_csum;
 +	uint16_t		bge_vlan_tag;
 +	uint16_t		bge_error_flag;
  #else
 -	u_int16_t		bge_idx;
 -	u_int16_t		bge_len;
 -	u_int16_t		bge_type;
 -	u_int16_t		bge_flags;
 -	u_int16_t		bge_ip_csum;
 -	u_int16_t		bge_tcp_udp_csum;
 -	u_int16_t		bge_error_flag;
 -	u_int16_t		bge_vlan_tag;
 +	uint16_t		bge_idx;
 +	uint16_t		bge_len;
 +	uint16_t		bge_type;
 +	uint16_t		bge_flags;
 +	uint16_t		bge_ip_csum;
 +	uint16_t		bge_tcp_udp_csum;
 +	uint16_t		bge_error_flag;
 +	uint16_t		bge_vlan_tag;
  #endif
 -	u_int32_t		bge_rsvd;
 -	u_int32_t		bge_opaque;
 +	uint32_t		bge_rsvd;
 +	uint32_t		bge_opaque;
  };
  
  struct bge_extrx_bd {
 @@ -1844,38 +1864,38 @@
  	bge_hostaddr		bge_addr2;
  	bge_hostaddr		bge_addr3;
  #if BYTE_ORDER == LITTLE_ENDIAN
 -	u_int16_t		bge_len2;
 -	u_int16_t		bge_len1;
 -	u_int16_t		bge_rsvd1;
 -	u_int16_t		bge_len3;
 +	uint16_t		bge_len2;
 +	uint16_t		bge_len1;
 +	uint16_t		bge_rsvd1;
 +	uint16_t		bge_len3;
  #else
 -	u_int16_t		bge_len1;
 -	u_int16_t		bge_len2;
 -	u_int16_t		bge_len3;
 -	u_int16_t		bge_rsvd1;
 +	uint16_t		bge_len1;
 +	uint16_t		bge_len2;
 +	uint16_t		bge_len3;
 +	uint16_t		bge_rsvd1;
  #endif
  	bge_hostaddr		bge_addr0;
  #if BYTE_ORDER == LITTLE_ENDIAN
 -	u_int16_t		bge_len0;
 -	u_int16_t		bge_idx;
 -	u_int16_t		bge_flags;
 -	u_int16_t		bge_type;
 -	u_int16_t		bge_tcp_udp_csum;
 -	u_int16_t		bge_ip_csum;
 -	u_int16_t		bge_vlan_tag;
 -	u_int16_t		bge_error_flag;
 +	uint16_t		bge_len0;
 +	uint16_t		bge_idx;
 +	uint16_t		bge_flags;
 +	uint16_t		bge_type;
 +	uint16_t		bge_tcp_udp_csum;
 +	uint16_t		bge_ip_csum;
 +	uint16_t		bge_vlan_tag;
 +	uint16_t		bge_error_flag;
  #else
 -	u_int16_t		bge_idx;
 -	u_int16_t		bge_len0;
 -	u_int16_t		bge_type;
 -	u_int16_t		bge_flags;
 -	u_int16_t		bge_ip_csum;
 -	u_int16_t		bge_tcp_udp_csum;
 -	u_int16_t		bge_error_flag;
 -	u_int16_t		bge_vlan_tag;
 +	uint16_t		bge_idx;
 +	uint16_t		bge_len0;
 +	uint16_t		bge_type;
 +	uint16_t		bge_flags;
 +	uint16_t		bge_ip_csum;
 +	uint16_t		bge_tcp_udp_csum;
 +	uint16_t		bge_error_flag;
 +	uint16_t		bge_vlan_tag;
  #endif
 -	u_int32_t		bge_rsvd0;
 -	u_int32_t		bge_opaque;
 +	uint32_t		bge_rsvd0;
 +	uint32_t		bge_opaque;
  };
  
  #define BGE_RXBDFLAG_END		0x0004
 @@ -1898,27 +1918,27 @@
  
  struct bge_sts_idx {
  #if BYTE_ORDER == LITTLE_ENDIAN
 -	u_int16_t		bge_rx_prod_idx;
 -	u_int16_t		bge_tx_cons_idx;
 +	uint16_t		bge_rx_prod_idx;
 +	uint16_t		bge_tx_cons_idx;
  #else
 -	u_int16_t		bge_tx_cons_idx;
 -	u_int16_t		bge_rx_prod_idx;
 +	uint16_t		bge_tx_cons_idx;
 +	uint16_t		bge_rx_prod_idx;
  #endif
  };
  
  struct bge_status_block {
 -	u_int32_t		bge_status;
 -	u_int32_t		bge_rsvd0;
 +	uint32_t		bge_status;
 +	uint32_t		bge_rsvd0;
  #if BYTE_ORDER == LITTLE_ENDIAN
 -	u_int16_t		bge_rx_jumbo_cons_idx;
 -	u_int16_t		bge_rx_std_cons_idx;
 -	u_int16_t		bge_rx_mini_cons_idx;
 -	u_int16_t		bge_rsvd1;
 +	uint16_t		bge_rx_jumbo_cons_idx;
 +	uint16_t		bge_rx_std_cons_idx;
 +	uint16_t		bge_rx_mini_cons_idx;
 +	uint16_t		bge_rsvd1;
  #else
 -	u_int16_t		bge_rx_std_cons_idx;
 -	u_int16_t		bge_rx_jumbo_cons_idx;
 -	u_int16_t		bge_rsvd1;
 -	u_int16_t		bge_rx_mini_cons_idx;
 +	uint16_t		bge_rx_std_cons_idx;
 +	uint16_t		bge_rx_jumbo_cons_idx;
 +	uint16_t		bge_rsvd1;
 +	uint16_t		bge_rx_mini_cons_idx;
  #endif
  	struct bge_sts_idx	bge_idx[16];
  };
 @@ -1939,37 +1959,54 @@
  #define BCOM_VENDORID			0x14E4
  #define BCOM_DEVICEID_BCM5700		0x1644
  #define BCOM_DEVICEID_BCM5701		0x1645
 -#define BCOM_DEVICEID_BCM5702		0x16A6
 -#define BCOM_DEVICEID_BCM5702X		0x16C6
 -#define BCOM_DEVICEID_BCM5703		0x16A7
 -#define BCOM_DEVICEID_BCM5703X		0x16C7
 +#define BCOM_DEVICEID_BCM5702		0x1646
 +#define BCOM_DEVICEID_BCM5702X		0x16A6
 +#define BCOM_DEVICEID_BCM5702_ALT	0x16C6
 +#define BCOM_DEVICEID_BCM5703		0x1647
 +#define BCOM_DEVICEID_BCM5703X		0x16A7
 +#define BCOM_DEVICEID_BCM5703_ALT	0x16C7
  #define BCOM_DEVICEID_BCM5704C		0x1648
  #define BCOM_DEVICEID_BCM5704S		0x16A8
 +#define BCOM_DEVICEID_BCM5704S_ALT	0x1649
  #define BCOM_DEVICEID_BCM5705		0x1653
  #define BCOM_DEVICEID_BCM5705K		0x1654
 -#define BCOM_DEVICEID_BCM5721		0x1659
 +#define BCOM_DEVICEID_BCM5705F		0x166E
  #define BCOM_DEVICEID_BCM5705M		0x165D
  #define BCOM_DEVICEID_BCM5705M_ALT	0x165E
  #define BCOM_DEVICEID_BCM5714C		0x1668
 +#define BCOM_DEVICEID_BCM5714S		0x1669
 +#define BCOM_DEVICEID_BCM5715		0x1678
 +#define BCOM_DEVICEID_BCM5715S		0x1679
 +#define BCOM_DEVICEID_BCM5720		0x1658
 +#define BCOM_DEVICEID_BCM5721		0x1659
  #define BCOM_DEVICEID_BCM5750		0x1676
  #define BCOM_DEVICEID_BCM5750M		0x167C
  #define BCOM_DEVICEID_BCM5751		0x1677
 +#define BCOM_DEVICEID_BCM5751F		0x167E
  #define BCOM_DEVICEID_BCM5751M		0x167D
  #define BCOM_DEVICEID_BCM5752		0x1600
 +#define BCOM_DEVICEID_BCM5752M		0x1601
 +#define BCOM_DEVICEID_BCM5753		0x16F7
 +#define BCOM_DEVICEID_BCM5753F		0x16FE
 +#define BCOM_DEVICEID_BCM5753M		0x16FD
 +#define BCOM_DEVICEID_BCM5780		0x166A
 +#define BCOM_DEVICEID_BCM5780S		0x166B
 +#define BCOM_DEVICEID_BCM5781		0x16DD
  #define BCOM_DEVICEID_BCM5782		0x1696
  #define BCOM_DEVICEID_BCM5788		0x169C
  #define BCOM_DEVICEID_BCM5789		0x169D
  #define BCOM_DEVICEID_BCM5901		0x170D
  #define BCOM_DEVICEID_BCM5901A2		0x170E
 +#define BCOM_DEVICEID_BCM5903M		0x16FF
  
  /*
   * Alteon AceNIC PCI vendor/device ID.
   */
 -#define ALT_VENDORID			0x12AE
 -#define ALT_DEVICEID_ACENIC		0x0001
 -#define ALT_DEVICEID_ACENIC_COPPER	0x0002
 -#define ALT_DEVICEID_BCM5700		0x0003
 -#define ALT_DEVICEID_BCM5701		0x0004
 +#define ALTEON_VENDORID			0x12AE
 +#define ALTEON_DEVICEID_ACENIC		0x0001
 +#define ALTEON_DEVICEID_ACENIC_COPPER	0x0002
 +#define ALTEON_DEVICEID_BCM5700		0x0003
 +#define ALTEON_DEVICEID_BCM5701		0x0004
  
  /*
   * 3Com 3c985 PCI vendor/device ID.
 @@ -2001,6 +2038,12 @@
  #define DELL_VENDORID			0x1028
  
  /*
 + * Apple PCI vendor ID.
 + */
 +#define	APPLE_VENDORID			0x106b
 +#define APPLE_DEVICE_BCM5701		0x1645
 +
 +/*
   * Offset of MAC address inside EEPROM.
   */
  #define BGE_EE_MAC_OFFSET		0x7C
 @@ -2129,43 +2172,43 @@
  
  /* Stats counters access through registers */
  struct bge_mac_stats_regs {
 -	u_int32_t		ifHCOutOctets;
 -	u_int32_t		Reserved0;
 -	u_int32_t		etherStatsCollisions;
 -	u_int32_t		outXonSent;
 -	u_int32_t		outXoffSent;
 -	u_int32_t		Reserved1;
 -	u_int32_t		dot3StatsInternalMacTransmitErrors;
 -	u_int32_t		dot3StatsSingleCollisionFrames;
 -	u_int32_t		dot3StatsMultipleCollisionFrames;
 -	u_int32_t		dot3StatsDeferredTransmissions;
 -	u_int32_t		Reserved2;
 -	u_int32_t		dot3StatsExcessiveCollisions;
 -	u_int32_t		dot3StatsLateCollisions;
 -	u_int32_t		Reserved3[14];
 -	u_int32_t		ifHCOutUcastPkts;
 -	u_int32_t		ifHCOutMulticastPkts;
 -	u_int32_t		ifHCOutBroadcastPkts;
 -	u_int32_t		Reserved4[2];
 -	u_int32_t		ifHCInOctets;
 -	u_int32_t		Reserved5;
 -	u_int32_t		etherStatsFragments;
 -	u_int32_t		ifHCInUcastPkts;
 -	u_int32_t		ifHCInMulticastPkts;
 -	u_int32_t		ifHCInBroadcastPkts;
 -	u_int32_t		dot3StatsFCSErrors;
 -	u_int32_t		dot3StatsAlignmentErrors;
 -	u_int32_t		xonPauseFramesReceived;
 -	u_int32_t		xoffPauseFramesReceived;
 -	u_int32_t		macControlFramesReceived;
 -	u_int32_t		xoffStateEntered;
 -	u_int32_t		dot3StatsFramesTooLong;
 -	u_int32_t		etherStatsJabbers;
 -	u_int32_t		etherStatsUndersizePkts;
 +	uint32_t		ifHCOutOctets;
 +	uint32_t		Reserved0;
 +	uint32_t		etherStatsCollisions;
 +	uint32_t		outXonSent;
 +	uint32_t		outXoffSent;
 +	uint32_t		Reserved1;
 +	uint32_t		dot3StatsInternalMacTransmitErrors;
 +	uint32_t		dot3StatsSingleCollisionFrames;
 +	uint32_t		dot3StatsMultipleCollisionFrames;
 +	uint32_t		dot3StatsDeferredTransmissions;
 +	uint32_t		Reserved2;
 +	uint32_t		dot3StatsExcessiveCollisions;
 +	uint32_t		dot3StatsLateCollisions;
 +	uint32_t		Reserved3[14];
 +	uint32_t		ifHCOutUcastPkts;
 +	uint32_t		ifHCOutMulticastPkts;
 +	uint32_t		ifHCOutBroadcastPkts;
 +	uint32_t		Reserved4[2];
 +	uint32_t		ifHCInOctets;
 +	uint32_t		Reserved5;
 +	uint32_t		etherStatsFragments;
 +	uint32_t		ifHCInUcastPkts;
 +	uint32_t		ifHCInMulticastPkts;
 +	uint32_t		ifHCInBroadcastPkts;
 +	uint32_t		dot3StatsFCSErrors;
 +	uint32_t		dot3StatsAlignmentErrors;
 +	uint32_t		xonPauseFramesReceived;
 +	uint32_t		xoffPauseFramesReceived;
 +	uint32_t		macControlFramesReceived;
 +	uint32_t		xoffStateEntered;
 +	uint32_t		dot3StatsFramesTooLong;
 +	uint32_t		etherStatsJabbers;
 +	uint32_t		etherStatsUndersizePkts;
  };
  
  struct bge_stats {
 -	u_int8_t		Reserved0[256];
 +	uint8_t		Reserved0[256];
  
  	/* Statistics maintained by Receive MAC. */
  	struct bge_rx_mac_stats rxstats;
 @@ -2202,7 +2245,7 @@
  	bge_hostaddr		nicAvoidedInterrupts;
  	bge_hostaddr		nicSendThresholdHit;
  
 -	u_int8_t		Reserved4[320];
 +	uint8_t		Reserved4[320];
  };
  
  /*
 @@ -2238,14 +2281,14 @@
  
  /* VPD structures */
  struct vpd_res {
 -	u_int8_t		vr_id;
 -	u_int8_t		vr_len;
 -	u_int8_t		vr_pad;
 +	uint8_t		vr_id;
 +	uint8_t		vr_len;
 +	uint8_t		vr_pad;
  };
  
  struct vpd_key {
  	char			vk_key[2];
 -	u_int8_t		vk_len;
 +	uint8_t		vk_len;
  };
  
  #define VPD_RES_ID	0x82	/* ID string */
 @@ -2286,8 +2329,8 @@
  #define BGE_JSLOTS	384
  
  #define BGE_JRAWLEN (BGE_JUMBO_FRAMELEN + ETHER_ALIGN)
 -#define BGE_JLEN (BGE_JRAWLEN + (sizeof(u_int64_t) - \
 -	(BGE_JRAWLEN % sizeof(u_int64_t))))
 +#define BGE_JLEN (BGE_JRAWLEN + (sizeof(uint64_t) - \
 +	(BGE_JRAWLEN % sizeof(uint64_t))))
  #define BGE_JPAGESZ PAGE_SIZE
  #define BGE_RESID (BGE_JPAGESZ - (BGE_JLEN * BGE_JSLOTS) % BGE_JPAGESZ)
  #define BGE_JMEM ((BGE_JLEN * BGE_JSLOTS) + BGE_RESID)
 @@ -2363,16 +2406,15 @@
  struct bge_dmamap_arg {
  	struct bge_softc	*sc;
  	bus_addr_t		bge_busaddr;
 -	u_int16_t		bge_flags;
 +	uint16_t		bge_flags;
  	int			bge_idx;
  	int			bge_maxsegs;
  	struct bge_tx_bd	*bge_ring;
  };
  
  struct bge_type {
 -	u_int16_t		bge_vid;
 -	u_int16_t		bge_did;
 -	char			*bge_name;
 +	uint16_t		bge_vid;
 +	uint16_t		bge_did;
  };
  
  #define BGE_HWREV_TIGON		0x01
 @@ -2396,29 +2438,30 @@
  	struct resource		*bge_irq;
  	struct resource		*bge_res;
  	struct ifmedia		bge_ifmedia;	/* TBI media info */
 -	u_int8_t		bge_extram;	/* has external SSRAM */
 -	u_int8_t		bge_tbi;
 -	u_int8_t		bge_rx_alignment_bug;
 -	u_int32_t		bge_chipid;
 -	u_int8_t		bge_asicrev;
 -	u_int8_t		bge_chiprev;
 -	u_int8_t		bge_no_3_led;
 -	u_int8_t		bge_pcie;
 +	uint8_t		bge_extram;	/* has external SSRAM */
 +	uint8_t		bge_tbi;
 +	uint8_t		bge_rx_alignment_bug;
 +	uint32_t		bge_chipid;
 +	uint8_t		bge_asicrev;
 +	uint8_t		bge_chiprev;
 +	uint8_t		bge_no_3_led;
 +	uint8_t		bge_pcie;
 +	uint8_t		bge_pcix;
  	struct bge_ring_data	bge_ldata;	/* rings */
  	struct bge_chain_data	bge_cdata;	/* mbufs */
 -	u_int16_t		bge_tx_saved_considx;
 -	u_int16_t		bge_rx_saved_considx;
 -	u_int16_t		bge_ev_saved_considx;
 -	u_int16_t		bge_return_ring_cnt;
 -	u_int16_t		bge_std;	/* current std ring head */
 -	u_int16_t		bge_jumbo;	/* current jumo ring head */
 -	u_int32_t		bge_stat_ticks;
 -	u_int32_t		bge_rx_coal_ticks;
 -	u_int32_t		bge_tx_coal_ticks;
 -	u_int32_t		bge_tx_prodidx;
 -	u_int32_t		bge_rx_max_coal_bds;
 -	u_int32_t		bge_tx_max_coal_bds;
 -	u_int32_t		bge_tx_buf_ratio;
 +	uint16_t		bge_tx_saved_considx;
 +	uint16_t		bge_rx_saved_considx;
 +	uint16_t		bge_ev_saved_considx;
 +	uint16_t		bge_return_ring_cnt;
 +	uint16_t		bge_std;	/* current std ring head */
 +	uint16_t		bge_jumbo;	/* current jumo ring head */
 +	uint32_t		bge_stat_ticks;
 +	uint32_t		bge_rx_coal_ticks;
 +	uint32_t		bge_tx_coal_ticks;
 +	uint32_t		bge_tx_prodidx;
 +	uint32_t		bge_rx_max_coal_bds;
 +	uint32_t		bge_tx_max_coal_bds;
 +	uint32_t		bge_tx_buf_ratio;
  	int			bge_if_flags;
  	int			bge_txcnt;
  	int			bge_link;	/* link state */
 
 --61jdw2sOBCFtR2d/--
State-Changed-From-To: open->feedback 
State-Changed-By: glebius 
State-Changed-When: Thu Jun 15 14:32:01 UTC 2006 
State-Changed-Why:  
I've committed a patch to HEAD and a diff for RELENG_6 is 
filed inside the PR. 

Now we need submitter to confirm that the bug is fixed. 


Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Thu Jun 15 14:32:01 UTC 2006 
Responsible-Changed-Why:  
I've committed a patch to HEAD and a diff for RELENG_6 is 
filed inside the PR. 

Now we need submitter to confirm that the bug is fixed. 

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

From: "Imri Zvik" <imriz@co.zahav.net.il>
To: <bug-followup@FreeBSD.org>,
	<freebsd-bugs@mikhailov.org>
Cc:  
Subject: Re: kern/68351: [bge] bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Sun, 23 Jul 2006 11:37:00 +0300

 Hi,
 
 I've been suffering from the watchdog timeout issue on a 6.1-STABLE
 system. I've applied the patch, and so far the system has been running
 for 20 days without seeing any watchdog timeouts, but I still get quite
 a lot of Ierrs (tried to change the cable/switch/negotiated media type)
 - did not help.
 
 dmesg output:
 
 Copyright (c) 1992-2006 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 6.1-STABLE #7: Tue Jul  4 15:52:09 IDT 2006
     root@XXXX:/usr/obj/usr/src/sys/IGLD
 ACPI APIC Table: <COMPAQ 00000083>
 Timecounter "i8254" frequency 1193182 Hz quality 0
 CPU: Intel(R) Xeon(TM) CPU 2.80GHz (2799.23-MHz 686-class CPU)
   Origin =3D "GenuineIntel"  Id =3D 0xf29  Stepping =3D 9
 =20
 Features=3D0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PG=
 E
 ,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
   Features2=3D0x4400<CNTX-ID,<b14>>
   Logical CPUs per core: 2
 real memory  =3D 1073717248 (1023 MB)
 avail memory =3D 1041608704 (993 MB)
 FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
  cpu0 (BSP): APIC ID:  0
  cpu1 (AP): APIC ID:  1
  cpu2 (AP): APIC ID:  6
  cpu3 (AP): APIC ID:  7
 MADT: Forcing active-low polarity and level trigger for SCI
 ioapic0 <Version 1.1> irqs 0-15 on motherboard
 ioapic1 <Version 1.1> irqs 16-31 on motherboard
 ioapic2 <Version 1.1> irqs 32-47 on motherboard
 ioapic3 <Version 1.1> irqs 48-63 on motherboard
 acpi0: <COMPAQ P31> on motherboard
 acpi0: Power Button (fixed)
 Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000
 acpi_timer0: <32-bit timer at 3.579545MHz> port 0x920-0x923 on acpi0
 cpu0: <ACPI CPU> on acpi0
 cpu1: <ACPI CPU> on acpi0
 cpu2: <ACPI CPU> on acpi0
 cpu3: <ACPI CPU> on acpi0
 pcib0: <ACPI Host-PCI bridge> on acpi0
 pci0: <ACPI PCI bus> on pcib0
 pci0: <display, VGA> at device 3.0 (no driver attached)
 ciss0: <Compaq Smart Array 5i> port 0x2800-0x28ff mem
 0xf5f80000-0xf5fbffff,0xf5df0000-0xf5df3fff irq 31 at device 4.0 on pci0
 ciss0: [GIANT-LOCKED]
 pci0: <base peripheral> at device 5.0 (no driver attached)
 pci0: <base peripheral> at device 5.2 (no driver attached)
 isab0: <PCI-ISA bridge> at device 15.0 on pci0
 isa0: <ISA bus> on isab0
 atapci0: <ServerWorks CSB5 UDMA100 controller> port
 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x2000-0x200f at device 15.1 on pci0
 ata0: <ATA channel 0> on atapci0
 ata1: <ATA channel 1> on atapci0
 ohci0: <OHCI (generic) USB controller> mem 0xf5e70000-0xf5e70fff irq 10
 at device 15.2 on pci0
 ohci0: [GIANT-LOCKED]
 usb0: OHCI version 1.0, legacy support
 usb0: SMM does not respond, resetting
 usb0: <OHCI (generic) USB controller> on ohci0
 usb0: USB revision 1.0
 uhub0: (0x1166) OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub0: 4 ports with 4 removable, self powered
 pcib1: <ACPI Host-PCI bridge> on acpi0
 pci1: <ACPI PCI bus> on pcib1
 bge0: <BCM5703 A2, ASIC rev. 0x1002> mem 0xf7ef0000-0xf7efffff irq 30 at
 device 2.0 on pci1
 miibus0: <MII bus> on bge0
 brgphy0: <BCM5703 10/100/1000baseTX PHY> on miibus0
 brgphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX,
 1000baseTX-FDX, auto
 bge0: Ethernet address: 00:11:0a:30:95:e6
 pcib2: <ACPI Host-PCI bridge> on acpi0
 pci4: <ACPI PCI bus> on pcib2
 bge1: <BCM5703 A2, ASIC rev. 0x1002> mem 0xf7ff0000-0xf7ffffff irq 29 at
 device 2.0 on pci4
 miibus1: <MII bus> on bge1
 brgphy1: <BCM5703 10/100/1000baseTX PHY> on miibus1
 brgphy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX,
 1000baseTX-FDX, auto
 bge1: Ethernet address: 00:11:0a:30:95:e5
 acpi_tz0: <Thermal Zone> on acpi0
 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
 atkbd0: <AT Keyboard> irq 1 on atkbdc0
 kbd0 at atkbd0
 atkbd0: [GIANT-LOCKED]
 sio0: <Standard PC COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
 sio0: type 16550A
 fdc0: <floppy drive controller (FDE)> port 0x3f2-0x3f5 irq 6 drq 2 on
 acpi0
 fdc0: [FAST]
 fd0: <1440-KB 3.5" drive> on fdc0 drive 0
 pmtimer0 on isa0
 orm0: <ISA Option ROMs> at iomem
 0xc0000-0xc7fff,0xc8000-0xcbfff,0xcc000-0xcd7ff,0xee000-0xeffff on isa0
 ppc0: parallel port not found.
 sc0: <System console> at flags 0x100 on isa0
 sc0: VGA <16 virtual consoles, flags=3D0x300>
 sio1: configured irq 3 not in bitmap of probed irqs 0
 sio1: port may not be enabled
 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on
 isa0
 Timecounters tick every 1.000 msec
 ipfw2 (+ipv6) initialized, divert loadable, rule-based forwarding
 enabled, default to accept, logging unlimited
 acd0: CDROM <CRN-8245B/2.19> at ata0-master PIO4
 da0 at ciss0 bus 0 target 0 lun 0
 da0: <COMPAQ RAID 1  VOLUME OK> Fixed Direct Access SCSI-0 device
 da0: 135.168MB/s transfers
 da0: 69459MB (142253280 512 byte sectors: 255H 32S/T 17433C)
 SMP: AP CPU #3 Launched!
 SMP: AP CPU #1 Launched!
 SMP: AP CPU #2 Launched!
 Trying to mount root from ufs:/dev/da0s1a
 bge1: link state changed to UP

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: Imri Zvik <imriz@co.zahav.net.il>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/68351: [bge] bge0 watchdog timeout on 5.2.1 and -current, 5.1 is ok
Date: Mon, 7 Aug 2006 14:13:35 +0400

 On Sun, Jul 23, 2006 at 08:40:17AM +0000, Imri Zvik wrote:
 I>  I've been suffering from the watchdog timeout issue on a 6.1-STABLE
 I>  system. I've applied the patch, and so far the system has been running
 I>  for 20 days without seeing any watchdog timeouts, but I still get quite
 I>  a lot of Ierrs (tried to change the cable/switch/negotiated media type)
 I>  - did not help.
 
 Good to hear that watchdog timeout has gone. I have already merged the
 patch to RELENG_6. I'd like to hear from the submitter, that I can close
 the PR.
 
 The Ierrs weren't counted before oleg@ has committed a patch that did
 count them. So I suppose you had the ierrs before, but the driver
 didn't show them.
 
 revision 1.114
 date: 2006/01/17 23:01:57;  author: oleg;  state: Exp;  lines: +30 -29
  - Count packets discarded by RX/TX MAC (cause of FIFO overflow, etc)
    as input/output interface errors.
  - Keep values of rx/tx discards & tx collisions inside struct bge_softc.
    So we can keep statistic across ifconfig down/up runs (cause bringing
    bge up will reset chip).
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE
State-Changed-From-To: feedback->closed 
State-Changed-By: glebius 
State-Changed-When: Thu Aug 10 11:15:36 UTC 2006 
State-Changed-Why:  
The bug is expected to be fixed in RELENG_6. Submitter doesn't responds. 

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