PERFORCE change 109084 for review

Warner Losh imp at FreeBSD.org
Fri Nov 3 00:20:28 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=109084

Change 109084 by imp at imp_lighthouse on 2006/11/03 00:19:45

	Avoid a copy and alloc/free pair when there's only one mbuf.
	
	Suggested by:	scottl@, sam@

Affected files ...

.. //depot/projects/arm/src/sys/arm/at91/if_ate.c#60 edit

Differences ...

==== //depot/projects/arm/src/sys/arm/at91/if_ate.c#60 (text+ko) ====

@@ -778,7 +778,7 @@
 	struct ate_softc *sc = ifp->if_softc;
 	struct mbuf *m, *mdefrag;
 	bus_dma_segment_t segs[1];
-	int nseg;
+	int nseg, e;
 
 	ATE_ASSERT_LOCKED(sc);
 	if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
@@ -800,14 +800,19 @@
 			ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 			return;
 		}
-		mdefrag = m_defrag(m, M_DONTWAIT);
-		if (mdefrag == NULL) {
-			IFQ_DRV_PREPEND(&ifp->if_snd, m);
-			return;
+		e = bus_dmamap_load_mbuf_sg(sc->mtag, sc->tx_map[sc->txcur], m,
+		    segs, &nseg, 0);
+		if (e == EFBIG) {
+			mdefrag = m_defrag(m, M_DONTWAIT);
+			if (mdefrag == NULL) {
+				IFQ_DRV_PREPEND(&ifp->if_snd, m);
+				return;
+			}
+			m = mdefrag;
+			e = bus_dmamap_load_mbuf_sg(sc->mtag,
+			    sc->tx_map[sc->txcur], m, segs, &nseg, 0);
 		}
-		m = mdefrag;
-		if (bus_dmamap_load_mbuf_sg(sc->mtag, sc->tx_map[sc->txcur], m,
-		    segs, &nseg, 0) != 0) {
+		if (e == EFBIG) {
 			m_freem(m);
 			continue;
 		}


More information about the p4-projects mailing list