summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorheas <heas@NetBSD.org>2005-02-18 01:21:02 +0000
committerheas <heas@NetBSD.org>2005-02-18 01:21:02 +0000
commitf5a6c8bf2f8444a08b4dc7ff4b771b2e9e64aa3f (patch)
tree931f896e2d98ccc858e389416197a636e186c6fa /sys/dev
parentd6e174eefd7872196188889165bc0082ec405d9d (diff)
Adjust csum_data usage; mask off the high 16 bits for L4 header stuff offset
and make use of the L3 header length from the high 16 bits such that an m_pullup is no londer necessary.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_dge.c23
-rw-r--r--sys/dev/pci/if_wm.c44
2 files changed, 10 insertions, 57 deletions
diff --git a/sys/dev/pci/if_dge.c b/sys/dev/pci/if_dge.c
index 65e73476f60..122a8eb62f7 100644
--- a/sys/dev/pci/if_dge.c
+++ b/sys/dev/pci/if_dge.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_dge.c,v 1.7 2004/10/30 18:09:22 thorpej Exp $ */
+/* $NetBSD: if_dge.c,v 1.8 2005/02/18 01:21:02 heas Exp $ */
/*
* Copyright (c) 2004, SUNET, Swedish University Computer Network.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.7 2004/10/30 18:09:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.8 2005/02/18 01:21:02 heas Exp $");
#include "bpfilter.h"
#include "rnd.h"
@@ -1024,7 +1024,6 @@ dge_tx_cksum(struct dge_softc *sc, struct dge_txsoft *txs, uint8_t *fieldsp)
struct mbuf *m0 = txs->txs_mbuf;
struct dge_ctdes *t;
uint32_t ipcs, tucs;
- struct ip *ip;
struct ether_header *eh;
int offset, iphl;
uint8_t fields = 0;
@@ -1037,12 +1036,10 @@ dge_tx_cksum(struct dge_softc *sc, struct dge_txsoft *txs, uint8_t *fieldsp)
eh = mtod(m0, struct ether_header *);
switch (htons(eh->ether_type)) {
case ETHERTYPE_IP:
- iphl = sizeof(struct ip);
offset = ETHER_HDR_LEN;
break;
case ETHERTYPE_VLAN:
- iphl = sizeof(struct ip);
offset = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
break;
@@ -1054,17 +1051,7 @@ dge_tx_cksum(struct dge_softc *sc, struct dge_txsoft *txs, uint8_t *fieldsp)
return (0);
}
- if (m0->m_len < (offset + iphl)) {
- if ((txs->txs_mbuf = m_pullup(m0, offset + iphl)) == NULL) {
- printf("%s: dge_tx_cksum: mbuf allocation failed, "
- "packet dropped\n", sc->sc_dev.dv_xname);
- return (ENOMEM);
- }
- m0 = txs->txs_mbuf;
- }
-
- ip = (struct ip *) (mtod(m0, caddr_t) + offset);
- iphl = ip->ip_hl << 2;
+ iphl = m0->m_pkthdr.csum_data >> 16;
/*
* NOTE: Even if we're not using the IP or TCP/UDP checksum
@@ -1097,8 +1084,8 @@ dge_tx_cksum(struct dge_softc *sc, struct dge_txsoft *txs, uint8_t *fieldsp)
DGE_EVCNT_INCR(&sc->sc_ev_txtusum);
fields |= TDESC_POPTS_TXSM;
tucs = DGE_TCPIP_TUCSS(offset) |
- DGE_TCPIP_TUCSO(offset + m0->m_pkthdr.csum_data) |
- DGE_TCPIP_TUCSE(0) /* rest of packet */;
+ DGE_TCPIP_TUCSO(offset + (m0->m_pkthdr.csum_data & 0xffff)) |
+ DGE_TCPIP_TUCSE(0) /* rest of packet */;
} else if (__predict_true(sc->sc_txctx_tucs != 0xffffffff)) {
/* Use the cached value. */
tucs = sc->sc_txctx_tucs;
diff --git a/sys/dev/pci/if_wm.c b/sys/dev/pci/if_wm.c
index 4f279eecf4b..a5e7dfcbf0f 100644
--- a/sys/dev/pci/if_wm.c
+++ b/sys/dev/pci/if_wm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.90 2005/01/30 17:33:48 thorpej Exp $ */
+/* $NetBSD: if_wm.c,v 1.91 2005/02/18 01:21:02 heas Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.90 2005/01/30 17:33:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.91 2005/02/18 01:21:02 heas Exp $");
#include "bpfilter.h"
#include "rnd.h"
@@ -1350,7 +1350,6 @@ wm_tx_offload(struct wm_softc *sc, struct wm_txsoft *txs, uint32_t *cmdp,
struct mbuf *m0 = txs->txs_mbuf;
struct livengood_tcpip_ctxdesc *t;
uint32_t ipcs, tucs;
- struct ip *ip;
struct ether_header *eh;
int offset, iphl;
uint8_t fields = 0;
@@ -1363,12 +1362,10 @@ wm_tx_offload(struct wm_softc *sc, struct wm_txsoft *txs, uint32_t *cmdp,
eh = mtod(m0, struct ether_header *);
switch (htons(eh->ether_type)) {
case ETHERTYPE_IP:
- iphl = sizeof(struct ip);
offset = ETHER_HDR_LEN;
break;
case ETHERTYPE_VLAN:
- iphl = sizeof(struct ip);
offset = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
break;
@@ -1381,38 +1378,7 @@ wm_tx_offload(struct wm_softc *sc, struct wm_txsoft *txs, uint32_t *cmdp,
return (0);
}
- if (m0->m_len < (offset + iphl)) {
- /*
- * Packet headers aren't in the first mbuf. Let's hope
- * there is space at the end if it for them.
- */
- WM_EVCNT_INCR(&sc->sc_ev_txpullup_needed);
- if ((txs->txs_mbuf = m_pullup(m0, offset + iphl)) == NULL) {
- WM_EVCNT_INCR(&sc->sc_ev_txpullup_nomem);
- log(LOG_ERR,
- "%s: wm_tx_offload: mbuf allocation failed, "
- "packet dropped\n", sc->sc_dev.dv_xname);
- return (ENOMEM);
- } else if (m0 != txs->txs_mbuf) {
- /*
- * The DMA map has already been loaded, so we
- * would have to unload and reload it. But then
- * if that were to fail, we are already committed
- * to transmitting the packet (can't put it back
- * on the queue), so we have to drop the packet.
- */
- WM_EVCNT_INCR(&sc->sc_ev_txpullup_fail);
- log(LOG_ERR, "%s: wm_tx_offload: packet headers did "
- "not fit in first mbuf, packet dropped\n",
- sc->sc_dev.dv_xname);
- m_freem(txs->txs_mbuf);
- txs->txs_mbuf = NULL;
- return (EINVAL);
- }
- }
-
- ip = (struct ip *) (mtod(m0, caddr_t) + offset);
- iphl = ip->ip_hl << 2;
+ iphl = m0->m_pkthdr.csum_data >> 16;
/*
* NOTE: Even if we're not using the IP or TCP/UDP checksum
@@ -1434,8 +1400,8 @@ wm_tx_offload(struct wm_softc *sc, struct wm_txsoft *txs, uint32_t *cmdp,
WM_EVCNT_INCR(&sc->sc_ev_txtusum);
fields |= WTX_TXSM;
tucs = WTX_TCPIP_TUCSS(offset) |
- WTX_TCPIP_TUCSO(offset + m0->m_pkthdr.csum_data) |
- WTX_TCPIP_TUCSE(0) /* rest of packet */;
+ WTX_TCPIP_TUCSO(offset + (m0->m_pkthdr.csum_data & 0xffff)) |
+ WTX_TCPIP_TUCSE(0) /* rest of packet */;
} else {
/* Just initialize it to a valid TCP context. */
tucs = WTX_TCPIP_TUCSS(offset) |