NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/46961: Please support BCM57762 Ethernet arapter (Apple's Thunderbolt Ethernet Adapter)



>Number:         46961
>Category:       kern
>Synopsis:       Please support BCM57762 Ethernet arapter (Apple's Thunderbolt 
>Ethernet Adapter)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 16 00:50:01 +0000 2012
>Originator:     Ryo ONODERA
>Release:        NetBSD 6.99.11
>Organization:
        
>Environment:
        
        
System: NetBSD tellurium.elements.tetera.org 6.99.11 NetBSD 6.99.11 (NODKWEDGE) 
#42: Sun Sep 16 09:31:57 JST 2012 
root%tellurium.elements.tetera.org@localhost:/usr/obj/sys/arch/amd64/compile/NODKWEDGE
 amd64
Architecture: x86_64
Machine: amd64
>Description:
Apple's Thunderbolt to Gigabit Ethernet Adapter,
http://store.apple.com/us/product/MD463ZM/A/thunderbolt-to-gigabit-ethernet-adapter
 ,
is not supported for NetBSD current.
Please support it.
With my patches, I have gotten the following dmesg and ifconfig output.

dmesg:

bge0 at pci8 dev 0 function 0: Broadcom BCM57762 Gigabit Ethernet
bge0: interrupting at ioapic0 pin 19
bge0: ASIC unknown BCM57766 (0x57766000), Ethernet address 40:6c:8f:58:6c:c5
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM57765 1000BASE-T media interface, rev. 0
brgphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 
1000baseT-FDX, auto


ifconfig output:

bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        
capabilities=3f80<TSO4,IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM_Rx,UDP4CSUM_Tx>
        enabled=0
        address: 40:6c:8f:58:6c:c5
        media: Ethernet autoselect (100baseTX 
full-duplex,flowcontrol,rxpause,txpause)
        status: active
        inet 192.168.81.9 netmask 0xffffff00 broadcast 192.168.81.255
        inet6 fe80::426c:8fff:fe58:6cc5%bge0 prefixlen 64 scopeid 0x1

        
>How-To-Repeat:
Insert Thunderbolt to Gigabit Ethernet Adapter to Apple's machine,
for example Macbook Air, and reboot.
        
>Fix:
        
Index: net/if_ether.h
===================================================================
RCS file: /cvsroot/src/sys/net/if_ether.h,v
retrieving revision 1.58
diff -u -r1.58 if_ether.h
--- net/if_ether.h      19 May 2010 20:41:59 -0000      1.58
+++ net/if_ether.h      16 Sep 2012 00:45:23 -0000
@@ -51,6 +51,7 @@
 #define        ETHER_MIN_LEN   64      /* minimum frame length, including CRC 
*/
 #define        ETHER_MAX_LEN   1518    /* maximum frame length, including CRC 
*/
 #define        ETHER_MAX_LEN_JUMBO 9018 /* maximum jumbo frame len, including 
CRC */
+#define ETHER_MAX_DIX_LEN      1536    /* Maximum DIX frame length */
 
 /*
  * Some Ethernet extensions.
Index: dev/pci/if_bge.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_bge.c,v
retrieving revision 1.201
diff -u -r1.201 if_bge.c
--- dev/pci/if_bge.c    22 Jul 2012 14:33:01 -0000      1.201
+++ dev/pci/if_bge.c    16 Sep 2012 00:45:23 -0000
@@ -564,6 +564,10 @@
          "Broadcom BCM57761 Fast Ethernet",
          },
        { PCI_VENDOR_BROADCOM,
+         PCI_PRODUCT_BROADCOM_BCM57762,
+         "Broadcom BCM57762 Gigabit Ethernet",
+         },
+       { PCI_VENDOR_BROADCOM,
          PCI_PRODUCT_BROADCOM_BCM57765,
          "Broadcom BCM57765 Fast Ethernet",
          },
@@ -728,6 +732,7 @@
        { BGE_ASICREV_BCM57780, "unknown BCM57780" },
        { BGE_ASICREV_BCM5717, "unknown BCM5717" },
        { BGE_ASICREV_BCM57765, "unknown BCM57765" },
+       { BGE_ASICREV_BCM57766, "unknown BCM57766" },
 
        { 0, NULL }
 };
@@ -1969,7 +1974,23 @@
 #else
 
        /* new broadcom docs strongly recommend these: */
-       if (!BGE_IS_5705_PLUS(sc)) {
+       if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5717 ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57765 ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57766) {
+               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0);
+               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x2a);
+               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0xa0);
+       } else if (BGE_IS_5705_PLUS(sc)) {
+               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0);
+
+               if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906) {
+                       CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x04);
+                       CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0x10);
+               } else {
+                       CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x10);
+                       CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0x60);
+               }
+       } else if (!BGE_IS_5705_PLUS(sc)) {
                if (ifp->if_mtu > ETHER_MAX_LEN) {
                        CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x50);
                        CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x20);
@@ -1979,14 +2000,10 @@
                        CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 152);
                        CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 380);
                }
-       } else if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906) {
-               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0);
-               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x04);
-               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0x10);
        } else {
-               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0);
-               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x10);
-               CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0x60);
+                       CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0);
+                       CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x10);
+                       CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0x60);
        }
 #endif
 
@@ -2031,7 +2048,12 @@
        /* Step 41: Initialize the standard RX ring control block */
        rcb = &sc->bge_rdata->bge_info.bge_std_rx_rcb;
        BGE_HOSTADDR(rcb->bge_hostaddr, BGE_RING_DMA_ADDR(sc, bge_rx_std_ring));
