From owner-svn-src-user@FreeBSD.ORG Sun Aug 14 11:47:42 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 DE5981065679; Sun, 14 Aug 2011 11:47:42 +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 B4B988FC19; Sun, 14 Aug 2011 11:47:42 +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 p7EBlgqj062899; Sun, 14 Aug 2011 11:47:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7EBlgPb062896; Sun, 14 Aug 2011 11:47:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108141147.p7EBlgPb062896@svn.freebsd.org> From: Adrian Chadd Date: Sun, 14 Aug 2011 11:47:42 +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: r224861 - 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, 14 Aug 2011 11:47:43 -0000 Author: adrian Date: Sun Aug 14 11:47:42 2011 New Revision: 224861 URL: http://svn.freebsd.org/changeset/base/224861 Log: Add the 4ms framelength maximum values. This'll be eventually used by the aggregation logic to determine how long the maximum frame length will be at the selected rate control. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Sun Aug 14 00:55:18 2011 (r224860) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Sun Aug 14 11:47:42 2011 (r224861) @@ -88,6 +88,33 @@ __FBSDID("$FreeBSD$"); #include +int ath_max_4ms_framelen[4][32] = { + [MCS_HT20] = { + 3212, 6432, 9648, 12864, 19300, 25736, 28952, 32172, + 6424, 12852, 19280, 25708, 38568, 51424, 57852, 64280, + 9628, 19260, 28896, 38528, 57792, 65532, 65532, 65532, + 12828, 25656, 38488, 51320, 65532, 65532, 65532, 65532, + }, + [MCS_HT20_SGI] = { + 3572, 7144, 10720, 14296, 21444, 28596, 32172, 35744, + 7140, 14284, 21428, 28568, 42856, 57144, 64288, 65532, + 10700, 21408, 32112, 42816, 64228, 65532, 65532, 65532, + 14256, 28516, 42780, 57040, 65532, 65532, 65532, 65532, + }, + [MCS_HT40] = { + 6680, 13360, 20044, 26724, 40092, 53456, 60140, 65532, + 13348, 26700, 40052, 53400, 65532, 65532, 65532, 65532, + 20004, 40008, 60016, 65532, 65532, 65532, 65532, 65532, + 26644, 53292, 65532, 65532, 65532, 65532, 65532, 65532, + }, + [MCS_HT40_SGI] = { + 7420, 14844, 22272, 29696, 44544, 59396, 65532, 65532, + 14832, 29668, 44504, 59340, 65532, 65532, 65532, 65532, + 22232, 44464, 65532, 65532, 65532, 65532, 65532, 65532, + 29616, 59232, 65532, 65532, 65532, 65532, 65532, 65532, + } +}; + /* * Setup a 11n rate series structure * Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Sun Aug 14 00:55:18 2011 (r224860) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Sun Aug 14 11:47:42 2011 (r224861) @@ -31,6 +31,15 @@ #ifndef __IF_ATH_TX_HT_H__ #define __IF_ATH_TX_HT_H__ +enum { + MCS_HT20, + MCS_HT20_SGI, + MCS_HT40, + MCS_HT40_SGI, +}; + +extern int ath_max_4ms_framelen[4][32]; + extern void ath_buf_set_rate(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf, int pktlen, int flags, uint8_t ctsrate, int is_pspoll, From owner-svn-src-user@FreeBSD.ORG Sun Aug 14 12:21: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 B083F106566B; Sun, 14 Aug 2011 12:21:08 +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 9FFD58FC19; Sun, 14 Aug 2011 12:21:08 +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 p7ECL8aq063887; Sun, 14 Aug 2011 12:21:08 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7ECL85S063882; Sun, 14 Aug 2011 12:21:08 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108141221.p7ECL85S063882@svn.freebsd.org> From: Adrian Chadd Date: Sun, 14 Aug 2011 12:21:08 +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: r224862 - 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, 14 Aug 2011 12:21:08 -0000 Author: adrian Date: Sun Aug 14 12:21:08 2011 New Revision: 224862 URL: http://svn.freebsd.org/changeset/base/224862 Log: Begin fleshing out the BAR handling. net80211 implements BAR frame queuing and completion handofing. The first place a BAR should be TXed is when the software retry limit has been exceeded for a TID currently doing aggregation. The process should be (just so I don't forget): * pause the TID; * send the BAR; * unpause the TID in ath_bar_response() If multiple BAR's are sent, paused will be incremented and decremented appropriately until all BAR frames have been transmitted (succesfully or otherwise.) However, using it with the current code is likely not going to work because the ath TX code isn't re-entrant w/ the way locking currently is implement. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h 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 Sun Aug 14 11:47:42 2011 (r224861) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 14 12:21:08 2011 (r224862) @@ -733,10 +733,12 @@ ath_attach(u_int16_t devid, struct ath_s sc->sc_addba_request = ic->ic_addba_request; sc->sc_addba_response = ic->ic_addba_response; sc->sc_addba_stop = ic->ic_addba_stop; + sc->sc_bar_response = ic->ic_bar_response; ic->ic_addba_request = ath_addba_request; ic->ic_addba_response = ath_addba_response; ic->ic_addba_stop = ath_addba_stop; + ic->ic_bar_response = ath_bar_response; ieee80211_radiotap_attach(ic, &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), 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 14 11:47:42 2011 (r224861) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 14 12:21:08 2011 (r224862) @@ -2104,6 +2104,12 @@ ath_tx_aggr_retry_unaggr(struct ath_soft ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + /* Pause the TID */ + + /* Send BAR frame */ + device_printf(sc->sc_dev, "%s: TID %d: send BAR\n", + __func__, tid); + /* Free buffer, bf is free after this call */ ath_tx_default_comp(sc, bf, 0); return; @@ -2487,3 +2493,14 @@ ath_addba_stop(struct ieee80211_node *ni ath_tx_cleanup(sc, an, tid); ATH_TXQ_UNLOCK(txq); } + +void +ath_bar_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, + int status) +{ + struct ath_softc *sc = ni->ni_ic->ic_ifp->if_softc; + + device_printf(sc->sc_dev, "%s: called\n", __func__); + + sc->sc_bar_response(ni, tap, status); +} 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 Sun Aug 14 11:47:42 2011 (r224861) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Sun Aug 14 12:21:08 2011 (r224862) @@ -62,5 +62,7 @@ extern int ath_addba_response(struct iee int code, int batimeout); extern void ath_addba_stop(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap); +extern void ath_bar_response(struct ieee80211_node *ni, + struct ieee80211_tx_ampdu *tap, int status); #endif Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sun Aug 14 11:47:42 2011 (r224861) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sun Aug 14 12:21:08 2011 (r224862) @@ -470,6 +470,9 @@ struct ath_softc { struct ieee80211_tx_ampdu *, int, int, int); void (*sc_addba_stop)(struct ieee80211_node *, struct ieee80211_tx_ampdu *); + void (*sc_bar_response)(struct ieee80211_node *ni, + struct ieee80211_tx_ampdu *tap, + int status); }; #define ATH_LOCK_INIT(_sc) \ From owner-svn-src-user@FreeBSD.ORG Sun Aug 14 12:26:25 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 416AA106564A; Sun, 14 Aug 2011 12:26:25 +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 314168FC12; Sun, 14 Aug 2011 12:26:25 +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 p7ECQP1T064078; Sun, 14 Aug 2011 12:26:25 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7ECQPMj064076; Sun, 14 Aug 2011 12:26:25 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108141226.p7ECQPMj064076@svn.freebsd.org> From: Adrian Chadd Date: Sun, 14 Aug 2011 12:26:25 +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: r224863 - 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, 14 Aug 2011 12:26:25 -0000 Author: adrian Date: Sun Aug 14 12:26:24 2011 New Revision: 224863 URL: http://svn.freebsd.org/changeset/base/224863 Log: Write out some notes about BAR response processing and what we're (currently) missing. 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 Sun Aug 14 12:21:08 2011 (r224862) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 14 12:26:24 2011 (r224863) @@ -2494,6 +2494,13 @@ ath_addba_stop(struct ieee80211_node *ni ATH_TXQ_UNLOCK(txq); } +/* + * Note: net80211 bar_timeout() doesn't call this function on BAR failure; + * it simply tears down the aggregation session. Ew. + * + * It however will call ieee80211_ampdu_stop() which will call + * ic->ic_addba_stop(). + */ void ath_bar_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int status) @@ -2503,4 +2510,7 @@ ath_bar_response(struct ieee80211_node * device_printf(sc->sc_dev, "%s: called\n", __func__); sc->sc_bar_response(ni, tap, status); + /* Note: This may update the BAW details */ + + /* Unpause the TID */ } From owner-svn-src-user@FreeBSD.ORG Sun Aug 14 16:03:26 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 97CB0106566B; Sun, 14 Aug 2011 16:03:26 +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 86F8D8FC13; Sun, 14 Aug 2011 16:03:26 +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 p7EG3Qcb070596; Sun, 14 Aug 2011 16:03:26 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7EG3QtO070594; Sun, 14 Aug 2011 16:03:26 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108141603.p7EG3QtO070594@svn.freebsd.org> From: Adrian Chadd Date: Sun, 14 Aug 2011 16:03:26 +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: r224867 - 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, 14 Aug 2011 16:03:26 -0000 Author: adrian Date: Sun Aug 14 16:03:26 2011 New Revision: 224867 URL: http://svn.freebsd.org/changeset/base/224867 Log: Begin to attempt to handle sending BAR frames. This doesn't work yet and will panic the kernel. BAR frames should be generated to resync the remote side with where the block-ack window left edge is - eg, after some packet loss. The problem here is that said BAR frames will be generated from: * the TX packet completion handler; and * via a timer callout if the BAR TX wasn't successful. The former will occur with the hardware TXQ lock held, as that's currently how I've implemented the locking (ie, the hardware TXQ protects the TXQ and the TID state.) This results in lock recursion (as we're recursing back through net80211 and then back into the driver via ic->ic_raw_xmit()) and thus TX'ing a BAR frame will very much fail. The problem here (among other things) is that TX'ing a BAR frame should occur after all the hardware-queued frames for that AC, in case there's some other packets (which may or may not be successfully transmitted in the future), and in the same hardware queue. This means we can't just use the normal software queue method, as the TID should be paused when a BAR frame is TX'ed. Hence, the direct dispatch to hardware. Anyway, this is all quite messy. I think I'm going to have to bite the bullet and (re) introduce more fine-grained locking in a subsequent commit before supporting this in a clean fashion is even possible. (The other option is to modify the ieee80211_send_bar()) function to just schedule a callback even and have the TX occur from there, rather than recurse through the driver. I may end up doing that at a later date, but I really need to fix the locking anyway. So, I'll just do that first.) 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 Sun Aug 14 14:36:32 2011 (r224866) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 14 16:03:26 2011 (r224867) @@ -1010,7 +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; + uint8_t type, subtype; /* * Determine the target hardware queue. @@ -1032,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); + type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; /* A-MPDU TX */ @@ -1097,9 +1098,38 @@ ath_tx_start(struct ath_softc *sc, struc * destination hardware queue. Don't bother software * queuing it. */ + /* + * If it's a BAR frame, do a direct dispatch to the + * destination hardware queue. Don't bother software + * queuing it, as the TID will now be paused. + */ if (ismcast) ath_tx_handoff_mcast(sc, txq, bf); - else { + else if (type == IEEE80211_FC0_TYPE_CTL && + subtype == IEEE80211_FC0_SUBTYPE_BAR) { + /* + * XXX The following is dirty but needed for now. + * + * Because of the current way locking is implemented, + * we may end up here because of a call to + * ieee80211_send_bar() from a call inside the completion + * handler. This will have the hardware TXQ locked, + * protecting the TXQ and the node TID state in question. + * + * So we (a) can't SWQ queue to it, as it'll be queued + * on the same TID which will be paused, and (b) the TXQ + * will be locked anyway, so grabbing the lock will cause + * recursion. + * + * The longer term issue is that the TXQ lock is being held + * for so damned long, and that must be addressed before this + * stuff is merged into -HEAD. + */ + device_printf(sc->sc_dev, "%s: BAR: TX'ing direct\n", __func__); + ATH_TXQ_LOCK(txq); + ath_tx_handoff(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); + } else { ATH_TXQ_LOCK(txq); /* add to software queue */ ath_tx_swq(sc, ni, txq, bf); @@ -1108,15 +1138,16 @@ ath_tx_start(struct ath_softc *sc, struc ATH_TXQ_UNLOCK(txq); } #else - /* * For now, since there's no software queue, * direct-dispatch to the hardware. */ + ATH_TXQ_LOCK(txq); if (ismcast) ath_tx_handoff_mcast(sc, txq, bf); else ath_tx_handoff_hw(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); #endif return 0; @@ -2093,9 +2124,12 @@ ath_tx_aggr_retry_unaggr(struct ath_soft int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + struct ieee80211_tx_ampdu *tap; ATH_TXQ_LOCK_ASSERT(txq); + tap = ath_tx_get_tx_tid(an, tid); + if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { sc->sc_stats.ast_tx_swretrymax++; @@ -2107,8 +2141,18 @@ ath_tx_aggr_retry_unaggr(struct ath_soft /* Pause the TID */ /* Send BAR frame */ + /* + * XXX This causes the kernel to recurse + * XXX back into the net80211 layer, then back out + * XXX to the TX queue (via ic->ic_raw_xmit()). + * XXX Because the TXQ lock is held here, + * XXX this will cause a lock recurse panic. + */ device_printf(sc->sc_dev, "%s: TID %d: send BAR\n", __func__, tid); +#if 0 + ieee80211_send_bar(ni, tap, ni->ni_txseqs[tid]); +#endif /* Free buffer, bf is free after this call */ ath_tx_default_comp(sc, bf, 0); From owner-svn-src-user@FreeBSD.ORG Sun Aug 14 20:54: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 4A002106566B; Sun, 14 Aug 2011 20:54: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 DC92A8FC0C; Sun, 14 Aug 2011 20:54: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 p7EKsD6J079321; Sun, 14 Aug 2011 20:54:13 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7EKsDpV079319; Sun, 14 Aug 2011 20:54:13 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108142054.p7EKsDpV079319@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 14 Aug 2011 20:54: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: r224869 - 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: Sun, 14 Aug 2011 20:54:14 -0000 Author: gabor Date: Sun Aug 14 20:54:13 2011 New Revision: 224869 URL: http://svn.freebsd.org/changeset/base/224869 Log: - Fix word boundary matching for the remaining case 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 Sun Aug 14 16:17:00 2011 (r224868) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 20:54:13 2011 (r224869) @@ -459,29 +459,26 @@ tre_fastcomp(fastmatch_t *fg, const tre_ continue; \ } +#define _BBOUND_COND \ + ((type == STR_WIDE) ? \ + ((j == 0) || !(tre_isalnum(str_wide[j - 1]) || \ + (str_wide[j - 1] == TRE_CHAR('_')))) : \ + ((j == 0) || !(tre_isalnum(str_byte[j - 1]) || \ + (str_byte[j - 1] == '_')))) + +#define _EBOUND_COND \ + ((type == STR_WIDE) ? \ + ((j + fg->wlen == len) || !(tre_isalnum(str_wide[j + fg->wlen]) || \ + (str_wide[j + fg->wlen] == TRE_CHAR('_')))) : \ + ((j + fg->len == len) || !(tre_isalnum(str_byte[j + fg->len]) || \ + (str_byte[j + fg->len] == '_')))) + +#define IS_ON_WORD_BOUNDARY \ + (_BBOUND_COND && _EBOUND_COND) + #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_ONE; \ - } + if (!IS_ON_WORD_BOUNDARY) \ + _SHIFT_ONE; #define _BOL_COND \ ((j == 0) || ((type == STR_WIDE) ? tre_isspace(str_wide[j - 1]) : \ @@ -540,7 +537,6 @@ 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->newline && (fg->bol || fg->eol)) { @@ -554,6 +550,8 @@ tre_fastexec(const fastmatch_t *fg, cons COMPARE; if (mismatch == REG_OK) { + if (fg->word && !IS_ON_WORD_BOUNDARY) + return ret; pmatch[0].rm_so = j; pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len); return REG_OK; From owner-svn-src-user@FreeBSD.ORG Sun Aug 14 22:53:03 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 26B6E1065675; Sun, 14 Aug 2011 22:53:03 +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 163148FC1A; Sun, 14 Aug 2011 22:53:03 +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 p7EMr2rn082935; Sun, 14 Aug 2011 22:53:02 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7EMr2hr082931; Sun, 14 Aug 2011 22:53:02 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108142253.p7EMr2hr082931@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 14 Aug 2011 22:53: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: r224871 - 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: Sun, 14 Aug 2011 22:53:03 -0000 Author: gabor Date: Sun Aug 14 22:53:02 2011 New Revision: 224871 URL: http://svn.freebsd.org/changeset/base/224871 Log: - Implement TRE-specific REG_NOTBOL and REG_NOTEOL - Adjust an older comment Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/fastmatch.h user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 20:55:32 2011 (r224870) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 22:53:02 2011 (r224871) @@ -503,9 +503,9 @@ tre_fastcomp(fastmatch_t *fg, const tre_ */ int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len, - tre_str_type_t type, int nmatch, regmatch_t pmatch[]) + tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags) { - unsigned int j; + unsigned int j = 0; int ret = REG_NOMATCH; int mismatch, shift, u = 0, v; const char *str_byte = data; @@ -537,8 +537,23 @@ tre_fastexec(const fastmatch_t *fg, cons shift = fg->len; } + /* + * REG_NOTBOL means not anchoring ^ to the beginning of the line, so we + * can shift one because there can't be a match at the beginning. + */ + if (fg->bol && (eflags & REG_NOTBOL)) + j = 1; + + /* + * Like above, we cannot have a match at the very end when anchoring to + * the end and REG_NOTEOL is specified. + */ + if (fg->eol && (eflags & REG_NOTEOL)) + len--; + /* Only try once at the beginning or ending of the line. */ - if (!fg->newline && (fg->bol || fg->eol)) + if ((fg->bol || fg->eol) && !fg->newline && !(eflags & REG_NOTBOL) && + !(eflags & REG_NOTEOL)) { /* Simple text comparison. */ if (!((fg->bol && fg->eol) && @@ -561,7 +576,6 @@ tre_fastexec(const fastmatch_t *fg, cons else { /* Quick Search / Turbo Boyer-Moore algorithm. */ - j = 0; do { SKIP_CHARS(j); Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Sun Aug 14 20:55:32 2011 (r224870) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Sun Aug 14 22:53:02 2011 (r224871) @@ -62,7 +62,7 @@ int tre_fastcomp_literal(fastmatch_t *pr size_t, int); int tre_fastcomp(fastmatch_t *preg, const tre_char_t *regex, size_t, int); int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len, - tre_str_type_t type, int nmatch, regmatch_t pmatch[]); + tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags); void tre_fastfree(fastmatch_t *preg); #endif /* FASTMATCH_H */ Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Sun Aug 14 20:55:32 2011 (r224870) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Sun Aug 14 22:53:02 2011 (r224871) @@ -156,9 +156,9 @@ tre_match(const tre_tnfa_t *tnfa, const reg_errcode_t status; int *tags = NULL, eo; - /* Check if we can cheat with a fixed string */ + /* Check if we can cheat with a faster algorithm */ if (shortcut != NULL) - return tre_fastexec(shortcut, string, len, type, nmatch, pmatch); + return tre_fastexec(shortcut, string, len, type, nmatch, pmatch, eflags); if (tnfa->num_tags > 0 && nmatch > 0) { From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 00:38: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 EAA11106564A; Mon, 15 Aug 2011 00:38: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 D8EB98FC08; Mon, 15 Aug 2011 00:38: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 p7F0cEDp086171; Mon, 15 Aug 2011 00:38:14 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7F0cE37086169; Mon, 15 Aug 2011 00:38:14 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108150038.p7F0cE37086169@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 00:38: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: r224873 - 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, 15 Aug 2011 00:38:15 -0000 Author: gabor Date: Mon Aug 15 00:38:14 2011 New Revision: 224873 URL: http://svn.freebsd.org/changeset/base/224873 Log: - Add some comments - One TRE-specific portability nit 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 Sun Aug 14 23:26:32 2011 (r224872) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Aug 15 00:38:14 2011 (r224873) @@ -324,6 +324,10 @@ static int fastcmp(const void *, const v free(suff); \ } +/* + * Copies the pattern pat having lenght n to p and stores + * the size in l. + */ #define SAVE_PATTERN(p, l) \ l = (n == 0) ? tre_strlen(pat) : n; \ p = xmalloc((l + 1) * sizeof(tre_char_t)); \ @@ -332,6 +336,9 @@ static int fastcmp(const void *, const v memcpy(p, pat, l * sizeof(tre_char_t)); \ p[l] = TRE_CHAR('\0'); +/* + * Initializes pattern compiling. + */ #define INIT_COMP \ /* Initialize. */ \ memset(fg, 0, sizeof(*fg)); \ @@ -473,9 +480,17 @@ tre_fastcomp(fastmatch_t *fg, const tre_ ((j + fg->len == len) || !(tre_isalnum(str_byte[j + fg->len]) || \ (str_byte[j + fg->len] == '_')))) +/* + * Condition to check whether the match on position j is on a + * word boundary. + */ #define IS_ON_WORD_BOUNDARY \ (_BBOUND_COND && _EBOUND_COND) +/* + * Checks word boundary and shifts one if match is not on a + * boundary. + */ #define CHECK_WORD_BOUNDARY \ if (!IS_ON_WORD_BOUNDARY) \ _SHIFT_ONE; @@ -484,6 +499,10 @@ tre_fastcomp(fastmatch_t *fg, const tre_ ((j == 0) || ((type == STR_WIDE) ? tre_isspace(str_wide[j - 1]) : \ isspace(str_byte[j - 1]))) +/* + * Checks BOL anchor and shifts one if match is not on a + * boundary. + */ #define CHECK_BOL_ANCHOR \ if (!_BOL_COND) \ _SHIFT_ONE; @@ -493,6 +512,10 @@ tre_fastcomp(fastmatch_t *fg, const tre_ ((j + fg->wlen == len) || tre_isspace(str_wide[j + fg->wlen])) : \ ((j + fg->len == len) || isspace(str_byte[j + fg->wlen]))) +/* + * Checks EOL anchor and shifts one if match is not on a + * boundary. + */ #define CHECK_EOL_ANCHOR \ if (!_EOL_COND) \ _SHIFT_ONE; @@ -512,11 +535,12 @@ tre_fastexec(const fastmatch_t *fg, cons const void *startptr = NULL; const tre_char_t *str_wide = data; + /* Calculate length if unspecified. */ if (len == (unsigned)-1) switch (type) { case STR_WIDE: - len = wcslen(str_wide); + len = tre_strlen(str_wide); break; default: len = strlen(str_byte); @@ -601,6 +625,9 @@ tre_fastexec(const fastmatch_t *fg, cons return ret; } +/* + * Frees the resources that were allocated when the pattern was compiled. + */ void tre_fastfree(fastmatch_t *fg) { @@ -627,21 +654,29 @@ fastcmp(const void *pat, const void *dat const tre_char_t *str_wide = data; const tre_char_t *pat_wide = pat; + /* Compare the pattern and the input char-by-char from the last position. */ for (int i = len - 1; i >= 0; i--) { switch (type) { case STR_WIDE: + + /* Check dot */ if (pat_wide[i] == TRE_CHAR('.') && (!newline || (str_wide[i] != TRE_CHAR('\n')))) continue; + + /* Compare */ if (icase ? (towlower(pat_wide[i]) == towlower(str_wide[i])) : (pat_wide[i] == str_wide[i])) continue; break; default: + /* Check dot */ if (pat_byte[i] == '.' && (!newline || (str_byte[i] != '\n'))) continue; + + /* Compare */ if (icase ? (tolower(pat_byte[i]) == tolower(str_byte[i])) : (pat_byte[i] == str_byte[i])) continue; From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 03:41: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 DA2D9106564A; Mon, 15 Aug 2011 03:41: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 C8B5A8FC15; Mon, 15 Aug 2011 03:41: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 p7F3fmJl091866; Mon, 15 Aug 2011 03:41:48 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7F3fm1j091861; Mon, 15 Aug 2011 03:41:48 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108150341.p7F3fm1j091861@svn.freebsd.org> From: Adrian Chadd Date: Mon, 15 Aug 2011 03:41: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: r224874 - 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, 15 Aug 2011 03:41:48 -0000 Author: adrian Date: Mon Aug 15 03:41:48 2011 New Revision: 224874 URL: http://svn.freebsd.org/changeset/base/224874 Log: Do some relatively major changes to my software TX scheduling code. In the first cut, and inspired by some other code I have here which implements this, I decided to hide the per-TID locking behind the hardware TXQ lock. That worked, as the mapping for TID->TXQ is constant and predictable, but it meant the hardware lock is held a lot longer than it needs to be. This has caused all kinds of problems. A 'better' way (for values of 'better') would be to implement fine-grained locking of the per-node and per-TID state. Then those locks can be held as long (short) as they need to be. But for now, I'm going with another temporary solution designed to give me more breathing room whilst I port over the code. I've separated out the TX code into a sort of split setup, with the upper half being net80211/network code, and the lower half being the TX scheduling and completion. * Create a "TX sched" task, which will run the TX scheduling code as a task * Remove a lot of the hardware TXQ locking and asserting * Re-introduce the per-TID software TXQ lock * Since the entry pathways into this code now aren't locked behind the hardware TXQ locks, re-lock the TID software queue access * Re-introduce the short-held hardware TXQ locks, so top and bottom level fiddling of the hardware TXQs don't trample on each other. Now, the "top" level code (ie, anything which wishes to queue packets) will enter via ath_start / ath_raw_xmit / ath_tx_start / ath_tx_raw_start and will either queue directly to the hardware (and that's protected by the hardware TXQ locks) or be queued to the software queue via a call to ath_tx_swq(). ath_tx_swq() simply queues a packet to the software queue (protected by a software TXQ lock) and then the actual TX packet scheduling code is invoked in a task call to ath_tx_sched_proc(). ath_tx_sched_proc() handles scheduling; ath_tx_proc() handles TX completion and further scheduling; since neither of them run simultaneously I can avoid a lot of the complicated locking. This likely won't be the final solution (as I may end up introducing fine-grained locks anyway) but it does push (almost) all of the per-TID state and general aggregation state handling into the ath task, rather than trying to handle concurrent accesses from TX processes, RX/TX tasks and interrupt tasks. Note: net80211 node cleanup and node flush may still need some further locking. I'll look into that shortly. (as node_flush can occur during a scan, for example, and I haven't checked to see whether that runs within or separate to the ath taskqueue.) 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 Mon Aug 15 00:38:14 2011 (r224873) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Mon Aug 15 03:41:48 2011 (r224874) @@ -175,6 +175,7 @@ static void ath_tx_cleanup(struct ath_so static void ath_tx_proc_q0(void *, int); static void ath_tx_proc_q0123(void *, int); static void ath_tx_proc(void *, int); +static void ath_tx_sched_proc(void *, int); static int ath_chan_set(struct ath_softc *, struct ieee80211_channel *); static void ath_draintxq(struct ath_softc *); static void ath_stoprecv(struct ath_softc *); @@ -398,6 +399,7 @@ ath_attach(u_int16_t devid, struct ath_s TASK_INIT(&sc->sc_rxtask, 0, ath_rx_proc, sc); TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc); TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc); + TASK_INIT(&sc->sc_txschedtask, 0, ath_tx_sched_proc, sc); /* * Allocate hardware transmit queues: one queue for @@ -4140,6 +4142,8 @@ ath_tx_default_comp(struct ath_softc *sc /* * Process completed xmit descriptors from the specified queue. + * Kick the packet scheduler if needed. This can occur from this + * particular task. */ static int ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) @@ -4153,7 +4157,6 @@ ath_tx_processq(struct ath_softc *sc, st int nacked; HAL_STATUS status; - ATH_TXQ_LOCK(txq); DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: tx queue %u head %p link %p\n", __func__, txq->axq_qnum, (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), @@ -4161,8 +4164,10 @@ ath_tx_processq(struct ath_softc *sc, st nacked = 0; for (;;) { txq->axq_intrcnt = 0; /* reset periodic desc intr count */ + ATH_TXQ_LOCK(txq); bf = STAILQ_FIRST(&txq->axq_q); if (bf == NULL) { + ATH_TXQ_UNLOCK(txq); break; } ds0 = &bf->bf_desc[0]; @@ -4175,6 +4180,7 @@ ath_tx_processq(struct ath_softc *sc, st status == HAL_OK); #endif if (status == HAL_EINPROGRESS) { + ATH_TXQ_UNLOCK(txq); break; } ATH_TXQ_REMOVE_HEAD(txq, bf_list); @@ -4191,6 +4197,7 @@ ath_tx_processq(struct ath_softc *sc, st if (txq->axq_depth == 0) #endif txq->axq_link = NULL; + ATH_TXQ_UNLOCK(txq); ni = bf->bf_node; /* @@ -4238,7 +4245,6 @@ ath_tx_processq(struct ath_softc *sc, st /* Kick the TXQ scheduler */ ath_txq_sched(sc, txq); - ATH_TXQ_UNLOCK(txq); return nacked; } @@ -4341,6 +4347,39 @@ ath_tx_proc(void *arg, int npending) } /* + * TX scheduling + * + * This calls the per-TXQ TX queue packet scheduling code. + * + * Note: there's no need to handle the mcastq; it doesn't have + * a software TID queue attached (as it's a software queue in + * itself.) + */ +static void +ath_tx_sched_proc(void *arg, int npending) +{ + struct ath_softc *sc = arg; + struct ath_txq *txq; + int i; + + for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { + txq = &sc->sc_txq[i]; + if (ATH_TXQ_SETUP(sc, i)) { + ath_txq_sched(sc, txq); + } + } +} + +/* + * Schedule a TXQ scheduling task to occur. + */ +void +ath_tx_sched_proc_sched(struct ath_softc *sc) +{ + taskqueue_enqueue(sc->sc_tq, &sc->sc_txschedtask); +} + +/* * This is currently used by ath_tx_draintxq() and * ath_tx_tid_free_pkts(). * @@ -4389,23 +4428,17 @@ 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) { + ATH_TXQ_UNLOCK(txq); txq->axq_link = NULL; 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; @@ -4428,7 +4461,6 @@ ath_tx_draintxq(struct ath_softc *sc, st 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 Mon Aug 15 00:38:14 2011 (r224873) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Mon Aug 15 03:41:48 2011 (r224874) @@ -59,5 +59,6 @@ extern void ath_tx_default_comp(struct a int fail); extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status); +extern void ath_tx_sched_proc_sched(struct ath_softc *sc); #endif 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 15 00:38:14 2011 (r224873) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 15 03:41:48 2011 (r224874) @@ -470,6 +470,7 @@ ath_tx_handoff_hw(struct ath_softc *sc, /* * Hand off a packet to the hardware (or mcast queue.) + * * The relevant hardware txq should be locked. */ static void @@ -995,6 +996,11 @@ ath_tx_normal_setup(struct ath_softc *sc /* * Direct-dispatch the current frame to the hardware. + * + * This can be called by the net80211 code. + * + * XXX what about locking? Or, push the seqno assign into the + * XXX aggregate scheduler so its serialised? */ int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, @@ -1130,12 +1136,11 @@ ath_tx_start(struct ath_softc *sc, struc ath_tx_handoff(sc, txq, bf); ATH_TXQ_UNLOCK(txq); } else { - ATH_TXQ_LOCK(txq); /* add to software queue */ ath_tx_swq(sc, ni, txq, bf); - /* Kick txq */ - ath_txq_sched(sc, txq); - ATH_TXQ_UNLOCK(txq); + + /* Schedule a TX scheduler task call to occur */ + ath_tx_sched_proc_sched(sc); } #else /* @@ -1143,10 +1148,7 @@ ath_tx_start(struct ath_softc *sc, struc * direct-dispatch to the hardware. */ ATH_TXQ_LOCK(txq); - if (ismcast) - ath_tx_handoff_mcast(sc, txq, bf); - else - ath_tx_handoff_hw(sc, txq, bf); + ath_tx_handoff(sc, txq, bf); ATH_TXQ_UNLOCK(txq); #endif @@ -1371,21 +1373,24 @@ ath_tx_raw_start(struct ath_softc *sc, s * frames to that node are. */ - ATH_TXQ_LOCK(sc->sc_ac2q[pri]); - if (do_override) + if (do_override) { + ATH_TXQ_LOCK(sc->sc_ac2q[pri]); ath_tx_handoff(sc, sc->sc_ac2q[pri], bf); + ATH_TXQ_UNLOCK(sc->sc_ac2q[pri]); + } else { /* Queue to software queue */ ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf); - - /* Kick txq */ - ath_txq_sched(sc, sc->sc_ac2q[pri]); } - ATH_TXQ_UNLOCK(sc->sc_ac2q[pri]); return 0; } +/* + * Send a raw frame. + * + * This can be called by net80211. + */ int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_bpf_params *params) @@ -1438,6 +1443,14 @@ ath_raw_xmit(struct ieee80211_node *ni, ifp->if_opackets++; sc->sc_stats.ast_tx_raw++; + /* + * This kicks off a TX packet scheduler task, + * pushing packet scheduling out of this thread + * and into a separate context. This will (hopefully) + * simplify locking/contention in the long run. + */ + ath_tx_sched_proc_sched(sc); + return 0; bad2: ATH_TXBUF_LOCK(sc); @@ -1557,8 +1570,6 @@ ath_tx_addto_baw(struct ath_softc *sc, s if (bf->bf_state.bfs_isretried) return; - ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]); - tap = ath_tx_get_tx_tid(an, tid->tid); DPRINTF(sc, ATH_DEBUG_SW_TX_BAW, "%s: tid=%d, seqno %d; window %d:%d\n", __func__, tid->tid, SEQNO(bf->bf_state.bfs_seqno), @@ -1604,8 +1615,6 @@ ath_tx_update_baw(struct ath_softc *sc, int index, cindex; struct ieee80211_tx_ampdu *tap; - ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]); - tap = ath_tx_get_tx_tid(an, tid->tid); DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d, baw=%d:%d, seqno=%d\n", __func__, tid->tid, tap->txa_start, tap->txa_wnd, seqno); @@ -1631,7 +1640,7 @@ ath_tx_update_baw(struct ath_softc *sc, * This is done to make it easy for the software scheduler to * find which nodes have data to send. * - * The relevant hw txq lock should be held. + * The TXQ lock must be held. */ static void ath_tx_tid_sched(struct ath_softc *sc, struct ath_node *an, int tid) @@ -1653,7 +1662,7 @@ ath_tx_tid_sched(struct ath_softc *sc, s * Mark the current node as no longer needing to be polled for * TX packets. * - * The relevant hw txq lock should be held. + * The TXQ lock must NOT be held, it'll be grabbed as needed. */ static void ath_tx_tid_unsched(struct ath_softc *sc, struct ath_node *an, int tid) @@ -1661,13 +1670,13 @@ ath_tx_tid_unsched(struct ath_softc *sc, struct ath_tid *atid = &an->an_tid[tid]; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; - ATH_TXQ_LOCK_ASSERT(txq); - if (atid->sched == 0) return; atid->sched = 0; + ATH_TXQ_LOCK(txq); STAILQ_REMOVE(&txq->axq_tidq, atid, ath_tid, axq_qelem); + ATH_TXQ_UNLOCK(txq); } /* @@ -1738,8 +1747,6 @@ ath_tx_swq(struct ath_softc *sc, struct int pri, tid; struct mbuf *m0 = bf->bf_m; - ATH_TXQ_LOCK_ASSERT(txq); - /* Fetch the TID - non-QoS frames get assigned to TID 16 */ wh = mtod(m0, struct ieee80211_frame *); pri = ath_tx_getac(sc, m0); @@ -1756,10 +1763,14 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_dobaw = 0; /* Queue frame to the tail of the software queue */ + ATH_TXQ_LOCK(atid); ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); + ATH_TXQ_UNLOCK(atid); /* Mark the given tid as having packets to dequeue */ + ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, an, tid); + ATH_TXQ_UNLOCK(txq); } /* @@ -1805,6 +1816,9 @@ ath_tx_tid_init(struct ath_softc *sc, st atid->ac = WME_AC_BE; else atid->ac = TID_TO_WME_AC(i); + snprintf(atid->axq_name, 48, "%p %s %d", + an, device_get_nameunit(sc->sc_dev), i); + mtx_init(&atid->axq_lock, atid->axq_name, NULL, MTX_DEF); } } @@ -1815,9 +1829,6 @@ ath_tx_tid_init(struct ath_softc *sc, st static void ath_tx_tid_pause(struct ath_softc *sc, struct ath_tid *tid) { - struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - - ATH_TXQ_LOCK_ASSERT(txq); tid->paused++; DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: paused = %d\n", __func__, tid->paused); @@ -1828,7 +1839,6 @@ ath_tx_tid_resume(struct ath_softc *sc, { struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - ATH_TXQ_LOCK_ASSERT(txq); tid->paused--; DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: unpaused = %d\n", @@ -1838,8 +1848,11 @@ ath_tx_tid_resume(struct ath_softc *sc, if (tid->axq_depth == 0) return; + ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, tid->an, tid->tid); - ath_txq_sched(sc, txq); + ATH_TXQ_UNLOCK(txq); + + ath_tx_sched_proc_sched(sc); } /* @@ -1876,8 +1889,10 @@ ath_tx_tid_free_pkts(struct ath_softc *s /* Walk the queue, free frames */ for (;;) { + ATH_TXQ_LOCK(atid); bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { + ATH_TXQ_UNLOCK(atid); break; } @@ -1890,6 +1905,7 @@ ath_tx_tid_free_pkts(struct ath_softc *s ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); ATH_TXQ_REMOVE_HEAD(atid, bf_list); + ATH_TXQ_UNLOCK(atid); ath_tx_freebuf(sc, bf, -1); } } @@ -1951,6 +1967,7 @@ ath_tx_tid_cleanup(struct ath_softc *sc, atid = &an->an_tid[tid]; /* Mark hw-queued packets as having no parent now */ ath_tx_tid_txq_unmark(sc, an, tid); + mtx_destroy(&atid->axq_lock); } } @@ -1987,13 +2004,10 @@ ath_tx_comp_cleanup(struct ath_softc *sc 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", @@ -2015,26 +2029,23 @@ ath_tx_comp_cleanup(struct ath_softc *sc * 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; 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 */ + ATH_TXQ_LOCK(atid); bf = STAILQ_FIRST(&atid->axq_q); while (bf) { if (bf->bf_state.bfs_isretried) { @@ -2056,6 +2067,7 @@ ath_tx_cleanup(struct ath_softc *sc, str bf->bf_comp = NULL; bf = STAILQ_NEXT(bf, bf_list); } + ATH_TXQ_UNLOCK(atid); /* The caller is required to pause the TID */ #if 0 @@ -2123,11 +2135,8 @@ ath_tx_aggr_retry_unaggr(struct ath_soft 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]; struct ieee80211_tx_ampdu *tap; - ATH_TXQ_LOCK_ASSERT(txq); - tap = ath_tx_get_tx_tid(an, tid); if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { @@ -2170,8 +2179,13 @@ ath_tx_aggr_retry_unaggr(struct ath_soft * Insert this at the head of the queue, so it's * retried before any current/subsequent frames. */ + ATH_TXQ_LOCK(atid); ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); + ATH_TXQ_UNLOCK(atid); + + ATH_TXQ_LOCK(bf->bf_state.bfs_txq); ath_tx_tid_sched(sc, an, atid->tid); + ATH_TXQ_UNLOCK(bf->bf_state.bfs_txq); } /* @@ -2248,8 +2262,10 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft __func__); for (;;) { + ATH_TXQ_LOCK(atid); bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { + ATH_TXQ_UNLOCK(atid); break; } DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: tid=%d\n", @@ -2272,10 +2288,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft break; } - /* Don't add packets to the BAW that don't contribute to it */ - if (bf->bf_state.bfs_dobaw) - ath_tx_addto_baw(sc, an, atid, bf); - /* * XXX If the seqno is out of BAW, then we should pause this TID * XXX until a completion for this TID allows the BAW to be advanced. @@ -2283,10 +2295,16 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft * XXX for this node/TID until some TX completion has occured * XXX and progress can be made. */ + + /* We've committed to sending it, so remove it from the list */ ATH_TXQ_REMOVE_HEAD(atid, bf_list); + ATH_TXQ_UNLOCK(atid); + + /* Don't add packets to the BAW that don't contribute to it */ + if (bf->bf_state.bfs_dobaw) + ath_tx_addto_baw(sc, an, atid, bf); txq = bf->bf_state.bfs_txq; - ATH_TXQ_LOCK_ASSERT(txq); /* Sanity check! */ if (tid != bf->bf_state.bfs_tid) { @@ -2301,7 +2319,9 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft device_printf(sc->sc_dev, "%s: TID=16?\n", __func__); /* Punt to hardware or software txq */ + ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); } } @@ -2324,14 +2344,17 @@ ath_tx_tid_hw_queue_norm(struct ath_soft __func__, tid); for (;;) { - bf = STAILQ_FIRST(&atid->axq_q); + ATH_TXQ_LOCK(atid); + bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { + ATH_TXQ_UNLOCK(atid); break; } ATH_TXQ_REMOVE_HEAD(atid, bf_list); + ATH_TXQ_UNLOCK(atid); txq = bf->bf_state.bfs_txq; - ATH_TXQ_LOCK_ASSERT(txq); + /* Sanity check! */ if (tid != bf->bf_state.bfs_tid) { device_printf(sc->sc_dev, "%s: bfs_tid %d !=" @@ -2341,7 +2364,9 @@ ath_tx_tid_hw_queue_norm(struct ath_soft bf->bf_comp = NULL; /* XXX default handler */ /* Punt to hardware or software txq */ + ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); } } @@ -2351,13 +2376,10 @@ ath_tx_tid_hw_queue_norm(struct ath_soft * This function walks the list of TIDs (ie, ath_node TIDs * with queued traffic) and attempts to schedule traffic * from them. - * - * This must be called with the HW TXQ lock held. */ void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq) { - ATH_TXQ_LOCK_ASSERT(txq); struct ath_tid *atid, *next; /* @@ -2468,10 +2490,8 @@ ath_addba_request(struct ieee80211_node struct ath_node *an = ATH_NODE(ni); 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]); return sc->sc_addba_request(ni, tap, dialogtoken, baparamset, batimeout); @@ -2503,10 +2523,8 @@ ath_addba_response(struct ieee80211_node */ 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 r; } @@ -2521,21 +2539,16 @@ ath_addba_stop(struct ieee80211_node *ni int tid = WME_AC_TO_TID(tap->txa_ac); struct ath_node *an = ATH_NODE(ni); 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 Mon Aug 15 00:38:14 2011 (r224873) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Mon Aug 15 03:41:48 2011 (r224874) @@ -91,8 +91,10 @@ struct ath_buf; * Note that TID 16 (WME_NUM_TID+1) is for handling non-QoS frames. */ struct ath_tid { - STAILQ_HEAD(,ath_buf) axq_q; /* pending buffers */ + STAILQ_HEAD(,ath_buf) axq_q; /* pending buffers */ + struct mtx axq_lock; /* lock on q and link */ u_int axq_depth; /* SW queue depth */ + char axq_name[48]; /* lock name */ struct ath_node *an; /* pointer to parent */ int tid; /* tid */ int ac; /* which AC gets this trafic */ @@ -417,6 +419,7 @@ struct ath_softc { struct ath_txq sc_txq[HAL_NUM_TX_QUEUES]; struct ath_txq *sc_ac2q[5]; /* WME AC -> h/w q map */ struct task sc_txtask; /* tx int processing */ + struct task sc_txschedtask; /* tx processing task */ int sc_wd_timer; /* count down for wd timer */ struct callout sc_wd_ch; /* tx watchdog timer */ struct ath_tx_radiotap_header sc_tx_th; From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 09:07: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 364D3106566B; Mon, 15 Aug 2011 09:07: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 1C81D8FC08; Mon, 15 Aug 2011 09:07: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 p7F97hYh001808; Mon, 15 Aug 2011 09:07:43 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7F97g7F001806; Mon, 15 Aug 2011 09:07:43 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108150907.p7F97g7F001806@svn.freebsd.org> From: Adrian Chadd Date: Mon, 15 Aug 2011 09:07:42 +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: r224877 - 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, 15 Aug 2011 09:07:43 -0000 Author: adrian Date: Mon Aug 15 09:07:42 2011 New Revision: 224877 URL: http://svn.freebsd.org/changeset/base/224877 Log: * Flip on sending BAR frames, but don't (yet) pause the TID until that's actually completed. * Fix a bug in the retry code - ATH_BUF_BUSY indicates that there may be frames after this one and the hardware QCU may be paused at said frame, waiting for the next TX opportunity to open up (when doing TDMA.) For now, just remove the flag. I'll revisit this before I merge this code into -HEAD. This now queues BAR frames but has exposed a bug in the TID scheduling when sending BAR frames and handling packet loss. I'll fix this in a subsequent commit. 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 15 07:32:44 2011 (r224876) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 15 09:07:42 2011 (r224877) @@ -348,7 +348,7 @@ ath_tx_handoff_mcast(struct ath_softc *s { ATH_TXQ_LOCK_ASSERT(txq); KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, - ("busy status 0x%x", bf->bf_flags)); + ("%s: busy status 0x%x", __func__, bf->bf_flags)); if (txq->axq_link != NULL) { struct ath_buf *last = ATH_TXQ_LAST(txq); struct ieee80211_frame *wh; @@ -386,7 +386,7 @@ ath_tx_handoff_hw(struct ath_softc *sc, */ ATH_TXQ_LOCK_ASSERT(txq); KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, - ("busy status 0x%x", bf->bf_flags)); + ("%s: busy status 0x%x", __func__, bf->bf_flags)); KASSERT(txq->axq_qnum != ATH_TXQ_SWQ, ("ath_tx_handoff_hw called for mcast queue")); @@ -2151,17 +2151,12 @@ ath_tx_aggr_retry_unaggr(struct ath_soft /* Send BAR frame */ /* - * XXX This causes the kernel to recurse - * XXX back into the net80211 layer, then back out - * XXX to the TX queue (via ic->ic_raw_xmit()). - * XXX Because the TXQ lock is held here, - * XXX this will cause a lock recurse panic. + * This'll end up going into net80211 and back out + * again, via ic->ic_raw_xmit(). */ device_printf(sc->sc_dev, "%s: TID %d: send BAR\n", __func__, tid); -#if 0 ieee80211_send_bar(ni, tap, ni->ni_txseqs[tid]); -#endif /* Free buffer, bf is free after this call */ ath_tx_default_comp(sc, bf, 0); @@ -2176,6 +2171,26 @@ ath_tx_aggr_retry_unaggr(struct ath_soft ath_tx_set_retry(sc, bf); /* + * XXX Clear the ATH_BUF_BUSY flag. This is likely incorrect + * XXX and must be revisited before this is merged into -HEAD. + * + * This flag is set in ath_tx_processq() if the HW TXQ has + * further frames on it. The hardware may currently be processing + * the link field in the descriptor (because for TDMA, the + * QCU (TX queue DMA engine) can stop until the next TX slot is + * available and a recycled buffer may still contain a descriptor + * which the currently-paused QCU still points to. + * + * Since I'm not worried about TDMA just for now, I'm going to blank + * the flag. + */ + if (bf->bf_flags & ATH_BUF_BUSY) { + bf->bf_flags &= ~ ATH_BUF_BUSY; + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: bf %p: ATH_BUF_BUSY\n", __func__, bf); + } + + /* * Insert this at the head of the queue, so it's * retried before any current/subsequent frames. */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 13:25: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 2759E1065673; Mon, 15 Aug 2011 13:25: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 170648FC0C; Mon, 15 Aug 2011 13:25: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 p7FDPtlr011750; Mon, 15 Aug 2011 13:25:55 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FDPt3F011747; Mon, 15 Aug 2011 13:25:55 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108151325.p7FDPt3F011747@svn.freebsd.org> From: Adrian Chadd Date: Mon, 15 Aug 2011 13:25:55 +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: r224880 - 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, 15 Aug 2011 13:25:56 -0000 Author: adrian Date: Mon Aug 15 13:25:55 2011 New Revision: 224880 URL: http://svn.freebsd.org/changeset/base/224880 Log: Fix some of the locking to correctly protect things. Specifically, ath_tx_tid_unsched() wasn't correctly locking things, so there was a race condition between the upper half that were unscheduling things (eg a node flush) and the lower half (tx sched and completion task.) Fixing it required re-doing some of the locking. This seems to now cope with TX failures -> BAR -> BAR failure -> DELBA. Normal TX then continues fine. Before, the code would get wedged whilst doing packet TX whilst doing BAR re-transmission, and things would stop progressing until a scan or some other flush would occur. Modified: 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/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 15 12:08:41 2011 (r224879) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 15 13:25:55 2011 (r224880) @@ -1662,7 +1662,7 @@ ath_tx_tid_sched(struct ath_softc *sc, s * Mark the current node as no longer needing to be polled for * TX packets. * - * The TXQ lock must NOT be held, it'll be grabbed as needed. + * The TXQ lock must be held. */ static void ath_tx_tid_unsched(struct ath_softc *sc, struct ath_node *an, int tid) @@ -1670,13 +1670,13 @@ ath_tx_tid_unsched(struct ath_softc *sc, struct ath_tid *atid = &an->an_tid[tid]; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + ATH_TXQ_LOCK_ASSERT(txq); + if (atid->sched == 0) return; atid->sched = 0; - ATH_TXQ_LOCK(txq); STAILQ_REMOVE(&txq->axq_tidq, atid, ath_tid, axq_qelem); - ATH_TXQ_UNLOCK(txq); } /* @@ -1922,29 +1922,18 @@ 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]; - /* - * 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_TXQ_LOCK(txq); ath_tx_tid_unsched(sc, an, tid); + ATH_TXQ_UNLOCK(txq); /* Free packets */ ath_tx_tid_free_pkts(sc, an, tid); - if (! is_owned) - ATH_TXQ_UNLOCK(txq); - } } @@ -1971,27 +1960,16 @@ ath_tx_tid_cleanup(struct ath_softc *sc, } } -#ifdef notyet /* * Handle completion of non-aggregate session frames. */ -static void +void 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; - 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, fail); - } + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: fail=%d\n", __func__, + bf, fail); + ath_tx_default_comp(sc, bf, fail); } -#endif /* * Handle cleanup of aggregate session packets that aren't @@ -2064,7 +2042,7 @@ ath_tx_cleanup(struct ath_softc *sc, str continue; } /* Give these the default completion handler */ - bf->bf_comp = NULL; + bf->bf_comp = ath_tx_normal_comp; bf = STAILQ_NEXT(bf, bf_list); } ATH_TXQ_UNLOCK(atid); @@ -2350,6 +2328,9 @@ ath_tx_tid_hw_queue_norm(struct ath_soft struct ath_txq *txq; struct ath_tid *atid = &an->an_tid[tid]; + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: node %p: TID %d: called\n", + __func__, an, 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", @@ -2376,7 +2357,8 @@ 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 */ + /* Normal completion handler */ + bf->bf_comp = ath_tx_normal_comp; /* Punt to hardware or software txq */ ATH_TXQ_LOCK(txq); @@ -2410,7 +2392,9 @@ ath_txq_sched(struct ath_softc *sc, stru DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d, paused=%d\n", __func__, atid->tid, atid->paused); if (atid->paused) { + ATH_TXQ_LOCK(txq); ath_tx_tid_unsched(sc, atid->an, atid->tid); + ATH_TXQ_UNLOCK(txq); continue; } if (ath_tx_ampdu_running(sc, atid->an, atid->tid)) @@ -2419,8 +2403,10 @@ ath_txq_sched(struct ath_softc *sc, stru ath_tx_tid_hw_queue_norm(sc, atid->an, atid->tid); /* Empty? Remove */ + ATH_TXQ_LOCK(txq); if (atid->axq_depth == 0) ath_tx_tid_unsched(sc, atid->an, atid->tid); + ATH_TXQ_UNLOCK(txq); } } 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 Mon Aug 15 12:08:41 2011 (r224879) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Mon Aug 15 13:25:55 2011 (r224880) @@ -52,6 +52,8 @@ extern void ath_tx_tid_hw_queue_aggr(str extern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, int tid); extern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq); +extern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, + int fail); /* TX addba handling */ extern int ath_addba_request(struct ieee80211_node *ni, From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 13:27: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 C8D7D1065675; Mon, 15 Aug 2011 13:27:02 +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 B83708FC2C; Mon, 15 Aug 2011 13:27: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 p7FDR2Qh011825; Mon, 15 Aug 2011 13:27:02 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FDR23B011820; Mon, 15 Aug 2011 13:27:02 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108151327.p7FDR23B011820@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 13:27: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: r224881 - 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, 15 Aug 2011 13:27:02 -0000 Author: gabor Date: Mon Aug 15 13:27:02 2011 New Revision: 224881 URL: http://svn.freebsd.org/changeset/base/224881 Log: - Use internal names for fast matching that match better TRE's internal names. The POSIX-like names will be used to provide an alternative interface for the fast matching code. Added: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c - copied, changed from r224873, user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h - copied, changed from r224871, user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Deleted: 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/regexec.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 15 13:25:55 2011 (r224880) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 15 13:27:02 2011 (r224881) @@ -44,7 +44,7 @@ char *alloca (); #endif /* HAVE_MALLOC_H */ #include -#include "fastmatch.h" +#include "tre-fastmatch.h" #include "tre-internal.h" #include "tre.h" #include "xmalloc.h" @@ -158,7 +158,7 @@ tre_match(const tre_tnfa_t *tnfa, const /* Check if we can cheat with a faster algorithm */ if (shortcut != NULL) - return tre_fastexec(shortcut, string, len, type, nmatch, pmatch, eflags); + return tre_match_fast(shortcut, string, len, type, nmatch, pmatch, eflags); if (tnfa->num_tags > 0 && nmatch > 0) { Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Mon Aug 15 13:25:55 2011 (r224880) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Mon Aug 15 13:27:02 2011 (r224881) @@ -20,7 +20,7 @@ #include #include -#include "fastmatch.h" +#include "tre-fastmatch.h" #include "tre-internal.h" #include "tre-mem.h" #include "tre-stack.h" @@ -1876,8 +1876,8 @@ tre_compile(regex_t *preg, const tre_cha if (!shortcut) return REG_ESPACE; ret = (cflags & REG_LITERAL) - ? tre_fastcomp_literal(shortcut, regex, n, cflags) - : tre_fastcomp(shortcut, regex, n, cflags); + ? tre_compile_literal(shortcut, regex, n, cflags) + : tre_compile_fast(shortcut, regex, n, cflags); if (ret == REG_OK) { preg->shortcut = shortcut; Copied and modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c (from r224873, user/gabor/tre-integration/contrib/tre/lib/fastmatch.c) ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Aug 15 00:38:14 2011 (r224873, copy source) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 13:27:02 2011 (r224881) @@ -37,9 +37,9 @@ #include #endif -#include "fastmatch.h" #include "hashtable.h" #include "tre.h" +#include "tre-fastmatch.h" #include "tre-internal.h" #include "xmalloc.h" @@ -357,8 +357,8 @@ static int fastcmp(const void *, const v * Returns: REG_OK on success, error code otherwise */ int -tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n, - int cflags) +tre_compile_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n, + int cflags) { INIT_COMP; @@ -387,8 +387,8 @@ 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 *pat, size_t n, - int cflags) +tre_compile_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n, + int cflags) { INIT_COMP; @@ -525,7 +525,7 @@ tre_fastcomp(fastmatch_t *fg, const tre_ * 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_match_fast(const fastmatch_t *fg, const void *data, size_t len, tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags) { unsigned int j = 0; @@ -629,7 +629,7 @@ tre_fastexec(const fastmatch_t *fg, cons * Frees the resources that were allocated when the pattern was compiled. */ void -tre_fastfree(fastmatch_t *fg) +tre_free_fast(fastmatch_t *fg) { #ifdef TRE_WCHAR Copied and modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h (from r224871, user/gabor/tre-integration/contrib/tre/lib/fastmatch.h) ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Sun Aug 14 22:53:02 2011 (r224871, copy source) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Mon Aug 15 13:27:02 2011 (r224881) @@ -58,11 +58,11 @@ typedef struct { bool newline; } fastmatch_t; -int tre_fastcomp_literal(fastmatch_t *preg, const tre_char_t *regex, +int tre_compile_literal(fastmatch_t *preg, const tre_char_t *regex, size_t, int); -int tre_fastcomp(fastmatch_t *preg, const tre_char_t *regex, size_t, int); -int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len, +int tre_compile_fast(fastmatch_t *preg, const tre_char_t *regex, size_t, int); +int tre_match_fast(const fastmatch_t *fg, const void *data, size_t len, tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags); -void tre_fastfree(fastmatch_t *preg); +void tre_free_fast(fastmatch_t *preg); #endif /* FASTMATCH_H */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 13:43: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 E54C5106566B; Mon, 15 Aug 2011 13:43:43 +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 D56068FC0A; Mon, 15 Aug 2011 13:43: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 p7FDhhWh012439; Mon, 15 Aug 2011 13:43:43 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FDhhtl012437; Mon, 15 Aug 2011 13:43:43 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108151343.p7FDhhtl012437@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 13:43: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: r224884 - 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, 15 Aug 2011 13:43:44 -0000 Author: gabor Date: Mon Aug 15 13:43:43 2011 New Revision: 224884 URL: http://svn.freebsd.org/changeset/base/224884 Log: - Properly free resources Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regcomp.c Mon Aug 15 13:33:28 2011 (r224883) +++ user/gabor/tre-integration/contrib/tre/lib/regcomp.c Mon Aug 15 13:43:43 2011 (r224884) @@ -141,6 +141,8 @@ tre_regwcomp(regex_t *preg, const wchar_ void tre_regfree(regex_t *preg) { + if (preg->shortcut != NULL) + tre_free_fast(preg->shortcut); tre_free(preg); } From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 14:00: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 0AD23106564A; Mon, 15 Aug 2011 14:00: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 EEE418FC12; Mon, 15 Aug 2011 14:00: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 p7FE0tBp013252; Mon, 15 Aug 2011 14:00:55 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FE0tff013250; Mon, 15 Aug 2011 14:00:55 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108151400.p7FE0tff013250@svn.freebsd.org> From: Adrian Chadd Date: Mon, 15 Aug 2011 14:00:55 +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: r224885 - 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, 15 Aug 2011 14:00:56 -0000 Author: adrian Date: Mon Aug 15 14:00:55 2011 New Revision: 224885 URL: http://svn.freebsd.org/changeset/base/224885 Log: Update comments to reflect reality 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 15 13:43:43 2011 (r224884) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 15 14:00:55 2011 (r224885) @@ -1116,20 +1116,14 @@ ath_tx_start(struct ath_softc *sc, struc /* * XXX The following is dirty but needed for now. * - * Because of the current way locking is implemented, - * we may end up here because of a call to - * ieee80211_send_bar() from a call inside the completion - * handler. This will have the hardware TXQ locked, - * protecting the TXQ and the node TID state in question. + * Sending a BAR frame can occur from the net80211 txa timer + * (ie, retries) or from the ath txtask (completion call.) + * It queues directly to hardware because the TID is paused + * at this point (and won't be unpaused until the BAR has + * either been TXed successfully or max retries has been + * reached.) * - * So we (a) can't SWQ queue to it, as it'll be queued - * on the same TID which will be paused, and (b) the TXQ - * will be locked anyway, so grabbing the lock will cause - * recursion. - * - * The longer term issue is that the TXQ lock is being held - * for so damned long, and that must be addressed before this - * stuff is merged into -HEAD. + * TODO: sending a BAR should be done at the management rate! */ device_printf(sc->sc_dev, "%s: BAR: TX'ing direct\n", __func__); ATH_TXQ_LOCK(txq); From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 14:59:57 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 3CDA2106567C; Mon, 15 Aug 2011 14:59:57 +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 2D07A8FC23; Mon, 15 Aug 2011 14:59:57 +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 p7FExv9Z015198; Mon, 15 Aug 2011 14:59:57 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FExv8j015196; Mon, 15 Aug 2011 14:59:57 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108151459.p7FExv8j015196@svn.freebsd.org> From: Adrian Chadd Date: Mon, 15 Aug 2011 14:59: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: r224887 - user/adrian/if_ath_tx/sys/net80211 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, 15 Aug 2011 14:59:57 -0000 Author: adrian Date: Mon Aug 15 14:59:56 2011 New Revision: 224887 URL: http://svn.freebsd.org/changeset/base/224887 Log: Fix BAR handling - status == 0 means ACKed or "TX successful", non-zero means failure. Modified: user/adrian/if_ath_tx/sys/net80211/ieee80211_ht.c Modified: user/adrian/if_ath_tx/sys/net80211/ieee80211_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/net80211/ieee80211_ht.c Mon Aug 15 14:19:26 2011 (r224886) +++ user/adrian/if_ath_tx/sys/net80211/ieee80211_ht.c Mon Aug 15 14:59:56 2011 (r224887) @@ -2200,7 +2200,7 @@ bar_tx_complete(struct ieee80211_node *n callout_pending(&tap->txa_timer)) { struct ieee80211com *ic = ni->ni_ic; - if (status) /* ACK'd */ + if (status == 0) /* ACK'd */ bar_stop_timer(tap); ic->ic_bar_response(ni, tap, status); /* NB: just let timer expire so we pace requests */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 15:22: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 F046C1065672; Mon, 15 Aug 2011 15:22:27 +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 E04D98FC08; Mon, 15 Aug 2011 15:22:27 +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 p7FFMRDK015924; Mon, 15 Aug 2011 15:22:27 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FFMRm8015922; Mon, 15 Aug 2011 15:22:27 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108151522.p7FFMRm8015922@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 15:22:27 +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: r224888 - 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, 15 Aug 2011 15:22:28 -0000 Author: gabor Date: Mon Aug 15 15:22:27 2011 New Revision: 224888 URL: http://svn.freebsd.org/changeset/base/224888 Log: - Match macro name to filename Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Mon Aug 15 14:59:56 2011 (r224887) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Mon Aug 15 15:22:27 2011 (r224888) @@ -25,8 +25,8 @@ * SUCH DAMAGE. */ -#ifndef FASTMATCH_H -#define FASTMATCH_H 1 +#ifndef TRE_FASTMATCH_H +#define TRE_FASTMATCH_H 1 #include #include @@ -65,4 +65,4 @@ int tre_match_fast(const fastmatch_t *fg tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags); void tre_free_fast(fastmatch_t *preg); -#endif /* FASTMATCH_H */ +#endif /* TRE_FASTMATCH_H */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 15:26: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 7BEBC106564A; Mon, 15 Aug 2011 15:26: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 6B21D8FC0A; Mon, 15 Aug 2011 15:26: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 p7FFQaht016082; Mon, 15 Aug 2011 15:26:36 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FFQaR3016080; Mon, 15 Aug 2011 15:26:36 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108151526.p7FFQaR3016080@svn.freebsd.org> From: Adrian Chadd Date: Mon, 15 Aug 2011 15:26: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: r224889 - 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, 15 Aug 2011 15:26:36 -0000 Author: adrian Date: Mon Aug 15 15:26:36 2011 New Revision: 224889 URL: http://svn.freebsd.org/changeset/base/224889 Log: More BAR related stuff, which is partially locking related stuff. * Pause/unpause the queue when BAR TX is complete. The problem is that we're not notified when a BAR TX times out and the TX won't happen again - the session is just torn down. So, to work around the API shortcomings for now, hard-code it to cause an unpause at retry == 50. This only works if the hardware _DOES_ call the callback upon frame TX failure. If the callback never gets called, this will all fall in a heap. Luckily, ath will. * Fix locking around TXQ pause/resume calls, as they can occur from the upper layers. This isn't entirely complete, as I'm not similarly locking the pause/resume checks in the rest of the code. I'll do that soon. * Only pause the TID if the ieee80211_send_bar() call was successful. This now seems to work fine with TX packet loss in non-aggregate mode, but I'm not yet convinced that I'm sending the correct sequence number in the BAR frame. I'll look at that next. 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 15 15:22:27 2011 (r224888) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 15 15:26:36 2011 (r224889) @@ -1125,7 +1125,8 @@ ath_tx_start(struct ath_softc *sc, struc * * TODO: sending a BAR should be done at the management rate! */ - device_printf(sc->sc_dev, "%s: BAR: TX'ing direct\n", __func__); + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: BAR: TX'ing direct\n", __func__); ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); ATH_TXQ_UNLOCK(txq); @@ -1819,28 +1820,43 @@ ath_tx_tid_init(struct ath_softc *sc, st /* * Pause the current TID. This stops packets from being transmitted * on it. + * + * XXX As this is being called from upper layers, it needs to be + * XXX properly locked! */ static void ath_tx_tid_pause(struct ath_softc *sc, struct ath_tid *tid) { + ATH_TXQ_LOCK(tid); tid->paused++; DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: paused = %d\n", __func__, tid->paused); + ATH_TXQ_UNLOCK(tid); } +/* + * Unpause the current TID, and schedule it if needed. + * + * XXX As this is being called from upper layers, it needs to be + * XXX properly locked! + */ static void ath_tx_tid_resume(struct ath_softc *sc, struct ath_tid *tid) { struct ath_txq *txq = sc->sc_ac2q[tid->ac]; + ATH_TXQ_LOCK(tid); + 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) + + if (tid->paused || tid->axq_depth == 0) { + ATH_TXQ_UNLOCK(tid); return; + } + ATH_TXQ_UNLOCK(tid); ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, tid->an, tid->tid); @@ -1977,12 +1993,13 @@ ath_tx_comp_cleanup(struct ath_softc *sc int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; - device_printf(sc->sc_dev, "%s: TID %d: incomp=%d\n", + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: incomp=%d\n", __func__, tid, atid->incomp); atid->incomp--; if (atid->incomp == 0) { - device_printf(sc->sc_dev, "%s: TID %d: cleaned up! resume!\n", + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: TID %d: cleaned up! resume!\n", __func__, tid); atid->cleanup_inprogress = 0; ath_tx_tid_resume(sc, atid); @@ -2009,7 +2026,8 @@ ath_tx_cleanup(struct ath_softc *sc, str struct ieee80211_tx_ampdu *tap; struct ath_buf *bf, *bf_next; - device_printf(sc->sc_dev, "%s: TID %d: called\n", __func__, tid); + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: TID %d: called\n", __func__, tid); /* * Update the frames in the software TX queue: @@ -2073,7 +2091,7 @@ ath_tx_cleanup(struct ath_softc *sc, str ath_tx_tid_resume(sc, atid); if (atid->cleanup_inprogress) - device_printf(sc->sc_dev, + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: cleanup needed: %d packets\n", __func__, tid, atid->incomp); } @@ -2119,16 +2137,26 @@ ath_tx_aggr_retry_unaggr(struct ath_soft ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); - /* Pause the TID */ - /* Send BAR frame */ /* * This'll end up going into net80211 and back out * again, via ic->ic_raw_xmit(). */ - device_printf(sc->sc_dev, "%s: TID %d: send BAR\n", + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: send BAR\n", __func__, tid); - ieee80211_send_bar(ni, tap, ni->ni_txseqs[tid]); + if (ieee80211_send_bar(ni, tap, ni->ni_txseqs[tid]) == 0) { + /* + * Pause the TID if this was successful. + * An un-successful BAR TX would never call + * the BAR complete / timeout methods. + */ + ath_tx_tid_pause(sc, atid); + } else { + /* BAR TX failed */ + device_printf(sc->sc_dev, + "%s: TID %d: BAR TX failed\n", + __func__, tid); + } /* Free buffer, bf is free after this call */ ath_tx_default_comp(sc, bf, 0); @@ -2544,6 +2572,11 @@ ath_addba_stop(struct ieee80211_node *ni sc->sc_addba_stop(ni, tap); ath_tx_cleanup(sc, an, tid); + /* + * ath_tx_cleanup will resume the TID if possible, otherwise + * it'll set the cleanup flag, and it'll be unpaused once + * things have been cleaned up. + */ } /* @@ -2552,17 +2585,32 @@ ath_addba_stop(struct ieee80211_node *ni * * It however will call ieee80211_ampdu_stop() which will call * ic->ic_addba_stop(). + * + * XXX This uses a hard-coded max BAR count value; the whole + * XXX BAR TX success or failure should be better handled! */ void ath_bar_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int status) { 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 attempts = tap->txa_attempts; - device_printf(sc->sc_dev, "%s: called\n", __func__); + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: called; status=%d\n", __func__, status); - sc->sc_bar_response(ni, tap, status); /* Note: This may update the BAW details */ + sc->sc_bar_response(ni, tap, status); /* Unpause the TID */ + /* + * XXX if this is attempt=50, the TID will be downgraded + * XXX to a non-aggregate session. So we must unpause the + * XXX TID here or it'll never be done. + */ + if (status == 0 || attempts == 50) + ath_tx_tid_resume(sc, atid); } From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 16:06:28 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 F18DF106564A; Mon, 15 Aug 2011 16:06:28 +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 E1CE48FC13; Mon, 15 Aug 2011 16:06:28 +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 p7FG6S4K017275; Mon, 15 Aug 2011 16:06:28 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FG6SGt017273; Mon, 15 Aug 2011 16:06:28 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108151606.p7FG6SGt017273@svn.freebsd.org> From: Adrian Chadd Date: Mon, 15 Aug 2011 16:06:28 +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: r224890 - user/adrian/if_ath_tx/sys/net80211 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, 15 Aug 2011 16:06:29 -0000 Author: adrian Date: Mon Aug 15 16:06:28 2011 New Revision: 224890 URL: http://svn.freebsd.org/changeset/base/224890 Log: This needs to be fixed too - status=0 means "success". Modified: user/adrian/if_ath_tx/sys/net80211/ieee80211_ht.c Modified: user/adrian/if_ath_tx/sys/net80211/ieee80211_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/net80211/ieee80211_ht.c Mon Aug 15 15:26:36 2011 (r224889) +++ user/adrian/if_ath_tx/sys/net80211/ieee80211_ht.c Mon Aug 15 16:06:28 2011 (r224890) @@ -2212,7 +2212,7 @@ ieee80211_bar_response(struct ieee80211_ struct ieee80211_tx_ampdu *tap, int status) { - if (status != 0) { /* got ACK */ + if (status == 0) { /* got ACK */ IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_11N, ni, "BAR moves BA win <%u:%u> (%u frames) txseq %u tid %u", tap->txa_start, From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 17:23: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 04D46106566C; Mon, 15 Aug 2011 17:23: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 DF4878FC1C; Mon, 15 Aug 2011 17:23: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 p7FHN6Sn019705; Mon, 15 Aug 2011 17:23:06 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FHN6jO019690; Mon, 15 Aug 2011 17:23:06 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108151723.p7FHN6jO019690@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 17:23: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: r224893 - in user/gabor/tre-integration: contrib/tre/lib include lib/libc/regex 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, 15 Aug 2011 17:23:07 -0000 Author: gabor Date: Mon Aug 15 17:23:06 2011 New Revision: 224893 URL: http://svn.freebsd.org/changeset/base/224893 Log: - Clean up header files Deleted: user/gabor/tre-integration/contrib/tre/lib/tre-config.h user/gabor/tre-integration/contrib/tre/lib/tre.h Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c user/gabor/tre-integration/contrib/tre/lib/regerror.c user/gabor/tre-integration/contrib/tre/lib/regexec.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h user/gabor/tre-integration/contrib/tre/lib/tre-internal.h user/gabor/tre-integration/contrib/tre/lib/tre-match-approx.c user/gabor/tre-integration/contrib/tre/lib/tre-match-backtrack.c user/gabor/tre-integration/contrib/tre/lib/tre-match-parallel.c user/gabor/tre-integration/contrib/tre/lib/tre-stack.h user/gabor/tre-integration/include/regex.h user/gabor/tre-integration/lib/libc/regex/Makefile.inc Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regcomp.c Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/regcomp.c Mon Aug 15 17:23:06 2011 (r224893) @@ -12,13 +12,14 @@ #include #include +#include #include +#include "tre-fastmatch.h" #include "tre-internal.h" -#include "tre.h" #include "xmalloc.h" -#ifdef TRE_WEAK_REF +#ifdef TRE_LIBC_BUILD __weak_reference(tre_regcomp, regcomp); __weak_reference(tre_regncomp, regncomp); __weak_reference(tre_regwcomp, regwcomp); Modified: user/gabor/tre-integration/contrib/tre/lib/regerror.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regerror.c Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/regerror.c Mon Aug 15 17:23:06 2011 (r224893) @@ -10,6 +10,7 @@ #include #endif /* HAVE_CONFIG_H */ +#include #include #ifdef HAVE_WCHAR_H #include @@ -19,7 +20,6 @@ #endif /* HAVE_WCTYPE_H */ #include "tre-internal.h" -#include "tre.h" #ifdef HAVE_GETTEXT #include @@ -28,7 +28,7 @@ #define gettext(s) s #endif -#ifdef TRE_WEAK_REF +#ifdef TRE_LIBC_BUILD __weak_reference(tre_regerror, regerror); #endif Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 15 17:23:06 2011 (r224893) @@ -28,6 +28,7 @@ char *alloca (); #endif /* TRE_USE_ALLOCA */ #include +#include #include #include #ifdef HAVE_WCHAR_H @@ -46,10 +47,9 @@ char *alloca (); #include "tre-fastmatch.h" #include "tre-internal.h" -#include "tre.h" #include "xmalloc.h" -#ifdef TRE_WEAK_REF +#ifdef TRE_LIBC_BUILD __weak_reference(tre_regexec, regexec); __weak_reference(tre_regnexec, regnexec); __weak_reference(tre_regwexec, regwexec); Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Mon Aug 15 17:23:06 2011 (r224893) @@ -18,6 +18,7 @@ #endif /* HAVE_CONFIG_H */ #include #include +#include #include #include "tre-fastmatch.h" @@ -27,7 +28,6 @@ #include "tre-ast.h" #include "tre-parse.h" #include "tre-compile.h" -#include "tre.h" #include "xmalloc.h" /* Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 17:23:06 2011 (r224893) @@ -29,6 +29,7 @@ #include #endif /* HAVE_CONFIG_H */ #include +#include #include #include #include @@ -38,7 +39,6 @@ #endif #include "hashtable.h" -#include "tre.h" #include "tre-fastmatch.h" #include "tre-internal.h" #include "xmalloc.h" Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Mon Aug 15 17:23:06 2011 (r224893) @@ -29,10 +29,10 @@ #define TRE_FASTMATCH_H 1 #include +#include #include #include "hashtable.h" -#include "tre.h" #include "tre-internal.h" #define BM_MAX_LEN 1024 Modified: user/gabor/tre-integration/contrib/tre/lib/tre-internal.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-internal.h Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/tre-internal.h Mon Aug 15 17:23:06 2011 (r224893) @@ -9,6 +9,8 @@ #ifndef TRE_INTERNAL_H #define TRE_INTERNAL_H 1 +#include + #ifdef HAVE_WCHAR_H #include #endif /* HAVE_WCHAR_H */ @@ -18,7 +20,6 @@ #endif /* !HAVE_WCTYPE_H */ #include -#include "tre.h" #ifdef TRE_DEBUG #include Modified: user/gabor/tre-integration/contrib/tre/lib/tre-match-approx.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-match-approx.c Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/tre-match-approx.c Mon Aug 15 17:23:06 2011 (r224893) @@ -31,6 +31,7 @@ char *alloca (); #undef __NO_INLINE__ #include +#include #include #include #include @@ -49,7 +50,6 @@ char *alloca (); #include "tre-internal.h" #include "tre-match-utils.h" -#include "tre.h" #include "xmalloc.h" #define TRE_M_COST 0 Modified: user/gabor/tre-integration/contrib/tre/lib/tre-match-backtrack.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-match-backtrack.c Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/tre-match-backtrack.c Mon Aug 15 17:23:06 2011 (r224893) @@ -52,6 +52,7 @@ char *alloca (); #endif /* TRE_USE_ALLOCA */ #include +#include #include #include #ifdef HAVE_WCHAR_H @@ -70,7 +71,6 @@ char *alloca (); #include "tre-internal.h" #include "tre-mem.h" #include "tre-match-utils.h" -#include "tre.h" #include "xmalloc.h" typedef struct { Modified: user/gabor/tre-integration/contrib/tre/lib/tre-match-parallel.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-match-parallel.c Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/tre-match-parallel.c Mon Aug 15 17:23:06 2011 (r224893) @@ -45,6 +45,7 @@ char *alloca (); #endif /* TRE_USE_ALLOCA */ #include +#include #include #include #ifdef HAVE_WCHAR_H @@ -62,7 +63,6 @@ char *alloca (); #include "tre-internal.h" #include "tre-match-utils.h" -#include "tre.h" #include "xmalloc.h" Modified: user/gabor/tre-integration/contrib/tre/lib/tre-stack.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-stack.h Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/contrib/tre/lib/tre-stack.h Mon Aug 15 17:23:06 2011 (r224893) @@ -10,7 +10,7 @@ #ifndef TRE_STACK_H #define TRE_STACK_H 1 -#include "tre.h" +#include typedef struct tre_stack_rec tre_stack_t; Modified: user/gabor/tre-integration/include/regex.h ============================================================================== --- user/gabor/tre-integration/include/regex.h Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/include/regex.h Mon Aug 15 17:23:06 2011 (r224893) @@ -18,6 +18,7 @@ extern "C" { #endif +#ifndef TRE_LIBC_BUILD #define tre_regcomp regcomp #define tre_regerror regerror #define tre_regexec regexec @@ -36,6 +37,29 @@ extern "C" { #define tre_regwncomp regwncomp #define tre_regwnexec regwnexec +#define FUNC_DECL(f) f +#else +#define regcomp tre_regcomp +#define regerror tre_regerror +#define regexec tre_regexec +#define regfree tre_regfree + +#define regacomp tre_regacomp +#define regaexec tre_regaexec +#define regancomp tre_regancomp +#define reganexec tre_reganexec +#define regawncomp tre_regawncomp +#define regawnexec tre_regawnexec +#define regncomp tre_regncomp +#define regnexec tre_regnexec +#define regwcomp tre_regwcomp +#define regwexec tre_regwexec +#define regwncomp tre_regwncomp +#define regwnexec tre_regwnexec + +#define FUNC_DECL(f) tre_##f +#endif + typedef int regoff_t; typedef struct { size_t re_nsub; /* Number of parenthesized subexpressions. */ @@ -106,46 +130,46 @@ typedef enum { /* The POSIX.2 regexp functions */ extern int -regcomp(regex_t *preg, const char *regex, int cflags); +FUNC_DECL(regcomp)(regex_t *preg, const char *regex, int cflags); extern int -regexec(const regex_t *preg, const char *string, size_t nmatch, +FUNC_DECL(regexec)(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags); extern size_t -regerror(int errcode, const regex_t *preg, char *errbuf, +FUNC_DECL(regerror)(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size); extern void -regfree(regex_t *preg); +FUNC_DECL(regfree)(regex_t *preg); #ifdef TRE_WCHAR #include /* Wide character versions (not in POSIX.2). */ extern int -regwcomp(regex_t *preg, const wchar_t *regex, int cflags); +FUNC_DECL(regwcomp)(regex_t *preg, const wchar_t *regex, int cflags); extern int -regwexec(const regex_t *preg, const wchar_t *string, +FUNC_DECL(regwexec)(const regex_t *preg, const wchar_t *string, size_t nmatch, regmatch_t pmatch[], int eflags); #endif /* TRE_WCHAR */ /* Versions with a maximum length argument and therefore the capability to handle null characters in the middle of the strings (not in POSIX.2). */ extern int -regncomp(regex_t *preg, const char *regex, size_t len, int cflags); +FUNC_DECL(regncomp)(regex_t *preg, const char *regex, size_t len, int cflags); extern int -regnexec(const regex_t *preg, const char *string, size_t len, +FUNC_DECL(regnexec)(const regex_t *preg, const char *string, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags); #ifdef TRE_WCHAR extern int -regwncomp(regex_t *preg, const wchar_t *regex, size_t len, int cflags); +FUNC_DECL(regwncomp)(regex_t *preg, const wchar_t *regex, size_t len, int cflags); extern int -regwnexec(const regex_t *preg, const wchar_t *string, size_t len, +FUNC_DECL(regwnexec)(const regex_t *preg, const wchar_t *string, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags); #endif /* TRE_WCHAR */ @@ -177,20 +201,20 @@ typedef struct { /* Approximate matching functions. */ extern int -regaexec(const regex_t *preg, const char *string, +FUNC_DECL(regaexec)(const regex_t *preg, const char *string, regamatch_t *match, regaparams_t params, int eflags); extern int -reganexec(const regex_t *preg, const char *string, size_t len, +FUNC_DECL(reganexec)(const regex_t *preg, const char *string, size_t len, regamatch_t *match, regaparams_t params, int eflags); #ifdef TRE_WCHAR /* Wide character approximate matching. */ extern int -regawexec(const regex_t *preg, const wchar_t *string, +FUNC_DECL(regawexec)(const regex_t *preg, const wchar_t *string, regamatch_t *match, regaparams_t params, int eflags); extern int -regawnexec(const regex_t *preg, const wchar_t *string, size_t len, +FUNC_DECL(regawnexec)(const regex_t *preg, const wchar_t *string, size_t len, regamatch_t *match, regaparams_t params, int eflags); #endif /* TRE_WCHAR */ @@ -213,7 +237,7 @@ typedef struct { } tre_str_source; extern int -reguexec(const regex_t *preg, const tre_str_source *string, +FUNC_DECL(reguexec)(const regex_t *preg, const tre_str_source *string, size_t nmatch, regmatch_t pmatch[], int eflags); /* Returns the version string. The returned string is static. */ Modified: user/gabor/tre-integration/lib/libc/regex/Makefile.inc ============================================================================== --- user/gabor/tre-integration/lib/libc/regex/Makefile.inc Mon Aug 15 17:10:23 2011 (r224892) +++ user/gabor/tre-integration/lib/libc/regex/Makefile.inc Mon Aug 15 17:23:06 2011 (r224893) @@ -3,12 +3,11 @@ .PATH: ${.CURDIR}/../../contrib/tre/lib ${.CURDIR}/regex -CFLAGS+=-DHAVE_CONFIG_H -DTRE_WEAK_REF -I${.CURDIR}/../../contrib/tre +CFLAGS+=-DHAVE_CONFIG_H -DTRE_LIBC_BUILD -I${.CURDIR}/../../contrib/tre -SRCS+= fastmatch.c hashtable.c \ - regcomp.c regerror.c regexec.c tre-ast.c tre-compile.c \ - tre-match-approx.c tre-match-backtrack.c tre-match-parallel.c \ - tre-mem.c tre-parse.c tre-stack.c xmalloc.c +SRCS+= hashtable.c regcomp.c regerror.c regexec.c tre-ast.c tre-compile.c \ + tre-fastmatch.c tre-match-approx.c tre-match-backtrack.c \ + tre-match-parallel.c tre-mem.c tre-parse.c tre-stack.c xmalloc.c MAN+= regex.3 re_format.7 From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 18:03: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 6766B1065673; Mon, 15 Aug 2011 18:03:36 +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 4CF198FC13; Mon, 15 Aug 2011 18:03: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 p7FI3aJj020947; Mon, 15 Aug 2011 18:03:36 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FI3aRi020944; Mon, 15 Aug 2011 18:03:36 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108151803.p7FI3aRi020944@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 18:03: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: r224894 - 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, 15 Aug 2011 18:03:36 -0000 Author: gabor Date: Mon Aug 15 18:03:35 2011 New Revision: 224894 URL: http://svn.freebsd.org/changeset/base/224894 Log: - Eliminate code duplication - TRE-specific style changes Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 15 17:23:06 2011 (r224893) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 15 18:03:35 2011 (r224894) @@ -216,6 +216,28 @@ tre_match(const tre_tnfa_t *tnfa, const return status; } +#define ADJUST_OFFSETS \ + { \ + size_t slen = (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so); \ + size_t offset = pmatch[0].rm_so; \ + int ret; \ + \ + if ((len != (unsigned)-1) && (pmatch[0].rm_eo > len)) \ + return REG_NOMATCH; \ + if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \ + return REG_NOMATCH; \ + ret = tre_match(tnfa, &str[offset], slen, type, nmatch, \ + pmatch, eflags, preg->shortcut); \ + for (unsigned i = 0; (i == 0) || (!(eflags & REG_NOSUB) && \ + (i < nmatch)); i++) \ + { \ + pmatch[i].rm_so += offset; \ + pmatch[i].rm_eo += offset; \ + } \ + return ret; \ + } + + int tre_regnexec(const regex_t *preg, const char *str, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) @@ -224,32 +246,10 @@ tre_regnexec(const regex_t *preg, const tre_str_type_t type = (TRE_MB_CUR_MAX == 1) ? STR_BYTE : STR_MBS; if (eflags & REG_STARTEND) - { - if ((len != (unsigned)-1) && (pmatch[0].rm_eo > len)) - return REG_NOMATCH; - if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) - return REG_NOMATCH; - size_t slen = (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so); - size_t offset = pmatch[0].rm_so; - int ret = tre_match(tnfa, &str[offset], slen, type, nmatch, pmatch, eflags, - preg->shortcut); - pmatch[0].rm_so += offset; - pmatch[0].rm_eo += offset; - if (!(eflags & REG_NOSUB)) - { - for (unsigned i = 1; i < nmatch; i++) - { - pmatch[i].rm_so += offset; - pmatch[i].rm_eo += offset; - } - } - return ret; - } + ADJUST_OFFSETS else - { return tre_match(tnfa, str, len, type, nmatch, pmatch, eflags, preg->shortcut); - } } int @@ -267,34 +267,13 @@ tre_regwnexec(const regex_t *preg, const size_t nmatch, regmatch_t pmatch[], int eflags) { tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; + tre_str_type_t type = STR_WIDE; if (eflags & REG_STARTEND) - { - if ((len != (unsigned)-1) && (pmatch[0].rm_eo > len)) - return REG_NOMATCH; - if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) - return REG_NOMATCH; - size_t slen = (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so); - size_t offset = pmatch[0].rm_so; - int ret = tre_match(tnfa, &str[offset], slen, STR_WIDE, nmatch, pmatch, eflags, - preg->shortcut); - pmatch[0].rm_so += offset; - pmatch[0].rm_eo += offset; - if (!(eflags & REG_NOSUB)) - { - for (unsigned i = 0; i < nmatch; i++) - { - pmatch[i].rm_so += offset; - pmatch[i].rm_eo += offset; - } - } - return ret; - } + ADJUST_OFFSETS else - { return tre_match(tnfa, str, len, STR_WIDE, nmatch, pmatch, eflags, preg->shortcut); - } } int Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Mon Aug 15 17:23:06 2011 (r224893) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Mon Aug 15 18:03:35 2011 (r224894) @@ -1876,8 +1876,8 @@ tre_compile(regex_t *preg, const tre_cha if (!shortcut) return REG_ESPACE; ret = (cflags & REG_LITERAL) - ? tre_compile_literal(shortcut, regex, n, cflags) - : tre_compile_fast(shortcut, regex, n, cflags); + ? tre_compile_literal(shortcut, regex, n, cflags) + : tre_compile_fast(shortcut, regex, n, cflags); if (ret == REG_OK) { preg->shortcut = shortcut; From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 18:04:42 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 E850A106564A; Mon, 15 Aug 2011 18:04:42 +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 D8F898FC17; Mon, 15 Aug 2011 18:04:42 +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 p7FI4grU021066; Mon, 15 Aug 2011 18:04:42 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FI4gIJ021064; Mon, 15 Aug 2011 18:04:42 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108151804.p7FI4gIJ021064@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 18:04:42 +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: r224895 - 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, 15 Aug 2011 18:04:43 -0000 Author: gabor Date: Mon Aug 15 18:04:42 2011 New Revision: 224895 URL: http://svn.freebsd.org/changeset/base/224895 Log: - Use TRE-specific internal macro for better portability Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 18:03:35 2011 (r224894) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 18:04:42 2011 (r224895) @@ -347,7 +347,7 @@ static int fastcmp(const void *, const v fg->newline = (cflags & REG_NEWLINE); \ \ /* Cannot handle REG_ICASE with MB string */ \ - if (fg->icase && (MB_CUR_MAX > 1)) \ + if (fg->icase && (TRE_MB_CUR_MAX > 1)) \ return REG_BADPAT; \ \ /* Calculate length if unspecified */ \ @@ -363,7 +363,7 @@ tre_compile_literal(fastmatch_t *fg, con INIT_COMP; /* Cannot handle word boundaries with MB string */ - if (fg->word && (MB_CUR_MAX > 1)) + if (fg->word && (TRE_MB_CUR_MAX > 1)) return REG_BADPAT; #ifdef TRE_WCHAR @@ -419,7 +419,7 @@ tre_compile_fast(fastmatch_t *fg, const } /* Cannot handle word boundaries with MB string */ - if (fg->word && (MB_CUR_MAX > 1)) + if (fg->word && (TRE_MB_CUR_MAX > 1)) return REG_BADPAT; /* Look for ways to cheat...er...avoid the full regex engine. */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 18:07:41 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 EE019106566B; Mon, 15 Aug 2011 18:07:41 +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 DE5A38FC08; Mon, 15 Aug 2011 18:07:41 +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 p7FI7fL0021498; Mon, 15 Aug 2011 18:07:41 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FI7fon021496; Mon, 15 Aug 2011 18:07:41 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108151807.p7FI7fon021496@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 18:07:41 +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: r224896 - 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, 15 Aug 2011 18:07:42 -0000 Author: gabor Date: Mon Aug 15 18:07:41 2011 New Revision: 224896 URL: http://svn.freebsd.org/changeset/base/224896 Log: - Use TRE-specific xfree() instead of free() Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 18:04:42 2011 (r224895) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 18:07:41 2011 (r224896) @@ -263,7 +263,7 @@ static int fastcmp(const void *, const v for (int i = 0; i < plen; i++) \ wp[i] = towlower(pat[i]); \ _CALC_BMGS(arr, wp, plen); \ - free(wp); \ + xfree(wp); \ } \ else \ _CALC_BMGS(arr, pat, plen); \ @@ -278,7 +278,7 @@ static int fastcmp(const void *, const v for (int i = 0; i < plen; i++) \ p[i] = tolower(pat[i]); \ _CALC_BMGS(arr, p, plen); \ - free(p); \ + xfree(p); \ } \ else \ _CALC_BMGS(arr, pat, plen); \ @@ -321,7 +321,7 @@ static int fastcmp(const void *, const v for (int i = 0; i <= plen - 2; i++) \ arr[plen - 1 - suff[i]] = plen - 1 - i; \ \ - free(suff); \ + xfree(suff); \ } /* @@ -634,9 +634,9 @@ tre_free_fast(fastmatch_t *fg) #ifdef TRE_WCHAR hashtable_free(fg->qsBc_table); - free(fg->wpattern); + xfree(fg->wpattern); #endif - free(fg->pattern); + xfree(fg->pattern); } /* From owner-svn-src-user@FreeBSD.ORG Mon Aug 15 18:49: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 52B86106564A; Mon, 15 Aug 2011 18:49:43 +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 29AC98FC0C; Mon, 15 Aug 2011 18:49: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 p7FInhtS023153; Mon, 15 Aug 2011 18:49:43 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7FInhX8023150; Mon, 15 Aug 2011 18:49:43 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108151849.p7FInhX8023150@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 15 Aug 2011 18:49: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: r224897 - 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, 15 Aug 2011 18:49:43 -0000 Author: gabor Date: Mon Aug 15 18:49:42 2011 New Revision: 224897 URL: http://svn.freebsd.org/changeset/base/224897 Log: - Do not limit pattern length Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 18:07:41 2011 (r224896) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 15 18:49:42 2011 (r224897) @@ -239,14 +239,24 @@ static int fastcmp(const void *, const v */ #define FILL_BMGS \ if (!fg->hasdot) \ - _FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); + { \ + fg->sbmGs = xmalloc(fg->len * sizeof(int)); \ + if (!fg->sbmGs) \ + return REG_ESPACE; \ + _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); + { \ + fg->bmGs = xmalloc(fg->wlen * sizeof(int)); \ + if (!fg->bmGs) \ + return REG_ESPACE; \ + _FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); \ + } #define _FILL_BMGS(arr, pat, plen, wide) \ { \ @@ -634,8 +644,12 @@ tre_free_fast(fastmatch_t *fg) #ifdef TRE_WCHAR hashtable_free(fg->qsBc_table); + if (!fg->hasdot) + xfree(fg->bmGs); xfree(fg->wpattern); #endif + if (!fg->hasdot) + xfree(fg->sbmGs); xfree(fg->pattern); } Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Mon Aug 15 18:07:41 2011 (r224896) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Mon Aug 15 18:49:42 2011 (r224897) @@ -35,21 +35,17 @@ #include "hashtable.h" #include "tre-internal.h" -#define BM_MAX_LEN 1024 - typedef struct { size_t wlen; size_t len; tre_char_t *wpattern; int hasdot; int qsBc[UCHAR_MAX + 1]; - int bmGs[BM_MAX_LEN]; -#ifdef TRE_WCHAR + int *bmGs; char *pattern; int defBc; hashtable *qsBc_table; - int sbmGs[BM_MAX_LEN]; -#endif + int *sbmGs; /* flags */ bool bol; bool eol; From owner-svn-src-user@FreeBSD.ORG Tue Aug 16 00:43:25 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 D2E191065676; Tue, 16 Aug 2011 00:43:25 +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 A86028FC1A; Tue, 16 Aug 2011 00:43:25 +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 p7G0hP9J033911; Tue, 16 Aug 2011 00:43:25 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7G0hP5B033909; Tue, 16 Aug 2011 00:43:25 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108160043.p7G0hP5B033909@svn.freebsd.org> From: Adrian Chadd Date: Tue, 16 Aug 2011 00:43:25 +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: r224900 - 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: Tue, 16 Aug 2011 00:43:25 -0000 Author: adrian Date: Tue Aug 16 00:43:25 2011 New Revision: 224900 URL: http://svn.freebsd.org/changeset/base/224900 Log: Add a missing lock arounnd ath_tid->paused, just to be correct. Update some comments to better reflect reality. 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 15 20:31:27 2011 (r224899) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Tue Aug 16 00:43:25 2011 (r224900) @@ -1821,8 +1821,8 @@ ath_tx_tid_init(struct ath_softc *sc, st * Pause the current TID. This stops packets from being transmitted * on it. * - * XXX As this is being called from upper layers, it needs to be - * XXX properly locked! + * Since this is also called from upper layers as well as the driver, + * it will get the TID lock. */ static void ath_tx_tid_pause(struct ath_softc *sc, struct ath_tid *tid) @@ -1837,8 +1837,8 @@ ath_tx_tid_pause(struct ath_softc *sc, s /* * Unpause the current TID, and schedule it if needed. * - * XXX As this is being called from upper layers, it needs to be - * XXX properly locked! + * Since this is called from upper layers as well as the driver, + * it will get the TID lock and the TXQ lock if needed. */ static void ath_tx_tid_resume(struct ath_softc *sc, struct ath_tid *tid) @@ -2410,15 +2410,21 @@ ath_txq_sched(struct ath_softc *sc, stru /* * Suspend paused queues here; they'll be resumed * once the addba completes or times out. + * + * Since this touches tid->paused, it should lock + * the TID lock before checking. */ DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d, paused=%d\n", __func__, atid->tid, atid->paused); + ATH_TXQ_LOCK(atid); if (atid->paused) { + ATH_TXQ_UNLOCK(atid); ATH_TXQ_LOCK(txq); ath_tx_tid_unsched(sc, atid->an, atid->tid); ATH_TXQ_UNLOCK(txq); continue; } + ATH_TXQ_UNLOCK(atid); if (ath_tx_ampdu_running(sc, atid->an, atid->tid)) ath_tx_tid_hw_queue_aggr(sc, atid->an, atid->tid); else From owner-svn-src-user@FreeBSD.ORG Tue Aug 16 06:26:52 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 307051065670; Tue, 16 Aug 2011 06:26:52 +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 16FDF8FC0A; Tue, 16 Aug 2011 06:26:52 +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 p7G6QpYg044325; Tue, 16 Aug 2011 06:26:51 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7G6QpLA044322; Tue, 16 Aug 2011 06:26:51 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108160626.p7G6QpLA044322@svn.freebsd.org> From: Adrian Chadd Date: Tue, 16 Aug 2011 06:26:51 +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: r224902 - 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: Tue, 16 Aug 2011 06:26:52 -0000 Author: adrian Date: Tue Aug 16 06:26:51 2011 New Revision: 224902 URL: http://svn.freebsd.org/changeset/base/224902 Log: Begin to flesh out the 11n aggregation fields needed in ath_buf. The reference driver splits out the descriptor setup and rate series setup into functions separate from the initial TX path from net80211. The descriptor decisions are made during the ath_tx_start() / ath_tx_raw_xmit() calls, but the rate control selection is done at packet scheduling time. (I'll have to handle raw frames differently, preserving the rate control being requested by the caller.) I may not end up using all of these fields, but the basic premise still holds - ie, in order to do aggregation, I need to delay the descriptor setup until the aggregates are formed, and then only set the rate control flags on the first packet of the series. (Then I have to set the 11n aggregation fields in the first descriptor of each subframe.) Since I'm going for a unified TX path between legacy and non-legacy NICs, I'll have to squirrel away 11n and non-11n copies of the rate control decisions; and then use the correct set when setting up the multi-rate retry fields (either ath_hal_setupxtxdesc(), or ath_hal_set11nratescenario()). Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Tue Aug 16 04:35:42 2011 (r224901) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Tue Aug 16 06:26:51 2011 (r224902) @@ -77,6 +77,12 @@ struct ath_ratectrl { struct ath_ratectrl *ath_rate_attach(struct ath_softc *); void ath_rate_detach(struct ath_ratectrl *); +struct ath_rc_series { + uint8_t rix; + uint8_t tries; + uint8_t flags; + uint32_t max4msframelen; +}; /* * State storage handling. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 16 04:35:42 2011 (r224901) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 16 06:26:51 2011 (r224902) @@ -194,14 +194,11 @@ struct ath_buf { /* This state is kept to support software retries and aggregation */ struct { - int bfs_pktlen; /* length of this packet */ - int bfs_hdrlen; /* length of this packet header */ int bfs_seqno; /* sequence number of this packet */ int bfs_retries; /* retry count */ uint16_t bfs_tid; /* packet TID (or TID_MAX for no QoS) */ uint16_t bfs_pri; /* packet AC priority */ struct ath_txq *bfs_txq; /* eventual dest hardware TXQ */ - uint16_t bfs_al; /* length of aggregate */ uint16_t bfs_pktdur; /* packet duration (at current rate?) */ uint16_t bfs_nframes; /* number of frames in aggregate */ uint16_t bfs_ndelim; /* number of delims for padding */ @@ -210,6 +207,24 @@ struct ath_buf { int bfs_aggrburst:1; /* part of aggregate burst? */ int bfs_isretried:1; /* retried frame? */ int bfs_dobaw:1; /* actually check against BAW? */ + int bfs_shpream:1; /* use short preamble */ + int bfs_istxfrag:1; /* is fragmented */ + int bfs_nfl; /* next fragment length */ + + /* + * These fields are passed into the + * descriptor setup functions. + */ + HAL_PKT_TYPE bfs_atype; /* packet type */ + int bfs_pktlen; /* length of this packet */ + int bfs_hdrlen; /* length of this packet header */ + uint16_t bfs_al; /* length of aggregate */ + int bfs_flags; /* HAL descriptor flags */ + int bfs_keyix; /* crypto key index */ + int bfs_keytype; /* crypto key type */ + enum ieee80211_protmode bfs_protmode; + HAL_11N_RATE_SERIES bfs_rc11n[4]; /* 11n TX series */ + struct ath_rc_series bfs_rc[4]; /* non-11n TX series */ } bf_state; }; typedef STAILQ_HEAD(, ath_buf) ath_bufhead; From owner-svn-src-user@FreeBSD.ORG Tue Aug 16 13:34: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 D56FD1065670; Tue, 16 Aug 2011 13:34: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 C51A88FC16; Tue, 16 Aug 2011 13:34: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 p7GDYYxM059687; Tue, 16 Aug 2011 13:34:34 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7GDYYWs059684; Tue, 16 Aug 2011 13:34:34 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108161334.p7GDYYWs059684@svn.freebsd.org> From: Adrian Chadd Date: Tue, 16 Aug 2011 13:34: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: r224909 - 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: Tue, 16 Aug 2011 13:34:35 -0000 Author: adrian Date: Tue Aug 16 13:34:34 2011 New Revision: 224909 URL: http://svn.freebsd.org/changeset/base/224909 Log: Break out the descriptor setup code and stuff it into ath_tx_setds(). The reference code also sets up the descriptor chain in this function. I'm not doing this just yet. 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 Tue Aug 16 10:52:29 2011 (r224908) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Tue Aug 16 13:34:34 2011 (r224909) @@ -603,6 +603,34 @@ ath_tx_calc_ctsduration(struct ath_hal * return ctsduration; } + +/* + * Setup the descriptor chain for a normal or fast-frame + * frame. + */ +static void +ath_tx_setds(struct ath_softc *sc, struct ath_buf *bf) +{ + struct ath_desc *ds = bf->bf_desc; + struct ath_hal *ah = sc->sc_ah; + + ath_hal_setuptxdesc(ah, ds + , bf->bf_state.bfs_pktlen /* packet length */ + , bf->bf_state.bfs_hdrlen /* header length */ + , bf->bf_state.bfs_atype /* Atheros packet type */ + , bf->bf_state.bfs_txpower /* txpower */ + , bf->bf_state.bfs_txrate0 + , bf->bf_state.bfs_try0 /* series 0 rate/tries */ + , bf->bf_state.bfs_keyix /* key cache index */ + , bf->bf_state.bfs_txantenna /* antenna mode */ + , bf->bf_state.bfs_flags /* flags */ + , bf->bf_state.bfs_ctsrate /* rts/cts rate */ + , bf->bf_state.bfs_ctsduration /* rts/cts duration */ + ); + + /* XXX TODO: Setup descriptor chain */ +} + static int ath_tx_normal_setup(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf, struct mbuf *m0) @@ -917,7 +945,6 @@ ath_tx_normal_setup(struct ath_softc *sc /* This point forward is actual TX bits */ - /* * At this point we are committed to sending the frame * and we don't need to look at m_nextpkt; clear it in @@ -945,31 +972,33 @@ ath_tx_normal_setup(struct ath_softc *sc ieee80211_radiotap_tx(vap, m0); } - if (ath_tx_is_11n(sc)) { rate[0] = rix; try[0] = try0; } + /* Store the decided rate index values away */ + bf->bf_state.bfs_pktlen = pktlen; + bf->bf_state.bfs_hdrlen = hdrlen; + bf->bf_state.bfs_atype = atype; + bf->bf_state.bfs_txpower = ni->ni_txpower; + bf->bf_state.bfs_txrate0 = txrate; + bf->bf_state.bfs_try0 = try0; + bf->bf_state.bfs_keyix = keyix; + bf->bf_state.bfs_txantenna = sc->sc_txantenna; + bf->bf_state.bfs_flags = flags; + bf->bf_txflags = flags; + + /* XXX this should be done in ath_tx_setrate() */ + bf->bf_state.bfs_ctsrate = ctsrate; + bf->bf_state.bfs_ctsduration = ctsduration; + bf->bf_state.bfs_ismrr = ismrr; + /* * Formulate first tx descriptor with tx controls. */ - /* XXX check return value? */ - /* XXX is this ok to call for 11n descriptors? */ - /* XXX or should it go through the first, next, last 11n calls? */ - ath_hal_setuptxdesc(ah, ds - , pktlen /* packet length */ - , hdrlen /* header length */ - , atype /* Atheros packet type */ - , ni->ni_txpower /* txpower */ - , txrate, try0 /* series 0 rate/tries */ - , keyix /* key cache index */ - , sc->sc_txantenna /* antenna mode */ - , flags /* flags */ - , ctsrate /* rts/cts rate */ - , ctsduration /* rts/cts duration */ - ); - bf->bf_txflags = flags; + ath_tx_setds(sc, bf); + /* * Setup the multi-rate retry state only when we're * going to use it. This assumes ath_hal_setuptxdesc @@ -986,6 +1015,7 @@ ath_tx_normal_setup(struct ath_softc *sc ATH_NODE_UNLOCK(an); } + /* Setup 11n rate scenario for 11n NICs only */ if (ath_tx_is_11n(sc)) { ath_buf_set_rate(sc, ni, bf, pktlen, flags, ctsrate, (atype == HAL_PKT_TYPE_PSPOLL), rate, try); @@ -1277,20 +1307,26 @@ ath_tx_raw_start(struct ath_softc *sc, s */ ds = bf->bf_desc; /* XXX check return value? */ - ath_hal_setuptxdesc(ah, ds - , pktlen /* packet length */ - , hdrlen /* header length */ - , atype /* Atheros packet type */ - , params->ibp_power /* txpower */ - , txrate, try0 /* series 0 rate/tries */ - , keyix /* key cache index */ - , txantenna /* antenna mode */ - , flags /* flags */ - , ctsrate /* rts/cts rate */ - , ctsduration /* rts/cts duration */ - ); + + /* Store the decided rate index values away */ + bf->bf_state.bfs_pktlen = pktlen; + bf->bf_state.bfs_hdrlen = hdrlen; + bf->bf_state.bfs_atype = atype; + bf->bf_state.bfs_txpower = params->ibp_power; + bf->bf_state.bfs_txrate0 = txrate; + bf->bf_state.bfs_try0 = try0; + bf->bf_state.bfs_keyix = keyix; + bf->bf_state.bfs_txantenna = txantenna; + bf->bf_state.bfs_flags = flags; bf->bf_txflags = flags; + /* XXX this should be done in ath_tx_setrate() */ + bf->bf_state.bfs_ctsrate = ctsrate; + bf->bf_state.bfs_ctsduration = ctsduration; + bf->bf_state.bfs_ismrr = ismrr; + + ath_tx_setds(sc, bf); + if (ath_tx_is_11n(sc)) { rate[0] = ath_tx_findrix(sc, params->ibp_rate0); try[0] = params->ibp_try0; Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 16 10:52:29 2011 (r224908) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 16 13:34:34 2011 (r224909) @@ -209,6 +209,7 @@ struct ath_buf { int bfs_dobaw:1; /* actually check against BAW? */ int bfs_shpream:1; /* use short preamble */ int bfs_istxfrag:1; /* is fragmented */ + int bfs_ismrr:1; /* do multi-rate TX retry */ int bfs_nfl; /* next fragment length */ /* @@ -220,10 +221,15 @@ struct ath_buf { int bfs_hdrlen; /* length of this packet header */ uint16_t bfs_al; /* length of aggregate */ int bfs_flags; /* HAL descriptor flags */ + int bfs_txrate0; /* first TX rate */ + int bfs_try0; /* first try count */ int bfs_keyix; /* crypto key index */ - int bfs_keytype; /* crypto key type */ + int bfs_txpower; /* tx power */ + int bfs_txantenna; /* TX antenna config */ enum ieee80211_protmode bfs_protmode; HAL_11N_RATE_SERIES bfs_rc11n[4]; /* 11n TX series */ + int bfs_ctsrate; /* CTS rate */ + int bfs_ctsduration; /* CTS duration (pre-11n NICs) */ struct ath_rc_series bfs_rc[4]; /* non-11n TX series */ } bf_state; }; From owner-svn-src-user@FreeBSD.ORG Tue Aug 16 14:25:41 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 90728106564A; Tue, 16 Aug 2011 14:25:41 +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 7E4958FC17; Tue, 16 Aug 2011 14:25:41 +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 p7GEPfW6061365; Tue, 16 Aug 2011 14:25:41 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7GEPfGY061356; Tue, 16 Aug 2011 14:25:41 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108161425.p7GEPfGY061356@svn.freebsd.org> From: Adrian Chadd Date: Tue, 16 Aug 2011 14:25:41 +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: r224912 - in user/adrian/if_ath_tx/sys/dev/ath: . ath_rate/amrr ath_rate/onoe ath_rate/sample 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, 16 Aug 2011 14:25:41 -0000 Author: adrian Date: Tue Aug 16 14:25:41 2011 New Revision: 224912 URL: http://svn.freebsd.org/changeset/base/224912 Log: Begin to modify the ath rate path to use the stuff hiding in ath_buf now, rather than passing around all these extra fields. The (eventual) aim is to fully setup ath_buf.bf_state.bfs_rc with the legacy rate code information, then populate the rate series stuff as needed. Then legacy chips can use the bfs_rc rates, and 11n chipsets can use the rate series (which will also be set for legacy rates.) TODO: making sure the short preamble flag is set correctly everywhere. This commit doesn't fully fix onoe/amrr to use the new API, I must do that before I merge this into -HEAD. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/amrr/amrr.c user/adrian/if_ath_tx/sys/dev/ath/ath_rate/onoe/onoe.c user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/amrr/amrr.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_rate/amrr/amrr.c Tue Aug 16 14:23:16 2011 (r224911) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/amrr/amrr.c Tue Aug 16 14:25:41 2011 (r224912) @@ -126,7 +126,7 @@ ath_rate_getxtxrates(struct ath_softc *s { struct amrr_node *amn = ATH_NODE_AMRR(an); -/* rix[0] = amn->amn_tx_rate0; */ + rix[0] = amn->amn_tx_rate0; rix[1] = amn->amn_tx_rate1; rix[2] = amn->amn_tx_rate2; rix[3] = amn->amn_tx_rate3; Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/onoe/onoe.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_rate/onoe/onoe.c Tue Aug 16 14:23:16 2011 (r224911) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/onoe/onoe.c Tue Aug 16 14:25:41 2011 (r224912) @@ -134,7 +134,7 @@ ath_rate_getxtxrates(struct ath_softc *s { struct onoe_node *on = ATH_NODE_ONOE(an); -/* rix[0] = on->on_tx_rate0; */ + rix[0] = on->on_tx_rate0; rix[1] = on->on_tx_rate1; rix[2] = on->on_tx_rate2; rix[3] = on->on_tx_rate3; Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Tue Aug 16 14:23:16 2011 (r224911) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Tue Aug 16 14:25:41 2011 (r224912) @@ -446,22 +446,24 @@ done: */ void ath_rate_getxtxrates(struct ath_softc *sc, struct ath_node *an, - uint8_t rix0, uint8_t *rix, uint8_t *try) + uint8_t rix0, struct ath_rc_series *rc) { struct sample_node *sn = ATH_NODE_SAMPLE(an); const struct txschedule *sched = &sn->sched[rix0]; KASSERT(rix0 == sched->r0, ("rix0 (%x) != sched->r0 (%x)!\n", rix0, sched->r0)); -/* rix[0] = sched->r0; */ - rix[1] = sched->r1; - rix[2] = sched->r2; - rix[3] = sched->r3; - - try[0] = sched->t0; - try[1] = sched->t1; - try[2] = sched->t2; - try[3] = sched->t3; + rc[0].flags = rc[1].flags = rc[2].flags = rc[3].flags = 0; + + rc[0].rix = sched->r0; + rc[1].rix = sched->r1; + rc[2].rix = sched->r2; + rc[3].rix = sched->r3; + + rc[0].tries = sched->t0; + rc[1].tries = sched->t1; + rc[2].tries = sched->t2; + rc[3].tries = sched->t3; } void 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 Tue Aug 16 14:23:16 2011 (r224911) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Tue Aug 16 14:25:41 2011 (r224912) @@ -654,10 +654,6 @@ ath_tx_normal_setup(struct ath_softc *sc HAL_BOOL shortPreamble; struct ath_node *an; u_int pri; - uint8_t try[4], rate[4]; - - bzero(try, sizeof(try)); - bzero(rate, sizeof(rate)); wh = mtod(m0, struct ieee80211_frame *); iswep = wh->i_fc[1] & IEEE80211_FC1_WEP; @@ -972,9 +968,16 @@ ath_tx_normal_setup(struct ath_softc *sc ieee80211_radiotap_tx(vap, m0); } + /* Blank the legacy rate array */ + bzero(&bf->bf_state.bfs_rc, sizeof(bf->bf_state.bfs_rc)); + + /* + * ath_buf_set_rate needs at least one rate/try to setup + * the rate scenario. + */ if (ath_tx_is_11n(sc)) { - rate[0] = rix; - try[0] = try0; + bf->bf_state.bfs_rc[0].rix = rix; + bf->bf_state.bfs_rc[0].tries = try0; } /* Store the decided rate index values away */ @@ -988,6 +991,7 @@ ath_tx_normal_setup(struct ath_softc *sc bf->bf_state.bfs_txantenna = sc->sc_txantenna; bf->bf_state.bfs_flags = flags; bf->bf_txflags = flags; + bf->bf_state.bfs_shpream = shortPreamble; /* XXX this should be done in ath_tx_setrate() */ bf->bf_state.bfs_ctsrate = ctsrate; @@ -1009,17 +1013,15 @@ ath_tx_normal_setup(struct ath_softc *sc if (ismrr) { ATH_NODE_LOCK(an); if (ath_tx_is_11n(sc)) - ath_rate_getxtxrates(sc, an, rix, rate, try); + ath_rate_getxtxrates(sc, an, rix, bf->bf_state.bfs_rc); else ath_rate_setupxtxdesc(sc, an, ds, shortPreamble, rix); ATH_NODE_UNLOCK(an); } /* Setup 11n rate scenario for 11n NICs only */ - if (ath_tx_is_11n(sc)) { - ath_buf_set_rate(sc, ni, bf, pktlen, flags, ctsrate, - (atype == HAL_PKT_TYPE_PSPOLL), rate, try); - } + if (ath_tx_is_11n(sc)) + ath_buf_set_rate(sc, ni, bf); return 0; } @@ -1198,13 +1200,9 @@ ath_tx_raw_start(struct ath_softc *sc, s const HAL_RATE_TABLE *rt; struct ath_desc *ds; u_int pri; - uint8_t try[4], rate[4]; int o_tid = -1; int do_override; - bzero(try, sizeof(try)); - bzero(rate, sizeof(rate)); - wh = mtod(m0, struct ieee80211_frame *); ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); hdrlen = ieee80211_anyhdrsize(wh); @@ -1319,6 +1317,8 @@ ath_tx_raw_start(struct ath_softc *sc, s bf->bf_state.bfs_txantenna = txantenna; bf->bf_state.bfs_flags = flags; bf->bf_txflags = flags; + bf->bf_state.bfs_shpream = + !! (params->ibp_flags & IEEE80211_BPF_SHORTPRE); /* XXX this should be done in ath_tx_setrate() */ bf->bf_state.bfs_ctsrate = ctsrate; @@ -1327,21 +1327,32 @@ ath_tx_raw_start(struct ath_softc *sc, s ath_tx_setds(sc, bf); + /* Blank the legacy rate array */ + bzero(&bf->bf_state.bfs_rc, sizeof(bf->bf_state.bfs_rc)); + if (ath_tx_is_11n(sc)) { - rate[0] = ath_tx_findrix(sc, params->ibp_rate0); - try[0] = params->ibp_try0; + bf->bf_state.bfs_rc[0].rix = ath_tx_findrix(sc, params->ibp_rate0); + bf->bf_state.bfs_rc[0].tries = params->ibp_try0; if (ismrr) { /* Remember, rate[] is actually an array of rix's -adrian */ - rate[0] = ath_tx_findrix(sc, params->ibp_rate0); - rate[1] = ath_tx_findrix(sc, params->ibp_rate1); - rate[2] = ath_tx_findrix(sc, params->ibp_rate2); - rate[3] = ath_tx_findrix(sc, params->ibp_rate3); - - try[0] = params->ibp_try0; - try[1] = params->ibp_try1; - try[2] = params->ibp_try2; - try[3] = params->ibp_try3; + bf->bf_state.bfs_rc[0].rix = + ath_tx_findrix(sc, params->ibp_rate0); + bf->bf_state.bfs_rc[1].rix = + ath_tx_findrix(sc, params->ibp_rate1); + bf->bf_state.bfs_rc[2].rix = + ath_tx_findrix(sc, params->ibp_rate2); + bf->bf_state.bfs_rc[3].rix = + ath_tx_findrix(sc, params->ibp_rate3); + + bf->bf_state.bfs_rc[0].tries = + params->ibp_try0; + bf->bf_state.bfs_rc[1].tries = + params->ibp_try1; + bf->bf_state.bfs_rc[2].tries = + params->ibp_try2; + bf->bf_state.bfs_rc[3].tries = + params->ibp_try3; } } else { if (ismrr) { @@ -1376,8 +1387,7 @@ ath_tx_raw_start(struct ath_softc *sc, s * notice that rix doesn't include any of the "magic" flags txrate * does for communicating "other stuff" to the HAL. */ - ath_buf_set_rate(sc, ni, bf, pktlen, flags, ctsrate, - (atype == HAL_PKT_TYPE_PSPOLL), rate, try); + ath_buf_set_rate(sc, ni, bf); } /* NB: no buffered multicast in power save support */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Tue Aug 16 14:23:16 2011 (r224911) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Tue Aug 16 14:25:41 2011 (r224912) @@ -122,8 +122,7 @@ int ath_max_4ms_framelen[4][32] = { */ static void ath_rateseries_setup(struct ath_softc *sc, struct ieee80211_node *ni, - HAL_11N_RATE_SERIES *series, unsigned int pktlen, uint8_t *rix, - uint8_t *try, int flags) + struct ath_buf *bf, HAL_11N_RATE_SERIES *series) { #define HT_RC_2_STREAMS(_rc) ((((_rc) & 0x78) >> 3) + 1) struct ieee80211com *ic = ni->ni_ic; @@ -131,6 +130,9 @@ ath_rateseries_setup(struct ath_softc *s HAL_BOOL shortPreamble = AH_FALSE; const HAL_RATE_TABLE *rt = sc->sc_currates; int i; + int pktlen = bf->bf_state.bfs_pktlen; + int flags = bf->bf_state.bfs_flags; + struct ath_rc_series *rc = bf->bf_state.bfs_rc; if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)) @@ -139,10 +141,10 @@ ath_rateseries_setup(struct ath_softc *s memset(series, 0, sizeof(HAL_11N_RATE_SERIES) * 4); for (i = 0; i < 4; i++) { /* Only set flags for actual TX attempts */ - if (try[i] == 0) + if (rc[i].tries == 0) continue; - series[i].Tries = try[i]; + series[i].Tries = rc[i].tries; /* * XXX this isn't strictly correct - sc_txchainmask @@ -181,7 +183,7 @@ ath_rateseries_setup(struct ath_softc *s ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20) series[i].RateFlags |= HAL_RATESERIES_HALFGI; - series[i].Rate = rt->info[rix[i]].rateCode; + series[i].Rate = rt->info[rc[i].rix].rateCode; /* PktDuration doesn't include slot, ACK, RTS, etc timing - it's just the packet duration */ if (series[i].Rate & IEEE80211_RATE_MCS) { @@ -193,9 +195,10 @@ ath_rateseries_setup(struct ath_softc *s , series[i].RateFlags & HAL_RATESERIES_HALFGI); } else { if (shortPreamble) - series[i].Rate |= rt->info[rix[i]].shortPreamble; + series[i].Rate |= + rt->info[rc[i].rix].shortPreamble; series[i].PktDuration = ath_hal_computetxtime(ah, - rt, pktlen, rix[i], shortPreamble); + rt, pktlen, rc[i].rix, shortPreamble); } } #undef HT_RC_2_STREAMS @@ -227,18 +230,21 @@ ath_rateseries_print(HAL_11N_RATE_SERIES */ void -ath_buf_set_rate(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf, - int pktlen, int flags, uint8_t ctsrate, int is_pspoll, uint8_t *rix, uint8_t *try) +ath_buf_set_rate(struct ath_softc *sc, struct ieee80211_node *ni, + struct ath_buf *bf) { HAL_11N_RATE_SERIES series[4]; struct ath_desc *ds = bf->bf_desc; struct ath_desc *lastds = NULL; struct ath_hal *ah = sc->sc_ah; + int is_pspoll = (bf->bf_state.bfs_atype == HAL_PKT_TYPE_PSPOLL); + int ctsrate = bf->bf_state.bfs_ctsrate; + int flags = bf->bf_state.bfs_flags; /* Setup rate scenario */ memset(&series, 0, sizeof(series)); - ath_rateseries_setup(sc, ni, series, pktlen, rix, try, flags); + ath_rateseries_setup(sc, ni, bf, series); /* Enforce AR5416 aggregate limit - can't do RTS w/ an agg frame > 8k */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Tue Aug 16 14:23:16 2011 (r224911) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Tue Aug 16 14:25:41 2011 (r224912) @@ -41,8 +41,6 @@ enum { extern int ath_max_4ms_framelen[4][32]; extern void ath_buf_set_rate(struct ath_softc *sc, - struct ieee80211_node *ni, struct ath_buf *bf, - int pktlen, int flags, uint8_t ctsrate, int is_pspoll, - uint8_t *rix, uint8_t *try); + struct ieee80211_node *ni, struct ath_buf *bf); #endif Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Tue Aug 16 14:23:16 2011 (r224911) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Tue Aug 16 14:25:41 2011 (r224912) @@ -77,6 +77,8 @@ struct ath_ratectrl { struct ath_ratectrl *ath_rate_attach(struct ath_softc *); void ath_rate_detach(struct ath_ratectrl *); +#define ATH_RC_NUM 4 + struct ath_rc_series { uint8_t rix; uint8_t tries; @@ -111,7 +113,7 @@ void ath_rate_newassoc(struct ath_softc * Return the four TX rate index and try counts for the current data packet. */ void ath_rate_getxtxrates(struct ath_softc *sc, struct ath_node *an, - uint8_t rix0, uint8_t *rix, uint8_t *try); + uint8_t rix0, struct ath_rc_series *rc); /* * Return the transmit info for a data packet. If multi-rate state Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 16 14:23:16 2011 (r224911) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 16 14:25:41 2011 (r224912) @@ -227,10 +227,10 @@ struct ath_buf { int bfs_txpower; /* tx power */ int bfs_txantenna; /* TX antenna config */ enum ieee80211_protmode bfs_protmode; - HAL_11N_RATE_SERIES bfs_rc11n[4]; /* 11n TX series */ + HAL_11N_RATE_SERIES bfs_rc11n[ATH_RC_NUM]; /* 11n TX series */ int bfs_ctsrate; /* CTS rate */ int bfs_ctsduration; /* CTS duration (pre-11n NICs) */ - struct ath_rc_series bfs_rc[4]; /* non-11n TX series */ + struct ath_rc_series bfs_rc[ATH_RC_NUM]; /* non-11n TX series */ } bf_state; }; typedef STAILQ_HEAD(, ath_buf) ath_bufhead; From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 02:01:37 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 D15AF106566B; Wed, 17 Aug 2011 02:01:37 +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 C084F8FC0A; Wed, 17 Aug 2011 02:01:37 +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 p7H21blC082336; Wed, 17 Aug 2011 02:01:37 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H21bJX082333; Wed, 17 Aug 2011 02:01:37 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170201.p7H21bJX082333@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 02:01: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: r224923 - 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, 17 Aug 2011 02:01:37 -0000 Author: adrian Date: Wed Aug 17 02:01:37 2011 New Revision: 224923 URL: http://svn.freebsd.org/changeset/base/224923 Log: Break out the rate setup code into a new function, ath_tx_set_ratectrl(), which programs the 11n or non-11n rate setup as needed. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athrate.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 Tue Aug 16 23:47:53 2011 (r224922) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 02:01:37 2011 (r224923) @@ -631,6 +631,49 @@ ath_tx_setds(struct ath_softc *sc, struc /* XXX TODO: Setup descriptor chain */ } +/* + * Set the rate control fields in the given descriptor based on + * the bf_state fields and node state. + * + * The bfs fields should already be set with the relevant rate + * control information, including whether MRR is to be enabled. + * + * Since the FreeBSD HAL currently sets up the first TX rate + * in ath_hal_setuptxdesc(), this will setup the MRR + * conditionally for the pre-11n chips, and call ath_buf_set_rate + * unconditionally for 11n chips. These require the 11n rate + * scenario to be set if MCS rates are enabled, so it's easier + * to just always call it. The caller can then only set rates 2, 3 + * and 4 if multi-rate retry is needed. + */ +static void +ath_tx_set_ratectrl(struct ath_softc *sc, struct ieee80211_node *ni, + struct ath_buf *bf) +{ + const HAL_RATE_TABLE *rt = sc->sc_currates; + struct ath_rc_series *rc = bf->bf_state.bfs_rc; + uint8_t rate[4]; + int i; + + if (ath_tx_is_11n(sc)) { + /* Always setup rate series */ + ath_buf_set_rate(sc, ni, bf); + } else if (bf->bf_state.bfs_ismrr) { + /* Only call for legacy NICs if MRR */ + for (i = 0; i < 4; i++) { + rate[i] = rt->info[rc[i].rix].rateCode; + if (bf->bf_state.bfs_shpream) { + rate[i] |= rt->info[rc[i].rix].shortPreamble; + } + } + ath_hal_setupxtxdesc(sc->sc_ah, bf->bf_desc + , rate[1], rc[1].tries + , rate[2], rc[2].tries + , rate[3], rc[3].tries + ); + } +} + static int ath_tx_normal_setup(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf, struct mbuf *m0) @@ -975,10 +1018,8 @@ ath_tx_normal_setup(struct ath_softc *sc * ath_buf_set_rate needs at least one rate/try to setup * the rate scenario. */ - if (ath_tx_is_11n(sc)) { - bf->bf_state.bfs_rc[0].rix = rix; - bf->bf_state.bfs_rc[0].tries = try0; - } + bf->bf_state.bfs_rc[0].rix = rix; + bf->bf_state.bfs_rc[0].tries = try0; /* Store the decided rate index values away */ bf->bf_state.bfs_pktlen = pktlen; @@ -999,11 +1040,6 @@ ath_tx_normal_setup(struct ath_softc *sc bf->bf_state.bfs_ismrr = ismrr; /* - * Formulate first tx descriptor with tx controls. - */ - ath_tx_setds(sc, bf); - - /* * Setup the multi-rate retry state only when we're * going to use it. This assumes ath_hal_setuptxdesc * initializes the descriptors (so we don't have to) @@ -1012,16 +1048,19 @@ ath_tx_normal_setup(struct ath_softc *sc */ if (ismrr) { ATH_NODE_LOCK(an); - if (ath_tx_is_11n(sc)) - ath_rate_getxtxrates(sc, an, rix, bf->bf_state.bfs_rc); - else - ath_rate_setupxtxdesc(sc, an, ds, shortPreamble, rix); + ath_rate_getxtxrates(sc, an, rix, bf->bf_state.bfs_rc); ATH_NODE_UNLOCK(an); } - /* Setup 11n rate scenario for 11n NICs only */ - if (ath_tx_is_11n(sc)) - ath_buf_set_rate(sc, ni, bf); + /* + * Formulate first tx descriptor with tx controls. + */ + ath_tx_setds(sc, bf); + + /* + * Setup rate control series. + */ + ath_tx_set_ratectrl(sc, ni, bf); return 0; } @@ -1193,7 +1232,7 @@ ath_tx_raw_start(struct ath_softc *sc, s struct ieee80211vap *vap = ni->ni_vap; int error, ismcast, ismrr; int keyix, hdrlen, pktlen, try0, txantenna; - u_int8_t rix, cix, txrate, ctsrate, rate1, rate2, rate3; + u_int8_t rix, cix, txrate, ctsrate; struct ieee80211_frame *wh; u_int flags, ctsduration; HAL_PKT_TYPE atype; @@ -1325,70 +1364,31 @@ ath_tx_raw_start(struct ath_softc *sc, s bf->bf_state.bfs_ctsduration = ctsduration; bf->bf_state.bfs_ismrr = ismrr; - ath_tx_setds(sc, bf); - /* Blank the legacy rate array */ bzero(&bf->bf_state.bfs_rc, sizeof(bf->bf_state.bfs_rc)); - if (ath_tx_is_11n(sc)) { - bf->bf_state.bfs_rc[0].rix = ath_tx_findrix(sc, params->ibp_rate0); - bf->bf_state.bfs_rc[0].tries = params->ibp_try0; - - if (ismrr) { - /* Remember, rate[] is actually an array of rix's -adrian */ - bf->bf_state.bfs_rc[0].rix = - ath_tx_findrix(sc, params->ibp_rate0); - bf->bf_state.bfs_rc[1].rix = - ath_tx_findrix(sc, params->ibp_rate1); - bf->bf_state.bfs_rc[2].rix = - ath_tx_findrix(sc, params->ibp_rate2); - bf->bf_state.bfs_rc[3].rix = - ath_tx_findrix(sc, params->ibp_rate3); - - bf->bf_state.bfs_rc[0].tries = - params->ibp_try0; - bf->bf_state.bfs_rc[1].tries = - params->ibp_try1; - bf->bf_state.bfs_rc[2].tries = - params->ibp_try2; - bf->bf_state.bfs_rc[3].tries = - params->ibp_try3; - } - } else { - if (ismrr) { - rix = ath_tx_findrix(sc, params->ibp_rate1); - rate1 = rt->info[rix].rateCode; - if (params->ibp_flags & IEEE80211_BPF_SHORTPRE) - rate1 |= rt->info[rix].shortPreamble; - if (params->ibp_try2) { - rix = ath_tx_findrix(sc, params->ibp_rate2); - rate2 = rt->info[rix].rateCode; - if (params->ibp_flags & IEEE80211_BPF_SHORTPRE) - rate2 |= rt->info[rix].shortPreamble; - } else - rate2 = 0; - if (params->ibp_try3) { - rix = ath_tx_findrix(sc, params->ibp_rate3); - rate3 = rt->info[rix].rateCode; - if (params->ibp_flags & IEEE80211_BPF_SHORTPRE) - rate3 |= rt->info[rix].shortPreamble; - } else - rate3 = 0; - ath_hal_setupxtxdesc(ah, ds - , rate1, params->ibp_try1 /* series 1 */ - , rate2, params->ibp_try2 /* series 2 */ - , rate3, params->ibp_try3 /* series 3 */ - ); - } + bf->bf_state.bfs_rc[0].rix = + ath_tx_findrix(sc, params->ibp_rate0); + bf->bf_state.bfs_rc[0].tries = try0; + + if (ismrr) { + bf->bf_state.bfs_rc[1].rix = + ath_tx_findrix(sc, params->ibp_rate1); + bf->bf_state.bfs_rc[2].rix = + ath_tx_findrix(sc, params->ibp_rate2); + bf->bf_state.bfs_rc[3].rix = + ath_tx_findrix(sc, params->ibp_rate3); + + bf->bf_state.bfs_rc[1].tries = params->ibp_try1; + bf->bf_state.bfs_rc[2].tries = params->ibp_try2; + bf->bf_state.bfs_rc[3].tries = params->ibp_try3; } - if (ath_tx_is_11n(sc)) { - /* - * notice that rix doesn't include any of the "magic" flags txrate - * does for communicating "other stuff" to the HAL. - */ - ath_buf_set_rate(sc, ni, bf); - } + /* Program the descriptor */ + ath_tx_setds(sc, bf); + + /* Program the rate control series */ + ath_tx_set_ratectrl(sc, ni, bf); /* NB: no buffered multicast in power save support */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Tue Aug 16 23:47:53 2011 (r224922) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Wed Aug 17 02:01:37 2011 (r224923) @@ -80,7 +80,7 @@ void ath_rate_detach(struct ath_ratectrl #define ATH_RC_NUM 4 struct ath_rc_series { - uint8_t rix; + uint8_t rix; /* ratetable index, not rate code */ uint8_t tries; uint8_t flags; uint32_t max4msframelen; From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 03:04:03 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 0D4C3106566B; Wed, 17 Aug 2011 03:04:03 +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 F1B528FC19; Wed, 17 Aug 2011 03:04: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 p7H3427a084318; Wed, 17 Aug 2011 03:04:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H342f4084316; Wed, 17 Aug 2011 03:04:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170304.p7H342f4084316@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 03:04: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: r224924 - 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, 17 Aug 2011 03:04:03 -0000 Author: adrian Date: Wed Aug 17 03:04:02 2011 New Revision: 224924 URL: http://svn.freebsd.org/changeset/base/224924 Log: Break out the descriptor and rate control programming and place them in ath_tx_start(). This means the descriptor setup should now be able to be delayed until packet scheduling to the hardware. 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 Wed Aug 17 02:01:37 2011 (r224923) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 03:04:02 2011 (r224924) @@ -959,7 +959,6 @@ ath_tx_normal_setup(struct ath_softc *sc } else ctsrate = 0; - /* * Determine if a tx interrupt should be generated for * this descriptor. We take a tx interrupt to reap @@ -1052,16 +1051,6 @@ ath_tx_normal_setup(struct ath_softc *sc ATH_NODE_UNLOCK(an); } - /* - * Formulate first tx descriptor with tx controls. - */ - ath_tx_setds(sc, bf); - - /* - * Setup rate control series. - */ - ath_tx_set_ratectrl(sc, ni, bf); - return 0; } @@ -1166,6 +1155,16 @@ ath_tx_start(struct ath_softc *sc, struc /* At this point m0 could have changed! */ m0 = bf->bf_m; + /* + * Formulate first tx descriptor with tx controls. + */ + ath_tx_setds(sc, bf); + + /* + * Setup rate control series. + */ + ath_tx_set_ratectrl(sc, ni, bf); + /* Fill in the details in the descriptor list */ ath_tx_chaindesclist(sc, bf); From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 03:44: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 4ECAF1065672; Wed, 17 Aug 2011 03:44: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 3EF7F8FC0A; Wed, 17 Aug 2011 03:44: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 p7H3imgR085696; Wed, 17 Aug 2011 03:44:48 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H3imXV085694; Wed, 17 Aug 2011 03:44:48 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170344.p7H3imXV085694@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 03:44: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: r224925 - 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, 17 Aug 2011 03:44:48 -0000 Author: adrian Date: Wed Aug 17 03:44:47 2011 New Revision: 224925 URL: http://svn.freebsd.org/changeset/base/224925 Log: Update my TODO/README 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 Wed Aug 17 03:04:02 2011 (r224924) +++ user/adrian/if_ath_tx/sys/dev/ath/README Wed Aug 17 03:44:47 2011 (r224925) @@ -13,30 +13,11 @@ Things that need doing! + Support rate updates and lookup on a retry; maybe a slower rate is needed? -* Send BAR when needed - + after TX failure - + 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? + 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! @@ -145,3 +126,36 @@ ath_tx_freebuf+68 (?,?,?,?) ra 80079d2c ath_tx_default_comp+34 (?,?,?,?) ra 80079ef0 sp c7717ce0 sz 24 80079e3c+b4 (?,?,?,?) ra 0 sp c7717cf8 sz 0 pid 0 + +* 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 + + - implemented and tested + +* 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. + - I had messed up the blockack window tracking a bit, and there were some + races in marking the queue scheduled/unscheduled. I've since fixed these. + +* Send BAR when needed + + after TX failure + + 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. + + - I've implemented this; the recursion into the TX path was fixed by + causing all TX scheduling and completion to run in the ath task, + ath_tx_start() / ath_tx_raw_xmit() just queues packets to the hardware + or software queue. It doesn't run scheduling as well. This eliminated + most of the locking issues and the recursion. + + - There's a dirty workaround to unpause the queue if BAR TX is definitely + failing. This needs to be addressed before this work is merged back into + -HEAD. From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 06:21: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 90E8D1065676; Wed, 17 Aug 2011 06:21: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 80DEE8FC18; Wed, 17 Aug 2011 06:21: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 p7H6LYMM090374; Wed, 17 Aug 2011 06:21:34 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H6LYF3090372; Wed, 17 Aug 2011 06:21:34 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170621.p7H6LYF3090372@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 06:21: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: r224926 - 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, 17 Aug 2011 06:21:34 -0000 Author: adrian Date: Wed Aug 17 06:21:34 2011 New Revision: 224926 URL: http://svn.freebsd.org/changeset/base/224926 Log: Modify how/when the frame descriptor is being setup. For packets being immediately queued to the hardware, setup the descriptor before handing it off to the hardware. For packets being queued to the per-TID software queue, defer setting up the descriptor details (setup, rate control, chaining) until the packet is about to be queued to the hardware. This way, packet aggregation (RIFS burst, A-MPDU) can setup the descriptor list as needed. The only downside at the moment is that the rate control decision is done (very) early on. I'll fix this at a later stage so software retries can use different rates as needed. 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 Wed Aug 17 03:44:47 2011 (r224925) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 06:21:34 2011 (r224926) @@ -1155,19 +1155,6 @@ ath_tx_start(struct ath_softc *sc, struc /* At this point m0 could have changed! */ m0 = bf->bf_m; - /* - * Formulate first tx descriptor with tx controls. - */ - ath_tx_setds(sc, bf); - - /* - * Setup rate control series. - */ - ath_tx_set_ratectrl(sc, ni, bf); - - /* Fill in the details in the descriptor list */ - ath_tx_chaindesclist(sc, bf); - #if 1 /* * If it's a multicast frame, do a direct-dispatch to the @@ -1179,9 +1166,16 @@ ath_tx_start(struct ath_softc *sc, struc * destination hardware queue. Don't bother software * queuing it, as the TID will now be paused. */ - if (ismcast) - ath_tx_handoff_mcast(sc, txq, bf); - else if (type == IEEE80211_FC0_TYPE_CTL && + if (ismcast) { + /* Setup the descriptor before handoff */ + ath_tx_setds(sc, bf); + ath_tx_set_ratectrl(sc, ni, bf); + ath_tx_chaindesclist(sc, bf); + + ATH_TXQ_LOCK(txq); + ath_tx_handoff(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); + } else if (type == IEEE80211_FC0_TYPE_CTL && subtype == IEEE80211_FC0_SUBTYPE_BAR) { /* * XXX The following is dirty but needed for now. @@ -1197,6 +1191,12 @@ ath_tx_start(struct ath_softc *sc, struc */ DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: BAR: TX'ing direct\n", __func__); + + /* Setup the descriptor before handoff */ + ath_tx_setds(sc, bf); + ath_tx_set_ratectrl(sc, ni, bf); + ath_tx_chaindesclist(sc, bf); + ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); ATH_TXQ_UNLOCK(txq); @@ -1212,6 +1212,12 @@ ath_tx_start(struct ath_softc *sc, struc * For now, since there's no software queue, * direct-dispatch to the hardware. */ + + /* Setup the descriptor before handoff */ + ath_tx_setds(sc, bf); + ath_tx_set_ratectrl(sc, ni, bf); + ath_tx_chaindesclist(sc, bf); + ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); ATH_TXQ_UNLOCK(txq); @@ -1383,12 +1389,6 @@ ath_tx_raw_start(struct ath_softc *sc, s bf->bf_state.bfs_rc[3].tries = params->ibp_try3; } - /* Program the descriptor */ - ath_tx_setds(sc, bf); - - /* Program the rate control series */ - ath_tx_set_ratectrl(sc, ni, bf); - /* NB: no buffered multicast in power save support */ /* XXX If it's an ADDBA, override the correct queue */ @@ -1404,9 +1404,6 @@ ath_tx_raw_start(struct ath_softc *sc, s pri = TID_TO_WME_AC(o_tid); } - /* Fill in the details in the descriptor list */ - ath_tx_chaindesclist(sc, bf); - /* * If we're overiding the ADDBA destination, dump directly * into the hardware queue, right after any pending @@ -1415,6 +1412,9 @@ ath_tx_raw_start(struct ath_softc *sc, s if (do_override) { ATH_TXQ_LOCK(sc->sc_ac2q[pri]); + ath_tx_setds(sc, bf); + ath_tx_set_ratectrl(sc, ni, bf); + ath_tx_chaindesclist(sc, bf); ath_tx_handoff(sc, sc->sc_ac2q[pri], bf); ATH_TXQ_UNLOCK(sc->sc_ac2q[pri]); } @@ -2312,6 +2312,7 @@ 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; + struct ieee80211_node *ni = &an->an_node; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid); @@ -2378,6 +2379,11 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft if (bf->bf_state.bfs_tid == IEEE80211_NONQOS_TID) device_printf(sc->sc_dev, "%s: TID=16?\n", __func__); + /* Program descriptor */ + ath_tx_setds(sc, bf); + ath_tx_set_ratectrl(sc, ni, bf); + ath_tx_chaindesclist(sc, bf); + /* Punt to hardware or software txq */ ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); @@ -2394,6 +2400,7 @@ ath_tx_tid_hw_queue_norm(struct ath_soft struct ath_buf *bf; struct ath_txq *txq; struct ath_tid *atid = &an->an_tid[tid]; + struct ieee80211_node *ni = &an->an_node; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: node %p: TID %d: called\n", __func__, an, tid); @@ -2427,6 +2434,11 @@ ath_tx_tid_hw_queue_norm(struct ath_soft /* Normal completion handler */ bf->bf_comp = ath_tx_normal_comp; + /* Program descriptor */ + ath_tx_setds(sc, bf); + ath_tx_set_ratectrl(sc, ni, bf); + ath_tx_chaindesclist(sc, bf); + /* Punt to hardware or software txq */ ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 07:52: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 C6BE71065675; Wed, 17 Aug 2011 07:52:14 +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 B77C88FC15; Wed, 17 Aug 2011 07:52: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 p7H7qEZI093089; Wed, 17 Aug 2011 07:52:14 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H7qE8O093087; Wed, 17 Aug 2011 07:52:14 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170752.p7H7qE8O093087@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 07:52: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: r224927 - 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, 17 Aug 2011 07:52:14 -0000 Author: adrian Date: Wed Aug 17 07:52:14 2011 New Revision: 224927 URL: http://svn.freebsd.org/changeset/base/224927 Log: Fix a silly typo 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 Wed Aug 17 06:21:34 2011 (r224926) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 17 07:52:14 2011 (r224927) @@ -830,7 +830,7 @@ void ath_intr(void *); ((*(_ah)->ah_set11nRateScenario)((_ah), (_ds), (_dur), (_rt), \ (_series), (_ns), (_flags))) #define ath_hal_set11naggrmiddle(_ah, _ds, _num) \ - ((*(_ah)->ah_set11nAggrMiddle((_ah), (_ds), (_num)))) + ((*(_ah)->ah_set11nAggrMiddle)((_ah), (_ds), (_num))) #define ath_hal_set11nburstduration(_ah, _ds, _dur) \ ((*(_ah)->ah_set11nBurstDuration)((_ah), (_ds), (_dur))) From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 07:53: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 1F670106566C; Wed, 17 Aug 2011 07:53: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 056318FC12; Wed, 17 Aug 2011 07:53: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 p7H7r52h093150; Wed, 17 Aug 2011 07:53:05 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H7r5dc093147; Wed, 17 Aug 2011 07:53:05 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170753.p7H7r5dc093147@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 07:53:05 +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: r224928 - 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, 17 Aug 2011 07:53:06 -0000 Author: adrian Date: Wed Aug 17 07:53:05 2011 New Revision: 224928 URL: http://svn.freebsd.org/changeset/base/224928 Log: In preparation for the aggregate list creation code, move some needed code/defines into public view. Modified: 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/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 07:52:14 2011 (r224927) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 07:53:05 2011 (r224928) @@ -101,31 +101,10 @@ __FBSDID("$FreeBSD$"); #include /* - * some general macros - */ -#define INCR(_l, _sz) (_l) ++; (_l) &= ((_sz) - 1) -/* - * return block-ack bitmap index given sequence and starting sequence - */ -#define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_RANGE - 1)) - -/* extracting the seqno from buffer seqno */ -#define SEQNO(_a) ((_a) >> IEEE80211_SEQ_SEQ_SHIFT) - -/* - * Whether the current sequence number is within the - * BAW. - */ -#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, int tid); static int ath_tx_ampdu_running(struct ath_softc *sc, struct ath_node *an, @@ -1600,7 +1579,7 @@ ath_tx_action_frame_override_queue(struc * + fits inside the BAW; * + already has had a sequence number allocated. */ -static void +void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an, struct ath_tid *tid, struct ath_buf *bf) { @@ -2255,7 +2234,7 @@ ath_tx_aggr_retry_unaggr(struct ath_soft * Fail is set to 1 if the entry is being freed via a call to * ath_tx_draintxq(). */ -static void +void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) { struct ieee80211_node *ni = bf->bf_node; @@ -2502,7 +2481,7 @@ ath_txq_sched(struct ath_softc *sc, stru /* * Return net80211 TID struct pointer, or NULL for none */ -static struct ieee80211_tx_ampdu * +struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an, int tid) { struct ieee80211_node *ni = &an->an_node; 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 Wed Aug 17 07:52:14 2011 (r224927) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Wed Aug 17 07:53:05 2011 (r224928) @@ -31,6 +31,25 @@ #ifndef __IF_ATH_TX_H__ #define __IF_ATH_TX_H__ +/* + * some general macros + */ +#define INCR(_l, _sz) (_l) ++; (_l) &= ((_sz) - 1) +/* + * return block-ack bitmap index given sequence and starting sequence + */ +#define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_RANGE - 1)) + +/* extracting the seqno from buffer seqno */ +#define SEQNO(_a) ((_a) >> IEEE80211_SEQ_SEQ_SHIFT) + +/* + * Whether the current sequence number is within the + * BAW. + */ +#define BAW_WITHIN(_start, _bawsz, _seqno) \ + ((((_seqno) - (_start)) & 4095) < (_bawsz)) + extern void ath_freetx(struct mbuf *m); extern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an); extern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags, @@ -54,6 +73,12 @@ extern void ath_tx_tid_hw_queue_norm(str extern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq); extern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, int fail); +extern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, + int fail); +extern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an, + struct ath_tid *tid, struct ath_buf *bf); +extern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an, + int tid); /* TX addba handling */ extern int ath_addba_request(struct ieee80211_node *ni, From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 08:27: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 15E96106566B; Wed, 17 Aug 2011 08:27: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 06DC18FC08; Wed, 17 Aug 2011 08:27: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 p7H8RBOH094172; Wed, 17 Aug 2011 08:27:11 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H8RBe2094170; Wed, 17 Aug 2011 08:27:11 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170827.p7H8RBe2094170@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 08:27:11 +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: r224929 - 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, 17 Aug 2011 08:27:12 -0000 Author: adrian Date: Wed Aug 17 08:27:11 2011 New Revision: 224929 URL: http://svn.freebsd.org/changeset/base/224929 Log: Add another HAL method 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 Wed Aug 17 07:53:05 2011 (r224928) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 17 08:27:11 2011 (r224929) @@ -833,6 +833,8 @@ void ath_intr(void *); ((*(_ah)->ah_set11nAggrMiddle)((_ah), (_ds), (_num))) #define ath_hal_set11nburstduration(_ah, _ds, _dur) \ ((*(_ah)->ah_set11nBurstDuration)((_ah), (_ds), (_dur))) +#define ath_hal_clr11n_aggr(_ah, _ds) \ + ((*(_ah)->ah_clr11nAggr)((_ah), (_ds))) /* * This is badly-named; you need to set the correct parameters From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 09:02: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 CB66B106566C; Wed, 17 Aug 2011 09:02: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 BACA88FC0C; Wed, 17 Aug 2011 09:02: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 p7H92wtq095288; Wed, 17 Aug 2011 09:02:58 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H92w3T095282; Wed, 17 Aug 2011 09:02:58 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170902.p7H92w3T095282@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 09:02:58 +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: r224930 - 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, 17 Aug 2011 09:02:58 -0000 Author: adrian Date: Wed Aug 17 09:02:58 2011 New Revision: 224930 URL: http://svn.freebsd.org/changeset/base/224930 Log: This is another "too much going on in one commit for my own good" commits. The stuff in progress, which shouldn't affect anything: * Begin fleshing out the aggregate list creation function, untested * Rename some of the aggregate response functions to indicate they're handling individual, non-aggregate frames when in aggregation mode. * make ath_tx_aggr_comp() now call either the aggr_comp_aggr() for an aggregate frame list, or aggr_comp_unaggr() for a single frame. The important change which could break things, but is needed: * add ath_buf->bf_lastds, which points to the descriptor in the last frame in the list. Now, the reasoning. The TX descriptor status is in the _last_ descriptor in a list. For a single frame w/ a single TX descriptor, it's also the first descriptor. For a single frame w/ multiple TX descriptors, it's the last descriptor in the frame. For an aggregate list w/ multiple TX descriptors, it's the first descriptor in the -last- subframe. Ie, NOT the very last descriptor. The (upcoming) aggregate scheduling function will thus have to set ds->lastds to the first descriptor in the last buffer. The point is, bf->bf_lastds needs to be correct for setting the rate control stuff (which uses bf_lastds to hide a copy of the rate information in the last descriptor in the chain) and for completion status checking. TODO: although linux and the reference code seem to use the above, I really should double-check that this is correct before trying to TX aggregate frames. TODO: see whether that use of lastds in ath_buf_set_rate() is needed for the hardware, or for hiding a copy of the rate settings used, to be used by the rate control code. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h 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 17 08:27:11 2011 (r224929) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 17 09:02:58 2011 (r224930) @@ -3086,6 +3086,7 @@ ath_descdma_setup(struct ath_softc *sc, ath_descdma_cleanup(sc, dd, head); return error; } + bf->bf_lastds = bf->bf_desc; /* Just an initial value */ STAILQ_INSERT_TAIL(head, bf, bf_list); } return 0; @@ -4171,7 +4172,7 @@ ath_tx_processq(struct ath_softc *sc, st break; } ds0 = &bf->bf_desc[0]; - ds = &bf->bf_desc[bf->bf_nseg - 1]; + ds = bf->bf_lastds; /* XXX must be setup correctly! */ ts = &bf->bf_status.ds_txstat; status = ath_hal_txprocdesc(ah, ds, ts); #ifdef ATH_DEBUG 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 17 08:27:11 2011 (r224929) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 09:02:58 2011 (r224930) @@ -317,8 +317,8 @@ ath_tx_chaindesclist(struct ath_softc *s "%s: %d: %08x %08x %08x %08x %08x %08x\n", __func__, i, ds->ds_link, ds->ds_data, ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1]); + bf->bf_lastds = ds; } - } static void @@ -606,6 +606,7 @@ ath_tx_setds(struct ath_softc *sc, struc , bf->bf_state.bfs_ctsrate /* rts/cts rate */ , bf->bf_state.bfs_ctsduration /* rts/cts duration */ ); + bf->bf_lastds = ds; /* XXX TODO: Setup descriptor chain */ } @@ -1780,6 +1781,8 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_txq = txq; bf->bf_state.bfs_pri = pri; bf->bf_state.bfs_dobaw = 0; + bf->bf_state.bfs_aggr = 0; + bf->bf_state.bfs_aggrburst = 0; /* Queue frame to the tail of the software queue */ ATH_TXQ_LOCK(atid); @@ -2010,7 +2013,7 @@ ath_tx_normal_comp(struct ath_softc *sc, * an A-MPDU. */ static void -ath_tx_comp_cleanup(struct ath_softc *sc, struct ath_buf *bf) +ath_tx_comp_cleanup_unaggr(struct ath_softc *sc, struct ath_buf *bf) { struct ieee80211_node *ni = bf->bf_node; struct ath_node *an = ATH_NODE(ni); @@ -2228,14 +2231,160 @@ ath_tx_aggr_retry_unaggr(struct ath_soft } /* + * Common code for aggregate excessive retry/subframe retry. + * If retrying, queues buffers to bf_q. If not, frees the + * buffers. + * + * XXX should unify this with ath_tx_aggr_retry_unaggr() + */ +static int +ath_tx_retry_subframe(struct ath_softc *sc, struct ath_buf *bf, + ath_bufhead *bf_q) +{ + 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]; + + ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); + ath_hal_set11nburstduration(sc->sc_ah, bf->bf_desc, 0); + /* ath_hal_set11n_virtualmorefrag(sc->sc_ah, bf->bf_desc, 0); */ + + if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { + ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + /* XXX subframe completion status? is that valid here? */ + ath_tx_default_comp(sc, bf, 0); + return 1; + } + + if (bf->bf_flags & ATH_BUF_BUSY) { + bf->bf_flags &= ~ ATH_BUF_BUSY; + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: bf %p: ATH_BUF_BUSY\n", __func__, bf); + } + + ath_tx_set_retry(sc, bf); + + STAILQ_INSERT_TAIL(bf_q, bf, bf_list); + return 0; +} + +/* + * error pkt completion for an aggregate destination + */ +static void +ath_tx_comp_aggr_error(struct ath_softc *sc, struct ath_buf *bf_first, + struct ath_tid *tid) +{ + struct ieee80211_node *ni = bf_first->bf_node; + struct ath_node *an = ATH_NODE(ni); + struct ath_buf *bf_next, *bf; + ath_bufhead bf_q; + int drops = 0; + struct ieee80211_tx_ampdu *tap; + + tap = ath_tx_get_tx_tid(an, tid->tid); + + STAILQ_INIT(&bf_q); + + /* Retry all subframes */ + bf = bf_first; + while (bf) { + bf_next = bf->bf_next; + drops += ath_tx_retry_subframe(sc, bf, &bf_q); + bf = bf_next; + } + + /* Update rate control module about aggregation */ + /* XXX todo */ + + /* + * send bar if we dropped any frames + */ + if (drops) { + if (ieee80211_send_bar(ni, tap, ni->ni_txseqs[tid->tid]) == 0) { + /* + * Pause the TID if this was successful. + * An un-successful BAR TX would never call + * the BAR complete / timeout methods. + */ + ath_tx_tid_pause(sc, tid); + } else { + /* BAR TX failed */ + device_printf(sc->sc_dev, + "%s: TID %d: BAR TX failed\n", + __func__, tid->tid); + } + } + + /* Prepend all frames to the beginning of the queue */ + ATH_TXQ_LOCK(tid); + while ((bf = STAILQ_FIRST(&bf_q)) != NULL) { + ATH_TXQ_INSERT_HEAD(tid, bf, bf_list); + STAILQ_REMOVE_HEAD(&bf_q, bf_list); + } + ATH_TXQ_LOCK(tid); +} + +/* + * Handle clean-up of packets from an aggregate list. + */ +static void +ath_tx_comp_cleanup_aggr(struct ath_softc *sc, struct ath_buf *bf) +{ + /* XXX TODO */ +} + +/* + * Handle completion of an set of aggregate frames. + * + * XXX for now, simply complete each sub-frame. + * + * Note: the completion handler is the last descriptor in the aggregate, + * not the last descriptor in the first frame. + */ +static void +ath_tx_aggr_comp_aggr(struct ath_softc *sc, struct ath_buf *bf, int fail) +{ + //struct ath_desc *ds = bf->bf_lastds; + 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_tx_status *ts = &bf->bf_status.ds_txstat; + + /* + * Punt cleanup to the relevant function, not our problem now + */ + if (atid->cleanup_inprogress) { + ath_tx_comp_cleanup_aggr(sc, bf); + return; + } + + /* + * handle errors first + */ + if (ts->ts_status & HAL_TXERR_XRETRY) { + ath_tx_comp_aggr_error(sc, bf, atid); + return; + } + + /* + * extract starting sequence and block-ack bitmap + */ + + /* AR5416 BA bug; this requires re-TX of all 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(). */ -void -ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) +static void +ath_tx_aggr_comp_unaggr(struct ath_softc *sc, struct ath_buf *bf, int fail) { struct ieee80211_node *ni = bf->bf_node; struct ath_node *an = ATH_NODE(ni); @@ -2248,7 +2397,6 @@ 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 @@ -2256,7 +2404,7 @@ ath_tx_aggr_comp(struct ath_softc *sc, s * function in net80211, update rate control, etc. */ if (atid->cleanup_inprogress) { - ath_tx_comp_cleanup(sc, bf); + ath_tx_comp_cleanup_unaggr(sc, bf); return; } @@ -2279,6 +2427,15 @@ ath_tx_aggr_comp(struct ath_softc *sc, s /* bf is freed at this point */ } +void +ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) +{ + if (bf->bf_state.bfs_aggr) + ath_tx_aggr_comp_aggr(sc, bf, fail); + else + ath_tx_aggr_comp_unaggr(sc, bf, fail); +} + /* * Schedule some packets from the given node/TID to the hardware. * Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Wed Aug 17 08:27:11 2011 (r224929) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Wed Aug 17 09:02:58 2011 (r224930) @@ -86,8 +86,27 @@ __FBSDID("$FreeBSD$"); #include #endif +#include /* XXX for some support functions */ #include +/* + * XXX net80211? + */ +#define IEEE80211_AMPDU_SUBFRAME_DEFAULT 32 + +#define ATH_AGGR_DELIM_SZ 4 /* delimiter size */ +#define ATH_AGGR_MINPLEN 256 /* in bytes, minimum packet length */ +#define ATH_AGGR_ENCRYPTDELIM 10 /* number of delimiters for encryption padding */ + +/* + * returns delimiter padding required given the packet length + */ +#define ATH_AGGR_GET_NDELIM(_len) \ + (((((_len) + ATH_AGGR_DELIM_SZ) < ATH_AGGR_MINPLEN) ? \ + (ATH_AGGR_MINPLEN - (_len) - ATH_AGGR_DELIM_SZ) : 0) >> 2) + +#define PADBYTES(_len) ((4 - ((_len) % 4)) % 4) + int ath_max_4ms_framelen[4][32] = { [MCS_HT20] = { 3212, 6432, 9648, 12864, 19300, 25736, 28952, 32172, @@ -251,7 +270,7 @@ ath_buf_set_rate(struct ath_softc *sc, s /* Enforce RTS and CTS are mutually exclusive */ /* Get a pointer to the last tx descriptor in the list */ - lastds = &bf->bf_desc[bf->bf_nseg - 1]; + lastds = bf->bf_lastds; #if 0 printf("pktlen: %d; flags 0x%x\n", pktlen, flags); @@ -274,3 +293,197 @@ ath_buf_set_rate(struct ath_softc *sc, s /* This should only be done if aggregate protection is enabled */ //ath_hal_set11nburstduration(ah, ds, 8192); } + +/* + * Form an aggregate packet list. + * + * This function enforces the aggregate restrictions/requirements. + * + * These are: + * + * + The aggregate size maximum (64k for AR9160 and later, 8K for + * AR5416 when doing RTS frame protection.) + * + Maximum number of sub-frames for an aggregate + * + The aggregate delimiter size, giving MACs time to do whatever is + * needed before each frame + * + Enforce the BAW limit + * + * Each descriptor queued should already have the TX fields setup, + * the DMA map setup and the rate control series setup. Since + * aggregate sub-frame retransmission is done entirely in software, + * it should only have a single rate series configured. + * + * The first descriptor has the rate control and aggregate setup + * fields; the middle frames have "aggregate" and "more" flags set + * along with the delimiter count; the last frame has "aggregate" + * set. + * + * Note that the TID lock is only grabbed when dequeuing packets from + * the TID queue. If some code in another thread adds to the head of this + * list, very strange behaviour will occur. Since retransmission is the + * only reason this will occur, and this routine is designed to be called + * from within the scheduler task, it won't ever clash with the completion + * task. + * + * So if you want to call this from an upper layer context (eg, to direct- + * dispatch aggregate frames to the hardware), please keep this in mind. + */ +ATH_AGGR_STATUS +ath_tx_form_aggr(struct ath_softc *sc, struct ath_node *an, struct ath_tid *tid, + ath_bufhead *bf_q) +{ + //struct ieee80211_node *ni = &an->an_node; + struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL; + int nframes = 0; + uint16_t aggr_limit = 0, al = 0, bpad = 0, al_delta, h_baw; + struct ieee80211_tx_ampdu *tap; + int status = ATH_AGGR_DONE; + int prev_frames = 0; /* XXX for AR5416 burst, not done here */ + int prev_al = 0; /* XXX also for AR5416 burst */ + + tap = ath_tx_get_tx_tid(an, tid->tid); + if (tap == NULL) { + status = ATH_AGGR_ERROR; + goto finish; + } + + h_baw = tap->txa_wnd / 2; + + /* Calculate aggregation limit */ + aggr_limit = 8192; /* XXX just for now, for testing */ + + for (;;) { + ATH_TXQ_LOCK(tid); + bf = STAILQ_FIRST(&tid->axq_q); + if (bf_first == NULL) + bf_first = bf; + if (bf == NULL) { + ATH_TXQ_UNLOCK(tid); + status = ATH_AGGR_DONE; + break; + } + + /* + * Don't unlock the tid lock until we're sure we are going + * to queue this frame. + */ + + /* + * If the frame doesn't have a sequence number, we can't + * aggregate it. + */ + if (! bf->bf_state.bfs_dobaw) { + ATH_TXQ_UNLOCK(tid); + status = ATH_AGGR_NONAGGR; + break; + } + + /* + * If the packet has a sequence number, do not + * step outside of the block-ack window. + */ + if (! BAW_WITHIN(tap->txa_start, tap->txa_wnd, + SEQNO(bf->bf_state.bfs_seqno))) { + ATH_TXQ_UNLOCK(tid); + status = ATH_AGGR_BAW_CLOSED; + break; + } + + /* + * do not exceed aggregation limit + */ + al_delta = ATH_AGGR_DELIM_SZ + bf->bf_state.bfs_pktlen; + + /* + * XXX TODO: AR5416 has an 8K aggregation size limit + * when RTS is enabled, and RTS is required for dual-stream + * rates. + * + * For now, limit all aggregates for the AR5416 to be 8K. + */ + + if (nframes && + (aggr_limit < (al + bpad + al_delta + prev_al))) { + ATH_TXQ_UNLOCK(tid); + status = ATH_AGGR_LIMITED; + break; + } + + /* + * Do not exceed subframe limit. + */ + if ((nframes + prev_frames) >= MIN((h_baw), + IEEE80211_AMPDU_SUBFRAME_DEFAULT)) { + ATH_TXQ_UNLOCK(tid); + status = ATH_AGGR_LIMITED; + break; + } + + /* + * XXX TODO: do not exceed 4ms packet length + */ + + /* + * this packet is part of an aggregate. + */ + ATH_TXQ_REMOVE_HEAD(tid, bf_list); + ATH_TXQ_UNLOCK(tid); + + ath_tx_addto_baw(sc, an, tid, bf); + STAILQ_INSERT_TAIL(bf_q, bf, bf_list); + nframes ++; + + /* Completion handler */ + bf->bf_comp = ath_tx_aggr_comp; + + /* + * add padding for previous frame to aggregation length + */ + al += bpad + al_delta; + bf->bf_state.bfs_ndelim = + ATH_AGGR_GET_NDELIM(bf->bf_state.bfs_pktlen); + + /* + * Add further padding if encryption is required + * XXX for now, always add it. + */ + bf->bf_state.bfs_ndelim += ATH_AGGR_ENCRYPTDELIM; + + bpad = PADBYTES(al_delta) + (bf->bf_state.bfs_ndelim << 2); + + /* + * link current buffer to the aggregate + */ + if (bf_prev) { + bf_prev->bf_next = bf; + bf_prev->bf_desc->ds_link = bf->bf_daddr; + } + bf_prev = bf; + + /* Set aggregate flags */ + ath_hal_set11naggrmiddle(sc->sc_ah, bf->bf_desc, + bf->bf_state.bfs_ndelim); + +#if 0 + /* + * terminate aggregation on a small packet boundary + */ + if (bf->bf_state.bfs_pktlen < ATH_AGGR_MINPLEN) { + status = ATH_AGGR_SHORTPKT; + break; + } +#endif + + } + +finish: + /* + * Just in case the list was empty when we tried to + * dequeue a packet .. + */ + if (bf_first) { + bf_first->bf_state.bfs_al = al; + bf_first->bf_state.bfs_nframes = nframes; + } + return status; +} Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Wed Aug 17 08:27:11 2011 (r224929) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Wed Aug 17 09:02:58 2011 (r224930) @@ -38,9 +38,23 @@ enum { MCS_HT40_SGI, }; +typedef enum { + ATH_AGGR_DONE, + ATH_AGGR_BAW_CLOSED, + ATH_AGGR_LIMITED, + ATH_AGGR_SHORTPKT, + ATH_AGGR_8K_LIMITED, + ATH_AGGR_ERROR, + ATH_AGGR_NONAGGR, +} ATH_AGGR_STATUS; + extern int ath_max_4ms_framelen[4][32]; extern void ath_buf_set_rate(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf); +extern ATH_AGGR_STATUS + ath_tx_form_aggr(struct ath_softc *sc, struct ath_node *an, + struct ath_tid *tid, ath_bufhead *bf_q); + #endif 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 17 08:27:11 2011 (r224929) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 17 09:02:58 2011 (r224930) @@ -181,6 +181,7 @@ struct ath_buf { bus_dmamap_t bf_dmamap; /* DMA map for mbuf chain */ struct mbuf *bf_m; /* mbuf for buf */ struct ieee80211_node *bf_node; /* pointer to the node */ + struct ath_desc *bf_lastds; /* last descriptor for comp status */ bus_size_t bf_mapsize; #define ATH_MAX_SCATTER ATH_TXDESC /* max(tx,rx,beacon) desc's */ bus_dma_segment_t bf_segs[ATH_MAX_SCATTER]; From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 09:06: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 478211065673; Wed, 17 Aug 2011 09:06: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 384A58FC14; Wed, 17 Aug 2011 09:06: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 p7H966Rq095416; Wed, 17 Aug 2011 09:06:06 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H966Qf095413; Wed, 17 Aug 2011 09:06:06 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170906.p7H966Qf095413@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 09:06: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: r224931 - 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, 17 Aug 2011 09:06:06 -0000 Author: adrian Date: Wed Aug 17 09:06:05 2011 New Revision: 224931 URL: http://svn.freebsd.org/changeset/base/224931 Log: * Fix a busted locking call I just introduced * Fix a potential LOR when fiddling with the mcastq/cabq Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c 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 17 09:02:58 2011 (r224930) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 17 09:06:05 2011 (r224931) @@ -2653,8 +2653,8 @@ ath_beacon_generate(struct ath_softc *sc } /* NB: gated by beacon so safe to start here */ ath_hal_txstart(ah, cabq->axq_qnum); - ATH_TXQ_UNLOCK(cabq); ATH_TXQ_UNLOCK(&avp->av_mcastq); + ATH_TXQ_UNLOCK(cabq); } return bf; } 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 17 09:02:58 2011 (r224930) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 09:06:05 2011 (r224931) @@ -2323,7 +2323,7 @@ ath_tx_comp_aggr_error(struct ath_softc ATH_TXQ_INSERT_HEAD(tid, bf, bf_list); STAILQ_REMOVE_HEAD(&bf_q, bf_list); } - ATH_TXQ_LOCK(tid); + ATH_TXQ_UNLOCK(tid); } /* From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 09:40: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 5CEF01065672; Wed, 17 Aug 2011 09:40: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 33F888FC18; Wed, 17 Aug 2011 09:40: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 p7H9eruh096476; Wed, 17 Aug 2011 09:40:53 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H9erh9096472; Wed, 17 Aug 2011 09:40:53 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170940.p7H9erh9096472@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 09:40: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: r224932 - in user/adrian/if_ath_tx/sys/dev/ath/ath_hal: . ar5416 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, 17 Aug 2011 09:40:53 -0000 Author: adrian Date: Wed Aug 17 09:40:52 2011 New Revision: 224932 URL: http://svn.freebsd.org/changeset/base/224932 Log: Extract out the TID field from the TX completion status. Obtained from: Linux ath9k Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah_desc.h user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416desc.h Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah_desc.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah_desc.h Wed Aug 17 09:06:05 2011 (r224931) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah_desc.h Wed Aug 17 09:40:52 2011 (r224932) @@ -50,6 +50,7 @@ struct ath_tx_status { /* #define ts_rssi ts_rssi_combined */ uint32_t ts_ba_low; /* blockack bitmap low */ uint32_t ts_ba_high; /* blockack bitmap high */ + uint8_t ts_tid; /* TID */ uint32_t ts_evm0; /* evm bytes */ uint32_t ts_evm1; uint32_t ts_evm2; Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Wed Aug 17 09:06:05 2011 (r224931) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Wed Aug 17 09:40:52 2011 (r224932) @@ -504,6 +504,7 @@ ar5416ProcTxDesc(struct ath_hal *ah, /* Update software copies of the HW status */ ts->ts_seqnum = MS(ds_txstatus[9], AR_SeqNum); ts->ts_tstamp = AR_SendTimestamp(ds_txstatus); + ts->ts_tid = MS(ds_txstatus[9], AR_TxTid); ts->ts_status = 0; if (ds_txstatus[1] & AR_ExcessiveRetries) Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416desc.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416desc.h Wed Aug 17 09:06:05 2011 (r224931) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416desc.h Wed Aug 17 09:40:52 2011 (r224932) @@ -302,6 +302,8 @@ struct ar5416_desc { #define AR_FinalTxIdx_S 21 #define AR_TxStatusRsvd82 0x01800000 #define AR_PowerMgmt 0x02000000 +#define AR_TxTid 0xf0000000 +#define AR_TxTid_S 28 #define AR_TxStatusRsvd83 0xfc000000 /*********** From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 09:44:16 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 12E8A106564A; Wed, 17 Aug 2011 09:44:16 +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 ECD798FC14; Wed, 17 Aug 2011 09:44: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 p7H9iF5H096622; Wed, 17 Aug 2011 09:44:15 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H9iFR3096619; Wed, 17 Aug 2011 09:44:15 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170944.p7H9iFR3096619@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 09:44: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: r224933 - 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, 17 Aug 2011 09:44:16 -0000 Author: adrian Date: Wed Aug 17 09:44:15 2011 New Revision: 224933 URL: http://svn.freebsd.org/changeset/base/224933 Log: Flesh out a completely untested aggregate completion handler. Modified: 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/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 09:40:52 2011 (r224932) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 09:44:15 2011 (r224933) @@ -2344,20 +2344,28 @@ ath_tx_comp_cleanup_aggr(struct ath_soft * not the last descriptor in the first frame. */ static void -ath_tx_aggr_comp_aggr(struct ath_softc *sc, struct ath_buf *bf, int fail) +ath_tx_aggr_comp_aggr(struct ath_softc *sc, struct ath_buf *bf_first, int fail) { //struct ath_desc *ds = bf->bf_lastds; - struct ieee80211_node *ni = bf->bf_node; + struct ieee80211_node *ni = bf_first->bf_node; struct ath_node *an = ATH_NODE(ni); - int tid = bf->bf_state.bfs_tid; + int tid = bf_first->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; - struct ath_tx_status *ts = &bf->bf_status.ds_txstat; + struct ath_tx_status *ts = &bf_first->bf_status.ds_txstat; + struct ieee80211_tx_ampdu *tap; + ath_bufhead bf_q; + int seq_st, tx_ok; + int hasba, isaggr; + uint32_t ba[2]; + struct ath_buf *bf, *bf_next; + int ba_index; + int drops = 0; /* * Punt cleanup to the relevant function, not our problem now */ if (atid->cleanup_inprogress) { - ath_tx_comp_cleanup_aggr(sc, bf); + ath_tx_comp_cleanup_aggr(sc, bf_first); return; } @@ -2365,15 +2373,83 @@ ath_tx_aggr_comp_aggr(struct ath_softc * * handle errors first */ if (ts->ts_status & HAL_TXERR_XRETRY) { - ath_tx_comp_aggr_error(sc, bf, atid); + ath_tx_comp_aggr_error(sc, bf_first, atid); return; } + STAILQ_INIT(&bf_q); + tap = ath_tx_get_tx_tid(an, tid); + /* * extract starting sequence and block-ack bitmap */ + /* XXX endian-ness of seq_st, ba? */ + seq_st = ts->ts_seqnum; + hasba = !! (ts->ts_flags & HAL_TX_BA); + tx_ok = (ts->ts_status == 0); + isaggr = bf_first->bf_state.bfs_aggr; + ba[0] = ts->ts_ba_low; + ba[1] = ts->ts_ba_high; + + /* Occasionally, the MAC sends a tx status for the wrong TID. */ + if (tid != ts->ts_tid) { + device_printf(sc->sc_dev, "%s: tid %d != hw tid %d\n", + __func__, tid, ts->ts_tid); + tx_ok = 0; + } + + /* AR5416 BA bug; this requires an interface reset */ + /* XXX TODO */ + + /* + * Walk the list of frames, figure out which ones were correctly + * sent and which weren't. + */ + bf = bf_first; - /* AR5416 BA bug; this requires re-TX of all frames */ + while (bf) { + ba_index = ATH_BA_INDEX(seq_st, SEQNO(bf->bf_state.bfs_seqno)); + bf_next = bf->bf_next; + + if (tx_ok && ATH_BA_ISSET(ba, ba_index)) { + ath_tx_update_baw(sc, an, atid, + SEQNO(bf->bf_state.bfs_seqno)); + ath_tx_default_comp(sc, bf, 0); + } else { + drops += ath_tx_retry_subframe(sc, bf, &bf_q); + } + bf = bf_next; + } + + /* update rate control module about aggregate status */ + /* XXX TODO */ + + /* + * send bar if we dropped any frames + */ + if (drops) { + if (ieee80211_send_bar(ni, tap, ni->ni_txseqs[tid]) == 0) { + /* + * Pause the TID if this was successful. + * An un-successful BAR TX would never call + * the BAR complete / timeout methods. + */ + ath_tx_tid_pause(sc, atid); + } else { + /* BAR TX failed */ + device_printf(sc->sc_dev, + "%s: TID %d: BAR TX failed\n", + __func__, tid); + } + } + + /* Prepend all frames to the beginning of the queue */ + ATH_TXQ_LOCK(atid); + while ((bf = STAILQ_FIRST(&bf_q)) != NULL) { + ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); + STAILQ_REMOVE_HEAD(&bf_q, bf_list); + } + ATH_TXQ_UNLOCK(atid); } /* 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 Wed Aug 17 09:40:52 2011 (r224932) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Wed Aug 17 09:44:15 2011 (r224933) @@ -40,6 +40,17 @@ */ #define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_RANGE - 1)) +#define WME_BA_BMP_SIZE 64 +#define WME_MAX_BA WME_BA_BMP_SIZE + +/* + * return whether a bit at index _n in bitmap _bm is set + * _sz is the size of the bitmap + */ +#define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \ + ((_bm)[(_n) >> 5] & (1 << ((_n) & 31)))) + + /* extracting the seqno from buffer seqno */ #define SEQNO(_a) ((_a) >> IEEE80211_SEQ_SEQ_SHIFT) From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 09:52:35 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 550311065674; Wed, 17 Aug 2011 09:52:35 +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 45B9A8FC28; Wed, 17 Aug 2011 09:52:35 +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 p7H9qYLj096901; Wed, 17 Aug 2011 09:52:34 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7H9qYEO096899; Wed, 17 Aug 2011 09:52:34 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108170952.p7H9qYEO096899@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 09:52: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: r224934 - 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, 17 Aug 2011 09:52:35 -0000 Author: adrian Date: Wed Aug 17 09:52:34 2011 New Revision: 224934 URL: http://svn.freebsd.org/changeset/base/224934 Log: Flesh out the aggregate cleanup function. Again, untested. Fix the aggregate single-packet cleanup function - call the completion handler before potentially kicking the 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 Wed Aug 17 09:44:15 2011 (r224933) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 09:52:34 2011 (r224934) @@ -2023,6 +2023,8 @@ ath_tx_comp_cleanup_unaggr(struct ath_so DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: incomp=%d\n", __func__, tid, atid->incomp); + ath_tx_default_comp(sc, bf, 0); + atid->incomp--; if (atid->incomp == 0) { DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, @@ -2032,7 +2034,6 @@ ath_tx_comp_cleanup_unaggr(struct ath_so ath_tx_tid_resume(sc, atid); } - ath_tx_default_comp(sc, bf, 0); } /* @@ -2330,9 +2331,31 @@ ath_tx_comp_aggr_error(struct ath_softc * Handle clean-up of packets from an aggregate list. */ static void -ath_tx_comp_cleanup_aggr(struct ath_softc *sc, struct ath_buf *bf) +ath_tx_comp_cleanup_aggr(struct ath_softc *sc, struct ath_buf *bf_first) { - /* XXX TODO */ + struct ath_buf *bf, *bf_next; + struct ieee80211_node *ni = bf_first->bf_node; + struct ath_node *an = ATH_NODE(ni); + int tid = bf_first->bf_state.bfs_tid; + struct ath_tid *atid = &an->an_tid[tid]; + + bf = bf_first; + + while (bf) { + atid->incomp--; + bf_next = bf->bf_next; + ath_tx_default_comp(sc, bf, -1); + bf = bf_next; + } + + if (atid->incomp == 0) { + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: TID %d: cleaned up! resume!\n", + __func__, tid); + atid->cleanup_inprogress = 0; + ath_tx_tid_resume(sc, atid); + } + } /* From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 14: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 7B3C51065677; Wed, 17 Aug 2011 14:08:02 +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 690008FC18; Wed, 17 Aug 2011 14: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 p7HE82Hd008340; Wed, 17 Aug 2011 14:08:02 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7HE82gh008332; Wed, 17 Aug 2011 14:08:02 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108171408.p7HE82gh008332@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 17 Aug 2011 14: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: r224939 - in user/gabor/tre-integration: contrib/tre/lib include lib/libc/regex 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, 17 Aug 2011 14:08:02 -0000 Author: gabor Date: Wed Aug 17 14:08:02 2011 New Revision: 224939 URL: http://svn.freebsd.org/changeset/base/224939 Log: - Introduce a public interface for fast matching Added: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c (contents, props changed) user/gabor/tre-integration/include/fastmatch.h (contents, props changed) user/gabor/tre-integration/include/hashtable.h - copied unchanged from r223646, user/gabor/tre-integration/contrib/tre/lib/hashtable.h Deleted: user/gabor/tre-integration/contrib/tre/lib/hashtable.h Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h user/gabor/tre-integration/include/Makefile user/gabor/tre-integration/lib/libc/regex/Makefile.inc Added: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 17 14:08:02 2011 (r224939) @@ -0,0 +1,185 @@ +/*- + * Copyright (C) 2011 Gabor Kovesdan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /* HAVE_CONFIG_H */ +#include +#include + +#include "tre-fastmatch.h" +#include "tre-internal.h" +#include "xmalloc.h" + +/* XXX: clean up */ +#define CONV_PAT \ + int ret; \ + tre_char_t *wregex; \ + size_t wlen; \ + \ + wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); \ + if (wregex == NULL) \ + return REG_ESPACE; \ + else \ + { \ + int consumed; \ + tre_char_t *wcptr = wregex; \ + mbstate_t state; \ + memset(&state, '\0', sizeof(state)); \ + while (n > 0) \ + { \ + consumed = tre_mbrtowc(wcptr, regex, n, &state); \ + \ + switch (consumed) \ + { \ + case 0: \ + if (*regex == '\0') \ + consumed = 1; \ + else \ + { \ + xfree(wregex); \ + return REG_BADPAT; \ + } \ + break; \ + case -1: \ + DPRINT(("mbrtowc: error %d: %s.\n", errno, \ + strerror(errno))); \ + xfree(wregex); \ + return REG_BADPAT; \ + case -2: \ + consumed = n; \ + break; \ + } \ + regex += consumed; \ + n -= consumed; \ + wcptr++; \ + } \ + wlen = wcptr - wregex; \ + } \ + \ + wregex[wlen] = L'\0'; + +int +tre_fixncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) +{ + CONV_PAT; + + ret = tre_compile_literal(preg, wregex, n, cflags); + xfree(wregex); + + return ret; +} + +int +tre_fastncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) +{ + CONV_PAT; + + ret = (cflags & REG_LITERAL) ? + tre_compile_literal(preg, wregex, n, cflags) : + tre_compile_fast(preg, wregex, n, cflags); + xfree(wregex); + + return ret; +} + + +int +tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags) +{ + return tre_fixncomp(preg, regex, 0, cflags); +} + +int +tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags) +{ + return tre_fastncomp(preg, regex, 0, cflags); +} + +int +tre_fixwncomp(fastmatch_t *preg, const wchar_t *regex, size_t n, int cflags) +{ + return tre_compile_literal(preg, regex, n, cflags); +} + +int +tre_fastwncomp(fastmatch_t *preg, const wchar_t *regex, size_t n, int cflags) +{ + return (cflags & REG_LITERAL) ? + tre_compile_literal(preg, regex, n, cflags) : + tre_compile_fast(preg, regex, n, cflags); +} + +int +tre_fixwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags) +{ + return tre_fixwncomp(preg, regex, 0, cflags); +} + +int +tre_fastwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags) +{ + return tre_fastwncomp(preg, regex, 0, cflags); +} + +void +tre_fastfree(fastmatch_t *preg) +{ + tre_free_fast(preg); +} + +int +tre_fastnexec(const fastmatch_t *preg, const char *string, size_t n, + size_t nmatch, regmatch_t pmatch[], int eflags) +{ + tre_str_type_t type = (TRE_MB_CUR_MAX == 1) ? STR_BYTE : STR_MBS; + + return tre_match_fast(preg, string, n, type, nmatch, + pmatch, eflags); +} + +int +tre_fastexec(const fastmatch_t *preg, const char *string, size_t nmatch, + regmatch_t pmatch[], int eflags) +{ + return tre_fastnexec(preg, string, (size_t)-1, nmatch, pmatch, eflags); +} + +int +tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t n, + size_t nmatch, regmatch_t pmatch[], int eflags) +{ + return tre_match_fast(preg, string, n, STR_WIDE, nmatch, + pmatch, eflags); +} + +int +tre_fastwexec(const fastmatch_t *preg, const wchar_t *string, + size_t nmatch, regmatch_t pmatch[], int eflags) +{ + return tre_fastwnexec(preg, string, (size_t)-1, nmatch, pmatch, eflags); +} + Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/hashtable.c Wed Aug 17 13:58:39 2011 (r224938) +++ user/gabor/tre-integration/contrib/tre/lib/hashtable.c Wed Aug 17 14:08:02 2011 (r224939) @@ -25,11 +25,10 @@ */ #include +#include #include #include -#include "hashtable.h" - hashtable *hashtable_init(size_t table_size, size_t key_size, size_t value_size) { Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 17 13:58:39 2011 (r224938) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 17 14:08:02 2011 (r224939) @@ -28,6 +28,7 @@ #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ +#include #include #include #include Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Wed Aug 17 13:58:39 2011 (r224938) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Wed Aug 17 14:08:02 2011 (r224939) @@ -28,6 +28,8 @@ #ifndef TRE_FASTMATCH_H #define TRE_FASTMATCH_H 1 +#include +#include #include #include #include @@ -35,25 +37,6 @@ #include "hashtable.h" #include "tre-internal.h" -typedef struct { - size_t wlen; - size_t len; - tre_char_t *wpattern; - int hasdot; - int qsBc[UCHAR_MAX + 1]; - int *bmGs; - char *pattern; - int defBc; - hashtable *qsBc_table; - int *sbmGs; - /* flags */ - bool bol; - bool eol; - bool word; - bool icase; - bool newline; -} fastmatch_t; - int tre_compile_literal(fastmatch_t *preg, const tre_char_t *regex, size_t, int); int tre_compile_fast(fastmatch_t *preg, const tre_char_t *regex, size_t, int); Modified: user/gabor/tre-integration/include/Makefile ============================================================================== --- user/gabor/tre-integration/include/Makefile Wed Aug 17 13:58:39 2011 (r224938) +++ user/gabor/tre-integration/include/Makefile Wed Aug 17 14:08:02 2011 (r224939) @@ -9,9 +9,9 @@ CLEANFILES= osreldate.h version vers.c SUBDIR= arpa gssapi protocols rpcsvc rpc INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \ db.h \ - dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \ - fts.h ftw.h getopt.h glob.h grp.h gssapi.h \ - ieeefp.h ifaddrs.h \ + dirent.h dlfcn.h elf.h elf-hints.h err.h fastmatch.h fmtmsg.h fnmatch.h \ + fstab.h fts.h ftw.h getopt.h glob.h grp.h gssapi.h \ + hashtable.h ieeefp.h ifaddrs.h \ inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \ locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \ ndbm.h netconfig.h \ Added: user/gabor/tre-integration/include/fastmatch.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/include/fastmatch.h Wed Aug 17 14:08:02 2011 (r224939) @@ -0,0 +1,101 @@ +/*- + * Copyright (C) 2011 Gabor Kovesdan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef FASTMATCH_H +#define FASTMATCH_H 1 + +#include +#include +#include +#include +#include + +typedef struct { + size_t wlen; + size_t len; + wchar_t *wpattern; + int hasdot; + int qsBc[UCHAR_MAX + 1]; + int *bmGs; + char *pattern; + int defBc; + hashtable *qsBc_table; + int *sbmGs; + + /* flags */ + bool bol; + bool eol; + bool word; + bool icase; + bool newline; +} fastmatch_t; + +extern int +tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags); + +extern int +tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags); + +extern int +tre_fastexec(const fastmatch_t *preg, const char *string, size_t nmatch, + regmatch_t pmatch[], int eflags); + +extern void +tre_fastfree(fastmatch_t *preg); + +extern int +tre_fixwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags); + +extern int +tre_fastwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags); + +extern int +tre_fastwexec(const fastmatch_t *preg, const wchar_t *string, + size_t nmatch, regmatch_t pmatch[], int eflags); + +/* Versions with a maximum length argument and therefore the capability to + handle null characters in the middle of the strings. */ +extern int +tre_fixncomp(fastmatch_t *preg, const char *regex, size_t len, int cflags); + +extern int +tre_fastncomp(fastmatch_t *preg, const char *regex, size_t len, int cflags); + +extern int +tre_fastnexec(const fastmatch_t *preg, const char *string, size_t len, + size_t nmatch, regmatch_t pmatch[], int eflags); + +extern int +tre_fixwncomp(fastmatch_t *preg, const wchar_t *regex, size_t len, int cflags); + +extern int +tre_fastwncomp(fastmatch_t *preg, const wchar_t *regex, size_t len, int cflags); + +extern int +tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t len, + size_t nmatch, regmatch_t pmatch[], int eflags); + +#endif /* FASTMATCH_H */ Copied: user/gabor/tre-integration/include/hashtable.h (from r223646, user/gabor/tre-integration/contrib/tre/lib/hashtable.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/include/hashtable.h Wed Aug 17 14:08:02 2011 (r224939, copy of r223646, user/gabor/tre-integration/contrib/tre/lib/hashtable.h) @@ -0,0 +1,51 @@ +/*- + * Copyright (C) 2011 Gabor Kovesdan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef HASHTABLE_H +#define HASHTABLE_H 1 + +#include + +typedef struct { + void *key; + void *value; +} hashtable_entry; + +typedef struct { + size_t key_size; + size_t table_size; + size_t usage; + size_t value_size; + hashtable_entry **entries; +} hashtable; + +void hashtable_free(hashtable *); +int hashtable_get(hashtable *, const void *, void *); +hashtable *hashtable_init(size_t, size_t, size_t); +int hashtable_put(hashtable *, const void *, const void *); +int hashtable_remove(hashtable *, const void *); + +#endif /* HASHTABLE.H */ Modified: user/gabor/tre-integration/lib/libc/regex/Makefile.inc ============================================================================== --- user/gabor/tre-integration/lib/libc/regex/Makefile.inc Wed Aug 17 13:58:39 2011 (r224938) +++ user/gabor/tre-integration/lib/libc/regex/Makefile.inc Wed Aug 17 14:08:02 2011 (r224939) @@ -5,9 +5,10 @@ CFLAGS+=-DHAVE_CONFIG_H -DTRE_LIBC_BUILD -I${.CURDIR}/../../contrib/tre -SRCS+= hashtable.c regcomp.c regerror.c regexec.c tre-ast.c tre-compile.c \ - tre-fastmatch.c tre-match-approx.c tre-match-backtrack.c \ - tre-match-parallel.c tre-mem.c tre-parse.c tre-stack.c xmalloc.c +SRCS+= fastmatch.c hashtable.c regcomp.c regerror.c regexec.c tre-ast.c \ + tre-compile.c tre-fastmatch.c tre-match-approx.c \ + tre-match-backtrack.c tre-match-parallel.c tre-mem.c tre-parse.c \ + tre-stack.c xmalloc.c MAN+= regex.3 re_format.7 From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 14:28:59 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 5DB511065672; Wed, 17 Aug 2011 14:28:59 +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 4C6898FC18; Wed, 17 Aug 2011 14:28:59 +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 p7HESxWZ009050; Wed, 17 Aug 2011 14:28:59 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7HESxpv009044; Wed, 17 Aug 2011 14:28:59 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108171428.p7HESxpv009044@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 14:28:59 +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: r224940 - in user/adrian/if_ath_tx/sys/dev/ath: . ath_hal ath_hal/ar5416 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, 17 Aug 2011 14:28:59 -0000 Author: adrian Date: Wed Aug 17 14:28:58 2011 New Revision: 224940 URL: http://svn.freebsd.org/changeset/base/224940 Log: Add two new 11n methods - aggr middle and aggr last. This matches the HAL routines in ath9k and the reference driver. There's some duplicate and unused code though; I'll do a subsequent pass to prune those out. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah.h user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.h user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah.h Wed Aug 17 14:08:02 2011 (r224939) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah.h Wed Aug 17 14:28:58 2011 (r224940) @@ -1000,8 +1000,14 @@ struct ath_hal { void __ahdecl(*ah_set11nRateScenario)(struct ath_hal *, struct ath_desc *, u_int, u_int, HAL_11N_RATE_SERIES [], u_int, u_int); + + void __ahdecl(*ah_set11nAggrFirst)(struct ath_hal *, + struct ath_desc *, u_int, u_int); void __ahdecl(*ah_set11nAggrMiddle)(struct ath_hal *, struct ath_desc *, u_int); + void __ahdecl(*ah_set11nAggrLast)(struct ath_hal *, + struct ath_desc *); + void __ahdecl(*ah_clr11nAggr)(struct ath_hal *, struct ath_desc *); void __ahdecl(*ah_set11nBurstDuration)(struct ath_hal *, Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.h Wed Aug 17 14:08:02 2011 (r224939) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.h Wed Aug 17 14:28:58 2011 (r224940) @@ -334,8 +334,14 @@ extern u_int ar5416GetGlobalTxTimeout(st extern void ar5416Set11nRateScenario(struct ath_hal *ah, struct ath_desc *ds, u_int durUpdateEn, u_int rtsctsRate, HAL_11N_RATE_SERIES series[], u_int nseries, u_int flags); + +extern void ar5416Set11nAggrFirst(struct ath_hal *ah, struct ath_desc *ds, + u_int aggrLen, u_int numDelims); extern void ar5416Set11nAggrMiddle(struct ath_hal *ah, struct ath_desc *ds, u_int numDelims); +extern void ar5416Set11nAggrLast(struct ath_hal *ah, struct ath_desc *ds); + extern void ar5416Clr11nAggr(struct ath_hal *ah, struct ath_desc *ds); + extern void ar5416Set11nBurstDuration(struct ath_hal *ah, struct ath_desc *ds, u_int burstDuration); extern const HAL_RATE_TABLE *ar5416GetRateTable(struct ath_hal *, u_int mode); Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Wed Aug 17 14:08:02 2011 (r224939) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Wed Aug 17 14:28:58 2011 (r224940) @@ -165,7 +165,9 @@ ar5416InitState(struct ath_hal_5416 *ahp ah->ah_setupFirstTxDesc = ar5416SetupFirstTxDesc; ah->ah_setupLastTxDesc = ar5416SetupLastTxDesc; ah->ah_set11nRateScenario = ar5416Set11nRateScenario; + ah->ah_set11nAggrFirst = ar5416Set11nAggrFirst; ah->ah_set11nAggrMiddle = ar5416Set11nAggrMiddle; + ah->ah_set11nAggrLast = ar5416Set11nAggrLast; ah->ah_clr11nAggr = ar5416Clr11nAggr; ah->ah_set11nBurstDuration = ar5416Set11nBurstDuration; ah->ah_get11nExtBusy = ar5416Get11nExtBusy; Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Wed Aug 17 14:08:02 2011 (r224939) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Wed Aug 17 14:28:58 2011 (r224940) @@ -693,6 +693,19 @@ ar5416Set11nRateScenario(struct ath_hal } void +ar5416Set11nAggrFirst(struct ath_hal *ah, struct ath_desc *ds, + u_int aggrLen, u_int numDelims) +{ + struct ar5416_desc *ads = AR5416DESC(ds); + + ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr); + + ads->ds_ctl6 &= ~(AR_AggrLen | AR_PadDelim); + ads->ds_ctl6 |= SM(aggrLen, AR_AggrLen) | + SM(numDelims, AR_PadDelim); +} + +void ar5416Set11nAggrMiddle(struct ath_hal *ah, struct ath_desc *ds, u_int numDelims) { struct ar5416_desc *ads = AR5416DESC(ds); @@ -712,6 +725,16 @@ ar5416Set11nAggrMiddle(struct ath_hal *a } void +ar5416Set11nAggrLast(struct ath_hal *ah, struct ath_desc *ds) +{ + struct ar5416_desc *ads = AR5416DESC(ds); + + ads->ds_ctl1 |= AR_IsAggr; + ads->ds_ctl1 &= ~AR_MoreAggr; + ads->ds_ctl6 &= ~AR_PadDelim; +} + +void ar5416Clr11nAggr(struct ath_hal *ah, struct ath_desc *ds) { struct ar5416_desc *ads = AR5416DESC(ds); 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 17 14:08:02 2011 (r224939) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 17 14:28:58 2011 (r224940) @@ -830,8 +830,14 @@ void ath_intr(void *); #define ath_hal_set11nratescenario(_ah, _ds, _dur, _rt, _series, _ns, _flags) \ ((*(_ah)->ah_set11nRateScenario)((_ah), (_ds), (_dur), (_rt), \ (_series), (_ns), (_flags))) + +#define ath_hal_set11n_aggr_first(_ah, _ds, _len, _num) \ + ((*(_ah)->ah_set11nAggrFirst)((_ah), (_ds), (_len), (_num))) #define ath_hal_set11naggrmiddle(_ah, _ds, _num) \ ((*(_ah)->ah_set11nAggrMiddle)((_ah), (_ds), (_num))) +#define ath_hal_set11n_aggr_last(_ah, _ds) \ + ((*(_ah)->ah_set11nAggrLast)((_ah), (_ds))) + #define ath_hal_set11nburstduration(_ah, _ds, _dur) \ ((*(_ah)->ah_set11nBurstDuration)((_ah), (_ds), (_dur))) #define ath_hal_clr11n_aggr(_ah, _ds) \ From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 15:13: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 B3C771065670; Wed, 17 Aug 2011 15:13: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 A36328FC0A; Wed, 17 Aug 2011 15:13: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 p7HFD708010628; Wed, 17 Aug 2011 15:13:07 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7HFD7Qx010626; Wed, 17 Aug 2011 15:13:07 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108171513.p7HFD7Qx010626@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 15:13: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: r224943 - 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, 17 Aug 2011 15:13:07 -0000 Author: adrian Date: Wed Aug 17 15:13:07 2011 New Revision: 224943 URL: http://svn.freebsd.org/changeset/base/224943 Log: Comment what SHOULD happen. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Wed Aug 17 14:39:45 2011 (r224942) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Wed Aug 17 15:13:07 2011 (r224943) @@ -369,8 +369,11 @@ ath_tx_form_aggr(struct ath_softc *sc, s */ /* - * If the frame doesn't have a sequence number, we can't - * aggregate it. + * If the frame doesn't have a sequence number that we're + * tracking in the BAW (eg NULL QOS data frame), we can't + * aggregate it. Stop the aggregation process; the sender + * can then TX what's in the list thus far and then + * TX the frame individually. */ if (! bf->bf_state.bfs_dobaw) { ATH_TXQ_UNLOCK(tid); From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 15:45:41 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 28DDD106566B; Wed, 17 Aug 2011 15:45:41 +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 F2D898FC08; Wed, 17 Aug 2011 15:45:40 +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 p7HFjebf011984; Wed, 17 Aug 2011 15:45:40 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7HFjeW2011982; Wed, 17 Aug 2011 15:45:40 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108171545.p7HFjeW2011982@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 15:45:40 +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: r224947 - 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, 17 Aug 2011 15:45:41 -0000 Author: adrian Date: Wed Aug 17 15:45:40 2011 New Revision: 224947 URL: http://svn.freebsd.org/changeset/base/224947 Log: Fix some BAW brokenness introduced by previous commits. The BAW tracking was completely broken. ath_tx_swq() was blanking the BAW flag in the ath_buf, thus no frames were ever thrown into the BAW tracking code. This restores the BAW tracking functionality but there's again a race between the pre-ADDBA sequence numbers and the post-ADDBA BAW. I'll look into this and fix it in a subsequent commit. 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 Wed Aug 17 15:24:25 2011 (r224946) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 15:45:40 2011 (r224947) @@ -1097,6 +1097,8 @@ ath_tx_start(struct ath_softc *sc, struc txq = &avp->av_mcastq; /* Do the generic frame setup */ + /* XXX should just bzero the bf_state? */ + bf->bf_state.bfs_dobaw = 0; /* A-MPDU TX? Manually set sequence number */ /* Don't do it whilst pending; the net80211 layer still assigns them */ @@ -1247,6 +1249,10 @@ ath_tx_raw_start(struct ath_softc *sc, s /* packet header may have moved, reset our local pointer */ wh = mtod(m0, struct ieee80211_frame *); + /* Do the generic frame setup */ + /* XXX should just bzero the bf_state? */ + bf->bf_state.bfs_dobaw = 0; + error = ath_tx_dmasetup(sc, bf, m0); if (error != 0) return error; @@ -1780,7 +1786,6 @@ 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; bf->bf_state.bfs_aggr = 0; bf->bf_state.bfs_aggrburst = 0; @@ -2581,6 +2586,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft "%s: seq %d outside of %d/%d; waiting\n", __func__, SEQNO(bf->bf_state.bfs_seqno), tap->txa_start, tap->txa_wnd); + ATH_TXQ_UNLOCK(atid); break; } From owner-svn-src-user@FreeBSD.ORG Wed Aug 17 23:59: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 989311065670; Wed, 17 Aug 2011 23:59:55 +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 883208FC08; Wed, 17 Aug 2011 23:59: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 p7HNxtvw028188; Wed, 17 Aug 2011 23:59:55 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7HNxt7K028186; Wed, 17 Aug 2011 23:59:55 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108172359.p7HNxt7K028186@svn.freebsd.org> From: Adrian Chadd Date: Wed, 17 Aug 2011 23:59:55 +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: r224952 - 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, 17 Aug 2011 23:59:55 -0000 Author: adrian Date: Wed Aug 17 23:59:55 2011 New Revision: 224952 URL: http://svn.freebsd.org/changeset/base/224952 Log: Close up any BAW races as much as possible; document the current problem and the workaround. In the first cut of this code, packet scheduling (ie, stuffing into a software or hardware TXQ) occured in the same context as the serialised TX from the net80211/netif code. When addba was set, the TID could be paused, and anything queued into the software queue would sit there and wait. Once the TID was unpaused, all those queued packets with sequence numbers would fall into an aggregate TID, and their sequence numbers would happily fall into the BAW. Now, packet scheduling occurs in the task context rather than the TX context. So when the TID is paused, any currently running packet scheduler/queue function in the ath task may be running concurrently. So it's possible that some packets would be dumped to the hardware before the TID pause value was checked. This commit (mostly) fixes the races in checking the TID paused flag. It doesn't check for races when forming aggregates; I'll worry about that later when I'm actively making aggregate frames. But as the TID isn't being locked for the entire duration of the packet scheduling and hardware queue, it's quite possible one will leak by between when TID->paused is set, and the next time it's checked. I'm also "sliding" the left edge of the BAW along to match whatever sequence numbers net80211 assigns between addba being setup and addba being actually enabled. The (likely) correct way to handle this is to queue frames during addba setup for this TID as aggregates without creating sequence numbers for them. If the TID pause is handled correctly, this should occur. This needs to be revisited and fixed before the code is merged into -HEAD. 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 Wed Aug 17 20:55:56 2011 (r224951) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 17 23:59:55 2011 (r224952) @@ -1104,7 +1104,7 @@ ath_tx_start(struct ath_softc *sc, struc /* Don't do it whilst pending; the net80211 layer still assigns them */ if (is_ampdu_tx) { /* - * Always set a seqno; this function will + * Always call; 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. @@ -1676,6 +1676,9 @@ ath_tx_tid_sched(struct ath_softc *sc, s ATH_TXQ_LOCK_ASSERT(txq); + if (atid->paused) + return; /* paused, can't schedule yet */ + if (atid->sched) return; /* already scheduled */ @@ -2564,11 +2567,24 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft for (;;) { ATH_TXQ_LOCK(atid); + + /* + * If the upper layer has paused the TID, don't + * queue any further packets. + * + * This can also occur from the completion task because + * of packet loss; but as its serialised with this code, + * it won't "appear" half way through queuing packets. + */ + if (atid->paused) + break; + bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { ATH_TXQ_UNLOCK(atid); 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) @@ -2656,11 +2672,20 @@ ath_tx_tid_hw_queue_norm(struct ath_soft for (;;) { ATH_TXQ_LOCK(atid); + + /* + * If the upper layers have paused the TID, don't + * queue any further packets. + */ + if (atid->paused) + break; + bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { ATH_TXQ_UNLOCK(atid); break; } + ATH_TXQ_REMOVE_HEAD(atid, bf_list); ATH_TXQ_UNLOCK(atid); @@ -2817,9 +2842,32 @@ ath_addba_request(struct ieee80211_node struct ath_node *an = ATH_NODE(ni); struct ath_tid *atid = &an->an_tid[tid]; - DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); + /* + * XXX This isn't enough. + * + * The taskqueue may be running and scheduling some more packets. + * It acquires the TID lock to serialise access to the TID paused + * flag but as the rest of the code doesn't hold the TID lock + * for the duration of any activity (outside of adding/removing + * items from the software queue), it can't possibly guarantee + * consistency. + * + * This pauses future scheduling, but it doesn't interrupt the + * current scheduling, nor does it wait for that scheduling to + * finish. So the txseq window has moved, and those frames + * in the meantime have "normal" completion handlers. + * + * The addba teardown pause/resume likely has the same problem. + */ ath_tx_tid_pause(sc, atid); + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: called; dialogtoken=%d, baparamset=%d, batimeout=%d\n", + __func__, dialogtoken, baparamset, batimeout); + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: txa_start=%d, ni_txseqs=%d\n", + __func__, tap->txa_start, ni->ni_txseqs[tid]); + return sc->sc_addba_request(ni, tap, dialogtoken, baparamset, batimeout); } @@ -2831,6 +2879,18 @@ ath_addba_request(struct ieee80211_node * * Any packets TX'ed from this point should be "aggregate" (whether * aggregate or not) so the BAW is updated. + * + * Note! net80211 keeps self-assigning sequence numbers until + * ampdu is negotiated. This means the initially-negotiated BAW left + * edge won't match the ni->ni_txseq. + * + * So, being very dirty, the BAW left edge is "slid" here to match + * ni->ni_txseq. + * + * What likely SHOULD happen is that all packets subsequent to the + * addba request should be tagged as aggregate and queued as non-aggregate + * frames; thus updating the BAW. For now though, I'll just slide the + * window. */ int ath_addba_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, @@ -2842,6 +2902,14 @@ ath_addba_response(struct ieee80211_node struct ath_tid *atid = &an->an_tid[tid]; int r; + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: called; status=%d, code=%d, batimeout=%d\n", __func__, + status, code, batimeout); + + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: txa_start=%d, ni_txseqs=%d\n", + __func__, tap->txa_start, ni->ni_txseqs[tid]); + /* * Call this first, so the interface flags get updated * before the TID is unpaused. Otherwise a race condition @@ -2850,7 +2918,13 @@ ath_addba_response(struct ieee80211_node */ r = sc->sc_addba_response(ni, tap, status, code, batimeout); - DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); + /* + * XXX dirty! + * Slide the BAW left edge to wherever net80211 left it for us. + * Read above for more information. + */ + tap->txa_start = ni->ni_txseqs[tid]; + ath_tx_tid_resume(sc, atid); return r; } From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 00:19: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 CCB8E1065672; Thu, 18 Aug 2011 00:19: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 A3AF98FC12; Thu, 18 Aug 2011 00:19: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 p7I0JCAh028898; Thu, 18 Aug 2011 00:19:12 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I0JCmn028896; Thu, 18 Aug 2011 00:19:12 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180019.p7I0JCmn028896@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 00:19: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: r224954 - 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, 18 Aug 2011 00:19:12 -0000 Author: adrian Date: Thu Aug 18 00:19:12 2011 New Revision: 224954 URL: http://svn.freebsd.org/changeset/base/224954 Log: In preparation for forming aggregates, push the descriptor setup and descriptor chain code into the software queue routine, and leave setting the rate control stuff until the packet is actually queued to the hardware. 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 18 00:05:09 2011 (r224953) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 18 00:19:12 2011 (r224954) @@ -1397,10 +1397,10 @@ ath_tx_raw_start(struct ath_softc *sc, s */ if (do_override) { - ATH_TXQ_LOCK(sc->sc_ac2q[pri]); ath_tx_setds(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); ath_tx_chaindesclist(sc, bf); + ATH_TXQ_LOCK(sc->sc_ac2q[pri]); ath_tx_handoff(sc, sc->sc_ac2q[pri], bf); ATH_TXQ_UNLOCK(sc->sc_ac2q[pri]); } @@ -1792,6 +1792,16 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_aggr = 0; bf->bf_state.bfs_aggrburst = 0; + /* + * Program first and chain the descriptors together. + * + * These fields (along with the DMA map setup) are needed + * by the aggregate forming code, which only overrides + * the rate control setup and the aggregation fields. + */ + ath_tx_setds(sc, bf); + ath_tx_chaindesclist(sc, bf); + /* Queue frame to the tail of the software queue */ ATH_TXQ_LOCK(atid); ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); @@ -2636,10 +2646,8 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft if (bf->bf_state.bfs_tid == IEEE80211_NONQOS_TID) device_printf(sc->sc_dev, "%s: TID=16?\n", __func__); - /* Program descriptor */ - ath_tx_setds(sc, bf); + /* Program rate control */ ath_tx_set_ratectrl(sc, ni, bf); - ath_tx_chaindesclist(sc, bf); /* Punt to hardware or software txq */ ATH_TXQ_LOCK(txq); @@ -2700,10 +2708,8 @@ ath_tx_tid_hw_queue_norm(struct ath_soft /* Normal completion handler */ bf->bf_comp = ath_tx_normal_comp; - /* Program descriptor */ - ath_tx_setds(sc, bf); + /* Program rate control*/ ath_tx_set_ratectrl(sc, ni, bf); - ath_tx_chaindesclist(sc, bf); /* Punt to hardware or software txq */ ATH_TXQ_LOCK(txq); From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 00:31: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 DD2FC1065670; Thu, 18 Aug 2011 00:31:08 +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 B42D58FC1C; Thu, 18 Aug 2011 00:31:08 +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 p7I0V8QH029283; Thu, 18 Aug 2011 00:31:08 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I0V8xq029281; Thu, 18 Aug 2011 00:31:08 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180031.p7I0V8xq029281@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 00:31:08 +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: r224955 - 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, 18 Aug 2011 00:31:08 -0000 Author: adrian Date: Thu Aug 18 00:31:08 2011 New Revision: 224955 URL: http://svn.freebsd.org/changeset/base/224955 Log: Update with a nice, long description of what I have to do to fix the initial burst of packets after addba negotiation begins. 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 18 00:19:12 2011 (r224954) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 18 00:31:08 2011 (r224955) @@ -2849,21 +2849,27 @@ ath_addba_request(struct ieee80211_node struct ath_tid *atid = &an->an_tid[tid]; /* - * XXX This isn't enough. + * XXX danger Will Robinson! * - * The taskqueue may be running and scheduling some more packets. - * It acquires the TID lock to serialise access to the TID paused - * flag but as the rest of the code doesn't hold the TID lock - * for the duration of any activity (outside of adding/removing - * items from the software queue), it can't possibly guarantee - * consistency. + * Although the taskqueue may be running and scheduling some more + * packets, these should all be _before_ the addba sequence number. + * However, net80211 will keep self-assigning sequence numbers + * until addba has been negotiated. * - * This pauses future scheduling, but it doesn't interrupt the - * current scheduling, nor does it wait for that scheduling to - * finish. So the txseq window has moved, and those frames - * in the meantime have "normal" completion handlers. + * In the past, these packets would be "paused" (which still works + * fine, as they're being scheduled to the driver in the same + * serialised method which is calling the addba request routine) + * and when the aggregation session begins, they'll be dequeued + * as aggregate packets and added to the BAW. However, now there's + * a "bf->bf_state.bfs_dobaw" flag, and this isn't set for these + * packets. Thus they never get included in the BAW tracking and + * this can cause the initial burst of packets after the addba + * negotiation to "hang", as they quickly fall outside the BAW. * - * The addba teardown pause/resume likely has the same problem. + * The "eventual" solution should be to tag these packets with + * dobaw. Although net80211 has given us a sequence number, + * it'll be "after" the left edge of the BAW and thus it'll + * fall within it. */ ath_tx_tid_pause(sc, atid); From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 03:44: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 83A2B106566B; Thu, 18 Aug 2011 03:44:32 +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 746538FC16; Thu, 18 Aug 2011 03:44: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 p7I3iWEq035339; Thu, 18 Aug 2011 03:44:32 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I3iWjW035337; Thu, 18 Aug 2011 03:44:32 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180344.p7I3iWjW035337@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 03:44: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: r224956 - 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, 18 Aug 2011 03:44:32 -0000 Author: adrian Date: Thu Aug 18 03:44:32 2011 New Revision: 224956 URL: http://svn.freebsd.org/changeset/base/224956 Log: Fix a locking bug I introduced in the past. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 00:31:08 2011 (r224955) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 03:44:32 2011 (r224956) @@ -4434,8 +4434,8 @@ ath_tx_draintxq(struct ath_softc *sc, st ATH_TXQ_LOCK(txq); bf = STAILQ_FIRST(&txq->axq_q); if (bf == NULL) { - ATH_TXQ_UNLOCK(txq); txq->axq_link = NULL; + ATH_TXQ_UNLOCK(txq); break; } ATH_TXQ_REMOVE_HEAD(txq, bf_list); From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 04:39:30 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 58E15106564A; Thu, 18 Aug 2011 04:39:30 +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 495ED8FC12; Thu, 18 Aug 2011 04:39:30 +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 p7I4dU98037010; Thu, 18 Aug 2011 04:39:30 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I4dUTG037008; Thu, 18 Aug 2011 04:39:30 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180439.p7I4dUTG037008@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 04:39:30 +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: r224957 - 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, 18 Aug 2011 04:39:30 -0000 Author: adrian Date: Thu Aug 18 04:39:29 2011 New Revision: 224957 URL: http://svn.freebsd.org/changeset/base/224957 Log: Detaching the STA VAP causes a station disassociate frame to be sent. This ends up being queued on a TX node that is then being freed, leading to a node sticking around whose vap state is now invalid. For now, just force another hardware and software TXQ flush. Later on, investigate why this is the case as this doesn't occur in the normal ath tree. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 03:44:32 2011 (r224956) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 04:39:29 2011 (r224957) @@ -1150,6 +1150,27 @@ ath_vap_delete(struct ieee80211vap *vap) } ieee80211_vap_detach(vap); + + /* + * XXX Danger Will Robinson! Danger! + * + * Because ieee80211_vap_detach() can queue a frame (the station + * diassociate message?) after we've drained the TXQ and + * flushed the software TXQ, we will end up with a frame queued + * to a node whose vap is about to be freed. + * + * To work around this, flush the hardware/software again. + * This may be racy - the ath task may be running and the packet + * may be being scheduled between sw->hw txq. Tsk. + * + * TODO: figure out why a new node gets allocated somewhere around + * here (after the ath_tx_swq() call; and after an ath_stop_locked() + * call!) + */ + + ath_draintxq(sc); + ath_sc_flushtxq(sc); + ATH_LOCK(sc); /* * Reclaim beacon state. Note this must be done before From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 04:44:42 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 4D495106564A; Thu, 18 Aug 2011 04:44:42 +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 3DE238FC19; Thu, 18 Aug 2011 04:44:42 +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 p7I4igRj037201; Thu, 18 Aug 2011 04:44:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I4igag037199; Thu, 18 Aug 2011 04:44:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180444.p7I4igag037199@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 04:44:42 +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: r224958 - 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, 18 Aug 2011 04:44:42 -0000 Author: adrian Date: Thu Aug 18 04:44:41 2011 New Revision: 224958 URL: http://svn.freebsd.org/changeset/base/224958 Log: Whilst auditing the code, I've found that my shuffling of ATH_BUF_BUSY handling is incorrect. Since this'll break the TDMA code (and I'd rather not do that), just leave a note for it to be revisited before this is merged back into -HEAD. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 04:39:29 2011 (r224957) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 04:44:41 2011 (r224958) @@ -4425,6 +4425,11 @@ ath_tx_freebuf(struct ath_softc *sc, str } m_freem(bf->bf_m); bf->bf_m = NULL; + + /* + * XXX This is incorrect. Check what the -HEAD code is doing. + * XXX The TDMA code will be broken if this isn't properly repaired. + */ bf->bf_flags &= ~ATH_BUF_BUSY; ATH_TXBUF_LOCK(sc); From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 08:40:11 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 6B87E1065680; Thu, 18 Aug 2011 08:40:11 +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 5B5158FC08; Thu, 18 Aug 2011 08:40:11 +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 p7I8eBIs046218; Thu, 18 Aug 2011 08:40:11 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I8eBm6046216; Thu, 18 Aug 2011 08:40:11 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180840.p7I8eBm6046216@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 08:40:11 +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: r224961 - 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, 18 Aug 2011 08:40:11 -0000 Author: adrian Date: Thu Aug 18 08:40:11 2011 New Revision: 224961 URL: http://svn.freebsd.org/changeset/base/224961 Log: Fix a typo; shuffle things around a bit. 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 18 08:25:27 2011 (r224960) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Thu Aug 18 08:40:11 2011 (r224961) @@ -816,17 +816,18 @@ void ath_intr(void *); #define ath_hal_gettxcompletionrates(_ah, _ds, _rates, _tries) \ ((*(_ah)->ah_getTxCompletionRates)((_ah), (_ds), (_rates), (_tries))) -#define ath_hal_chaintxdesc(_ah, _ds, _pktlen, _hdrlen, _type, _keyix, \ - _cipher, _delims, _seglen, _first, _last) \ - ((*(_ah)->ah_chainTxDesc((_ah), (_ds), (_pktlen), (_hdrlen), \ - (_type), (_keyix), (_cipher), (_delims), (_seglen), \ - (_first), (_last)))) #define ath_hal_setupfirsttxdesc(_ah, _ds, _aggrlen, _flags, _txpower, \ _txr0, _txtr0, _antm, _rcr, _rcd) \ ((*(_ah)->ah_setupFirstTxDesc)((_ah), (_ds), (_aggrlen), (_flags), \ (_txpower), (_txr0), (_txtr0), (_antm), (_rcr), (_rcd))) +#define ath_hal_chaintxdesc(_ah, _ds, _pktlen, _hdrlen, _type, _keyix, \ + _cipher, _delims, _seglen, _first, _last) \ + ((*(_ah)->ah_chainTxDesc)((_ah), (_ds), (_pktlen), (_hdrlen), \ + (_type), (_keyix), (_cipher), (_delims), (_seglen), \ + (_first), (_last))) #define ath_hal_setuplasttxdesc(_ah, _ds, _ds0) \ ((*(_ah)->ah_setupLastTxDesc)((_ah), (_ds), (_ds0))) + #define ath_hal_set11nratescenario(_ah, _ds, _dur, _rt, _series, _ns, _flags) \ ((*(_ah)->ah_set11nRateScenario)((_ah), (_ds), (_dur), (_rt), \ (_series), (_ns), (_flags))) From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 08:42:39 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 86330106566C; Thu, 18 Aug 2011 08:42:39 +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 75F818FC12; Thu, 18 Aug 2011 08:42:39 +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 p7I8gdoM046322; Thu, 18 Aug 2011 08:42:39 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I8gdTE046320; Thu, 18 Aug 2011 08:42:39 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180842.p7I8gdTE046320@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 08:42:39 +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: r224962 - 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, 18 Aug 2011 08:42:39 -0000 Author: adrian Date: Thu Aug 18 08:42:39 2011 New Revision: 224962 URL: http://svn.freebsd.org/changeset/base/224962 Log: More updates, the LORs have mostly gone. 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 18 08:40:11 2011 (r224961) +++ user/adrian/if_ath_tx/sys/dev/ath/README Thu Aug 18 08:42:39 2011 (r224962) @@ -20,6 +20,25 @@ Things that need doing! Things that need investigating! +There's a crash which occurs when a wlan interface is destroyed and +re-created. + + +ifconfig wlan0 destroy + +adrian-home-mips# /root/wifi-client ath0 CACHEBOY_11N_1 +ifconfig: interface wlan0 does not exist +wlan0: Ethernet address: 00:15:6d:84:05:52 +kern.msgbuf_clear: 0 -> 0 +net.wlan.0.debug: 0x0 => 0x80000000<11n> +net.wlan.0.debug: 0x80000000 => 0x80800000<11n,assoc> +Trap cause = 4 (address error (load or I-fetch) - kernel mode) +[ thread pid 0 tid 100025 ] +Stopped at ieee80211_node_attach+0x3f4: lw v0,24(v0) +db> reset + +Maybe do a bit of kernel version bisecting to see when this was first broken? +Hopefully it's something easy * 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. @@ -27,63 +46,6 @@ 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 - -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: * Recursive TXQ lock on interface destruction: @@ -159,3 +121,63 @@ pid 0 - There's a dirty workaround to unpause the queue if BAR TX is definitely failing. This needs to be addressed before this work is merged back into -HEAD. + + +* LOR between the net80211 node lock and the txqs + - These have disappeared now that the locking has been reworked. + +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 + +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 + From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 08:45:35 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 BCF5D106566B; Thu, 18 Aug 2011 08:45:35 +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 AD3308FC13; Thu, 18 Aug 2011 08:45:35 +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 p7I8jZL6046462; Thu, 18 Aug 2011 08:45:35 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I8jZFl046460; Thu, 18 Aug 2011 08:45:35 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180845.p7I8jZFl046460@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 08:45:35 +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: r224963 - 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, 18 Aug 2011 08:45:35 -0000 Author: adrian Date: Thu Aug 18 08:45:35 2011 New Revision: 224963 URL: http://svn.freebsd.org/changeset/base/224963 Log: Clear bf_next when a buffer is recycled, just to ensure things aren't pointing to random memory. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 08:42:39 2011 (r224962) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 08:45:35 2011 (r224963) @@ -1855,6 +1855,7 @@ _ath_getbuf_locked(struct ath_softc *sc) STAILQ_FIRST(&sc->sc_txbuf) == NULL ? "out of xmit buffers" : "xmit buffer busy"); } + bf->bf_next = NULL; /* XXX just to be sure */ return bf; } From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 08:58:10 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 69A441065686; Thu, 18 Aug 2011 08:58:10 +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 598548FC0C; Thu, 18 Aug 2011 08:58:10 +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 p7I8wApj046914; Thu, 18 Aug 2011 08:58:10 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I8wASG046912; Thu, 18 Aug 2011 08:58:10 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180858.p7I8wASG046912@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 08:58:10 +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: r224964 - user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416 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, 18 Aug 2011 08:58:10 -0000 Author: adrian Date: Thu Aug 18 08:58:10 2011 New Revision: 224964 URL: http://svn.freebsd.org/changeset/base/224964 Log: To bring this in line with other function calls, use the cipher field stored in the HAL state, rather than the explictly given one. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Thu Aug 18 08:45:35 2011 (r224963) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Thu Aug 18 08:58:10 2011 (r224964) @@ -318,6 +318,9 @@ ar5416FillTxDesc(struct ath_hal *ah, str return AH_TRUE; } +/* + * NB: cipher is no longer used, it's calculated. + */ HAL_BOOL ar5416ChainTxDesc(struct ath_hal *ah, struct ath_desc *ds, u_int pktLen, @@ -362,7 +365,7 @@ ar5416ChainTxDesc(struct ath_hal *ah, st ads->ds_ctl0 |= AR_DestIdxValid; } - ads->ds_ctl6 = SM(ahp->ah_keytype[cipher], AR_EncrType); + ads->ds_ctl6 |= SM(ahp->ah_keytype[keyIx], AR_EncrType); if (isaggr) { ads->ds_ctl6 |= SM(delims, AR_PadDelim); } From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 09:18:39 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 B9D411065677; Thu, 18 Aug 2011 09:18:39 +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 A86608FC20; Thu, 18 Aug 2011 09:18:39 +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 p7I9Iddj047563; Thu, 18 Aug 2011 09:18:39 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7I9IdcD047559; Thu, 18 Aug 2011 09:18:39 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108180918.p7I9IdcD047559@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 09:18:39 +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: r224965 - 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, 18 Aug 2011 09:18:39 -0000 Author: adrian Date: Thu Aug 18 09:18:39 2011 New Revision: 224965 URL: http://svn.freebsd.org/changeset/base/224965 Log: Flip on TX aggregate formation. No, it doesn't quite work. * Push ath_tx_setds() and ath_tx_chaindesc() back to where I had it - ie, setup just before the buffer was queued to the hardware. * Use the 11n aggregate form methods from Sam's HAL, rather than the added methods from linux/reference code. I'm still unsure which to use for now, but those methods do seem to work. the chaindesc method knows about sub-frames _and_ segments of a sub-frame; the Linux/reference code seem to assume that a TX'ed aggregate sub-frame will only take up one skb. (Or there's something else subtle going on that I haven't quite understood.) * Modify ath_tx_form_aggr() to only form the aggregate buffer list; it doesn't link the descriptors together or do any descriptor setup. * Write ath_tx_setds_11n() which sets up an aggregate descriptor set. This sets up the first/last descriptors as appropriate as well as chaining the subframes together. * Teach the aggregate scheduler function to use ath_tx_form_aggr(), then based on the result of that process, either send a single-packet (which is known to be inside the BAW), or fire off an aggregate frame list to the hardware. * Add some debugging to try and figure out what's going on. As it stands, the TX path halts very quickly. It looks like some completion handling is incorrect, as the TX stops because the BAW tracking becomes out of whack. If I disable this (ie, treat all packets as ACKed and not retry anything), TX is slow (on the order of a few megabits/sec) but the hardware doesn't lock up; so it's likely the descriptor fiddling is functioning mostly correctly. Unfortunately, I don't yet have a clear picture how I'm supposed to setup multi-segment frames inside an aggregate. As mentioned above, Linux/reference code both seem to assume an aggregate subframe fits in a whole skb. (Yes, the receive-side does indeed indicate the frames received were A-MPDU frames. No, I haven't even begun to dig deeply into the aggregate setup to see if I've done everything completely correctly. No, don't expect to use this in STA/Hostap mode just yet.) 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 user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.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 Thu Aug 18 08:58:10 2011 (r224964) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h Thu Aug 18 09:18:39 2011 (r224965) @@ -60,6 +60,7 @@ enum { 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_SW_TX_AGGR = 0x20000000, /* aggregate TX */ 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 Thu Aug 18 08:58:10 2011 (r224964) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 18 09:18:39 2011 (r224965) @@ -290,6 +290,9 @@ ath_tx_dmasetup(struct ath_softc *sc, st return 0; } +/* + * Chain together segments+descriptors for a non-11n frame. + */ static void ath_tx_chaindesclist(struct ath_softc *sc, struct ath_buf *bf) { @@ -321,6 +324,127 @@ ath_tx_chaindesclist(struct ath_softc *s } } +/* + * Fill in the descriptor list for a aggregate subframe. + * + * The subframe is returned with the ds_link field in the last subframe + * pointing to 0. + */ +static void +ath_tx_chaindesclist_subframe(struct ath_softc *sc, struct ath_buf *bf) +{ + struct ath_hal *ah = sc->sc_ah; + struct ath_desc *ds, *ds0; + int i; + + ds0 = ds = bf->bf_desc; + + /* + * There's no need to call ath_hal_setupfirsttxdesc here; + * That's only going to occur for the first frame in an aggregate. + */ + for (i = 0; i < bf->bf_nseg; i++, ds++) { + ds->ds_data = bf->bf_segs[i].ds_addr; + if (i == bf->bf_nseg - 1) + ds->ds_link = 0; + else + ds->ds_link = bf->bf_daddr + sizeof(*ds) * (i + 1); + + /* + * This performs the setup for an aggregate frame. + * This includes enabling the aggregate flags if needed. + */ + ath_hal_chaintxdesc(ah, ds, + bf->bf_state.bfs_pktlen, + bf->bf_state.bfs_hdrlen, + HAL_PKT_TYPE_AMPDU, /* forces aggregate bits to be set */ + bf->bf_state.bfs_keyix, + 0, /* cipher, calculated from keyix */ + bf->bf_state.bfs_ndelim, + bf->bf_segs[i].ds_len, /* segment length */ + i == 0, /* first segment */ + i == bf->bf_nseg - 1 /* last segment */ + ); + + DPRINTF(sc, ATH_DEBUG_XMIT, + "%s: %d: %08x %08x %08x %08x %08x %08x\n", + __func__, i, ds->ds_link, ds->ds_data, + ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1]); + bf->bf_lastds = ds; + } +} + +/* + * Setup segments+descriptors for an 11n aggregate. + * bf_first is the first buffer in the aggregate. + * The descriptor list must already been linked together using + * bf->bf_next. + */ +static void +ath_tx_setds_11n(struct ath_softc *sc, struct ath_buf *bf_first) +{ + struct ath_buf *bf, *bf_prev = NULL; + + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: nframes=%d, al=%d\n", + __func__, bf_first->bf_state.bfs_nframes, + bf_first->bf_state.bfs_al); + + /* + * Setup first descriptor of first frame. + * The sub-frame specific stuff is done + * later. + */ + ath_hal_setupfirsttxdesc(sc->sc_ah, + bf_first->bf_desc, + bf_first->bf_state.bfs_al, + bf_first->bf_state.bfs_flags, + bf_first->bf_state.bfs_txpower, + bf_first->bf_state.bfs_txrate0, + bf_first->bf_state.bfs_try0, + bf_first->bf_state.bfs_txantenna, + bf_first->bf_state.bfs_ctsrate, + bf_first->bf_state.bfs_ctsduration); + + /* + * Setup all descriptors of all subframes. + */ + bf = bf_first; + while (bf != NULL) { + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, + "%s: bf=%p, nseg=%d, pktlen=%d\n", + __func__, bf, bf->bf_nseg, bf->bf_state.bfs_pktlen); + + /* Sub-frame setup */ + ath_tx_chaindesclist_subframe(sc, bf); + + /* + * Link the last descriptor of the previous frame + * to the beginning descriptor of this frame. + */ + if (bf_prev != NULL) + bf_prev->bf_lastds->ds_link = bf->bf_daddr; + + /* Save a copy so we can link the next descriptor in */ + bf_prev = bf; + bf = bf->bf_next; + } + + /* + * Setup the last descriptor in the list. + * bf_prev points to the last; bf is NULL here. + */ + ath_hal_setuplasttxdesc(sc->sc_ah, bf_prev->bf_desc, bf_first->bf_desc); + + /* + * Set the first descriptor bf_lastds field to point to + * the last descriptor in the last subframe, that's where + * the status update will occur. + */ + bf_first->bf_lastds = bf_prev->bf_lastds; + + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: end\n", __func__); +} + static void ath_tx_handoff_mcast(struct ath_softc *sc, struct ath_txq *txq, struct ath_buf *bf) @@ -342,7 +466,7 @@ ath_tx_handoff_mcast(struct ath_softc *s *txq->axq_link = bf->bf_daddr; } ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); - txq->axq_link = &bf->bf_desc[bf->bf_nseg - 1].ds_link; + txq->axq_link = &bf->bf_lastds->ds_link; } @@ -442,7 +566,7 @@ ath_tx_handoff_hw(struct ath_softc *sc, (caddr_t)bf->bf_daddr, bf->bf_desc, txq->axq_depth); } #endif /* IEEE80211_SUPPORT_TDMA */ - txq->axq_link = &bf->bf_desc[bf->bf_nseg - 1].ds_link; + txq->axq_link = &bf->bf_lastds->ds_link; ath_hal_txstart(ah, txq->axq_qnum); } } @@ -606,6 +730,10 @@ ath_tx_setds(struct ath_softc *sc, struc , bf->bf_state.bfs_ctsrate /* rts/cts rate */ , bf->bf_state.bfs_ctsduration /* rts/cts duration */ ); + + /* + * This will be overriden when the descriptor chain is written. + */ bf->bf_lastds = ds; /* XXX TODO: Setup descriptor chain */ @@ -1792,16 +1920,6 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_aggr = 0; bf->bf_state.bfs_aggrburst = 0; - /* - * Program first and chain the descriptors together. - * - * These fields (along with the DMA map setup) are needed - * by the aggregate forming code, which only overrides - * the rate control setup and the aggregation fields. - */ - ath_tx_setds(sc, bf); - ath_tx_chaindesclist(sc, bf); - /* Queue frame to the tail of the software queue */ ATH_TXQ_LOCK(atid); ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); @@ -2283,6 +2401,7 @@ ath_tx_retry_subframe(struct ath_softc * } ath_tx_set_retry(sc, bf); + bf->bf_next = NULL; /* Just to make sure */ STAILQ_INSERT_TAIL(bf_q, bf, bf_list); return 0; @@ -2317,6 +2436,7 @@ ath_tx_comp_aggr_error(struct ath_softc /* Update rate control module about aggregation */ /* XXX todo */ +#if 0 /* * send bar if we dropped any frames */ @@ -2335,6 +2455,7 @@ ath_tx_comp_aggr_error(struct ath_softc __func__, tid->tid); } } +#endif /* Prepend all frames to the beginning of the queue */ ATH_TXQ_LOCK(tid); @@ -2402,10 +2523,12 @@ ath_tx_aggr_comp_aggr(struct ath_softc * int ba_index; int drops = 0; + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called\n", __func__); + /* * Punt cleanup to the relevant function, not our problem now */ - if (atid->cleanup_inprogress) { + if (0 && atid->cleanup_inprogress) { ath_tx_comp_cleanup_aggr(sc, bf_first); return; } @@ -2413,7 +2536,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * /* * handle errors first */ - if (ts->ts_status & HAL_TXERR_XRETRY) { + if (0 && ts->ts_status & HAL_TXERR_XRETRY) { ath_tx_comp_aggr_error(sc, bf_first, atid); return; } @@ -2432,6 +2555,10 @@ ath_tx_aggr_comp_aggr(struct ath_softc * ba[0] = ts->ts_ba_low; ba[1] = ts->ts_ba_high; + device_printf(sc->sc_dev, + "%s: txa_start=%d, tx_ok=%d, isaggr=%d, seq_st=%d, hasba=%d, ba=%.8x, %.8x\n", + __func__, tap->txa_start, tx_ok, isaggr, seq_st, hasba, ba[0], ba[1]); + /* Occasionally, the MAC sends a tx status for the wrong TID. */ if (tid != ts->ts_tid) { device_printf(sc->sc_dev, "%s: tid %d != hw tid %d\n", @@ -2449,10 +2576,17 @@ ath_tx_aggr_comp_aggr(struct ath_softc * bf = bf_first; while (bf) { + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: checking bf=%p seqno=%d\n", + __func__, bf, SEQNO(bf->bf_state.bfs_seqno)); + ba_index = ATH_BA_INDEX(seq_st, SEQNO(bf->bf_state.bfs_seqno)); bf_next = bf->bf_next; + /* + * For now, ACK all packets + */ if (tx_ok && ATH_BA_ISSET(ba, ba_index)) { + //if (1) { ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); ath_tx_default_comp(sc, bf, 0); @@ -2465,6 +2599,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * /* update rate control module about aggregate status */ /* XXX TODO */ +#if 0 /* * send bar if we dropped any frames */ @@ -2483,6 +2618,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * __func__, tid); } } +#endif /* Prepend all frames to the beginning of the queue */ ATH_TXQ_LOCK(atid); @@ -2491,6 +2627,9 @@ ath_tx_aggr_comp_aggr(struct ath_softc * STAILQ_REMOVE_HEAD(&bf_q, bf_list); } ATH_TXQ_UNLOCK(atid); + + device_printf(sc->sc_dev, "%s: finished; txa_start now %d\n", + __func__, tap->txa_start); } /* @@ -2566,6 +2705,8 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft struct ath_tid *atid = &an->an_tid[tid]; struct ieee80211_tx_ampdu *tap; struct ieee80211_node *ni = &an->an_node; + ATH_AGGR_STATUS status; + ath_bufhead bf_q; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid); @@ -2576,6 +2717,8 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft __func__); for (;;) { + status = ATH_AGGR_DONE; + ATH_TXQ_LOCK(atid); /* @@ -2589,70 +2732,119 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft if (atid->paused) break; - bf = STAILQ_FIRST(&atid->axq_q); + bf = STAILQ_FIRST(&atid->axq_q); if (bf == NULL) { ATH_TXQ_UNLOCK(atid); 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); - if (sc->sc_ac2q[TID_TO_WME_AC(tid)] != bf->bf_state.bfs_txq) - device_printf(sc->sc_dev, "%s: TXQ: tid=%d, ac=%d, bf tid=%d\n", - __func__, tid, atid->ac, bf->bf_state.bfs_tid); - - /* 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, - "%s: seq %d outside of %d/%d; waiting\n", - __func__, SEQNO(bf->bf_state.bfs_seqno), - tap->txa_start, tap->txa_wnd); + /* + * If the packet doesn't fall within the BAW (eg a NULL + * data frame), schedule it directly; continue. + */ + if (! bf->bf_state.bfs_dobaw) { + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: non-baw packet\n", + __func__); + ATH_TXQ_REMOVE_HEAD(atid, bf_list); ATH_TXQ_UNLOCK(atid); - break; + bf->bf_state.bfs_aggr = 0; + /* Ensure the last descriptor link is 0 */ + bf->bf_lastds->ds_link = 0; + ath_tx_setds(sc, bf); + ath_tx_chaindesclist(sc, bf); + ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); + ath_tx_set_ratectrl(sc, ni, bf); + + /* Queue the packet; continue */ + goto queuepkt; } + ATH_TXQ_UNLOCK(atid); + + /* Don't lock the TID - ath_tx_form_aggr will lock as needed */ + STAILQ_INIT(&bf_q); + status = ath_tx_form_aggr(sc, an, atid, &bf_q); + + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: ath_tx_form_aggr() status=%d\n", __func__, status); /* - * XXX If the seqno is out of BAW, then we should pause this TID - * XXX until a completion for this TID allows the BAW to be advanced. - * XXX Otherwise it's possible that we'll simply keep getting called - * XXX for this node/TID until some TX completion has occured - * XXX and progress can be made. + * No frames to be picked up - out of BAW */ + if (STAILQ_EMPTY(&bf_q)) + break; - /* We've committed to sending it, so remove it from the list */ - ATH_TXQ_REMOVE_HEAD(atid, bf_list); - ATH_TXQ_UNLOCK(atid); + /* + * This assumes that the descriptor list in the ath_bufhead + * are already linked together via bf_next pointers. + */ + bf = STAILQ_FIRST(&bf_q); - /* Don't add packets to the BAW that don't contribute to it */ - if (bf->bf_state.bfs_dobaw) - ath_tx_addto_baw(sc, an, atid, bf); + /* + * If it's the only frame send as non-aggregate + * assume that ath_tx_form_aggr() has checked + * whether it's in the BAW and added it appropriately. + */ + if (bf->bf_state.bfs_nframes == 1) { + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: single-frame aggregate\n", __func__); + bf->bf_state.bfs_aggr = 0; + /* Ensure the last descriptor link is 0 */ + bf->bf_lastds->ds_link = 0; + ath_tx_setds(sc, bf); + ath_tx_chaindesclist(sc, bf); + ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); + ath_tx_set_ratectrl(sc, ni, bf); + } else { + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: multi-frame aggregate: %d frames, length %d\n", + __func__, bf->bf_state.bfs_nframes, + bf->bf_state.bfs_al); + bf->bf_state.bfs_aggr = 1; + + /* Set rate 1, 2, 3 to 0 for aggregate frames */ + bf->bf_state.bfs_rc[1].rix = + bf->bf_state.bfs_rc[2].rix = + bf->bf_state.bfs_rc[3].rix = 0; + bf->bf_state.bfs_rc[1].tries = + bf->bf_state.bfs_rc[2].tries = + bf->bf_state.bfs_rc[3].tries = 0; - txq = bf->bf_state.bfs_txq; + /* + * Setup the relevant descriptor fields + * for aggregation. The first descriptor + * already points to the rest in the chain. + */ + ath_tx_setds_11n(sc, bf); - /* Sanity check! */ - if (tid != bf->bf_state.bfs_tid) { - device_printf(sc->sc_dev, "%s: bfs_tid %d !=" - " tid %d\n", - __func__, bf->bf_state.bfs_tid, tid); + /* + * setup first desc with rate and aggr info + */ + ath_tx_set_ratectrl(sc, ni, bf); } + queuepkt: + txq = bf->bf_state.bfs_txq; - /* Set completion handler */ + /* Set completion handler, multi-frame aggregate or not */ 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__); - /* Program rate control */ - ath_tx_set_ratectrl(sc, ni, bf); + 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 */ + /* Punt to txq */ ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); ATH_TXQ_UNLOCK(txq); + + /* + * Break out if ath_tx_form_aggr() indicated + * there can't be any further progress (eg BAW is full.) + * Checking for an empty txq is done above. + * + * Later on, enforce ATH_AGGR_MIN_QDEPTH to try and + * keep aggregation flowing. + */ + if (status == ATH_AGGR_BAW_CLOSED) + break; } } @@ -2708,7 +2900,9 @@ ath_tx_tid_hw_queue_norm(struct ath_soft /* Normal completion handler */ bf->bf_comp = ath_tx_normal_comp; - /* Program rate control*/ + /* Program descriptors + rate control */ + ath_tx_setds(sc, bf); + ath_tx_chaindesclist(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); /* Punt to hardware or software txq */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Thu Aug 18 08:58:10 2011 (r224964) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Thu Aug 18 09:18:39 2011 (r224965) @@ -350,7 +350,7 @@ ath_tx_form_aggr(struct ath_softc *sc, s h_baw = tap->txa_wnd / 2; /* Calculate aggregation limit */ - aggr_limit = 8192; /* XXX just for now, for testing */ + aggr_limit = 49152; /* XXX just for now, for testing */ for (;;) { ATH_TXQ_LOCK(tid); @@ -363,6 +363,9 @@ ath_tx_form_aggr(struct ath_softc *sc, s break; } + /* Set this early just so things don't get confused */ + bf->bf_next = NULL; + /* * Don't unlock the tid lock until we're sure we are going * to queue this frame. @@ -455,18 +458,12 @@ ath_tx_form_aggr(struct ath_softc *sc, s bpad = PADBYTES(al_delta) + (bf->bf_state.bfs_ndelim << 2); /* - * link current buffer to the aggregate + * Chain the buffers together */ - if (bf_prev) { + if (bf_prev) bf_prev->bf_next = bf; - bf_prev->bf_desc->ds_link = bf->bf_daddr; - } bf_prev = bf; - /* Set aggregate flags */ - ath_hal_set11naggrmiddle(sc->sc_ah, bf->bf_desc, - bf->bf_state.bfs_ndelim); - #if 0 /* * terminate aggregation on a small packet boundary From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 13:00:42 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 7DF00106566C; Thu, 18 Aug 2011 13:00:42 +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 558BB8FC0C; Thu, 18 Aug 2011 13:00:42 +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 p7ID0gKR058080; Thu, 18 Aug 2011 13:00:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7ID0gpq058078; Thu, 18 Aug 2011 13:00:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108181300.p7ID0gpq058078@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 13:00:42 +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: r224966 - 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, 18 Aug 2011 13:00:42 -0000 Author: adrian Date: Thu Aug 18 13:00:41 2011 New Revision: 224966 URL: http://svn.freebsd.org/changeset/base/224966 Log: Fix the order of shifting items around the buf lists - it has to be removed from the list first before added to another. Doing it in the reverse order just ends up getting stuck in an infinite loop. Fix some debugging whilst I'm at it. 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 18 09:18:39 2011 (r224965) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 18 13:00:41 2011 (r224966) @@ -2458,10 +2458,15 @@ ath_tx_comp_aggr_error(struct ath_softc #endif /* Prepend all frames to the beginning of the queue */ + /* + * XXX for now, these are done in reverse order. + * XXX I'll have to convert this into a TAILQ, so it can + * XXX added to by walking in the reverse order. + */ ATH_TXQ_LOCK(tid); while ((bf = STAILQ_FIRST(&bf_q)) != NULL) { - ATH_TXQ_INSERT_HEAD(tid, bf, bf_list); STAILQ_REMOVE_HEAD(&bf_q, bf_list); + ATH_TXQ_INSERT_HEAD(tid, bf, bf_list); } ATH_TXQ_UNLOCK(tid); } @@ -2555,7 +2560,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * ba[0] = ts->ts_ba_low; ba[1] = ts->ts_ba_high; - device_printf(sc->sc_dev, + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: txa_start=%d, tx_ok=%d, isaggr=%d, seq_st=%d, hasba=%d, ba=%.8x, %.8x\n", __func__, tap->txa_start, tx_ok, isaggr, seq_st, hasba, ba[0], ba[1]); @@ -2621,15 +2626,20 @@ ath_tx_aggr_comp_aggr(struct ath_softc * #endif /* Prepend all frames to the beginning of the queue */ + /* + * XXX for now, these are done in reverse order. + * XXX I'll have to convert this into a TAILQ, so it can + * XXX added to by walking in the reverse order. + */ ATH_TXQ_LOCK(atid); while ((bf = STAILQ_FIRST(&bf_q)) != NULL) { - ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); STAILQ_REMOVE_HEAD(&bf_q, bf_list); + ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); } ATH_TXQ_UNLOCK(atid); - device_printf(sc->sc_dev, "%s: finished; txa_start now %d\n", - __func__, tap->txa_start); + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, + "%s: finished; txa_start now %d\n", __func__, tap->txa_start); } /* From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 14:11:03 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 9980B106566B; Thu, 18 Aug 2011 14:11:03 +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 7045A8FC12; Thu, 18 Aug 2011 14:11:03 +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 p7IEB3sA060265; Thu, 18 Aug 2011 14:11:03 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IEB3Zg060263; Thu, 18 Aug 2011 14:11:03 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181411.p7IEB3Zg060263@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 14:11:03 +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: r224968 - 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: Thu, 18 Aug 2011 14:11:03 -0000 Author: gabor Date: Thu Aug 18 14:11:03 2011 New Revision: 224968 URL: http://svn.freebsd.org/changeset/base/224968 Log: - Properly pass pattern length to underlying functions 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 Thu Aug 18 13:33:34 2011 (r224967) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Aug 18 14:11:03 2011 (r224968) @@ -34,7 +34,7 @@ #include "tre-internal.h" #include "xmalloc.h" -/* XXX: clean up */ +/* XXX: avoid duplication */ #define CONV_PAT \ int ret; \ tre_char_t *wregex; \ @@ -43,6 +43,17 @@ wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); \ if (wregex == NULL) \ return REG_ESPACE; \ + \ + if (TRE_MB_CUR_MAX == 1) \ + { \ + unsigned int i; \ + const unsigned char *str = (const unsigned char *)regex; \ + tre_char_t *wstr = wregex; \ + \ + for (i = 0; i < n; i++) \ + *(wstr++) = *(str++); \ + wlen = n; \ + } \ else \ { \ int consumed; \ @@ -87,7 +98,7 @@ tre_fixncomp(fastmatch_t *preg, const ch { CONV_PAT; - ret = tre_compile_literal(preg, wregex, n, cflags); + ret = tre_compile_literal(preg, wregex, wlen, cflags); xfree(wregex); return ret; @@ -99,8 +110,8 @@ tre_fastncomp(fastmatch_t *preg, const c CONV_PAT; ret = (cflags & REG_LITERAL) ? - tre_compile_literal(preg, wregex, n, cflags) : - tre_compile_fast(preg, wregex, n, cflags); + tre_compile_literal(preg, wregex, wlen, cflags) : + tre_compile_fast(preg, wregex, wlen, cflags); xfree(wregex); return ret; @@ -110,13 +121,13 @@ tre_fastncomp(fastmatch_t *preg, const c int tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags) { - return tre_fixncomp(preg, regex, 0, cflags); + return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } int tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags) { - return tre_fastncomp(preg, regex, 0, cflags); + return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } int @@ -136,13 +147,13 @@ tre_fastwncomp(fastmatch_t *preg, const int tre_fixwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags) { - return tre_fixwncomp(preg, regex, 0, cflags); + return tre_fixwncomp(preg, regex, regex ? tre_strlen(regex) : 0, cflags); } int tre_fastwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags) { - return tre_fastwncomp(preg, regex, 0, cflags); + return tre_fastwncomp(preg, regex, regex ? tre_strlen(regex) : 0, cflags); } void From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 15:12:40 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 3BD5A1065670; Thu, 18 Aug 2011 15:12:40 +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 2BEF68FC0A; Thu, 18 Aug 2011 15:12:40 +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 p7IFCeB0062326; Thu, 18 Aug 2011 15:12:40 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IFCefm062324; Thu, 18 Aug 2011 15:12:40 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181512.p7IFCefm062324@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 15:12:40 +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: r224969 - 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: Thu, 18 Aug 2011 15:12:40 -0000 Author: gabor Date: Thu Aug 18 15:12:39 2011 New Revision: 224969 URL: http://svn.freebsd.org/changeset/base/224969 Log: - Style Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Thu Aug 18 14:11:03 2011 (r224968) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Thu Aug 18 15:12:39 2011 (r224969) @@ -237,7 +237,6 @@ tre_match(const tre_tnfa_t *tnfa, const return ret; \ } - int tre_regnexec(const regex_t *preg, const char *str, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 15:13:09 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 1AC2A106566C; Thu, 18 Aug 2011 15:13:09 +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 E524A8FC08; Thu, 18 Aug 2011 15:13:08 +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 p7IFD8Bs062379; Thu, 18 Aug 2011 15:13:08 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IFD8OU062377; Thu, 18 Aug 2011 15:13:08 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181513.p7IFD8OU062377@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 15:13:08 +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: r224970 - 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: Thu, 18 Aug 2011 15:13:09 -0000 Author: gabor Date: Thu Aug 18 15:13:08 2011 New Revision: 224970 URL: http://svn.freebsd.org/changeset/base/224970 Log: - Add REG_STARTEND 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 Thu Aug 18 15:12:39 2011 (r224969) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Aug 18 15:13:08 2011 (r224970) @@ -162,14 +162,39 @@ tre_fastfree(fastmatch_t *preg) tre_free_fast(preg); } +/* XXX: avoid duplication */ +#define ADJUST_OFFSETS \ + { \ + size_t slen = (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so); \ + size_t offset = pmatch[0].rm_so; \ + int ret; \ + \ + if ((len != (unsigned)-1) && (pmatch[0].rm_eo > len)) \ + return REG_NOMATCH; \ + if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \ + return REG_NOMATCH; \ + ret = tre_match_fast(preg, &string[offset], slen, type, nmatch, \ + pmatch, eflags); \ + for (unsigned i = 0; (i == 0) || (!(eflags & REG_NOSUB) && \ + (i < nmatch)); i++) \ + { \ + pmatch[i].rm_so += offset; \ + pmatch[i].rm_eo += offset; \ + } \ + return ret; \ + } + int -tre_fastnexec(const fastmatch_t *preg, const char *string, size_t n, +tre_fastnexec(const fastmatch_t *preg, const char *string, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) { tre_str_type_t type = (TRE_MB_CUR_MAX == 1) ? STR_BYTE : STR_MBS; - return tre_match_fast(preg, string, n, type, nmatch, - pmatch, eflags); + if (eflags & REG_STARTEND) + ADJUST_OFFSETS + else + return tre_match_fast(preg, string, len, type, nmatch, + pmatch, eflags); } int @@ -180,11 +205,16 @@ tre_fastexec(const fastmatch_t *preg, co } int -tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t n, +tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) { - return tre_match_fast(preg, string, n, STR_WIDE, nmatch, - pmatch, eflags); + tre_str_type_t type = STR_WIDE; + + if (eflags & REG_STARTEND) + ADJUST_OFFSETS + else + return tre_match_fast(preg, string, len, type, nmatch, + pmatch, eflags); } int From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 15:31: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 6D53A106564A; Thu, 18 Aug 2011 15:31: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 43F1D8FC13; Thu, 18 Aug 2011 15:31: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 p7IFVWsJ062955; Thu, 18 Aug 2011 15:31:32 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IFVWud062952; Thu, 18 Aug 2011 15:31:32 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181531.p7IFVWud062952@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 15:31: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: r224971 - 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: Thu, 18 Aug 2011 15:31:32 -0000 Author: gabor Date: Thu Aug 18 15:31:31 2011 New Revision: 224971 URL: http://svn.freebsd.org/changeset/base/224971 Log: - Support REG_PEND in the fast matching functions - Fall back to strlen() when the end pointer is invalid Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/regcomp.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Aug 18 15:13:08 2011 (r224970) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Aug 18 15:31:31 2011 (r224971) @@ -121,13 +121,29 @@ tre_fastncomp(fastmatch_t *preg, const c int tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags) { - return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags); + if (cflags & REG_PEND) + { + len = (preg->re_endp >= regex) + ? preg->re_endp - regex + : 0; + return tre_fixncomp(preg, regex, len ? strlen(regex) : 0, cflags); + } + else + return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } int tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags) { - return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags); + if (cflags & REG_PEND) + { + len = (preg->re_endp >= regex) + ? preg->re_endp - regex + : 0; + return tre_fastncomp(preg, regex, len ? strlen(regex) : 0, cflags); + } + else + return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } int Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regcomp.c Thu Aug 18 15:13:08 2011 (r224970) +++ user/gabor/tre-integration/contrib/tre/lib/regcomp.c Thu Aug 18 15:31:31 2011 (r224971) @@ -118,7 +118,7 @@ tre_regcomp(regex_t *preg, const char *r len = (preg->re_endp >= regex) ? preg->re_endp - regex : 0; - return tre_regncomp(preg, regex, len, cflags); + return tre_regncomp(preg, regex, len ? strlen(regex) : 0, cflags); } else return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags); From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 16:19:26 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 A392C106566B; Thu, 18 Aug 2011 16:19:26 +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 5A34F8FC1D; Thu, 18 Aug 2011 16:19:26 +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 p7IGJQw5064508; Thu, 18 Aug 2011 16:19:26 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IGJQWb064503; Thu, 18 Aug 2011 16:19:26 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108181619.p7IGJQWb064503@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 16:19:26 +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: r224974 - 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, 18 Aug 2011 16:19:26 -0000 Author: adrian Date: Thu Aug 18 16:19:26 2011 New Revision: 224974 URL: http://svn.freebsd.org/changeset/base/224974 Log: As much as I've been wanting to avoid this, convert STAILQ->TAILQ. There's at least one instance where I need to traverse the list in reverse order, and that's impossible with a STAILQ. It also makes TID schedule/unschedule O(1). Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.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 Thu Aug 18 16:07:41 2011 (r224973) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 18 16:19:26 2011 (r224974) @@ -977,7 +977,7 @@ ath_vap_create(struct ieee80211com *ic, /* * Check that a beacon buffer is available; the code below assumes it. */ - if (needbeacon & STAILQ_EMPTY(&sc->sc_bbuf)) { + if (needbeacon & TAILQ_EMPTY(&sc->sc_bbuf)) { device_printf(sc->sc_dev, "no beacon buffer available\n"); goto bad; } @@ -1039,8 +1039,8 @@ ath_vap_create(struct ieee80211com *ic, * multicast frames. We know a beacon buffer is * available because we checked above. */ - avp->av_bcbuf = STAILQ_FIRST(&sc->sc_bbuf); - STAILQ_REMOVE_HEAD(&sc->sc_bbuf, bf_list); + avp->av_bcbuf = TAILQ_FIRST(&sc->sc_bbuf); + TAILQ_REMOVE(&sc->sc_bbuf, avp->av_bcbuf, bf_list); if (opmode != IEEE80211_M_IBSS || !sc->sc_hasveol) { /* * Assign the vap to a beacon xmit slot. As above @@ -1845,14 +1845,14 @@ _ath_getbuf_locked(struct ath_softc *sc) ATH_TXBUF_LOCK_ASSERT(sc); - bf = STAILQ_FIRST(&sc->sc_txbuf); + bf = TAILQ_FIRST(&sc->sc_txbuf); if (bf != NULL && (bf->bf_flags & ATH_BUF_BUSY) == 0) - STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list); + TAILQ_REMOVE(&sc->sc_txbuf, bf, bf_list); else bf = NULL; if (bf == NULL) { DPRINTF(sc, ATH_DEBUG_XMIT, "%s: %s\n", __func__, - STAILQ_FIRST(&sc->sc_txbuf) == NULL ? + TAILQ_FIRST(&sc->sc_txbuf) == NULL ? "out of xmit buffers" : "xmit buffer busy"); } bf->bf_next = NULL; /* XXX just to be sure */ @@ -1899,7 +1899,7 @@ ath_start(struct ifnet *ifp) IFQ_DEQUEUE(&ifp->if_snd, m); if (m == NULL) { ATH_TXBUF_LOCK(sc); - STAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); + TAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); ATH_TXBUF_UNLOCK(sc); break; } @@ -1910,7 +1910,7 @@ ath_start(struct ifnet *ifp) * buffers to send all the fragments so all * go out or none... */ - STAILQ_INIT(&frags); + TAILQ_INIT(&frags); if ((m->m_flags & M_FRAG) && !ath_txfrag_setup(sc, &frags, m, ni)) { DPRINTF(sc, ATH_DEBUG_XMIT, @@ -1942,7 +1942,7 @@ ath_start(struct ifnet *ifp) bf->bf_m = NULL; bf->bf_node = NULL; ATH_TXBUF_LOCK(sc); - STAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); + TAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); ath_txfrag_cleanup(sc, &frags, ni); ATH_TXBUF_UNLOCK(sc); if (ni != NULL) @@ -1963,9 +1963,9 @@ ath_start(struct ifnet *ifp) goto reclaim; } m = next; - bf = STAILQ_FIRST(&frags); + bf = TAILQ_FIRST(&frags); KASSERT(bf != NULL, ("no buf for txfrag")); - STAILQ_REMOVE_HEAD(&frags, bf_list); + TAILQ_REMOVE(&frags, bf, bf_list); goto nextfrag; } @@ -2468,7 +2468,7 @@ ath_beacon_update(struct ieee80211vap *v static void ath_txqmove(struct ath_txq *dst, struct ath_txq *src) { - STAILQ_CONCAT(&dst->axq_q, &src->axq_q); + TAILQ_CONCAT(&dst->axq_q, &src->axq_q, bf_list); dst->axq_link = src->axq_link; src->axq_link = NULL; dst->axq_depth += src->axq_depth; @@ -2663,7 +2663,7 @@ ath_beacon_generate(struct ath_softc *sc * Move frames from the s/w mcast q to the h/w cab q. * XXX MORE_DATA bit */ - bfm = STAILQ_FIRST(&avp->av_mcastq.axq_q); + bfm = TAILQ_FIRST(&avp->av_mcastq.axq_q); if (cabq->axq_link != NULL) { *cabq->axq_link = bfm->bf_daddr; } else @@ -2752,7 +2752,7 @@ ath_beacon_return(struct ath_softc *sc, ieee80211_free_node(bf->bf_node); bf->bf_node = NULL; } - STAILQ_INSERT_TAIL(&sc->sc_bbuf, bf, bf_list); + TAILQ_INSERT_TAIL(&sc->sc_bbuf, bf, bf_list); } /* @@ -2763,7 +2763,7 @@ ath_beacon_free(struct ath_softc *sc) { struct ath_buf *bf; - STAILQ_FOREACH(bf, &sc->sc_bbuf, bf_list) { + TAILQ_FOREACH(bf, &sc->sc_bbuf, bf_list) { if (bf->bf_m != NULL) { bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); m_freem(bf->bf_m); @@ -3082,7 +3082,7 @@ ath_descdma_setup(struct ath_softc *sc, } dd->dd_bufptr = bf; - STAILQ_INIT(head); + TAILQ_INIT(head); for (i = 0; i < nbuf; i++, bf++, ds += (ndesc * desc_len)) { bf->bf_desc = (struct ath_desc *) ds; bf->bf_daddr = DS2PHYS(dd, ds); @@ -3109,7 +3109,7 @@ ath_descdma_setup(struct ath_softc *sc, return error; } bf->bf_lastds = bf->bf_desc; /* Just an initial value */ - STAILQ_INSERT_TAIL(head, bf, bf_list); + TAILQ_INSERT_TAIL(head, bf, bf_list); } return 0; fail3: @@ -3138,7 +3138,7 @@ ath_descdma_cleanup(struct ath_softc *sc bus_dmamap_destroy(dd->dd_dmat, dd->dd_dmamap); bus_dma_tag_destroy(dd->dd_dmat); - STAILQ_FOREACH(bf, head, bf_list) { + TAILQ_FOREACH(bf, head, bf_list) { if (bf->bf_m) { m_freem(bf->bf_m); bf->bf_m = NULL; @@ -3157,7 +3157,7 @@ ath_descdma_cleanup(struct ath_softc *sc } } - STAILQ_INIT(head); + TAILQ_INIT(head); free(dd->dd_bufptr, M_ATHDEV); memset(dd, 0, sizeof(*dd)); } @@ -3511,7 +3511,7 @@ ath_rx_proc(void *arg, int npending) sc->sc_stats.ast_rx_noise = nf; tsf = ath_hal_gettsf64(ah); do { - bf = STAILQ_FIRST(&sc->sc_rxbuf); + bf = TAILQ_FIRST(&sc->sc_rxbuf); if (sc->sc_rxslink && bf == NULL) { /* NB: shouldn't happen */ if_printf(ifp, "%s: no buffer!\n", __func__); break; @@ -3531,7 +3531,7 @@ ath_rx_proc(void *arg, int npending) */ /* XXX make debug msg */ if_printf(ifp, "%s: no mbuf!\n", __func__); - STAILQ_REMOVE_HEAD(&sc->sc_rxbuf, bf_list); + TAILQ_REMOVE(&sc->sc_rxbuf, bf, bf_list); goto rx_next; } ds = bf->bf_desc; @@ -3561,7 +3561,7 @@ ath_rx_proc(void *arg, int npending) #endif if (status == HAL_EINPROGRESS) break; - STAILQ_REMOVE_HEAD(&sc->sc_rxbuf, bf_list); + TAILQ_REMOVE(&sc->sc_rxbuf, bf, bf_list); /* These aren't specifically errors */ if (rs->rs_flags & HAL_RX_GI) @@ -3828,7 +3828,7 @@ rx_accept: ath_led_event(sc, 0); } rx_next: - STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); + TAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); } while (ath_rxbuf_init(sc, bf) == 0); /* rx signal state monitoring */ @@ -3877,8 +3877,8 @@ ath_txq_init(struct ath_softc *sc, struc txq->axq_depth = 0; txq->axq_intrcnt = 0; txq->axq_link = NULL; - STAILQ_INIT(&txq->axq_q); - STAILQ_INIT(&txq->axq_tidq); + TAILQ_INIT(&txq->axq_q); + TAILQ_INIT(&txq->axq_tidq); ATH_TXQ_LOCK_INIT(sc, txq); } @@ -4188,7 +4188,7 @@ ath_tx_processq(struct ath_softc *sc, st for (;;) { txq->axq_intrcnt = 0; /* reset periodic desc intr count */ ATH_TXQ_LOCK(txq); - bf = STAILQ_FIRST(&txq->axq_q); + bf = TAILQ_FIRST(&txq->axq_q); if (bf == NULL) { ATH_TXQ_UNLOCK(txq); break; @@ -4206,7 +4206,7 @@ ath_tx_processq(struct ath_softc *sc, st ATH_TXQ_UNLOCK(txq); break; } - ATH_TXQ_REMOVE_HEAD(txq, bf_list); + ATH_TXQ_REMOVE(txq, bf, bf_list); #ifdef IEEE80211_SUPPORT_TDMA if (txq->axq_depth > 0) { /* @@ -4434,7 +4434,7 @@ ath_tx_freebuf(struct ath_softc *sc, str bf->bf_flags &= ~ATH_BUF_BUSY; ATH_TXBUF_LOCK(sc); - STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); + TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); ATH_TXBUF_UNLOCK(sc); } @@ -4452,20 +4452,20 @@ ath_tx_draintxq(struct ath_softc *sc, st * we do not need to block ath_tx_proc */ ATH_TXBUF_LOCK(sc); - bf = STAILQ_LAST(&sc->sc_txbuf, ath_buf, bf_list); + bf = TAILQ_LAST(&sc->sc_txbuf, ath_bufhead_s); if (bf != NULL) bf->bf_flags &= ~ATH_BUF_BUSY; ATH_TXBUF_UNLOCK(sc); for (ix = 0;; ix++) { ATH_TXQ_LOCK(txq); - bf = STAILQ_FIRST(&txq->axq_q); + bf = TAILQ_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_REMOVE(txq, bf, bf_list); ATH_TXQ_UNLOCK(txq); #ifdef ATH_DEBUG if (sc->sc_debug & ATH_DEBUG_RESET) { @@ -4530,7 +4530,7 @@ ath_draintxq(struct ath_softc *sc) ath_tx_draintxq(sc, &sc->sc_txq[i]); #ifdef ATH_DEBUG if (sc->sc_debug & ATH_DEBUG_RESET) { - struct ath_buf *bf = STAILQ_FIRST(&sc->sc_bbuf); + struct ath_buf *bf = TAILQ_FIRST(&sc->sc_bbuf); if (bf != NULL && bf->bf_m != NULL) { ath_printtxbuf(sc, bf, sc->sc_bhalq, 0, ath_hal_txprocdesc(ah, bf->bf_desc, @@ -4568,7 +4568,7 @@ ath_stoprecv(struct ath_softc *sc) printf("%s: rx queue %p, link %p\n", __func__, (caddr_t)(uintptr_t) ath_hal_getrxbuf(ah), sc->sc_rxlink); ix = 0; - STAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { + TAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { struct ath_desc *ds = bf->bf_desc; struct ath_rx_status *rs = &bf->bf_status.ds_rxstat; HAL_STATUS status = ath_hal_rxprocdesc(ah, ds, @@ -4598,7 +4598,7 @@ ath_startrecv(struct ath_softc *sc) sc->sc_rxlink = NULL; sc->sc_rxpending = NULL; - STAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { + TAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { int error = ath_rxbuf_init(sc, bf); if (error != 0) { DPRINTF(sc, ATH_DEBUG_RECV, @@ -4608,7 +4608,7 @@ ath_startrecv(struct ath_softc *sc) } } - bf = STAILQ_FIRST(&sc->sc_rxbuf); + bf = TAILQ_FIRST(&sc->sc_rxbuf); ath_hal_putrxbuf(ah, bf->bf_daddr); ath_hal_rxena(ah); /* enable recv descriptors */ ath_mode_init(sc); /* set filters, etc. */ 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 18 16:07:41 2011 (r224973) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 18 16:19:26 2011 (r224974) @@ -181,10 +181,10 @@ ath_txfrag_cleanup(struct ath_softc *sc, ATH_TXBUF_LOCK_ASSERT(sc); - STAILQ_FOREACH_SAFE(bf, frags, bf_list, next) { + TAILQ_FOREACH_SAFE(bf, frags, bf_list, next) { /* NB: bf assumed clean */ - STAILQ_REMOVE_HEAD(frags, bf_list); - STAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); + TAILQ_REMOVE(frags, bf, bf_list); + TAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); ieee80211_node_decref(ni); } } @@ -209,11 +209,11 @@ ath_txfrag_setup(struct ath_softc *sc, a break; } ieee80211_node_incref(ni); - STAILQ_INSERT_TAIL(frags, bf, bf_list); + TAILQ_INSERT_TAIL(frags, bf, bf_list); } ATH_TXBUF_UNLOCK(sc); - return !STAILQ_EMPTY(frags); + return !TAILQ_EMPTY(frags); } /* @@ -453,7 +453,7 @@ ath_tx_handoff_mcast(struct ath_softc *s KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, ("%s: busy status 0x%x", __func__, bf->bf_flags)); if (txq->axq_link != NULL) { - struct ath_buf *last = ATH_TXQ_LAST(txq); + struct ath_buf *last = ATH_TXQ_LAST(txq, axq_q_s); struct ieee80211_frame *wh; /* mark previous frame */ @@ -542,7 +542,7 @@ ath_tx_handoff_hw(struct ath_softc *sc, * is/was empty. */ ath_hal_puttxbuf(ah, txq->axq_qnum, - STAILQ_FIRST(&txq->axq_q)->bf_daddr); + TAILQ_FIRST(&txq->axq_q)->bf_daddr); txq->axq_flags &= ~ATH_TXQ_PUTPENDING; DPRINTF(sc, ATH_DEBUG_TDMA | ATH_DEBUG_XMIT, "%s: Q%u restarted\n", __func__, @@ -1608,7 +1608,7 @@ ath_raw_xmit(struct ieee80211_node *ni, return 0; bad2: ATH_TXBUF_LOCK(sc); - STAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); + TAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); ATH_TXBUF_UNLOCK(sc); bad: ifp->if_oerrors++; @@ -1812,7 +1812,7 @@ ath_tx_tid_sched(struct ath_softc *sc, s atid->sched = 1; - STAILQ_INSERT_TAIL(&txq->axq_tidq, atid, axq_qelem); + TAILQ_INSERT_TAIL(&txq->axq_tidq, atid, axq_qelem); } /* @@ -1833,7 +1833,7 @@ ath_tx_tid_unsched(struct ath_softc *sc, return; atid->sched = 0; - STAILQ_REMOVE(&txq->axq_tidq, atid, ath_tid, axq_qelem); + TAILQ_REMOVE(&txq->axq_tidq, atid, axq_qelem); } /* @@ -1961,7 +1961,7 @@ ath_tx_tid_init(struct ath_softc *sc, st for (i = 0; i < IEEE80211_TID_SIZE; i++) { atid = &an->an_tid[i]; - STAILQ_INIT(&atid->axq_q); + TAILQ_INIT(&atid->axq_q); atid->tid = i; atid->an = an; for (j = 0; j < ATH_TID_MAX_BUFS; j++) @@ -2063,7 +2063,7 @@ ath_tx_tid_free_pkts(struct ath_softc *s /* Walk the queue, free frames */ for (;;) { ATH_TXQ_LOCK(atid); - bf = STAILQ_FIRST(&atid->axq_q); + bf = TAILQ_FIRST(&atid->axq_q); if (bf == NULL) { ATH_TXQ_UNLOCK(atid); break; @@ -2077,7 +2077,7 @@ ath_tx_tid_free_pkts(struct ath_softc *s 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); + ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); ath_tx_freebuf(sc, bf, -1); } @@ -2200,11 +2200,11 @@ ath_tx_cleanup(struct ath_softc *sc, str * + Fix the completion function to be non-aggregate */ ATH_TXQ_LOCK(atid); - bf = STAILQ_FIRST(&atid->axq_q); + bf = TAILQ_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); + bf_next = TAILQ_NEXT(bf, bf_list); + TAILQ_REMOVE(&atid->axq_q, bf, bf_list); atid->axq_depth--; if (bf->bf_state.bfs_dobaw) ath_tx_update_baw(sc, an, atid, @@ -2219,7 +2219,7 @@ ath_tx_cleanup(struct ath_softc *sc, str } /* Give these the default completion handler */ bf->bf_comp = ath_tx_normal_comp; - bf = STAILQ_NEXT(bf, bf_list); + bf = TAILQ_NEXT(bf, bf_list); } ATH_TXQ_UNLOCK(atid); @@ -2403,7 +2403,7 @@ ath_tx_retry_subframe(struct ath_softc * ath_tx_set_retry(sc, bf); bf->bf_next = NULL; /* Just to make sure */ - STAILQ_INSERT_TAIL(bf_q, bf, bf_list); + TAILQ_INSERT_TAIL(bf_q, bf, bf_list); return 0; } @@ -2423,7 +2423,7 @@ ath_tx_comp_aggr_error(struct ath_softc tap = ath_tx_get_tx_tid(an, tid->tid); - STAILQ_INIT(&bf_q); + TAILQ_INIT(&bf_q); /* Retry all subframes */ bf = bf_first; @@ -2458,14 +2458,9 @@ ath_tx_comp_aggr_error(struct ath_softc #endif /* Prepend all frames to the beginning of the queue */ - /* - * XXX for now, these are done in reverse order. - * XXX I'll have to convert this into a TAILQ, so it can - * XXX added to by walking in the reverse order. - */ ATH_TXQ_LOCK(tid); - while ((bf = STAILQ_FIRST(&bf_q)) != NULL) { - STAILQ_REMOVE_HEAD(&bf_q, bf_list); + while ((bf = TAILQ_LAST(&bf_q, ath_bufhead_s)) != NULL) { + TAILQ_REMOVE(&bf_q, bf, bf_list); ATH_TXQ_INSERT_HEAD(tid, bf, bf_list); } ATH_TXQ_UNLOCK(tid); @@ -2546,7 +2541,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * return; } - STAILQ_INIT(&bf_q); + TAILQ_INIT(&bf_q); tap = ath_tx_get_tx_tid(an, tid); /* @@ -2626,14 +2621,9 @@ ath_tx_aggr_comp_aggr(struct ath_softc * #endif /* Prepend all frames to the beginning of the queue */ - /* - * XXX for now, these are done in reverse order. - * XXX I'll have to convert this into a TAILQ, so it can - * XXX added to by walking in the reverse order. - */ ATH_TXQ_LOCK(atid); - while ((bf = STAILQ_FIRST(&bf_q)) != NULL) { - STAILQ_REMOVE_HEAD(&bf_q, bf_list); + while ((bf = TAILQ_LAST(&bf_q, ath_bufhead_s)) != NULL) { + TAILQ_REMOVE(&bf_q, bf, bf_list); ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); } ATH_TXQ_UNLOCK(atid); @@ -2742,7 +2732,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft if (atid->paused) break; - bf = STAILQ_FIRST(&atid->axq_q); + bf = TAILQ_FIRST(&atid->axq_q); if (bf == NULL) { ATH_TXQ_UNLOCK(atid); break; @@ -2755,7 +2745,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft if (! bf->bf_state.bfs_dobaw) { DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: non-baw packet\n", __func__); - ATH_TXQ_REMOVE_HEAD(atid, bf_list); + ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); bf->bf_state.bfs_aggr = 0; /* Ensure the last descriptor link is 0 */ @@ -2771,7 +2761,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft ATH_TXQ_UNLOCK(atid); /* Don't lock the TID - ath_tx_form_aggr will lock as needed */ - STAILQ_INIT(&bf_q); + TAILQ_INIT(&bf_q); status = ath_tx_form_aggr(sc, an, atid, &bf_q); DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, @@ -2780,14 +2770,14 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft /* * No frames to be picked up - out of BAW */ - if (STAILQ_EMPTY(&bf_q)) + if (TAILQ_EMPTY(&bf_q)) break; /* * This assumes that the descriptor list in the ath_bufhead * are already linked together via bf_next pointers. */ - bf = STAILQ_FIRST(&bf_q); + bf = TAILQ_FIRST(&bf_q); /* * If it's the only frame send as non-aggregate @@ -2890,13 +2880,13 @@ ath_tx_tid_hw_queue_norm(struct ath_soft if (atid->paused) break; - bf = STAILQ_FIRST(&atid->axq_q); + bf = TAILQ_FIRST(&atid->axq_q); if (bf == NULL) { ATH_TXQ_UNLOCK(atid); break; } - ATH_TXQ_REMOVE_HEAD(atid, bf_list); + ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); txq = bf->bf_state.bfs_txq; @@ -2939,7 +2929,7 @@ ath_txq_sched(struct ath_softc *sc, stru * or the like. That's a later problem. Just throw * packets at the hardware. */ - STAILQ_FOREACH_SAFE(atid, &txq->axq_tidq, axq_qelem, next) { + TAILQ_FOREACH_SAFE(atid, &txq->axq_tidq, axq_qelem, next) { /* * Suspend paused queues here; they'll be resumed * once the addba completes or times out. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Thu Aug 18 16:07:41 2011 (r224973) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Thu Aug 18 16:19:26 2011 (r224974) @@ -354,7 +354,7 @@ ath_tx_form_aggr(struct ath_softc *sc, s for (;;) { ATH_TXQ_LOCK(tid); - bf = STAILQ_FIRST(&tid->axq_q); + bf = TAILQ_FIRST(&tid->axq_q); if (bf_first == NULL) bf_first = bf; if (bf == NULL) { @@ -432,11 +432,11 @@ ath_tx_form_aggr(struct ath_softc *sc, s /* * this packet is part of an aggregate. */ - ATH_TXQ_REMOVE_HEAD(tid, bf_list); + ATH_TXQ_REMOVE(tid, bf, bf_list); ATH_TXQ_UNLOCK(tid); ath_tx_addto_baw(sc, an, tid, bf); - STAILQ_INSERT_TAIL(bf_q, bf, bf_list); + TAILQ_INSERT_TAIL(bf_q, bf, bf_list); nframes ++; /* Completion handler */ 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 18 16:07:41 2011 (r224973) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Thu Aug 18 16:19:26 2011 (r224974) @@ -91,7 +91,7 @@ struct ath_buf; * Note that TID 16 (WME_NUM_TID+1) is for handling non-QoS frames. */ struct ath_tid { - STAILQ_HEAD(,ath_buf) axq_q; /* pending buffers */ + TAILQ_HEAD(,ath_buf) axq_q; /* pending buffers */ struct mtx axq_lock; /* lock on q and link */ u_int axq_depth; /* SW queue depth */ char axq_name[48]; /* lock name */ @@ -103,7 +103,7 @@ struct ath_tid { * Entry on the ath_txq; when there's traffic * to send */ - STAILQ_ENTRY(ath_tid) axq_qelem; + TAILQ_ENTRY(ath_tid) axq_qelem; int sched; int paused; /* >0 if the TID has been paused */ @@ -170,7 +170,7 @@ struct ath_node { #define ATH_RSSI(x) ATH_EP_RND(x, HAL_RSSI_EP_MULTIPLIER) struct ath_buf { - STAILQ_ENTRY(ath_buf) bf_list; + TAILQ_ENTRY(ath_buf) bf_list; struct ath_buf * bf_next; /* next buffer in the aggregate */ int bf_nseg; uint16_t bf_txflags; /* tx descriptor flags */ @@ -234,7 +234,7 @@ struct ath_buf { struct ath_rc_series bfs_rc[ATH_RC_NUM]; /* non-11n TX series */ } bf_state; }; -typedef STAILQ_HEAD(, ath_buf) ath_bufhead; +typedef TAILQ_HEAD(ath_bufhead_s, ath_buf) ath_bufhead; #define ATH_BUF_BUSY 0x00000002 /* (tx) desc owned by h/w */ @@ -270,12 +270,12 @@ struct ath_txq { u_int axq_depth; /* queue depth (stat only) */ u_int axq_intrcnt; /* interrupt count */ u_int32_t *axq_link; /* link ptr in last TX desc */ - STAILQ_HEAD(, ath_buf) axq_q; /* transmit queue */ + TAILQ_HEAD(axq_q_s, ath_buf) axq_q; /* transmit queue */ struct mtx axq_lock; /* lock on q and link */ char axq_name[12]; /* e.g. "ath0_txq4" */ /* Per-TID traffic queue for software -> hardware TX */ - STAILQ_HEAD(,ath_tid) axq_tidq; + TAILQ_HEAD(,ath_tid) axq_tidq; }; #define ATH_NODE_LOCK(_an) mtx_lock(&(_an)->an_mtx) @@ -294,21 +294,18 @@ struct ath_txq { #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); \ + TAILQ_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); \ + TAILQ_INSERT_TAIL(&(_tq)->axq_q, (_elm), _field); \ (_tq)->axq_depth++; \ } while (0) -#define ATH_TXQ_REMOVE_HEAD(_tq, _field) do { \ - STAILQ_REMOVE_HEAD(&(_tq)->axq_q, _field); \ +#define ATH_TXQ_REMOVE(_tq, _elm, _field) do { \ + TAILQ_REMOVE(&(_tq)->axq_q, _elm, _field); \ (_tq)->axq_depth--; \ } while (0) -/* NB: this does not do the "head empty check" that STAILQ_LAST does */ -#define ATH_TXQ_LAST(_tq) \ - ((struct ath_buf *)(void *) \ - ((char *)((_tq)->axq_q.stqh_last) - __offsetof(struct ath_buf, bf_list))) +#define ATH_TXQ_LAST(_tq, _field) TAILQ_LAST(&(_tq)->axq_q, _field) struct ath_vap { struct ieee80211vap av_vap; /* base class */ From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 16:36:26 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 DEE40106566C; Thu, 18 Aug 2011 16:36:26 +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 B58D78FC13; Thu, 18 Aug 2011 16:36:26 +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 p7IGaQk9065096; Thu, 18 Aug 2011 16:36:26 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IGaQUc065094; Thu, 18 Aug 2011 16:36:26 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108181636.p7IGaQUc065094@svn.freebsd.org> From: Adrian Chadd Date: Thu, 18 Aug 2011 16:36:26 +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: r224975 - 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, 18 Aug 2011 16:36:27 -0000 Author: adrian Date: Thu Aug 18 16:36:26 2011 New Revision: 224975 URL: http://svn.freebsd.org/changeset/base/224975 Log: ath_hal_setupfirsttxdesc() sets the first TX descriptor fields but it doesn't overwrite them. ath_hal_chaintxdesc() initialises the TX descriptor fields. Calling setupfirsttxdesc() -before- chaintxdesc() meant various fields were being overwritten, blanking a bunch of needed fields (such as flags.) This allows TX aggregate DMA to proceed a little further, but things are still pausing due to BAW tracking issues. 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 18 16:19:26 2011 (r224974) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 18 16:36:26 2011 (r224975) @@ -390,22 +390,6 @@ ath_tx_setds_11n(struct ath_softc *sc, s bf_first->bf_state.bfs_al); /* - * Setup first descriptor of first frame. - * The sub-frame specific stuff is done - * later. - */ - ath_hal_setupfirsttxdesc(sc->sc_ah, - bf_first->bf_desc, - bf_first->bf_state.bfs_al, - bf_first->bf_state.bfs_flags, - bf_first->bf_state.bfs_txpower, - bf_first->bf_state.bfs_txrate0, - bf_first->bf_state.bfs_try0, - bf_first->bf_state.bfs_txantenna, - bf_first->bf_state.bfs_ctsrate, - bf_first->bf_state.bfs_ctsduration); - - /* * Setup all descriptors of all subframes. */ bf = bf_first; @@ -430,6 +414,25 @@ ath_tx_setds_11n(struct ath_softc *sc, s } /* + * Setup first descriptor of first frame. + * chaintxdesc() overwrites the descriptor entries; + * setupfirsttxdesc() merges in things. + * Otherwise various fields aren't set correctly (eg flags). + */ + ath_hal_setupfirsttxdesc(sc->sc_ah, + bf_first->bf_desc, + bf_first->bf_state.bfs_al, + bf_first->bf_state.bfs_flags, + bf_first->bf_state.bfs_txpower, + bf_first->bf_state.bfs_txrate0, + bf_first->bf_state.bfs_try0, + bf_first->bf_state.bfs_txantenna, + bf_first->bf_state.bfs_ctsrate, + bf_first->bf_state.bfs_ctsduration); + + + + /* * Setup the last descriptor in the list. * bf_prev points to the last; bf is NULL here. */ @@ -2556,8 +2559,9 @@ ath_tx_aggr_comp_aggr(struct ath_softc * ba[1] = ts->ts_ba_high; DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, - "%s: txa_start=%d, tx_ok=%d, isaggr=%d, seq_st=%d, hasba=%d, ba=%.8x, %.8x\n", - __func__, tap->txa_start, tx_ok, isaggr, seq_st, hasba, ba[0], ba[1]); + "%s: txa_start=%d, tx_ok=%d, status=%.8x, flags=%.8x, isaggr=%d, seq_st=%d, hasba=%d, ba=%.8x, %.8x\n", + __func__, tap->txa_start, tx_ok, ts->ts_status, ts->ts_flags, + isaggr, seq_st, hasba, ba[0], ba[1]); /* Occasionally, the MAC sends a tx status for the wrong TID. */ if (tid != ts->ts_tid) { From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 16:44:42 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 835E6106564A; Thu, 18 Aug 2011 16:44:42 +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 5AD4F8FC0C; Thu, 18 Aug 2011 16:44:42 +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 p7IGigqf065383; Thu, 18 Aug 2011 16:44:42 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IGigaZ065382; Thu, 18 Aug 2011 16:44:42 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181644.p7IGigaZ065382@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 16:44:42 +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: r224976 - user/gabor/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: Thu, 18 Aug 2011 16:44:42 -0000 Author: gabor Date: Thu Aug 18 16:44:42 2011 New Revision: 224976 URL: http://svn.freebsd.org/changeset/base/224976 Log: - Create a directory for BSD grep Added: user/gabor/grep/ From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 16:45: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 BCE73106566C; Thu, 18 Aug 2011 16:45:23 +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 945E08FC12; Thu, 18 Aug 2011 16:45: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 p7IGjNmR065450; Thu, 18 Aug 2011 16:45:23 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IGjN1t065449; Thu, 18 Aug 2011 16:45:23 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181645.p7IGjN1t065449@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 16:45: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: r224977 - user/gabor/grep/trunk 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, 18 Aug 2011 16:45:23 -0000 Author: gabor Date: Thu Aug 18 16:45:23 2011 New Revision: 224977 URL: http://svn.freebsd.org/changeset/base/224977 Log: - Create a private branch of BSD grep for local development Added: - copied from r224976, head/usr.bin/grep/ Directory Properties: user/gabor/grep/trunk/ (props changed) From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 16:57:51 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 8E62E1065674; Thu, 18 Aug 2011 16:57:51 +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 7D8738FC19; Thu, 18 Aug 2011 16:57:51 +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 p7IGvpv9065892; Thu, 18 Aug 2011 16:57:51 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IGvpqZ065887; Thu, 18 Aug 2011 16:57:51 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181657.p7IGvpqZ065887@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 16:57:51 +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: r224979 - 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: Thu, 18 Aug 2011 16:57:51 -0000 Author: gabor Date: Thu Aug 18 16:57:51 2011 New Revision: 224979 URL: http://svn.freebsd.org/changeset/base/224979 Log: - Add $FreeBSD$ id to files in /usr/include - Remove the license text from header files as they usually do not have it Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h user/gabor/tre-integration/include/fastmatch.h user/gabor/tre-integration/include/hashtable.h user/gabor/tre-integration/include/regex.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Thu Aug 18 16:54:04 2011 (r224978) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Thu Aug 18 16:57:51 2011 (r224979) @@ -1,30 +1,3 @@ -/*- - * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav - * Copyright (c) 2008-2011 Gabor Kovesdan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - #ifndef TRE_FASTMATCH_H #define TRE_FASTMATCH_H 1 Modified: user/gabor/tre-integration/include/fastmatch.h ============================================================================== --- user/gabor/tre-integration/include/fastmatch.h Thu Aug 18 16:54:04 2011 (r224978) +++ user/gabor/tre-integration/include/fastmatch.h Thu Aug 18 16:57:51 2011 (r224979) @@ -1,28 +1,4 @@ -/*- - * Copyright (C) 2011 Gabor Kovesdan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ +/* $FreeBSD$ */ #ifndef FASTMATCH_H #define FASTMATCH_H 1 Modified: user/gabor/tre-integration/include/hashtable.h ============================================================================== --- user/gabor/tre-integration/include/hashtable.h Thu Aug 18 16:54:04 2011 (r224978) +++ user/gabor/tre-integration/include/hashtable.h Thu Aug 18 16:57:51 2011 (r224979) @@ -1,28 +1,4 @@ -/*- - * Copyright (C) 2011 Gabor Kovesdan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ +/* $FreeBSD$ */ #ifndef HASHTABLE_H #define HASHTABLE_H 1 Modified: user/gabor/tre-integration/include/regex.h ============================================================================== --- user/gabor/tre-integration/include/regex.h Thu Aug 18 16:54:04 2011 (r224978) +++ user/gabor/tre-integration/include/regex.h Thu Aug 18 16:57:51 2011 (r224979) @@ -1,3 +1,5 @@ +/* $FreeBSD$ */ + /* tre.h - TRE public API definitions From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 17:09:10 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 A17F01065673; Thu, 18 Aug 2011 17:09:10 +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 903C58FC1A; Thu, 18 Aug 2011 17:09:10 +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 p7IH9AkP066274; Thu, 18 Aug 2011 17:09:10 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IH9ATh066263; Thu, 18 Aug 2011 17:09:10 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181709.p7IH9ATh066263@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 17:09:10 +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: r224980 - in user/gabor/grep/trunk: . regex 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, 18 Aug 2011 17:09:10 -0000 Author: gabor Date: Thu Aug 18 17:09:10 2011 New Revision: 224980 URL: http://svn.freebsd.org/changeset/base/224980 Log: - Backport the fast matching algorithm from TRE that has been written during this summer as a part of GSoC 2011. This only improves the performance slightly but expected to be much better tested and much more robust. Added: user/gabor/grep/trunk/regex/ user/gabor/grep/trunk/regex/fastmatch.c (contents, props changed) user/gabor/grep/trunk/regex/fastmatch.h (contents, props changed) user/gabor/grep/trunk/regex/glue.h (contents, props changed) user/gabor/grep/trunk/regex/hashtable.c (contents, props changed) user/gabor/grep/trunk/regex/hashtable.h (contents, props changed) user/gabor/grep/trunk/regex/tre-fastmatch.c (contents, props changed) user/gabor/grep/trunk/regex/tre-fastmatch.h (contents, props changed) user/gabor/grep/trunk/regex/xmalloc.c (contents, props changed) user/gabor/grep/trunk/regex/xmalloc.h (contents, props changed) Deleted: user/gabor/grep/trunk/fastgrep.c Modified: user/gabor/grep/trunk/Makefile user/gabor/grep/trunk/grep.c user/gabor/grep/trunk/grep.h user/gabor/grep/trunk/util.c Modified: user/gabor/grep/trunk/Makefile ============================================================================== --- user/gabor/grep/trunk/Makefile Thu Aug 18 16:57:51 2011 (r224979) +++ user/gabor/grep/trunk/Makefile Thu Aug 18 17:09:10 2011 (r224980) @@ -9,7 +9,12 @@ PROG= grep .else PROG= bsdgrep .endif -SRCS= fastgrep.c file.c grep.c queue.c util.c +SRCS= file.c grep.c queue.c util.c + +# Extra files ported backported form some regex improvements +.PATH: ${.CURDIR}/regex +SRCS+= fastmatch.c hashtable.c tre-fastmatch.c xmalloc.c +CFLAGS+=-I${.CURDIR}/regex .if ${MK_BSD_GREP} == "yes" LINKS= ${BINDIR}/grep ${BINDIR}/egrep \ Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Thu Aug 18 16:57:51 2011 (r224979) +++ user/gabor/grep/trunk/grep.c Thu Aug 18 17:09:10 2011 (r224980) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include "fastmatch.h" #include "grep.h" #ifndef WITHOUT_NLS @@ -83,7 +84,7 @@ bool matchall; unsigned int patterns, pattern_sz; char **pattern; regex_t *r_pattern; -fastgrep_t *fg_pattern; +fastmatch_t *fg_pattern; /* Filename exclusion/inclusion patterns */ unsigned int fpatterns, fpattern_sz; @@ -662,10 +663,10 @@ main(int argc, char *argv[]) /* Check if cheating is allowed (always is for fgrep). */ if (grepbehave == GREP_FIXED) { for (i = 0; i < patterns; ++i) - fgrepcomp(&fg_pattern[i], pattern[i]); + fixcomp(&fg_pattern[i], pattern[i], cflags); } else { for (i = 0; i < patterns; ++i) { - if (fastcomp(&fg_pattern[i], pattern[i])) { + if (fastcomp(&fg_pattern[i], pattern[i], cflags) != 0) { /* Fall back to full regex library */ c = regcomp(&r_pattern[i], pattern[i], cflags); if (c != 0) { Modified: user/gabor/grep/trunk/grep.h ============================================================================== --- user/gabor/grep/trunk/grep.h Thu Aug 18 16:57:51 2011 (r224979) +++ user/gabor/grep/trunk/grep.h Thu Aug 18 17:09:10 2011 (r224980) @@ -36,6 +36,8 @@ #include #include +#include "fastmatch.h" + #ifdef WITHOUT_NLS #define getstr(n) errstr[n] #else @@ -95,17 +97,6 @@ struct epat { int mode; }; -typedef struct { - size_t len; - unsigned char *pattern; - int qsBc[UCHAR_MAX + 1]; - /* flags */ - bool bol; - bool eol; - bool reversed; - bool word; -} fastgrep_t; - /* Flags passed to regcomp() and regexec() */ extern int cflags, eflags; @@ -125,7 +116,7 @@ extern unsigned int dpatterns, fpatterns extern char **pattern; extern struct epat *dpattern, *fpattern; extern regex_t *er_pattern, *r_pattern; -extern fastgrep_t *fg_pattern; +extern fastmatch_t *fg_pattern; /* For regex errors */ #define RE_ERROR_BUF 512 @@ -150,8 +141,3 @@ void clearqueue(void); void grep_close(struct file *f); struct file *grep_open(const char *path); char *grep_fgetln(struct file *f, size_t *len); - -/* fastgrep.c */ -int fastcomp(fastgrep_t *, const char *); -void fgrepcomp(fastgrep_t *, const char *); -int grep_search(fastgrep_t *, const unsigned char *, size_t, regmatch_t *); Added: user/gabor/grep/trunk/regex/fastmatch.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/grep/trunk/regex/fastmatch.c Thu Aug 18 17:09:10 2011 (r224980) @@ -0,0 +1,227 @@ +/* $FreeBSD$ */ + +/*- + * Copyright (C) 2011 Gabor Kovesdan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "glue.h" + +#include +#include +#include + +#include "tre-fastmatch.h" +#include "xmalloc.h" + +/* XXX: avoid duplication */ +#define CONV_PAT \ + int ret; \ + tre_char_t *wregex; \ + size_t wlen; \ + \ + wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); \ + if (wregex == NULL) \ + return REG_ESPACE; \ + \ + if (TRE_MB_CUR_MAX == 1) \ + { \ + unsigned int i; \ + const unsigned char *str = (const unsigned char *)regex; \ + tre_char_t *wstr = wregex; \ + \ + for (i = 0; i < n; i++) \ + *(wstr++) = *(str++); \ + wlen = n; \ + } \ + else \ + { \ + int consumed; \ + tre_char_t *wcptr = wregex; \ + mbstate_t state; \ + memset(&state, '\0', sizeof(state)); \ + while (n > 0) \ + { \ + consumed = tre_mbrtowc(wcptr, regex, n, &state); \ + \ + switch (consumed) \ + { \ + case 0: \ + if (*regex == '\0') \ + consumed = 1; \ + else \ + { \ + xfree(wregex); \ + return REG_BADPAT; \ + } \ + break; \ + case -1: \ + DPRINT(("mbrtowc: error %d: %s.\n", errno, \ + strerror(errno))); \ + xfree(wregex); \ + return REG_BADPAT; \ + case -2: \ + consumed = n; \ + break; \ + } \ + regex += consumed; \ + n -= consumed; \ + wcptr++; \ + } \ + wlen = wcptr - wregex; \ + } \ + \ + wregex[wlen] = L'\0'; + +int +tre_fixncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) +{ + CONV_PAT; + + ret = tre_compile_literal(preg, wregex, wlen, cflags); + xfree(wregex); + + return ret; +} + +int +tre_fastncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) +{ + CONV_PAT; + + ret = (cflags & REG_LITERAL) ? + tre_compile_literal(preg, wregex, wlen, cflags) : + tre_compile_fast(preg, wregex, wlen, cflags); + xfree(wregex); + + return ret; +} + + +int +tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags) +{ + return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags); +} + +int +tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags) +{ + return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags); +} + +int +tre_fixwncomp(fastmatch_t *preg, const wchar_t *regex, size_t n, int cflags) +{ + return tre_compile_literal(preg, regex, n, cflags); +} + +int +tre_fastwncomp(fastmatch_t *preg, const wchar_t *regex, size_t n, int cflags) +{ + return (cflags & REG_LITERAL) ? + tre_compile_literal(preg, regex, n, cflags) : + tre_compile_fast(preg, regex, n, cflags); +} + +int +tre_fixwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags) +{ + return tre_fixwncomp(preg, regex, regex ? tre_strlen(regex) : 0, cflags); +} + +int +tre_fastwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags) +{ + return tre_fastwncomp(preg, regex, regex ? tre_strlen(regex) : 0, cflags); +} + +void +tre_fastfree(fastmatch_t *preg) +{ + tre_free_fast(preg); +} + +/* XXX: avoid duplication */ +#define ADJUST_OFFSETS \ + { \ + size_t slen = (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so); \ + size_t offset = pmatch[0].rm_so; \ + int ret; \ + \ + if ((len != (unsigned)-1) && (pmatch[0].rm_eo > len)) \ + return REG_NOMATCH; \ + if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \ + return REG_NOMATCH; \ + ret = tre_match_fast(preg, &string[offset], slen, type, nmatch, \ + pmatch, eflags); \ + for (unsigned i = 0; (i == 0) || (!(eflags & REG_NOSUB) && \ + (i < nmatch)); i++) \ + { \ + pmatch[i].rm_so += offset; \ + pmatch[i].rm_eo += offset; \ + } \ + return ret; \ + } + +int +tre_fastnexec(const fastmatch_t *preg, const char *string, size_t len, + size_t nmatch, regmatch_t pmatch[], int eflags) +{ + tre_str_type_t type = (TRE_MB_CUR_MAX == 1) ? STR_BYTE : STR_MBS; + + if (eflags & REG_STARTEND) + ADJUST_OFFSETS + else + return tre_match_fast(preg, string, len, type, nmatch, + pmatch, eflags); +} + +int +tre_fastexec(const fastmatch_t *preg, const char *string, size_t nmatch, + regmatch_t pmatch[], int eflags) +{ + return tre_fastnexec(preg, string, (size_t)-1, nmatch, pmatch, eflags); +} + +int +tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t len, + size_t nmatch, regmatch_t pmatch[], int eflags) +{ + tre_str_type_t type = STR_WIDE; + + if (eflags & REG_STARTEND) + ADJUST_OFFSETS + else + return tre_match_fast(preg, string, len, type, nmatch, + pmatch, eflags); +} + +int +tre_fastwexec(const fastmatch_t *preg, const wchar_t *string, + size_t nmatch, regmatch_t pmatch[], int eflags) +{ + return tre_fastwnexec(preg, string, (size_t)-1, nmatch, pmatch, eflags); +} + Added: user/gabor/grep/trunk/regex/fastmatch.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/grep/trunk/regex/fastmatch.h Thu Aug 18 17:09:10 2011 (r224980) @@ -0,0 +1,103 @@ +/* $FreeBSD$ */ + +#ifndef FASTMATCH_H +#define FASTMATCH_H 1 + +#include +#include +#include +#include +#include + +typedef struct { + size_t wlen; + size_t len; + wchar_t *wpattern; + int hasdot; + int qsBc[UCHAR_MAX + 1]; + int *bmGs; + char *pattern; + int defBc; + hashtable *qsBc_table; + int *sbmGs; + + /* flags */ + bool bol; + bool eol; + bool word; + bool icase; + bool newline; +} fastmatch_t; + +extern int +tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags); + +extern int +tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags); + +extern int +tre_fastexec(const fastmatch_t *preg, const char *string, size_t nmatch, + regmatch_t pmatch[], int eflags); + +extern void +tre_fastfree(fastmatch_t *preg); + +extern int +tre_fixwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags); + +extern int +tre_fastwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags); + +extern int +tre_fastwexec(const fastmatch_t *preg, const wchar_t *string, + size_t nmatch, regmatch_t pmatch[], int eflags); + +/* Versions with a maximum length argument and therefore the capability to + handle null characters in the middle of the strings. */ +extern int +tre_fixncomp(fastmatch_t *preg, const char *regex, size_t len, int cflags); + +extern int +tre_fastncomp(fastmatch_t *preg, const char *regex, size_t len, int cflags); + +extern int +tre_fastnexec(const fastmatch_t *preg, const char *string, size_t len, + size_t nmatch, regmatch_t pmatch[], int eflags); + +extern int +tre_fixwncomp(fastmatch_t *preg, const wchar_t *regex, size_t len, int cflags); + +extern int +tre_fastwncomp(fastmatch_t *preg, const wchar_t *regex, size_t len, int cflags); + +extern int +tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t len, + size_t nmatch, regmatch_t pmatch[], int eflags); + +#define fixncomp tre_fixncomp +#define fastncomp tre_fastncomp +#define fixcomp tre_fixcomp +#define fastcomp tre_fastcomp +#define fixwncomp tre_fixwncomp +#define fastwncomp tre_fastwncomp +#define fixwcomp tre_fixwcomp +#define fastwcomp tre_fastwcomp +#define fastfree tre_fastfree +#define fastnexec tre_fastnexec +#define fastexec tre_fastexec +#define fastwnexec tre_fastwnexec +#define fastwexec tre_fastwexec +#define fixcomp tre_fixcomp +#define fastcomp tre_fastcomp +#define fastexec tre_fastexec +#define fastfree tre_fastfree +#define fixwcomp tre_fixwcomp +#define fastwcomp tre_fastwcomp +#define fastwexec tre_fastwexec +#define fixncomp tre_fixncomp +#define fastncomp tre_fastncomp +#define fastnexec tre_fastnexec +#define fixwncomp tre_fixwncomp +#define fastwncomp tre_fastwncomp +#define fastwnexec tre_fastwnexec +#endif /* FASTMATCH_H */ Added: user/gabor/grep/trunk/regex/glue.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/grep/trunk/regex/glue.h Thu Aug 18 17:09:10 2011 (r224980) @@ -0,0 +1,30 @@ +/* $FreeBSD$ */ + +#ifndef GLUE_H +#define GLUE_H + +#include + +#define TRE_WCHAR 1 +#define TRE_MULTIBYTE 1 + +#define tre_char_t wchar_t +#define tre_mbrtowc(pwc, s, n, ps) (mbrtowc((pwc), (s), (n), (ps))) +#define tre_strlen wcslen +#define tre_isspace iswspace +#define tre_isalnum iswalnum + +#define REG_LITERAL 0020 +#define REG_WORD 0100 +#define REG_GNU 0400 + +#define REG_OK 0 + +#define TRE_MB_CUR_MAX MB_CUR_MAX + +#define DPRINT(msg) +#define MIN(a,b) ((a > b) ? (b) : (a)) +#define MAX(a,b) ((a > b) ? (a) : (b)) + +typedef enum { STR_WIDE, STR_BYTE, STR_MBS, STR_USER } tre_str_type_t; +#endif Added: user/gabor/grep/trunk/regex/hashtable.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/grep/trunk/regex/hashtable.c Thu Aug 18 17:09:10 2011 (r224980) @@ -0,0 +1,159 @@ +/* $FreeBSD$ */ + +/*- + * Copyright (C) 2011 Gabor Kovesdan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +hashtable +*hashtable_init(size_t table_size, size_t key_size, size_t value_size) +{ + hashtable *tbl; + + tbl = malloc(sizeof(hashtable)); + if (tbl == NULL) + return (NULL); + + tbl->entries = calloc(sizeof(hashtable_entry *), table_size); + if (tbl->entries == NULL) { + free(tbl); + return (NULL); + } + + tbl->table_size = table_size; + tbl->usage = 0; + tbl->key_size = key_size; + tbl->value_size = value_size; + + return (tbl); +} + +int +hashtable_put(hashtable *tbl, const void *key, const void *value) +{ + uint32_t hash = 0; + + if (tbl->table_size == tbl->usage) + return (-1); + + hash = hash32_buf(key, tbl->key_size, hash); + hash %= tbl->table_size; + + while (tbl->entries[hash] != NULL) + hash = (hash >= tbl->table_size) ? 0 : hash + 1; + + tbl->entries[hash] = malloc(sizeof(hashtable_entry)); + if (tbl->entries[hash] == NULL) + return (-1); + + tbl->entries[hash]->key = malloc(tbl->key_size); + if (tbl->entries[hash]->key == NULL) { + free(tbl->entries[hash]); + return (-1); + } + + tbl->entries[hash]->value = malloc(tbl->value_size); + if (tbl->entries[hash]->value == NULL) { + free(tbl->entries[hash]->key); + free(tbl->entries[hash]); + return (-1); + } + + memcpy(&tbl->entries[hash]->key, key, tbl->key_size); + memcpy(&tbl->entries[hash]->value, value, tbl->value_size); + tbl->usage++; + + return (0); +} + +static hashtable_entry +*hashtable_lookup(const hashtable *tbl, const void *key) +{ + uint32_t hash = 0; + + hash = hash32_buf(key, tbl->key_size, hash); + hash %= tbl->table_size; + + for (;;) { + if (tbl->entries[hash] == NULL) + return (NULL); + else if (memcmp(key, &tbl->entries[hash]->key, + tbl->key_size) == 0) + return (tbl->entries[hash]); + + hash = (hash == tbl->table_size) ? 0 : hash + 1; + } +} + +int +hashtable_get(hashtable *tbl, const void *key, void *value) +{ + hashtable_entry *entry; + + entry = hashtable_lookup(tbl, key); + if (entry == NULL) + return (-1); + + memcpy(value, &entry->value, tbl->value_size); + return (0); +} + +int +hashtable_remove(hashtable *tbl, const void *key) +{ + hashtable_entry *entry; + + entry = hashtable_lookup(tbl, key); + if (entry == NULL) + return (-1); + +// free(entry->key); +// free(entry->value); + free(entry); + + tbl->usage--; + + return (0); +} + +void +hashtable_free(hashtable *tbl) +{ + + if (tbl == NULL) + return; + + for (unsigned int i = 0; i < tbl->table_size; i++) + if (tbl->entries[i] != NULL) { +// free(tbl->entries[i]->key); +// free(tbl->entries[i]->value); +// free(tbl->entries[i]); + } + free(tbl->entries); +} Added: user/gabor/grep/trunk/regex/hashtable.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/grep/trunk/regex/hashtable.h Thu Aug 18 17:09:10 2011 (r224980) @@ -0,0 +1,27 @@ +/* $FreeBSD$ */ + +#ifndef HASHTABLE_H +#define HASHTABLE_H 1 + +#include + +typedef struct { + void *key; + void *value; +} hashtable_entry; + +typedef struct { + size_t key_size; + size_t table_size; + size_t usage; + size_t value_size; + hashtable_entry **entries; +} hashtable; + +void hashtable_free(hashtable *); +int hashtable_get(hashtable *, const void *, void *); +hashtable *hashtable_init(size_t, size_t, size_t); +int hashtable_put(hashtable *, const void *, const void *); +int hashtable_remove(hashtable *, const void *); + +#endif /* HASHTABLE.H */ Added: user/gabor/grep/trunk/regex/tre-fastmatch.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/grep/trunk/regex/tre-fastmatch.c Thu Aug 18 17:09:10 2011 (r224980) @@ -0,0 +1,704 @@ +/* $FreeBSD$ */ + +/*- + * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav + * Copyright (C) 2008-2011 Gabor Kovesdan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "glue.h" + +#include +#include +#include +#include +#include +#include +#include +#ifdef TRE_WCHAR +#include +#include +#endif + +#include "hashtable.h" +#include "tre-fastmatch.h" +#include "xmalloc.h" + +static int fastcmp(const void *, const void *, size_t, + tre_str_type_t, bool, 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) \ + 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 + * it in fg->pattern. Sets fg->len to the byte length of the + * converted string. + */ +#define STORE_MBS_PAT \ + { \ + 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'; \ + } \ + +/* + * Compares the pattern to the input string at the position + * stored in startptr. + */ +#define COMPARE \ + switch (type) \ + { \ + case STR_WIDE: \ + mismatch = fastcmp(fg->wpattern, startptr, fg->wlen, type, \ + fg->icase, fg->newline); \ + break; \ + default: \ + mismatch = fastcmp(fg->pattern, startptr, fg->len, type, \ + fg->icase, fg->newline); \ + } \ + +#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; \ + \ + { \ + 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, \ + &((tre_char_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 \ + { \ + 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; \ + } + +/* + * Normal Quick Search would require a shift based on the position the + * 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. + * + * Examples: + * Pattern Max shift + * ------- --------- + * this 5 + * .his 4 + * t.is 3 + * th.s 2 + * 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; \ + for (int i = fg->hasdot + 1; i < fg->len; i++) \ + { \ + fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ + if (fg->icase) \ + { \ + char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ + : tolower(fg->pattern[i]); \ + fg->qsBc[(unsigned)c] = fg->len - i; \ + } \ + } + +/* + * 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; \ + \ + /* Preprocess pattern. */ \ + 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); \ + } \ + } + +/* + * Fills in the good suffix table for SB/MB strings. + */ +#define FILL_BMGS \ + if (!fg->hasdot) \ + { \ + fg->sbmGs = xmalloc(fg->len * sizeof(int)); \ + if (!fg->sbmGs) \ + return REG_ESPACE; \ + _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) \ + { \ + fg->bmGs = xmalloc(fg->wlen * sizeof(int)); \ + if (!fg->bmGs) \ + return REG_ESPACE; \ + _FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); \ + } + +#define _FILL_BMGS(arr, pat, plen, wide) \ + { \ + char *p; \ + tre_char_t *wp; \ + \ + if (wide) \ + { \ + if (fg->icase) \ + { \ + 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); \ + xfree(wp); \ + } \ + else \ + _CALC_BMGS(arr, pat, plen); \ + } \ + else \ + { \ + if (fg->icase) \ + { \ + 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); \ + xfree(p); \ + } \ + else \ + _CALC_BMGS(arr, pat, plen); \ + } \ + } + +#define _CALC_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; \ + \ + xfree(suff); \ + } + +/* + * Copies the pattern pat having lenght n to p and stores + * the size in l. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 17:12: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 033281065678; Thu, 18 Aug 2011 17:12:02 +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 E80BD8FC26; Thu, 18 Aug 2011 17:12:01 +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 p7IHC1I2066409; Thu, 18 Aug 2011 17:12:01 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IHC19B066407; Thu, 18 Aug 2011 17:12:01 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181712.p7IHC19B066407@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 17:12:01 +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: r224981 - user/gabor/grep/trunk 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, 18 Aug 2011 17:12:02 -0000 Author: gabor Date: Thu Aug 18 17:12:01 2011 New Revision: 224981 URL: http://svn.freebsd.org/changeset/base/224981 Log: - Submatches are actually never needed Modified: user/gabor/grep/trunk/grep.c Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Thu Aug 18 17:09:10 2011 (r224980) +++ user/gabor/grep/trunk/grep.c Thu Aug 18 17:12:01 2011 (r224981) @@ -521,7 +521,6 @@ main(int argc, char *argv[]) break; case 'o': oflag = true; - cflags &= ~REG_NOSUB; break; case 'p': linkbehave = LINK_SKIP; @@ -555,11 +554,9 @@ main(int argc, char *argv[]) break; case 'w': wflag = true; - cflags &= ~REG_NOSUB; break; case 'x': xflag = true; - cflags &= ~REG_NOSUB; break; case 'Z': filebehave = FILE_GZIP; @@ -593,7 +590,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; From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 17:53:19 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 86043106564A; Thu, 18 Aug 2011 17:53:19 +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 6C5368FC13; Thu, 18 Aug 2011 17:53:19 +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 p7IHrJri067635; Thu, 18 Aug 2011 17:53:19 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IHrJxE067632; Thu, 18 Aug 2011 17:53:19 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181753.p7IHrJxE067632@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 17:53:19 +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: r224982 - user/gabor/grep/trunk 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, 18 Aug 2011 17:53:19 -0000 Author: gabor Date: Thu Aug 18 17:53:19 2011 New Revision: 224982 URL: http://svn.freebsd.org/changeset/base/224982 Log: - Pass the pattern length to the matcher instead of calculating it twice Modified: user/gabor/grep/trunk/grep.c user/gabor/grep/trunk/grep.h Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Thu Aug 18 17:12:01 2011 (r224981) +++ user/gabor/grep/trunk/grep.c Thu Aug 18 17:53:19 2011 (r224982) @@ -82,7 +82,7 @@ bool matchall; /* Searching patterns */ unsigned int patterns, pattern_sz; -char **pattern; +struct pat *pattern; regex_t *r_pattern; fastmatch_t *fg_pattern; @@ -233,14 +233,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].len = len; + pattern[patterns].pat[len] = '\0'; ++patterns; } @@ -652,19 +653,18 @@ main(int argc, char *argv[]) fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); -/* - * XXX: fgrepcomp() and fastcomp() are workarounds for regexec() performance. - * Optimizations should be done there. - */ - /* Check if cheating is allowed (always is for fgrep). */ + + /* Check if cheating is allowed (always is for fgrep). */ if (grepbehave == GREP_FIXED) { for (i = 0; i < patterns; ++i) - fixcomp(&fg_pattern[i], pattern[i], cflags); + fixncomp(&fg_pattern[i], pattern[i].pat, + pattern[i].len, cflags); } else { for (i = 0; i < patterns; ++i) { - if (fastcomp(&fg_pattern[i], pattern[i], cflags) != 0) { + if (fastncomp(&fg_pattern[i], pattern[i].pat, + pattern[i].len, cflags) != 0) { /* Fall back to full regex library */ - c = regcomp(&r_pattern[i], pattern[i], cflags); + c = regcomp(&r_pattern[i], pattern[i].pat, cflags); if (c != 0) { regerror(c, &r_pattern[i], re_error, RE_ERROR_BUF); Modified: user/gabor/grep/trunk/grep.h ============================================================================== --- user/gabor/grep/trunk/grep.h Thu Aug 18 17:12:01 2011 (r224981) +++ user/gabor/grep/trunk/grep.h Thu Aug 18 17:53:19 2011 (r224982) @@ -92,6 +92,11 @@ struct str { int line_no; }; +struct pat { + char *pat; + int len; +}; + struct epat { char *pat; int mode; @@ -113,7 +118,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; extern fastmatch_t *fg_pattern; From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 17:54:33 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 8502C1065674; Thu, 18 Aug 2011 17:54:33 +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 758B98FC08; Thu, 18 Aug 2011 17:54:33 +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 p7IHsXwY067707; Thu, 18 Aug 2011 17:54:33 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IHsXlQ067705; Thu, 18 Aug 2011 17:54:33 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181754.p7IHsXlQ067705@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 17:54:33 +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: r224983 - user/gabor/grep/trunk 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, 18 Aug 2011 17:54:33 -0000 Author: gabor Date: Thu Aug 18 17:54:33 2011 New Revision: 224983 URL: http://svn.freebsd.org/changeset/base/224983 Log: - Revert r224981; it was incorrect Modified: user/gabor/grep/trunk/grep.c Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Thu Aug 18 17:53:19 2011 (r224982) +++ user/gabor/grep/trunk/grep.c Thu Aug 18 17:54:33 2011 (r224983) @@ -522,6 +522,7 @@ main(int argc, char *argv[]) break; case 'o': oflag = true; + cflags &= ~REG_NOSUB; break; case 'p': linkbehave = LINK_SKIP; @@ -555,9 +556,11 @@ main(int argc, char *argv[]) break; case 'w': wflag = true; + cflags &= ~REG_NOSUB; break; case 'x': xflag = true; + cflags &= ~REG_NOSUB; break; case 'Z': filebehave = FILE_GZIP; @@ -591,6 +594,7 @@ 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; From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 18:15: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 9539E1065673; Thu, 18 Aug 2011 18:15: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 85BA88FC0C; Thu, 18 Aug 2011 18:15: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 p7IIFE2r068460; Thu, 18 Aug 2011 18:15:14 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IIFEQf068458; Thu, 18 Aug 2011 18:15:14 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181815.p7IIFEQf068458@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 18:15: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: r224984 - user/gabor/grep/trunk 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, 18 Aug 2011 18:15:15 -0000 Author: gabor Date: Thu Aug 18 18:15:14 2011 New Revision: 224984 URL: http://svn.freebsd.org/changeset/base/224984 Log: - Kepp things clean Pointyhat to: obrien Modified: user/gabor/grep/trunk/Makefile Modified: user/gabor/grep/trunk/Makefile ============================================================================== --- user/gabor/grep/trunk/Makefile Thu Aug 18 17:54:33 2011 (r224983) +++ user/gabor/grep/trunk/Makefile Thu Aug 18 18:15:14 2011 (r224984) @@ -8,6 +8,10 @@ PROG= grep .else PROG= bsdgrep +CLEANFILES+= bsdgrep.1 + +bsdgrep.1: grep.1 + cp ${.ALLSRC} ${.TARGET} .endif SRCS= file.c grep.c queue.c util.c @@ -30,9 +34,6 @@ MLINKS= grep.1 egrep.1 \ grep.1 zfgrep.1 .endif -bsdgrep.1: grep.1 - cp ${.ALLSRC} ${.TARGET} - LDADD= -lz -lbz2 DPADD= ${LIBZ} ${LIBBZ2} From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 00:44:37 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 A34951065673; Fri, 19 Aug 2011 00:44:37 +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 9439D8FC18; Fri, 19 Aug 2011 00:44:37 +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 p7J0ibnc080179; Fri, 19 Aug 2011 00:44:37 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J0ib7x080177; Fri, 19 Aug 2011 00:44:37 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108190044.p7J0ib7x080177@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 19 Aug 2011 00:44: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: r224990 - 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, 19 Aug 2011 00:44:37 -0000 Author: gabor Date: Fri Aug 19 00:44:37 2011 New Revision: 224990 URL: http://svn.freebsd.org/changeset/base/224990 Log: - Also fix here the REG_NOSUB regression Modified: user/gabor/tre-integration/usr.bin/grep/grep.c Modified: user/gabor/tre-integration/usr.bin/grep/grep.c ============================================================================== --- user/gabor/tre-integration/usr.bin/grep/grep.c Thu Aug 18 23:15:04 2011 (r224989) +++ user/gabor/tre-integration/usr.bin/grep/grep.c Fri Aug 19 00:44:37 2011 (r224990) @@ -518,6 +518,7 @@ main(int argc, char *argv[]) break; case 'o': oflag = true; + cflags &= ~REG_NOSUB; break; case 'p': linkbehave = LINK_SKIP; @@ -551,9 +552,11 @@ main(int argc, char *argv[]) break; case 'w': cflags |= REG_WORD; + cflags &= ~REG_NOSUB; break; case 'x': xflag = true; + cflags &= ~REG_NOSUB; break; case 'Z': filebehave = FILE_GZIP; @@ -587,6 +590,7 @@ 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; From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 02:03:01 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 3AF7B106566B; Fri, 19 Aug 2011 02:03:01 +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 2BD268FC0C; Fri, 19 Aug 2011 02:03:01 +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 p7J231II082564; Fri, 19 Aug 2011 02:03:01 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J231Eb082561; Fri, 19 Aug 2011 02:03:01 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108190203.p7J231Eb082561@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 19 Aug 2011 02:03:01 +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: r224992 - 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, 19 Aug 2011 02:03:01 -0000 Author: gabor Date: Fri Aug 19 02:03:00 2011 New Revision: 224992 URL: http://svn.freebsd.org/changeset/base/224992 Log: - Move TRE_CHAR macro to tre-internal.h because it will be used in the heuristic code Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-internal.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Fri Aug 19 01:11:06 2011 (r224991) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Fri Aug 19 02:03:00 2011 (r224992) @@ -48,15 +48,6 @@ static int fastcmp(const void *, const v tre_str_type_t, bool, 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 Modified: user/gabor/tre-integration/contrib/tre/lib/tre-internal.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-internal.h Fri Aug 19 01:11:06 2011 (r224991) +++ user/gabor/tre-integration/contrib/tre/lib/tre-internal.h Fri Aug 19 02:03:00 2011 (r224992) @@ -47,6 +47,9 @@ /* Define the character types and functions. */ #ifdef TRE_WCHAR +/* Use wide character constants */ +#define TRE_CHAR(n) L##n + /* Wide characters. */ typedef wint_t tre_cint_t; #define TRE_CHAR_MAX WCHAR_MAX @@ -78,6 +81,9 @@ typedef wint_t tre_cint_t; #else /* !TRE_WCHAR */ +/* Use single-byte character constants */ +#define TRE_CHAR(n) n + /* 8 bit characters. */ typedef short tre_cint_t; #define TRE_CHAR_MAX 255 From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 02:16:30 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 1CA9E106564A; Fri, 19 Aug 2011 02:16:30 +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 025A68FC1A; Fri, 19 Aug 2011 02:16:30 +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 p7J2GTAi082978; Fri, 19 Aug 2011 02:16:29 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J2GTFP082976; Fri, 19 Aug 2011 02:16:29 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108190216.p7J2GTFP082976@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 02:16:29 +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: r224993 - 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, 19 Aug 2011 02:16:30 -0000 Author: adrian Date: Fri Aug 19 02:16:29 2011 New Revision: 224993 URL: http://svn.freebsd.org/changeset/base/224993 Log: Fix the holes in the sequence number ranges being fed to the BAW tracking code. The main culprit was the retries flag, this wasn't being cleared for new frames and thus ath_tx_addto_baw() was incorrectly ignoring those frames. The traffic flow is now stable until the first set of failed frames. Aggregate frames are being transmitted however the throughput is still much less than expected. 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 19 02:03:00 2011 (r224992) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 19 02:16:29 2011 (r224993) @@ -1233,7 +1233,10 @@ ath_tx_start(struct ath_softc *sc, struc /* A-MPDU TX? Manually set sequence number */ /* Don't do it whilst pending; the net80211 layer still assigns them */ + /* XXX do we need locking here? */ if (is_ampdu_tx) { + struct ath_node *an = ATH_NODE(ni); + //ATH_TXQ_LOCK(&an->an_tid[tid]); /* * Always call; this function will * handle making sure that null data frames @@ -1245,6 +1248,7 @@ ath_tx_start(struct ath_softc *sc, struc subtype != IEEE80211_FC0_SUBTYPE_QOS_NULL) { bf->bf_state.bfs_dobaw = 1; } + //ATH_TXQ_UNLOCK(&an->an_tid[tid]); } /* @@ -1728,21 +1732,17 @@ ath_tx_addto_baw(struct ath_softc *sc, s return; tap = ath_tx_get_tx_tid(an, tid->tid); - DPRINTF(sc, ATH_DEBUG_SW_TX_BAW, "%s: tid=%d, seqno %d; window %d:%d\n", - __func__, tid->tid, SEQNO(bf->bf_state.bfs_seqno), - tap->txa_start, tap->txa_wnd); - /* * ni->ni_txseqs[] is the currently allocated seqno. * the txa state contains the current baw start. */ - DPRINTF(sc, ATH_DEBUG_SW_TX_BAW, "%s: tap->txa_start: %d, seqno: %d\n", - __func__, tap->txa_start, SEQNO(bf->bf_state.bfs_seqno)); index = ATH_BA_INDEX(tap->txa_start, SEQNO(bf->bf_state.bfs_seqno)); cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); DPRINTF(sc, ATH_DEBUG_SW_TX_BAW, - "%s: index=%d, cindex=%d, baw head=%d, tail=%d\n", - __func__, index, cindex, tid->baw_head, tid->baw_tail); + "%s: tid=%d, seqno %d; window %d:%d; index=%d cindex=%d baw head=%d tail=%d\n", + __func__, tid->tid, SEQNO(bf->bf_state.bfs_seqno), + tap->txa_start, tap->txa_wnd, index, cindex, tid->baw_head, tid->baw_tail); + #if 0 assert(tid->tx_buf[cindex] == NULL); @@ -1773,15 +1773,12 @@ ath_tx_update_baw(struct ath_softc *sc, struct ieee80211_tx_ampdu *tap; tap = ath_tx_get_tx_tid(an, tid->tid); - DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d, baw=%d:%d, seqno=%d\n", - __func__, tid->tid, tap->txa_start, tap->txa_wnd, seqno); - index = ATH_BA_INDEX(tap->txa_start, seqno); cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); DPRINTF(sc, ATH_DEBUG_SW_TX_BAW, - "%s: index=%d, cindex=%d, baw head=%d, tail=%d\n", - __func__, index, cindex, tid->baw_head, tid->baw_tail); + "%s: tid=%d, baw=%d:%d, seqno=%d, index=%d, cindex=%d, baw head=%d, tail=%d\n", + __func__, tid->tid, tap->txa_start, tap->txa_wnd, seqno, index, cindex, tid->baw_head, tid->baw_tail); tid->tx_buf[cindex] = NULL; @@ -1789,6 +1786,8 @@ ath_tx_update_baw(struct ath_softc *sc, INCR(tap->txa_start, IEEE80211_SEQ_RANGE); INCR(tid->baw_head, ATH_TID_MAX_BUFS); } + DPRINTF(sc, ATH_DEBUG_SW_TX_BAW, "%s: baw is now %d:%d, baw head=%d\n", + __func__, tap->txa_start, tap->txa_wnd, tid->baw_head); } /* @@ -1920,8 +1919,20 @@ 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; + + /* + * blank out fields which will be overridden if needed + * Don't touch bfs_dobaw - that's already been set by + * ath_tx_start(). + */ bf->bf_state.bfs_aggr = 0; bf->bf_state.bfs_aggrburst = 0; + bf->bf_next = NULL; + bf->bf_state.bfs_retries = 0; + bf->bf_state.bfs_isretried = 0; + bf->bf_state.bfs_ndelim = 0; + bf->bf_state.bfs_nframes = 0; + bf->bf_state.bfs_al = 0; /* Queue frame to the tail of the software queue */ ATH_TXQ_LOCK(atid); @@ -2297,6 +2308,8 @@ ath_tx_aggr_retry_unaggr(struct ath_soft tap = ath_tx_get_tx_tid(an, tid); if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { + device_printf(sc->sc_dev, "%s: exceeded retries; seqno %d\n", + __func__, SEQNO(bf->bf_state.bfs_seqno)); sc->sc_stats.ast_tx_swretrymax++; /* Update BAW anyway */ @@ -2391,6 +2404,8 @@ ath_tx_retry_subframe(struct ath_softc * /* ath_hal_set11n_virtualmorefrag(sc->sc_ah, bf->bf_desc, 0); */ if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { + device_printf(sc->sc_dev, "%s: max retries: seqno %d\n", + __func__, SEQNO(bf->bf_state.bfs_seqno)); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); /* XXX subframe completion status? is that valid here? */ ath_tx_default_comp(sc, bf, 0); @@ -2471,6 +2486,7 @@ ath_tx_comp_aggr_error(struct ath_softc /* * Handle clean-up of packets from an aggregate list. + * XXX update BAW? */ static void ath_tx_comp_cleanup_aggr(struct ath_softc *sc, struct ath_buf *bf_first) @@ -2539,7 +2555,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * /* * handle errors first */ - if (0 && ts->ts_status & HAL_TXERR_XRETRY) { + if (ts->ts_status & HAL_TXERR_XRETRY) { ath_tx_comp_aggr_error(sc, bf_first, atid); return; } From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 02:37: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 1B878106566C; Fri, 19 Aug 2011 02:37:14 +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 0C37E8FC14; Fri, 19 Aug 2011 02:37: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 p7J2bDns083597; Fri, 19 Aug 2011 02:37:13 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J2bDZR083595; Fri, 19 Aug 2011 02:37:13 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108190237.p7J2bDZR083595@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 02:37: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: r224994 - 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, 19 Aug 2011 02:37:14 -0000 Author: adrian Date: Fri Aug 19 02:37:13 2011 New Revision: 224994 URL: http://svn.freebsd.org/changeset/base/224994 Log: Comment out an unused variable; locking doesn't seem to be needed here just yet. 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 19 02:16:29 2011 (r224993) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 19 02:37:13 2011 (r224994) @@ -1235,7 +1235,7 @@ ath_tx_start(struct ath_softc *sc, struc /* Don't do it whilst pending; the net80211 layer still assigns them */ /* XXX do we need locking here? */ if (is_ampdu_tx) { - struct ath_node *an = ATH_NODE(ni); + //struct ath_node *an = ATH_NODE(ni); //ATH_TXQ_LOCK(&an->an_tid[tid]); /* * Always call; this function will From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 06:33:41 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 4B653106564A; Fri, 19 Aug 2011 06:33:41 +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 30DCC8FC0A; Fri, 19 Aug 2011 06:33:41 +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 p7J6XfuD090851; Fri, 19 Aug 2011 06:33:41 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J6Xflp090849; Fri, 19 Aug 2011 06:33:41 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108190633.p7J6Xflp090849@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 06:33:41 +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: r224995 - 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, 19 Aug 2011 06:33:41 -0000 Author: adrian Date: Fri Aug 19 06:33:40 2011 New Revision: 224995 URL: http://svn.freebsd.org/changeset/base/224995 Log: * Disable BAR sending for now, I'm still not entirely convinced that it's all setup correctly and the right BAW left edge value is being sent (ie, I think I need to add some locking to ensure that new values aren't allocated by the TX send context, as completion and TX occur in different thread/processes.) I'll revisit correct BAR TX'ing later on. * Add/change some debugging around to make tracking down strange sequence number issues easier. And the actual bugfix: * re-schedule the TID for more TX scheduling after the aggregate completion handler is run - either the error handler (which retries all subframes if possible) or after the completion handler itself. In both instances, since packets may be requeued on the software queue, the TID needs rescheduling. Without this, I noticed the throughput would drop immediately when any retries occured, and lots of frames were being scheduled later on when I was issuing a single ICMP ping. That ping was causing the software queue to be scheduled, and lots of frames were thus being re-scheduled to the hardware (and updating the BAW in the process.) With this, things are stable. Slow (same as non-aggregate speed) and the software retry rate is too high for my liking, but packets now seem to zip along. 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 19 02:37:13 2011 (r224994) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 19 06:33:40 2011 (r224995) @@ -395,8 +395,9 @@ ath_tx_setds_11n(struct ath_softc *sc, s bf = bf_first; while (bf != NULL) { DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, - "%s: bf=%p, nseg=%d, pktlen=%d\n", - __func__, bf, bf->bf_nseg, bf->bf_state.bfs_pktlen); + "%s: bf=%p, nseg=%d, pktlen=%d, seqno=%d\n", + __func__, bf, bf->bf_nseg, bf->bf_state.bfs_pktlen, + SEQNO(bf->bf_state.bfs_seqno)); /* Sub-frame setup */ ath_tx_chaindesclist_subframe(sc, bf); @@ -2322,6 +2323,7 @@ ath_tx_aggr_retry_unaggr(struct ath_soft * This'll end up going into net80211 and back out * again, via ic->ic_raw_xmit(). */ +#if 0 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: send BAR\n", __func__, tid); if (ieee80211_send_bar(ni, tap, ni->ni_txseqs[tid]) == 0) { @@ -2337,6 +2339,7 @@ ath_tx_aggr_retry_unaggr(struct ath_soft "%s: TID %d: BAR TX failed\n", __func__, tid); } +#endif /* Free buffer, bf is free after this call */ ath_tx_default_comp(sc, bf, 0); @@ -2438,6 +2441,7 @@ ath_tx_comp_aggr_error(struct ath_softc ath_bufhead bf_q; int drops = 0; struct ieee80211_tx_ampdu *tap; + struct ath_txq *txq = sc->sc_ac2q[tid->ac]; tap = ath_tx_get_tx_tid(an, tid->tid); @@ -2482,6 +2486,13 @@ ath_tx_comp_aggr_error(struct ath_softc ATH_TXQ_INSERT_HEAD(tid, bf, bf_list); } ATH_TXQ_UNLOCK(tid); + + /* + * Kick the queue + */ + ATH_TXQ_LOCK(txq); + ath_tx_tid_sched(sc, an, tid->tid); + ATH_TXQ_UNLOCK(txq); } /* @@ -2541,6 +2552,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * struct ath_buf *bf, *bf_next; int ba_index; int drops = 0; + struct ath_txq *txq = sc->sc_ac2q[atid->ac]; DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called\n", __func__); @@ -2596,12 +2608,14 @@ ath_tx_aggr_comp_aggr(struct ath_softc * bf = bf_first; while (bf) { - DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: checking bf=%p seqno=%d\n", - __func__, bf, SEQNO(bf->bf_state.bfs_seqno)); - ba_index = ATH_BA_INDEX(seq_st, SEQNO(bf->bf_state.bfs_seqno)); bf_next = bf->bf_next; + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, + "%s: checking bf=%p seqno=%d; ack=%d\n", + __func__, bf, SEQNO(bf->bf_state.bfs_seqno), + ATH_BA_ISSET(ba, ba_index)); + /* * For now, ACK all packets */ @@ -2648,6 +2662,14 @@ ath_tx_aggr_comp_aggr(struct ath_softc * } ATH_TXQ_UNLOCK(atid); + /* + * Kick the queue if it needs it + * XXX too aggressive? + */ + ATH_TXQ_LOCK(txq); + ath_tx_tid_sched(sc, an, atid->tid); + ATH_TXQ_UNLOCK(txq); + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: finished; txa_start now %d\n", __func__, tap->txa_start); } From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 07:12:29 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 E9ACF1065670; Fri, 19 Aug 2011 07:12:29 +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 D99CE8FC1A; Fri, 19 Aug 2011 07:12:29 +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 p7J7CTRB092082; Fri, 19 Aug 2011 07:12:29 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J7CTSX092080; Fri, 19 Aug 2011 07:12:29 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108190712.p7J7CTSX092080@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 07:12:29 +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: r224996 - 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, 19 Aug 2011 07:12:30 -0000 Author: adrian Date: Fri Aug 19 07:12:29 2011 New Revision: 224996 URL: http://svn.freebsd.org/changeset/base/224996 Log: More things to look at! 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 19 06:33:40 2011 (r224995) +++ user/adrian/if_ath_tx/sys/dev/ath/README Fri Aug 19 07:12:29 2011 (r224996) @@ -18,6 +18,22 @@ Things that need doing! + right now packets are simply flushed; why not just re-prod them into the software TXQ ? +* Delimiter calculation? is it right? + port ath_compute_num_delims() + +* rate series packet duration calculation - it needs to be the entire + aggregate length for aggregates, not the individual frame? + (carrier code uses the whole aggregate, what about newma/fusion/ath9k?) + newma does this too (check ath_pkt_duration()) + +* nodes w/ a lower BA window size; try to fill it in ath_tx_form_aggr() ? + +* teach ath_rate about aggregate completion? + - just pass in the number of failed+attempted packets? + - there's only one rate for all aggregates, but we need to know which + one was used? + - what else would be helpful? + Things that need investigating! There's a crash which occurs when a wlan interface is destroyed and From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 07:12:50 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 D7C981065673; Fri, 19 Aug 2011 07:12:50 +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 ADCFB8FC12; Fri, 19 Aug 2011 07:12:50 +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 p7J7CoCM092129; Fri, 19 Aug 2011 07:12:50 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J7CoHI092125; Fri, 19 Aug 2011 07:12:50 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108190712.p7J7CoHI092125@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 07:12:50 +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: r224997 - 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, 19 Aug 2011 07:12:50 -0000 Author: adrian Date: Fri Aug 19 07:12:50 2011 New Revision: 224997 URL: http://svn.freebsd.org/changeset/base/224997 Log: Add more statistics to keep track of. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c 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.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Aug 19 07:12:29 2011 (r224996) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Aug 19 07:12:50 2011 (r224997) @@ -4120,8 +4120,10 @@ ath_tx_update_stats(struct ath_softc *sc if (ts->ts_status & HAL_TXERR_TIMER_EXPIRED) sc->sc_stats.ast_tx_timerexpired++; - /* XXX HAL_TX_DATA_UNDERRUN */ - /* XXX HAL_TX_DELIM_UNDERRUN */ + if (ts->ts_status & HAL_TX_DATA_UNDERRUN) + sc->sc_stats.ast_tx_data_underrun++; + if (ts->ts_status & HAL_TX_DELIM_UNDERRUN) + sc->sc_stats.ast_tx_delim_underrun++; if (bf->bf_m->m_flags & M_FF) sc->sc_stats.ast_ff_txerr++; 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 Fri Aug 19 07:12:29 2011 (r224996) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Fri Aug 19 07:12:50 2011 (r224997) @@ -734,6 +734,11 @@ ath_sysctl_stats_attach(struct ath_softc SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swretrymax", CTLFLAG_RD, &sc->sc_stats.ast_tx_swretrymax, 0, "TX software retry max reached"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_data_underrun", CTLFLAG_RD, + &sc->sc_stats.ast_tx_data_underrun, 0, ""); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_delim_underrun", CTLFLAG_RD, + &sc->sc_stats.ast_tx_delim_underrun, 0, ""); + /* 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 Fri Aug 19 07:12:29 2011 (r224996) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Fri Aug 19 07:12:50 2011 (r224997) @@ -136,7 +136,9 @@ struct ath_stats { u_int32_t ast_tx_desccfgerr; /* tx desc cfg error */ 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]; + u_int32_t ast_tx_data_underrun; + u_int32_t ast_tx_delim_underrun; + u_int32_t ast_pad[9]; }; #define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 07:21:19 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 A5F4A106564A; Fri, 19 Aug 2011 07:21:19 +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 95B108FC14; Fri, 19 Aug 2011 07:21:19 +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 p7J7LJ7D092415; Fri, 19 Aug 2011 07:21:19 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J7LJhU092413; Fri, 19 Aug 2011 07:21:19 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108190721.p7J7LJhU092413@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 07:21:19 +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: r224998 - 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, 19 Aug 2011 07:21:19 -0000 Author: adrian Date: Fri Aug 19 07:21:19 2011 New Revision: 224998 URL: http://svn.freebsd.org/changeset/base/224998 Log: Note some more things to look at. 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 19 07:12:50 2011 (r224997) +++ user/adrian/if_ath_tx/sys/dev/ath/README Fri Aug 19 07:21:19 2011 (r224998) @@ -34,6 +34,17 @@ Things that need doing! one was used? - what else would be helpful? +* Am I too aggressively scheduling things, and thus the aggregation code + doesn't ever get a chance to form decent sized aggregates? + +* I'm getting a lot of OOR packets at the receive end, is this because + of a large number of software retries? or is it that, combined with + TX'ing a long list of aggregates that mostly fill the BAW, meaning + packets can stay out of order for longer (but still be within the BAW?) + I bet this'd piss off TCP, if it had to wait for 20/30 packets + before it received the next retransmit (and thus the AMPDU RX queue + would get flushed.) + Things that need investigating! There's a crash which occurs when a wlan interface is destroyed and From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 09:14: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 92939106566C; Fri, 19 Aug 2011 09:14: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 819398FC15; Fri, 19 Aug 2011 09:14: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 p7J9EMEV095918; Fri, 19 Aug 2011 09:14:22 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7J9EMOE095916; Fri, 19 Aug 2011 09:14:22 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108190914.p7J9EMOE095916@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 09:14: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: r225002 - 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, 19 Aug 2011 09:14:22 -0000 Author: adrian Date: Fri Aug 19 09:14:22 2011 New Revision: 225002 URL: http://svn.freebsd.org/changeset/base/225002 Log: (mostly) cosmetic changes: * bump the aggregate max packet size up a bit, just for testing. This needs to be calculated based on the rate control information. * start to break out the delimiter calculation function. This needs to take the negotiated mpdudensity into account, but this calculation again requires the rate control information (to map density to delimiter byte size). * Modify/add some more comments, more accurately describing what is going on. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Fri Aug 19 09:06:00 2011 (r225001) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Fri Aug 19 09:14:22 2011 (r225002) @@ -135,6 +135,44 @@ int ath_max_4ms_framelen[4][32] = { }; /* + * Return the number of delimiters to be added to + * meet the minimum required mpdudensity. + * Caller should make sure that the rate is HT. + * + * TODO: is this delimiter calculation supposed to be the + * total frame length, the hdr length, the data length (including + * delimiters, padding, CRC, etc) or ? + */ +static int +ath_compute_num_delims(struct ath_softc *sc, struct ath_buf *first_bf, + uint16_t pktlen) +{ + int ndelim; + + /* Select standard number of delimiters based on frame length */ + ndelim = ATH_AGGR_GET_NDELIM(pktlen); + + /* + * If encryption is enabled, add extra delimiters to let the + * crypto hardware catch up. This could be tuned per-MAC and + * per-rate, but for now we'll simply assume encryption is + * always enabled. + */ + ndelim += ATH_AGGR_ENCRYPTDELIM; + + /* + * If the MPDU density is 0, we can return here. + * Otherwise, we need to convert the desired mpdudensity + * into a byte length, based on the rate in the subframe. + * + * XXX TODO: since the rate scenario hasn't been configured + * XXX yet, this is likely not going to work. So, for now, + * XXX ignore it. + */ + return ndelim; +} + +/* * Setup a 11n rate series structure * * This should be called for both legacy and MCS rates. @@ -290,7 +328,14 @@ ath_buf_set_rate(struct ath_softc *sc, s ath_hal_setuplasttxdesc(ah, lastds, ds); /* Set burst duration */ - /* This should only be done if aggregate protection is enabled */ + /* + * This is only required when doing 11n burst, not aggregation + * ie, if there's a second frame in a RIFS or A-MPDU burst + * w/ >1 A-MPDU frame bursting back to back. + * Normal A-MPDU doesn't do bursting -between- aggregates. + * + * .. and it's highly likely this won't ever be implemented + */ //ath_hal_set11nburstduration(ah, ds, 8192); } @@ -308,15 +353,12 @@ ath_buf_set_rate(struct ath_softc *sc, s * needed before each frame * + Enforce the BAW limit * - * Each descriptor queued should already have the TX fields setup, - * the DMA map setup and the rate control series setup. Since - * aggregate sub-frame retransmission is done entirely in software, - * it should only have a single rate series configured. - * - * The first descriptor has the rate control and aggregate setup - * fields; the middle frames have "aggregate" and "more" flags set - * along with the delimiter count; the last frame has "aggregate" - * set. + * Each descriptor queued should have the DMA setup. + * The rate series, descriptor setup, linking, etc is all done + * externally. This routine simply chains them together. + * ath_tx_setds_11n() will take care of configuring the per- + * descriptor setup, and ath_buf_set_rate() will configure the + * rate control. * * Note that the TID lock is only grabbed when dequeuing packets from * the TID queue. If some code in another thread adds to the head of this @@ -350,7 +392,10 @@ ath_tx_form_aggr(struct ath_softc *sc, s h_baw = tap->txa_wnd / 2; /* Calculate aggregation limit */ - aggr_limit = 49152; /* XXX just for now, for testing */ + /* + * XXX TODO: do not exceed 4ms packet length + */ + aggr_limit = 65530; /* XXX just for now, for testing */ for (;;) { ATH_TXQ_LOCK(tid); @@ -396,11 +441,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s } /* - * do not exceed aggregation limit - */ - al_delta = ATH_AGGR_DELIM_SZ + bf->bf_state.bfs_pktlen; - - /* * XXX TODO: AR5416 has an 8K aggregation size limit * when RTS is enabled, and RTS is required for dual-stream * rates. @@ -408,6 +448,10 @@ ath_tx_form_aggr(struct ath_softc *sc, s * For now, limit all aggregates for the AR5416 to be 8K. */ + /* + * do not exceed aggregation limit + */ + al_delta = ATH_AGGR_DELIM_SZ + bf->bf_state.bfs_pktlen; if (nframes && (aggr_limit < (al + bpad + al_delta + prev_al))) { ATH_TXQ_UNLOCK(tid); @@ -425,9 +469,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s break; } - /* - * XXX TODO: do not exceed 4ms packet length - */ /* * this packet is part of an aggregate. @@ -446,15 +487,19 @@ ath_tx_form_aggr(struct ath_softc *sc, s * add padding for previous frame to aggregation length */ al += bpad + al_delta; - bf->bf_state.bfs_ndelim = - ATH_AGGR_GET_NDELIM(bf->bf_state.bfs_pktlen); /* - * Add further padding if encryption is required - * XXX for now, always add it. + * Calculate delimiters needed for the current frame */ - bf->bf_state.bfs_ndelim += ATH_AGGR_ENCRYPTDELIM; + bf->bf_state.bfs_ndelim = + ath_compute_num_delims(sc, bf_first, + bf->bf_state.bfs_pktlen); + /* + * Calculate the padding needed from this set of delimiters, + * used when calculating if the next frame will fit in + * the aggregate. + */ bpad = PADBYTES(al_delta) + (bf->bf_state.bfs_ndelim << 2); /* @@ -464,6 +509,11 @@ ath_tx_form_aggr(struct ath_softc *sc, s bf_prev->bf_next = bf; bf_prev = bf; + /* + * XXX TODO: if any sub-frames have RTS/CTS enabled; + * enable it for the entire aggregate. + */ + #if 0 /* * terminate aggregation on a small packet boundary From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 11:58: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 45701106566C; Fri, 19 Aug 2011 11:58: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 1C52E8FC13; Fri, 19 Aug 2011 11:58: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 p7JBw6r5002573; Fri, 19 Aug 2011 11:58:06 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7JBw5qs002571; Fri, 19 Aug 2011 11:58:05 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108191158.p7JBw5qs002571@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 11:58:05 +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: r225004 - 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, 19 Aug 2011 11:58:06 -0000 Author: adrian Date: Fri Aug 19 11:58:05 2011 New Revision: 225004 URL: http://svn.freebsd.org/changeset/base/225004 Log: Tidy up some debugging, remove some now unused code. 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 19 10:12:02 2011 (r225003) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 19 11:58:05 2011 (r225004) @@ -2616,11 +2616,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * __func__, bf, SEQNO(bf->bf_state.bfs_seqno), ATH_BA_ISSET(ba, ba_index)); - /* - * For now, ACK all packets - */ if (tx_ok && ATH_BA_ISSET(ba, ba_index)) { - //if (1) { ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); ath_tx_default_comp(sc, bf, 0); @@ -2785,7 +2781,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft * data frame), schedule it directly; continue. */ if (! bf->bf_state.bfs_dobaw) { - DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: non-baw packet\n", + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: non-baw packet\n", __func__); ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); @@ -2806,7 +2802,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft TAILQ_INIT(&bf_q); status = ath_tx_form_aggr(sc, an, atid, &bf_q); - DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: ath_tx_form_aggr() status=%d\n", __func__, status); /* @@ -2827,7 +2823,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft * whether it's in the BAW and added it appropriately. */ if (bf->bf_state.bfs_nframes == 1) { - DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: single-frame aggregate\n", __func__); bf->bf_state.bfs_aggr = 0; /* Ensure the last descriptor link is 0 */ @@ -2837,7 +2833,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); ath_tx_set_ratectrl(sc, ni, bf); } else { - DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: multi-frame aggregate: %d frames, length %d\n", __func__, bf->bf_state.bfs_nframes, bf->bf_state.bfs_al); From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 12:55:50 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 DC61E1065670; Fri, 19 Aug 2011 12:55:50 +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 CCC758FC12; Fri, 19 Aug 2011 12:55:50 +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 p7JCtoPW004479; Fri, 19 Aug 2011 12:55:50 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7JCtoHb004477; Fri, 19 Aug 2011 12:55:50 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108191255.p7JCtoHb004477@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 12:55:50 +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: r225008 - 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, 19 Aug 2011 12:55:50 -0000 Author: adrian Date: Fri Aug 19 12:55:50 2011 New Revision: 225008 URL: http://svn.freebsd.org/changeset/base/225008 Log: Use the aggregate length when calculating the packet duration. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Fri Aug 19 12:48:06 2011 (r225007) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Fri Aug 19 12:55:50 2011 (r225008) @@ -176,6 +176,9 @@ ath_compute_num_delims(struct ath_softc * Setup a 11n rate series structure * * This should be called for both legacy and MCS rates. + * + * It, along with ath_buf_set_rate, must be called -after- a burst + * or aggregate is setup. */ static void ath_rateseries_setup(struct ath_softc *sc, struct ieee80211_node *ni, @@ -187,7 +190,7 @@ ath_rateseries_setup(struct ath_softc *s HAL_BOOL shortPreamble = AH_FALSE; const HAL_RATE_TABLE *rt = sc->sc_currates; int i; - int pktlen = bf->bf_state.bfs_pktlen; + int pktlen; int flags = bf->bf_state.bfs_flags; struct ath_rc_series *rc = bf->bf_state.bfs_rc; @@ -195,6 +198,15 @@ ath_rateseries_setup(struct ath_softc *s (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)) shortPreamble = AH_TRUE; + /* + * If this is the first frame in an aggregate series, + * use the aggregate length. + */ + if (bf->bf_state.bfs_aggr) + pktlen = bf->bf_state.bfs_al; + else + pktlen = bf->bf_state.bfs_pktlen; + memset(series, 0, sizeof(HAL_11N_RATE_SERIES) * 4); for (i = 0; i < 4; i++) { /* Only set flags for actual TX attempts */ From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 13:34: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 5A87F1065675; Fri, 19 Aug 2011 13:34: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 4AF4F8FC0C; Fri, 19 Aug 2011 13:34: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 p7JDY6To005737; Fri, 19 Aug 2011 13:34:06 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7JDY6iv005735; Fri, 19 Aug 2011 13:34:06 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108191334.p7JDY6iv005735@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 13:34: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: r225010 - 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, 19 Aug 2011 13:34:06 -0000 Author: adrian Date: Fri Aug 19 13:34:05 2011 New Revision: 225010 URL: http://svn.freebsd.org/changeset/base/225010 Log: Be consistent in the buffer free/completion path. 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 19 13:31:48 2011 (r225009) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 19 13:34:05 2011 (r225010) @@ -2094,7 +2094,7 @@ ath_tx_tid_free_pkts(struct ath_softc *s SEQNO(bf->bf_state.bfs_seqno)); ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); - ath_tx_freebuf(sc, bf, -1); + ath_tx_default_comp(sc, bf, -1); } } From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 15:14: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 0947E106566B; Fri, 19 Aug 2011 15:14:14 +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 EC6498FC0C; Fri, 19 Aug 2011 15:14: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 p7JFEDLm008776; Fri, 19 Aug 2011 15:14:13 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7JFEDXa008772; Fri, 19 Aug 2011 15:14:13 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108191514.p7JFEDXa008772@svn.freebsd.org> From: Adrian Chadd Date: Fri, 19 Aug 2011 15:14: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: r225012 - 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, 19 Aug 2011 15:14:14 -0000 Author: adrian Date: Fri Aug 19 15:14:13 2011 New Revision: 225012 URL: http://svn.freebsd.org/changeset/base/225012 Log: Add BAW state tracking to ensure I'm updating the BAW before freeing the ath_buf. Add locking around the BAW related code. Since the BAW can be modified by both net80211/ifnet context (ie interface TX) as well as the ath task (frame scheduling & completion), it needs to be locked. A node purge during active traffic could leave the BAW inconsistent. This has fixed some immediate issues with the TX hanging, but it hasn't fully fixed things. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Aug 19 13:41:00 2011 (r225011) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Aug 19 15:14:13 2011 (r225012) @@ -4156,6 +4156,10 @@ ath_tx_default_comp(struct ath_softc *sc st = ((bf->bf_txflags & HAL_TXDESC_NOACK) == 0) ? ts->ts_status : HAL_TXERR_XRETRY; + if (bf->bf_state.bfs_dobaw) + device_printf(sc->sc_dev, + "%s: dobaw should've been cleared!\n", __func__); + /* * Do any tx complete callback. Note this must * be done before releasing the node reference. 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 19 13:41:00 2011 (r225011) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 19 15:14:13 2011 (r225012) @@ -1721,6 +1721,9 @@ ath_tx_action_frame_override_queue(struc * * + fits inside the BAW; * + already has had a sequence number allocated. + * + * Since the BAW status may be modified by both the ath task and + * the net80211/ifnet contexts, the TID must be locked. */ void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an, @@ -1729,6 +1732,8 @@ ath_tx_addto_baw(struct ath_softc *sc, s int index, cindex; struct ieee80211_tx_ampdu *tap; + ATH_TXQ_LOCK_ASSERT(tid); + if (bf->bf_state.bfs_isretried) return; @@ -1765,6 +1770,9 @@ ath_tx_addto_baw(struct ath_softc *sc, s /* * seq_start - left edge of BAW * seq_next - current/next sequence number to allocate + * + * Since the BAW status may be modified by both the ath task and + * the net80211/ifnet contexts, the TID must be locked. */ static void ath_tx_update_baw(struct ath_softc *sc, struct ath_node *an, @@ -1773,6 +1781,8 @@ ath_tx_update_baw(struct ath_softc *sc, int index, cindex; struct ieee80211_tx_ampdu *tap; + ATH_TXQ_LOCK_ASSERT(tid); + tap = ath_tx_get_tx_tid(an, tid->tid); index = ATH_BA_INDEX(tap->txa_start, seqno); cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); @@ -2089,9 +2099,11 @@ ath_tx_tid_free_pkts(struct ath_softc *s * the BAW. */ if (ath_tx_ampdu_running(sc, an, tid) && - bf->bf_state.bfs_dobaw) + bf->bf_state.bfs_dobaw) { ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + bf->bf_state.bfs_dobaw = 0; + } ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); ath_tx_default_comp(sc, bf, -1); @@ -2224,6 +2236,7 @@ ath_tx_cleanup(struct ath_softc *sc, str if (bf->bf_state.bfs_dobaw) ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + bf->bf_state.bfs_dobaw = 0; /* * Call the default completion handler with "fail" just * so upper levels are suitably notified about this. @@ -2251,6 +2264,8 @@ ath_tx_cleanup(struct ath_softc *sc, str * not yet ACKed. */ tap = ath_tx_get_tx_tid(an, tid); + /* Need the lock - fiddling with BAW */ + ATH_TXQ_LOCK(atid); while (atid->baw_head != atid->baw_tail) { if (atid->tx_buf[atid->baw_head]) { atid->incomp++; @@ -2260,6 +2275,7 @@ ath_tx_cleanup(struct ath_softc *sc, str INCR(atid->baw_head, ATH_TID_MAX_BUFS); INCR(tap->txa_start, IEEE80211_SEQ_RANGE); } + ATH_TXQ_UNLOCK(atid); /* * If cleanup is required, defer TID scheduling @@ -2314,9 +2330,13 @@ ath_tx_aggr_retry_unaggr(struct ath_soft sc->sc_stats.ast_tx_swretrymax++; /* Update BAW anyway */ - if (bf->bf_state.bfs_dobaw) + if (bf->bf_state.bfs_dobaw) { + ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + ATH_TXQ_UNLOCK(atid); + } + bf->bf_state.bfs_dobaw = 0; /* Send BAR frame */ /* @@ -2369,8 +2389,10 @@ ath_tx_aggr_retry_unaggr(struct ath_soft */ if (bf->bf_flags & ATH_BUF_BUSY) { bf->bf_flags &= ~ ATH_BUF_BUSY; +#if 0 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: bf %p: ATH_BUF_BUSY\n", __func__, bf); +#endif } /* @@ -2409,7 +2431,10 @@ ath_tx_retry_subframe(struct ath_softc * if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { device_printf(sc->sc_dev, "%s: max retries: seqno %d\n", __func__, SEQNO(bf->bf_state.bfs_seqno)); + ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + bf->bf_state.bfs_dobaw = 0; + ATH_TXQ_UNLOCK(atid); /* XXX subframe completion status? is that valid here? */ ath_tx_default_comp(sc, bf, 0); return 1; @@ -2417,8 +2442,10 @@ ath_tx_retry_subframe(struct ath_softc * if (bf->bf_flags & ATH_BUF_BUSY) { bf->bf_flags &= ~ ATH_BUF_BUSY; +#if 0 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: bf %p: ATH_BUF_BUSY\n", __func__, bf); +#endif } ath_tx_set_retry(sc, bf); @@ -2617,8 +2644,11 @@ ath_tx_aggr_comp_aggr(struct ath_softc * ATH_BA_ISSET(ba, ba_index)); if (tx_ok && ATH_BA_ISSET(ba, ba_index)) { + ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + ATH_TXQ_UNLOCK(atid); + bf->bf_state.bfs_dobaw = 0; ath_tx_default_comp(sc, bf, 0); } else { drops += ath_tx_retry_subframe(sc, bf, &bf_q); @@ -2714,8 +2744,12 @@ ath_tx_aggr_comp_unaggr(struct ath_softc /* Success? Complete */ DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: TID=%d, seqno %d\n", __func__, tid, SEQNO(bf->bf_state.bfs_seqno)); - if (bf->bf_state.bfs_dobaw) + if (bf->bf_state.bfs_dobaw) { + ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + bf->bf_state.bfs_dobaw = 0; + ATH_TXQ_UNLOCK(atid); + } ath_tx_default_comp(sc, bf, fail); /* bf is freed at this point */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Fri Aug 19 13:41:00 2011 (r225011) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Fri Aug 19 15:14:13 2011 (r225012) @@ -486,9 +486,16 @@ ath_tx_form_aggr(struct ath_softc *sc, s * this packet is part of an aggregate. */ ATH_TXQ_REMOVE(tid, bf, bf_list); - ATH_TXQ_UNLOCK(tid); + /* The TID lock is required for the BAW update */ ath_tx_addto_baw(sc, an, tid, bf); + ATH_TXQ_UNLOCK(tid); + + /* + * Add the now owned buffer (which isn't + * on the software TXQ any longer) to our + * aggregate frame list. + */ TAILQ_INSERT_TAIL(bf_q, bf, bf_list); nframes ++; From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 21:58:50 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 A424F106564A; Fri, 19 Aug 2011 21:58:50 +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 955C08FC0C; Fri, 19 Aug 2011 21:58:50 +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 p7JLwoWn021656; Fri, 19 Aug 2011 21:58:50 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7JLwoXY021654; Fri, 19 Aug 2011 21:58:50 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108192158.p7JLwoXY021654@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 19 Aug 2011 21:58:50 +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: r225019 - 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, 19 Aug 2011 21:58:50 -0000 Author: gabor Date: Fri Aug 19 21:58:50 2011 New Revision: 225019 URL: http://svn.freebsd.org/changeset/base/225019 Log: - Use xfree() instead of free() Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Fri Aug 19 21:33:46 2011 (r225018) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Fri Aug 19 21:58:50 2011 (r225019) @@ -1886,7 +1886,7 @@ tre_compile(regex_t *preg, const tre_cha } else { - free(shortcut); + xfree(shortcut); preg->shortcut = NULL; } From owner-svn-src-user@FreeBSD.ORG Fri Aug 19 21:59: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 A73FC1065672; Fri, 19 Aug 2011 21:59: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 987D78FC12; Fri, 19 Aug 2011 21:59: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 p7JLxl9d021719; Fri, 19 Aug 2011 21:59:47 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7JLxlCW021717; Fri, 19 Aug 2011 21:59:47 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108192159.p7JLxlCW021717@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 19 Aug 2011 21:59: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: r225020 - 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, 19 Aug 2011 21:59:47 -0000 Author: gabor Date: Fri Aug 19 21:59:47 2011 New Revision: 225020 URL: http://svn.freebsd.org/changeset/base/225020 Log: - Fix compilation by adding forgotten variable declaration 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 19 21:58:50 2011 (r225019) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Aug 19 21:59:47 2011 (r225020) @@ -121,6 +121,8 @@ tre_fastncomp(fastmatch_t *preg, const c int tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags) { + size_t len; + if (cflags & REG_PEND) { len = (preg->re_endp >= regex) @@ -135,6 +137,8 @@ tre_fixcomp(fastmatch_t *preg, const cha int tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags) { + size_t len; + if (cflags & REG_PEND) { len = (preg->re_endp >= regex) From owner-svn-src-user@FreeBSD.ORG Sat Aug 20 06:08:31 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 A8C231065670; Sat, 20 Aug 2011 06:08:31 +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 96BEA8FC12; Sat, 20 Aug 2011 06:08:31 +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 p7K68VO8036653; Sat, 20 Aug 2011 06:08:31 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7K68VhV036645; Sat, 20 Aug 2011 06:08:31 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108200608.p7K68VhV036645@svn.freebsd.org> From: Adrian Chadd Date: Sat, 20 Aug 2011 06:08:31 +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: r225021 - 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, 20 Aug 2011 06:08:31 -0000 Author: adrian Date: Sat Aug 20 06:08:31 2011 New Revision: 225021 URL: http://svn.freebsd.org/changeset/base/225021 Log: Another combined diff - partly debugging, partly implementing more aggregation related stuff. Debugging/enforcing (which I'll likely remove at some point, or at least make optional): * Remove ath_buf's from the aggregate list - ie, blank bf->bf_next - when they've been handled and they're being requeued or completed. * Print out a message ath_tx_default_comp() if the ath_buf in question is still on an aggregation list. * Check whether the number of buffers handled in the aggregate frame completion or aggregate frame error functions match the number of frames -in- the aggregate buffer list. Print out an error if this isn't the case. Aggregation changes: * Fill out the rest of the ath_rc_series fields in the ath_buf - max4msframelen and the flags fields. This is done after the rate control decisions have been made in the (raw, normal) TX path. Later on, this will be pushed into the rate control module and then, much later on, it'll be pushed into net80211. * Implement the rest of the ampdu delimiter calculation code. The ampdu density figure, negotiated in STA mode and configured in hostap mode, is enforced when calculating delimiter counts. It uses the "fastest" rate (ie, the first one) to calculate how long a frame will be (in bytes) at the given rate/config, and then enforces that the configured delimiter count matches at least -that- length. If a sub-frame length is smaller than the configured mpdudensity, the delimiter count is the minimum density, rather than soley based on the frame count. * Implement a very simple function to return the maximum frame length for 4ms, based on the slowest rate. If the rate control returns a set of rate series rather than a single one, the aggregate may end up being transmitted at the slowest rather than the fastest. A lot of stuff that has been shoehorned into if_ath_tx_ht.c should likely live elsewhere, including the HAL and net80211. I'll worry about where to place all of this once the code is (more) stable. Obtained from: Atheros, Linux ath9k Modified: user/adrian/if_ath_tx/sys/dev/ath/README user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Modified: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/README Fri Aug 19 21:59:47 2011 (r225020) +++ user/adrian/if_ath_tx/sys/dev/ath/README Sat Aug 20 06:08:31 2011 (r225021) @@ -1,3 +1,18 @@ +Things to debug! + +* Write something in ath_tx_default_comp() that ensures the buffer is unlinked + (ie, not part of an aggregate) + +* Write something in the aggr comp function which checks that the number of + frames in the aggregate list matches bf_stats.bfs_nframes + - Done + +* Am I losing an ath_buf in the hardware TX queue code? Ie, are they not + ever queued? + +* Is it some missing sequence numbers? ie, is addto_baw being called with + sequence numbers out of order, or "gaps" in the sequence numbers? + Things that need doing! * RIFS? Do I care about supporting RIFS? Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Aug 19 21:59:47 2011 (r225020) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sat Aug 20 06:08:31 2011 (r225021) @@ -4159,6 +4159,9 @@ ath_tx_default_comp(struct ath_softc *sc if (bf->bf_state.bfs_dobaw) device_printf(sc->sc_dev, "%s: dobaw should've been cleared!\n", __func__); + if (bf->bf_next != NULL) + device_printf(sc->sc_dev, + "%s: bf_next not NULL!\n", __func__); /* * Do any tx complete callback. Note this must 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 19 21:59:47 2011 (r225020) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sat Aug 20 06:08:31 2011 (r225021) @@ -1273,6 +1273,12 @@ ath_tx_start(struct ath_softc *sc, struc /* At this point m0 could have changed! */ m0 = bf->bf_m; + /* + * ath_tx_normal_setup() has done the single and multi-rate + * retry rate lookup for us. Fill in the rcflags based on + * that. + */ + ath_tx_rate_fill_rcflags(sc, bf); #if 1 /* * If it's a multicast frame, do a direct-dispatch to the @@ -1510,6 +1516,11 @@ ath_tx_raw_start(struct ath_softc *sc, s bf->bf_state.bfs_rc[2].tries = params->ibp_try2; bf->bf_state.bfs_rc[3].tries = params->ibp_try3; } + /* + * All the required rate control decisions have been made; + * fill in the rc flags. + */ + ath_tx_rate_fill_rcflags(sc, bf); /* NB: no buffered multicast in power save support */ @@ -2478,6 +2489,7 @@ ath_tx_comp_aggr_error(struct ath_softc bf = bf_first; while (bf) { bf_next = bf->bf_next; + bf->bf_next = NULL; /* Remove it from the aggr list */ drops += ath_tx_retry_subframe(sc, bf, &bf_q); bf = bf_next; } @@ -2540,6 +2552,7 @@ ath_tx_comp_cleanup_aggr(struct ath_soft while (bf) { atid->incomp--; bf_next = bf->bf_next; + bf->bf_next = NULL; /* Remove it from the aggr list */ ath_tx_default_comp(sc, bf, -1); bf = bf_next; } @@ -2580,6 +2593,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * int ba_index; int drops = 0; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + int np = 0; DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called\n", __func__); @@ -2635,8 +2649,10 @@ ath_tx_aggr_comp_aggr(struct ath_softc * bf = bf_first; while (bf) { + np++; ba_index = ATH_BA_INDEX(seq_st, SEQNO(bf->bf_state.bfs_seqno)); bf_next = bf->bf_next; + bf->bf_next = NULL; /* Remove it from the aggr list */ DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: checking bf=%p seqno=%d; ack=%d\n", @@ -2656,6 +2672,10 @@ ath_tx_aggr_comp_aggr(struct ath_softc * bf = bf_next; } + if (np != bf_first->bf_state.bfs_nframes) + device_printf(sc->sc_dev, "%s: np=%d; nframes=%d\n", + __func__, np, bf_first->bf_state.bfs_nframes); + /* update rate control module about aggregate status */ /* XXX TODO */ 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 Fri Aug 19 21:59:47 2011 (r225020) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Sat Aug 20 06:08:31 2011 (r225021) @@ -44,6 +44,11 @@ #define WME_MAX_BA WME_BA_BMP_SIZE /* + * How 'busy' to try and keep the hardware txq + */ +#define ATH_AGGR_MIN_QDEPTH 2 + +/* * return whether a bit at index _n in bitmap _bm is set * _sz is the size of the bitmap */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Fri Aug 19 21:59:47 2011 (r225020) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Sat Aug 20 06:08:31 2011 (r225021) @@ -88,6 +88,8 @@ __FBSDID("$FreeBSD$"); #include /* XXX for some support functions */ #include +#include +#include /* * XXX net80211? @@ -135,19 +137,196 @@ int ath_max_4ms_framelen[4][32] = { }; /* + * XXX should be in net80211 + */ +static int ieee80211_mpdudensity_map[] = { + 0, /* IEEE80211_HTCAP_MPDUDENSITY_NA */ + 25, /* IEEE80211_HTCAP_MPDUDENSITY_025 */ + 50, /* IEEE80211_HTCAP_MPDUDENSITY_05 */ + 100, /* IEEE80211_HTCAP_MPDUDENSITY_1 */ + 200, /* IEEE80211_HTCAP_MPDUDENSITY_2 */ + 400, /* IEEE80211_HTCAP_MPDUDENSITY_4 */ + 800, /* IEEE80211_HTCAP_MPDUDENSITY_8 */ + 1600, /* IEEE80211_HTCAP_MPDUDENSITY_16 */ +}; + +/* + * XXX should be in the HAL/net80211 ? + */ +#define BITS_PER_BYTE 8 +#define OFDM_PLCP_BITS 22 +#define HT_RC_2_MCS(_rc) ((_rc) & 0x7f) +#define HT_RC_2_STREAMS(_rc) ((((_rc) & 0x78) >> 3) + 1) +#define L_STF 8 +#define L_LTF 8 +#define L_SIG 4 +#define HT_SIG 8 +#define HT_STF 4 +#define HT_LTF(_ns) (4 * (_ns)) +#define SYMBOL_TIME(_ns) ((_ns) << 2) // ns * 4 us +#define SYMBOL_TIME_HALFGI(_ns) (((_ns) * 18 + 4) / 5) // ns * 3.6 us +#define NUM_SYMBOLS_PER_USEC(_usec) (_usec >> 2) +#define NUM_SYMBOLS_PER_USEC_HALFGI(_usec) (((_usec*5)-4)/18) +#define IS_HT_RATE(_rate) ((_rate) & 0x80) + +const uint32_t bits_per_symbol[][2] = { + /* 20MHz 40MHz */ + { 26, 54 }, // 0: BPSK + { 52, 108 }, // 1: QPSK 1/2 + { 78, 162 }, // 2: QPSK 3/4 + { 104, 216 }, // 3: 16-QAM 1/2 + { 156, 324 }, // 4: 16-QAM 3/4 + { 208, 432 }, // 5: 64-QAM 2/3 + { 234, 486 }, // 6: 64-QAM 3/4 + { 260, 540 }, // 7: 64-QAM 5/6 + { 52, 108 }, // 8: BPSK + { 104, 216 }, // 9: QPSK 1/2 + { 156, 324 }, // 10: QPSK 3/4 + { 208, 432 }, // 11: 16-QAM 1/2 + { 312, 648 }, // 12: 16-QAM 3/4 + { 416, 864 }, // 13: 64-QAM 2/3 + { 468, 972 }, // 14: 64-QAM 3/4 + { 520, 1080 }, // 15: 64-QAM 5/6 + { 78, 162 }, // 16: BPSK + { 156, 324 }, // 17: QPSK 1/2 + { 234, 486 }, // 18: QPSK 3/4 + { 312, 648 }, // 19: 16-QAM 1/2 + { 468, 972 }, // 20: 16-QAM 3/4 + { 624, 1296 }, // 21: 64-QAM 2/3 + { 702, 1458 }, // 22: 64-QAM 3/4 + { 780, 1620 }, // 23: 64-QAM 5/6 + { 104, 216 }, // 24: BPSK + { 208, 432 }, // 25: QPSK 1/2 + { 312, 648 }, // 26: QPSK 3/4 + { 416, 864 }, // 27: 16-QAM 1/2 + { 624, 1296 }, // 28: 16-QAM 3/4 + { 832, 1728 }, // 29: 64-QAM 2/3 + { 936, 1944 }, // 30: 64-QAM 3/4 + { 1040, 2160 }, // 31: 64-QAM 5/6 +}; + +/* + * Fill in the rate array information based on the current + * node configuration and the choices made by the rate + * selection code and ath_buf setup code. + * + * Later on, this may end up also being made by the + * rate control code, but for now it can live here. + * + * This needs to be called just before the packet is + * queued to the software queue or hardware queue, + * so all of the needed fields in bf_state are setup. + */ +void +ath_tx_rate_fill_rcflags(struct ath_softc *sc, struct ath_buf *bf) +{ + struct ieee80211_node *ni = bf->bf_node; + struct ieee80211com *ic = ni->ni_ic; + const HAL_RATE_TABLE *rt = sc->sc_currates; + struct ath_rc_series *rc = bf->bf_state.bfs_rc; + uint8_t rate; + int i; + + for (i = 0; i < ATH_RC_NUM; i++) { + rc[i].flags = 0; + if (rc[i].tries == 0) + continue; + + rate = rt->info[rc[i].rix].rateCode; + + if (bf->bf_state.bfs_flags & + (HAL_TXDESC_RTSENA | HAL_TXDESC_CTSENA)) + rc[i].flags |= ATH_RC_RTSCTS_FLAG; + + /* Only enable shortgi, 2040, dual-stream if HT is set */ + if (IS_HT_RATE(rate)) { + rc[i].flags |= ATH_RC_HT_FLAG; + + if (ni->ni_chw == 40) + rc[i].flags |= ATH_RC_CW40_FLAG; + + if (ni->ni_chw == 40 && + ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40 && + ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) + rc[i].flags |= ATH_RC_SGI_FLAG; + + if (ni->ni_chw == 20 && + ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20 && + ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20) + rc[i].flags |= ATH_RC_SGI_FLAG; + + /* XXX dual stream? and 3-stream? */ + } + + /* + * Calculate the maximum 4ms frame length based + * on the MCS rate, SGI and channel width flags. + */ + if ((rc[i].flags & ATH_RC_HT_FLAG) && + (HT_RC_2_MCS(rate) < 32)) { + int j; + if (rc[i].flags & ATH_RC_CW40_FLAG) { + if (rc[i].flags & ATH_RC_SGI_FLAG) + j = MCS_HT40_SGI; + else + j = MCS_HT40; + } else { + if (rc[i].flags & ATH_RC_SGI_FLAG) + j = MCS_HT20_SGI; + else + j = MCS_HT20; + } + rc[i].max4msframelen = + ath_max_4ms_framelen[j][HT_RC_2_MCS(rate)]; + } else + rc[i].max4msframelen = 0; +#if 0 + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, + "%s: i=%d, rate=0x%x, flags=0x%x, max4ms=%d\n", + __func__, i, rate, rc[i].flags, rc[i].max4msframelen); +#endif + } +} + +/* * Return the number of delimiters to be added to * meet the minimum required mpdudensity. + * * Caller should make sure that the rate is HT. * * TODO: is this delimiter calculation supposed to be the * total frame length, the hdr length, the data length (including * delimiters, padding, CRC, etc) or ? + * + * TODO: this should ensure that the rate control information + * HAS been setup for the first rate. + * + * TODO: ensure this is only called for MCS rates. + * + * TODO: enforce MCS < 31 */ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_buf *first_bf, uint16_t pktlen) { - int ndelim; + const HAL_RATE_TABLE *rt = sc->sc_currates; + struct ieee80211_node *ni = first_bf->bf_node; + struct ieee80211vap *vap = ni->ni_vap; + int ndelim, mindelim = 0; + int mpdudensity; /* in 1/100'th of a microsecond */ + uint8_t rc, rix, flags; + int width, half_gi; + uint32_t nsymbits, nsymbols; + uint16_t minlen; + + /* + * vap->iv_ampdu_density is a value, rather than the actual + * density. + */ + if (vap->iv_ampdu_density > IEEE80211_HTCAP_MPDUDENSITY_16) + mpdudensity = 1600; /* maximum density */ + else + mpdudensity = ieee80211_mpdudensity_map[vap->iv_ampdu_density]; /* Select standard number of delimiters based on frame length */ ndelim = ATH_AGGR_GET_NDELIM(pktlen); @@ -160,19 +339,85 @@ ath_compute_num_delims(struct ath_softc */ ndelim += ATH_AGGR_ENCRYPTDELIM; + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, + "%s: pktlen=%d, ndelim=%d, mpdudensity=%d\n", + __func__, pktlen, ndelim, mpdudensity); + /* * If the MPDU density is 0, we can return here. * Otherwise, we need to convert the desired mpdudensity * into a byte length, based on the rate in the subframe. - * - * XXX TODO: since the rate scenario hasn't been configured - * XXX yet, this is likely not going to work. So, for now, - * XXX ignore it. */ + if (mpdudensity == 0) + return ndelim; + + /* + * Convert desired mpdu density from microeconds to bytes based + * on highest rate in rate series (i.e. first rate) to determine + * required minimum length for subframe. Take into account + * whether high rate is 20 or 40Mhz and half or full GI. + */ + rix = first_bf->bf_state.bfs_rc[0].rix; + rc = rt->info[rix].rateCode; + flags = first_bf->bf_state.bfs_rc[0].flags; + width = !! (flags & ATH_RC_CW40_FLAG); + half_gi = !! (flags & ATH_RC_SGI_FLAG); + + /* + * mpdudensity is in 1/100th of a usec, so divide by 100 + */ + if (half_gi) + nsymbols = NUM_SYMBOLS_PER_USEC_HALFGI(mpdudensity); + else + nsymbols = NUM_SYMBOLS_PER_USEC(mpdudensity); + nsymbols /= 100; + + if (nsymbols == 0) + nsymbols = 1; + + nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width]; + minlen = (nsymbols * nsymbits) / BITS_PER_BYTE; + + /* + * Min length is the minimum frame length for the + * required MPDU density. + */ + if (pktlen < minlen) { + mindelim = (minlen - pktlen) / ATH_AGGR_DELIM_SZ; + ndelim = MAX(mindelim, ndelim); + } + + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, + "%s: pktlen=%d, minlen=%d, rix=%x, rc=%x, width=%d, hgi=%d, ndelim=%d\n", + __func__, pktlen, minlen, rix, rc, width, half_gi, ndelim); + return ndelim; } /* + * Fetch the aggregation limit. + * + * It's the lowest of the four rate series 4ms frame length. + */ +static int +ath_get_aggr_limit(struct ath_softc *sc, struct ath_buf *bf) +{ + int amin = 65530; + int i; + + for (i = 0; i < 4; i++) { + if (bf->bf_state.bfs_rc[i].tries == 0) + continue; + amin = MIN(amin, bf->bf_state.bfs_rc[i].max4msframelen); + } + + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: max frame len= %d\n", + __func__, amin); + + return amin; +} + +/* * Setup a 11n rate series structure * * This should be called for both legacy and MCS rates. @@ -207,6 +452,10 @@ ath_rateseries_setup(struct ath_softc *s else pktlen = bf->bf_state.bfs_pktlen; + /* + * XXX TODO: modify this routine to use the bfs_rc[x].flags + * XXX fields. + */ memset(series, 0, sizeof(HAL_11N_RATE_SERIES) * 4); for (i = 0; i < 4; i++) { /* Only set flags for actual TX attempts */ @@ -403,12 +652,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s h_baw = tap->txa_wnd / 2; - /* Calculate aggregation limit */ - /* - * XXX TODO: do not exceed 4ms packet length - */ - aggr_limit = 65530; /* XXX just for now, for testing */ - for (;;) { ATH_TXQ_LOCK(tid); bf = TAILQ_FIRST(&tid->axq_q); @@ -418,6 +661,13 @@ ath_tx_form_aggr(struct ath_softc *sc, s ATH_TXQ_UNLOCK(tid); status = ATH_AGGR_DONE; break; + } else { + /* + * It's the first frame; + * set the aggregation limit based on the + * rate control decision that has been made. + */ + aggr_limit = ath_get_aggr_limit(sc, bf_first); } /* Set this early just so things don't get confused */ @@ -442,6 +692,13 @@ ath_tx_form_aggr(struct ath_softc *sc, s } /* + * If any of the rates are non-HT, this packet + * can't be aggregated. + * XXX TODO: add a bf_state flag which gets marked + * if any active rate is non-HT. + */ + + /* * If the packet has a sequence number, do not * step outside of the block-ack window. */ @@ -481,7 +738,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s break; } - /* * this packet is part of an aggregate. */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Fri Aug 19 21:59:47 2011 (r225020) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.h Sat Aug 20 06:08:31 2011 (r225021) @@ -50,6 +50,8 @@ typedef enum { extern int ath_max_4ms_framelen[4][32]; +extern void ath_tx_rate_fill_rcflags(struct ath_softc *sc, struct ath_buf *bf); + extern void ath_buf_set_rate(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf); Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Fri Aug 19 21:59:47 2011 (r225020) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Sat Aug 20 06:08:31 2011 (r225021) @@ -79,6 +79,12 @@ void ath_rate_detach(struct ath_ratectrl #define ATH_RC_NUM 4 +#define ATH_RC_DS_FLAG 0x01 /* dual-stream rate */ +#define ATH_RC_CW40_FLAG 0x02 /* use HT40 */ +#define ATH_RC_SGI_FLAG 0x04 /* use short-GI */ +#define ATH_RC_HT_FLAG 0x08 /* use HT */ +#define ATH_RC_RTSCTS_FLAG 0x10 /* enable RTS/CTS protection */ + struct ath_rc_series { uint8_t rix; /* ratetable index, not rate code */ uint8_t tries; From owner-svn-src-user@FreeBSD.ORG Sat Aug 20 10:44: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 EE8061065672; Sat, 20 Aug 2011 10:44:13 +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 DE3888FC14; Sat, 20 Aug 2011 10:44: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 p7KAiDjg048395; Sat, 20 Aug 2011 10:44:13 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7KAiDr0048393; Sat, 20 Aug 2011 10:44:13 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108201044.p7KAiDr0048393@svn.freebsd.org> From: Adrian Chadd Date: Sat, 20 Aug 2011 10:44: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: r225025 - 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, 20 Aug 2011 10:44:14 -0000 Author: adrian Date: Sat Aug 20 10:44:13 2011 New Revision: 225025 URL: http://svn.freebsd.org/changeset/base/225025 Log: More things to look at and fix! 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 Sat Aug 20 09:31:52 2011 (r225024) +++ user/adrian/if_ath_tx/sys/dev/ath/README Sat Aug 20 10:44:13 2011 (r225025) @@ -2,6 +2,7 @@ Things to debug! * Write something in ath_tx_default_comp() that ensures the buffer is unlinked (ie, not part of an aggregate) + - Done * Write something in the aggr comp function which checks that the number of frames in the aggregate list matches bf_stats.bfs_nframes @@ -13,8 +14,60 @@ Things to debug! * Is it some missing sequence numbers? ie, is addto_baw being called with sequence numbers out of order, or "gaps" in the sequence numbers? +* Scheduler issues - add some statistics to track how many packets are going + out as aggregates (looks like around 84%) -and- what the distribution of + aggregate packets is like. Abuse a histogram - will only send up to 64 + aggregate packets at once, so track: + + + single packet returned from ath_tx_form_aggr() + + single packet with no BAW returned from ath_tx_form_aggr() + + single packet with non HT rate + + aggregate packets (ie, how many times were aggregates sent) + + aggregate sub-frame count histogram, 2->64 sub-frames + + I can't help but think we're sending very small aggregates. + +* The RX side (AR9160, FreeBSD) seems to lock up from time to time, with + stuck beacons and RXORN interrupts (ie, RX FIFO overflows.) Why? + +* There's the possibility that ampdu seqno packets have sequence numbers + allocated but are flushed -before- they're added to the BAW. + I guess this is why seqno allocation should be delayed until just before + it's queued to the hardware. + + That should be .. well, fixed. + Things that need doing! +* Add a swretrysubframe and swretrysubframemax counter, use it + +* Scheduling is wrong - the software TXQ needs more time to assemble + frames together for aggregation. + + Based on Linux ath9k: + + + Don't base it completely on how "deep" the hardware queue is, that + can involve multiple TIDs, not just one! + + If the TID has say, more than two hardware queued aggregate frames, + or more than say eight hardware-queued normal frames, don't schedule it. + + When the completion function is called, check to see if there are frames + in the queue and the frames queued to hardware has dropped. If so, + schedule the TID. If not, give the TID some more time to gather packets. + + The logic: + + + The MAC has to be kept busy enough to not wait around for data to send. + Not more, not less. + + Immediately handling a TID when the hardware is busy sending aggregate + frames is just plain silly - as it's already busy. So queuing the frames + to the hardware doesn't buy you anything, it doesn't decrease latency, etc. + + So instead, just feed it enough frames to keep the hardware queue busy, + and let the TID software queue gather up more frames. + + Finally, if the TID has a couple frames queued to the hardware + -and- there's only one frame to send, don't just queue it. + Wait until the completion handlers are called, then schedule the + queue function again. + * RIFS? Do I care about supporting RIFS? * Fast Frames? Do I care about supporting FF here, or is it done via suitable From owner-svn-src-user@FreeBSD.ORG Sat Aug 20 13:07:29 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 DB7C21065670; Sat, 20 Aug 2011 13:07:29 +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 CA6378FC0C; Sat, 20 Aug 2011 13:07:29 +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 p7KD7Two053039; Sat, 20 Aug 2011 13:07:29 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7KD7TuV053035; Sat, 20 Aug 2011 13:07:29 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108201307.p7KD7TuV053035@svn.freebsd.org> From: Adrian Chadd Date: Sat, 20 Aug 2011 13:07:29 +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: r225031 - 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, 20 Aug 2011 13:07:29 -0000 Author: adrian Date: Sat Aug 20 13:07:29 2011 New Revision: 225031 URL: http://svn.freebsd.org/changeset/base/225031 Log: Add some debugging to trace whether a packet has been added to the BAW before it's actually removed from it. It turns out that a node flush during active traffic would cause some frames to be freed before the frame was added to the BAW. This is why traffic exchange would (eventually) stop. For example: ath0: ath_tx_tid_free_pkts: wasn't added: seqno 3701 I'll have to see what Linux and the reference driver do here before I fix this. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.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 20 12:40:17 2011 (r225030) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sat Aug 20 13:07:29 2011 (r225031) @@ -1955,6 +1955,7 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_ndelim = 0; bf->bf_state.bfs_nframes = 0; bf->bf_state.bfs_al = 0; + bf->bf_state.bfs_addedbaw = 0; /* Queue frame to the tail of the software queue */ ATH_TXQ_LOCK(atid); @@ -2114,6 +2115,10 @@ ath_tx_tid_free_pkts(struct ath_softc *s ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); bf->bf_state.bfs_dobaw = 0; + if (! bf->bf_state.bfs_addedbaw) + device_printf(sc->sc_dev, + "%s: wasn't added: seqno %d\n", + __func__, SEQNO(bf->bf_state.bfs_seqno)); } ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); @@ -2160,6 +2165,9 @@ ath_tx_tid_cleanup(struct ath_softc *sc, int tid; struct ath_tid *atid; + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: node %p: cleaning up\n", + __func__, an); + /* Flush all packets currently in the sw queues for this node */ ath_tx_node_flush(sc, an); @@ -2244,9 +2252,14 @@ ath_tx_cleanup(struct ath_softc *sc, str bf_next = TAILQ_NEXT(bf, bf_list); TAILQ_REMOVE(&atid->axq_q, bf, bf_list); atid->axq_depth--; - if (bf->bf_state.bfs_dobaw) + if (bf->bf_state.bfs_dobaw) { ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + if (! bf->bf_state.bfs_addedbaw) + device_printf(sc->sc_dev, + "%s: wasn't added: seqno %d\n", + __func__, SEQNO(bf->bf_state.bfs_seqno)); + } bf->bf_state.bfs_dobaw = 0; /* * Call the default completion handler with "fail" just @@ -2346,6 +2359,10 @@ ath_tx_aggr_retry_unaggr(struct ath_soft ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); ATH_TXQ_UNLOCK(atid); + if (! bf->bf_state.bfs_addedbaw) + device_printf(sc->sc_dev, + "%s: wasn't added: seqno %d\n", + __func__, SEQNO(bf->bf_state.bfs_seqno)); } bf->bf_state.bfs_dobaw = 0; @@ -2444,6 +2461,10 @@ ath_tx_retry_subframe(struct ath_softc * __func__, SEQNO(bf->bf_state.bfs_seqno)); ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); + if (! bf->bf_state.bfs_addedbaw) + device_printf(sc->sc_dev, + "%s: wasn't added: seqno %d\n", + __func__, SEQNO(bf->bf_state.bfs_seqno)); bf->bf_state.bfs_dobaw = 0; ATH_TXQ_UNLOCK(atid); /* XXX subframe completion status? is that valid here? */ @@ -2665,6 +2686,10 @@ ath_tx_aggr_comp_aggr(struct ath_softc * SEQNO(bf->bf_state.bfs_seqno)); ATH_TXQ_UNLOCK(atid); bf->bf_state.bfs_dobaw = 0; + if (! bf->bf_state.bfs_addedbaw) + device_printf(sc->sc_dev, + "%s: wasn't added: seqno %d\n", + __func__, SEQNO(bf->bf_state.bfs_seqno)); ath_tx_default_comp(sc, bf, 0); } else { drops += ath_tx_retry_subframe(sc, bf, &bf_q); @@ -2768,6 +2793,10 @@ ath_tx_aggr_comp_unaggr(struct ath_softc ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); bf->bf_state.bfs_dobaw = 0; + if (! bf->bf_state.bfs_addedbaw) + device_printf(sc->sc_dev, + "%s: wasn't added: seqno %d\n", + __func__, SEQNO(bf->bf_state.bfs_seqno)); ATH_TXQ_UNLOCK(atid); } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Sat Aug 20 12:40:17 2011 (r225030) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Sat Aug 20 13:07:29 2011 (r225031) @@ -745,6 +745,7 @@ ath_tx_form_aggr(struct ath_softc *sc, s /* The TID lock is required for the BAW update */ ath_tx_addto_baw(sc, an, tid, bf); + bf->bf_state.bfs_addedbaw = 1; ATH_TXQ_UNLOCK(tid); /* 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 20 12:40:17 2011 (r225030) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sat Aug 20 13:07:29 2011 (r225031) @@ -208,6 +208,7 @@ struct ath_buf { int bfs_aggrburst:1; /* part of aggregate burst? */ int bfs_isretried:1; /* retried frame? */ int bfs_dobaw:1; /* actually check against BAW? */ + int bfs_addedbaw:1; /* has been added to the BAW */ int bfs_shpream:1; /* use short preamble */ int bfs_istxfrag:1; /* is fragmented */ int bfs_ismrr:1; /* do multi-rate TX retry */ From owner-svn-src-user@FreeBSD.ORG Sat Aug 20 16:34: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 4133C106566B; Sat, 20 Aug 2011 16:34:32 +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 D47B28FC0C; Sat, 20 Aug 2011 16:34:31 +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 p7KGYV17059919; Sat, 20 Aug 2011 16:34:31 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7KGYVn9059917; Sat, 20 Aug 2011 16:34:31 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108201634.p7KGYVn9059917@svn.freebsd.org> From: Adrian Chadd Date: Sat, 20 Aug 2011 16:34:31 +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: r225042 - 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, 20 Aug 2011 16:34:32 -0000 Author: adrian Date: Sat Aug 20 16:34:31 2011 New Revision: 225042 URL: http://svn.freebsd.org/changeset/base/225042 Log: More updates, now that: * I know what the current batch of BAW tracking failures are; * some discussions with Felix (nbd) and I about what this code and Linux ath9k are doing have given rise to some issues with channel changes (eg channel, 20/2040 change, mode, etc) and what this may do to software/hardware queued frames, etc. 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 Sat Aug 20 16:21:40 2011 (r225041) +++ user/adrian/if_ath_tx/sys/dev/ath/README Sat Aug 20 16:34:31 2011 (r225042) @@ -37,8 +37,37 @@ Things to debug! That should be .. well, fixed. + Yes, it's this. The problem is the cleanup, flush, drain handling. + What I need to do is: + + * for interface -teardown-, the frames can be completed. + * for interface -flush-, complete the retries as failed?, and reschedule + the frames on the queue. + - the problem - what if that flush is a mode change? + - or what else? 20/40 change? rate change? etc. + * for interface -cleanup-, ? + * drain? + + Things that need doing! +* Handle channel/mode changes which shouldn't flush packets in the + software queue (and the packets in the hardware queue that can + be recovered after TX DMA is stopped..) + + eg a mode change which changes the channel (2/5ghz), or ht<->non-ht, + or 40<->20mhz modes - these may end up with packets in the software + queue which can't be supported by the new operating mode. + + How to fix? :-) + +* Perhaps delay the rate lookup until the packet is being hardware queued, + rather than doing the rate decision at ath_tx_raw_xmit() / ath_tx_start(); +* .. and since raw queued frames may have invalid rate information, enforce + valid rate/flags when the packet is being hardware queued. +* .. this also will allow for rate lookups to be done on retried frames, + which may help with reliability. +* Find where in the driver the rate table is updated, and do what? Trigger + updating the software-queued frames? Or? + * Add a swretrysubframe and swretrysubframemax counter, use it * Scheduling is wrong - the software TXQ needs more time to assemble From owner-svn-src-user@FreeBSD.ORG Sat Aug 20 17:11:51 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 C0F731065674; Sat, 20 Aug 2011 17:11:51 +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 B21518FC1D; Sat, 20 Aug 2011 17:11:51 +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 p7KHBpJm061210; Sat, 20 Aug 2011 17:11:51 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7KHBpdB061208; Sat, 20 Aug 2011 17:11:51 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108201711.p7KHBpdB061208@svn.freebsd.org> From: Adrian Chadd Date: Sat, 20 Aug 2011 17:11:51 +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: r225045 - 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, 20 Aug 2011 17:11:51 -0000 Author: adrian Date: Sat Aug 20 17:11:51 2011 New Revision: 225045 URL: http://svn.freebsd.org/changeset/base/225045 Log: * Add some debugging to announce functions which call ath_tx_flushtxq(). * Disable ath_tx_flushtxq() for ath_reset(), on a hunch. It likely isn't needed. * Add some more comments about what's going on and what the implications seem to be flushing the TXQ there. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sat Aug 20 17:05:11 2011 (r225044) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sat Aug 20 17:11:51 2011 (r225045) @@ -1137,6 +1137,8 @@ ath_vap_delete(struct ieee80211vap *vap) struct ath_hal *ah = sc->sc_ah; struct ath_vap *avp = ATH_VAP(vap); + DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { /* * Quiesce the hardware while we remove the vap. In @@ -1145,6 +1147,7 @@ ath_vap_delete(struct ieee80211vap *vap) */ ath_hal_intrset(ah, 0); /* disable interrupts */ ath_draintxq(sc); /* stop hw xmit side */ + /* XXX Do all frames from all vaps/nodes need draining here? */ ath_sc_flushtxq(sc); /* drain sw xmit side */ ath_stoprecv(sc); /* stop recv side */ } @@ -1169,6 +1172,7 @@ ath_vap_delete(struct ieee80211vap *vap) */ ath_draintxq(sc); + /* XXX Do all frames from all vaps/nodes need draining here? */ ath_sc_flushtxq(sc); ATH_LOCK(sc); @@ -1745,6 +1749,10 @@ ath_stop_locked(struct ifnet *ifp) ath_hal_intrset(ah, 0); } ath_draintxq(sc); + /* + * XXX Draining these packets may create a hole in the + * XXX BAW. + */ ath_sc_flushtxq(sc); /* drain sw xmit side */ if (!sc->sc_invalid) { ath_stoprecv(sc); @@ -1780,9 +1788,23 @@ ath_reset(struct ifnet *ifp) struct ath_hal *ah = sc->sc_ah; HAL_STATUS status; + DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__); + ath_hal_intrset(ah, 0); /* disable interrupts */ ath_draintxq(sc); /* stop xmit side */ + /* + * XXX as long as ath_reset() isn't called during a state + * transition (eg channel change, mode change, etc) + * then there's no need to flush the software TXQ. + * Doing this here messes with the BAW tracking, as + * there may be aggregate packets in the software TXQ + * which haven't been queued to the hardware, and thus + * the BAW hasn't been set. Freeing those packets will + * create a "hole" in the BAW. + */ +#if 0 ath_sc_flushtxq(sc); /* drain sw xmit side */ +#endif ath_stoprecv(sc); /* stop recv side */ ath_settkipmic(sc); /* configure TKIP MIC handling */ /* NB: indicate channel change so we do a full reset */ @@ -4669,6 +4691,17 @@ ath_chan_set(struct ath_softc *sc, struc */ ath_hal_intrset(ah, 0); /* disable interrupts */ ath_draintxq(sc); /* clear pending tx frames */ + /* + * XXX This may create holes in the BAW, since some + * XXX aggregate packets may have not yet been scheduled + * XXX to the hardware, and thus ath_tx_addto_baw() has + * XXX never been called. + * + * But we can't _not_ call this here, because the current + * TX code doesn't handle the potential rate/flags change + * (eg a 40->20mhz change, or HT->non-HT change, or 11a<->g + * change, etc.) + */ ath_sc_flushtxq(sc); /* drain sw xmit side */ ath_stoprecv(sc); /* turn off frame recv */ if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE, &status)) {