diff options
author | avos <avos@FreeBSD.org> | 2016-01-03 21:32:47 +0000 |
---|---|---|
committer | avos <avos@FreeBSD.org> | 2016-01-03 21:32:47 +0000 |
commit | 50c750b01e8aac78f09263477269a8717979876c (patch) | |
tree | b0c82d31dc379e1a0931af75d3d2f7b69a1aaf50 /sys/dev/iwm/if_iwm.c | |
parent | 00310b91de6e5683b28a346b8b2a4bb00600c770 (diff) | |
download | FreeBSD-src-50c750b01e8aac78f09263477269a8717979876c.zip FreeBSD-src-50c750b01e8aac78f09263477269a8717979876c.tar.gz |
iwm: use m_collapse() to defragment a mbuf chain
- Simplify defragmentation code.
- Use proper number of dma segments for data.
Approved by: adrian (mentor)
Obtained from: DragonFlyBSD (mostly)
Differential Revision: https://reviews.freebsd.org/D4754
Diffstat (limited to 'sys/dev/iwm/if_iwm.c')
-rw-r--r-- | sys/dev/iwm/if_iwm.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index 874921f..73cccd9 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -956,7 +956,7 @@ iwm_alloc_tx_ring(struct iwm_softc *sc, struct iwm_tx_ring *ring, int qid) error = bus_dma_tag_create(sc->sc_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, - IWM_MAX_SCATTER - 1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); + IWM_MAX_SCATTER - 2, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); if (error != 0) { device_printf(sc->sc_dev, "could not create TX buf DMA tag\n"); goto fail; @@ -2778,23 +2778,15 @@ iwm_tx(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni, int ac) return error; } /* Too many DMA segments, linearize mbuf. */ - MGETHDR(m1, M_NOWAIT, MT_DATA); + m1 = m_collapse(m, M_NOWAIT, IWM_MAX_SCATTER - 2); if (m1 == NULL) { + device_printf(sc->sc_dev, + "%s: could not defrag mbuf\n", __func__); m_freem(m); - return ENOBUFS; - } - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_NOWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m); - m_freem(m1); - return ENOBUFS; - } + return (ENOBUFS); } - m_copydata(m, 0, m->m_pkthdr.len, mtod(m1, void *)); - m1->m_pkthdr.len = m1->m_len = m->m_pkthdr.len; - m_freem(m); m = m1; + error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m, segs, &nsegs, BUS_DMA_NOWAIT); if (error != 0) { |