diff options
-rw-r--r-- | sys/dev/ic/rt2560.c | 21 | ||||
-rw-r--r-- | sys/dev/ic/rt2661.c | 21 | ||||
-rw-r--r-- | sys/dev/ic/rt2860.c | 19 | ||||
-rw-r--r-- | sys/dev/pci/if_ipw.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/if_iwi.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/if_iwn.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/if_wpi.c | 21 |
7 files changed, 125 insertions, 20 deletions
diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c index 4981fc06a59..e24147275e5 100644 --- a/sys/dev/ic/rt2560.c +++ b/sys/dev/ic/rt2560.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2560.c,v 1.40 2008/11/25 21:43:57 damien Exp $ */ +/* $OpenBSD: rt2560.c,v 1.41 2008/12/21 18:19:58 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -1699,6 +1699,7 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0, struct rt2560_tx_data *data; struct ieee80211_frame *wh; struct ieee80211_key *k; + struct mbuf *m1; uint16_t dur; uint32_t flags = 0; int pktlen, rate, needcts = 0, needrts = 0, error; @@ -1827,10 +1828,24 @@ rt2560_tx_data(struct rt2560_softc *sc, struct mbuf *m0, } if (error != 0) { /* too many fragments, linearize */ - if (m_defrag(m0, M_DONTWAIT) != 0) { + MGETHDR(m1, MT_DATA, M_DONTWAIT); + if (m1 == NULL) { m_freem(m0); - return ENOMEM; + 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/ic/rt2661.c b/sys/dev/ic/rt2661.c index c22fd40b010..b146edefd82 100644 --- a/sys/dev/ic/rt2661.c +++ b/sys/dev/ic/rt2661.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2661.c,v 1.45 2008/11/25 21:43:57 damien Exp $ */ +/* $OpenBSD: rt2661.c,v 1.46 2008/12/21 18:19:58 damien Exp $ */ /*- * Copyright (c) 2006 @@ -1546,6 +1546,7 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0, struct rt2661_tx_data *data; struct ieee80211_frame *wh; struct ieee80211_key *k; + struct mbuf *m1; uint16_t dur; uint32_t flags = 0; int pktlen, rate, needcts = 0, needrts = 0, error; @@ -1671,10 +1672,24 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0, } if (error != 0) { /* too many fragments, linearize */ - if (m_defrag(m0, M_DONTWAIT) != 0) { + MGETHDR(m1, MT_DATA, M_DONTWAIT); + if (m1 == NULL) { m_freem(m0); - return ENOMEM; + 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/ic/rt2860.c b/sys/dev/ic/rt2860.c index e15cb41e7ec..a9b17915a59 100644 --- a/sys/dev/ic/rt2860.c +++ b/sys/dev/ic/rt2860.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2860.c,v 1.27 2008/12/15 18:35:59 damien Exp $ */ +/* $OpenBSD: rt2860.c,v 1.28 2008/12/21 18:19:58 damien Exp $ */ /*- * Copyright (c) 2007, 2008 @@ -1356,6 +1356,7 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni) struct rt2860_txd *txd; struct rt2860_txwi *txwi; struct ieee80211_frame *wh; + struct mbuf *m1; bus_dma_segment_t *seg; u_int hdrlen; uint16_t qos, dur; @@ -1500,10 +1501,24 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni) } if (__predict_false(error != 0)) { /* too many fragments, linearize */ - if (m_defrag(m, M_DONTWAIT) != 0) { + MGETHDR(m1, MT_DATA, M_DONTWAIT); + if (m1 == NULL) { 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); if (__predict_false(error != 0)) { diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index 3df6e44fd83..45c7b33b141 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.81 2008/11/25 21:43:57 damien Exp $ */ +/* $OpenBSD: if_ipw.c,v 1.82 2008/12/21 18:19:58 damien Exp $ */ /*- * Copyright (c) 2004-2008 @@ -1127,6 +1127,7 @@ 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; @@ -1191,10 +1192,24 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) } if (error != 0) { /* too many fragments, linearize */ - if (m_defrag(m, M_DONTWAIT) != 0) { + MGETHDR(m1, MT_DATA, M_DONTWAIT); + if (m1 == NULL) { m_freem(m); - return ENOMEM; + 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 c77a4073bb5..c6d9986a66a 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.96 2008/11/25 22:20:11 damien Exp $ */ +/* $OpenBSD: if_iwi.c,v 1.97 2008/12/21 18:19:58 damien Exp $ */ /*- * Copyright (c) 2004-2008 @@ -1233,6 +1233,7 @@ 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]; @@ -1299,10 +1300,24 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni) } if (error != 0) { /* too many fragments, linearize */ - if (m_defrag(m0, M_DONTWAIT) != 0) { + MGETHDR(m1, MT_DATA, M_DONTWAIT); + if (m1 == NULL) { m_freem(m0); - return ENOMEM; + 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 15f69c1df23..e7f8a44b7a8 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.43 2008/12/12 17:15:40 damien Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.44 2008/12/21 18:19:58 damien Exp $ */ /*- * Copyright (c) 2007, 2008 @@ -2363,6 +2363,7 @@ 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; @@ -2582,10 +2583,24 @@ iwn_tx(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) } if (error != 0) { /* Too many DMA segments, linearize mbuf. */ - if (m_defrag(m, M_DONTWAIT) != 0) { + MGETHDR(m1, MT_DATA, M_DONTWAIT); + if (m1 == NULL) { m_freem(m); - return ENOMEM; + 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); if (error != 0) { diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index 561714f1599..3fed5f6112e 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.78 2008/12/03 17:17:08 damien Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.79 2008/12/21 18:19:58 damien Exp $ */ /*- * Copyright (c) 2006-2008 @@ -1687,6 +1687,7 @@ 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; @@ -1865,10 +1866,24 @@ wpi_tx(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni) } if (error != 0) { /* Too many DMA segments, linearize mbuf. */ - if (m_defrag(m, M_DONTWAIT) != 0) { + MGETHDR(m1, MT_DATA, M_DONTWAIT); + if (m1 == NULL) { m_freem(m); - return ENOMEM; + 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); if (error != 0) { |