[rfc] MFC 7.x bce(4) to 6.x

pluknet pluknet at gmail.com
Fri Jul 17 13:42:39 UTC 2009


Hi.

Is there a planned MFC of bce(4) changes between 6.4 and 7.2 to RELENG_6?

We need this at work in order to support Broadcom BCM5709 in (post-)6.4.

I could able to backport recent 7.x changes to 6.4.
I'm not sure about MSI and/or TSO4 stability here since there are
changes since 6.x in bce(4).
What I did is checkout RELENG_7 bce sources plus small hackish patch
to compile this on 6.x.

# uname -a
FreeBSD  6.4-RELEASE FreeBSD 6.4-RELEASE #0: Fri Jul 17 21:08:32 MSD
2009     root@:/usr/obj/usr/src/sys/SMP  i386

It seems to work good. I have a network access to the box now.

after kldload if_bce:
bce0: <Broadcom NetXtreme II BCM5709 1000Base-T (C0)> mem 0x92000000-0x93ffffff
irq 28 at device 0.0 on pci11
miibus0: <MII bus> on bce0
ukphy0: <Generic IEEE 802.3u media interface> on miibus0
ukphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FD
X, auto
bce0: Ethernet address: 00:1a:64:e5:13:ec
bce0: link state changed to DOWN
bce0: ASIC (0x57092003); Rev (C0); Bus (PCIe x2, 5Gbps); B/C (0x04060705); Flags
( MFW MSI )
bce1: <Broadcom NetXtreme II BCM5709 1000Base-T (C0)> mem 0x94000000-0x95ffffff
irq 40 at device 0.1 on pci11
miibus1: <MII bus> on bce1
ukphy1: <Generic IEEE 802.3u media interface> on miibus1
ukphy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FD
X, auto
bce1: Ethernet address: 00:1a:64:e5:13:ee
bce1: ASIC (0x
bce1: link state changed to DOWN
57092003); Rev (C0); Bus (PCIe x2, 5Gbps); B/C (0x04060705); Flags( MFW MSI )
bce0: link state changed to UP
bce0: link state changed to DOWN
bce0: link state changed to UP

The patch (against if_bce.c,v 1.34.2.9):

--- /home/pluknet/cvs-7/src/sys/dev/bce/if_bce.c        Wed Jun  3 13:42:55 2009
+++ bce/if_bce.c        Fri Jul 17 15:26:00 2009
@@ -54,6 +54,12 @@ __FBSDID("$FreeBSD: src/sys/dev/bce/if_b
 #include <dev/bce/if_bcereg.h>
 #include <dev/bce/if_bcefw.h>

+/* From sys/mbuf.h */
+#define CSUM_TSO       0x0020          /* will do TSO */
+
+/* From net/if.h */
+#define IFCAP_TSO4     0x00100         /* can do TCP Segmentation Offload */
+
 /****************************************************************************/
 /* BCE Debug Options                                                        */
 /****************************************************************************/
@@ -1059,7 +1065,7 @@ bce_attach(device_t dev)

        /* Hookup IRQ last. */
        rc = bus_setup_intr(dev, sc->bce_res_irq, INTR_TYPE_NET | INTR_MPSAFE,
-               NULL, bce_intr, sc, &sc->bce_intrhand);
+               bce_intr, sc, &sc->bce_intrhand);

        if (rc) {
                BCE_PRINTF("%s(%d): Failed to setup IRQ!\n",
@@ -6391,13 +6397,24 @@ bce_tx_encap(struct bce_softc *sc, struc
        bus_dma_segment_t segs[BCE_MAX_SEGMENTS];
        bus_dmamap_t map;
        struct tx_bd *txbd = NULL;
+#if __FreeBSD_version <= 700022
+       struct m_tag *mtag;
+#endif
        struct mbuf *m0;
+#if __FreeBSD_version > 700022
        struct ether_vlan_header *eh;
        struct ip *ip;
        struct tcphdr *th;
-       u16 prod, chain_prod, etype, mss = 0, vlan_tag = 0, flags = 0;
+#endif
+       u16 prod, chain_prod,
+#if __FreeBSD_version > 700022
+       etype,
+#endif
+       mss = 0, vlan_tag = 0, flags = 0;
        u32 prod_bseq;
+#if __FreeBSD_version > 700022
        int hdr_len = 0, e_hlen = 0, ip_hlen = 0, tcp_hlen = 0, ip_len = 0;
+#endif

 #ifdef BCE_DEBUG
        u16 debug_prod;
@@ -6418,6 +6435,7 @@ bce_tx_encap(struct bce_softc *sc, struc
                        flags |= TX_BD_FLAGS_IP_CKSUM;
                if (m0->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP))
                        flags |= TX_BD_FLAGS_TCP_UDP_CKSUM;
+#if __FreeBSD_version > 700022
                if (m0->m_pkthdr.csum_flags & CSUM_TSO) {
                        /* For TSO the controller needs two pieces of info, */
                        /* the MSS and the IP+TCP options length.           */
@@ -6481,14 +6499,23 @@ bce_tx_encap(struct bce_softc *sc, struc
 bce_tx_encap_skip_tso:
                        DBRUN(sc->requested_tso_frames++);
                }
+#endif
        }

        /* Transfer any VLAN tags to the bd. */
+#if __FreeBSD_version > 700022
        if (m0->m_flags & M_VLANTAG) {
                flags |= TX_BD_FLAGS_VLAN_TAG;
                vlan_tag = m0->m_pkthdr.ether_vtag;
        }

+#else
+        mtag = VLAN_OUTPUT_TAG(sc->bce_ifp, m0);
+        if (mtag != NULL) {
+                flags |= TX_BD_FLAGS_VLAN_TAG;
+                vlan_tag = VLAN_TAG_VALUE(mtag);
+        }
+#endif
        /* Map the mbuf into DMAable memory. */
        prod = sc->tx_prod;
        chain_prod = TX_CHAIN_IDX(prod);

-- 
wbr,
pluknet
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bce.7-down-to-6.patch
Type: application/octet-stream
Size: 2710 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20090717/1bb9863a/bce.7-down-to-6.obj


More information about the freebsd-stable mailing list