summaryrefslogtreecommitdiff
path: root/sys/dev/ic/bwi.c
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/bwi.c
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/bwi.c')
-rw-r--r--sys/dev/ic/bwi.c33
1 files changed, 2 insertions, 31 deletions
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) {