-       if (BGE_IS_5705_PLUS(sc))
+       if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5717 ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57765 ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57766)
+               rcb->bge_maxlen_flags = (BGE_RCB_MAXLEN_FLAGS(512, 0) |
+                                       (ETHER_MAX_DIX_LEN << 2));
+       else if (BGE_IS_5705_PLUS(sc))
                rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(512, 0);
        else
                rcb->bge_maxlen_flags =
@@ -2097,7 +2119,8 @@
        CSR_WRITE_4(sc, BGE_RBDI_JUMBO_REPL_THRESH, BGE_JUMBO_RX_RING_CNT / 8);
 
        if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5717 ||
-           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57765) {
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57765 ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57766) {
                CSR_WRITE_4(sc, BGE_STD_REPL_LWM, 4);
                CSR_WRITE_4(sc, BGE_JUMBO_REPL_LWM, 4);
        }
@@ -2603,6 +2626,7 @@
                        sc->bge_chipid = pci_conf_read(pc, pa->pa_tag,
                            BGE_PCI_GEN2_PRODID_ASICREV);
                else if (PCI_PRODUCT(pa->pa_id) == 
PCI_PRODUCT_BROADCOM_BCM57761 ||
+                        PCI_PRODUCT(pa->pa_id) == 
PCI_PRODUCT_BROADCOM_BCM57762 ||
                         PCI_PRODUCT(pa->pa_id) == 
PCI_PRODUCT_BROADCOM_BCM57765 ||
                         PCI_PRODUCT(pa->pa_id) == 
PCI_PRODUCT_BROADCOM_BCM57781 ||
                         PCI_PRODUCT(pa->pa_id) == 
PCI_PRODUCT_BROADCOM_BCM57785 ||
@@ -2651,6 +2675,7 @@
            BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5785 ||
            BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5787 ||
            BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57765 ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57766 ||
            BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57780)
                sc->bge_flags |= BGE_5755_PLUS;
 
@@ -2751,6 +2776,7 @@
            BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5717 &&
            BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5785 &&
            BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM57765 &&
+           BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM57766 &&
            BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM57780) {
                if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5755 ||
                    BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5761 ||
@@ -2904,10 +2930,14 @@
                            "setting short Tx thresholds\n");
        }
 
-       if (BGE_IS_5705_PLUS(sc))
-               sc->bge_return_ring_cnt = BGE_RETURN_RING_CNT_5705;
-       else
+
+       if (BGE_IS_5700_FAMILY(sc) ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5717 ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57765 ||
+           BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57766)
                sc->bge_return_ring_cnt = BGE_RETURN_RING_CNT;
+       else
+               sc->bge_return_ring_cnt = BGE_RETURN_RING_CNT_5705;
 
        /* Set up ifnet structure */
        ifp = &sc->ethercom.ec_if;
@@ -3297,7 +3327,8 @@
            sc->bge_chipid != BGE_CHIPID_BCM5750_A0 &&
            BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5717 &&
            BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5785 &&
-           BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM57765) {
+           BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM57765 &&
+           BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM57766) {
                uint32_t v;
 
                /* Enable PCI Express bug fix */
Index: dev/pci/if_bgereg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_bgereg.h,v
retrieving revision 1.56
diff -u -r1.56 if_bgereg.h
--- dev/pci/if_bgereg.h 3 Feb 2010 15:36:36 -0000       1.56
+++ dev/pci/if_bgereg.h 16 Sep 2012 00:45:24 -0000
@@ -318,6 +318,7 @@
 #define BGE_CHIPID_BCM5787_A2          0xb002
 #define BGE_CHIPID_BCM5906_A1          0xc001
 #define BGE_CHIPID_BCM5906_A2          0xc002
+#define BGE_CHIPID_BCM57762            0x57766000
 #define BGE_CHIPID_BCM57780_A0         0x57780000
 #define BGE_CHIPID_BCM57780_A1         0x57780001
 
@@ -344,6 +345,7 @@
 #define BGE_ASICREV_BCM57780           0x57780
 #define BGE_ASICREV_BCM5717            0x5717
 #define BGE_ASICREV_BCM57765           0x57785
+#define BGE_ASICREV_BCM57766           0x57766
 
 /* chip revisions */
 #define BGE_CHIPREV(x)                 ((x) >> 8)
Index: dev/pci/pcidevs
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1133
diff -u -r1.1133 pcidevs
--- dev/pci/pcidevs     13 Sep 2012 12:11:06 -0000      1.1133
+++ dev/pci/pcidevs     16 Sep 2012 00:45:24 -0000
@@ -1592,6 +1592,7 @@
 product BROADCOM BCM5787F      0x167f  BCM5787F 10/100 Ethernet
 product BROADCOM BCM5761E      0x1680  BCM5761E 10/100/1000 Ethernet
 product BROADCOM BCM5761       0x1681  BCM5761 10/100/1000 Ethernet
+product BROADCOM BCM57762      0x1682  BCM57762 Gigabit Ethernet
 product BROADCOM BCM5764       0x1684  BCM5764 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5761S      0x1688  BCM5761S 10/100/1000 Ethernet
 product BROADCOM BCM5761SE     0x1689  BCM5761SE 10/100/1000 Ethernet


>Unformatted:
        
        


Home | Main Index | Thread Index | Old Index