From owner-svn-src-user@FreeBSD.ORG Sun Aug 7 13:17:36 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40B88106564A; Sun, 7 Aug 2011 13:17:36 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 30B948FC08; Sun, 7 Aug 2011 13:17:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p77DHa8V002097; Sun, 7 Aug 2011 13:17:36 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p77DHaQ4002094; Sun, 7 Aug 2011 13:17:36 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108071317.p77DHaQ4002094@svn.freebsd.org> From: Adrian Chadd Date: Sun, 7 Aug 2011 13:17:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224692 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Aug 2011 13:17:36 -0000 Author: adrian Date: Sun Aug 7 13:17:35 2011 New Revision: 224692 URL: http://svn.freebsd.org/changeset/base/224692 Log: Fix a subtle race condition in addba setup - make sure the net80211 addba state is updated before the TID is unpaused, or some frames may get queued as normal when they should get queued as aggregate. This completely breaks the BAW tracking. Add some further debugging to expose race conditions. Flesh out some other, currently unused stuff. This finally(!) makes BAW tracking work and has eliminated the last obvious race conditions. It works until the first interface reset (where buffers are flushed w/out updating the BAW), or addba session teardown. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h Sun Aug 7 08:42:36 2011 (r224691) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h Sun Aug 7 13:17:35 2011 (r224692) @@ -57,8 +57,9 @@ enum { ATH_DEBUG_TDMA = 0x00800000, /* TDMA processing */ ATH_DEBUG_TDMA_TIMER = 0x01000000, /* TDMA timer processing */ ATH_DEBUG_REGDOMAIN = 0x02000000, /* regulatory processing */ - ATH_DEBUG_SW_TX = 0x04000000, - ATH_DEBUG_SW_TX_BAW = 0x08000000, + ATH_DEBUG_SW_TX = 0x04000000, /* per-packet software TX */ + ATH_DEBUG_SW_TX_BAW = 0x08000000, /* BAW handling */ + ATH_DEBUG_SW_TX_CTRL = 0x10000000, /* queue control */ ATH_DEBUG_FATAL = 0x80000000, /* fatal errors */ ATH_DEBUG_ANY = 0xffffffff }; Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 7 08:42:36 2011 (r224691) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 7 13:17:35 2011 (r224692) @@ -1748,6 +1748,8 @@ ath_tx_tid_pause(struct ath_softc *sc, s ATH_TXQ_LOCK_ASSERT(txq); tid->paused++; + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: paused = %d\n", + __func__, tid->paused); } static void @@ -1758,6 +1760,8 @@ ath_tx_tid_resume(struct ath_softc *sc, ATH_TXQ_LOCK_ASSERT(txq); tid->paused--; + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: unpaused = %d\n", + __func__, tid->paused); if (tid->paused) return; if (tid->axq_depth == 0) @@ -1884,6 +1888,28 @@ ath_tx_tid_cleanup(struct ath_softc *sc, } } +#ifdef notyet +/* + * Handle completion of non-aggregate frames. + */ +static void +ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf) +{ + struct ieee80211_node *ni = bf->bf_node; + struct ath_node *an; + struct ath_tid *atid; + int tid; + + if (ni != NULL) { + tid = bf->bf_state.bfs_tid; + an = ATH_NODE(ni); + atid = &an->an_tid[tid]; + + ath_tx_default_comp(sc, bf); + } +} +#endif + /* * Handle completion of aggregate frames. */ @@ -1996,6 +2022,14 @@ ath_tx_tid_hw_queue_norm(struct ath_soft struct ath_txq *txq; struct ath_tid *atid = &an->an_tid[tid]; + /* Check - is AMPDU pending or running? then print out something */ + if (ath_tx_ampdu_pending(sc, an, tid)) + device_printf(sc->sc_dev, "%s: tid=%d, ampdu pending?\n", + __func__, tid); + if (ath_tx_ampdu_running(sc, an, tid)) + device_printf(sc->sc_dev, "%s: tid=%d, ampdu running?\n", + __func__, tid); + for (;;) { bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { @@ -2133,6 +2167,7 @@ ath_addba_request(struct ieee80211_node struct ath_tid *atid = &an->an_tid[tid]; ATH_TXQ_LOCK(sc->sc_ac2q[tap->txa_ac]); + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); ath_tx_tid_pause(sc, atid); ATH_TXQ_UNLOCK(sc->sc_ac2q[tap->txa_ac]); @@ -2150,17 +2185,27 @@ ath_addba_request(struct ieee80211_node */ int ath_addba_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, - int dialogtoken, int code, int batimeout) + int status, int code, int batimeout) { struct ath_softc *sc = ni->ni_ic->ic_ifp->if_softc; int tid = WME_AC_TO_TID(tap->txa_ac); struct ath_node *an = ATH_NODE(ni); struct ath_tid *atid = &an->an_tid[tid]; + int r; + + /* + * Call this first, so the interface flags get updated + * before the TID is unpaused. Otherwise a race condition + * exists where the unpaused TID still doesn't yet have + * IEEE80211_AGGR_RUNNING set. + */ + r = sc->sc_addba_response(ni, tap, status, code, batimeout); ATH_TXQ_LOCK(sc->sc_ac2q[tap->txa_ac]); + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); ath_tx_tid_resume(sc, atid); ATH_TXQ_UNLOCK(sc->sc_ac2q[tap->txa_ac]); - return sc->sc_addba_response(ni, tap, dialogtoken, code, batimeout); + return r; } @@ -2180,6 +2225,6 @@ ath_addba_stop(struct ieee80211_node *ni struct ath_node *an = ATH_NODE(ni); struct ath_tid *atid = an->an_tid[tid]; #endif - + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); sc->sc_addba_stop(ni, tap); } From owner-svn-src-user@FreeBSD.ORG Mon Aug 8 11:33:08 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E25241065675; Mon, 8 Aug 2011 11:33:07 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C760A8FC15; Mon, 8 Aug 2011 11:33:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p78BX7io045577; Mon, 8 Aug 2011 11:33:07 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p78BX7uA045575; Mon, 8 Aug 2011 11:33:07 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108081133.p78BX7uA045575@svn.freebsd.org> From: Adrian Chadd Date: Mon, 8 Aug 2011 11:33:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224705 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2011 11:33:08 -0000 Author: adrian Date: Mon Aug 8 11:33:07 2011 New Revision: 224705 URL: http://svn.freebsd.org/changeset/base/224705 Log: Find another panic - this time, TID=16 traffic that occured with aggregation enabled * add some more debugging * absolutely, positively ensure that IEEE80211_NONQOS_TID TIDs never get assigned an aggregation session And to fix the actual issue: * recycling ath_buf's wasn't involving a bzero() to reset the state to blank; so a left-over completion handler from an aggregate packet. Blanking the handler fixes this behaviour. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 8 08:22:15 2011 (r224704) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 8 11:33:07 2011 (r224705) @@ -1677,8 +1677,8 @@ ath_tx_swq(struct ath_softc *sc, struct tid = ath_tx_gettid(sc, m0); atid = &an->an_tid[tid]; - DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: pri=%d, tid=%d, qos=%d\n", - __func__, pri, tid, IEEE80211_QOS_HAS_SEQ(wh)); + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p, pri=%d, tid=%d, qos=%d\n", + __func__, bf, pri, tid, IEEE80211_QOS_HAS_SEQ(wh)); /* Set local packet state, used to queue packets to hardware */ bf->bf_state.bfs_tid = tid; @@ -1925,6 +1925,10 @@ ath_tx_aggr_comp(struct ath_softc *sc, s * * Mark as retry, requeue at head of queue */ + if (tid == IEEE80211_NONQOS_TID) + device_printf(sc->sc_dev, "%s: TID=16!\n", __func__); + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: tid=%d\n", + __func__, bf, bf->bf_state.bfs_tid); /* * Not success and out of retries? @@ -1936,8 +1940,8 @@ ath_tx_aggr_comp(struct ath_softc *sc, s */ /* Success? Complete */ - DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: seqno %d\n", - __func__, SEQNO(bf->bf_state.bfs_seqno)); + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: TID=%d, seqno %d\n", + __func__, tid, SEQNO(bf->bf_state.bfs_seqno)); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); ath_tx_default_comp(sc, bf); @@ -1961,11 +1965,17 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft tap = ath_tx_get_tx_tid(an, tid); + if (tid == IEEE80211_NONQOS_TID) + device_printf(sc->sc_dev, "%s: called for TID=NONQOS_TID?\n", + __func__); + for (;;) { bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { break; } + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: tid=%d\n", + __func__, bf, bf->bf_state.bfs_tid); if (bf->bf_state.bfs_tid != tid) device_printf(sc->sc_dev, "%s: TID: tid=%d, ac=%d, bf tid=%d\n", __func__, tid, atid->ac, bf->bf_state.bfs_tid); @@ -2006,6 +2016,8 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft /* Set completion handler */ bf->bf_comp = ath_tx_aggr_comp; + if (bf->bf_state.bfs_tid == IEEE80211_NONQOS_TID) + device_printf(sc->sc_dev, "%s: TID=16?\n", __func__); /* Punt to hardware or software txq */ ath_tx_handoff(sc, txq, bf); @@ -2045,6 +2057,7 @@ ath_tx_tid_hw_queue_norm(struct ath_soft " tid %d\n", __func__, bf->bf_state.bfs_tid, tid); } + bf->bf_comp = NULL; /* XXX default handler */ /* Punt to hardware or software txq */ ath_tx_handoff(sc, txq, bf); @@ -2076,6 +2089,8 @@ ath_txq_sched(struct ath_softc *sc, stru * Suspend paused queues here; they'll be resumed * once the addba completes or times out. */ + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d, paused=%d\n", + __func__, atid->tid, atid->paused); if (atid->paused) { ath_tx_tid_unsched(sc, atid->an, atid->tid); continue; @@ -2122,6 +2137,9 @@ ath_tx_ampdu_running(struct ath_softc *s { struct ieee80211_tx_ampdu *tap; + if (tid == IEEE80211_NONQOS_TID) + return 0; + tap = ath_tx_get_tx_tid(an, tid); if (tap == NULL) return 0; /* Not valid; default to not running */ @@ -2137,6 +2155,9 @@ ath_tx_ampdu_pending(struct ath_softc *s { struct ieee80211_tx_ampdu *tap; + if (tid == IEEE80211_NONQOS_TID) + return 0; + tap = ath_tx_get_tx_tid(an, tid); if (tap == NULL) return 0; /* Not valid; default to not pending */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 8 14:40:24 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D9651065673; Mon, 8 Aug 2011 14:40:24 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C7CD8FC0A; Mon, 8 Aug 2011 14:40:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p78EeOKA051412; Mon, 8 Aug 2011 14:40:24 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p78EeN8X051409; Mon, 8 Aug 2011 14:40:23 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108081440.p78EeN8X051409@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 8 Aug 2011 14:40:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224713 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2011 14:40:24 -0000 Author: gabor Date: Mon Aug 8 14:40:23 2011 New Revision: 224713 URL: http://svn.freebsd.org/changeset/base/224713 Log: - Use the Turbo Boyer-Moore algorithm for literal patterns - Patterns containing . will still use the quick sort algorithm because it is harder to adapt the TBM algorithm for this case but this is broken atm anyway - Use a larger hash table to reduce hash collisions at insertion Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Aug 8 14:02:08 2011 (r224712) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Aug 8 14:40:23 2011 (r224713) @@ -116,30 +116,85 @@ static void revs(char *str, int len); #define SHIFT \ CHECKBOUNDS; \ { \ - int k = 0, r = -1; \ + int bc = 0, gs = 0, ts, r = -1; \ \ switch (type) \ { \ case STR_BYTE: \ case STR_MBS: \ - k = fg->qsBc[(unsigned char)((char *)startptr) \ + if (!fg->hasdot) \ + { \ + if (u != 0 && mismatch == fg->len - 1 - shift) \ + mismatch -= u; \ + v = fg->len - 1 - mismatch; \ + gs = fg->sbmGs[mismatch]; \ + } \ + bc = fg->qsBc[(unsigned char)((char *)startptr) \ [mismatch + 1]]; \ break; \ case STR_WIDE: \ - r = hashtable_get(fg->qsBc_table, \ - &((wchar_t *)startptr)[mismatch + 1], &k); \ - k = (r == 0) ? k : fg->defBc; \ + if (!fg->hasdot) \ + { \ + if (u != 0 && mismatch == fg->wlen - 1 - shift) \ + mismatch -= u; \ + v = fg->wlen - 1 - mismatch; \ + r = hashtable_get(fg->qsBc_table, \ + &((wchar_t *)startptr)[mismatch + 1], &bc); \ + gs = fg->bmGs[mismatch]; \ + } \ + bc = (r == 0) ? bc : fg->defBc; \ break; \ default: \ /* XXX */ \ break; \ } \ - j += k; \ + if (fg->hasdot) \ + shift = bc; \ + else \ + { \ + ts = u - v; \ + shift = MAX(ts, bc); \ + shift = MAX(shift, gs); \ + if (shift == gs) \ + u = MIN((type == STR_WIDE ? fg->wlen : fg->len) - \ + shift, v); \ + else \ + { \ + if (ts < bc) \ + shift = MAX(shift, u + 1); \ + u = 0; \ + } \ + } \ + j += shift; \ } #else #define SHIFT \ CHECKBOUNDS; \ - j += fg->qsBc[(unsigned char)((char *)startptr)[mismatch + 1]]; + { \ + int bc, gs; \ + bc = fg->qsBc[(unsigned char)((char *)startptr)[mismatch + 1]]; \ + if (fg->hasdot) \ + shift = bc; \ + else \ + { \ + gs = fg->bmGs[mismatch]; \ + if (u != 0 && mismatch == fg->wlen - 1 - shift) \ + mismatch -= u; \ + v = fg->wlen - 1 - mismatch; \ + ts = u - v; \ + shift = MAX(ts, bc); \ + shift = MAX(shift, gs); \ + if (shift == gs) \ + u = MIN(fg->wlen - shift, v); \ + else \ + { \ + if (ts < bc) \ + shift = MAX(shift, u + 1); \ + u = 0; \ + } \ + } \ + j += shift; \ + } #endif /* @@ -163,8 +218,8 @@ static void revs(char *str, int len); #define FILL_ARRAY(pat, plen) \ for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ - fg->qsBc[i] = plen - hasDot; \ - for (int i = hasDot + 1; i < plen; i++) \ + fg->qsBc[i] = plen - fg->hasdot; \ + for (int i = fg->hasdot + 1; i < plen; i++) \ { \ fg->qsBc[(unsigned)pat[i]] = plen - i; \ if (fg->icase) \ @@ -179,12 +234,12 @@ static void revs(char *str, int len); #ifdef TRE_WCHAR #define FILL_QSBC \ /* Adjust the shift based on location of the last dot ('.'). */ \ - fg->defBc = fg->wlen - hasDot; \ + fg->defBc = fg->wlen - fg->hasdot; \ \ /* Preprocess pattern. */ \ - fg->qsBc_table = hashtable_init(fg->wlen, sizeof(tre_char_t), \ + fg->qsBc_table = hashtable_init(fg->wlen * 4, sizeof(tre_char_t), \ sizeof(int)); \ - for (unsigned int i = hasDot + 1; i < fg->wlen; i++) \ + for (unsigned int i = fg->hasdot + 1; i < fg->wlen; i++) \ { \ int k = fg->wlen - i; \ hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ @@ -201,6 +256,76 @@ static void revs(char *str, int len); #define FILL_QSBC FILL_ARRAY(fg->wpattern, fg->wlen); #endif +#define FILL_BMGS(arr, pat, plen, wide) \ + { \ + char *p; \ + wchar_t *wp; \ + \ + if (wide) \ + { \ + if (fg->icase) \ + { \ + wp = alloca(plen * sizeof(wint_t)); \ + for (int i = 0; i < plen; i++) \ + wp[i] = towlower(pat[i]); \ + _FILL_BMGS(arr, wp, plen); \ + } \ + else \ + _FILL_BMGS(arr, pat, plen); \ + } \ + else \ + { \ + if (fg->icase) \ + { \ + p = alloca(plen); \ + for (int i = 0; i < plen; i++) \ + p[i] = tolower(pat[i]); \ + _FILL_BMGS(arr, p, plen); \ + } \ + else \ + _FILL_BMGS(arr, pat, plen); \ + } \ + } + +#define _FILL_BMGS(arr, pat, plen) \ + { \ + int f, g; \ + \ + int *suff = xmalloc(plen * sizeof(int)); \ + if (suff == NULL) \ + return REG_ESPACE; \ + \ + suff[plen - 1] = plen; \ + g = plen - 1; \ + for (int i = plen - 2; i >= 0; i--) \ + { \ + if (i > g && suff[i + plen - 1 - f] < i - g) \ + suff[i] = suff[i + plen - 1 - f]; \ + else \ + { \ + if (i < g) \ + g = i; \ + f = i; \ + while (g >= 0 && pat[g] == pat[g + plen - 1 - f]) \ + g--; \ + suff[i] = f - g; \ + } \ + } \ + \ + for (int i = 0; i < plen; i++) \ + arr[i] = plen; \ + g = 0; \ + for (int i = plen - 1; i >= 0; i--) \ + if (suff[i] == i + 1) \ + for(; g < plen - 1 - i; g++) \ + if (arr[g] == plen) \ + arr[g] = plen - 1 - i; \ + for (int i = 0; i <= plen - 2; i++) \ + arr[plen - 1 - suff[i]] = plen - 1 - i; \ + \ + free(suff); \ + } + #define REVFUNC(name, argtype) \ static inline void \ name(argtype *str, int len) \ @@ -218,7 +343,6 @@ name(argtype *str, int len) \ REVFUNC(revstr, tre_char_t) REVFUNC(revs, char) - /* * Returns: REG_OK on success, error code otherwise */ @@ -226,8 +350,6 @@ int tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *wpat, size_t n, int cflags) { - int hasDot = 0; - /* Initialize. */ memset(fg, 0, sizeof(*fg)); fg->icase = (cflags & REG_ICASE); @@ -246,6 +368,10 @@ tre_fastcomp_literal(fastmatch_t *fg, co #endif FILL_QSBC; + FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); +#ifdef TRE_WCHAR + FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); +#endif return REG_OK; } @@ -259,7 +385,6 @@ tre_fastcomp(fastmatch_t *fg, const tre_ { int firstHalfDot = -1; int firstLastHalfDot = -1; - int hasDot = 0; int lastHalfDot = 0; /* Initialize. */ @@ -316,7 +441,7 @@ tre_fastcomp(fastmatch_t *fg, const tre_ (fg->wpattern[i] == TRE_CHAR(':')) || (fg->wpattern[i] == TRE_CHAR('/'))) { continue; } else if (fg->wpattern[i] == TRE_CHAR('.')) { - hasDot = i; + fg->hasdot = i; if (i < fg->wlen / 2) { if (firstHalfDot < 0) /* Closest dot to the beginning */ @@ -343,19 +468,25 @@ tre_fastcomp(fastmatch_t *fg, const tre_ * Determine if a reverse search would be faster based on the placement * of the dots. */ - if ((!(fg->bol || fg->eol)) && - (lastHalfDot && ((firstHalfDot < 0) || - ((fg->wlen - (lastHalfDot + 1)) < (size_t)firstHalfDot)))) { - fg->reversed = true; - hasDot = fg->wlen - (firstHalfDot < 0 ? - firstLastHalfDot : firstHalfDot) - 1; - revstr(fg->wpattern, fg->wlen); -#ifdef TRE_WCHAR - revs(fg->pattern, fg->len); -#endif - } +// if ((!(fg->bol || fg->eol)) && +// (lastHalfDot && ((firstHalfDot < 0) || +// ((fg->wlen - (lastHalfDot + 1)) < (size_t)firstHalfDot)))) { +// fg->reversed = true; +// fg->hasdot = fg->wlen - (firstHalfDot < 0 ? +// firstLastHalfDot : firstHalfDot) - 1; +// revstr(fg->wpattern, fg->wlen); +//#ifdef TRE_WCHAR +// revs(fg->pattern, fg->len); +//#endif +// } FILL_QSBC; + if (!fg->hasdot) + FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); +#ifdef TRE_WCHAR + if (!fg->hasdot) + FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); +#endif /* * Put pattern back to normal after pre-processing to allow for easy @@ -378,7 +509,7 @@ tre_fastexec(const fastmatch_t *fg, cons { unsigned int j; int ret = REG_NOMATCH; - int mismatch; + int mismatch, shift, u = 0, v; const char *str_byte = data; const void *startptr = NULL; #ifdef TRE_WCHAR @@ -406,6 +537,16 @@ tre_fastexec(const fastmatch_t *fg, cons if (len < fg->len) return ret; + switch (type) + { + case STR_WIDE: + shift = fg->wlen; + break; + default: + shift = fg->len; + break; + } + /* Only try once at the beginning or ending of the line. */ if (fg->bol || fg->eol) { /* Simple text comparison. */ Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Mon Aug 8 14:02:08 2011 (r224712) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Mon Aug 8 14:40:23 2011 (r224713) @@ -35,16 +35,21 @@ #include "tre.h" #include "tre-internal.h" +#define BM_MAX_LEN 1024 + typedef struct { size_t wlen; size_t len; tre_char_t *wpattern; - char *pattern; + int hasdot; + int qsBc[UCHAR_MAX + 1]; + int bmGs[BM_MAX_LEN]; #ifdef TRE_WCHAR + char *pattern; int defBc; hashtable *qsBc_table; + int sbmGs[BM_MAX_LEN]; #endif - int qsBc[UCHAR_MAX + 1]; /* flags */ bool bol; bool eol; From owner-svn-src-user@FreeBSD.ORG Mon Aug 8 15:12:27 2011 Return-Path: Delivered-To: svn-src-user@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36BD8106566C; Mon, 8 Aug 2011 15:12:27 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 8E7578FC0A; Mon, 8 Aug 2011 15:12:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id p78ExQV4084350; Mon, 8 Aug 2011 18:59:26 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id p78ExQs0084349; Mon, 8 Aug 2011 18:59:26 +0400 (MSK) (envelope-from ache) Date: Mon, 8 Aug 2011 18:59:26 +0400 From: Andrey Chernov To: Gabor Kovesdan Message-ID: <20110808145926.GA84321@vniz.net> Mail-Followup-To: Andrey Chernov , Gabor Kovesdan , src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG References: <201108081440.p78EeN8X051409@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201108081440.p78EeN8X051409@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG Subject: Re: svn commit: r224713 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2011 15:12:27 -0000 On Mon, Aug 08, 2011 at 02:40:23PM +0000, Gabor Kovesdan wrote: > Author: gabor > Date: Mon Aug 8 14:40:23 2011 > New Revision: 224713 > URL: http://svn.freebsd.org/changeset/base/224713 > > + bc = fg->qsBc[(unsigned char)((char *)startptr) \ IMHO you can use just single (unsigned char *) cast instead of 2 casts in all such places. -- http://ache.vniz.net/ From owner-svn-src-user@FreeBSD.ORG Mon Aug 8 22:16:07 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C22A1065686; Mon, 8 Aug 2011 22:16:07 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C0278FC16; Mon, 8 Aug 2011 22:16:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p78MG7jo065710; Mon, 8 Aug 2011 22:16:07 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p78MG71C065708; Mon, 8 Aug 2011 22:16:07 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108082216.p78MG71C065708@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 8 Aug 2011 22:16:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224723 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2011 22:16:07 -0000 Author: gabor Date: Mon Aug 8 22:16:07 2011 New Revision: 224723 URL: http://svn.freebsd.org/changeset/base/224723 Log: - Fix matching . Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Aug 8 20:53:04 2011 (r224722) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Aug 8 22:16:07 2011 (r224723) @@ -624,17 +624,19 @@ fastcmp(const void *pat, const void *dat #endif for (int i = len - 1; i >= 0; i--) { - if (pat_wide[i] == TRE_CHAR('.')) - continue; switch (type) { case STR_BYTE: case STR_MBS: + if (pat_byte[i] == '.') + continue; if (icase ? (tolower(pat_byte[i]) == tolower(str_byte[i])) : (pat_byte[i] == str_byte[i])) continue; break; case STR_WIDE: + if (pat_wide[i] == L'.') + continue; if (icase ? (towlower(pat_wide[i]) == towlower(str_wide[i])) : (pat_wide[i] == str_wide[i])) continue; From owner-svn-src-user@FreeBSD.ORG Tue Aug 9 15:47:55 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 270861065673; Tue, 9 Aug 2011 15:47:55 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0C6E28FC13; Tue, 9 Aug 2011 15:47:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p79FlsDN002024; Tue, 9 Aug 2011 15:47:54 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p79FlsB7002022; Tue, 9 Aug 2011 15:47:54 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108091547.p79FlsB7002022@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 9 Aug 2011 15:47:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224735 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2011 15:47:55 -0000 Author: gabor Date: Tue Aug 9 15:47:54 2011 New Revision: 224735 URL: http://svn.freebsd.org/changeset/base/224735 Log: - Simplify cast Submitted by: ache Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Tue Aug 9 15:46:52 2011 (r224734) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Tue Aug 9 15:47:54 2011 (r224735) @@ -129,7 +129,7 @@ static void revs(char *str, int len); v = fg->len - 1 - mismatch; \ gs = fg->sbmGs[mismatch]; \ } \ - bc = fg->qsBc[(unsigned char)((char *)startptr) \ + bc = fg->qsBc[((unsigned char *)startptr) \ [mismatch + 1]]; \ break; \ case STR_WIDE: \ @@ -172,7 +172,7 @@ static void revs(char *str, int len); CHECKBOUNDS; \ { \ int bc, gs; \ - bc = fg->qsBc[(unsigned char)((char *)startptr)[mismatch + 1]]; \ + bc = fg->qsBc[((unsigned char *)startptr)[mismatch + 1]]; \ if (fg->hasdot) \ shift = bc; \ else \ From owner-svn-src-user@FreeBSD.ORG Wed Aug 10 13:24:32 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 862FD106566C; Wed, 10 Aug 2011 13:24:32 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B3398FC14; Wed, 10 Aug 2011 13:24:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7ADOW0t047207; Wed, 10 Aug 2011 13:24:32 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7ADOWOe047204; Wed, 10 Aug 2011 13:24:32 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108101324.p7ADOWOe047204@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 10 Aug 2011 13:24:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224757 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2011 13:24:32 -0000 Author: gabor Date: Wed Aug 10 13:24:32 2011 New Revision: 224757 URL: http://svn.freebsd.org/changeset/base/224757 Log: - Drop reverse matching code. We always need the first match so it cannot be applied here. Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 08:55:46 2011 (r224756) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 13:24:32 2011 (r224757) @@ -202,9 +202,7 @@ static void revs(char *str, int len); * next character after the comparison is within the pattern. With * wildcards, the position of the last dot effects the maximum shift * distance. - * The closer to the end the wild card is the slower the search. A - * reverse version of this algorithm would be useful for wildcards near - * the end of the string. + * The closer to the end the wild card is the slower the search. * * Examples: * Pattern Max shift @@ -383,10 +381,6 @@ int tre_fastcomp(fastmatch_t *fg, const tre_char_t *wpat, size_t n, int cflags) { - int firstHalfDot = -1; - int firstLastHalfDot = -1; - int lastHalfDot = 0; - /* Initialize. */ memset(fg, 0, sizeof(*fg)); fg->icase = (cflags & REG_ICASE); @@ -440,19 +434,9 @@ tre_fastcomp(fastmatch_t *fg, const tre_ (fg->wpattern[i] == TRE_CHAR('=')) || (fg->wpattern[i] == TRE_CHAR('-')) || (fg->wpattern[i] == TRE_CHAR(':')) || (fg->wpattern[i] == TRE_CHAR('/'))) { continue; - } else if (fg->wpattern[i] == TRE_CHAR('.')) { + } else if (fg->wpattern[i] == TRE_CHAR('.')) fg->hasdot = i; - if (i < fg->wlen / 2) { - if (firstHalfDot < 0) - /* Closest dot to the beginning */ - firstHalfDot = i; - } else { - /* Closest dot to the end of the pattern. */ - lastHalfDot = i; - if (firstLastHalfDot < 0) - firstLastHalfDot = i; - } - } else { + else { /* Free memory and let others know this is empty. */ free(fg->wpattern); fg->wpattern = NULL; @@ -464,22 +448,6 @@ tre_fastcomp(fastmatch_t *fg, const tre_ STORE_MBS_PAT; #endif - /* - * Determine if a reverse search would be faster based on the placement - * of the dots. - */ -// if ((!(fg->bol || fg->eol)) && -// (lastHalfDot && ((firstHalfDot < 0) || -// ((fg->wlen - (lastHalfDot + 1)) < (size_t)firstHalfDot)))) { -// fg->reversed = true; -// fg->hasdot = fg->wlen - (firstHalfDot < 0 ? -// firstLastHalfDot : firstHalfDot) - 1; -// revstr(fg->wpattern, fg->wlen); -//#ifdef TRE_WCHAR -// revs(fg->pattern, fg->len); -//#endif -// } - FILL_QSBC; if (!fg->hasdot) FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); @@ -488,18 +456,6 @@ tre_fastcomp(fastmatch_t *fg, const tre_ FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); #endif - /* - * Put pattern back to normal after pre-processing to allow for easy - * comparisons later. - */ - if (fg->reversed) - { - revstr(fg->wpattern, fg->wlen); -#ifdef TRE_WCHAR - revs(fg->pattern, fg->len); -#endif - } - return REG_OK; } @@ -561,21 +517,6 @@ tre_fastexec(const fastmatch_t *fg, cons return REG_OK; } } - } else if (fg->reversed) { - /* Quick Search algorithm. */ - j = len - fg->len; - do { - SKIP_CHARS(j); - COMPARE; - if (mismatch == REG_OK) { - pmatch[0].rm_so = j - fg->len; - pmatch[0].rm_eo = j; - return REG_OK; - } else if (mismatch > 0) - return mismatch; - mismatch = -mismatch - 1; - SHIFT; - } while (!IS_OUT_OF_BOUNDS); } else { /* Quick Search algorithm. */ j = 0; Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Wed Aug 10 08:55:46 2011 (r224756) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Wed Aug 10 13:24:32 2011 (r224757) @@ -53,7 +53,6 @@ typedef struct { /* flags */ bool bol; bool eol; - bool reversed; bool word; bool icase; } fastmatch_t; From owner-svn-src-user@FreeBSD.ORG Wed Aug 10 15:19:14 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59409106566C; Wed, 10 Aug 2011 15:19:14 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3F1DA8FC14; Wed, 10 Aug 2011 15:19:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7AFJEiO050693; Wed, 10 Aug 2011 15:19:14 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7AFJESt050691; Wed, 10 Aug 2011 15:19:14 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108101519.p7AFJESt050691@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 10 Aug 2011 15:19:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224758 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2011 15:19:14 -0000 Author: gabor Date: Wed Aug 10 15:19:14 2011 New Revision: 224758 URL: http://svn.freebsd.org/changeset/base/224758 Log: - Make fg->pattern always hold SB/MB string and fg->wpattern always hold wide string. This is more logical and allows simplifying some parts of the code. - Cleanup and style changes according to TRE's coding style Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 13:24:32 2011 (r224757) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 15:19:14 2011 (r224758) @@ -43,8 +43,6 @@ static int fastcmp(const void *, const void *, size_t, tre_str_type_t, bool); -static void revstr(tre_char_t *, int); -static void revs(char *str, int len); #ifdef TRE_WCHAR #define TRE_CHAR(n) L##n @@ -56,16 +54,11 @@ static void revs(char *str, int len); do { \ switch (type) \ { \ - case STR_BYTE: \ - case STR_MBS: \ - startptr = str_byte + n; \ - break; \ case STR_WIDE: \ startptr = str_wide + n; \ break; \ default: \ - /* XXX */ \ - break; \ + startptr = str_byte + n; \ } \ } while (0); \ @@ -85,117 +78,72 @@ static void revs(char *str, int len); } while (0); \ #define COMPARE \ - do { \ - switch (type) \ - { \ - case STR_BYTE: \ - case STR_MBS: \ - mismatch = fastcmp(fg->pattern, startptr, fg->len, type, \ - fg->icase); \ - break; \ - case STR_WIDE: \ - mismatch = fastcmp(fg->wpattern, startptr, fg->wlen, type, \ - fg->icase); \ - default: \ - break; \ + switch (type) \ + { \ + case STR_WIDE: \ + mismatch = fastcmp(fg->wpattern, startptr, fg->wlen, type, \ + fg->icase); \ + break; \ + default: \ + mismatch = fastcmp(fg->pattern, startptr, fg->len, type, \ + fg->icase); \ } \ - } while (0); -#ifdef TRE_WCHAR #define IS_OUT_OF_BOUNDS \ ((type == STR_WIDE) ? ((j + fg->wlen) > len) : ((j + fg->len) > len)) -#else -#define IS_OUT_OF_BOUNDS ((j + fg->len) > len) -#endif #define CHECKBOUNDS \ if (IS_OUT_OF_BOUNDS) \ break; \ -#ifdef TRE_WCHAR #define SHIFT \ - CHECKBOUNDS; \ - { \ - int bc = 0, gs = 0, ts, r = -1; \ + CHECKBOUNDS; \ \ - switch (type) \ - { \ - case STR_BYTE: \ - case STR_MBS: \ - if (!fg->hasdot) \ - { \ - if (u != 0 && mismatch == fg->len - 1 - shift) \ - mismatch -= u; \ - v = fg->len - 1 - mismatch; \ - gs = fg->sbmGs[mismatch]; \ - } \ - bc = fg->qsBc[((unsigned char *)startptr) \ - [mismatch + 1]]; \ - break; \ - case STR_WIDE: \ - if (!fg->hasdot) \ - { \ - if (u != 0 && mismatch == fg->wlen - 1 - shift) \ - mismatch -= u; \ - v = fg->wlen - 1 - mismatch; \ - r = hashtable_get(fg->qsBc_table, \ - &((wchar_t *)startptr)[mismatch + 1], &bc); \ - gs = fg->bmGs[mismatch]; \ - } \ - bc = (r == 0) ? bc : fg->defBc; \ - break; \ - default: \ - /* XXX */ \ - break; \ - } \ - if (fg->hasdot) \ - shift = bc; \ - else \ - { \ - ts = u - v; \ - shift = MAX(ts, bc); \ - shift = MAX(shift, gs); \ - if (shift == gs) \ - u = MIN((type == STR_WIDE ? fg->wlen : fg->len) - \ - shift, v); \ - else \ - { \ - if (ts < bc) \ - shift = MAX(shift, u + 1); \ - u = 0; \ - } \ - } \ - j += shift; \ - } -#else -#define SHIFT \ - CHECKBOUNDS; \ + { \ + int bc = 0, gs = 0, ts, r = -1; \ + \ + switch (type) \ + { \ + case STR_WIDE: \ + if (!fg->hasdot) \ + { \ + if (u != 0 && mismatch == fg->wlen - 1 - shift) \ + mismatch -= u; \ + v = fg->wlen - 1 - mismatch; \ + r = hashtable_get(fg->qsBc_table, \ + &((wchar_t *)startptr)[mismatch + 1], &bc); \ + gs = fg->bmGs[mismatch]; \ + } \ + bc = (r == 0) ? bc : fg->defBc; \ + break; \ + default: \ + if (!fg->hasdot) \ + { \ + if (u != 0 && mismatch == fg->len - 1 - shift) \ + mismatch -= u; \ + v = fg->len - 1 - mismatch; \ + gs = fg->sbmGs[mismatch]; \ + } \ + bc = fg->qsBc[((unsigned char *)startptr)[mismatch + 1]]; \ + } \ + if (fg->hasdot) \ + shift = bc; \ + else \ { \ - int bc, gs; \ - bc = fg->qsBc[((unsigned char *)startptr)[mismatch + 1]]; \ - if (fg->hasdot) \ - shift = bc; \ + ts = u - v; \ + shift = MAX(ts, bc); \ + shift = MAX(shift, gs); \ + if (shift == gs) \ + u = MIN((type == STR_WIDE ? fg->wlen : fg->len) - shift, v); \ else \ { \ - gs = fg->bmGs[mismatch]; \ - if (u != 0 && mismatch == fg->wlen - 1 - shift) \ - mismatch -= u; \ - v = fg->wlen - 1 - mismatch; \ - ts = u - v; \ - shift = MAX(ts, bc); \ - shift = MAX(shift, gs); \ - if (shift == gs) \ - u = MIN(fg->wlen - shift, v); \ - else \ - { \ - if (ts < bc) \ - shift = MAX(shift, u + 1); \ - u = 0; \ - } \ + if (ts < bc) \ + shift = MAX(shift, u + 1); \ + u = 0; \ } \ - j += shift; \ - } -#endif + } \ + j += shift; \ + } /* * Normal Quick Search would require a shift based on the position the @@ -214,23 +162,22 @@ static void revs(char *str, int len); * thi. 1 */ -#define FILL_ARRAY(pat, plen) \ +#define FILL_QSBC \ for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ - fg->qsBc[i] = plen - fg->hasdot; \ - for (int i = fg->hasdot + 1; i < plen; i++) \ + fg->qsBc[i] = fg->len - fg->hasdot; \ + for (int i = fg->hasdot + 1; i < fg->len; i++) \ { \ - fg->qsBc[(unsigned)pat[i]] = plen - i; \ + fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ if (fg->icase) \ { \ - char c = islower(pat[i]) ? toupper(pat[i]) \ - : tolower(pat[i]); \ - fg->qsBc[(unsigned)c] = plen - i; \ + char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ + : tolower(fg->pattern[i]); \ + fg->qsBc[(unsigned)c] = fg->len - i; \ } \ } -#ifdef TRE_WCHAR -#define FILL_QSBC \ +#define FILL_QSBC_WIDE \ /* Adjust the shift based on location of the last dot ('.'). */ \ fg->defBc = fg->wlen - fg->hasdot; \ \ @@ -248,11 +195,6 @@ static void revs(char *str, int len); hashtable_put(fg->qsBc_table, &wc, &k); \ } \ } \ - \ - FILL_ARRAY(fg->pattern, fg->len); -#else -#define FILL_QSBC FILL_ARRAY(fg->wpattern, fg->wlen); -#endif #define FILL_BMGS(arr, pat, plen, wide) \ { \ @@ -324,51 +266,44 @@ static void revs(char *str, int len); free(suff); \ } -#define REVFUNC(name, argtype) \ -static inline void \ -name(argtype *str, int len) \ -{ \ - argtype c; \ - \ - for (int i = 0; i < len / 2; i++) \ - { \ - c = str[i]; \ - str[i] = str[len - i - 1]; \ - str[len - i - 1] = c; \ - } \ -} - -REVFUNC(revstr, tre_char_t) -REVFUNC(revs, char) - /* * Returns: REG_OK on success, error code otherwise */ int -tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *wpat, size_t n, +tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n, int cflags) { /* Initialize. */ memset(fg, 0, sizeof(*fg)); fg->icase = (cflags & REG_ICASE); - /* XXX */ + + /* Cannot handle REG_ICASE with MB string */ if (fg->icase && (MB_CUR_MAX > 1)) return REG_BADPAT; - fg->wlen = (n == 0) ? tre_strlen(wpat) : n; +#ifdef TRE_WCHAR + fg->wlen = (n == 0) ? tre_strlen(pat) : n; fg->wpattern = xmalloc((fg->wlen + 1) * sizeof(tre_char_t)); if (fg->wpattern == NULL) return REG_ESPACE; - memcpy(fg->wpattern, wpat, fg->wlen * sizeof(tre_char_t)); + memcpy(fg->wpattern, pat, fg->wlen * sizeof(tre_char_t)); fg->wpattern[fg->wlen] = TRE_CHAR('\0'); -#ifdef TRE_WCHAR + STORE_MBS_PAT; +#else + fg->len = (n == 0) ? tre_strlen(pat) : n; + fg->pattern = xmalloc((fg->len + 1) * sizeof(tre_char_t)); + if (fg->pattern == NULL) + return REG_ESPACE; + memcpy(fg->pattern, pat, fg->len * sizeof(tre_char_t)); + fg->pattern[fg->len] = TRE_CHAR('\0'); #endif FILL_QSBC; - FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); -#ifdef TRE_WCHAR FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); +#ifdef TRE_WCHAR + FILL_QSBC_WIDE; + FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); #endif return REG_OK; @@ -378,52 +313,53 @@ tre_fastcomp_literal(fastmatch_t *fg, co * Returns: REG_OK on success, error code otherwise */ int -tre_fastcomp(fastmatch_t *fg, const tre_char_t *wpat, size_t n, +tre_fastcomp(fastmatch_t *fg, const tre_char_t *pat, size_t n, int cflags) { /* Initialize. */ memset(fg, 0, sizeof(*fg)); fg->icase = (cflags & REG_ICASE); - /* XXX */ + + /* Cannot handle REG_ICASE with MB string */ if (fg->icase && (MB_CUR_MAX > 1)) return REG_BADPAT; - fg->wlen = (n == 0) ? tre_strlen(wpat) : n; + fg->wlen = (n == 0) ? tre_strlen(pat) : n; /* Remove end-of-line character ('$'). */ - if ((fg->wlen > 0) && (wpat[fg->wlen - 1] == TRE_CHAR('$'))) + if ((fg->wlen > 0) && (pat[fg->wlen - 1] == TRE_CHAR('$'))) { fg->eol = true; fg->wlen--; } /* Remove beginning-of-line character ('^'). */ - if (wpat[0] == TRE_CHAR('^')) + if (pat[0] == TRE_CHAR('^')) { fg->bol = true; fg->wlen--; - wpat++; + pat++; } if ((fg->wlen >= 14) && - (memcmp(wpat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && - (memcmp(wpat + fg->wlen - 7, TRE_CHAR("[[:>:]]"), + (memcmp(pat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && + (memcmp(pat + fg->wlen - 7, TRE_CHAR("[[:>:]]"), 7 * sizeof(tre_char_t)) == 0)) { fg->wlen -= 14; - wpat += 7; + pat += 7; fg->word = true; } /* - * wpat has been adjusted earlier to not include '^', '$' or + * pat has been adjusted earlier to not include '^', '$' or * the word match character classes at the beginning and ending * of the string respectively. */ fg->wpattern = xmalloc((fg->wlen + 1) * sizeof(tre_char_t)); if (fg->wpattern == NULL) return REG_ESPACE; - memcpy(fg->wpattern, wpat, fg->wlen * sizeof(tre_char_t)); + memcpy(fg->wpattern, pat, fg->wlen * sizeof(tre_char_t)); fg->wpattern[fg->wlen] = TRE_CHAR('\0'); /* Look for ways to cheat...er...avoid the full regex engine. */ @@ -446,14 +382,18 @@ tre_fastcomp(fastmatch_t *fg, const tre_ #ifdef TRE_WCHAR STORE_MBS_PAT; +#else + fg->len = fg->wlen; + fg->patter = fg->wpattern; #endif FILL_QSBC; if (!fg->hasdot) - FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); + FILL_BMGS(fg->bmGs, fg->pattern, fg->len, false); #ifdef TRE_WCHAR + FILL_QSBC_WIDE; if (!fg->hasdot) - FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); + FILL_BMGS(fg->sbmGs, fg->wpattern, fg->wlen, true); #endif return REG_OK; @@ -473,36 +413,31 @@ tre_fastexec(const fastmatch_t *fg, cons #endif if (len == (unsigned)-1) - { - switch (type) - { - case STR_BYTE: - case STR_MBS: - len = strlen(str_byte); - break; - case STR_WIDE: - len = wcslen(str_wide); - break; - default: - /* XXX */ - break; - } - } + switch (type) + { + case STR_WIDE: + len = wcslen(str_wide); + break; + default: + len = strlen(str_byte); + break; + } /* No point in going farther if we do not have enough data. */ - if (len < fg->len) - return ret; - switch (type) { case STR_WIDE: + if (len < fg->wlen) + return ret; shift = fg->wlen; break; default: + if (len < fg->len) + return ret; shift = fg->len; - break; } + /* XXX: make wchar-clean */ /* Only try once at the beginning or ending of the line. */ if (fg->bol || fg->eol) { /* Simple text comparison. */ @@ -525,7 +460,7 @@ tre_fastexec(const fastmatch_t *fg, cons COMPARE; if (mismatch == REG_OK) { pmatch[0].rm_so = j; - pmatch[0].rm_eo = j + fg->len; + pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); return REG_OK; } else if (mismatch > 0) return mismatch; @@ -542,9 +477,9 @@ tre_fastfree(fastmatch_t *fg) #ifdef TRE_WCHAR hashtable_free(fg->qsBc_table); - free(fg->pattern); -#endif free(fg->wpattern); +#endif + free(fg->pattern); } /* From owner-svn-src-user@FreeBSD.ORG Wed Aug 10 16:13:43 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83C50106566C; Wed, 10 Aug 2011 16:13:43 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 736AD8FC0C; Wed, 10 Aug 2011 16:13:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7AGDh79052364; Wed, 10 Aug 2011 16:13:43 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7AGDhoe052358; Wed, 10 Aug 2011 16:13:43 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108101613.p7AGDhoe052358@svn.freebsd.org> From: Adrian Chadd Date: Wed, 10 Aug 2011 16:13:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224760 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2011 16:13:43 -0000 Author: adrian Date: Wed Aug 10 16:13:43 2011 New Revision: 224760 URL: http://svn.freebsd.org/changeset/base/224760 Log: Fix the (current) major issue where BAW tracking was failing, causing the TX side to hang. When ath_tx_draintxq() was called, flushing hardware-queued TX frames, they'd be immediately freed. The bf_comp handler wasn't being called. So frames in an aggregation session would be freed without their seqnum being updated in the BAW. If enough frames were skipped, the current seqnum would be outside the BAW and thus TX on that TID would stop. This fixes the initial issue of hanging TX during an aggregation session. This also causes the receiver to have to slide the BAW over as there will be gaps in what's transmitted but without a BAR being sent to force the RX side to update. That's (for now) preferable to having things just hang. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 10 15:49:24 2011 (r224759) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 10 16:13:43 2011 (r224760) @@ -4110,19 +4110,30 @@ ath_tx_update_stats(struct ath_softc *sc } +/* + * The default completion. If fail is 1, this means + * "please don't retry the frame, and just return -1 status + * to the net80211 stack. + */ void -ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf) +ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) { struct ath_tx_status *ts = &bf->bf_status.ds_txstat; + int st; + + if (fail == 1) + st = -1; + else + st = ((bf->bf_txflags & HAL_TXDESC_NOACK) == 0) ? + ts->ts_status : HAL_TXERR_XRETRY; + /* * Do any tx complete callback. Note this must * be done before releasing the node reference. * This will free the mbuf, release the net80211 * node and recycle the ath_buf. */ - ath_tx_freebuf(sc, bf, - ((bf->bf_txflags & HAL_TXDESC_NOACK) == 0) ? - ts->ts_status : HAL_TXERR_XRETRY); + ath_tx_freebuf(sc, bf, st); } /* @@ -4211,9 +4222,9 @@ ath_tx_processq(struct ath_softc *sc, st } if (bf->bf_comp == NULL) - ath_tx_default_comp(sc, bf); + ath_tx_default_comp(sc, bf, 0); else - bf->bf_comp(sc, bf); + bf->bf_comp(sc, bf, 0); } #ifdef IEEE80211_SUPPORT_SUPERG /* @@ -4376,16 +4387,23 @@ ath_tx_draintxq(struct ath_softc *sc, st if (bf != NULL) bf->bf_flags &= ~ATH_BUF_BUSY; ATH_TXBUF_UNLOCK(sc); + /* + * The TXQ lock is held here for the entire trip through the + * list (rather than just being held whilst acquiring frames + * off of the list) because of the (current) assumption that + * the per-TID software queue stuff is locked by the hardware + * queue it maps to, thus ensuring proper ordering of things. + * + * The chance for LOR's however, is now that much bigger. Sigh. + */ + ATH_TXQ_LOCK(txq); for (ix = 0;; ix++) { - ATH_TXQ_LOCK(txq); bf = STAILQ_FIRST(&txq->axq_q); if (bf == NULL) { txq->axq_link = NULL; - ATH_TXQ_UNLOCK(txq); break; } ATH_TXQ_REMOVE_HEAD(txq, bf_list); - ATH_TXQ_UNLOCK(txq); #ifdef ATH_DEBUG if (sc->sc_debug & ATH_DEBUG_RESET) { struct ieee80211com *ic = sc->sc_ifp->if_l2com; @@ -4397,8 +4415,18 @@ ath_tx_draintxq(struct ath_softc *sc, st bf->bf_m->m_len, 0, -1); } #endif /* ATH_DEBUG */ - ath_tx_freebuf(sc, bf, -1); + //ath_tx_freebuf(sc, bf, -1); + /* + * Since we're now doing magic in the completion + * functions, we -must- call it for aggregation + * destinations or BAW tracking will get upset. + */ + if (bf->bf_comp) + bf->bf_comp(sc, bf, 1); + else + ath_tx_default_comp(sc, bf, 1); } + ATH_TXQ_UNLOCK(txq); } static void Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Wed Aug 10 15:49:24 2011 (r224759) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Wed Aug 10 16:13:43 2011 (r224760) @@ -55,7 +55,8 @@ extern struct ath_buf * _ath_getbuf_lock extern int ath_reset(struct ifnet *); extern void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq); -extern void ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf); +extern void ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf, + int fail); extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status); Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 10 15:49:24 2011 (r224759) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 10 16:13:43 2011 (r224760) @@ -1890,10 +1890,10 @@ ath_tx_tid_cleanup(struct ath_softc *sc, #ifdef notyet /* - * Handle completion of non-aggregate frames. + * Handle completion of non-aggregate session frames. */ static void -ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf) +ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) { struct ieee80211_node *ni = bf->bf_node; struct ath_node *an; @@ -1905,30 +1905,35 @@ ath_tx_normal_comp(struct ath_softc *sc, an = ATH_NODE(ni); atid = &an->an_tid[tid]; - ath_tx_default_comp(sc, bf); + ath_tx_default_comp(sc, bf, fail); } } #endif /* * Handle completion of aggregate frames. + * + * Fail is set to 1 if the entry is being freed via a call to + * ath_tx_draintxq(). */ static void -ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf) +ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) { struct ieee80211_node *ni = bf->bf_node; struct ath_node *an = ATH_NODE(ni); int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; + + if (tid == IEEE80211_NONQOS_TID) + device_printf(sc->sc_dev, "%s: TID=16!\n", __func__); + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: tid=%d\n", + __func__, bf, bf->bf_state.bfs_tid); + /* * Not success and have retries left? * * Mark as retry, requeue at head of queue */ - if (tid == IEEE80211_NONQOS_TID) - device_printf(sc->sc_dev, "%s: TID=16!\n", __func__); - DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: tid=%d\n", - __func__, bf, bf->bf_state.bfs_tid); /* * Not success and out of retries? @@ -1944,7 +1949,7 @@ ath_tx_aggr_comp(struct ath_softc *sc, s __func__, tid, SEQNO(bf->bf_state.bfs_seqno)); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); - ath_tx_default_comp(sc, bf); + ath_tx_default_comp(sc, bf, fail); /* bf is freed at this point */ } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 10 15:49:24 2011 (r224759) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 10 16:13:43 2011 (r224760) @@ -167,7 +167,11 @@ struct ath_buf { bus_dma_segment_t bf_segs[ATH_MAX_SCATTER]; /* Completion function to call on TX complete (fail or not) */ - void(* bf_comp) (struct ath_softc *sc, struct ath_buf *bf); + /* + * "fail" here is set to 1 if the queue entries were removed + * through a call to ath_tx_draintxq(). + */ + void(* bf_comp) (struct ath_softc *sc, struct ath_buf *bf, int fail); /* This state is kept to support software retries and aggregation */ struct { From owner-svn-src-user@FreeBSD.ORG Wed Aug 10 19:16:04 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D61F2106564A; Wed, 10 Aug 2011 19:16:04 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C6B368FC08; Wed, 10 Aug 2011 19:16:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7AJG46O057962; Wed, 10 Aug 2011 19:16:04 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7AJG4i3057960; Wed, 10 Aug 2011 19:16:04 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108101916.p7AJG4i3057960@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 10 Aug 2011 19:16:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224763 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2011 19:16:04 -0000 Author: gabor Date: Wed Aug 10 19:16:04 2011 New Revision: 224763 URL: http://svn.freebsd.org/changeset/base/224763 Log: - Add comments - Make FILL_BMGS and such consistent with FILL_QSBC - Avoid duplicated code by introducing a new macro - Simplify a switch to be consistent with earlier changes Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 19:12:21 2011 (r224762) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 19:16:04 2011 (r224763) @@ -44,12 +44,22 @@ static int fastcmp(const void *, const void *, size_t, tre_str_type_t, bool); +/* + * We will work with wide characters if they are supported + */ #ifdef TRE_WCHAR #define TRE_CHAR(n) L##n #else #define TRE_CHAR(n) n #endif +/* + * Skips n characters in the input string and assigns the start + * address to startptr. Note: as per IEEE Std 1003.1-2008 + * matching is based on bit pattern not character representations + * so we can handle MB strings as byte sequences just like + * SB strings. + */ #define SKIP_CHARS(n) \ do { \ switch (type) \ @@ -62,6 +72,11 @@ static int fastcmp(const void *, const v } \ } while (0); \ +/* + * Converts the wide string pattern to SB/MB string and stores + * it in fg->pattern. Sets fg->len to the byte length of the + * converted string. + */ #define STORE_MBS_PAT \ do { \ size_t siz; \ @@ -77,6 +92,10 @@ static int fastcmp(const void *, const v fg->pattern[siz] = '\0'; \ } while (0); \ +/* + * Compares the pattern to the input string at the position + * stored in startptr. + */ #define COMPARE \ switch (type) \ { \ @@ -92,10 +111,18 @@ static int fastcmp(const void *, const v #define IS_OUT_OF_BOUNDS \ ((type == STR_WIDE) ? ((j + fg->wlen) > len) : ((j + fg->len) > len)) +/* + * Checks whether the new position after shifting in the input string + * is out of the bounds and break out from the loop if so. + */ #define CHECKBOUNDS \ if (IS_OUT_OF_BOUNDS) \ break; \ +/* + * Shifts in the input string after a mismatch. The position of the + * mismatch is stored in the mismatch variable. + */ #define SHIFT \ CHECKBOUNDS; \ \ @@ -162,6 +189,9 @@ static int fastcmp(const void *, const v * thi. 1 */ +/* + * Fills in the bad character shift array for SB/MB strings. + */ #define FILL_QSBC \ for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ fg->qsBc[i] = fg->len - fg->hasdot; \ @@ -176,7 +206,15 @@ static int fastcmp(const void *, const v } \ } - +/* + * Fills in the bad character shifts into a hastable for wide strings. + * With wide characters it is not possible any more to use a normal + * array because there are too many characters and we could not + * provide enough memory. Fortunately, we only have to store distinct + * values for so many characters as the number of distinct characters + * in the pattern, so we can store them in a hashtable and store a + * default shift value for the rest. + */ #define FILL_QSBC_WIDE \ /* Adjust the shift based on location of the last dot ('.'). */ \ fg->defBc = fg->wlen - fg->hasdot; \ @@ -196,7 +234,21 @@ static int fastcmp(const void *, const v } \ } \ -#define FILL_BMGS(arr, pat, plen, wide) \ +/* + * Fills in the good suffix table for SB/MB strings. + */ +#define FILL_BMGS \ + if (!fg->hasdot) \ + _FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); + +/* + * Fills in the good suffix table for wide strings. + */ +#define FILL_BMGS_WIDE \ + if (!fg->hasdot) \ + _FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); + +#define _FILL_BMGS(arr, pat, plen, wide) \ { \ char *p; \ wchar_t *wp; \ @@ -208,10 +260,10 @@ static int fastcmp(const void *, const v wp = alloca(plen * sizeof(wint_t)); \ for (int i = 0; i < plen; i++) \ wp[i] = towlower(pat[i]); \ - _FILL_BMGS(arr, wp, plen); \ + _CALC_BMGS(arr, wp, plen); \ } \ else \ - _FILL_BMGS(arr, pat, plen); \ + _CALC_BMGS(arr, pat, plen); \ } \ else \ { \ @@ -220,14 +272,14 @@ static int fastcmp(const void *, const v p = alloca(plen); \ for (int i = 0; i < plen; i++) \ p[i] = tolower(pat[i]); \ - _FILL_BMGS(arr, p, plen); \ + _CALC_BMGS(arr, p, plen); \ } \ else \ - _FILL_BMGS(arr, pat, plen); \ + _CALC_BMGS(arr, pat, plen); \ } \ } -#define _FILL_BMGS(arr, pat, plen) \ +#define _CALC_BMGS(arr, pat, plen) \ { \ int f, g; \ \ @@ -266,6 +318,15 @@ static int fastcmp(const void *, const v free(suff); \ } +#define SAVE_PATTERN(p, l) \ + l = (n == 0) ? tre_strlen(pat) : n; \ + p = xmalloc((l + 1) * sizeof(tre_char_t)); \ + if (p == NULL) \ + return REG_ESPACE; \ + memcpy(p, pat, l * sizeof(tre_char_t)); \ + p[l] = TRE_CHAR('\0'); + + /* * Returns: REG_OK on success, error code otherwise */ @@ -282,28 +343,17 @@ tre_fastcomp_literal(fastmatch_t *fg, co return REG_BADPAT; #ifdef TRE_WCHAR - fg->wlen = (n == 0) ? tre_strlen(pat) : n; - fg->wpattern = xmalloc((fg->wlen + 1) * sizeof(tre_char_t)); - if (fg->wpattern == NULL) - return REG_ESPACE; - memcpy(fg->wpattern, pat, fg->wlen * sizeof(tre_char_t)); - fg->wpattern[fg->wlen] = TRE_CHAR('\0'); - + SAVE_PATTERN(fg->wpattern, fg->wlen); STORE_MBS_PAT; #else - fg->len = (n == 0) ? tre_strlen(pat) : n; - fg->pattern = xmalloc((fg->len + 1) * sizeof(tre_char_t)); - if (fg->pattern == NULL) - return REG_ESPACE; - memcpy(fg->pattern, pat, fg->len * sizeof(tre_char_t)); - fg->pattern[fg->len] = TRE_CHAR('\0'); + SAVE_PATTERN(fg->pattern, fg->len); #endif FILL_QSBC; - FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); + FILL_BMGS; #ifdef TRE_WCHAR FILL_QSBC_WIDE; - FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); + FILL_BMGS_WIDE; #endif return REG_OK; @@ -356,11 +406,7 @@ tre_fastcomp(fastmatch_t *fg, const tre_ * the word match character classes at the beginning and ending * of the string respectively. */ - fg->wpattern = xmalloc((fg->wlen + 1) * sizeof(tre_char_t)); - if (fg->wpattern == NULL) - return REG_ESPACE; - memcpy(fg->wpattern, pat, fg->wlen * sizeof(tre_char_t)); - fg->wpattern[fg->wlen] = TRE_CHAR('\0'); + SAVE_PATTERN(fg->wpattern, fg->wlen); /* Look for ways to cheat...er...avoid the full regex engine. */ for (unsigned int i = 0; i < fg->wlen; i++) { @@ -388,12 +434,10 @@ tre_fastcomp(fastmatch_t *fg, const tre_ #endif FILL_QSBC; - if (!fg->hasdot) - FILL_BMGS(fg->bmGs, fg->pattern, fg->len, false); + FILL_BMGS; #ifdef TRE_WCHAR FILL_QSBC_WIDE; - if (!fg->hasdot) - FILL_BMGS(fg->sbmGs, fg->wpattern, fg->wlen, true); + FILL_BMGS_WIDE; #endif return REG_OK; @@ -502,24 +546,19 @@ fastcmp(const void *pat, const void *dat for (int i = len - 1; i >= 0; i--) { switch (type) { - case STR_BYTE: - case STR_MBS: - if (pat_byte[i] == '.') - continue; - if (icase ? (tolower(pat_byte[i]) == tolower(str_byte[i])) - : (pat_byte[i] == str_byte[i])) - continue; - break; case STR_WIDE: if (pat_wide[i] == L'.') continue; if (icase ? (towlower(pat_wide[i]) == towlower(str_wide[i])) - : (pat_wide[i] == str_wide[i])) + : (pat_wide[i] == str_wide[i])) continue; break; default: - /* XXX */ - break; + if (pat_byte[i] == '.') + continue; + if (icase ? (tolower(pat_byte[i]) == tolower(str_byte[i])) + : (pat_byte[i] == str_byte[i])) + continue; } ret = -(i + 1); break; From owner-svn-src-user@FreeBSD.ORG Wed Aug 10 19:40:24 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33CAA106567C; Wed, 10 Aug 2011 19:40:24 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 249068FC0A; Wed, 10 Aug 2011 19:40:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7AJeOT7058707; Wed, 10 Aug 2011 19:40:24 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7AJeO7F058705; Wed, 10 Aug 2011 19:40:24 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108101940.p7AJeO7F058705@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 10 Aug 2011 19:40:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224764 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2011 19:40:24 -0000 Author: gabor Date: Wed Aug 10 19:40:23 2011 New Revision: 224764 URL: http://svn.freebsd.org/changeset/base/224764 Log: - Align backslashes of macros - Defer copying of pattern after all checks are passed; this also makes the code easier to read Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 19:16:04 2011 (r224763) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 19:40:23 2011 (r224764) @@ -60,37 +60,37 @@ static int fastcmp(const void *, const v * so we can handle MB strings as byte sequences just like * SB strings. */ -#define SKIP_CHARS(n) \ - do { \ - switch (type) \ - { \ - case STR_WIDE: \ - startptr = str_wide + n; \ - break; \ - default: \ - startptr = str_byte + n; \ - } \ - } while (0); \ +#define SKIP_CHARS(n) \ + do { \ + switch (type) \ + { \ + case STR_WIDE: \ + startptr = str_wide + n; \ + break; \ + default: \ + startptr = str_byte + n; \ + } \ + } while (0); \ /* * Converts the wide string pattern to SB/MB string and stores * it in fg->pattern. Sets fg->len to the byte length of the * converted string. */ -#define STORE_MBS_PAT \ - do { \ - size_t siz; \ - \ - siz = wcstombs(NULL, fg->wpattern, 0); \ - if (siz == (size_t)-1) \ - return REG_BADPAT; \ - fg->len = siz; \ - fg->pattern = xmalloc(siz + 1); \ - if (fg->pattern == NULL) \ - return REG_ESPACE; \ - wcstombs(fg->pattern, fg->wpattern, siz); \ - fg->pattern[siz] = '\0'; \ - } while (0); \ +#define STORE_MBS_PAT \ + do { \ + size_t siz; \ + \ + siz = wcstombs(NULL, fg->wpattern, 0); \ + if (siz == (size_t)-1) \ + return REG_BADPAT; \ + fg->len = siz; \ + fg->pattern = xmalloc(siz + 1); \ + if (fg->pattern == NULL) \ + return REG_ESPACE; \ + wcstombs(fg->pattern, fg->wpattern, siz); \ + fg->pattern[siz] = '\0'; \ + } while (0); \ /* * Compares the pattern to the input string at the position @@ -374,63 +374,57 @@ tre_fastcomp(fastmatch_t *fg, const tre_ if (fg->icase && (MB_CUR_MAX > 1)) return REG_BADPAT; - fg->wlen = (n == 0) ? tre_strlen(pat) : n; + n = (n == 0) ? tre_strlen(pat) : n; /* Remove end-of-line character ('$'). */ - if ((fg->wlen > 0) && (pat[fg->wlen - 1] == TRE_CHAR('$'))) + if ((n > 0) && (pat[n - 1] == TRE_CHAR('$'))) { fg->eol = true; - fg->wlen--; + n--; } /* Remove beginning-of-line character ('^'). */ if (pat[0] == TRE_CHAR('^')) { fg->bol = true; - fg->wlen--; + n--; pat++; } - if ((fg->wlen >= 14) && + if ((n >= 14) && (memcmp(pat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && - (memcmp(pat + fg->wlen - 7, TRE_CHAR("[[:>:]]"), + (memcmp(pat + n - 7, TRE_CHAR("[[:>:]]"), 7 * sizeof(tre_char_t)) == 0)) { - fg->wlen -= 14; + n -= 14; pat += 7; fg->word = true; } - /* - * pat has been adjusted earlier to not include '^', '$' or - * the word match character classes at the beginning and ending - * of the string respectively. - */ - SAVE_PATTERN(fg->wpattern, fg->wlen); - /* Look for ways to cheat...er...avoid the full regex engine. */ - for (unsigned int i = 0; i < fg->wlen; i++) { + for (unsigned int i = 0; i < n; i++) { /* Can still cheat? */ - if ((tre_isalnum(fg->wpattern[i])) || tre_isspace(fg->wpattern[i]) || - (fg->wpattern[i] == TRE_CHAR('_')) || (fg->wpattern[i] == TRE_CHAR(',')) || - (fg->wpattern[i] == TRE_CHAR('=')) || (fg->wpattern[i] == TRE_CHAR('-')) || - (fg->wpattern[i] == TRE_CHAR(':')) || (fg->wpattern[i] == TRE_CHAR('/'))) { + if ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || + (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) || + (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) || + (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/'))) continue; - } else if (fg->wpattern[i] == TRE_CHAR('.')) + else if (pat[i] == TRE_CHAR('.')) fg->hasdot = i; - else { - /* Free memory and let others know this is empty. */ - free(fg->wpattern); - fg->wpattern = NULL; + else return REG_BADPAT; - } } + /* + * pat has been adjusted earlier to not include '^', '$' or + * the word match character classes at the beginning and ending + * of the string respectively. + */ #ifdef TRE_WCHAR + SAVE_PATTERN(fg->wpattern, fg->wlen); STORE_MBS_PAT; #else - fg->len = fg->wlen; - fg->patter = fg->wpattern; + SAVE_PATTERN(fg->pattern, fg->len); #endif FILL_QSBC; From owner-svn-src-user@FreeBSD.ORG Wed Aug 10 21:32:13 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9EEAD106566B; Wed, 10 Aug 2011 21:32:13 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 755418FC0C; Wed, 10 Aug 2011 21:32:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7ALWD5o062205; Wed, 10 Aug 2011 21:32:13 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7ALWDvr062203; Wed, 10 Aug 2011 21:32:13 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108102132.p7ALWDvr062203@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 10 Aug 2011 21:32:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224766 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2011 21:32:13 -0000 Author: gabor Date: Wed Aug 10 21:32:13 2011 New Revision: 224766 URL: http://svn.freebsd.org/changeset/base/224766 Log: - TRE-specific changes to support better those systems that do not have wchar-support Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 20:52:02 2011 (r224765) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 21:32:13 2011 (r224766) @@ -32,8 +32,10 @@ #include #include #include +#ifdef TRE_WCHAR #include #include +#endif #include "fastmatch.h" #include "hashtable.h" @@ -138,7 +140,7 @@ static int fastcmp(const void *, const v mismatch -= u; \ v = fg->wlen - 1 - mismatch; \ r = hashtable_get(fg->qsBc_table, \ - &((wchar_t *)startptr)[mismatch + 1], &bc); \ + &((tre_char_t *)startptr)[mismatch + 1], &bc); \ gs = fg->bmGs[mismatch]; \ } \ bc = (r == 0) ? bc : fg->defBc; \ @@ -228,7 +230,7 @@ static int fastcmp(const void *, const v hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ if (fg->icase) \ { \ - wint_t wc = iswlower(fg->wpattern[i]) ? \ + tre_char_t wc = iswlower(fg->wpattern[i]) ? \ towupper(fg->wpattern[i]) : towlower(fg->wpattern[i]); \ hashtable_put(fg->qsBc_table, &wc, &k); \ } \ @@ -251,13 +253,13 @@ static int fastcmp(const void *, const v #define _FILL_BMGS(arr, pat, plen, wide) \ { \ char *p; \ - wchar_t *wp; \ + tre_char_t *wp; \ \ if (wide) \ { \ if (fg->icase) \ { \ - wp = alloca(plen * sizeof(wint_t)); \ + wp = alloca(plen * sizeof(tre_char_t)); \ for (int i = 0; i < plen; i++) \ wp[i] = towlower(pat[i]); \ _CALC_BMGS(arr, wp, plen); \ @@ -446,9 +448,7 @@ tre_fastexec(const fastmatch_t *fg, cons int mismatch, shift, u = 0, v; const char *str_byte = data; const void *startptr = NULL; -#ifdef TRE_WCHAR - const wchar_t *str_wide = data; -#endif + const tre_char_t *str_wide = data; if (len == (unsigned)-1) switch (type) @@ -532,10 +532,8 @@ fastcmp(const void *pat, const void *dat const char *str_byte = data; const char *pat_byte = pat; int ret = REG_OK; -#ifdef TRE_WCHAR - const wchar_t *str_wide = data; - const wchar_t *pat_wide = pat; -#endif + const tre_char_t *str_wide = data; + const tre_char_t *pat_wide = pat; for (int i = len - 1; i >= 0; i--) { switch (type) From owner-svn-src-user@FreeBSD.ORG Wed Aug 10 21:39:47 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D6801065672; Wed, 10 Aug 2011 21:39:47 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 73C958FC17; Wed, 10 Aug 2011 21:39:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7ALdl6h062460; Wed, 10 Aug 2011 21:39:47 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7ALdlNv062458; Wed, 10 Aug 2011 21:39:47 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108102139.p7ALdlNv062458@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 10 Aug 2011 21:39:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224767 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2011 21:39:47 -0000 Author: gabor Date: Wed Aug 10 21:39:47 2011 New Revision: 224767 URL: http://svn.freebsd.org/changeset/base/224767 Log: - Fix a wchar-cleanness issue - TRE-specific style Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 21:32:13 2011 (r224766) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 10 21:39:47 2011 (r224767) @@ -475,38 +475,46 @@ tre_fastexec(const fastmatch_t *fg, cons shift = fg->len; } - /* XXX: make wchar-clean */ /* Only try once at the beginning or ending of the line. */ - if (fg->bol || fg->eol) { - /* Simple text comparison. */ - if (!((fg->bol && fg->eol) && (len != fg->len))) { - /* Determine where in data to start search at. */ - j = fg->eol ? len - fg->len : 0; - SKIP_CHARS(j); - COMPARE; - if (mismatch == REG_OK) { - pmatch[0].rm_so = j; - pmatch[0].rm_eo = j + fg->len; - return REG_OK; - } + if (fg->bol || fg->eol) + { + /* Simple text comparison. */ + if (!((fg->bol && fg->eol) && + (type == STR_WIDE ? (wlen != fg->wlen) : (len != fg->len)))) + { + /* Determine where in data to start search at. */ + j = fg->eol ? len - (type == STR_WIDE ? fg->wlen : fg->len) : 0; + SKIP_CHARS(j); + COMPARE; + if (mismatch == REG_OK) + { + pmatch[0].rm_so = j; + pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len); + return REG_OK; + } + } } - } else { - /* Quick Search algorithm. */ - j = 0; - do { - SKIP_CHARS(j); - COMPARE; - if (mismatch == REG_OK) { - pmatch[0].rm_so = j; - pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); - return REG_OK; - } else if (mismatch > 0) - return mismatch; - mismatch = -mismatch - 1; - SHIFT; - } while (!IS_OUT_OF_BOUNDS); - } - return ret; + else + { + /* Quick Search algorithm. */ + j = 0; + do + { + SKIP_CHARS(j); + COMPARE; + if (mismatch == REG_OK) + { + pmatch[0].rm_so = j; + pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); + return REG_OK; + } + else if (mismatch > 0) + return mismatch; + mismatch = -mismatch - 1; + SHIFT; + } while (!IS_OUT_OF_BOUNDS); + } + return ret; } void From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 02:04:22 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3EF58106566B; Thu, 11 Aug 2011 02:04:22 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EBE98FC0C; Thu, 11 Aug 2011 02:04:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7B24MPQ070261; Thu, 11 Aug 2011 02:04:22 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7B24MG8070260; Thu, 11 Aug 2011 02:04:22 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108110204.p7B24MG8070260@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 02:04:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224769 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 02:04:22 -0000 Author: adrian Date: Thu Aug 11 02:04:21 2011 New Revision: 224769 URL: http://svn.freebsd.org/changeset/base/224769 Log: Include a TODO/README file with things I come across during this development and things I should likely fix/think about. Added: user/adrian/if_ath_tx/sys/dev/ath/README Added: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 02:04:21 2011 (r224769) @@ -0,0 +1,35 @@ +Things that need doing! + +* RIFS? Do I care about supporting RIFS? + +* Fast Frames? Do I care about supporting FF here, or is it done via suitable + evilness in net80211? + +* A-MPDU aggregation? + + how many pending A-MPDU frames per hardware TXQ? As many as needed? One? + +* Software retransmit when aggregation is enabled + + Whether doing A-MPDU or not + + Support rate updates and lookup on a retry; maybe a slower rate + is needed? + +* Send BAR when needed + + after TX failure + + when else? + +* DELBA - ie, downgrade existing packets in the SWQ + + What about stuff in the HWQ? + +* 20<->2040 mode change? + + part of this project or not? + + right now packets are simply flushed; why not just re-prod them into + the software TXQ ? + +Things that need investigating! + +* How should channel scanning be handled? Right now it's causing both a HW TXQ + and SW TXQ / node flush; this means the BAW will need to be slid along. Eek. + +* When a node is flushed (but not being deleted) should the BAW also be updated? + I don't think it is right now and this could be incorrect. + From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 02:08:02 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D78CD106564A; Thu, 11 Aug 2011 02:08:02 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C76B18FC19; Thu, 11 Aug 2011 02:08:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7B282kn070405; Thu, 11 Aug 2011 02:08:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7B282JC070403; Thu, 11 Aug 2011 02:08:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108110208.p7B282JC070403@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 02:08:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224770 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 02:08:02 -0000 Author: adrian Date: Thu Aug 11 02:08:02 2011 New Revision: 224770 URL: http://svn.freebsd.org/changeset/base/224770 Log: Add a couple more things I've forgotten. Modified: user/adrian/if_ath_tx/sys/dev/ath/README Modified: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 02:04:21 2011 (r224769) +++ user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 02:08:02 2011 (r224770) @@ -27,6 +27,10 @@ Things that need doing! Things that need investigating! +* Recursive HW TXQ's sometimes? Get some details about the the next one + +* LORs? Post some more details! (on STA join and node deletion?) + * How should channel scanning be handled? Right now it's causing both a HW TXQ and SW TXQ / node flush; this means the BAW will need to be slid along. Eek. From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 06:45:12 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D9254106564A; Thu, 11 Aug 2011 06:45:12 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE7AA8FC0A; Thu, 11 Aug 2011 06:45:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7B6jCGV080098; Thu, 11 Aug 2011 06:45:12 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7B6jCXe080096; Thu, 11 Aug 2011 06:45:12 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108110645.p7B6jCXe080096@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 06:45:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224773 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 06:45:13 -0000 Author: adrian Date: Thu Aug 11 06:45:12 2011 New Revision: 224773 URL: http://svn.freebsd.org/changeset/base/224773 Log: Add the LOR and recursive lock error details. Modified: user/adrian/if_ath_tx/sys/dev/ath/README Modified: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 04:58:20 2011 (r224772) +++ user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 06:45:12 2011 (r224773) @@ -27,9 +27,6 @@ Things that need doing! Things that need investigating! -* Recursive HW TXQ's sometimes? Get some details about the the next one - -* LORs? Post some more details! (on STA join and node deletion?) * How should channel scanning be handled? Right now it's causing both a HW TXQ and SW TXQ / node flush; this means the BAW will need to be slid along. Eek. @@ -37,3 +34,65 @@ Things that need investigating! * When a node is flushed (but not being deleted) should the BAW also be updated? I don't think it is right now and this could be incorrect. +* LOR between the net80211 node lock and the txqs + +lock order reversal: + 1st 0x80a02738 ath1_txq1 (ath1_txq1) @ /data/freebsd/mips/if_ath_tx/src/sys/dev/ath/if_ath.c:4154 + 2nd 0xc086c6cc ath1_node_lock (ath1_node_lock) @ /data/freebsd/mips/if_ath_tx/src/sys/net80211/ieee80211_node.c:1702 +KDB: stack backtrace: +db_trace_thread+30 (?,?,?,?) ra 8038aacc sp c7713a88 sz 24 +db_trace_self+1c (?,?,?,?) ra 80074c3c sp c7713aa0 sz 24 +80074c08+34 (?,?,?,?) ra 801ce304 sp c7713ab8 sz 416 +kdb_backtrace+44 (?,?,?,?) ra 801e5dc0 sp c7713c58 sz 24 +801e5d8c+34 (?,?,?,?) ra 801e6a04 sp c7713c70 sz 32 +witness_checkorder+954 (?,?,?,?) ra 80186ea0 sp c7713c90 sz 88 +_mtx_lock_flags+c4 (?,?,?,?) ra 8029885c sp c7713ce8 sz 48 +ieee80211_free_node+40 (?,?,?,?) ra 80079c80 sp c7713d18 sz 48 +ath_tx_freebuf+68 (?,?,?,?) ra 80079d2c sp c7713d48 sz 40 +ath_tx_default_comp+34 (?,?,?,?) ra 8007d664 sp c7713d70 sz 24 +8007d2b0+3b4 (?,?,?,?) ra 8007df3c sp c7713d88 sz 64 +8007deb4+88 (?,?,?,?) ra 801dc284 sp c7713dc8 sz 48 +801dc19c+e8 (?,?,?,?) ra 801dcd4c sp c7713df8 sz 56 +taskqueue_thread_loop+60 (?,?,?,?) ra 8016c2c4 sp c7713e30 sz 40 +fork_exit+a8 (?,?,?,?) ra 80383210 sp c7713e58 sz 40 +fork_trampoline+10 (?,?,?,?) ra 0 sp c7713e80 sz 0 +pid 0 + + +* Recursive TXQ lock on interface destruction: + +drian-home-mips# ifconfig wlan0 destroy +ath1: ath_tx_node_flush: called +ar5212StopDmaReceive: dma failed to stop in 10ms +AR_CR=0x00000024 +AR_DIAG_SW=0x42000020 +wlan0: [00:1b:b1:58:f6:f0] send station disassociate (reason 8) +ath1: ath_tx_node_flush: called +panic: _mtx_lock_sleep: recursed on non-recursive mutex ath1_txq1 @ /data/freebsd/mips/if_ath_tx/src/sys/dev/ath/if_ath_tx.c:1854 + +KDB: enter: panic +[ thread pid 0 tid 100028 ] +Stopped at kdb_enter+0x4c: lui at,0x804c +db> bt +Tracing pid 0 tid 100028 td 0x80762900 +db_trace_thread+30 (?,?,?,?) ra 80072de0 sp c7717748 sz 24 +80072ccc+114 (0,?,ffffffff,?) ra 8007239c sp c7717760 sz 32 +80072014+388 (?,?,?,?) ra 80072520 sp c7717780 sz 168 +db_command_loop+70 (?,?,?,?) ra 80074be4 sp c7717828 sz 24 +80074af0+f4 (?,?,?,?) ra 801cdf78 sp c7717840 sz 424 +kdb_trap+104 (?,?,?,?) ra 8037ee00 sp c77179e8 sz 40 +trap+bd8 (?,?,?,?) ra 80376d50 sp c7717a10 sz 168 +MipsKernGenException+134 (0,4,803f6b90,109) ra 801ce204 sp c7717ab8 sz 200 +kdb_enter+4c (?,?,?,?) ra 80196e38 sp c7717b80 sz 24 +panic+f4 (?,80a0274c,803ddea4,73e) ra 80186c9c sp c7717b98 sz 40 +_mtx_lock_sleep+68 (?,?,?,?) ra 80186f14 sp c7717bc0 sz 32 +_mtx_lock_flags+138 (?,?,?,?) ra 80085f74 sp c7717be0 sz 48 +ath_tx_node_flush+70 (?,?,?,?) ra 80086028 sp c7717c10 sz 40 +ath_tx_tid_cleanup+10 (?,?,?,?) ra 8007c654 sp c7717c38 sz 24 +8007c5fc+58 (?,?,?,?) ra 80298278 sp c7717c50 sz 32 +8029815c+11c (?,?,?,?) ra 80298958 sp c7717c70 sz 24 +ieee80211_free_node+13c (?,?,?,?) ra 80079c80 sp c7717c88 sz 48 +ath_tx_freebuf+68 (?,?,?,?) ra 80079d2c sp c7717cb8 sz 40 +ath_tx_default_comp+34 (?,?,?,?) ra 80079ef0 sp c7717ce0 sz 24 +80079e3c+b4 (?,?,?,?) ra 0 sp c7717cf8 sz 0 +pid 0 From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 08:51:53 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AAE87106564A; Thu, 11 Aug 2011 08:51:53 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 902478FC15; Thu, 11 Aug 2011 08:51:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7B8prwG083825; Thu, 11 Aug 2011 08:51:53 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7B8prYL083821; Thu, 11 Aug 2011 08:51:53 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108110851.p7B8prYL083821@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 08:51:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224774 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 08:51:53 -0000 Author: adrian Date: Thu Aug 11 08:51:53 2011 New Revision: 224774 URL: http://svn.freebsd.org/changeset/base/224774 Log: Fix the TXQ recursive locking bug that sometimes occurs when an interface is destroyed. Only lock the TXQ if it isn't locked by us. Modified: user/adrian/if_ath_tx/sys/dev/ath/README user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 06:45:12 2011 (r224773) +++ user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 08:51:53 2011 (r224774) @@ -59,8 +59,15 @@ fork_trampoline+10 (?,?,?,?) ra 0 sp c77 pid 0 + + +Fixed issues: + * Recursive TXQ lock on interface destruction: + - Fixed by only locking the TXQ in ath_tx_node_flush if the TXQ + isn't already locked by us. + drian-home-mips# ifconfig wlan0 destroy ath1: ath_tx_node_flush: called ar5212StopDmaReceive: dma failed to stop in 10ms Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 11 06:45:12 2011 (r224773) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 11 08:51:53 2011 (r224774) @@ -1818,41 +1818,34 @@ ath_tx_tid_free_pkts(struct ath_softc *s /* * Flush all software queued packets for the given node. * - * XXX there's a recursive lock here which currently panics - * XXX the kernel. - * - * bringing the interface down/up causes a flush on interface - * _up_; the stack looks like this: - * - * - * ath_tx_node_flush - locks each hardware txq - * ieee80211_free_node - * ath_tx_freebuf - * ath_tx_default_comp - * ath_tx_processq - locks the hardware txq - * - * To fix? Not (yet) sure. Perhaps unsched the TID in freebuf - * if there's no further buffers for it; then only flush - * nodes w/ a lock below if the qlen is 0. But can the tid - * txq length be checked without having the txq locked? - * It'll be locked by someone, but if this node is being freed, - * in theory all references to the node should be released - * and thus there shouldn't be any packets in the TIDs for that - * node. Hm. + * Work around recursive TXQ locking. + * This occurs when a completion handler frees the last buffer + * for a node, and the node is thus freed. This causes the node + * to be cleaned up, which ends up calling ath_tx_node_flush. */ void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an) { int tid; + int is_owned; for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) { struct ath_tid *atid = &an->an_tid[tid]; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; - ATH_TXQ_LOCK(txq); + /* + * Only lock if we don't have it locked. + * It may be locked already if this is being called + * when the last buffer for an ieee80211_node is + * being freed. + */ + is_owned = ATH_TXQ_IS_LOCKED(txq); + if (! is_owned) + ATH_TXQ_LOCK(txq); /* Remove this tid from the list of active tids */ ath_tx_tid_unsched(sc, an, tid); - ATH_TXQ_UNLOCK(txq); + if (! is_owned) + ATH_TXQ_UNLOCK(txq); /* Free packets */ ath_tx_tid_free_pkts(sc, an, tid); Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Thu Aug 11 06:45:12 2011 (r224773) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Thu Aug 11 08:51:53 2011 (r224774) @@ -249,6 +249,7 @@ struct ath_txq { #define ATH_TXQ_LOCK(_tq) mtx_lock(&(_tq)->axq_lock) #define ATH_TXQ_UNLOCK(_tq) mtx_unlock(&(_tq)->axq_lock) #define ATH_TXQ_LOCK_ASSERT(_tq) mtx_assert(&(_tq)->axq_lock, MA_OWNED) +#define ATH_TXQ_IS_LOCKED(_tq) mtx_owned(&(_tq)->axq_lock) #define ATH_TXQ_INSERT_TAIL(_tq, _elm, _field) do { \ STAILQ_INSERT_TAIL(&(_tq)->axq_q, (_elm), _field); \ From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 19:21:48 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6AFC1065672; Thu, 11 Aug 2011 19:21:48 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8D7358FC0A; Thu, 11 Aug 2011 19:21:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7BJLmOo005474; Thu, 11 Aug 2011 19:21:48 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7BJLmXm005472; Thu, 11 Aug 2011 19:21:48 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108111921.p7BJLmXm005472@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 19:21:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224785 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 19:21:48 -0000 Author: adrian Date: Thu Aug 11 19:21:48 2011 New Revision: 224785 URL: http://svn.freebsd.org/changeset/base/224785 Log: Another LOR Modified: user/adrian/if_ath_tx/sys/dev/ath/README Modified: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 15:52:06 2011 (r224784) +++ user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 11 19:21:48 2011 (r224785) @@ -58,8 +58,38 @@ fork_exit+a8 (?,?,?,?) ra 80383210 sp c7 fork_trampoline+10 (?,?,?,?) ra 0 sp c7713e80 sz 0 pid 0 +And another LOR: - +lock order reversal: + 1st 0xc08316cc ath0_node_lock (ath0_node_lock) @ /data/freebsd/mips/if_ath_tx/src/sys/net80211/ieee80211_node.c:1702 + 2nd 0x80a03738 ath0_txq1 (ath0_txq1) @ /data/freebsd/mips/if_ath_tx/src/sys/dev/ath/if_ath_tx.c:1854 +KDB: stack backtrace: +db_trace_thread+30 (?,?,?,?) ra 8038ab6c sp c7bf9798 sz 24 +db_trace_self+1c (?,?,?,?) ra 80074c3c sp c7bf97b0 sz 24 +80074c08+34 (?,?,?,?) ra 801ce3a4 sp c7bf97c8 sz 416 +kdb_backtrace+44 (?,?,?,?) ra 801e5e60 sp c7bf9968 sz 24 +801e5e2c+34 (?,?,?,?) ra 801e6aa4 sp c7bf9980 sz 32 +witness_checkorder+954 (?,?,?,?) ra 80186f40 sp c7bf99a0 sz 88 +_mtx_lock_flags+c4 (?,?,?,?) ra 80085fc4 sp c7bf99f8 sz 48 +ath_tx_node_flush+8c (?,?,?,?) ra 800860d0 sp c7bf9a28 sz 48 +ath_tx_tid_cleanup+10 (?,?,?,?) ra 8007c654 sp c7bf9a58 sz 24 +8007c5fc+58 (?,?,?,?) ra 80298318 sp c7bf9a70 sz 32 +802981fc+11c (?,?,?,?) ra 80298914 sp c7bf9a90 sz 24 +ieee80211_free_node+58 (?,?,?,?) ra 8029a110 sp c7bf9aa8 sz 48 +8029a078+98 (?,?,?,?) ra 8029c044 sp c7bf9ad8 sz 40 +ieee80211_sta_join+20c (?,?,?,?) ra 8028e720 sp c7bf9b00 sz 40 +8028e688+98 (?,?,?,?) ra 80290148 sp c7bf9b28 sz 48 +802900e4+64 (?,?,?,?) ra 80290948 sp c7bf9b58 sz 72 +802903f4+554 (?,?,?,?) ra 80292604 sp c7bf9ba0 sz 128 +ieee80211_ioctl+2c8 (?,?,?,?) ra 802b9e84 sp c7bf9c20 sz 48 +in_control+1c8 (?,?,?,?) ra 802514d8 sp c7bf9c50 sz 88 +ifioctl+13cc (?,?,80aaada0,80dda900) ra 801ee8c0 sp c7bf9ca8 sz 144 +soo_ioctl+3b0 (?,?,?,?) ra 801e91c4 sp c7bf9d38 sz 40 +kern_ioctl+23c (?,?,?,?) ra 801e936c sp c7bf9d60 sz 64 +ioctl+130 (?,?,?,?) ra 8037eb6c sp c7bf9da0 sz 56 +trap+8a4 (?,?,?,?) ra 80376fec sp c7bf9dd8 sz 168 +MipsUserGenException+10c (?,?,?,40818e20) ra 0 sp c7bf9e80 sz 0 +pid 1510 Fixed issues: From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 19:31:34 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50289106566B; Thu, 11 Aug 2011 19:31:34 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 404388FC08; Thu, 11 Aug 2011 19:31:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7BJVY3u005797; Thu, 11 Aug 2011 19:31:34 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7BJVYLg005795; Thu, 11 Aug 2011 19:31:34 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108111931.p7BJVYLg005795@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 19:31:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224786 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 19:31:34 -0000 Author: adrian Date: Thu Aug 11 19:31:33 2011 New Revision: 224786 URL: http://svn.freebsd.org/changeset/base/224786 Log: Update the BAW when packets from an aggregate TID session are being deleted. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 11 19:21:48 2011 (r224785) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 11 19:31:33 2011 (r224786) @@ -1809,7 +1809,14 @@ ath_tx_tid_free_pkts(struct ath_softc *s if (bf == NULL) { break; } - /* XXX update BAW if needed? */ + + /* + * If the current TID is running AMPDU, update + * the BAW. + */ + if (ath_tx_ampdu_running(sc, an, tid)) + ath_tx_update_baw(sc, an, atid, + SEQNO(bf->bf_state.bfs_seqno)); ATH_TXQ_REMOVE_HEAD(atid, bf_list); ath_tx_freebuf(sc, bf, -1); } From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 20:29:38 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A520B106567A; Thu, 11 Aug 2011 20:29:38 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 94F7C8FC17; Thu, 11 Aug 2011 20:29:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7BKTcjT007574; Thu, 11 Aug 2011 20:29:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7BKTcW0007571; Thu, 11 Aug 2011 20:29:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108112029.p7BKTcW0007571@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 20:29:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224787 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 20:29:38 -0000 Author: adrian Date: Thu Aug 11 20:29:38 2011 New Revision: 224787 URL: http://svn.freebsd.org/changeset/base/224787 Log: Add two new statistics fields, for software retries and software retry failures. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Thu Aug 11 19:31:33 2011 (r224786) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Thu Aug 11 20:29:38 2011 (r224787) @@ -729,6 +729,10 @@ ath_sysctl_stats_attach(struct ath_softc &sc->sc_stats.ast_tx_timerexpired, 0, "TX exceeded TX_TIMER register"); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_desccfgerr", CTLFLAG_RD, &sc->sc_stats.ast_tx_desccfgerr, 0, "TX Descriptor Cfg Error"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretries", CTLFLAG_RD, + &sc->sc_stats.ast_tx_swretries, 0, "TX software retry count"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretrymax", CTLFLAG_RD, + &sc->sc_stats.ast_tx_swretrymax, 0, "TX software retry max reached"); /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Thu Aug 11 19:31:33 2011 (r224786) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Thu Aug 11 20:29:38 2011 (r224787) @@ -134,7 +134,9 @@ struct ath_stats { u_int32_t ast_tx_xtxop; /* tx exceeded TXOP */ u_int32_t ast_tx_timerexpired; /* tx exceeded TX_TIMER */ u_int32_t ast_tx_desccfgerr; /* tx desc cfg error */ - u_int32_t ast_pad[13]; + u_int32_t ast_tx_swretries; /* software TX retries */ + u_int32_t ast_tx_swretrymax; /* software TX retry max limit reach */ + u_int32_t ast_pad[11]; }; #define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 20:30:23 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 545D0106564A; Thu, 11 Aug 2011 20:30:23 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 448D58FC0A; Thu, 11 Aug 2011 20:30:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7BKUNVx007640; Thu, 11 Aug 2011 20:30:23 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7BKUNJw007638; Thu, 11 Aug 2011 20:30:23 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108112030.p7BKUNJw007638@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 20:30:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224788 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 20:30:23 -0000 Author: adrian Date: Thu Aug 11 20:30:22 2011 New Revision: 224788 URL: http://svn.freebsd.org/changeset/base/224788 Log: Add another TXQ method, this time to prepend packets to the TXQ head. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Thu Aug 11 20:29:38 2011 (r224787) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Thu Aug 11 20:30:22 2011 (r224788) @@ -251,6 +251,10 @@ struct ath_txq { #define ATH_TXQ_LOCK_ASSERT(_tq) mtx_assert(&(_tq)->axq_lock, MA_OWNED) #define ATH_TXQ_IS_LOCKED(_tq) mtx_owned(&(_tq)->axq_lock) +#define ATH_TXQ_INSERT_HEAD(_tq, _elm, _field) do { \ + STAILQ_INSERT_HEAD(&(_tq)->axq_q, (_elm), _field); \ + (_tq)->axq_depth++; \ +} while (0) #define ATH_TXQ_INSERT_TAIL(_tq, _elm, _field) do { \ STAILQ_INSERT_TAIL(&(_tq)->axq_q, (_elm), _field); \ (_tq)->axq_depth++; \ From owner-svn-src-user@FreeBSD.ORG Thu Aug 11 20:34:58 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A47D106566B; Thu, 11 Aug 2011 20:34:58 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 09EDF8FC16; Thu, 11 Aug 2011 20:34:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7BKYvZr007812; Thu, 11 Aug 2011 20:34:57 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7BKYvTF007810; Thu, 11 Aug 2011 20:34:57 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108112034.p7BKYvTF007810@svn.freebsd.org> From: Adrian Chadd Date: Thu, 11 Aug 2011 20:34:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224789 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 20:34:58 -0000 Author: adrian Date: Thu Aug 11 20:34:57 2011 New Revision: 224789 URL: http://svn.freebsd.org/changeset/base/224789 Log: Implement a very basic software re-transmit algorithm. If an ADDBA session frame fails, and it's not during some kind of queue cleanup, attempt to retransmit the thing. The retransmit method is very simple - set some bits to indicate its a retry, prepend to the front of the queue, and schedule the TID for activity in the future. The frame will be rescheduled and resubmitted to the hardware for us by the normal TX path. This doesn't attempt a rate lookup; it re-uses the same rate information as the original frame. This means that if TX is failing because the rate selection isn't optimal, it's likely going to keep failing. I'll investigate that in the future. Use a (currently) hard-coded max of 10 retransmits. This is 10 retransmits on top of whatever the rate control module attempts, which may be 4 or 10 frames. This means a frame could be retried from 40 to 100 times. Finally, a BAR isn't sent if TX does finally fail. I'll worry about BAR handling and session teardown handling soon. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 11 20:30:22 2011 (r224788) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 11 20:34:57 2011 (r224789) @@ -119,6 +119,11 @@ __FBSDID("$FreeBSD$"); #define BAW_WITHIN(_start, _bawsz, _seqno) \ ((((_seqno) - (_start)) & 4095) < (_bawsz)) +/* + * How many retries to perform in software + */ +#define SWMAX_RETRIES 10 + static struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an, int tid); static int ath_tx_ampdu_pending(struct ath_softc *sc, struct ath_node *an, @@ -1910,8 +1915,68 @@ ath_tx_normal_comp(struct ath_softc *sc, } #endif +static void +ath_tx_set_retry(struct ath_softc *sc, struct ath_buf *bf) +{ + struct ieee80211_frame *wh; + + sc->sc_stats.ast_tx_swretries++; + bf->bf_state.bfs_isretried = 1; + bf->bf_state.bfs_retries ++; + wh = mtod(bf->bf_m, struct ieee80211_frame *); + wh->i_fc[1] |= IEEE80211_FC1_RETRY; +} + +/* + * Handle retrying an unaggregate frame in an aggregate + * session. + * + * If too many retries occur, pause the TID, wait for + * any further retransmits (as there's no reason why + * non-aggregate frames in an aggregate session are + * transmitted in-order; they just have to be in-BAW) + * and then queue a BAR. + */ +static void +ath_tx_aggr_retry_unaggr(struct ath_softc *sc, struct ath_buf *bf) +{ + struct ieee80211_node *ni = bf->bf_node; + struct ath_node *an = ATH_NODE(ni); + int tid = bf->bf_state.bfs_tid; + struct ath_tid *atid = &an->an_tid[tid]; + struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + + ATH_TXQ_LOCK_ASSERT(txq); + + if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { + sc->sc_stats.ast_tx_swretrymax++; + + /* Update BAW anyway */ + ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + + /* Free buffer, bf is free after this call */ + ath_tx_default_comp(sc, bf, 0); + return; + } + + /* + * This increments the retry counter as well as + * sets the retry flag in the ath_buf and packet + * body. + */ + ath_tx_set_retry(sc, bf); + + /* + * Insert this at the head of the queue, so it's + * retried before any current/subsequent frames. + */ + ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); + ath_tx_tid_sched(sc, an, atid->tid); +} + /* - * Handle completion of aggregate frames. + * Handle completion of unaggregated frames in an ADDBA + * session. * * Fail is set to 1 if the entry is being freed via a call to * ath_tx_draintxq(). @@ -1923,6 +1988,7 @@ ath_tx_aggr_comp(struct ath_softc *sc, s struct ath_node *an = ATH_NODE(ni); int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; + struct ath_tx_status *ts = &bf->bf_status.ds_txstat; if (tid == IEEE80211_NONQOS_TID) device_printf(sc->sc_dev, "%s: TID=16!\n", __func__); @@ -1930,19 +1996,13 @@ ath_tx_aggr_comp(struct ath_softc *sc, s __func__, bf, bf->bf_state.bfs_tid); /* - * Not success and have retries left? - * - * Mark as retry, requeue at head of queue - */ - - /* - * Not success and out of retries? - * - * Need to wait for the hardware TXQ to finish draining, - * then once we know what was successfully TXed and what - * wasn't, we send a BAR to advance the pointer to that - * place. + * Don't bother with the retry check if all frames + * are being failed (eg during queue deletion.) */ + if (fail == 0 && ts->ts_status & HAL_TXERR_XRETRY) { + ath_tx_aggr_retry_unaggr(sc, bf); + return; + } /* Success? Complete */ DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: TID=%d, seqno %d\n", From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 04:06:44 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB906106564A; Fri, 12 Aug 2011 04:06:43 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D29E48FC12; Fri, 12 Aug 2011 04:06:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7C46h50021478; Fri, 12 Aug 2011 04:06:43 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7C46hjE021475; Fri, 12 Aug 2011 04:06:43 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108120406.p7C46hjE021475@svn.freebsd.org> From: Adrian Chadd Date: Fri, 12 Aug 2011 04:06:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224790 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 04:06:44 -0000 Author: adrian Date: Fri Aug 12 04:06:43 2011 New Revision: 224790 URL: http://svn.freebsd.org/changeset/base/224790 Log: Begin fleshing out the cleanup code needed when transitioning from aggregation to non-aggregation on a TID. This will pause the TID scheduling and let hardware-queued packets complete, before restarting the (now non-aggregate) TID. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 11 20:34:57 2011 (r224789) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 04:06:43 2011 (r224790) @@ -1735,6 +1735,7 @@ ath_tx_tid_init(struct ath_softc *sc, st atid->baw_head = atid->baw_tail = 0; atid->paused = 0; atid->sched = 0; + atid->cleanup_inprogress = 0; if (i == IEEE80211_NONQOS_TID) atid->ac = WME_AC_BE; else @@ -1915,6 +1916,57 @@ ath_tx_normal_comp(struct ath_softc *sc, } #endif +#ifdef notyet +/* + * Handle cleanup of aggregate state packets that aren't + * an A-MPDU. + */ +static void +ath_tx_comp_cleanup(struct ath_softc *sc, struct ath_buf *bf) +{ + +} +#endif + +/* + * Performs transmit side cleanup when TID changes from aggregated to + * unaggregated. + * - Discard all retry frames from the s/w queue. + * - Fix the tx completion function for all buffers in s/w queue. + * - Count the number of unacked frames, and let transmit completion + * handle it later. + */ +static void +ath_tx_cleanup(struct ath_softc *sc, struct ath_node *an, int tid) +{ + struct ath_tid *atid = &an->an_tid[tid]; + struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + + ATH_TXQ_LOCK(txq); + + /* + * + Discard retry frames in the queue + * + Fix the completion function to be non-aggregate + */ + + /* Pause the TID */ + + /* + * Calculate what incomplete frames exist, based on + * the current BAW size. Ie, what frames have been + * added to the TX hardware queue for this TID but + * not yet ACKed. + */ + + /* + * If cleanup is required, defer TID scheduling + * until all the HW queued packets have been + * sent. + */ + + ATH_TXQ_UNLOCK(txq); +} + static void ath_tx_set_retry(struct ath_softc *sc, struct ath_buf *bf) { @@ -1995,6 +2047,20 @@ ath_tx_aggr_comp(struct ath_softc *sc, s DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: tid=%d\n", __func__, bf, bf->bf_state.bfs_tid); + + /* + * If a cleanup is in progress, punt to comp_cleanup; + * rather than handling it here. It's thus their + * responsibility to do the BAW update, track the + * incomplete packet count, etc. + */ +#ifdef notyet + if (atid->cleanup_inprogress) { + ath_tx_comp_cleanup(sc, bf); + return; + } +#endif + /* * Don't bother with the retry check if all frames * are being failed (eg during queue deletion.) @@ -2306,11 +2372,12 @@ void ath_addba_stop(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap) { struct ath_softc *sc = ni->ni_ic->ic_ifp->if_softc; -#if 0 int tid = WME_AC_TO_TID(tap->txa_ac); struct ath_node *an = ATH_NODE(ni); +#if 0 struct ath_tid *atid = an->an_tid[tid]; #endif DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); sc->sc_addba_stop(ni, tap); + ath_tx_cleanup(sc, an, tid); } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Thu Aug 11 20:34:57 2011 (r224789) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Fri Aug 12 04:06:43 2011 (r224790) @@ -106,6 +106,17 @@ struct ath_tid { int paused; /* >0 if the TID has been paused */ /* + * Is the TID being cleaned up after a transition + * from aggregation to non-aggregation? + * When this is set to 1, this TID will be paused + * and no further traffic will be queued until all + * the hardware packets pending for this TID have been + * TXed/completed; at which point (non-aggregation) + * traffic will resume being TXed. + */ + int cleanup_inprogress; + + /* * The following implements a ring representing * the frames in the current BAW. * To avoid copying the array content each time From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 09:18:02 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A434B1065678; Fri, 12 Aug 2011 09:18:02 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 938118FC2A; Fri, 12 Aug 2011 09:18:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7C9I2U6030780; Fri, 12 Aug 2011 09:18:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7C9I251030777; Fri, 12 Aug 2011 09:18:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108120918.p7C9I251030777@svn.freebsd.org> From: Adrian Chadd Date: Fri, 12 Aug 2011 09:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224792 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 09:18:02 -0000 Author: adrian Date: Fri Aug 12 09:18:02 2011 New Revision: 224792 URL: http://svn.freebsd.org/changeset/base/224792 Log: Commit some (very untested) initial code to clean up after a DELBA. Once a DELBA is received, there may be: * packets in the software TX TID queue * packets in the hardware queue (aggregate or individual frames) The software TX queue is fine - those packets don't yet have a personality as they haven't been "scheduled". The packets in the hardware TX queues need to be completed or deleted. So the logic here is: * packets in the SWQ which are retries are discarded; * packets in the SWQ which aren't retries are modified to have their completion handler be the default, non-aggregate one * if there are any packets left in the hardware queue, mark the TID as "cleanup" and keep track of how many are outstanding * if the TID is "cleanup", pause the TID so no further traffic is scheduled. Then, when the packets are completed, the "incomplete" packet count is updated and when it hits 0 (ie, all packets on the hardware queue) it'll be unpaused and will begin running as a non-aggregate TID. To avoid races, pause the TID in the addba handler before disabling the addba state and calling ath_tx_cleanup(). Since the TXQ lock is held for the duration of queue operations, any packets that snuck in before the TID was paused will be downgraded to non-aggregate status by ath_tx_cleanup(). Obtained from: Atheros Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 07:04:16 2011 (r224791) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 09:18:02 2011 (r224792) @@ -1916,53 +1916,121 @@ ath_tx_normal_comp(struct ath_softc *sc, } #endif -#ifdef notyet /* - * Handle cleanup of aggregate state packets that aren't + * Handle cleanup of aggregate session packets that aren't * an A-MPDU. */ static void ath_tx_comp_cleanup(struct ath_softc *sc, struct ath_buf *bf) { + struct ieee80211_node *ni = bf->bf_node; + struct ath_node *an = ATH_NODE(ni); + int tid = bf->bf_state.bfs_tid; + struct ath_tid *atid = &an->an_tid[tid]; + struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + + device_printf(sc->sc_dev, "%s: TID %d: incomp=%d\n", + __func__, tid, atid->incomp); + + ATH_TXQ_LOCK_ASSERT(txq); + + atid->incomp--; + if (atid->incomp == 0) { + device_printf(sc->sc_dev, "%s: TID %d: cleaned up! resume!\n", + __func__, tid); + atid->cleanup_inprogress = 0; + ath_tx_tid_resume(sc, atid); + } + ath_tx_default_comp(sc, bf, 0); } -#endif /* * Performs transmit side cleanup when TID changes from aggregated to * unaggregated. + * * - Discard all retry frames from the s/w queue. * - Fix the tx completion function for all buffers in s/w queue. * - Count the number of unacked frames, and let transmit completion * handle it later. + * + * The caller is responsible for pausing the TID. + * The caller is responsible for locking TXQ. */ static void ath_tx_cleanup(struct ath_softc *sc, struct ath_node *an, int tid) { struct ath_tid *atid = &an->an_tid[tid]; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + struct ieee80211_tx_ampdu *tap; + struct ath_buf *bf, *bf_next; - ATH_TXQ_LOCK(txq); + device_printf(sc->sc_dev, "%s: TID %d: called\n", __func__, tid); + + ATH_TXQ_LOCK_ASSERT(txq); /* + * Update the frames in the software TX queue: + * * + Discard retry frames in the queue * + Fix the completion function to be non-aggregate */ + bf = STAILQ_FIRST(&atid->axq_q); + while (bf) { + if (bf->bf_state.bfs_isretried) { + bf_next = STAILQ_NEXT(bf, bf_list); + STAILQ_REMOVE(&atid->axq_q, bf, ath_buf, bf_list); + atid->axq_depth--; + ath_tx_update_baw(sc, an, atid, + SEQNO(bf->bf_state.bfs_seqno)); + /* + * Call the default completion handler with "fail" just + * so upper levels are suitably notified about this. + */ + ath_tx_default_comp(sc, bf, 1); + bf = bf_next; + continue; + } + /* Give these the default completion handler */ + bf->bf_comp = NULL; + bf = STAILQ_NEXT(bf, bf_list); + } + /* The caller is required to pause the TID */ +#if 0 /* Pause the TID */ + ath_tx_tid_pause(sc, atid); +#endif /* - * Calculate what incomplete frames exist, based on - * the current BAW size. Ie, what frames have been + * Calculate what hardware-queued frames exist based + * on the current BAW size. Ie, what frames have been * added to the TX hardware queue for this TID but * not yet ACKed. */ + tap = ath_tx_get_tx_tid(an, tid); + while (atid->baw_head != atid->baw_tail) { + if (atid->tx_buf[atid->baw_head]) { + atid->incomp++; + atid->cleanup_inprogress = 1; + atid->tx_buf[atid->baw_head] = NULL; + } + INCR(atid->baw_head, ATH_TID_MAX_BUFS); + INCR(tap->txa_start, IEEE80211_SEQ_RANGE); + } /* * If cleanup is required, defer TID scheduling * until all the HW queued packets have been * sent. */ + if (! atid->cleanup_inprogress) + ath_tx_tid_resume(sc, atid); + + if (atid->cleanup_inprogress) + device_printf(sc->sc_dev, + "%s: TID %d: cleanup needed: %d packets\n", + __func__, tid, atid->incomp); ATH_TXQ_UNLOCK(txq); } @@ -2051,15 +2119,13 @@ ath_tx_aggr_comp(struct ath_softc *sc, s /* * If a cleanup is in progress, punt to comp_cleanup; * rather than handling it here. It's thus their - * responsibility to do the BAW update, track the - * incomplete packet count, etc. + * responsibility to clean up, call the completion + * function in net80211, update rate control, etc. */ -#ifdef notyet if (atid->cleanup_inprogress) { ath_tx_comp_cleanup(sc, bf); return; } -#endif /* * Don't bother with the retry check if all frames @@ -2363,10 +2429,6 @@ ath_addba_response(struct ieee80211_node /* * Stop ADDBA on a queue. - * - * In theory, queued ath_bufs should be turned back into non-aggregate - * buffers. I'm not sure what to do about packets currently queued - * to the hardware. */ void ath_addba_stop(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap) @@ -2374,10 +2436,20 @@ ath_addba_stop(struct ieee80211_node *ni struct ath_softc *sc = ni->ni_ic->ic_ifp->if_softc; int tid = WME_AC_TO_TID(tap->txa_ac); struct ath_node *an = ATH_NODE(ni); -#if 0 - struct ath_tid *atid = an->an_tid[tid]; -#endif + struct ath_tid *atid = &an->an_tid[tid]; + struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); + + /* Pause TID traffic early, so there aren't any races */ + ATH_TXQ_LOCK(txq); + ath_tx_tid_pause(sc, atid); + ATH_TXQ_UNLOCK(txq); + + /* There's no need to hold the TXQ lock here */ sc->sc_addba_stop(ni, tap); + + ATH_TXQ_LOCK(txq); ath_tx_cleanup(sc, an, tid); + ATH_TXQ_UNLOCK(txq); } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Fri Aug 12 07:04:16 2011 (r224791) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Fri Aug 12 09:18:02 2011 (r224792) @@ -115,6 +115,12 @@ struct ath_tid { * traffic will resume being TXed. */ int cleanup_inprogress; + /* + * How many hardware-queued packets are + * waiting to be cleaned up. + * This is only valid if cleanup_inprogress is 1. + */ + int incomp; /* * The following implements a ring representing From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 14:07:18 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9653D106564A; Fri, 12 Aug 2011 14:07:18 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B1B68FC0C; Fri, 12 Aug 2011 14:07:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CE7IiP065606; Fri, 12 Aug 2011 14:07:18 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CE7IDE065602; Fri, 12 Aug 2011 14:07:18 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108121407.p7CE7IDE065602@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 12 Aug 2011 14:07:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224795 - in user/gabor/tre-integration: contrib/tre/lib include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 14:07:18 -0000 Author: gabor Date: Fri Aug 12 14:07:18 2011 New Revision: 224795 URL: http://svn.freebsd.org/changeset/base/224795 Log: - Use malloc() instead of alloca() - Introduce REG_GNU for GNU extensions - Only process GNU-specific word-boundary notation if REG_GNU is specified - Fix a compilation error Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre.h user/gabor/tre-integration/include/regex.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 11:43:56 2011 (r224794) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 14:07:18 2011 (r224795) @@ -259,10 +259,13 @@ static int fastcmp(const void *, const v { \ if (fg->icase) \ { \ - wp = alloca(plen * sizeof(tre_char_t)); \ + wp = xmalloc(plen * sizeof(tre_char_t)); \ + if (wp == NULL) \ + return REG_ESPACE; \ for (int i = 0; i < plen; i++) \ wp[i] = towlower(pat[i]); \ _CALC_BMGS(arr, wp, plen); \ + free(wp); \ } \ else \ _CALC_BMGS(arr, pat, plen); \ @@ -271,10 +274,13 @@ static int fastcmp(const void *, const v { \ if (fg->icase) \ { \ - p = alloca(plen); \ + p = xmalloc(plen); \ + if (p == NULL) \ + return REG_ESPACE; \ for (int i = 0; i < plen; i++) \ p[i] = tolower(pat[i]); \ _CALC_BMGS(arr, p, plen); \ + free(p); \ } \ else \ _CALC_BMGS(arr, pat, plen); \ @@ -393,7 +399,8 @@ tre_fastcomp(fastmatch_t *fg, const tre_ pat++; } - if ((n >= 14) && + /* Handle word-boundary matching when GNU extensions are enabled */ + if ((cflags & REG_GNU) && (n >= 14) && (memcmp(pat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && (memcmp(pat + n - 7, TRE_CHAR("[[:>:]]"), 7 * sizeof(tre_char_t)) == 0)) @@ -439,6 +446,10 @@ tre_fastcomp(fastmatch_t *fg, const tre_ return REG_OK; } +/* + * Executes matching of the precompiled pattern on the input string. + * Returns REG_OK or REG_NOMATCH depending on if we find a match or not. + */ int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len, tre_str_type_t type, int nmatch, regmatch_t pmatch[]) @@ -480,7 +491,7 @@ tre_fastexec(const fastmatch_t *fg, cons { /* Simple text comparison. */ if (!((fg->bol && fg->eol) && - (type == STR_WIDE ? (wlen != fg->wlen) : (len != fg->len)))) + (type == STR_WIDE ? (len != fg->wlen) : (len != fg->len)))) { /* Determine where in data to start search at. */ j = fg->eol ? len - (type == STR_WIDE ? fg->wlen : fg->len) : 0; Modified: user/gabor/tre-integration/contrib/tre/lib/tre.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre.h Fri Aug 12 11:43:56 2011 (r224794) +++ user/gabor/tre-integration/contrib/tre/lib/tre.h Fri Aug 12 14:07:18 2011 (r224795) @@ -89,6 +89,7 @@ typedef enum { #define REG_RIGHT_ASSOC (REG_LITERAL << 1) #define REG_UNGREEDY (REG_RIGHT_ASSOC << 1) #define REG_PEND (REG_UNGREEDY << 1) +#define REG_GNU (REG_PEND << 1) /* POSIX tre_regexec() flags. */ #define REG_NOTBOL 1 Modified: user/gabor/tre-integration/include/regex.h ============================================================================== --- user/gabor/tre-integration/include/regex.h Fri Aug 12 11:43:56 2011 (r224794) +++ user/gabor/tre-integration/include/regex.h Fri Aug 12 14:07:18 2011 (r224795) @@ -81,6 +81,7 @@ typedef enum { #define REG_RIGHT_ASSOC (REG_LITERAL << 1) #define REG_UNGREEDY (REG_RIGHT_ASSOC << 1) #define REG_PEND (REG_UNGREEDY << 1) +#define REG_GNU (REG_PEND << 1) /* POSIX tre_regexec() flags. */ #define REG_NOTBOL 1 From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 14:16:45 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB2B21065674; Fri, 12 Aug 2011 14:16:45 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D002C8FC13; Fri, 12 Aug 2011 14:16:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CEGjT6067104; Fri, 12 Aug 2011 14:16:45 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CEGjZm067102; Fri, 12 Aug 2011 14:16:45 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108121416.p7CEGjZm067102@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 12 Aug 2011 14:16:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224796 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 14:16:46 -0000 Author: gabor Date: Fri Aug 12 14:16:45 2011 New Revision: 224796 URL: http://svn.freebsd.org/changeset/base/224796 Log: - TRE-specific style changes Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 14:07:18 2011 (r224795) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 14:16:45 2011 (r224796) @@ -63,16 +63,14 @@ static int fastcmp(const void *, const v * SB strings. */ #define SKIP_CHARS(n) \ - do { \ - switch (type) \ - { \ - case STR_WIDE: \ - startptr = str_wide + n; \ - break; \ - default: \ - startptr = str_byte + n; \ - } \ - } while (0); \ + switch (type) \ + { \ + case STR_WIDE: \ + startptr = str_wide + n; \ + break; \ + default: \ + startptr = str_byte + n; \ + } /* * Converts the wide string pattern to SB/MB string and stores @@ -80,7 +78,7 @@ static int fastcmp(const void *, const v * converted string. */ #define STORE_MBS_PAT \ - do { \ + { \ size_t siz; \ \ siz = wcstombs(NULL, fg->wpattern, 0); \ @@ -92,7 +90,7 @@ static int fastcmp(const void *, const v return REG_ESPACE; \ wcstombs(fg->pattern, fg->wpattern, siz); \ fg->pattern[siz] = '\0'; \ - } while (0); \ + } \ /* * Compares the pattern to the input string at the position @@ -225,16 +223,16 @@ static int fastcmp(const void *, const v fg->qsBc_table = hashtable_init(fg->wlen * 4, sizeof(tre_char_t), \ sizeof(int)); \ for (unsigned int i = fg->hasdot + 1; i < fg->wlen; i++) \ - { \ - int k = fg->wlen - i; \ - hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ - if (fg->icase) \ - { \ - tre_char_t wc = iswlower(fg->wpattern[i]) ? \ - towupper(fg->wpattern[i]) : towlower(fg->wpattern[i]); \ - hashtable_put(fg->qsBc_table, &wc, &k); \ - } \ - } \ + { \ + int k = fg->wlen - i; \ + hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ + if (fg->icase) \ + { \ + tre_char_t wc = iswlower(fg->wpattern[i]) ? \ + towupper(fg->wpattern[i]) : towlower(fg->wpattern[i]); \ + hashtable_put(fg->qsBc_table, &wc, &k); \ + } \ + } /* * Fills in the good suffix table for SB/MB strings. @@ -386,41 +384,42 @@ tre_fastcomp(fastmatch_t *fg, const tre_ /* Remove end-of-line character ('$'). */ if ((n > 0) && (pat[n - 1] == TRE_CHAR('$'))) - { - fg->eol = true; - n--; - } + { + fg->eol = true; + n--; + } /* Remove beginning-of-line character ('^'). */ if (pat[0] == TRE_CHAR('^')) - { - fg->bol = true; - n--; - pat++; - } + { + fg->bol = true; + n--; + pat++; + } /* Handle word-boundary matching when GNU extensions are enabled */ if ((cflags & REG_GNU) && (n >= 14) && (memcmp(pat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && (memcmp(pat + n - 7, TRE_CHAR("[[:>:]]"), 7 * sizeof(tre_char_t)) == 0)) - { - n -= 14; - pat += 7; - fg->word = true; - } + { + n -= 14; + pat += 7; + fg->word = true; + } /* Look for ways to cheat...er...avoid the full regex engine. */ - for (unsigned int i = 0; i < n; i++) { - /* Can still cheat? */ - if ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || - (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) || - (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) || - (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/'))) + for (unsigned int i = 0; i < n; i++) + { + /* Can still cheat? */ + if ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || + (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) || + (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) || + (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/'))) continue; - else if (pat[i] == TRE_CHAR('.')) - fg->hasdot = i; - else + else if (pat[i] == TRE_CHAR('.')) + fg->hasdot = i; + else return REG_BADPAT; } @@ -574,6 +573,5 @@ fastcmp(const void *pat, const void *dat ret = -(i + 1); break; } - return ret; } From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 14:43:38 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31115106566B; Fri, 12 Aug 2011 14:43:38 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 074718FC0C; Fri, 12 Aug 2011 14:43:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CEhb6j068011; Fri, 12 Aug 2011 14:43:37 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CEhbPt068009; Fri, 12 Aug 2011 14:43:37 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108121443.p7CEhbPt068009@svn.freebsd.org> From: Adrian Chadd Date: Fri, 12 Aug 2011 14:43:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224798 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 14:43:38 -0000 Author: adrian Date: Fri Aug 12 14:43:37 2011 New Revision: 224798 URL: http://svn.freebsd.org/changeset/base/224798 Log: Don't assign sequence numbers to null qos frames. This creates a 1 packet hole in the receivers BAW, which causes packets to get received but put in the reassembly queue. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 14:26:47 2011 (r224797) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 14:43:37 2011 (r224798) @@ -1627,8 +1627,8 @@ ath_tx_tid_unsched(struct ath_softc *sc, /* * Assign a sequence number manually to the given frame. - * - * This should only be called for A-MPDU TX frames. + * + * This should only be called for A-MPDU TX frames. */ static ieee80211_seq ath_tx_tid_seqno_assign(struct ath_softc *sc, struct ieee80211_node *ni, @@ -1637,6 +1637,7 @@ ath_tx_tid_seqno_assign(struct ath_softc struct ieee80211_frame *wh; int tid, pri; ieee80211_seq seqno; + uint8_t subtype; /* TID lookup */ wh = mtod(m0, struct ieee80211_frame *); @@ -1645,13 +1646,28 @@ ath_tx_tid_seqno_assign(struct ath_softc DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: pri=%d, tid=%d, qos has seq=%d\n", __func__, pri, tid, IEEE80211_QOS_HAS_SEQ(wh)); + /* XXX Is it a control frame? Ignore */ + /* Does the packet require a sequence number? */ if (! IEEE80211_QOS_HAS_SEQ(wh)) return -1; - /* Manually assign sequence number */ - seqno = ni->ni_txseqs[tid]; - INCR(ni->ni_txseqs[tid], IEEE80211_SEQ_RANGE); + /* + * Is it a QOS NULL Data frame? Give it a sequence number of 0x0. + * The RX path of everything I've looked at doesn't include the NULL + * data frame sequence number in the aggregation state updates, so + * assigning it a sequence number there will cause a BAW hole on the + * RX side. + */ + /* XXX use the global sequence number instead? */ + subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; + if (subtype == IEEE80211_FC0_SUBTYPE_QOS_NULL) { + seqno = 0; + } else { + /* Manually assign sequence number */ + seqno = ni->ni_txseqs[tid]; + INCR(ni->ni_txseqs[tid], IEEE80211_SEQ_RANGE); + } *(uint16_t *)&wh->i_seq[0] = htole16(seqno << IEEE80211_SEQ_SEQ_SHIFT); M_SEQNO_SET(m0, seqno); From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 14:59:21 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7654106566B; Fri, 12 Aug 2011 14:59:21 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 96EAF8FC1C; Fri, 12 Aug 2011 14:59:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CExL5i068492; Fri, 12 Aug 2011 14:59:21 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CExL2m068490; Fri, 12 Aug 2011 14:59:21 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108121459.p7CExL2m068490@svn.freebsd.org> From: Adrian Chadd Date: Fri, 12 Aug 2011 14:59:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224799 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 14:59:21 -0000 Author: adrian Date: Fri Aug 12 14:59:21 2011 New Revision: 224799 URL: http://svn.freebsd.org/changeset/base/224799 Log: Fix some missing locks: * I didn't delete an ATH_TXQ_UNLOCK() from ath_tx_cleanup(); do that * Since the tid flush function now updates the BAW, the TXQ lock is required. This may cause another LOR with the net80211 node lock. I'll investigate this later. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 14:43:37 2011 (r224798) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 14:59:21 2011 (r224799) @@ -1873,19 +1873,13 @@ ath_tx_node_flush(struct ath_softc *sc, ATH_TXQ_LOCK(txq); /* Remove this tid from the list of active tids */ ath_tx_tid_unsched(sc, an, tid); - if (! is_owned) - ATH_TXQ_UNLOCK(txq); /* Free packets */ ath_tx_tid_free_pkts(sc, an, tid); - } + if (! is_owned) + ATH_TXQ_UNLOCK(txq); - /* - * Don't hold the node lock across free_pkts; - * freeing buffers may release the node and - * that will acquire the IEEE80211_NODE_LOCK (node table). - * That then causes a lock reversal. - */ + } } /* @@ -2047,8 +2041,6 @@ ath_tx_cleanup(struct ath_softc *sc, str device_printf(sc->sc_dev, "%s: TID %d: cleanup needed: %d packets\n", __func__, tid, atid->incomp); - - ATH_TXQ_UNLOCK(txq); } static void From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 15:06:12 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F9EA106564A; Fri, 12 Aug 2011 15:06:12 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F36E8FC14; Fri, 12 Aug 2011 15:06:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CF6CBx068744; Fri, 12 Aug 2011 15:06:12 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CF6CO5068741; Fri, 12 Aug 2011 15:06:12 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108121506.p7CF6CO5068741@svn.freebsd.org> From: Adrian Chadd Date: Fri, 12 Aug 2011 15:06:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224800 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 15:06:12 -0000 Author: adrian Date: Fri Aug 12 15:06:12 2011 New Revision: 224800 URL: http://svn.freebsd.org/changeset/base/224800 Log: Ok, don't use seqnum=0, use the non-qos seqnum (tid 16.) This matches what Linux does. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 14:59:21 2011 (r224799) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 12 15:06:12 2011 (r224800) @@ -1653,16 +1653,18 @@ ath_tx_tid_seqno_assign(struct ath_softc return -1; /* - * Is it a QOS NULL Data frame? Give it a sequence number of 0x0. + * Is it a QOS NULL Data frame? Give it a sequence number from + * the default TID (IEEE80211_NONQOS_TID.) + * * The RX path of everything I've looked at doesn't include the NULL * data frame sequence number in the aggregation state updates, so * assigning it a sequence number there will cause a BAW hole on the * RX side. */ - /* XXX use the global sequence number instead? */ subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; if (subtype == IEEE80211_FC0_SUBTYPE_QOS_NULL) { - seqno = 0; + seqno = ni->ni_txseqs[IEEE80211_NONQOS_TID]; + INCR(ni->ni_txseqs[IEEE80211_NONQOS_TID], IEEE80211_SEQ_RANGE); } else { /* Manually assign sequence number */ seqno = ni->ni_txseqs[tid]; From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 15:13:06 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC403106564A; Fri, 12 Aug 2011 15:13:06 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CC11C8FC14; Fri, 12 Aug 2011 15:13:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CFD651069672; Fri, 12 Aug 2011 15:13:06 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CFD6dv069670; Fri, 12 Aug 2011 15:13:06 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108121513.p7CFD6dv069670@svn.freebsd.org> From: Adrian Chadd Date: Fri, 12 Aug 2011 15:13:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224801 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 15:13:06 -0000 Author: adrian Date: Fri Aug 12 15:13:06 2011 New Revision: 224801 URL: http://svn.freebsd.org/changeset/base/224801 Log: Updates Modified: user/adrian/if_ath_tx/sys/dev/ath/README Modified: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/README Fri Aug 12 15:06:12 2011 (r224800) +++ user/adrian/if_ath_tx/sys/dev/ath/README Fri Aug 12 15:13:06 2011 (r224801) @@ -15,10 +15,19 @@ Things that need doing! * Send BAR when needed + after TX failure - + when else? + + when else? When shutting down an aggregation session and flushing packets? + + ieee80211_send_bar() will only work if IEEE80211_AGGR_RUNNING is set; + what's that mean for trying to send BAR frames during session teardown? + + it'll call raw_xmit to send the BAR, so the various bits of TX code + are going to have to be recursive. How's that going to work out for us? + (think: with all the TXQ node locks being held..) + + ic->ic_bar_response(ni, tap, status) is called on BAR response, and + ieee80211_ampdu_stop(ni, tap, IEEE80211_REASON_TIMEOUT) is called on + repeated failure to ACK the BAR. * DELBA - ie, downgrade existing packets in the SWQ + What about stuff in the HWQ? + + This is done, just completely and totally untested at the moment * 20<->2040 mode change? + part of this project or not? From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 16:17:15 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2020106566B; Fri, 12 Aug 2011 16:17:15 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B12448FC0A; Fri, 12 Aug 2011 16:17:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CGHFU0072844; Fri, 12 Aug 2011 16:17:15 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CGHFVI072840; Fri, 12 Aug 2011 16:17:15 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108121617.p7CGHFVI072840@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 12 Aug 2011 16:17:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224802 - in user/gabor/tre-integration: contrib/tre/lib include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 16:17:15 -0000 Author: gabor Date: Fri Aug 12 16:17:15 2011 New Revision: 224802 URL: http://svn.freebsd.org/changeset/base/224802 Log: - Introduce new flag for word-boundary matching: REG_WORD - Partly recover broken word-boundary matching; rest is TODO - Macroify fastcomp() and fastcomp_literal() initialization code - Adjust a comment Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre.h user/gabor/tre-integration/include/regex.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 15:13:06 2011 (r224801) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 16:17:15 2011 (r224802) @@ -332,6 +332,18 @@ static int fastcmp(const void *, const v memcpy(p, pat, l * sizeof(tre_char_t)); \ p[l] = TRE_CHAR('\0'); +#define INIT_COMP \ + /* Initialize. */ \ + memset(fg, 0, sizeof(*fg)); \ + fg->icase = (cflags & REG_ICASE); \ + fg->word = (cflags & REG_WORD); \ + \ + /* Cannot handle REG_ICASE with MB string */ \ + if (fg->icase && (MB_CUR_MAX > 1)) \ + return REG_BADPAT; \ + \ + /* Calculate length if unspecified */ \ + n = (n == 0) ? tre_strlen(pat) : n; /* * Returns: REG_OK on success, error code otherwise @@ -340,12 +352,10 @@ int tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n, int cflags) { - /* Initialize. */ - memset(fg, 0, sizeof(*fg)); - fg->icase = (cflags & REG_ICASE); + INIT_COMP; - /* Cannot handle REG_ICASE with MB string */ - if (fg->icase && (MB_CUR_MAX > 1)) + /* Cannot handle word boundaries with MB string */ + if (fg->word && (MB_CUR_MAX > 1)) return REG_BADPAT; #ifdef TRE_WCHAR @@ -372,15 +382,7 @@ int tre_fastcomp(fastmatch_t *fg, const tre_char_t *pat, size_t n, int cflags) { - /* Initialize. */ - memset(fg, 0, sizeof(*fg)); - fg->icase = (cflags & REG_ICASE); - - /* Cannot handle REG_ICASE with MB string */ - if (fg->icase && (MB_CUR_MAX > 1)) - return REG_BADPAT; - - n = (n == 0) ? tre_strlen(pat) : n; + INIT_COMP; /* Remove end-of-line character ('$'). */ if ((n > 0) && (pat[n - 1] == TRE_CHAR('$'))) @@ -408,6 +410,10 @@ tre_fastcomp(fastmatch_t *fg, const tre_ fg->word = true; } + /* Cannot handle word boundaries with MB string */ + if (fg->word && (MB_CUR_MAX > 1)) + return REG_BADPAT; + /* Look for ways to cheat...er...avoid the full regex engine. */ for (unsigned int i = 0; i < n; i++) { @@ -445,6 +451,34 @@ tre_fastcomp(fastmatch_t *fg, const tre_ return REG_OK; } +#define CHECK_WORD_BOUNDARY \ + { \ + bool bbound, ebound; \ + \ + switch (type) \ + { \ + case STR_WIDE: \ + bbound = (j == 0) || !(tre_isalnum(str_wide[j - 1]) || \ + (str_wide[j - 1] == TRE_CHAR('_'))); \ + ebound = (j + fg->wlen == len) || \ + !(tre_isalnum(str_wide[j + fg->wlen]) || \ + (str_wide[j + fg->wlen] == TRE_CHAR('_'))); \ + break; \ + default: \ + bbound = (j == 0) || !(tre_isalnum(str_byte[j - 1]) || \ + (str_byte[j - 1] == '_')); \ + ebound = (j + fg->len == len) || \ + !(tre_isalnum(str_byte[j + fg->len]) || \ + (str_byte[j + fg->len] == '_')); \ + } \ + if (!bbound || !ebound) \ + { \ + shift = 1; \ + j += shift; \ + continue; \ + } \ + } + /* * Executes matching of the precompiled pattern on the input string. * Returns REG_OK or REG_NOMATCH depending on if we find a match or not. @@ -485,6 +519,7 @@ tre_fastexec(const fastmatch_t *fg, cons shift = fg->len; } + /* XXX: Fix with word boundaries */ /* Only try once at the beginning or ending of the line. */ if (fg->bol || fg->eol) { @@ -506,7 +541,7 @@ tre_fastexec(const fastmatch_t *fg, cons } else { - /* Quick Search algorithm. */ + /* Quick Search / Turbo Boyer-Moore algorithm. */ j = 0; do { @@ -514,6 +549,8 @@ tre_fastexec(const fastmatch_t *fg, cons COMPARE; if (mismatch == REG_OK) { + if (fg->word) + CHECK_WORD_BOUNDARY; pmatch[0].rm_so = j; pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); return REG_OK; Modified: user/gabor/tre-integration/contrib/tre/lib/tre.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre.h Fri Aug 12 15:13:06 2011 (r224801) +++ user/gabor/tre-integration/contrib/tre/lib/tre.h Fri Aug 12 16:17:15 2011 (r224802) @@ -90,6 +90,7 @@ typedef enum { #define REG_UNGREEDY (REG_RIGHT_ASSOC << 1) #define REG_PEND (REG_UNGREEDY << 1) #define REG_GNU (REG_PEND << 1) +#define REG_WORD (REG_GNU << 1) /* POSIX tre_regexec() flags. */ #define REG_NOTBOL 1 Modified: user/gabor/tre-integration/include/regex.h ============================================================================== --- user/gabor/tre-integration/include/regex.h Fri Aug 12 15:13:06 2011 (r224801) +++ user/gabor/tre-integration/include/regex.h Fri Aug 12 16:17:15 2011 (r224802) @@ -82,6 +82,7 @@ typedef enum { #define REG_UNGREEDY (REG_RIGHT_ASSOC << 1) #define REG_PEND (REG_UNGREEDY << 1) #define REG_GNU (REG_PEND << 1) +#define REG_WORD (REG_GNU << 1) /* POSIX tre_regexec() flags. */ #define REG_NOTBOL 1 From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 16:21:06 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B422106566C; Fri, 12 Aug 2011 16:21:06 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2A9EA8FC14; Fri, 12 Aug 2011 16:21:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CGL6ed073049; Fri, 12 Aug 2011 16:21:06 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CGL6Eg073045; Fri, 12 Aug 2011 16:21:06 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108121621.p7CGL6Eg073045@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 12 Aug 2011 16:21:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224803 - user/gabor/tre-integration/usr.bin/grep X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 16:21:06 -0000 Author: gabor Date: Fri Aug 12 16:21:05 2011 New Revision: 224803 URL: http://svn.freebsd.org/changeset/base/224803 Log: - REG_NOSUB is always applicable - Avoid calculating pattern length various times - Drop code for -w and rely on recently introduced REG_WORD Modified: user/gabor/tre-integration/usr.bin/grep/grep.c user/gabor/tre-integration/usr.bin/grep/grep.h user/gabor/tre-integration/usr.bin/grep/util.c Modified: user/gabor/tre-integration/usr.bin/grep/grep.c ============================================================================== --- user/gabor/tre-integration/usr.bin/grep/grep.c Fri Aug 12 16:17:15 2011 (r224802) +++ user/gabor/tre-integration/usr.bin/grep/grep.c Fri Aug 12 16:21:05 2011 (r224803) @@ -81,7 +81,7 @@ bool matchall; /* Searching patterns */ unsigned int patterns, pattern_sz; -char **pattern; +struct pat *pattern; regex_t *r_pattern; /* Filename exclusion/inclusion patterns */ @@ -109,7 +109,6 @@ bool oflag; /* -o: print only matching bool qflag; /* -q: quiet mode (don't output anything) */ bool sflag; /* -s: silent mode (ignore errors) */ bool vflag; /* -v: only show non-matching lines */ -bool wflag; /* -w: pattern must start and end on word boundaries */ bool xflag; /* -x: pattern must match entire line */ bool lbflag; /* --line-buffered */ bool nullflag; /* --null */ @@ -231,14 +230,15 @@ add_pattern(char *pat, size_t len) if (patterns == pattern_sz) { pattern_sz *= 2; pattern = grep_realloc(pattern, ++pattern_sz * - sizeof(*pattern)); + sizeof(struct pat)); } if (len > 0 && pat[len - 1] == '\n') --len; /* pat may not be NUL-terminated */ - pattern[patterns] = grep_malloc(len + 1); - memcpy(pattern[patterns], pat, len); - pattern[patterns][len] = '\0'; + pattern[patterns].pat = grep_malloc(len + 1); + memcpy(pattern[patterns].pat, pat, len); + pattern[patterns].pat[len] = '\0'; + pattern[patterns].len = len; ++patterns; } @@ -518,7 +518,6 @@ main(int argc, char *argv[]) break; case 'o': oflag = true; - cflags &= ~REG_NOSUB; break; case 'p': linkbehave = LINK_SKIP; @@ -551,12 +550,10 @@ main(int argc, char *argv[]) vflag = true; break; case 'w': - wflag = true; - cflags &= ~REG_NOSUB; + cflags |= REG_WORD; break; case 'x': xflag = true; - cflags &= ~REG_NOSUB; break; case 'Z': filebehave = FILE_GZIP; @@ -590,7 +587,6 @@ main(int argc, char *argv[]) strcasecmp("none", optarg) != 0 && strcasecmp("no", optarg) != 0) errx(2, getstr(3), "--color"); - cflags &= ~REG_NOSUB; break; case LABEL_OPT: label = optarg; @@ -656,7 +652,8 @@ main(int argc, char *argv[]) r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); for (i = 0; i < patterns; ++i) { - c = regcomp(&r_pattern[i], pattern[i], cflags); + c = regncomp(&r_pattern[i], pattern[i].pat, + pattern[i].len, cflags); if (c != 0) { regerror(c, &r_pattern[i], re_error, RE_ERROR_BUF); Modified: user/gabor/tre-integration/usr.bin/grep/grep.h ============================================================================== --- user/gabor/tre-integration/usr.bin/grep/grep.h Fri Aug 12 16:17:15 2011 (r224802) +++ user/gabor/tre-integration/usr.bin/grep/grep.h Fri Aug 12 16:21:05 2011 (r224803) @@ -90,6 +90,11 @@ struct str { int line_no; }; +struct pat { + char *pat; + int len; +}; + struct epat { char *pat; int mode; @@ -101,7 +106,7 @@ extern int cflags, eflags; /* Command line flags */ extern bool Eflag, Fflag, Gflag, Hflag, Lflag, bflag, cflag, hflag, iflag, lflag, mflag, nflag, oflag, - qflag, sflag, vflag, wflag, xflag; + qflag, sflag, vflag, xflag; extern bool dexclude, dinclude, fexclude, finclude, lbflag, nullflag; extern unsigned long long Aflag, Bflag, mcount; extern char *label; @@ -111,7 +116,7 @@ extern int binbehave, devbehave, dirbeh extern bool first, matchall, notfound, prev; extern int tail; extern unsigned int dpatterns, fpatterns, patterns; -extern char **pattern; +extern struct pat *pattern; extern struct epat *dpattern, *fpattern; extern regex_t *er_pattern, *r_pattern; Modified: user/gabor/tre-integration/usr.bin/grep/util.c ============================================================================== --- user/gabor/tre-integration/usr.bin/grep/util.c Fri Aug 12 16:17:15 2011 (r224802) +++ user/gabor/tre-integration/usr.bin/grep/util.c Fri Aug 12 16:21:05 2011 (r224803) @@ -311,25 +311,6 @@ procline(struct str *l, int nottext) if (pmatch.rm_so != 0 || (size_t)pmatch.rm_eo != l->len) r = REG_NOMATCH; - /* Check for whole word match */ - if (r == 0 && wflag && - pmatch.rm_so != 0) { - wint_t wbegin, wend; - - wbegin = wend = L' '; - if (pmatch.rm_so != 0 && - sscanf(&l->dat[pmatch.rm_so - 1], - "%lc", &wbegin) != 1) - r = REG_NOMATCH; - else if ((size_t)pmatch.rm_eo != - l->len && - sscanf(&l->dat[pmatch.rm_eo], - "%lc", &wend) != 1) - r = REG_NOMATCH; - else if (iswword(wbegin) || - iswword(wend)) - r = REG_NOMATCH; - } if (r == 0) { if (m == 0) c++; From owner-svn-src-user@FreeBSD.ORG Fri Aug 12 20:02:47 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B05201065673; Fri, 12 Aug 2011 20:02:47 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9FF498FC1A; Fri, 12 Aug 2011 20:02:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7CK2l6d080769; Fri, 12 Aug 2011 20:02:47 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7CK2lbH080766; Fri, 12 Aug 2011 20:02:47 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108122002.p7CK2lbH080766@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 12 Aug 2011 20:02:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224805 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 20:02:47 -0000 Author: gabor Date: Fri Aug 12 20:02:47 2011 New Revision: 224805 URL: http://svn.freebsd.org/changeset/base/224805 Log: - Add support for TRE's REG_NEWLINE Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 19:51:28 2011 (r224804) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 12 20:02:47 2011 (r224805) @@ -44,7 +44,7 @@ #include "xmalloc.h" static int fastcmp(const void *, const void *, size_t, - tre_str_type_t, bool); + tre_str_type_t, bool, bool); /* * We will work with wide characters if they are supported @@ -101,11 +101,11 @@ static int fastcmp(const void *, const v { \ case STR_WIDE: \ mismatch = fastcmp(fg->wpattern, startptr, fg->wlen, type, \ - fg->icase); \ + fg->icase, fg->newline); \ break; \ default: \ mismatch = fastcmp(fg->pattern, startptr, fg->len, type, \ - fg->icase); \ + fg->icase, fg->newline); \ } \ #define IS_OUT_OF_BOUNDS \ @@ -337,6 +337,7 @@ static int fastcmp(const void *, const v memset(fg, 0, sizeof(*fg)); \ fg->icase = (cflags & REG_ICASE); \ fg->word = (cflags & REG_WORD); \ + fg->newline = (cflags & REG_NEWLINE); \ \ /* Cannot handle REG_ICASE with MB string */ \ if (fg->icase && (MB_CUR_MAX > 1)) \ @@ -451,6 +452,13 @@ tre_fastcomp(fastmatch_t *fg, const tre_ return REG_OK; } +#define _SHIFT_ONE \ + { \ + shift = 1; \ + j += shift; \ + continue; \ + } + #define CHECK_WORD_BOUNDARY \ { \ bool bbound, ebound; \ @@ -472,13 +480,26 @@ tre_fastcomp(fastmatch_t *fg, const tre_ (str_byte[j + fg->len] == '_')); \ } \ if (!bbound || !ebound) \ - { \ - shift = 1; \ - j += shift; \ - continue; \ - } \ + _SHIFT_ONE; \ } +#define _BOL_COND \ + ((j == 0) || ((type == STR_WIDE) ? tre_isspace(str_wide[j - 1]) : \ + isspace(str_byte[j - 1]))) + +#define CHECK_BOL_ANCHOR \ + if (!_BOL_COND) \ + _SHIFT_ONE; + +#define _EOL_COND \ + ((type == STR_WIDE) ? \ + ((j + fg->wlen == len) || tre_isspace(str_wide[j + fg->wlen])) : \ + ((j + fg->len == len) || isspace(str_byte[j + fg->wlen]))) + +#define CHECK_EOL_ANCHOR \ + if (!_EOL_COND) \ + _SHIFT_ONE; + /* * Executes matching of the precompiled pattern on the input string. * Returns REG_OK or REG_NOMATCH depending on if we find a match or not. @@ -521,7 +542,7 @@ tre_fastexec(const fastmatch_t *fg, cons /* XXX: Fix with word boundaries */ /* Only try once at the beginning or ending of the line. */ - if (fg->bol || fg->eol) + if (!fg->newline && (fg->bol || fg->eol)) { /* Simple text comparison. */ if (!((fg->bol && fg->eol) && @@ -551,6 +572,10 @@ tre_fastexec(const fastmatch_t *fg, cons { if (fg->word) CHECK_WORD_BOUNDARY; + if (fg->bol) + CHECK_BOL_ANCHOR; + if (fg->eol) + CHECK_EOL_ANCHOR; pmatch[0].rm_so = j; pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); return REG_OK; @@ -582,7 +607,7 @@ tre_fastfree(fastmatch_t *fg) */ static inline int fastcmp(const void *pat, const void *data, size_t len, - tre_str_type_t type, bool icase) + tre_str_type_t type, bool icase, bool newline) { const char *str_byte = data; const char *pat_byte = pat; @@ -594,14 +619,16 @@ fastcmp(const void *pat, const void *dat switch (type) { case STR_WIDE: - if (pat_wide[i] == L'.') + if (pat_wide[i] == TRE_CHAR('.') && + (!newline || (str_wide[i] != TRE_CHAR('\n')))) continue; if (icase ? (towlower(pat_wide[i]) == towlower(str_wide[i])) : (pat_wide[i] == str_wide[i])) continue; break; default: - if (pat_byte[i] == '.') + if (pat_byte[i] == '.' && + (!newline || (str_byte[i] != '\n'))) continue; if (icase ? (tolower(pat_byte[i]) == tolower(str_byte[i])) : (pat_byte[i] == str_byte[i])) Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Fri Aug 12 19:51:28 2011 (r224804) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Fri Aug 12 20:02:47 2011 (r224805) @@ -55,6 +55,7 @@ typedef struct { bool eol; bool word; bool icase; + bool newline; } fastmatch_t; int tre_fastcomp_literal(fastmatch_t *preg, const tre_char_t *regex, From owner-svn-src-user@FreeBSD.ORG Sat Aug 13 10:23:53 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 14311106564A; Sat, 13 Aug 2011 10:23:53 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 02E878FC17; Sat, 13 Aug 2011 10:23:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7DANqoM007142; Sat, 13 Aug 2011 10:23:52 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7DANqMr007138; Sat, 13 Aug 2011 10:23:52 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108131023.p7DANqMr007138@svn.freebsd.org> From: Adrian Chadd Date: Sat, 13 Aug 2011 10:23:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224811 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Aug 2011 10:23:53 -0000 Author: adrian Date: Sat Aug 13 10:23:52 2011 New Revision: 224811 URL: http://svn.freebsd.org/changeset/base/224811 Log: Some fixes - fix BAW checking/update (which isn't entirely fixed, I'll be fiddling with this shortly!) and simplify the swq TX routine. This is unfortunately one of those aggregate commits which I dislike doing. * Remove an unneeded mbuf argument to ath_tx_swq(). ath_buf should already be setup by now and bf->bf_m is the first mbuf in the chain. * Now that NULL data QOS frames are not receiving sequence numbers from the TID, we can't check them against the BAW window when we're scheduling packets. Otherwise it's likely it'll be outside the BAW and will remain so, so the TX will hang until the watchdog timer kicks in. The code duplication involved in checking whether a frame is going to be given a sequence number and treated as part of the BAW is .. well, horrible. Unfortunately, I didn't think about needing to also not call the BAW update upon packet completion. That's going to have to be the next check. Modified: user/adrian/if_ath_tx/sys/dev/ath/README user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Modified: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/README Sat Aug 13 09:21:16 2011 (r224810) +++ user/adrian/if_ath_tx/sys/dev/ath/README Sat Aug 13 10:23:52 2011 (r224811) @@ -34,6 +34,9 @@ Things that need doing! + right now packets are simply flushed; why not just re-prod them into the software TXQ ? +* A device timeout during an active iperf causes TCP to stop, until something + triggers a TX (say an ICMP ping.) Then it all keeps flowing. + Things that need investigating! Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sat Aug 13 09:21:16 2011 (r224810) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sat Aug 13 10:23:52 2011 (r224811) @@ -1072,7 +1072,7 @@ ath_tx_start(struct ath_softc *sc, struc return r; /* At this point m0 could have changed! */ - //m0 = bf->bf_m; + m0 = bf->bf_m; /* Fill in the details in the descriptor list */ ath_tx_chaindesclist(sc, bf); @@ -1088,7 +1088,7 @@ ath_tx_start(struct ath_softc *sc, struc else { ATH_TXQ_LOCK(txq); /* add to software queue */ - ath_tx_swq(sc, ni, txq, bf, m0); + ath_tx_swq(sc, ni, txq, bf); /* Kick txq */ ath_txq_sched(sc, txq); ATH_TXQ_UNLOCK(txq); @@ -1331,7 +1331,7 @@ ath_tx_raw_start(struct ath_softc *sc, s ath_tx_handoff(sc, sc->sc_ac2q[pri], bf); else { /* Queue to software queue */ - ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf, m0); + ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf); /* Kick txq */ ath_txq_sched(sc, sc->sc_ac2q[pri]); @@ -1685,12 +1685,13 @@ ath_tx_tid_seqno_assign(struct ath_softc */ void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_txq *txq, - struct ath_buf *bf, struct mbuf *m0) + struct ath_buf *bf) { struct ath_node *an = ATH_NODE(ni); struct ieee80211_frame *wh; struct ath_tid *atid; int pri, tid; + struct mbuf *m0 = bf->bf_m; ATH_TXQ_LOCK_ASSERT(txq); @@ -2167,6 +2168,9 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft struct ath_txq *txq; struct ath_tid *atid = &an->an_tid[tid]; struct ieee80211_tx_ampdu *tap; + int check_baw; + uint8_t subtype; + const struct ieee80211_frame *wh; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid); @@ -2177,6 +2181,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft __func__); for (;;) { + check_baw = 1; bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { break; @@ -2190,9 +2195,24 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft device_printf(sc->sc_dev, "%s: TXQ: tid=%d, ac=%d, bf tid=%d\n", __func__, tid, atid->ac, bf->bf_state.bfs_tid); + /* + * Some packets aren't going to fall within the BAW. + * If they're non-sequence QOS packets that sit inside this TID, + * or they're a null data frame. + * This is quite messy and I should make the seqno code and + * this code share the same decision logic. + */ + wh = mtod(bf->bf_m, const struct ieee80211_frame *); + if (! IEEE80211_QOS_HAS_SEQ(wh)) + check_baw = 0; + subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; + if (subtype == IEEE80211_FC0_SUBTYPE_QOS_NULL) + check_baw = 0; + /* XXX check if seqno is outside of BAW, if so don't queue it */ - if (! BAW_WITHIN(tap->txa_start, tap->txa_wnd, - SEQNO(bf->bf_state.bfs_seqno))) { + if (check_baw == 1 && + (! BAW_WITHIN(tap->txa_start, tap->txa_wnd, + SEQNO(bf->bf_state.bfs_seqno)))) { DPRINTF(sc, ATH_DEBUG_SW_TX_BAW, "%s: seq %d outside of %d/%d; waiting\n", __func__, SEQNO(bf->bf_state.bfs_seqno), @@ -2200,7 +2220,9 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft break; } - ath_tx_addto_baw(sc, an, atid, bf); + /* Don't add packets to the BAW that don't contribute to it */ + if (check_baw == 1) + ath_tx_addto_baw(sc, an, atid, bf); /* * XXX If the seqno is out of BAW, then we should pause this TID Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Sat Aug 13 09:21:16 2011 (r224810) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Sat Aug 13 10:23:52 2011 (r224811) @@ -44,7 +44,7 @@ extern int ath_raw_xmit(struct ieee80211 /* software queue stuff */ extern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni, - struct ath_txq *txq, struct ath_buf *bf, struct mbuf *m0); + struct ath_txq *txq, struct ath_buf *bf); extern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an); extern void ath_tx_tid_cleanup(struct ath_softc *sc, struct ath_node *an); extern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, From owner-svn-src-user@FreeBSD.ORG Sat Aug 13 10:43:56 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3C32106566C; Sat, 13 Aug 2011 10:43:56 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B25C68FC22; Sat, 13 Aug 2011 10:43:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7DAhuQG010345; Sat, 13 Aug 2011 10:43:56 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7DAhu7S010342; Sat, 13 Aug 2011 10:43:56 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108131043.p7DAhu7S010342@svn.freebsd.org> From: Adrian Chadd Date: Sat, 13 Aug 2011 10:43:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224813 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Aug 2011 10:43:56 -0000 Author: adrian Date: Sat Aug 13 10:43:56 2011 New Revision: 224813 URL: http://svn.freebsd.org/changeset/base/224813 Log: This deviates a bit from the reference code; I may end up backing this out at a later stage. This unifies the "is this packet supposed to be considered as part of the BAW?" logic. I've added a bit in the ath_buf.bf_state struct which indicates whether it's going to be considered for inclusion or not. Packets that aren't part of the BAW calculation are thus not passed to the BAW add or update code. Eventually, the aggregate forming code will also not include this packet as part of an aggregate and will be sent as a non-aggregate packet. This fixes the hangs, interface resets and general unhappiness that has been happening with my recent changes. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sat Aug 13 10:43:21 2011 (r224812) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sat Aug 13 10:43:56 2011 (r224813) @@ -1010,6 +1010,7 @@ ath_tx_start(struct ath_softc *sc, struc const struct ieee80211_frame *wh; int is_ampdu, is_ampdu_tx, is_ampdu_pending; ieee80211_seq seqno; + uint8_t subtype; /* * Determine the target hardware queue. @@ -1031,6 +1032,7 @@ ath_tx_start(struct ath_softc *sc, struc txq = sc->sc_ac2q[pri]; wh = mtod(m0, struct ieee80211_frame *); ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); + subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; /* A-MPDU TX */ is_ampdu_tx = ath_tx_ampdu_running(sc, ATH_NODE(ni), tid); @@ -1043,15 +1045,27 @@ ath_tx_start(struct ath_softc *sc, struc /* Multicast frames go onto the software multicast queue */ if (ismcast) txq = &avp->av_mcastq; - if ((! is_ampdu) && (vap->iv_ps_sta || avp->av_mcastq.axq_depth)) + + if ((! is_ampdu) && (vap->iv_ps_sta || avp->av_mcastq.axq_depth)) txq = &avp->av_mcastq; /* Do the generic frame setup */ /* A-MPDU TX? Manually set sequence number */ /* Don't do it whilst pending; the net80211 layer still assigns them */ - if (is_ampdu_tx) + if (is_ampdu_tx) { + /* + * Always set a seqno; this function will + * handle making sure that null data frames + * don't get a sequence number from the current + * TID and thus mess with the BAW. + */ seqno = ath_tx_tid_seqno_assign(sc, ni, bf, m0); + if (IEEE80211_QOS_HAS_SEQ(wh) && + subtype != IEEE80211_FC0_SUBTYPE_QOS_NULL) { + bf->bf_state.bfs_dobaw = 1; + } + } /* * If needed, the sequence number has been assigned. @@ -1708,6 +1722,7 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_tid = tid; bf->bf_state.bfs_txq = txq; bf->bf_state.bfs_pri = pri; + bf->bf_state.bfs_dobaw = 0; /* Queue frame to the tail of the software queue */ ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); @@ -1839,7 +1854,8 @@ ath_tx_tid_free_pkts(struct ath_softc *s * If the current TID is running AMPDU, update * the BAW. */ - if (ath_tx_ampdu_running(sc, an, tid)) + if (ath_tx_ampdu_running(sc, an, tid) && + bf->bf_state.bfs_dobaw) ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); ATH_TXQ_REMOVE_HEAD(atid, bf_list); @@ -1994,8 +2010,9 @@ ath_tx_cleanup(struct ath_softc *sc, str bf_next = STAILQ_NEXT(bf, bf_list); STAILQ_REMOVE(&atid->axq_q, bf, ath_buf, bf_list); atid->axq_depth--; - ath_tx_update_baw(sc, an, atid, - SEQNO(bf->bf_state.bfs_seqno)); + if (bf->bf_state.bfs_dobaw) + ath_tx_update_baw(sc, an, atid, + SEQNO(bf->bf_state.bfs_seqno)); /* * Call the default completion handler with "fail" just * so upper levels are suitably notified about this. @@ -2083,7 +2100,9 @@ ath_tx_aggr_retry_unaggr(struct ath_soft sc->sc_stats.ast_tx_swretrymax++; /* Update BAW anyway */ - ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + if (bf->bf_state.bfs_dobaw) + ath_tx_update_baw(sc, an, atid, + SEQNO(bf->bf_state.bfs_seqno)); /* Free buffer, bf is free after this call */ ath_tx_default_comp(sc, bf, 0); @@ -2150,7 +2169,8 @@ ath_tx_aggr_comp(struct ath_softc *sc, s /* Success? Complete */ DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: TID=%d, seqno %d\n", __func__, tid, SEQNO(bf->bf_state.bfs_seqno)); - ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + if (bf->bf_state.bfs_dobaw) + ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); ath_tx_default_comp(sc, bf, fail); /* bf is freed at this point */ @@ -2168,9 +2188,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft struct ath_txq *txq; struct ath_tid *atid = &an->an_tid[tid]; struct ieee80211_tx_ampdu *tap; - int check_baw; - uint8_t subtype; - const struct ieee80211_frame *wh; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid); @@ -2181,7 +2198,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft __func__); for (;;) { - check_baw = 1; bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { break; @@ -2195,22 +2211,8 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft device_printf(sc->sc_dev, "%s: TXQ: tid=%d, ac=%d, bf tid=%d\n", __func__, tid, atid->ac, bf->bf_state.bfs_tid); - /* - * Some packets aren't going to fall within the BAW. - * If they're non-sequence QOS packets that sit inside this TID, - * or they're a null data frame. - * This is quite messy and I should make the seqno code and - * this code share the same decision logic. - */ - wh = mtod(bf->bf_m, const struct ieee80211_frame *); - if (! IEEE80211_QOS_HAS_SEQ(wh)) - check_baw = 0; - subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; - if (subtype == IEEE80211_FC0_SUBTYPE_QOS_NULL) - check_baw = 0; - - /* XXX check if seqno is outside of BAW, if so don't queue it */ - if (check_baw == 1 && + /* Check if seqno is outside of BAW, if so don't queue it */ + if (bf->bf_state.bfs_dobaw && (! BAW_WITHIN(tap->txa_start, tap->txa_wnd, SEQNO(bf->bf_state.bfs_seqno)))) { DPRINTF(sc, ATH_DEBUG_SW_TX_BAW, @@ -2221,7 +2223,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft } /* Don't add packets to the BAW that don't contribute to it */ - if (check_baw == 1) + if (bf->bf_state.bfs_dobaw) ath_tx_addto_baw(sc, an, atid, bf); /* Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sat Aug 13 10:43:21 2011 (r224812) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sat Aug 13 10:43:56 2011 (r224813) @@ -207,6 +207,7 @@ struct ath_buf { int bfs_aggr:1; /* part of aggregate? */ int bfs_aggrburst:1; /* part of aggregate burst? */ int bfs_isretried:1; /* retried frame? */ + int bfs_dobaw:1; /* actually check against BAW? */ } bf_state; }; typedef STAILQ_HEAD(, ath_buf) ath_bufhead;