svn commit: r218932 - head/sys/dev/ath
Adrian Chadd
adrian at FreeBSD.org
Tue Feb 22 00:37:53 UTC 2011
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.
*/
More information about the svn-src-all
mailing list