]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mac80211: fix CTS protection handling
authorFelix Fietkau <nbd@openwrt.org>
Tue, 16 Apr 2013 11:38:43 +0000 (13:38 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 16 Apr 2013 21:42:30 +0000 (23:42 +0200)
The rates[0] CTS and RTS flags are only set after rate control has been
called, so minstrel cannot use them to for setting the number of
retries. This patch adds two new flags to explicitly indicate RTS/CTS use.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/rc80211_minstrel.c
net/mac80211/tx.c

index 05dbb97885043bc172f75c20739b9c53cf29d8dd..4f693a5c54de85e4439c9770cb7391aef79a7250 100644 (file)
@@ -655,7 +655,9 @@ struct ieee80211_tx_info {
                                        struct ieee80211_tx_rate rates[
                                                IEEE80211_TX_MAX_RATES];
                                        s8 rts_cts_rate_idx;
-                                       /* 3 bytes free */
+                                       u8 use_rts:1;
+                                       u8 use_cts_prot:1;
+                                       /* 2 bytes free */
                                };
                                /* only needed before rate control */
                                unsigned long jiffies;
index 1c36c9b4fa4a8f72689bcbf057edfbfa656f1d70..eda290fb8bd2145260f5f312d7cc40675761e2b0 100644 (file)
@@ -209,9 +209,9 @@ minstrel_get_retry_count(struct minstrel_rate *mr,
 {
        unsigned int retry = mr->adjusted_retry_count;
 
-       if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
+       if (info->control.use_rts)
                retry = max(2U, min(mr->retry_count_rtscts, retry));
-       else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
+       else if (info->control.use_cts_prot)
                retry = max(2U, min(mr->retry_count_cts, retry));
        return retry;
 }
@@ -460,6 +460,8 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
                } while ((tx_time < mp->segment_size) &&
                                (++mr->retry_count < mp->max_retry));
                mr->adjusted_retry_count = mr->retry_count;
+               if (!(sband->bitrates[i].flags & IEEE80211_RATE_ERP_G))
+                       mr->retry_count_cts = mr->retry_count;
        }
 
        for (i = n; i < sband->n_bitrates; i++) {
index 15c1b286e280693399905c83f71b55581dd43f48..6ca857f8f4248d2e7767c0dd464a29eb579df2a3 100644 (file)
@@ -656,6 +656,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
                txrc.rts = rts = true;
        }
 
+       info->control.use_rts = rts;
+       info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot;
+
        /*
         * Use short preamble if the BSS can handle it, but not for
         * management frames unless we know the receiver can handle
@@ -766,6 +769,11 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
                 */
                if (rc_rate->flags & IEEE80211_TX_RC_MCS) {
                        WARN_ON(rc_rate->idx > 76);
+
+                       if (!(rc_rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
+                           tx->sdata->vif.bss_conf.use_cts_prot)
+                               rc_rate->flags |=
+                                       IEEE80211_TX_RC_USE_CTS_PROTECT;
                        continue;
                }