From owner-p4-projects@FreeBSD.ORG Sun Mar 13 18:36:02 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5E64516A4DF; Sun, 13 Mar 2005 18:36:02 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1833D16A4D7 for ; Sun, 13 Mar 2005 18:36:02 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A090C43D46 for ; Sun, 13 Mar 2005 18:36:01 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j2DIa101071464 for ; Sun, 13 Mar 2005 18:36:01 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j2DIa196071461 for perforce@freebsd.org; Sun, 13 Mar 2005 18:36:01 GMT (envelope-from sam@freebsd.org) Date: Sun, 13 Mar 2005 18:36:01 GMT Message-Id: <200503131836.j2DIa196071461@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 73025 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Mar 2005 18:36:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=73025 Change 73025 by sam@sam_ebb on 2005/03/13 18:35:34 o check for rdonly mbuf's when coalescing o save stats+test stuff since this is a private branch Affected files ... .. //depot/projects/wifi/sys/dev/ath/if_ath.c#76 edit Differences ... ==== //depot/projects/wifi/sys/dev/ath/if_ath.c#76 (text+ko) ==== @@ -3269,6 +3269,18 @@ ath_tx_cleanupq(sc, &sc->sc_txq[i]); } +SYSCTL_NODE(_hw_ath, OID_AUTO, defrag, CTLFLAG_RD, 0, "defrag testing"); +static int ath_maxfrags = 4; +SYSCTL_INT(_hw_ath_defrag, OID_AUTO, max, CTLFLAG_RW, &ath_maxfrags, 0, ""); +static int ath_defrags; +SYSCTL_INT(_hw_ath_defrag, OID_AUTO, calls, CTLFLAG_RW, &ath_defrags, 0, ""); +static int ath_collectedfrags; +SYSCTL_INT(_hw_ath_defrag, OID_AUTO, combined, CTLFLAG_RW, &ath_collectedfrags, 0, ""); +static int ath_replacedfrags; +SYSCTL_INT(_hw_ath_defrag, OID_AUTO, replaced, CTLFLAG_RW, &ath_replacedfrags, 0, ""); +static int ath_defragsfail; +SYSCTL_INT(_hw_ath_defrag, OID_AUTO, fail, CTLFLAG_RW, &ath_defragsfail, 0, ""); + /* * Defragment an mbuf chain, returning at most maxfrags separate * mbufs+clusters. If this is not possible NULL is returned and @@ -3282,12 +3294,14 @@ struct mbuf *m, *n, *n2, **prev; u_int curfrags; +ath_defrags++;/*XXX*/ /* * Calculate the current number of frags. */ curfrags = 0; for (m = m0; m != NULL; m = m->m_next) curfrags++; +if (curfrags <= maxfrags) return m0; /* XXX for testing */ /* * First, try to collapse mbufs. Note that we always collapse * towards the front so we don't need to deal with moving the @@ -3300,12 +3314,14 @@ n = m->m_next; if (n == NULL) break; - if (n->m_len < M_TRAILINGSPACE(m)) { + 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); +ath_collectedfrags++;/*XXX*/ if (--curfrags <= maxfrags) return m0; } else @@ -3331,6 +3347,7 @@ *prev = m; m_free(n); m_free(n2); +ath_replacedfrags++;/*XXX*/ if (--curfrags <= maxfrags) /* +1 cl -2 mbufs */ return m0; /* @@ -3349,6 +3366,7 @@ * packet header). */ bad: +ath_defragsfail++;/*XXX*/ return NULL; } @@ -3423,6 +3441,8 @@ pktlen += IEEE80211_CRC_LEN; +m = ath_defrag(m0, M_DONTWAIT, ath_maxfrags); if (m != NULL) m0 = m; /*XXX*/ + /* * Load the DMA map so any coalescing is done. This * also calculates the number of descriptors we need.