summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2007-01-08 18:39:28 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2007-01-08 18:39:28 +0000
commit49441871594ee665e46094bc28ca0d87cbca5392 (patch)
tree4510f2e39f9b540083ca73e4ef3930e965f0d0e1 /sys
parent06c717d0ecd9153ae81180b3bb90421696e1d61d (diff)
Add support for HW TCP/IP checksum offload for adapters that support it.
Tested by many (IP/UDP/TCP): Jason McIntyre <jmc@> Chris Kuethe <chris.kuethe AT gmail.com> Alf Schlichting <a.schlichting AT lemarit.com> Rodolfo Gouveia <rgouveia AT cosmico.net> Peter Stromberg <wilfried@> Has been in snaps for weeks too with noone complaining so far.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/if_nfe.c25
-rw-r--r--sys/dev/pci/if_nfereg.h8
2 files changed, 12 insertions, 21 deletions
diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c
index 14d4aeb6eb6..62452aceb3a 100644
--- a/sys/dev/pci/if_nfe.c
+++ b/sys/dev/pci/if_nfe.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: if_nfe.c,v 1.67 2006/11/15 02:24:37 brad Exp $ */
+/* $OpenBSD: if_nfe.c,v 1.68 2007/01/08 18:39:27 damien Exp $ */
/*-
- * Copyright (c) 2006 Damien Bergamini <damien.bergamini@free.fr>
+ * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr>
* Copyright (c) 2005, 2006 Jonathan Gray <jsg@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -286,12 +286,10 @@ nfe_attach(struct device *parent, struct device *self, void *aux)
if (sc->sc_flags & NFE_HW_VLAN)
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
#endif
-#ifdef NFE_CSUM
if (sc->sc_flags & NFE_HW_CSUM) {
ifp->if_capabilities |= IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 |
IFCAP_CSUM_UDPv4;
}
-#endif
sc->sc_mii.mii_ifp = ifp;
sc->sc_mii.mii_readreg = nfe_miibus_readreg;
@@ -755,19 +753,14 @@ nfe_rxeof(struct nfe_softc *sc)
m->m_pkthdr.len = m->m_len = len;
m->m_pkthdr.rcvif = ifp;
-#ifdef notyet
- if (sc->sc_flags & NFE_HW_CSUM) {
- if (flags & NFE_RX_IP_CSUMOK)
- m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK;
+ if ((sc->sc_flags & NFE_HW_CSUM) &&
+ (flags & NFE_RX_IP_CSUMOK)) {
+ m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK;
if (flags & NFE_RX_UDP_CSUMOK)
m->m_pkthdr.csum_flags |= M_UDP_CSUM_IN_OK;
if (flags & NFE_RX_TCP_CSUMOK)
m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK;
}
-#elif defined(NFE_CSUM)
- if ((sc->sc_flags & NFE_HW_CSUM) && (flags & NFE_RX_CSUMOK))
- m->m_pkthdr.csum_flags = M_IPV4_CSUM_IN_OK;
-#endif
#if NBPFILTER > 0
if (ifp->if_bpf)
@@ -911,12 +904,10 @@ nfe_encap(struct nfe_softc *sc, struct mbuf *m0)
vtag = NFE_TX_VTAG | htons(ifv->ifv_tag);
}
#endif
-#ifdef NFE_CSUM
if (m0->m_pkthdr.csum_flags & M_IPV4_CSUM_OUT)
flags |= NFE_TX_IP_CSUM;
if (m0->m_pkthdr.csum_flags & (M_TCPV4_CSUM_OUT | M_UDPV4_CSUM_OUT))
- flags |= NFE_TX_TCP_CSUM;
-#endif
+ flags |= NFE_TX_TCP_UDP_CSUM;
for (i = 0; i < map->dm_nsegs; i++) {
data = &sc->txq.data[sc->txq.cur];
@@ -947,7 +938,7 @@ nfe_encap(struct nfe_softc *sc, struct mbuf *m0)
* Checksum flags and vtag belong to the first fragment
* only.
*/
- flags &= ~(NFE_TX_IP_CSUM | NFE_TX_TCP_CSUM);
+ flags &= ~(NFE_TX_IP_CSUM | NFE_TX_TCP_UDP_CSUM);
#if NVLAN > 0
vtag = 0;
#endif
@@ -1061,10 +1052,8 @@ nfe_init(struct ifnet *ifp)
sc->rxtxctl |= NFE_RXTX_V3MAGIC;
else if (sc->sc_flags & NFE_JUMBO_SUP)
sc->rxtxctl |= NFE_RXTX_V2MAGIC;
-#ifdef NFE_CSUM
if (sc->sc_flags & NFE_HW_CSUM)
sc->rxtxctl |= NFE_RXTX_RXCSUM;
-#endif
#if NVLAN > 0
/*
* Although the adapter is capable of stripping VLAN tags from received
diff --git a/sys/dev/pci/if_nfereg.h b/sys/dev/pci/if_nfereg.h
index 1af8a110d8b..c1516ccece2 100644
--- a/sys/dev/pci/if_nfereg.h
+++ b/sys/dev/pci/if_nfereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nfereg.h,v 1.20 2006/11/15 02:24:37 brad Exp $ */
+/* $OpenBSD: if_nfereg.h,v 1.21 2007/01/08 18:39:27 damien Exp $ */
/*-
* Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
@@ -176,10 +176,12 @@ struct nfe_desc64 {
"\14FORCEDINT\13LASTPACKET\12UNDERFLOW\10LOSTCARRIER\09DEFERRED\02RETRY"
/* flags common to V1/V2 descriptors */
-#define NFE_RX_CSUMOK 0x1c00
+#define NFE_RX_UDP_CSUMOK (1 << 10)
+#define NFE_RX_TCP_CSUMOK (1 << 11)
+#define NFE_RX_IP_CSUMOK (1 << 12)
#define NFE_RX_ERROR (1 << 14)
#define NFE_RX_READY (1 << 15)
-#define NFE_TX_TCP_CSUM (1 << 10)
+#define NFE_TX_TCP_UDP_CSUM (1 << 10)
#define NFE_TX_IP_CSUM (1 << 11)
#define NFE_TX_VALID (1 << 15)