Date: Tue, 7 Nov 2006 05:24:48 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 109417 for review Message-ID: <200611070524.kA75OmFw040648@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=109417 Change 109417 by sam@sam_ebb on 2006/11/07 05:24:12 replace m_defrag with private code for a small speedup Affected files ... .. //depot/projects/arm/src/sys/arm/xscale/ixp425/if_npe.c#8 edit Differences ... ==== //depot/projects/arm/src/sys/arm/xscale/ixp425/if_npe.c#8 (text+ko) ==== @@ -982,6 +982,29 @@ NPE_UNLOCK(sc); } +static struct mbuf * +npe_linearize(struct mbuf *m0, int how) +{ + struct mbuf *m, *n; + + if (m0->m_pkthdr.len > MHLEN) + n = m_getcl(how, MT_DATA, M_PKTHDR); + else + n = m_gethdr(how, MT_DATA); + if (n != NULL) { + n->m_len = 0; /* NB: not initialized on alloc */ + for (m = m0; m != NULL; m = m->m_next) { + bcopy(mtod(m, void *), mtod(n, char *) + n->m_len, + m->m_len); + n->m_len += m->m_len; + } + /* NB: this works because we never change m_final->m_data */ + m_move_pkthdr(n, m0); + } + m_freem(m0); + return n; +} + /* * dequeu packets and transmit */ @@ -990,7 +1013,7 @@ { struct npe_softc *sc = ifp->if_softc; struct npebuf *npe; - struct mbuf *m, *mdefrag; + struct mbuf *m; struct npedma *dma = &sc->txdma; bus_dma_segment_t segs[1]; int nseg, len; @@ -1007,16 +1030,14 @@ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; return; } - mdefrag = m_defrag(m, M_DONTWAIT); - if (mdefrag == NULL) { - /* XXX not a good idea */ - IFQ_DRV_PREPEND(&ifp->if_snd, m); - return; + npe = sc->tx_free; + if (m->m_next != NULL) { + m = npe_linearize(m, M_DONTWAIT); + if (m == NULL) + return; } - m = mdefrag; - npe = sc->tx_free; - if (bus_dmamap_load_mbuf_sg(dma->mtag, npe->ix_map, m, - segs, &nseg, 0) != 0) { + if (bus_dmamap_load_mbuf_sg(dma->mtag, npe->ix_map, + m, segs, &nseg, 0) != 0) { m_freem(m); continue; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611070524.kA75OmFw040648>