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;