summaryrefslogtreecommitdiffstats
path: root/sys/dev/ath/if_ath.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2008-01-17 21:25:09 +0000
committersam <sam@FreeBSD.org>2008-01-17 21:25:09 +0000
commite443f3b38cccc13a328e71f3311f30fedf9dbaf2 (patch)
tree08d1ba96d0307c83ac3232beee589e8446489976 /sys/dev/ath/if_ath.c
parentd51108b354a4cdd86fafecdde80002b5b6bb4d83 (diff)
downloadFreeBSD-src-e443f3b38cccc13a328e71f3311f30fedf9dbaf2.zip
FreeBSD-src-e443f3b38cccc13a328e71f3311f30fedf9dbaf2.tar.gz
promote ath_defrag to m_collapse (and retire private+unused
m_collapse from cxgb) Reviewed by: pyun, jhb, kmacy MFC after: 2 weeks
Diffstat (limited to 'sys/dev/ath/if_ath.c')
-rw-r--r--sys/dev/ath/if_ath.c86
1 files changed, 1 insertions, 85 deletions
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index 3f74add..1e30474 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -3892,90 +3892,6 @@ ath_tx_cleanup(struct ath_softc *sc)
}
/*
- * Defragment an mbuf chain, returning at most maxfrags separate
- * mbufs+clusters. If this is not possible NULL is returned and
- * the original mbuf chain is left in it's present (potentially
- * modified) state. We use two techniques: collapsing consecutive
- * mbufs and replacing consecutive mbufs by a cluster.
- */
-static struct mbuf *
-ath_defrag(struct mbuf *m0, int how, int maxfrags)
-{
- struct mbuf *m, *n, *n2, **prev;
- u_int curfrags;
-
- /*
- * Calculate the current number of frags.
- */
- curfrags = 0;
- for (m = m0; m != NULL; m = m->m_next)
- curfrags++;
- /*
- * First, try to collapse mbufs. Note that we always collapse
- * towards the front so we don't need to deal with moving the
- * pkthdr. This may be suboptimal if the first mbuf has much
- * less data than the following.
- */
- m = m0;
-again:
- for (;;) {
- n = m->m_next;
- if (n == NULL)
- break;
- if ((m->m_flags & M_RDONLY) == 0 &&
- n->m_len < M_TRAILINGSPACE(m)) {
- bcopy(mtod(n, void *), mtod(m, char *) + m->m_len,
- n->m_len);
- m->m_len += n->m_len;
- m->m_next = n->m_next;
- m_free(n);
- if (--curfrags <= maxfrags)
- return m0;
- } else
- m = n;
- }
- KASSERT(maxfrags > 1,
- ("maxfrags %u, but normal collapse failed", maxfrags));
- /*
- * Collapse consecutive mbufs to a cluster.
- */
- prev = &m0->m_next; /* NB: not the first mbuf */
- while ((n = *prev) != NULL) {
- if ((n2 = n->m_next) != NULL &&
- n->m_len + n2->m_len < MCLBYTES) {
- m = m_getcl(how, MT_DATA, 0);
- if (m == NULL)
- goto bad;
- bcopy(mtod(n, void *), mtod(m, void *), n->m_len);
- bcopy(mtod(n2, void *), mtod(m, char *) + n->m_len,
- n2->m_len);
- m->m_len = n->m_len + n2->m_len;
- m->m_next = n2->m_next;
- *prev = m;
- m_free(n);
- m_free(n2);
- if (--curfrags <= maxfrags) /* +1 cl -2 mbufs */
- return m0;
- /*
- * Still not there, try the normal collapse
- * again before we allocate another cluster.
- */
- goto again;
- }
- prev = &n->m_next;
- }
- /*
- * No place where we can collapse to a cluster; punt.
- * This can occur if, for example, you request 2 frags
- * but the packet requires that both be clusters (we
- * never reallocate the first mbuf to avoid moving the
- * packet header).
- */
-bad:
- return NULL;
-}
-
-/*
* Return h/w rate index for an IEEE rate (w/o basic rate bit).
*/
static int
@@ -4033,7 +3949,7 @@ ath_tx_dmasetup(struct ath_softc *sc, struct ath_buf *bf, struct mbuf *m0)
*/
if (bf->bf_nseg > ATH_TXDESC) { /* too many desc's, linearize */
sc->sc_stats.ast_tx_linear++;
- m = ath_defrag(m0, M_DONTWAIT, ATH_TXDESC);
+ m = m_collapse(m0, M_DONTWAIT, ATH_TXDESC);
if (m == NULL) {
ath_freetx(m0);
sc->sc_stats.ast_tx_nombuf++;
OpenPOWER on IntegriCloud