summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2011-02-22 00:37:53 +0000
committeradrian <adrian@FreeBSD.org>2011-02-22 00:37:53 +0000
commita186021311f64b0401dcfe1485d103a556f01655 (patch)
tree9790a627250d1c0522060a831701e600aa9832c6 /sys/dev
parent66c3d76f69e25a5e997a0262d906406ccd1116bf (diff)
downloadFreeBSD-src-a186021311f64b0401dcfe1485d103a556f01655.zip
FreeBSD-src-a186021311f64b0401dcfe1485d103a556f01655.tar.gz
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.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ath/if_ath_tx.c69
1 files changed, 52 insertions, 17 deletions
diff --git a/sys/dev/ath/if_ath_tx.c b/sys/dev/ath/if_ath_tx.c
index e38ada1..d889858 100644
--- a/sys/dev/ath/if_ath_tx.c
+++ b/sys/dev/ath/if_ath_tx.c
@@ -420,11 +420,12 @@ ath_tx_tag_crypto(struct ath_softc *sc, struct ieee80211_node *ni,
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 *ah, int rix, int cix,
*/
/* 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 *ah, int rix, int cix,
* 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, struct ieee80211_node *ni, struct ath_buf *bf
*/
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, struct ieee80211_node *ni,
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.
*/
OpenPOWER on IntegriCloud