summaryrefslogtreecommitdiffstats
path: root/sys/dev/mxge
diff options
context:
space:
mode:
authorgallatin <gallatin@FreeBSD.org>2008-02-14 00:09:59 +0000
committergallatin <gallatin@FreeBSD.org>2008-02-14 00:09:59 +0000
commit960266ca30f2cc722fa489cd00452c17a252f4e3 (patch)
tree00a5f5888189bcd5553bb21bf312c88a133dc599 /sys/dev/mxge
parentfd8332efc0afba46de3a399b5eab52ffebe88bdf (diff)
downloadFreeBSD-src-960266ca30f2cc722fa489cd00452c17a252f4e3.zip
FreeBSD-src-960266ca30f2cc722fa489cd00452c17a252f4e3.tar.gz
Add minimally invasive shims to ease MFCs of mxge back as far
as RELENG_6 Sponsored by: Myricom, Inc.
Diffstat (limited to 'sys/dev/mxge')
-rw-r--r--sys/dev/mxge/if_mxge.c49
-rw-r--r--sys/dev/mxge/if_mxge_var.h28
-rw-r--r--sys/dev/mxge/mxge_lro.c1
3 files changed, 68 insertions, 10 deletions
diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index 24ca729..fed3a6d 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -1730,6 +1730,8 @@ mxge_submit_req(mxge_tx_ring_t *tx, mcp_kreq_ether_send_t *src,
mb();
}
+#if IFCAP_TSO4
+
static void
mxge_encap_tso(struct mxge_slice_state *ss, struct mbuf *m,
int busdma_seg_cnt, int ip_off)
@@ -1889,6 +1891,9 @@ drop:
}
+#endif /* IFCAP_TSO4 */
+
+#ifdef MXGE_NEW_VLAN_API
/*
* We reproduce the software vlan tag insertion from
* net/if_vlan.c:vlan_start() here so that we can advertise "hardware"
@@ -1920,6 +1925,7 @@ mxge_vlan_tag_insert(struct mbuf *m)
m->m_flags &= ~M_VLANTAG;
return m;
}
+#endif /* MXGE_NEW_VLAN_API */
static void
mxge_encap(struct mxge_slice_state *ss, struct mbuf *m)
@@ -1941,13 +1947,14 @@ mxge_encap(struct mxge_slice_state *ss, struct mbuf *m)
tx = &ss->tx;
ip_off = sizeof (struct ether_header);
+#ifdef MXGE_NEW_VLAN_API
if (m->m_flags & M_VLANTAG) {
m = mxge_vlan_tag_insert(m);
if (__predict_false(m == NULL))
goto drop;
ip_off += ETHER_VLAN_ENCAP_LEN;
}
-
+#endif
/* (try to) map the frame for DMA */
idx = tx->req & tx->mask;
err = bus_dmamap_load_mbuf_sg(tx->dmat, tx->info[idx].map,
@@ -1976,12 +1983,13 @@ mxge_encap(struct mxge_slice_state *ss, struct mbuf *m)
BUS_DMASYNC_PREWRITE);
tx->info[idx].m = m;
-
+#if IFCAP_TSO4
/* TSO is different enough, we handle it in another routine */
if (m->m_pkthdr.csum_flags & (CSUM_TSO)) {
mxge_encap_tso(ss, m, cnt, ip_off);
return;
}
+#endif
req = tx->req_list;
cksum_offset = 0;
@@ -2291,8 +2299,21 @@ mxge_vlan_tag_remove(struct mbuf *m, uint32_t *csum)
*csum = htons(*csum);
/* save the tag */
- m->m_flags |= M_VLANTAG;
+#ifdef MXGE_NEW_VLAN_API
m->m_pkthdr.ether_vtag = ntohs(evl->evl_tag);
+#else
+ {
+ struct m_tag *mtag;
+ mtag = m_tag_alloc(MTAG_VLAN, MTAG_VLAN_TAG, sizeof(u_int),
+ M_NOWAIT);
+ if (mtag == NULL)
+ return;
+ VLAN_TAG_VALUE(mtag) = ntohs(evl->evl_tag);
+ m_tag_prepend(m, mtag);
+ }
+
+#endif
+ m->m_flags |= M_VLANTAG;
/*
* Remove the 802.1q header by copying the Ethernet
@@ -2557,7 +2578,7 @@ mxge_media_probe(mxge_softc_t *sc)
}
for (i = 0; i < 3; i++, ptr++) {
- ptr = strchr(ptr, '-');
+ ptr = index(ptr, '-');
if (ptr == NULL) {
device_printf(sc->dev,
"only %d dashes in PC?!?\n", i);
@@ -3954,8 +3975,10 @@ mxge_add_msix_irqs(mxge_softc_t *sc)
for (i = 0; i < sc->num_slices; i++) {
err = bus_setup_intr(sc->dev, sc->msix_irq_res[i],
INTR_TYPE_NET | INTR_MPSAFE,
- NULL, mxge_intr, &sc->ss[i],
- &sc->msix_ih[i]);
+#if __FreeBSD_version > 700030
+ NULL,
+#endif
+ mxge_intr, &sc->ss[i], &sc->msix_ih[i]);
if (err != 0) {
device_printf(sc->dev, "couldn't setup intr for "
"message %d\n", i);
@@ -4028,7 +4051,10 @@ mxge_add_single_irq(mxge_softc_t *sc)
rman_get_start(sc->irq_res));
err = bus_setup_intr(sc->dev, sc->irq_res,
INTR_TYPE_NET | INTR_MPSAFE,
- NULL, mxge_intr, &sc->ss[0], &sc->ih);
+#if __FreeBSD_version > 700030
+ NULL,
+#endif
+ mxge_intr, &sc->ss[0], &sc->ih);
if (err != 0) {
bus_release_resource(sc->dev, SYS_RES_IRQ,
sc->msi_enabled ? 1 : 0, sc->irq_res);
@@ -4230,8 +4256,11 @@ mxge_attach(device_t dev)
ifp->if_baudrate = 100000000;
ifp->if_capabilities = IFCAP_RXCSUM | IFCAP_TXCSUM | IFCAP_TSO4 |
- IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
- IFCAP_VLAN_HWCSUM | IFCAP_LRO;
+ IFCAP_VLAN_MTU | IFCAP_LRO;
+
+#ifdef MXGE_NEW_VLAN_API
+ ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWCSUM;
+#endif
sc->max_mtu = mxge_max_mtu(sc);
if (sc->max_mtu >= 9000)
@@ -4292,7 +4321,7 @@ mxge_detach(device_t dev)
{
mxge_softc_t *sc = device_get_softc(dev);
- if (sc->ifp->if_vlantrunk != NULL) {
+ if (mxge_vlans_active(sc)) {
device_printf(sc->dev,
"Detach vlans before removing module\n");
return EBUSY;
diff --git a/sys/dev/mxge/if_mxge_var.h b/sys/dev/mxge/if_mxge_var.h
index b6f9c8b..8e65e7f 100644
--- a/sys/dev/mxge/if_mxge_var.h
+++ b/sys/dev/mxge/if_mxge_var.h
@@ -45,6 +45,34 @@ $FreeBSD$
#define MXGE_VIRT_JUMBOS 0
#endif
+#ifndef VLAN_CAPABILITIES
+#define VLAN_CAPABILITIES(ifp)
+#define mxge_vlans_active(sc) (sc)->ifp->if_nvlans
+#else
+#define mxge_vlans_active(sc) (sc)->ifp->if_vlantrunk
+#endif
+
+#ifndef VLAN_TAG_VALUE
+#define MXGE_NEW_VLAN_API
+#endif
+
+#ifndef IFCAP_LRO
+#define IFCAP_LRO 0
+#endif
+
+#ifndef IFCAP_TSO
+#define IFCAP_TSO 0
+#endif
+
+#ifndef IFCAP_TSO4
+#define IFCAP_TSO4 0
+#endif
+
+#ifndef CSUM_TSO
+#define CSUM_TSO 0
+#endif
+
+
typedef struct {
void *addr;
bus_addr_t bus_addr;
diff --git a/sys/dev/mxge/mxge_lro.c b/sys/dev/mxge/mxge_lro.c
index 25bb5f4..3504702 100644
--- a/sys/dev/mxge/mxge_lro.c
+++ b/sys/dev/mxge/mxge_lro.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
+#include <sys/bus.h>
#include <net/if.h>
#include <net/ethernet.h>
OpenPOWER on IntegriCloud