From owner-svn-src-head@FreeBSD.ORG Tue Feb 22 00:37:53 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A8D3106566B; Tue, 22 Feb 2011 00:37: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 579768FC18; Tue, 22 Feb 2011 00:37:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1M0brn0088273; Tue, 22 Feb 2011 00:37:53 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1M0brv3088271; Tue, 22 Feb 2011 00:37:53 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201102220037.p1M0brv3088271@svn.freebsd.org> From: Adrian Chadd Date: Tue, 22 Feb 2011 00:37:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218932 - head/sys/dev/ath X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2011 00:37:53 -0000 Author: adrian Date: Tue Feb 22 00:37:53 2011 New Revision: 218932 URL: http://svn.freebsd.org/changeset/base/218932 Log: Shuffle around the RTS/CTS rate/duration logic. * Turn ath_tx_calc_ctsduration() into a function that returns the ctsduration, or -1 for HT rates; * add a printf() to ath_tx_calc_ctsduration() which will be very loud if somehow that function is called with an MCS rate; * Add ath_tx_get_rtscts_rate() which returns the RTS/CTS rate to use for the given data rate, incl. the short preamble flag; * Only call ath_tx_calc_ctsduration() for non-11n chipsets; 11n chipsets don't require the rtscts duration to be calculated. Modified: head/sys/dev/ath/if_ath_tx.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Tue Feb 22 00:01:19 2011 (r218931) +++ head/sys/dev/ath/if_ath_tx.c Tue Feb 22 00:37:53 2011 (r218932) @@ -420,11 +420,12 @@ ath_tx_tag_crypto(struct ath_softc *sc, return 1; } -static void -ath_tx_calc_ctsduration(struct ath_hal *ah, int rix, int cix, - int shortPreamble, int pktlen, const HAL_RATE_TABLE *rt, - int flags, u_int8_t *ctsrate, int *ctsduration) +static uint8_t +ath_tx_get_rtscts_rate(struct ath_hal *ah, const HAL_RATE_TABLE *rt, + int rix, int cix, int shortPreamble) { + uint8_t ctsrate; + /* * CTS transmit rate is derived from the transmit rate * by looking in the h/w rate table. We must also factor @@ -432,7 +433,33 @@ ath_tx_calc_ctsduration(struct ath_hal * */ /* NB: cix is set above where RTS/CTS is enabled */ KASSERT(cix != 0xff, ("cix not setup")); - (*ctsrate) = rt->info[cix].rateCode; + ctsrate = rt->info[cix].rateCode; + + /* XXX this should only matter for legacy rates */ + if (shortPreamble) + ctsrate |= rt->info[cix].shortPreamble; + + return ctsrate; +} + + +/* + * Calculate the RTS/CTS duration for legacy frames. + */ +static int +ath_tx_calc_ctsduration(struct ath_hal *ah, int rix, int cix, + int shortPreamble, int pktlen, const HAL_RATE_TABLE *rt, + int flags) +{ + int ctsduration = 0; + + /* This mustn't be called for HT modes */ + if (rt->info[cix].phy == IEEE80211_T_HT) { + printf("%s: HT rate where it shouldn't be (0x%x)\n", + __func__, rt->info[cix].rateCode); + return -1; + } + /* * Compute the transmit duration based on the frame * size and the size of an ACK frame. We call into the @@ -443,21 +470,22 @@ ath_tx_calc_ctsduration(struct ath_hal * * use the precalculated ACK durations. */ if (shortPreamble) { - (*ctsrate) |= rt->info[cix].shortPreamble; if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */ - (*ctsduration) += rt->info[cix].spAckDuration; - (*ctsduration) += ath_hal_computetxtime(ah, + ctsduration += rt->info[cix].spAckDuration; + ctsduration += ath_hal_computetxtime(ah, rt, pktlen, rix, AH_TRUE); if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */ - (*ctsduration) += rt->info[rix].spAckDuration; + ctsduration += rt->info[rix].spAckDuration; } else { if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */ - (*ctsduration) += rt->info[cix].lpAckDuration; - (*ctsduration) += ath_hal_computetxtime(ah, + ctsduration += rt->info[cix].lpAckDuration; + ctsduration += ath_hal_computetxtime(ah, rt, pktlen, rix, AH_FALSE); if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */ - (*ctsduration) += rt->info[rix].lpAckDuration; + ctsduration += rt->info[rix].lpAckDuration; } + + return ctsduration; } int @@ -714,8 +742,12 @@ ath_tx_start(struct ath_softc *sc, struc */ ctsduration = 0; if (flags & (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)) { - (void) ath_tx_calc_ctsduration(ah, rix, cix, shortPreamble, pktlen, - rt, flags, &ctsrate, &ctsduration); + ctsrate = ath_tx_get_rtscts_rate(ah, rt, rix, cix, shortPreamble); + + /* The 11n chipsets do ctsduration calculations for you */ + if (! ath_tx_is_11n(sc)) + ctsduration = ath_tx_calc_ctsduration(ah, rix, cix, shortPreamble, + pktlen, rt, flags); /* * Must disable multi-rate retry when using RTS/CTS. */ @@ -893,9 +925,12 @@ ath_tx_raw_start(struct ath_softc *sc, s ctsduration = 0; if (flags & (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)) { cix = ath_tx_findrix(sc, params->ibp_ctsrate); - (void) ath_tx_calc_ctsduration(ah, rix, cix, - params->ibp_flags & IEEE80211_BPF_SHORTPRE, pktlen, - rt, flags, &ctsrate, &ctsduration); + ctsrate = ath_tx_get_rtscts_rate(ah, rt, rix, cix, params->ibp_flags & IEEE80211_BPF_SHORTPRE); + /* The 11n chipsets do ctsduration calculations for you */ + if (! ath_tx_is_11n(sc)) + ctsduration = ath_tx_calc_ctsduration(ah, rix, cix, + params->ibp_flags & IEEE80211_BPF_SHORTPRE, pktlen, + rt, flags); /* * Must disable multi-rate retry when using RTS/CTS. */