]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mac80211: use STA info in rate_control_send_low()
authorJohannes Berg <johannes.berg@intel.com>
Wed, 29 May 2019 12:25:35 +0000 (15:25 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 14 Jun 2019 12:17:37 +0000 (14:17 +0200)
Even if we have a station, we currently call rate_control_send_low()
with the NULL station unless further rate control (driver, minstrel)
has been initialized.

Change this so we can use more information about the station to use
a better rate. For example, when we associate with an AP, we will
now use the lowest rate it advertised as supported (that we can)
rather than the lowest mandatory rate. This aligns our behaviour
with most other 802.11 implementations.

To make this possible, we need to also ensure that we have non-zero
rates at all times, so in case we really have *nothing* pre-fill
the supp_rates bitmap with the very lowest mandatory bitmap (11b
and 11a on 2.4 and 5 GHz respectively).

Additionally, hostapd appears to be giving us an empty supported
rates bitmap (it can and should do better, since the STA must have
supported for at least the basic rates in the BSS), so ignore any
such bitmaps that would actually zero out the supp_rates, and in
that case just keep the pre-filled mandatory rates.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/cfg.c
net/mac80211/mlme.c
net/mac80211/rate.c
net/mac80211/sta_info.c

index 023e8751d2234d13bd7df0ef25206e7ca2556d2d..fcf1dfc3a1cc6e4344aa96d494cac5a515ceba6d 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
  * Copyright 2013-2015  Intel Mobile Communications GmbH
  * Copyright (C) 2015-2017 Intel Deutschland GmbH
- * Copyright (C) 2018 Intel Corporation
+ * Copyright (C) 2018-2019 Intel Corporation
  *
  * This file is GPLv2 as found in COPYING.
  */
@@ -1468,7 +1468,7 @@ static int sta_apply_parameters(struct ieee80211_local *local,
                        return ret;
        }
 
-       if (params->supported_rates) {
+       if (params->supported_rates && params->supported_rates_len) {
                ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
                                         sband, params->supported_rates,
                                         params->supported_rates_len,
index 281319c826dd6f78fab4201736756598bf0bec25..b971b02d0d607320990b44d407dcc1cacaba9471 100644 (file)
@@ -4955,7 +4955,12 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
                        basic_rates = BIT(min_rate_index);
                }
 
-               new_sta->sta.supp_rates[cbss->channel->band] = rates;
+               if (rates)
+                       new_sta->sta.supp_rates[cbss->channel->band] = rates;
+               else
+                       sdata_info(sdata,
+                                  "No rates found, keeping mandatory only\n");
+
                sdata->vif.bss_conf.basic_rates = basic_rates;
 
                /* cf. IEEE 802.11 9.2.12 */
index 09f89d004a709a5e433f4130a632a7fee13ea61c..bc3cedc653f0f11a0dbb02a52621136080dcf950 100644 (file)
@@ -886,11 +886,6 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
        int i;
 
-       if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
-               ista = &sta->sta;
-               priv_sta = sta->rate_ctrl_priv;
-       }
-
        for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
                info->control.rates[i].idx = -1;
                info->control.rates[i].flags = 0;
@@ -900,9 +895,14 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
        if (ieee80211_hw_check(&sdata->local->hw, HAS_RATE_CONTROL))
                return;
 
-       if (rate_control_send_low(ista, txrc))
+       if (rate_control_send_low(sta ? &sta->sta : NULL, txrc))
                return;
 
+       if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
+               ista = &sta->sta;
+               priv_sta = sta->rate_ctrl_priv;
+       }
+
        if (ista) {
                spin_lock_bh(&sta->rate_ctrl_lock);
                ref->ops->get_rate(ref->priv, ista, priv_sta, txrc);
index a4932ee3595c2f0e03248ab59b13f576a6783faf..315adb473e2c7da47b65ffa044d8493e3ef217e2 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  * Copyright 2013-2014  Intel Mobile Communications GmbH
  * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
- * Copyright (C) 2018 Intel Corporation
+ * Copyright (C) 2018-2019 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -404,6 +404,47 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
        for (i = 0; i < IEEE80211_NUM_TIDS; i++)
                sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX);
 
+       for (i = 0; i < NUM_NL80211_BANDS; i++) {
+               u32 mandatory = 0;
+               int r;
+
+               if (!hw->wiphy->bands[i])
+                       continue;
+
+               switch (i) {
+               case NL80211_BAND_2GHZ:
+                       /*
+                        * We use both here, even if we cannot really know for
+                        * sure the station will support both, but the only use
+                        * for this is when we don't know anything yet and send
+                        * management frames, and then we'll pick the lowest
+                        * possible rate anyway.
+                        * If we don't include _G here, we cannot find a rate
+                        * in P2P, and thus trigger the WARN_ONCE() in rate.c
+                        */
+                       mandatory = IEEE80211_RATE_MANDATORY_B |
+                                   IEEE80211_RATE_MANDATORY_G;
+                       break;
+               case NL80211_BAND_5GHZ:
+                       mandatory = IEEE80211_RATE_MANDATORY_A;
+                       break;
+               case NL80211_BAND_60GHZ:
+                       WARN_ON(1);
+                       mandatory = 0;
+                       break;
+               }
+
+               for (r = 0; r < hw->wiphy->bands[i]->n_bitrates; r++) {
+                       struct ieee80211_rate *rate;
+
+                       rate = &hw->wiphy->bands[i]->bitrates[r];
+
+                       if (!(rate->flags & mandatory))
+                               continue;
+                       sta->sta.supp_rates[i] |= BIT(r);
+               }
+       }
+
        sta->sta.smps_mode = IEEE80211_SMPS_OFF;
        if (sdata->vif.type == NL80211_IFTYPE_AP ||
            sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {