Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jul 2009 17:42:37 +0400
From:      pluknet <pluknet@gmail.com>
To:        freebsd-stable <freebsd-stable@freebsd.org>, Xin LI <delphij@delphij.net>
Subject:   [rfc] MFC 7.x bce(4) to 6.x
Message-ID:  <a31046fc0907170642s67281e43mf14532105b8fbedf@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--001636c5b7c61aea3b046ee6f67b
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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

--001636c5b7c61aea3b046ee6f67b
Content-Type: application/octet-stream; name="bce.7-down-to-6.patch"
Content-Disposition: attachment; filename="bce.7-down-to-6.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fx8ylxw00

ZGlmZiAtdXJwTiAvaG9tZS9wbHVrbmV0L2N2cy03L3NyYy9zeXMvZGV2L2JjZS9pZl9iY2UuYyBi
Y2UvaWZfYmNlLmMKLS0tIC9ob21lL3BsdWtuZXQvY3ZzLTcvc3JjL3N5cy9kZXYvYmNlL2lmX2Jj
ZS5jCVdlZCBKdW4gIDMgMTM6NDI6NTUgMjAwOQorKysgYmNlL2lmX2JjZS5jCUZyaSBKdWwgMTcg
MTU6MjY6MDAgMjAwOQpAQCAtNTQsNiArNTQsMTIgQEAgX19GQlNESUQoIiRGcmVlQlNEOiBzcmMv
c3lzL2Rldi9iY2UvaWZfYgogI2luY2x1ZGUgPGRldi9iY2UvaWZfYmNlcmVnLmg+CiAjaW5jbHVk
ZSA8ZGV2L2JjZS9pZl9iY2Vmdy5oPgogCisvKiBGcm9tIHN5cy9tYnVmLmggKi8KKyNkZWZpbmUg
Q1NVTV9UU08JMHgwMDIwCQkvKiB3aWxsIGRvIFRTTyAqLworCisvKiBGcm9tIG5ldC9pZi5oICov
CisjZGVmaW5lIElGQ0FQX1RTTzQJMHgwMDEwMAkJLyogY2FuIGRvIFRDUCBTZWdtZW50YXRpb24g
T2ZmbG9hZCAqLworCiAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KIC8qIEJDRSBEZWJ1ZyBPcHRpb25z
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAq
LwogLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKiovCkBAIC0xMDU5LDcgKzEwNjUsNyBAQCBiY2VfYXR0YWNo
KGRldmljZV90IGRldikKIAogCS8qIEhvb2t1cCBJUlEgbGFzdC4gKi8KIAlyYyA9IGJ1c19zZXR1
cF9pbnRyKGRldiwgc2MtPmJjZV9yZXNfaXJxLCBJTlRSX1RZUEVfTkVUIHwgSU5UUl9NUFNBRkUs
Ci0JCU5VTEwsIGJjZV9pbnRyLCBzYywgJnNjLT5iY2VfaW50cmhhbmQpOworCQliY2VfaW50ciwg
c2MsICZzYy0+YmNlX2ludHJoYW5kKTsKIAogCWlmIChyYykgewogCQlCQ0VfUFJJTlRGKCIlcygl
ZCk6IEZhaWxlZCB0byBzZXR1cCBJUlEhXG4iLApAQCAtN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dfVkFMVUUobXRhZyk7CisgICAgICAgIH0KKyNlbmRpZgogCS8qIE1hcCB0
aGUgbWJ1ZiBpbnRvIERNQWFibGUgbWVtb3J5LiAqLwogCXByb2QgPSBzYy0+dHhfcHJvZDsKIAlj
aGFpbl9wcm9kID0gVFhfQ0hBSU5fSURYKHByb2QpOwo=
--001636c5b7c61aea3b046ee6f67b--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a31046fc0907170642s67281e43mf14532105b8fbedf>