diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2015-05-27 22:10:53 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2015-05-27 22:10:53 +0000 |
commit | be6aac3a754a69c2a15b26cde33aaccac2042105 (patch) | |
tree | 9bdd79f7f5dcac0c811e219b0b02fc49e1bb4df1 | |
parent | 63966299c09d84a8b302a8f428eda7958212686c (diff) |
Use m_defrag(9) instead of rolling our own inlined version.
ok mikeb@
-rw-r--r-- | sys/dev/pci/if_ipw.c | 19 | ||||
-rw-r--r-- | sys/dev/pci/if_iwi.c | 19 | ||||
-rw-r--r-- | sys/dev/pci/if_iwn.c | 31 | ||||
-rw-r--r-- | sys/dev/pci/if_wpi.c | 19 |
4 files changed, 14 insertions, 74 deletions
diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index d0305e32f48..496545b731f 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ipw.c,v 1.107 2015/02/10 23:25:46 mpi Exp $ */ +/* $OpenBSD: if_ipw.c,v 1.108 2015/05/27 22:10:52 kettenis Exp $ */ /*- * Copyright (c) 2004-2008 @@ -1143,7 +1143,6 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_frame *wh; struct ieee80211_key *k; - struct mbuf *m1; struct ipw_soft_bd *sbd; struct ipw_soft_hdr *shdr; struct ipw_soft_buf *sbuf; @@ -1208,24 +1207,10 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) } if (error != 0) { /* too many fragments, linearize */ - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { + if (m_defrag(m, M_DONTWAIT)) { m_freem(m); return ENOBUFS; } - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_DONTWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m); - m_freem(m1); - return ENOBUFS; - } - } - m_copydata(m, 0, m->m_pkthdr.len, mtod(m1, caddr_t)); - m1->m_pkthdr.len = m1->m_len = m->m_pkthdr.len; - m_freem(m); - m = m1; - error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, m, BUS_DMA_NOWAIT); if (error != 0) { diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index c9808fd4add..284bd599449 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwi.c,v 1.124 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: if_iwi.c,v 1.125 2015/05/27 22:10:52 kettenis Exp $ */ /*- * Copyright (c) 2004-2008 @@ -1250,7 +1250,6 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_frame *wh; struct ieee80211_key *k; - struct mbuf *m1; struct iwi_tx_data *data; struct iwi_tx_desc *desc; struct iwi_tx_ring *txq = &sc->txq[0]; @@ -1317,24 +1316,10 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni) } if (error != 0) { /* too many fragments, linearize */ - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { + if (m_defrag(m0, M_DONTWAIT)) { m_freem(m0); return ENOBUFS; } - if (m0->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_DONTWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m0); - m_freem(m1); - return ENOBUFS; - } - } - m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m1, caddr_t)); - m1->m_pkthdr.len = m1->m_len = m0->m_pkthdr.len; - m_freem(m0); - m0 = m1; - error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0) { diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index 62c24a65157..41af1eac0fa 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.142 2015/04/08 09:29:49 jasper Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.143 2015/05/27 22:10:52 kettenis Exp $ */ /*- * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr> @@ -2750,7 +2750,6 @@ iwn_tx(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) const struct iwn_rate *rinfo; struct ieee80211_frame *wh; struct ieee80211_key *k = NULL; - struct mbuf *m1; enum ieee80211_edca_ac ac; uint32_t flags; uint16_t qos; @@ -2962,32 +2961,18 @@ iwn_tx(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m, BUS_DMA_NOWAIT | BUS_DMA_WRITE); + if (error != 0 && error != EFBIG) { + printf("%s: can't map mbuf (error %d)\n", + sc->sc_dev.dv_xname, error); + m_freem(m); + return error; + } if (error != 0) { - if (error != EFBIG) { - printf("%s: can't map mbuf (error %d)\n", - sc->sc_dev.dv_xname, error); - m_freem(m); - return error; - } /* Too many DMA segments, linearize mbuf. */ - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { + if (m_defrag(m, M_DONTWAIT)) { m_freem(m); return ENOBUFS; } - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_DONTWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m); - m_freem(m1); - return ENOBUFS; - } - } - m_copydata(m, 0, m->m_pkthdr.len, mtod(m1, caddr_t)); - m1->m_pkthdr.len = m1->m_len = m->m_pkthdr.len; - m_freem(m); - m = m1; - error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m, BUS_DMA_NOWAIT | BUS_DMA_WRITE); if (error != 0) { diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index 7d838c60249..dce2e1e7b8b 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpi.c,v 1.126 2015/03/16 04:09:53 jsg Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.127 2015/05/27 22:10:52 kettenis Exp $ */ /*- * Copyright (c) 2006-2008 @@ -1655,7 +1655,6 @@ wpi_tx(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni) const struct wpi_rate *rinfo; struct ieee80211_frame *wh; struct ieee80211_key *k = NULL; - struct mbuf *m1; enum ieee80211_edca_ac ac; uint32_t flags; uint16_t qos; @@ -1833,24 +1832,10 @@ wpi_tx(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni) } if (error != 0) { /* Too many DMA segments, linearize mbuf. */ - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { + if (m_defrag(m, M_DONTWAIT)) { m_freem(m); return ENOBUFS; } - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_DONTWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m); - m_freem(m1); - return ENOBUFS; - } - } - m_copydata(m, 0, m->m_pkthdr.len, mtod(m1, caddr_t)); - m1->m_pkthdr.len = m1->m_len = m->m_pkthdr.len; - m_freem(m); - m = m1; - error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m, BUS_DMA_NOWAIT | BUS_DMA_WRITE); if (error != 0) { |