summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2009-09-13 14:42:53 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2009-09-13 14:42:53 +0000
commit72c9514b3fe03e2af58b7386b4ea1b1b8d03bb73 (patch)
treeddd67747f9e94367b396ade568c730dfa795adb5 /sys/dev/ic
parent4eef650080d9b8f29430c67e8bfb02019d822601 (diff)
M_DUP_PKTHDR() define -> m_dup_pkthdr() function to properly deal
with m_tag_copy_chain() failures. Use m_defrag() to eliminate hand rolled defragging of mbufs and some uses of M_DUP_PKTHDR(). Original diff from thib@, claudio@'s feedback integrated by me. Tests kevlo@ claudio@, "reads ok" blambert@ ok thib@ claudio@, "m_defrag() bits ok" kettenis@
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/acx.c32
-rw-r--r--sys/dev/ic/ath.c19
-rw-r--r--sys/dev/ic/bwi.c33
3 files changed, 6 insertions, 78 deletions
diff --git a/sys/dev/ic/acx.c b/sys/dev/ic/acx.c
index 693923cbfa3..2f9fe36b098 100644
--- a/sys/dev/ic/acx.c
+++ b/sys/dev/ic/acx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acx.c,v 1.94 2009/07/28 11:39:52 blambert Exp $ */
+/* $OpenBSD: acx.c,v 1.95 2009/09/13 14:42:52 krw Exp $ */
/*
* Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
@@ -2222,38 +2222,10 @@ acx_encap(struct acx_softc *sc, struct acx_txbuf *txbuf, struct mbuf *m,
if (error) { /* error == EFBIG */
/* too many fragments, linearize */
- struct mbuf *mnew;
-
- error = 0;
-
- MGETHDR(mnew, M_DONTWAIT, MT_DATA);
- if (mnew == NULL) {
- m_freem(m);
- error = ENOBUFS;
+ if (m_defrag(m, M_DONTWAIT)) {
printf("%s: can't defrag tx mbuf\n", ifp->if_xname);
goto back;
}
-
- M_DUP_PKTHDR(mnew, m);
- if (m->m_pkthdr.len > MHLEN) {
- MCLGET(mnew, M_DONTWAIT);
- if (!(mnew->m_flags & M_EXT)) {
- m_freem(m);
- m_freem(mnew);
- error = ENOBUFS;
- }
- }
-
- if (error) {
- printf("%s: can't defrag tx mbuf\n", ifp->if_xname);
- goto back;
- }
-
- m_copydata(m, 0, m->m_pkthdr.len, mtod(mnew, caddr_t));
- m_freem(m);
- mnew->m_len = mnew->m_pkthdr.len;
- m = mnew;
-
error = bus_dmamap_load_mbuf(sc->sc_dmat,
txbuf->tb_mbuf_dmamap, m, BUS_DMA_NOWAIT);
if (error) {
diff --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c
index 20376840e92..9fbd8940ecb 100644
--- a/sys/dev/ic/ath.c
+++ b/sys/dev/ic/ath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ath.c,v 1.82 2009/08/10 20:29:54 deraadt Exp $ */
+/* $OpenBSD: ath.c,v 1.83 2009/09/13 14:42:52 krw Exp $ */
/* $NetBSD: ath.c,v 1.37 2004/08/18 21:59:39 dyoung Exp $ */
/*-
@@ -2135,7 +2135,6 @@ ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni,
int i, error, iswep, hdrlen, pktlen, len, s;
u_int8_t rix, cix, txrate, ctsrate;
struct ath_desc *ds;
- struct mbuf *m;
struct ieee80211_frame *wh;
struct ieee80211_key *k;
u_int32_t iv;
@@ -2238,25 +2237,11 @@ ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni,
*/
if (error == EFBIG) { /* too many desc's, linearize */
sc->sc_stats.ast_tx_linear++;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL) {
- sc->sc_stats.ast_tx_nombuf++;
- m_freem(m0);
- return ENOMEM;
- }
-
- M_DUP_PKTHDR(m, m0);
- MCLGET(m, M_DONTWAIT);
- if ((m->m_flags & M_EXT) == 0) {
+ if (m_defrag(m0, M_DONTWAIT)) {
sc->sc_stats.ast_tx_nomcl++;
m_freem(m0);
- m_free(m);
return ENOMEM;
}
- m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t));
- m_freem(m0);
- m->m_len = m->m_pkthdr.len;
- m0 = m;
error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m0,
BUS_DMA_NOWAIT);
if (error != 0) {
diff --git a/sys/dev/ic/bwi.c b/sys/dev/ic/bwi.c
index 027b20d03ff..b4115985ad8 100644
--- a/sys/dev/ic/bwi.c
+++ b/sys/dev/ic/bwi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bwi.c,v 1.90 2009/08/02 19:33:01 blambert Exp $ */
+/* $OpenBSD: bwi.c,v 1.91 2009/09/13 14:42:52 krw Exp $ */
/*
* Copyright (c) 2007 The DragonFly Project. All rights reserved.
@@ -8849,40 +8849,11 @@ bwi_encap(struct bwi_softc *sc, int idx, struct mbuf *m,
}
if (error) { /* error == EFBIG */
- struct mbuf *m_new;
-
- error = 0;
-
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- m_freem(m);
- error = ENOBUFS;
+ if (m_defrag(m, M_DONTWAIT)) {
printf("%s: can't defrag TX buffer\n",
sc->sc_dev.dv_xname);
goto back;
}
-
- M_DUP_PKTHDR(m_new, m);
- if (m->m_pkthdr.len > MHLEN) {
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- m_freem(m);
- m_freem(m_new);
- error = ENOBUFS;
- }
- }
-
- if (error) {
- printf("%s: can't defrag TX buffer\n",
- sc->sc_dev.dv_xname);
- goto back;
- }
-
- m_copydata(m, 0, m->m_pkthdr.len, mtod(m_new, caddr_t));
- m_freem(m);
- m_new->m_len = m_new->m_pkthdr.len;
- m = m_new;
-
error = bus_dmamap_load_mbuf(sc->sc_dmat, tb->tb_dmap, m,
BUS_DMA_NOWAIT);
if (error) {