History

Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next

John W. Linville committed 13 years ago

Commit 6475cb02 parents e563589 1eb321742 files · +1526 −616Browse files

Unified · Split

42 files
  1. drivers/net/wireless/iwlegacy/4965-mac.c +15 −17
  2. drivers/net/wireless/iwlegacy/4965.c +1 −1
  3. drivers/net/wireless/iwlwifi/dvm/devices.c +6 −4
  4. drivers/net/wireless/iwlwifi/dvm/mac80211.c +15 −5
  5. drivers/net/wireless/iwlwifi/dvm/rxon.c +1 −1
  6. drivers/net/wireless/mac80211_hwsim.c +60 −9
  7. drivers/net/wireless/ti/wl12xx/cmd.c +1 −1
  8. drivers/net/wireless/ti/wl18xx/cmd.c +3 −3
  9. include/linux/ieee80211.h +40 −3
  10. include/net/cfg80211.h +34 −0
  11. include/net/mac80211.h +80 −10
  12. include/uapi/linux/nl80211.h +39 −0
  13. net/mac80211/cfg.c +15 −0
  14. net/mac80211/chan.c +33 −10
  15. net/mac80211/ibss.c +5 −1
  16. net/mac80211/ieee80211_i.h +10 −8
  17. net/mac80211/iface.c +3 −2
  18. net/mac80211/main.c +12 −11
  19. net/mac80211/mesh.c +2 −2
  20. net/mac80211/mesh_hwmp.c +1 −1
  21. net/mac80211/mesh_plink.c +3 −3
  22. net/mac80211/mlme.c +233 −101
  23. net/mac80211/pm.c +2 −1
  24. net/mac80211/rate.c +268 −56
  25. net/mac80211/rc80211_minstrel.c +113 −93
  26. net/mac80211/rc80211_minstrel.h +5 −2
  27. net/mac80211/rc80211_minstrel_debugfs.c +2 −2
  28. net/mac80211/rc80211_minstrel_ht.c +99 −73
  29. net/mac80211/rc80211_minstrel_ht.h +2 −0
  30. net/mac80211/rx.c +19 −5
  31. net/mac80211/scan.c +1 −1
  32. net/mac80211/trace.h +4 −4
  33. net/mac80211/tx.c +41 −101
  34. net/mac80211/util.c +52 −2
  35. net/rfkill/rfkill-gpio.c +5 −2
  36. net/wireless/core.h +3 −0
  37. net/wireless/mlme.c +5 −0
  38. net/wireless/nl80211.c +210 −75
  39. net/wireless/rdev-ops.h +23 −1
  40. net/wireless/reg.c +1 −1
  41. net/wireless/trace.h +35 −0
  42. net/wireless/util.c +24 −4
drivers/net/wireless/iwlegacy/4965-mac.c+15−17
@@ -6057,7 +6057,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, · 6056 unmodified lines
60576057 struct il_priv *il = hw->priv;
60586058 const struct il_channel_info *ch_info;
60596059 struct ieee80211_conf *conf = &hw->conf;
6060− struct ieee80211_channel *channel = ch_switch->channel;
6060+ struct ieee80211_channel *channel = ch_switch->chandef.chan;
60616061 struct il_ht_config *ht_conf = &il->current_ht_config;
60626062 u16 ch;
60636063
@@ -6094,23 +6094,21 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, · 30 unmodified lines
60946094 il->current_ht_config.smps = conf->smps_mode;
60956095
60966096 /* Configure HT40 channels */
6097− il->ht.enabled = conf_is_ht(conf);
6098− if (il->ht.enabled) {
6099− if (conf_is_ht40_minus(conf)) {
6100− il->ht.extension_chan_offset =
6101− IEEE80211_HT_PARAM_CHA_SEC_BELOW;
6102− il->ht.is_40mhz = true;
6103− } else if (conf_is_ht40_plus(conf)) {
6104− il->ht.extension_chan_offset =
6105− IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
6106− il->ht.is_40mhz = true;
6107− } else {
6108− il->ht.extension_chan_offset =
6109− IEEE80211_HT_PARAM_CHA_SEC_NONE;
6110− il->ht.is_40mhz = false;
6111− }
6112− } else
6097+ switch (cfg80211_get_chandef_type(&ch_switch->chandef)) {
6098+ case NL80211_CHAN_NO_HT:
6099+ case NL80211_CHAN_HT20:
61136100 il->ht.is_40mhz = false;
6101+ il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
6102+ break;
6103+ case NL80211_CHAN_HT40MINUS:
6104+ il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
6105+ il->ht.is_40mhz = true;
6106+ break;
6107+ case NL80211_CHAN_HT40PLUS:
6108+ il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
6109+ il->ht.is_40mhz = true;
6110+ break;
6111+ }
61146112
61156113 if ((le16_to_cpu(il->staging.channel) != ch))
61166114 il->staging.flags = 0;
drivers/net/wireless/iwlegacy/4965.c+1−1
@@ -1493,7 +1493,7 @@ il4965_hw_channel_switch(struct il_priv *il, · 1492 unmodified lines
14931493
14941494 cmd.band = band;
14951495 cmd.expect_beacon = 0;
1496− ch = ch_switch->channel->hw_value;
1496+ ch = ch_switch->chandef.chan->hw_value;
14971497 cmd.channel = cpu_to_le16(ch);
14981498 cmd.rxon_flags = il->staging.flags;
14991499 cmd.rxon_filter_flags = il->staging.filter_flags;
drivers/net/wireless/iwlwifi/dvm/devices.c+6−4
@@ -379,7 +379,7 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv, · 378 unmodified lines
379379 };
380380
381381 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
382− ch = ch_switch->channel->hw_value;
382+ ch = ch_switch->chandef.chan->hw_value;
383383 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
384384 ctx->active.channel, ch);
385385 cmd.channel = cpu_to_le16(ch);
@@ -414,7 +414,8 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv, · 28 unmodified lines
414414 }
415415 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
416416 cmd.switch_time);
417− cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
417+ cmd.expect_beacon =
418+ ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
418419
419420 return iwl_dvm_send_cmd(priv, &hcmd);
420421 }
@@ -540,7 +541,7 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv, · 119 unmodified lines
540541 hcmd.data[0] = cmd;
541542
542543 cmd->band = priv->band == IEEE80211_BAND_2GHZ;
543− ch = ch_switch->channel->hw_value;
544+ ch = ch_switch->chandef.chan->hw_value;
544545 IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
545546 ctx->active.channel, ch);
546547 cmd->channel = cpu_to_le16(ch);
@@ -575,7 +576,8 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv, · 28 unmodified lines
575576 }
576577 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
577578 cmd->switch_time);
578− cmd->expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
579+ cmd->expect_beacon =
580+ ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
579581
580582 err = iwl_dvm_send_cmd(priv, &hcmd);
581583 kfree(cmd);
drivers/net/wireless/iwlwifi/dvm/mac80211.c+15−5
@@ -970,7 +970,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, · 969 unmodified lines
970970 {
971971 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
972972 struct ieee80211_conf *conf = &hw->conf;
973− struct ieee80211_channel *channel = ch_switch->channel;
973+ struct ieee80211_channel *channel = ch_switch->chandef.chan;
974974 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
975975 /*
976976 * MULTI-FIXME
@@ -1008,11 +1008,21 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, · 31 unmodified lines
10081008 priv->current_ht_config.smps = conf->smps_mode;
10091009
10101010 /* Configure HT40 channels */
1011− ctx->ht.enabled = conf_is_ht(conf);
1012− if (ctx->ht.enabled)
1013− iwlagn_config_ht40(conf, ctx);
1014− else
1011+ switch (cfg80211_get_chandef_type(&ch_switch->chandef)) {
1012+ case NL80211_CHAN_NO_HT:
1013+ case NL80211_CHAN_HT20:
10151014 ctx->ht.is_40mhz = false;
1015+ ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
1016+ break;
1017+ case NL80211_CHAN_HT40MINUS:
1018+ ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
1019+ ctx->ht.is_40mhz = true;
1020+ break;
1021+ case NL80211_CHAN_HT40PLUS:
1022+ ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
1023+ ctx->ht.is_40mhz = true;
1024+ break;
1025+ }
10161026
10171027 if ((le16_to_cpu(ctx->staging.channel) != ch))
10181028 ctx->staging.flags = 0;
drivers/net/wireless/iwlwifi/dvm/rxon.c+1−1
@@ -1160,7 +1160,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) · 1159 unmodified lines
11601160 }
11611161
11621162 void iwlagn_config_ht40(struct ieee80211_conf *conf,
1163− struct iwl_rxon_context *ctx)
1163+ struct iwl_rxon_context *ctx)
11641164 {
11651165 if (conf_is_ht40_minus(conf)) {
11661166 ctx->ht.extension_chan_offset =
drivers/net/wireless/mac80211_hwsim.c+60−9
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <linux/if_arp.h>
2626 #include <linux/rtnetlink.h>
2727 #include <linux/etherdevice.h>
28+#include <linux/platform_device.h>
2829 #include <linux/debugfs.h>
2930 #include <linux/module.h>
3031 #include <linux/ktime.h>
@@ -52,6 +53,10 @@ static bool paged_rx = false; · 21 unmodified lines
5253 module_param(paged_rx, bool, 0644);
5354 MODULE_PARM_DESC(paged_rx, "Use paged SKBs for RX instead of linear ones");
5455
56+static bool rctbl = false;
57+module_param(rctbl, bool, 0444);
58+MODULE_PARM_DESC(rctbl, "Handle rate control table");
59+
5560 /**
5661 * enum hwsim_regtest - the type of regulatory tests we offer
5762 *
@@ -717,9 +722,17 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, · 659 unmodified lines
717722 rx_status.flag |= RX_FLAG_MACTIME_START;
718723 rx_status.freq = chan->center_freq;
719724 rx_status.band = chan->band;
720− rx_status.rate_idx = info->control.rates[0].idx;
721− if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
722− rx_status.flag |= RX_FLAG_HT;
725+ if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) {
726+ rx_status.rate_idx =
727+ ieee80211_rate_get_vht_mcs(&info->control.rates[0]);
728+ rx_status.vht_nss =
729+ ieee80211_rate_get_vht_nss(&info->control.rates[0]);
730+ rx_status.flag |= RX_FLAG_VHT;
731+ } else {
732+ rx_status.rate_idx = info->control.rates[0].idx;
733+ if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
734+ rx_status.flag |= RX_FLAG_HT;
735+ }
723736 if (info->control.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
724737 rx_status.flag |= RX_FLAG_40MHZ;
725738 if (info->control.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
@@ -886,8 +899,12 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, · 160 unmodified lines
886899 if (control->sta)
887900 hwsim_check_sta_magic(control->sta);
888901
889− txi->rate_driver_data[0] = channel;
902+ if (rctbl)
903+ ieee80211_get_tx_rates(txi->control.vif, control->sta, skb,
904+ txi->control.rates,
905+ ARRAY_SIZE(txi->control.rates));
890906
907+ txi->rate_driver_data[0] = channel;
891908 mac80211_hwsim_monitor_rx(hw, skb, channel);
892909
893910 /* wmediumd mode check */
@@ -989,6 +1006,13 @@ static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, · 95 unmodified lines
9891006 {
9901007 u32 _pid = ACCESS_ONCE(wmediumd_portid);
9911008
1009+ if (rctbl) {
1010+ struct ieee80211_tx_info *txi = IEEE80211_SKB_CB(skb);
1011+ ieee80211_get_tx_rates(txi->control.vif, NULL, skb,
1012+ txi->control.rates,
1013+ ARRAY_SIZE(txi->control.rates));
1014+ }
1015+
9921016 mac80211_hwsim_monitor_rx(hw, skb, chan);
9931017
9941018 if (_pid)
@@ -1019,6 +1043,11 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, · 24 unmodified lines
10191043 if (skb == NULL)
10201044 return;
10211045 info = IEEE80211_SKB_CB(skb);
1046+ if (rctbl)
1047+ ieee80211_get_tx_rates(vif, NULL, skb,
1048+ info->control.rates,
1049+ ARRAY_SIZE(info->control.rates));
1050+
10221051 txrate = ieee80211_get_tx_rate(hw, info);
10231052
10241053 mgmt = (struct ieee80211_mgmt *) skb->data;
@@ -1687,6 +1716,7 @@ static void mac80211_hwsim_free(void) · 662 unmodified lines
16871716 debugfs_remove(data->debugfs_ps);
16881717 debugfs_remove(data->debugfs);
16891718 ieee80211_unregister_hw(data->hw);
1719+ device_release_driver(data->dev);
16901720 device_unregister(data->dev);
16911721 ieee80211_free_hw(data->hw);
16921722 }
@@ -1695,7 +1725,9 @@ static void mac80211_hwsim_free(void) · 2 unmodified lines
16951725
16961726
16971727 static struct device_driver mac80211_hwsim_driver = {
1698− .name = "mac80211_hwsim"
1728+ .name = "mac80211_hwsim",
1729+ .bus = &platform_bus_type,
1730+ .owner = THIS_MODULE,
16991731 };
17001732
17011733 static const struct net_device_ops hwsim_netdev_ops = {
@@ -2187,9 +2219,15 @@ static int __init init_mac80211_hwsim(void) · 485 unmodified lines
21872219 spin_lock_init(&hwsim_radio_lock);
21882220 INIT_LIST_HEAD(&hwsim_radios);
21892221
2222+ err = driver_register(&mac80211_hwsim_driver);
2223+ if (err)
2224+ return err;
2225+
21902226 hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim");
2191− if (IS_ERR(hwsim_class))
2192− return PTR_ERR(hwsim_class);
2227+ if (IS_ERR(hwsim_class)) {
2228+ err = PTR_ERR(hwsim_class);
2229+ goto failed_unregister_driver;
2230+ }
21932231
21942232 memset(addr, 0, ETH_ALEN);
21952233 addr[0] = 0x02;
@@ -2211,12 +2249,20 @@ static int __init init_mac80211_hwsim(void) · 15 unmodified lines
22112249 "hwsim%d", i);
22122250 if (IS_ERR(data->dev)) {
22132251 printk(KERN_DEBUG
2214− "mac80211_hwsim: device_create "
2215− "failed (%ld)\n", PTR_ERR(data->dev));
2252+ "mac80211_hwsim: device_create failed (%ld)\n",
2253+ PTR_ERR(data->dev));
22162254 err = -ENOMEM;
22172255 goto failed_drvdata;
22182256 }
22192257 data->dev->driver = &mac80211_hwsim_driver;
2258+ err = device_bind_driver(data->dev);
2259+ if (err != 0) {
2260+ printk(KERN_DEBUG
2261+ "mac80211_hwsim: device_bind_driver failed (%d)\n",
2262+ err);
2263+ goto failed_hw;
2264+ }
2265+
22202266 skb_queue_head_init(&data->pending);
22212267
22222268 SET_IEEE80211_DEV(hw, data->dev);
@@ -2259,6 +2305,8 @@ static int __init init_mac80211_hwsim(void) · 36 unmodified lines
22592305 IEEE80211_HW_AMPDU_AGGREGATION |
22602306 IEEE80211_HW_WANT_MONITOR_VIF |
22612307 IEEE80211_HW_QUEUE_CONTROL;
2308+ if (rctbl)
2309+ hw->flags |= IEEE80211_HW_SUPPORTS_RC_TABLE;
22622310
22632311 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
22642312 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
@@ -2515,6 +2563,8 @@ failed_drvdata: · 250 unmodified lines
25152563 ieee80211_free_hw(hw);
25162564 failed:
25172565 mac80211_hwsim_free();
2566+failed_unregister_driver:
2567+ driver_unregister(&mac80211_hwsim_driver);
25182568 return err;
25192569 }
25202570 module_init(init_mac80211_hwsim);
@@ -2527,5 +2577,6 @@ static void __exit exit_mac80211_hwsim(void) · 6 unmodified lines
25272577
25282578 mac80211_hwsim_free();
25292579 unregister_netdev(hwsim_mon);
2580+ driver_unregister(&mac80211_hwsim_driver);
25302581 }
25312582 module_exit(exit_mac80211_hwsim);
drivers/net/wireless/ti/wl12xx/cmd.c+1−1
@@ -301,7 +301,7 @@ int wl12xx_cmd_channel_switch(struct wl1271 *wl, · 300 unmodified lines
301301 }
302302
303303 cmd->role_id = wlvif->role_id;
304− cmd->channel = ch_switch->channel->hw_value;
304+ cmd->channel = ch_switch->chandef.chan->hw_value;
305305 cmd->switch_time = ch_switch->count;
306306 cmd->stop_tx = ch_switch->block_tx;
307307
drivers/net/wireless/ti/wl18xx/cmd.c+3−3
@@ -42,11 +42,11 @@ int wl18xx_cmd_channel_switch(struct wl1271 *wl, · 41 unmodified lines
4242 }
4343
4444 cmd->role_id = wlvif->role_id;
45− cmd->channel = ch_switch->channel->hw_value;
45+ cmd->channel = ch_switch->chandef.chan->hw_value;
4646 cmd->switch_time = ch_switch->count;
4747 cmd->stop_tx = ch_switch->block_tx;
4848
49− switch (ch_switch->channel->band) {
49+ switch (ch_switch->chandef.chan->band) {
5050 case IEEE80211_BAND_2GHZ:
5151 cmd->band = WLCORE_BAND_2_4GHZ;
5252 break;
@@ -55,7 +55,7 @@ int wl18xx_cmd_channel_switch(struct wl1271 *wl, · 2 unmodified lines
5555 break;
5656 default:
5757 wl1271_error("invalid channel switch band: %d",
58− ch_switch->channel->band);
58+ ch_switch->chandef.chan->band);
5959 ret = -EINVAL;
6060 goto out_free;
6161 }
include/linux/ieee80211.h+40−3
@@ -672,6 +672,36 @@ struct ieee80211_channel_sw_ie { · 671 unmodified lines
672672 u8 count;
673673 } __packed;
674674
675+/**
676+ * struct ieee80211_ext_chansw_ie
677+ *
678+ * This structure represents the "Extended Channel Switch Announcement element"
679+ */
680+struct ieee80211_ext_chansw_ie {
681+ u8 mode;
682+ u8 new_operating_class;
683+ u8 new_ch_num;
684+ u8 count;
685+} __packed;
686+
687+/**
688+ * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
689+ * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
690+ * values here
691+ * This structure represents the "Secondary Channel Offset element"
692+ */
693+struct ieee80211_sec_chan_offs_ie {
694+ u8 sec_chan_offs;
695+} __packed;
696+
697+/**
698+ * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
699+ */
700+struct ieee80211_wide_bw_chansw_ie {
701+ u8 new_channel_width;
702+ u8 new_center_freq_seg0, new_center_freq_seg1;
703+} __packed;
704+
675705 /**
676706 * struct ieee80211_tim
677707 *
@@ -840,10 +870,13 @@ struct ieee80211_mgmt { · 162 unmodified lines
840870 } __packed wme_action;
841871 struct{
842872 u8 action_code;
843− u8 element_id;
844− u8 length;
845− struct ieee80211_channel_sw_ie sw_elem;
873+ u8 variable[0];
846874 } __packed chan_switch;
875+ struct{
876+ u8 action_code;
877+ struct ieee80211_ext_chansw_ie data;
878+ u8 variable[0];
879+ } __packed ext_chan_switch;
847880 struct{
848881 u8 action_code;
849882 u8 dialog_token;
@@ -1638,6 +1671,7 @@ enum ieee80211_eid { · 788 unmodified lines
16381671
16391672 WLAN_EID_HT_CAPABILITY = 45,
16401673 WLAN_EID_HT_OPERATION = 61,
1674+ WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
16411675
16421676 WLAN_EID_RSN = 48,
16431677 WLAN_EID_MMIE = 76,
@@ -1672,6 +1706,8 @@ enum ieee80211_eid { · 28 unmodified lines
16721706 WLAN_EID_VHT_CAPABILITY = 191,
16731707 WLAN_EID_VHT_OPERATION = 192,
16741708 WLAN_EID_OPMODE_NOTIF = 199,
1709+ WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
1710+ WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
16751711
16761712 /* 802.11ad */
16771713 WLAN_EID_NON_TX_BSSID_CAP = 83,
@@ -1795,6 +1831,7 @@ enum ieee80211_key_len { · 117 unmodified lines
17951831
17961832 /* Public action codes */
17971833 enum ieee80211_pub_actioncode {
1834+ WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
17981835 WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
17991836 };
18001837
include/net/cfg80211.h+34−0
@@ -2002,6 +2002,12 @@ struct cfg80211_update_ft_ies_params { · 2001 unmodified lines
20022002 * @update_ft_ies: Provide updated Fast BSS Transition information to the
20032003 * driver. If the SME is in the driver/firmware, this information can be
20042004 * used in building Authentication and Reassociation Request frames.
2005+ *
2006+ * @crit_proto_start: Indicates a critical protocol needs more link reliability
2007+ * for a given duration (milliseconds). The protocol is provided so the
2008+ * driver can take the most appropriate actions.
2009+ * @crit_proto_stop: Indicates critical protocol no longer needs increased link
2010+ * reliability. This operation can not fail.
20052011 */
20062012 struct cfg80211_ops {
20072013 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -2231,6 +2237,12 @@ struct cfg80211_ops { · 223 unmodified lines
22312237 struct cfg80211_chan_def *chandef);
22322238 int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
22332239 struct cfg80211_update_ft_ies_params *ftie);
2240+ int (*crit_proto_start)(struct wiphy *wiphy,
2241+ struct wireless_dev *wdev,
2242+ enum nl80211_crit_proto_id protocol,
2243+ u16 duration);
2244+ void (*crit_proto_stop)(struct wiphy *wiphy,
2245+ struct wireless_dev *wdev);
22342246 };
22352247
22362248 /*
@@ -4024,6 +4036,17 @@ bool cfg80211_reg_can_beacon(struct wiphy *wiphy, · 1787 unmodified lines
40244036 void cfg80211_ch_switch_notify(struct net_device *dev,
40254037 struct cfg80211_chan_def *chandef);
40264038
4039+/**
4040+ * ieee80211_operating_class_to_band - convert operating class to band
4041+ *
4042+ * @operating_class: the operating class to convert
4043+ * @band: band pointer to fill
4044+ *
4045+ * Returns %true if the conversion was successful, %false otherwise.
4046+ */
4047+bool ieee80211_operating_class_to_band(u8 operating_class,
4048+ enum ieee80211_band *band);
4049+
40274050 /*
40284051 * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
40294052 * @dev: the device on which the operation is requested
@@ -4126,6 +4149,17 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev, · 96 unmodified lines
41264149 struct cfg80211_wowlan_wakeup *wakeup,
41274150 gfp_t gfp);
41284151
4152+/**
4153+ * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver.
4154+ *
4155+ * @wdev: the wireless device for which critical protocol is stopped.
4156+ *
4157+ * This function can be called by the driver to indicate it has reverted
4158+ * operation back to normal. One reason could be that the duration given
4159+ * by .crit_proto_start() has expired.
4160+ */
4161+void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
4162+
41294163 /* Logging, debugging and troubleshooting/diagnostic helpers. */
41304164
41314165 /* wiphy_printk helpers, similar to dev_printk */
include/net/mac80211.h+80−10
@@ -128,6 +128,7 @@ enum ieee80211_ac_numbers { · 127 unmodified lines
128128 * 2^n-1 in the range 1..32767]
129129 * @cw_max: maximum contention window [like @cw_min]
130130 * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
131+ * @acm: is mandatory admission control required for the access category
131132 * @uapsd: is U-APSD mode enabled for the queue
132133 */
133134 struct ieee80211_tx_queue_params {
@@ -135,6 +136,7 @@ struct ieee80211_tx_queue_params { · 1 unmodified line
135136 u16 cw_min;
136137 u16 cw_max;
137138 u8 aifs;
139+ bool acm;
138140 bool uapsd;
139141 };
140142
@@ -209,7 +211,7 @@ struct ieee80211_chanctx_conf { · 68 unmodified lines
209211 * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note
210212 * that it is only ever disabled for station mode.
211213 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
212− * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode)
214+ * @BSS_CHANGED_SSID: SSID changed for this BSS (AP and IBSS mode)
213215 * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
214216 * @BSS_CHANGED_PS: PS changed for this BSS (STA mode)
215217 * @BSS_CHANGED_TXPOWER: TX power setting changed for this interface
@@ -326,7 +328,7 @@ enum ieee80211_rssi_event { · 110 unmodified lines
326328 * your driver/device needs to do.
327329 * @ps: power-save mode (STA only). This flag is NOT affected by
328330 * offchannel/dynamic_ps operations.
329− * @ssid: The SSID of the current vif. Only valid in AP-mode.
331+ * @ssid: The SSID of the current vif. Valid in AP and IBSS mode.
330332 * @ssid_len: Length of SSID given in @ssid.
331333 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
332334 * @txpower: TX power in dBm
@@ -561,6 +563,9 @@ enum mac80211_rate_control_flags { · 228 unmodified lines
561563 /* maximum number of rate stages */
562564 #define IEEE80211_TX_MAX_RATES 4
563565
566+/* maximum number of rate table entries */
567+#define IEEE80211_TX_RATE_TABLE_SIZE 4
568+
564569 /**
565570 * struct ieee80211_tx_rate - rate selection/status
566571 *
@@ -601,8 +606,8 @@ static inline void ieee80211_rate_set_vht(struct ieee80211_tx_rate *rate, · 34 unmodified lines
601606 u8 mcs, u8 nss)
602607 {
603608 WARN_ON(mcs & ~0xF);
604− WARN_ON(nss & ~0x7);
605− rate->idx = (nss << 4) | mcs;
609+ WARN_ON((nss - 1) & ~0x7);
610+ rate->idx = ((nss - 1) << 4) | mcs;
606611 }
607612
608613 static inline u8
@@ -614,7 +619,7 @@ ieee80211_rate_get_vht_mcs(const struct ieee80211_tx_rate *rate) · 5 unmodified lines
614619 static inline u8
615620 ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
616621 {
617− return rate->idx >> 4;
622+ return (rate->idx >> 4) + 1;
618623 }
619624
620625 /**
@@ -655,7 +660,11 @@ struct ieee80211_tx_info { · 34 unmodified lines
655660 struct ieee80211_tx_rate rates[
656661 IEEE80211_TX_MAX_RATES];
657662 s8 rts_cts_rate_idx;
658− /* 3 bytes free */
663+ u8 use_rts:1;
664+ u8 use_cts_prot:1;
665+ u8 short_preamble:1;
666+ u8 skip_table:1;
667+ /* 2 bytes free */
659668 };
660669 /* only needed before rate control */
661670 unsigned long jiffies;
@@ -676,6 +685,8 @@ struct ieee80211_tx_info { · 14 unmodified lines
676685 struct {
677686 struct ieee80211_tx_rate driver_rates[
678687 IEEE80211_TX_MAX_RATES];
688+ u8 pad[4];
689+
679690 void *rate_driver_data[
680691 IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
681692 };
@@ -1017,13 +1028,13 @@ struct ieee80211_conf { · 335 unmodified lines
10171028 * the driver passed into mac80211.
10181029 * @block_tx: Indicates whether transmission must be blocked before the
10191030 * scheduled channel switch, as indicated by the AP.
1020− * @channel: the new channel to switch to
1031+ * @chandef: the new channel to switch to
10211032 * @count: the number of TBTT's until the channel switch event
10221033 */
10231034 struct ieee80211_channel_switch {
10241035 u64 timestamp;
10251036 bool block_tx;
1026− struct ieee80211_channel *channel;
1037+ struct cfg80211_chan_def chandef;
10271038 u8 count;
10281039 };
10291040
@@ -1220,6 +1231,24 @@ enum ieee80211_sta_rx_bandwidth { · 190 unmodified lines
12201231 IEEE80211_STA_RX_BW_160,
12211232 };
12221233
1234+/**
1235+ * struct ieee80211_sta_rates - station rate selection table
1236+ *
1237+ * @rcu_head: RCU head used for freeing the table on update
1238+ * @rates: transmit rates/flags to be used by default.
1239+ * Overriding entries per-packet is possible by using cb tx control.
1240+ */
1241+struct ieee80211_sta_rates {
1242+ struct rcu_head rcu_head;
1243+ struct {
1244+ s8 idx;
1245+ u8 count;
1246+ u8 count_cts;
1247+ u8 count_rts;
1248+ u16 flags;
1249+ } rate[IEEE80211_TX_RATE_TABLE_SIZE];
1250+};
1251+
12231252 /**
12241253 * struct ieee80211_sta - station table entry
12251254 *
@@ -1247,6 +1276,7 @@ enum ieee80211_sta_rx_bandwidth { · 21 unmodified lines
12471276 * notifications and capabilities. The value is only valid after
12481277 * the station moves to associated state.
12491278 * @smps_mode: current SMPS mode (off, static or dynamic)
1279+ * @tx_rates: rate control selection table
12501280 */
12511281 struct ieee80211_sta {
12521282 u32 supp_rates[IEEE80211_NUM_BANDS];
@@ -1260,6 +1290,7 @@ struct ieee80211_sta { · 7 unmodified lines
12601290 u8 rx_nss;
12611291 enum ieee80211_sta_rx_bandwidth bandwidth;
12621292 enum ieee80211_smps_mode smps_mode;
1293+ struct ieee80211_sta_rates __rcu *rates;
12631294
12641295 /* must be last */
12651296 u8 drv_priv[0] __aligned(sizeof(void *));
@@ -1415,6 +1446,9 @@ struct ieee80211_tx_control { · 149 unmodified lines
14151446 * for different virtual interfaces. See the doc section on HW queue
14161447 * control for more details.
14171448 *
1449+ * @IEEE80211_HW_SUPPORTS_RC_TABLE: The driver supports using a rate
1450+ * selection table provided by the rate control algorithm.
1451+ *
14181452 * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any
14191453 * P2P Interface. This will be honoured even if more than one interface
14201454 * is supported.
@@ -1447,6 +1481,7 @@ enum ieee80211_hw_flags { · 26 unmodified lines
14471481 IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21,
14481482 IEEE80211_HW_AP_LINK_PS = 1<<22,
14491483 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23,
1484+ IEEE80211_HW_SUPPORTS_RC_TABLE = 1<<24,
14501485 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25,
14511486 IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26,
14521487 };
@@ -3132,6 +3167,25 @@ static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta, · 1679 unmodified lines
31323167 void ieee80211_sta_set_buffered(struct ieee80211_sta *sta,
31333168 u8 tid, bool buffered);
31343169
3170+/**
3171+ * ieee80211_get_tx_rates - get the selected transmit rates for a packet
3172+ *
3173+ * Call this function in a driver with per-packet rate selection support
3174+ * to combine the rate info in the packet tx info with the most recent
3175+ * rate selection table for the station entry.
3176+ *
3177+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
3178+ * @sta: the receiver station to which this packet is sent.
3179+ * @skb: the frame to be transmitted.
3180+ * @dest: buffer for extracted rate/retry information
3181+ * @max_rates: maximum number of rates to fetch
3182+ */
3183+void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
3184+ struct ieee80211_sta *sta,
3185+ struct sk_buff *skb,
3186+ struct ieee80211_tx_rate *dest,
3187+ int max_rates);
3188+
31353189 /**
31363190 * ieee80211_tx_status - transmit status callback
31373191 *
@@ -4107,7 +4161,7 @@ void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn); · 969 unmodified lines
41074161 * (deprecated; this will be removed once drivers get updated to use
41084162 * rate_idx_mask)
41094163 * @rate_idx_mask: user-requested (legacy) rate mask
4110− * @rate_idx_mcs_mask: user-requested MCS rate mask
4164+ * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
41114165 * @bss: whether this frame is sent out in AP or IBSS mode
41124166 */
41134167 struct ieee80211_tx_rate_control {
@@ -4119,7 +4173,7 @@ struct ieee80211_tx_rate_control { · 5 unmodified lines
41194173 bool rts, short_preamble;
41204174 u8 max_rate_idx;
41214175 u32 rate_idx_mask;
4122− u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
4176+ u8 *rate_idx_mcs_mask;
41234177 bool bss;
41244178 };
41254179
@@ -4208,6 +4262,22 @@ bool rate_usable_index_exists(struct ieee80211_supported_band *sband, · 82 unmodified lines
42084262 return false;
42094263 }
42104264
4265+/**
4266+ * rate_control_set_rates - pass the sta rate selection to mac80211/driver
4267+ *
4268+ * When not doing a rate control probe to test rates, rate control should pass
4269+ * its rate selection to mac80211. If the driver supports receiving a station
4270+ * rate table, it will use it to ensure that frames are always sent based on
4271+ * the most recent rate control module decision.
4272+ *
4273+ * @hw: pointer as obtained from ieee80211_alloc_hw()
4274+ * @pubsta: &struct ieee80211_sta pointer to the target destination.
4275+ * @rates: new tx rate set to be used for this station.
4276+ */
4277+int rate_control_set_rates(struct ieee80211_hw *hw,
4278+ struct ieee80211_sta *pubsta,
4279+ struct ieee80211_sta_rates *rates);
4280+
42114281 int ieee80211_rate_control_register(struct rate_control_ops *ops);
42124282 void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
42134283
include/uapi/linux/nl80211.h+39−0
@@ -639,6 +639,13 @@ · 638 unmodified lines
639639 * with the relevant Information Elements. This event is used to report
640640 * received FT IEs (MDIE, FTIE, RSN IE, TIE, RICIE).
641641 *
642+ * @NL80211_CMD_CRIT_PROTOCOL_START: Indicates user-space will start running
643+ * a critical protocol that needs more reliability in the connection to
644+ * complete.
645+ *
646+ * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
647+ * return back to normal.
648+ *
642649 * @NL80211_CMD_MAX: highest used command number
643650 * @__NL80211_CMD_AFTER_LAST: internal use
644651 */
@@ -798,6 +805,9 @@ enum nl80211_commands { · 153 unmodified lines
798805 NL80211_CMD_UPDATE_FT_IES,
799806 NL80211_CMD_FT_EVENT,
800807
808+ NL80211_CMD_CRIT_PROTOCOL_START,
809+ NL80211_CMD_CRIT_PROTOCOL_STOP,
810+
801811 /* add new commands above here */
802812
803813 /* used to define NL80211_CMD_MAX below */
@@ -1414,6 +1424,11 @@ enum nl80211_commands { · 610 unmodified lines
14141424 * @NL80211_ATTR_IE_RIC: Resource Information Container Information
14151425 * Element
14161426 *
1427+ * @NL80211_ATTR_CRIT_PROT_ID: critical protocol identifier requiring increased
1428+ * reliability, see &enum nl80211_crit_proto_id (u16).
1429+ * @NL80211_ATTR_MAX_CRIT_PROT_DURATION: duration in milliseconds in which
1430+ * the connection should have increased reliability (u16).
1431+ *
14171432 * @NL80211_ATTR_MAX: highest attribute number currently defined
14181433 * @__NL80211_ATTR_AFTER_LAST: internal use
14191434 */
@@ -1709,6 +1724,9 @@ enum nl80211_attrs { · 289 unmodified lines
17091724 NL80211_ATTR_MDID,
17101725 NL80211_ATTR_IE_RIC,
17111726
1727+ NL80211_ATTR_CRIT_PROT_ID,
1728+ NL80211_ATTR_MAX_CRIT_PROT_DURATION,
1729+
17121730 /* add attributes here, update the policy in nl80211.c */
17131731
17141732 __NL80211_ATTR_AFTER_LAST,
@@ -3682,4 +3700,25 @@ enum nl80211_protocol_features { · 1967 unmodified lines
36823700 NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 1 << 0,
36833701 };
36843702
3703+/**
3704+ * enum nl80211_crit_proto_id - nl80211 critical protocol identifiers
3705+ *
3706+ * @NL80211_CRIT_PROTO_UNSPEC: protocol unspecified.
3707+ * @NL80211_CRIT_PROTO_DHCP: BOOTP or DHCPv6 protocol.
3708+ * @NL80211_CRIT_PROTO_EAPOL: EAPOL protocol.
3709+ * @NL80211_CRIT_PROTO_APIPA: APIPA protocol.
3710+ * @NUM_NL80211_CRIT_PROTO: must be kept last.
3711+ */
3712+enum nl80211_crit_proto_id {
3713+ NL80211_CRIT_PROTO_UNSPEC,
3714+ NL80211_CRIT_PROTO_DHCP,
3715+ NL80211_CRIT_PROTO_EAPOL,
3716+ NL80211_CRIT_PROTO_APIPA,
3717+ /* add other protocols before this one */
3718+ NUM_NL80211_CRIT_PROTO
3719+};
3720+
3721+/* maximum duration for critical protocol measures */
3722+#define NL80211_CRIT_PROTO_MAX_DURATION 5000 /* msec */
3723+
36853724 #endif /* __LINUX_NL80211_H */
net/mac80211/cfg.c+15−0
@@ -1043,6 +1043,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) · 1042 unmodified lines
10431043 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
10441044 sta_info_flush_defer(vlan);
10451045 sta_info_flush_defer(sdata);
1046+ synchronize_net();
10461047 rcu_barrier();
10471048 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
10481049 sta_info_flush_cleanup(vlan);
@@ -1052,6 +1053,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) · 3 unmodified lines
10521053 ieee80211_free_keys(sdata);
10531054
10541055 sdata->vif.bss_conf.enable_beacon = false;
1056+ sdata->vif.bss_conf.ssid_len = 0;
10551057 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
10561058 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
10571059
@@ -2416,9 +2418,22 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, · 1358 unmodified lines
24162418 }
24172419
24182420 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
2421+ struct ieee80211_supported_band *sband = wiphy->bands[i];
2422+ int j;
2423+
24192424 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
24202425 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
24212426 sizeof(mask->control[i].mcs));
2427+
2428+ sdata->rc_has_mcs_mask[i] = false;
2429+ if (!sband)
2430+ continue;
2431+
2432+ for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++)
2433+ if (~sdata->rc_rateidx_mcs_mask[i][j]) {
2434+ sdata->rc_has_mcs_mask[i] = true;
2435+ break;
2436+ }
24222437 }
24232438
24242439 return 0;
net/mac80211/chan.c+33−10
@@ -57,6 +57,22 @@ ieee80211_find_chanctx(struct ieee80211_local *local, · 56 unmodified lines
5757 return NULL;
5858 }
5959
60+static bool ieee80211_is_radar_required(struct ieee80211_local *local)
61+{
62+ struct ieee80211_sub_if_data *sdata;
63+
64+ rcu_read_lock();
65+ list_for_each_entry_rcu(sdata, &local->interfaces, list) {
66+ if (sdata->radar_required) {
67+ rcu_read_unlock();
68+ return true;
69+ }
70+ }
71+ rcu_read_unlock();
72+
73+ return false;
74+}
75+
6076 static struct ieee80211_chanctx *
6177 ieee80211_new_chanctx(struct ieee80211_local *local,
6278 const struct cfg80211_chan_def *chandef,
@@ -76,6 +92,9 @@ ieee80211_new_chanctx(struct ieee80211_local *local, · 13 unmodified lines
7692 ctx->conf.rx_chains_static = 1;
7793 ctx->conf.rx_chains_dynamic = 1;
7894 ctx->mode = mode;
95+ ctx->conf.radar_enabled = ieee80211_is_radar_required(local);
96+ if (!local->use_chanctx)
97+ local->hw.conf.radar_enabled = ctx->conf.radar_enabled;
7998
8099 /* acquire mutex to prevent idle from changing */
81100 mutex_lock(&local->mtx);
@@ -110,6 +129,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local, · 28 unmodified lines
110129 static void ieee80211_free_chanctx(struct ieee80211_local *local,
111130 struct ieee80211_chanctx *ctx)
112131 {
132+ bool check_single_channel = false;
113133 lockdep_assert_held(&local->chanctx_mtx);
114134
115135 WARN_ON_ONCE(ctx->refcount != 0);
@@ -119,6 +139,14 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local, · 3 unmodified lines
119139 chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
120140 chandef->center_freq1 = chandef->chan->center_freq;
121141 chandef->center_freq2 = 0;
142+
143+ /* NOTE: Disabling radar is only valid here for
144+ * single channel context. To be sure, check it ...
145+ */
146+ if (local->hw.conf.radar_enabled)
147+ check_single_channel = true;
148+ local->hw.conf.radar_enabled = false;
149+
122150 ieee80211_hw_config(local, 0);
123151 } else {
124152 drv_remove_chanctx(local, ctx);
@@ -127,6 +155,9 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local, · 2 unmodified lines
127155 list_del_rcu(&ctx->list);
128156 kfree_rcu(ctx, rcu_head);
129157
158+ /* throw a warning if this wasn't the only channel context. */
159+ WARN_ON(check_single_channel && !list_empty(&local->chanctx_list));
160+
130161 mutex_lock(&local->mtx);
131162 ieee80211_recalc_idle(local);
132163 mutex_unlock(&local->mtx);
@@ -238,19 +269,11 @@ static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata) · 105 unmodified lines
238269 void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
239270 struct ieee80211_chanctx *chanctx)
240271 {
241− struct ieee80211_sub_if_data *sdata;
242− bool radar_enabled = false;
272+ bool radar_enabled;
243273
244274 lockdep_assert_held(&local->chanctx_mtx);
245275
246− rcu_read_lock();
247− list_for_each_entry_rcu(sdata, &local->interfaces, list) {
248− if (sdata->radar_required) {
249− radar_enabled = true;
250− break;
251− }
252− }
253− rcu_read_unlock();
276+ radar_enabled = ieee80211_is_radar_required(local);
254277
255278 if (radar_enabled == chanctx->conf.radar_enabled)
256279 return;
net/mac80211/ibss.c+5−1
@@ -209,6 +209,8 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, · 208 unmodified lines
209209 sdata->vif.bss_conf.enable_beacon = true;
210210 sdata->vif.bss_conf.beacon_int = beacon_int;
211211 sdata->vif.bss_conf.basic_rates = basic_rates;
212+ sdata->vif.bss_conf.ssid_len = ifibss->ssid_len;
213+ memcpy(sdata->vif.bss_conf.ssid, ifibss->ssid, ifibss->ssid_len);
212214 bss_change = BSS_CHANGED_BEACON_INT;
213215 bss_change |= ieee80211_reset_erp_info(sdata);
214216 bss_change |= BSS_CHANGED_BSSID;
@@ -217,6 +219,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, · 2 unmodified lines
217219 bss_change |= BSS_CHANGED_BASIC_RATES;
218220 bss_change |= BSS_CHANGED_HT;
219221 bss_change |= BSS_CHANGED_IBSS;
222+ bss_change |= BSS_CHANGED_SSID;
220223
221224 /*
222225 * In 5 GHz/802.11a, we can always use short slot time.
@@ -911,7 +914,7 @@ void ieee80211_rx_mgmt_probe_beacon(struct ieee80211_sub_if_data *sdata, · 688 unmodified lines
911914 return;
912915
913916 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
914− &elems);
917+ false, &elems);
915918
916919 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
917920 }
@@ -1159,6 +1162,7 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) · 241 unmodified lines
11591162 sdata->vif.bss_conf.ibss_joined = false;
11601163 sdata->vif.bss_conf.ibss_creator = false;
11611164 sdata->vif.bss_conf.enable_beacon = false;
1165+ sdata->vif.bss_conf.ssid_len = 0;
11621166 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
11631167 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
11641168 BSS_CHANGED_IBSS);
net/mac80211/ieee80211_i.h+10−8
@@ -156,6 +156,7 @@ struct ieee80211_tx_data { · 155 unmodified lines
156156 struct ieee80211_sub_if_data *sdata;
157157 struct sta_info *sta;
158158 struct ieee80211_key *key;
159+ struct ieee80211_tx_rate rate;
159160
160161 unsigned int flags;
161162 };
@@ -740,6 +741,8 @@ struct ieee80211_sub_if_data { · 578 unmodified lines
740741
741742 /* bitmap of allowed (non-MCS) rate indexes for rate control */
742743 u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
744+
745+ bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
743746 u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
744747
745748 union {
@@ -1020,7 +1023,7 @@ struct ieee80211_local { · 274 unmodified lines
10201023 enum mac80211_scan_state next_scan_state;
10211024 struct delayed_work scan_work;
10221025 struct ieee80211_sub_if_data __rcu *scan_sdata;
1023− struct ieee80211_channel *csa_channel;
1026+ struct cfg80211_chan_def csa_chandef;
10241027 /* For backward compatibility only -- do not use */
10251028 struct cfg80211_chan_def _oper_chandef;
10261029
@@ -1179,10 +1182,13 @@ struct ieee802_11_elems { · 152 unmodified lines
11791182 const u8 *perr;
11801183 const struct ieee80211_rann_ie *rann;
11811184 const struct ieee80211_channel_sw_ie *ch_switch_ie;
1185+ const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1186+ const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
11821187 const u8 *country_elem;
11831188 const u8 *pwr_constr_elem;
11841189 const struct ieee80211_timeout_interval_ie *timeout_int;
11851190 const u8 *opmode_notif;
1191+ const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
11861192
11871193 /* length of them, respectively */
11881194 u8 ssid_len;
@@ -1253,10 +1259,6 @@ void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata); · 64 unmodified lines
12531259 int ieee80211_max_network_latency(struct notifier_block *nb,
12541260 unsigned long data, void *dummy);
12551261 int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
1256−void
1257−ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1258− const struct ieee80211_channel_sw_ie *sw_elem,
1259− struct ieee80211_bss *bss, u64 timestamp);
12601262 void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
12611263 void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
12621264 struct sk_buff *skb);
@@ -1494,13 +1496,13 @@ static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, · 231 unmodified lines
14941496 ieee80211_tx_skb_tid(sdata, skb, 7);
14951497 }
14961498
1497−u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
1499+u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action,
14981500 struct ieee802_11_elems *elems,
14991501 u64 filter, u32 crc);
1500−static inline void ieee802_11_parse_elems(u8 *start, size_t len,
1502+static inline void ieee802_11_parse_elems(u8 *start, size_t len, bool action,
15011503 struct ieee802_11_elems *elems)
15021504 {
1503− ieee802_11_parse_elems_crc(start, len, elems, 0, 0);
1505+ ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
15041506 }
15051507
15061508 u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
net/mac80211/iface.c+3−2
@@ -839,11 +839,12 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, · 838 unmodified lines
839839 *
840840 * sta_info_flush_cleanup() requires rcu_barrier()
841841 * first to wait for the station call_rcu() calls
842− * to complete, here we need at least sychronize_rcu()
843− * it to wait for the RX path in case it is using the
842+ * to complete, and we also need synchronize_rcu()
843+ * to wait for the RX path in case it is using the
844844 * interface and enqueuing frames at this very time on
845845 * another CPU.
846846 */
847+ synchronize_rcu();
847848 rcu_barrier();
848849 sta_info_flush_cleanup(sdata);
849850
net/mac80211/main.c+12−11
@@ -668,6 +668,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) · 667 unmodified lines
668668 int channels, max_bitrates;
669669 bool supp_ht, supp_vht;
670670 netdev_features_t feature_whitelist;
671+ struct cfg80211_chan_def dflt_chandef = {};
671672 static const u32 cipher_suites[] = {
672673 /* keep WEP first, it may be removed below */
673674 WLAN_CIPHER_SUITE_WEP40,
@@ -745,19 +746,19 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) · 71 unmodified lines
745746 sband = local->hw.wiphy->bands[band];
746747 if (!sband)
747748 continue;
748− if (!local->use_chanctx && !local->_oper_chandef.chan) {
749+
750+ if (!dflt_chandef.chan) {
751+ cfg80211_chandef_create(&dflt_chandef,
752+ &sband->channels[0],
753+ NL80211_CHAN_NO_HT);
749754 /* init channel we're on */
750− struct cfg80211_chan_def chandef = {
751− .chan = &sband->channels[0],
752− .width = NL80211_CHAN_NO_HT,
753− .center_freq1 = sband->channels[0].center_freq,
754− .center_freq2 = 0
755− };
756− local->hw.conf.chandef = local->_oper_chandef = chandef;
755+ if (!local->use_chanctx && !local->_oper_chandef.chan) {
756+ local->hw.conf.chandef = dflt_chandef;
757+ local->_oper_chandef = dflt_chandef;
758+ }
759+ local->monitor_chandef = dflt_chandef;
757760 }
758− cfg80211_chandef_create(&local->monitor_chandef,
759− &sband->channels[0],
760− NL80211_CHAN_NO_HT);
761+
761762 channels += sband->n_channels;
762763
763764 if (max_bitrates < sband->n_bitrates)
net/mac80211/mesh.c+2−2
@@ -838,7 +838,7 @@ ieee80211_mesh_rx_probe_req(struct ieee80211_sub_if_data *sdata, · 837 unmodified lines
838838 if (baselen > len)
839839 return;
840840
841− ieee802_11_parse_elems(pos, len - baselen, &elems);
841+ ieee802_11_parse_elems(pos, len - baselen, false, &elems);
842842
843843 /* 802.11-2012 10.1.4.3.2 */
844844 if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) &&
@@ -899,7 +899,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, · 54 unmodified lines
899899 return;
900900
901901 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
902− &elems);
902+ false, &elems);
903903
904904 /* ignore non-mesh or secure / unsecure mismatch */
905905 if ((!elems.mesh_id || !elems.mesh_config) ||
net/mac80211/mesh_hwmp.c+1−1
@@ -880,7 +880,7 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, · 879 unmodified lines
880880
881881 baselen = (u8 *) mgmt->u.action.u.mesh_action.variable - (u8 *) mgmt;
882882 ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable,
883− len - baselen, &elems);
883+ len - baselen, false, &elems);
884884
885885 if (elems.preq) {
886886 if (elems.preq_len != 37)
net/mac80211/mesh_plink.c+3−3
@@ -544,8 +544,8 @@ static void mesh_plink_timer(unsigned long data) · 543 unmodified lines
544544 return;
545545 }
546546 mpl_dbg(sta->sdata,
547− "Mesh plink timer for %pM fired on state %d\n",
548− sta->sta.addr, sta->plink_state);
547+ "Mesh plink timer for %pM fired on state %s\n",
548+ sta->sta.addr, mplstates[sta->plink_state]);
549549 reason = 0;
550550 llid = sta->llid;
551551 plid = sta->plid;
@@ -687,7 +687,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, · 135 unmodified lines
687687 baseaddr += 4;
688688 baselen += 4;
689689 }
690− ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
690+ ieee802_11_parse_elems(baseaddr, len - baselen, true, &elems);
691691
692692 if (!elems.peering) {
693693 mpl_dbg(sdata,
net/mac80211/mlme.c+233−101
@@ -289,6 +289,8 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, · 288 unmodified lines
289289 } else {
290290 /* 40 MHz (and 80 MHz) must be supported for VHT */
291291 ret = IEEE80211_STA_DISABLE_VHT;
292+ /* also mark 40 MHz disabled */
293+ ret |= IEEE80211_STA_DISABLE_40MHZ;
292294 goto out;
293295 }
294296
@@ -303,12 +305,6 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, · 8 unmodified lines
303305 channel->band);
304306 vht_chandef.center_freq2 = 0;
305307
306− if (vht_oper->center_freq_seg2_idx)
307− vht_chandef.center_freq2 =
308− ieee80211_channel_to_frequency(
309− vht_oper->center_freq_seg2_idx,
310− channel->band);
311−
312308 switch (vht_oper->chan_width) {
313309 case IEEE80211_VHT_CHANWIDTH_USE_HT:
314310 vht_chandef.width = chandef->width;
@@ -321,6 +317,10 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, · 6 unmodified lines
321317 break;
322318 case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
323319 vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
320+ vht_chandef.center_freq2 =
321+ ieee80211_channel_to_frequency(
322+ vht_oper->center_freq_seg2_idx,
323+ channel->band);
324324 break;
325325 default:
326326 if (verbose)
@@ -604,7 +604,6 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, · 277 unmodified lines
604604 u8 *pos;
605605 u32 cap;
606606 struct ieee80211_sta_vht_cap vht_cap;
607− int i;
608607
609608 BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap));
610609
@@ -632,37 +631,6 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, · 21 unmodified lines
632631 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)))
633632 cap &= ~IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
634633
635− if (!(ap_vht_cap->vht_cap_info &
636− cpu_to_le32(IEEE80211_VHT_CAP_TXSTBC)))
637− cap &= ~(IEEE80211_VHT_CAP_RXSTBC_1 |
638− IEEE80211_VHT_CAP_RXSTBC_3 |
639− IEEE80211_VHT_CAP_RXSTBC_4);
640−
641− for (i = 0; i < 8; i++) {
642− int shift = i * 2;
643− u16 mask = IEEE80211_VHT_MCS_NOT_SUPPORTED << shift;
644− u16 ap_mcs, our_mcs;
645−
646− ap_mcs = (le16_to_cpu(ap_vht_cap->supp_mcs.tx_mcs_map) &
647− mask) >> shift;
648− our_mcs = (le16_to_cpu(vht_cap.vht_mcs.rx_mcs_map) &
649− mask) >> shift;
650−
651− if (our_mcs == IEEE80211_VHT_MCS_NOT_SUPPORTED)
652− continue;
653−
654− switch (ap_mcs) {
655− default:
656− if (our_mcs <= ap_mcs)
657− break;
658− /* fall through */
659− case IEEE80211_VHT_MCS_NOT_SUPPORTED:
660− vht_cap.vht_mcs.rx_mcs_map &= cpu_to_le16(~mask);
661− vht_cap.vht_mcs.rx_mcs_map |=
662− cpu_to_le16(ap_mcs << shift);
663− }
664− }
665−
666634 /* reserve and fill IE */
667635 pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2);
668636 ieee80211_ie_build_vht_cap(pos, &vht_cap, cap);
@@ -998,16 +966,7 @@ static void ieee80211_chswitch_work(struct work_struct *work) · 329 unmodified lines
998966 if (!ifmgd->associated)
999967 goto out;
1000968
1001− /*
1002− * FIXME: Here we are downgrading to NL80211_CHAN_WIDTH_20_NOHT
1003− * and don't adjust our ht/vht settings
1004− * This is wrong - we should behave according to the CSA params
1005− */
1006− local->_oper_chandef.chan = local->csa_channel;
1007− local->_oper_chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
1008− local->_oper_chandef.center_freq1 =
1009− local->_oper_chandef.chan->center_freq;
1010− local->_oper_chandef.center_freq2 = 0;
969+ local->_oper_chandef = local->csa_chandef;
1011970
1012971 if (!local->ops->channel_switch) {
1013972 /* call "hw_config" only if doing sw channel switch */
@@ -1054,56 +1013,193 @@ static void ieee80211_chswitch_timer(unsigned long data) · 40 unmodified lines
10541013 ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work);
10551014 }
10561015
1057−void
1016+static void
10581017 ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1059− const struct ieee80211_channel_sw_ie *sw_elem,
1060− struct ieee80211_bss *bss, u64 timestamp)
1018+ u64 timestamp, struct ieee802_11_elems *elems)
10611019 {
1062− struct cfg80211_bss *cbss =
1063− container_of((void *)bss, struct cfg80211_bss, priv);
1064− struct ieee80211_channel *new_ch;
1020+ struct ieee80211_local *local = sdata->local;
10651021 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1066− int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num,
1067− cbss->channel->band);
1022+ struct cfg80211_bss *cbss = ifmgd->associated;
1023+ struct ieee80211_bss *bss;
10681024 struct ieee80211_chanctx *chanctx;
1025+ enum ieee80211_band new_band;
1026+ int new_freq;
1027+ u8 new_chan_no;
1028+ u8 count;
1029+ u8 mode;
1030+ struct ieee80211_channel *new_chan;
1031+ struct cfg80211_chan_def new_chandef = {};
1032+ struct cfg80211_chan_def new_vht_chandef = {};
1033+ const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
1034+ const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
1035+ int secondary_channel_offset = -1;
10691036
10701037 ASSERT_MGD_MTX(ifmgd);
10711038
1072− if (!ifmgd->associated)
1039+ if (!cbss)
10731040 return;
10741041
1075− if (sdata->local->scanning)
1042+ if (local->scanning)
10761043 return;
10771044
1078− /* Disregard subsequent beacons if we are already running a timer
1079− processing a CSA */
1080−
1045+ /* disregard subsequent announcements if we are already processing */
10811046 if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED)
10821047 return;
10831048
1084− new_ch = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
1085− if (!new_ch || new_ch->flags & IEEE80211_CHAN_DISABLED) {
1049+ sec_chan_offs = elems->sec_chan_offs;
1050+ wide_bw_chansw_ie = elems->wide_bw_chansw_ie;
1051+
1052+ if (ifmgd->flags & (IEEE80211_STA_DISABLE_HT |
1053+ IEEE80211_STA_DISABLE_40MHZ)) {
1054+ sec_chan_offs = NULL;
1055+ wide_bw_chansw_ie = NULL;
1056+ }
1057+
1058+ if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT)
1059+ wide_bw_chansw_ie = NULL;
1060+
1061+ if (elems->ext_chansw_ie) {
1062+ if (!ieee80211_operating_class_to_band(
1063+ elems->ext_chansw_ie->new_operating_class,
1064+ &new_band)) {
1065+ sdata_info(sdata,
1066+ "cannot understand ECSA IE operating class %d, disconnecting\n",
1067+ elems->ext_chansw_ie->new_operating_class);
1068+ ieee80211_queue_work(&local->hw,
1069+ &ifmgd->csa_connection_drop_work);
1070+ }
1071+ new_chan_no = elems->ext_chansw_ie->new_ch_num;
1072+ count = elems->ext_chansw_ie->count;
1073+ mode = elems->ext_chansw_ie->mode;
1074+ } else if (elems->ch_switch_ie) {
1075+ new_band = cbss->channel->band;
1076+ new_chan_no = elems->ch_switch_ie->new_ch_num;
1077+ count = elems->ch_switch_ie->count;
1078+ mode = elems->ch_switch_ie->mode;
1079+ } else {
1080+ /* nothing here we understand */
1081+ return;
1082+ }
1083+
1084+ bss = (void *)cbss->priv;
1085+
1086+ new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band);
1087+ new_chan = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
1088+ if (!new_chan || new_chan->flags & IEEE80211_CHAN_DISABLED) {
10861089 sdata_info(sdata,
10871090 "AP %pM switches to unsupported channel (%d MHz), disconnecting\n",
10881091 ifmgd->associated->bssid, new_freq);
1089− ieee80211_queue_work(&sdata->local->hw,
1092+ ieee80211_queue_work(&local->hw,
1093+ &ifmgd->csa_connection_drop_work);
1094+ return;
1095+ }
1096+
1097+ if (sec_chan_offs) {
1098+ secondary_channel_offset = sec_chan_offs->sec_chan_offs;
1099+ } else if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
1100+ /* if HT is enabled and the IE not present, it's still HT */
1101+ secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
1102+ }
1103+
1104+ switch (secondary_channel_offset) {
1105+ default:
1106+ /* secondary_channel_offset was present but is invalid */
1107+ case IEEE80211_HT_PARAM_CHA_SEC_NONE:
1108+ cfg80211_chandef_create(&new_chandef, new_chan,
1109+ NL80211_CHAN_HT20);
1110+ break;
1111+ case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
1112+ cfg80211_chandef_create(&new_chandef, new_chan,
1113+ NL80211_CHAN_HT40PLUS);
1114+ break;
1115+ case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
1116+ cfg80211_chandef_create(&new_chandef, new_chan,
1117+ NL80211_CHAN_HT40MINUS);
1118+ break;
1119+ case -1:
1120+ cfg80211_chandef_create(&new_chandef, new_chan,
1121+ NL80211_CHAN_NO_HT);
1122+ break;
1123+ }
1124+
1125+ if (wide_bw_chansw_ie) {
1126+ new_vht_chandef.chan = new_chan;
1127+ new_vht_chandef.center_freq1 =
1128+ ieee80211_channel_to_frequency(
1129+ wide_bw_chansw_ie->new_center_freq_seg0,
1130+ new_band);
1131+
1132+ switch (wide_bw_chansw_ie->new_channel_width) {
1133+ default:
1134+ /* hmmm, ignore VHT and use HT if present */
1135+ case IEEE80211_VHT_CHANWIDTH_USE_HT:
1136+ new_vht_chandef.chan = NULL;
1137+ break;
1138+ case IEEE80211_VHT_CHANWIDTH_80MHZ:
1139+ new_vht_chandef.width = NL80211_CHAN_WIDTH_80;
1140+ break;
1141+ case IEEE80211_VHT_CHANWIDTH_160MHZ:
1142+ new_vht_chandef.width = NL80211_CHAN_WIDTH_160;
1143+ break;
1144+ case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
1145+ /* field is otherwise reserved */
1146+ new_vht_chandef.center_freq2 =
1147+ ieee80211_channel_to_frequency(
1148+ wide_bw_chansw_ie->new_center_freq_seg1,
1149+ new_band);
1150+ new_vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
1151+ break;
1152+ }
1153+ if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ &&
1154+ new_vht_chandef.width == NL80211_CHAN_WIDTH_80P80)
1155+ chandef_downgrade(&new_vht_chandef);
1156+ if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ &&
1157+ new_vht_chandef.width == NL80211_CHAN_WIDTH_160)
1158+ chandef_downgrade(&new_vht_chandef);
1159+ if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ &&
1160+ new_vht_chandef.width > NL80211_CHAN_WIDTH_20)
1161+ chandef_downgrade(&new_vht_chandef);
1162+ }
1163+
1164+ /* if VHT data is there validate & use it */
1165+ if (new_vht_chandef.chan) {
1166+ if (!cfg80211_chandef_compatible(&new_vht_chandef,
1167+ &new_chandef)) {
1168+ sdata_info(sdata,
1169+ "AP %pM CSA has inconsistent channel data, disconnecting\n",
1170+ ifmgd->associated->bssid);
1171+ ieee80211_queue_work(&local->hw,
1172+ &ifmgd->csa_connection_drop_work);
1173+ return;
1174+ }
1175+ new_chandef = new_vht_chandef;
1176+ }
1177+
1178+ if (!cfg80211_chandef_usable(local->hw.wiphy, &new_chandef,
1179+ IEEE80211_CHAN_DISABLED)) {
1180+ sdata_info(sdata,
1181+ "AP %pM switches to unsupported channel (%d MHz, width:%d, CF1/2: %d/%d MHz), disconnecting\n",
1182+ ifmgd->associated->bssid, new_freq,
1183+ new_chandef.width, new_chandef.center_freq1,
1184+ new_chandef.center_freq2);
1185+ ieee80211_queue_work(&local->hw,
10901186 &ifmgd->csa_connection_drop_work);
10911187 return;
10921188 }
10931189
10941190 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
10951191
1096− if (sdata->local->use_chanctx) {
1192+ if (local->use_chanctx) {
10971193 sdata_info(sdata,
10981194 "not handling channel switch with channel contexts\n");
1099− ieee80211_queue_work(&sdata->local->hw,
1195+ ieee80211_queue_work(&local->hw,
11001196 &ifmgd->csa_connection_drop_work);
11011197 return;
11021198 }
11031199
1104− mutex_lock(&sdata->local->chanctx_mtx);
1200+ mutex_lock(&local->chanctx_mtx);
11051201 if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) {
1106− mutex_unlock(&sdata->local->chanctx_mtx);
1202+ mutex_unlock(&local->chanctx_mtx);
11071203 return;
11081204 }
11091205 chanctx = container_of(rcu_access_pointer(sdata->vif.chanctx_conf),
@@ -1111,40 +1207,39 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, · 1 unmodified line
11111207 if (chanctx->refcount > 1) {
11121208 sdata_info(sdata,
11131209 "channel switch with multiple interfaces on the same channel, disconnecting\n");
1114− ieee80211_queue_work(&sdata->local->hw,
1210+ ieee80211_queue_work(&local->hw,
11151211 &ifmgd->csa_connection_drop_work);
1116− mutex_unlock(&sdata->local->chanctx_mtx);
1212+ mutex_unlock(&local->chanctx_mtx);
11171213 return;
11181214 }
1119− mutex_unlock(&sdata->local->chanctx_mtx);
1215+ mutex_unlock(&local->chanctx_mtx);
11201216
1121− sdata->local->csa_channel = new_ch;
1217+ local->csa_chandef = new_chandef;
11221218
1123− if (sw_elem->mode)
1124− ieee80211_stop_queues_by_reason(&sdata->local->hw,
1219+ if (mode)
1220+ ieee80211_stop_queues_by_reason(&local->hw,
11251221 IEEE80211_MAX_QUEUE_MAP,
11261222 IEEE80211_QUEUE_STOP_REASON_CSA);
11271223
1128− if (sdata->local->ops->channel_switch) {
1224+ if (local->ops->channel_switch) {
11291225 /* use driver's channel switch callback */
11301226 struct ieee80211_channel_switch ch_switch = {
11311227 .timestamp = timestamp,
1132− .block_tx = sw_elem->mode,
1133− .channel = new_ch,
1134− .count = sw_elem->count,
1228+ .block_tx = mode,
1229+ .chandef = new_chandef,
1230+ .count = count,
11351231 };
11361232
1137− drv_channel_switch(sdata->local, &ch_switch);
1233+ drv_channel_switch(local, &ch_switch);
11381234 return;
11391235 }
11401236
11411237 /* channel switch handled in software */
1142− if (sw_elem->count <= 1)
1143− ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
1238+ if (count <= 1)
1239+ ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work);
11441240 else
11451241 mod_timer(&ifmgd->chswitch_timer,
1146− TU_TO_EXP_TIME(sw_elem->count *
1147− cbss->beacon_interval));
1242+ TU_TO_EXP_TIME(count * cbss->beacon_interval));
11481243 }
11491244
11501245 static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
@@ -1566,6 +1661,7 @@ static bool ieee80211_sta_wmm_params(struct ieee80211_local *local, · 415 unmodified lines
15661661 params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4);
15671662 params.cw_min = ecw2cw(pos[1] & 0x0f);
15681663 params.txop = get_unaligned_le16(pos + 2);
1664+ params.acm = acm;
15691665 params.uapsd = uapsd;
15701666
15711667 mlme_dbg(sdata,
@@ -2120,7 +2216,6 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif) · 548 unmodified lines
21202216
21212217 trace_api_beacon_loss(sdata);
21222218
2123− WARN_ON(hw->flags & IEEE80211_HW_CONNECTION_MONITOR);
21242219 sdata->u.mgd.connection_loss = false;
21252220 ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work);
21262221 }
@@ -2170,7 +2265,7 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, · 43 unmodified lines
21702265 u32 tx_flags = 0;
21712266
21722267 pos = mgmt->u.auth.variable;
2173− ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
2268+ ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
21742269 if (!elems.challenge)
21752270 return;
21762271 auth_data->expected_transaction = 4;
@@ -2435,7 +2530,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, · 258 unmodified lines
24352530 }
24362531
24372532 pos = mgmt->u.assoc_resp.variable;
2438− ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
2533+ ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
24392534
24402535 if (!elems.supp_rates) {
24412536 sdata_info(sdata, "no SuppRates element in AssocResp\n");
@@ -2604,7 +2699,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, · 162 unmodified lines
26042699 capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14))));
26052700
26062701 pos = mgmt->u.assoc_resp.variable;
2607− ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
2702+ ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
26082703
26092704 if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
26102705 elems.timeout_int &&
@@ -2659,6 +2754,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, · 48 unmodified lines
26592754 struct ieee80211_channel *channel;
26602755 bool need_ps = false;
26612756
2757+ lockdep_assert_held(&sdata->u.mgd.mtx);
2758+
26622759 if ((sdata->u.mgd.associated &&
26632760 ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) ||
26642761 (sdata->u.mgd.assoc_data &&
@@ -2689,7 +2786,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, · 24 unmodified lines
26892786 if (bss)
26902787 ieee80211_rx_bss_put(local, bss);
26912788
2692− if (!sdata->u.mgd.associated)
2789+ if (!sdata->u.mgd.associated ||
2790+ !ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid))
26932791 return;
26942792
26952793 if (need_ps) {
@@ -2698,10 +2796,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, · 2 unmodified lines
26982796 mutex_unlock(&local->iflist_mtx);
26992797 }
27002798
2701− if (elems->ch_switch_ie &&
2702− memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, ETH_ALEN) == 0)
2703− ieee80211_sta_process_chanswitch(sdata, elems->ch_switch_ie,
2704− bss, rx_status->mactime);
2799+ ieee80211_sta_process_chanswitch(sdata, rx_status->mactime, elems);
2800+
27052801 }
27062802
27072803
@@ -2726,7 +2822,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, · 18 unmodified lines
27262822 return;
27272823
27282824 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
2729− &elems);
2825+ false, &elems);
27302826
27312827 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
27322828
@@ -2809,7 +2905,7 @@ ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, · 76 unmodified lines
28092905 if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon &&
28102906 ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) {
28112907 ieee802_11_parse_elems(mgmt->u.beacon.variable,
2812− len - baselen, &elems);
2908+ len - baselen, false, &elems);
28132909
28142910 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
28152911 ifmgd->assoc_data->have_beacon = true;
@@ -2919,7 +3015,7 @@ ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, · 103 unmodified lines
29193015
29203016 ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4);
29213017 ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable,
2922− len - baselen, &elems,
3018+ len - baselen, false, &elems,
29233019 care_about_ies, ncrc);
29243020
29253021 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) {
@@ -3066,6 +3162,8 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, · 140 unmodified lines
30663162 enum rx_mgmt_action rma = RX_MGMT_NONE;
30673163 u8 deauth_buf[IEEE80211_DEAUTH_FRAME_LEN];
30683164 u16 fc;
3165+ struct ieee802_11_elems elems;
3166+ int ies_len;
30693167
30703168 rx_status = (struct ieee80211_rx_status *) skb->cb;
30713169 mgmt = (struct ieee80211_mgmt *) skb->data;
@@ -3095,14 +3193,48 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, · 23 unmodified lines
30953193 rma = ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, &bss);
30963194 break;
30973195 case IEEE80211_STYPE_ACTION:
3098− switch (mgmt->u.action.category) {
3099− case WLAN_CATEGORY_SPECTRUM_MGMT:
3196+ if (mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) {
3197+ ies_len = skb->len -
3198+ offsetof(struct ieee80211_mgmt,
3199+ u.action.u.chan_switch.variable);
3200+
3201+ if (ies_len < 0)
3202+ break;
3203+
3204+ ieee802_11_parse_elems(
3205+ mgmt->u.action.u.chan_switch.variable,
3206+ ies_len, true, &elems);
3207+
3208+ if (elems.parse_error)
3209+ break;
3210+
31003211 ieee80211_sta_process_chanswitch(sdata,
3101− &mgmt->u.action.u.chan_switch.sw_elem,
3102− (void *)ifmgd->associated->priv,
3103− rx_status->mactime);
3104− break;
3212+ rx_status->mactime,
3213+ &elems);
3214+ } else if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) {
3215+ ies_len = skb->len -
3216+ offsetof(struct ieee80211_mgmt,
3217+ u.action.u.ext_chan_switch.variable);
3218+
3219+ if (ies_len < 0)
3220+ break;
3221+
3222+ ieee802_11_parse_elems(
3223+ mgmt->u.action.u.ext_chan_switch.variable,
3224+ ies_len, true, &elems);
3225+
3226+ if (elems.parse_error)
3227+ break;
3228+
3229+ /* for the handling code pretend this was also an IE */
3230+ elems.ext_chansw_ie =
3231+ &mgmt->u.action.u.ext_chan_switch.data;
3232+
3233+ ieee80211_sta_process_chanswitch(sdata,
3234+ rx_status->mactime,
3235+ &elems);
31053236 }
3237+ break;
31063238 }
31073239 mutex_unlock(&ifmgd->mtx);
31083240
net/mac80211/pm.c+2−1
@@ -37,8 +37,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) · 36 unmodified lines
3737 IEEE80211_MAX_QUEUE_MAP,
3838 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
3939
40− /* flush out all packets */
40+ /* flush out all packets and station cleanup call_rcu()s */
4141 synchronize_net();
42+ rcu_barrier();
4243
4344 ieee80211_flush_queues(local, NULL);
4445
net/mac80211/rate.c+268−56
@@ -252,6 +252,25 @@ rate_lowest_non_cck_index(struct ieee80211_supported_band *sband, · 251 unmodified lines
252252 return 0;
253253 }
254254
255+static void __rate_control_send_low(struct ieee80211_hw *hw,
256+ struct ieee80211_supported_band *sband,
257+ struct ieee80211_sta *sta,
258+ struct ieee80211_tx_info *info)
259+{
260+ if ((sband->band != IEEE80211_BAND_2GHZ) ||
261+ !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
262+ info->control.rates[0].idx = rate_lowest_index(sband, sta);
263+ else
264+ info->control.rates[0].idx =
265+ rate_lowest_non_cck_index(sband, sta);
266+
267+ info->control.rates[0].count =
268+ (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
269+ 1 : hw->max_rate_tries;
270+
271+ info->control.skip_table = 1;
272+}
273+
255274
256275 bool rate_control_send_low(struct ieee80211_sta *sta,
257276 void *priv_sta,
@@ -262,16 +281,8 @@ bool rate_control_send_low(struct ieee80211_sta *sta, · 4 unmodified lines
262281 int mcast_rate;
263282
264283 if (!sta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
265− if ((sband->band != IEEE80211_BAND_2GHZ) ||
266− !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
267− info->control.rates[0].idx =
268− rate_lowest_index(txrc->sband, sta);
269− else
270− info->control.rates[0].idx =
271− rate_lowest_non_cck_index(txrc->sband, sta);
272− info->control.rates[0].count =
273− (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
274− 1 : txrc->hw->max_rate_tries;
284+ __rate_control_send_low(txrc->hw, sband, sta, info);
285+
275286 if (!sta && txrc->bss) {
276287 mcast_rate = txrc->bss_conf->mcast_rate[sband->band];
277288 if (mcast_rate > 0) {
@@ -355,7 +366,8 @@ static bool rate_idx_match_mcs_mask(struct ieee80211_tx_rate *rate, · 77 unmodified lines
355366
356367
357368 static void rate_idx_match_mask(struct ieee80211_tx_rate *rate,
358− struct ieee80211_tx_rate_control *txrc,
369+ struct ieee80211_supported_band *sband,
370+ enum nl80211_chan_width chan_width,
359371 u32 mask,
360372 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN])
361373 {
@@ -375,27 +387,17 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, · 13 unmodified lines
375387 IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
376388 alt_rate.count = rate->count;
377389 if (rate_idx_match_legacy_mask(&alt_rate,
378− txrc->sband->n_bitrates,
379− mask)) {
390+ sband->n_bitrates, mask)) {
380391 *rate = alt_rate;
381392 return;
382393 }
383394 } else {
384− struct sk_buff *skb = txrc->skb;
385− struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
386− __le16 fc;
387−
388395 /* handle legacy rates */
389− if (rate_idx_match_legacy_mask(rate, txrc->sband->n_bitrates,
390− mask))
396+ if (rate_idx_match_legacy_mask(rate, sband->n_bitrates, mask))
391397 return;
392398
393399 /* if HT BSS, and we handle a data frame, also try HT rates */
394− if (txrc->bss_conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
395− return;
396−
397− fc = hdr->frame_control;
398− if (!ieee80211_is_data(fc))
400+ if (chan_width == NL80211_CHAN_WIDTH_20_NOHT)
399401 return;
400402
401403 alt_rate.idx = 0;
@@ -408,7 +410,7 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, · 6 unmodified lines
408410
409411 alt_rate.flags |= IEEE80211_TX_RC_MCS;
410412
411− if (txrc->bss_conf->chandef.width == NL80211_CHAN_WIDTH_40)
413+ if (chan_width == NL80211_CHAN_WIDTH_40)
412414 alt_rate.flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
413415
414416 if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) {
@@ -426,6 +428,228 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, · 11 unmodified lines
426428 */
427429 }
428430
431+static void rate_fixup_ratelist(struct ieee80211_vif *vif,
432+ struct ieee80211_supported_band *sband,
433+ struct ieee80211_tx_info *info,
434+ struct ieee80211_tx_rate *rates,
435+ int max_rates)
436+{
437+ struct ieee80211_rate *rate;
438+ bool inval = false;
439+ int i;
440+
441+ /*
442+ * Set up the RTS/CTS rate as the fastest basic rate
443+ * that is not faster than the data rate unless there
444+ * is no basic rate slower than the data rate, in which
445+ * case we pick the slowest basic rate
446+ *
447+ * XXX: Should this check all retry rates?
448+ */
449+ if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
450+ u32 basic_rates = vif->bss_conf.basic_rates;
451+ s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0;
452+
453+ rate = &sband->bitrates[rates[0].idx];
454+
455+ for (i = 0; i < sband->n_bitrates; i++) {
456+ /* must be a basic rate */
457+ if (!(basic_rates & BIT(i)))
458+ continue;
459+ /* must not be faster than the data rate */
460+ if (sband->bitrates[i].bitrate > rate->bitrate)
461+ continue;
462+ /* maximum */
463+ if (sband->bitrates[baserate].bitrate <
464+ sband->bitrates[i].bitrate)
465+ baserate = i;
466+ }
467+
468+ info->control.rts_cts_rate_idx = baserate;
469+ }
470+
471+ for (i = 0; i < max_rates; i++) {
472+ /*
473+ * make sure there's no valid rate following
474+ * an invalid one, just in case drivers don't
475+ * take the API seriously to stop at -1.
476+ */
477+ if (inval) {
478+ rates[i].idx = -1;
479+ continue;
480+ }
481+ if (rates[i].idx < 0) {
482+ inval = true;
483+ continue;
484+ }
485+
486+ /*
487+ * For now assume MCS is already set up correctly, this
488+ * needs to be fixed.
489+ */
490+ if (rates[i].flags & IEEE80211_TX_RC_MCS) {
491+ WARN_ON(rates[i].idx > 76);
492+
493+ if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
494+ info->control.use_cts_prot)
495+ rates[i].flags |=
496+ IEEE80211_TX_RC_USE_CTS_PROTECT;
497+ continue;
498+ }
499+
500+ if (rates[i].flags & IEEE80211_TX_RC_VHT_MCS) {
501+ WARN_ON(ieee80211_rate_get_vht_mcs(&rates[i]) > 9);
502+ continue;
503+ }
504+
505+ /* set up RTS protection if desired */
506+ if (info->control.use_rts) {
507+ rates[i].flags |= IEEE80211_TX_RC_USE_RTS_CTS;
508+ info->control.use_cts_prot = false;
509+ }
510+
511+ /* RC is busted */
512+ if (WARN_ON_ONCE(rates[i].idx >= sband->n_bitrates)) {
513+ rates[i].idx = -1;
514+ continue;
515+ }
516+
517+ rate = &sband->bitrates[rates[i].idx];
518+
519+ /* set up short preamble */
520+ if (info->control.short_preamble &&
521+ rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
522+ rates[i].flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
523+
524+ /* set up G protection */
525+ if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
526+ info->control.use_cts_prot &&
527+ rate->flags & IEEE80211_RATE_ERP_G)
528+ rates[i].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT;
529+ }
530+}
531+
532+
533+static void rate_control_fill_sta_table(struct ieee80211_sta *sta,
534+ struct ieee80211_tx_info *info,
535+ struct ieee80211_tx_rate *rates,
536+ int max_rates)
537+{
538+ struct ieee80211_sta_rates *ratetbl = NULL;
539+ int i;
540+
541+ if (sta && !info->control.skip_table)
542+ ratetbl = rcu_dereference(sta->rates);
543+
544+ /* Fill remaining rate slots with data from the sta rate table. */
545+ max_rates = min_t(int, max_rates, IEEE80211_TX_RATE_TABLE_SIZE);
546+ for (i = 0; i < max_rates; i++) {
547+ if (i < ARRAY_SIZE(info->control.rates) &&
548+ info->control.rates[i].idx >= 0 &&
549+ info->control.rates[i].count) {
550+ if (rates != info->control.rates)
551+ rates[i] = info->control.rates[i];
552+ } else if (ratetbl) {
553+ rates[i].idx = ratetbl->rate[i].idx;
554+ rates[i].flags = ratetbl->rate[i].flags;
555+ if (info->control.use_rts)
556+ rates[i].count = ratetbl->rate[i].count_rts;
557+ else if (info->control.use_cts_prot)
558+ rates[i].count = ratetbl->rate[i].count_cts;
559+ else
560+ rates[i].count = ratetbl->rate[i].count;
561+ } else {
562+ rates[i].idx = -1;
563+ rates[i].count = 0;
564+ }
565+
566+ if (rates[i].idx < 0 || !rates[i].count)
567+ break;
568+ }
569+}
570+
571+static void rate_control_apply_mask(struct ieee80211_sub_if_data *sdata,
572+ struct ieee80211_sta *sta,
573+ struct ieee80211_supported_band *sband,
574+ struct ieee80211_tx_info *info,
575+ struct ieee80211_tx_rate *rates,
576+ int max_rates)
577+{
578+ enum nl80211_chan_width chan_width;
579+ u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
580+ bool has_mcs_mask;
581+ u32 mask;
582+ int i;
583+
584+ /*
585+ * Try to enforce the rateidx mask the user wanted. skip this if the
586+ * default mask (allow all rates) is used to save some processing for
587+ * the common case.
588+ */
589+ mask = sdata->rc_rateidx_mask[info->band];
590+ has_mcs_mask = sdata->rc_has_mcs_mask[info->band];
591+ if (mask == (1 << sband->n_bitrates) - 1 && !has_mcs_mask)
592+ return;
593+
594+ if (has_mcs_mask)
595+ memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
596+ sizeof(mcs_mask));
597+ else
598+ memset(mcs_mask, 0xff, sizeof(mcs_mask));
599+
600+ if (sta) {
601+ /* Filter out rates that the STA does not support */
602+ mask &= sta->supp_rates[info->band];
603+ for (i = 0; i < sizeof(mcs_mask); i++)
604+ mcs_mask[i] &= sta->ht_cap.mcs.rx_mask[i];
605+ }
606+
607+ /*
608+ * Make sure the rate index selected for each TX rate is
609+ * included in the configured mask and change the rate indexes
610+ * if needed.
611+ */
612+ chan_width = sdata->vif.bss_conf.chandef.width;
613+ for (i = 0; i < max_rates; i++) {
614+ /* Skip invalid rates */
615+ if (rates[i].idx < 0)
616+ break;
617+
618+ rate_idx_match_mask(&rates[i], sband, mask, chan_width,
619+ mcs_mask);
620+ }
621+}
622+
623+void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
624+ struct ieee80211_sta *sta,
625+ struct sk_buff *skb,
626+ struct ieee80211_tx_rate *dest,
627+ int max_rates)
628+{
629+ struct ieee80211_sub_if_data *sdata;
630+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
631+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
632+ struct ieee80211_supported_band *sband;
633+
634+ rate_control_fill_sta_table(sta, info, dest, max_rates);
635+
636+ if (!vif)
637+ return;
638+
639+ sdata = vif_to_sdata(vif);
640+ sband = sdata->local->hw.wiphy->bands[info->band];
641+
642+ if (ieee80211_is_data(hdr->frame_control))
643+ rate_control_apply_mask(sdata, sta, sband, info, dest, max_rates);
644+
645+ if (dest[0].idx < 0)
646+ __rate_control_send_low(&sdata->local->hw, sband, sta, info);
647+
648+ if (sta)
649+ rate_fixup_ratelist(vif, sband, info, dest, max_rates);
650+}
651+EXPORT_SYMBOL(ieee80211_get_tx_rates);
652+
429653 void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
430654 struct sta_info *sta,
431655 struct ieee80211_tx_rate_control *txrc)
@@ -435,8 +659,6 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, · 3 unmodified lines
435659 struct ieee80211_sta *ista = NULL;
436660 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
437661 int i;
438− u32 mask;
439− u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
440662
441663 if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
442664 ista = &sta->sta;
@@ -454,37 +676,27 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, · 11 unmodified lines
454676
455677 ref->ops->get_rate(ref->priv, ista, priv_sta, txrc);
456678
457− /*
458− * Try to enforce the rateidx mask the user wanted. skip this if the
459− * default mask (allow all rates) is used to save some processing for
460− * the common case.
461− */
462− mask = sdata->rc_rateidx_mask[info->band];
463− memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
464− sizeof(mcs_mask));
465− if (mask != (1 << txrc->sband->n_bitrates) - 1) {
466− if (sta) {
467− /* Filter out rates that the STA does not support */
468− mask &= sta->sta.supp_rates[info->band];
469− for (i = 0; i < sizeof(mcs_mask); i++)
470− mcs_mask[i] &= sta->sta.ht_cap.mcs.rx_mask[i];
471− }
472− /*
473− * Make sure the rate index selected for each TX rate is
474− * included in the configured mask and change the rate indexes
475− * if needed.
476− */
477− for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
478− /* Skip invalid rates */
479− if (info->control.rates[i].idx < 0)
480− break;
481− rate_idx_match_mask(&info->control.rates[i], txrc,
482− mask, mcs_mask);
483− }
484− }
679+ if (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_RC_TABLE)
680+ return;
681+
682+ ieee80211_get_tx_rates(&sdata->vif, ista, txrc->skb,
683+ info->control.rates,
684+ ARRAY_SIZE(info->control.rates));
685+}
485686
486− BUG_ON(info->control.rates[0].idx < 0);
687+int rate_control_set_rates(struct ieee80211_hw *hw,
688+ struct ieee80211_sta *pubsta,
689+ struct ieee80211_sta_rates *rates)
690+{
691+ struct ieee80211_sta_rates *old = rcu_dereference(pubsta->rates);
692+
693+ rcu_assign_pointer(pubsta->rates, rates);
694+ if (old)
695+ kfree_rcu(old, rcu_head);
696+
697+ return 0;
487698 }
699+EXPORT_SYMBOL(rate_control_set_rates);
488700
489701 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
490702 const char *name)
net/mac80211/rc80211_minstrel.c+113−93
@@ -83,6 +83,50 @@ minstrel_sort_best_tp_rates(struct minstrel_sta_info *mi, int i, u8 *tp_list) · 82 unmodified lines
8383 tp_list[j] = i;
8484 }
8585
86+static void
87+minstrel_set_rate(struct minstrel_sta_info *mi, struct ieee80211_sta_rates *ratetbl,
88+ int offset, int idx)
89+{
90+ struct minstrel_rate *r = &mi->r[idx];
91+
92+ ratetbl->rate[offset].idx = r->rix;
93+ ratetbl->rate[offset].count = r->adjusted_retry_count;
94+ ratetbl->rate[offset].count_cts = r->retry_count_cts;
95+ ratetbl->rate[offset].count_rts = r->retry_count_rtscts;
96+}
97+
98+static void
99+minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
100+{
101+ struct ieee80211_sta_rates *ratetbl;
102+ int i = 0;
103+
104+ ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC);
105+ if (!ratetbl)
106+ return;
107+
108+ /* Start with max_tp_rate */
109+ minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[0]);
110+
111+ if (mp->hw->max_rates >= 3) {
112+ /* At least 3 tx rates supported, use max_tp_rate2 next */
113+ minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[1]);
114+ }
115+
116+ if (mp->hw->max_rates >= 2) {
117+ /* At least 2 tx rates supported, use max_prob_rate next */
118+ minstrel_set_rate(mi, ratetbl, i++, mi->max_prob_rate);
119+ }
120+
121+ /* Use lowest rate last */
122+ ratetbl->rate[i].idx = mi->lowest_rix;
123+ ratetbl->rate[i].count = mp->max_retry;
124+ ratetbl->rate[i].count_cts = mp->max_retry;
125+ ratetbl->rate[i].count_rts = mp->max_retry;
126+
127+ rate_control_set_rates(mp->hw, mi->sta, ratetbl);
128+}
129+
86130 static void
87131 minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
88132 {
@@ -161,6 +205,8 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) · 72 unmodified lines
161205
162206 /* Reset update timer */
163207 mi->stats_update = jiffies;
208+
209+ minstrel_update_rates(mp, mi);
164210 }
165211
166212 static void
@@ -209,9 +255,9 @@ minstrel_get_retry_count(struct minstrel_rate *mr, · 42 unmodified lines
209255 {
210256 unsigned int retry = mr->adjusted_retry_count;
211257
212− if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
258+ if (info->control.use_rts)
213259 retry = max(2U, min(mr->retry_count_rtscts, retry));
214− else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
260+ else if (info->control.use_cts_prot)
215261 retry = max(2U, min(mr->retry_count_cts, retry));
216262 return retry;
217263 }
@@ -240,13 +286,12 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta, · 22 unmodified lines
240286 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
241287 struct minstrel_sta_info *mi = priv_sta;
242288 struct minstrel_priv *mp = priv;
243− struct ieee80211_tx_rate *ar = info->control.rates;
244− unsigned int ndx, sample_ndx = 0;
289+ struct ieee80211_tx_rate *rate = &info->control.rates[0];
290+ struct minstrel_rate *msr, *mr;
291+ unsigned int ndx;
245292 bool mrr_capable;
246− bool indirect_rate_sampling = false;
247− bool rate_sampling = false;
248− int i, delta;
249− int mrr_ndx[3];
293+ bool prev_sample = mi->prev_sample;
294+ int delta;
250295 int sampling_ratio;
251296
252297 /* management/no-ack frames do not use rate control */
@@ -262,107 +307,75 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta, · 9 unmodified lines
262307 else
263308 sampling_ratio = mp->lookaround_rate;
264309
265− /* init rateindex [ndx] with max throughput rate */
266− ndx = mi->max_tp_rate[0];
267−
268310 /* increase sum packet counter */
269311 mi->packet_count++;
270312
271313 delta = (mi->packet_count * sampling_ratio / 100) -
272314 (mi->sample_count + mi->sample_deferred / 2);
273315
274− /* delta > 0: sampling required */
275− if ((delta > 0) && (mrr_capable || !mi->prev_sample)) {
276− struct minstrel_rate *msr;
277− if (mi->packet_count >= 10000) {
278− mi->sample_deferred = 0;
279− mi->sample_count = 0;
280− mi->packet_count = 0;
281− } else if (delta > mi->n_rates * 2) {
282− /* With multi-rate retry, not every planned sample
283− * attempt actually gets used, due to the way the retry
284− * chain is set up - [max_tp,sample,prob,lowest] for
285− * sample_rate < max_tp.
286− *
287− * If there's too much sampling backlog and the link
288− * starts getting worse, minstrel would start bursting
289− * out lots of sampling frames, which would result
290− * in a large throughput loss. */
291− mi->sample_count += (delta - mi->n_rates * 2);
292− }
316+ /* delta < 0: no sampling required */
317+ mi->prev_sample = false;
318+ if (delta < 0 || (!mrr_capable && prev_sample))
319+ return;
293320
294− /* get next random rate sample */
295− sample_ndx = minstrel_get_next_sample(mi);
296− msr = &mi->r[sample_ndx];
297− rate_sampling = true;
298−
299− /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage)
300− * rate sampling method should be used.
301− * Respect such rates that are not sampled for 20 interations.
302− */
303− if (mrr_capable &&
304− msr->perfect_tx_time > mi->r[ndx].perfect_tx_time &&
305− msr->sample_skipped < 20)
306− indirect_rate_sampling = true;
307−
308− if (!indirect_rate_sampling) {
309− if (msr->sample_limit != 0) {
310− ndx = sample_ndx;
311− mi->sample_count++;
312− if (msr->sample_limit > 0)
313− msr->sample_limit--;
314− } else
315− rate_sampling = false;
316− } else {
317− /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark
318− * packets that have the sampling rate deferred to the
319− * second MRR stage. Increase the sample counter only
320− * if the deferred sample rate was actually used.
321− * Use the sample_deferred counter to make sure that
322− * the sampling is not done in large bursts */
323− info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
324− mi->sample_deferred++;
325− }
321+ if (mi->packet_count >= 10000) {
322+ mi->sample_deferred = 0;
323+ mi->sample_count = 0;
324+ mi->packet_count = 0;
325+ } else if (delta > mi->n_rates * 2) {
326+ /* With multi-rate retry, not every planned sample
327+ * attempt actually gets used, due to the way the retry
328+ * chain is set up - [max_tp,sample,prob,lowest] for
329+ * sample_rate < max_tp.
330+ *
331+ * If there's too much sampling backlog and the link
332+ * starts getting worse, minstrel would start bursting
333+ * out lots of sampling frames, which would result
334+ * in a large throughput loss. */
335+ mi->sample_count += (delta - mi->n_rates * 2);
336+ }
337+
338+ /* get next random rate sample */
339+ ndx = minstrel_get_next_sample(mi);
340+ msr = &mi->r[ndx];
341+ mr = &mi->r[mi->max_tp_rate[0]];
342+
343+ /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage)
344+ * rate sampling method should be used.
345+ * Respect such rates that are not sampled for 20 interations.
346+ */
347+ if (mrr_capable &&
348+ msr->perfect_tx_time > mr->perfect_tx_time &&
349+ msr->sample_skipped < 20) {
350+ /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark
351+ * packets that have the sampling rate deferred to the
352+ * second MRR stage. Increase the sample counter only
353+ * if the deferred sample rate was actually used.
354+ * Use the sample_deferred counter to make sure that
355+ * the sampling is not done in large bursts */
356+ info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
357+ rate++;
358+ mi->sample_deferred++;
359+ } else {
360+ if (!msr->sample_limit != 0)
361+ return;
362+
363+ mi->sample_count++;
364+ if (msr->sample_limit > 0)
365+ msr->sample_limit--;
326366 }
327− mi->prev_sample = rate_sampling;
328367
329368 /* If we're not using MRR and the sampling rate already
330369 * has a probability of >95%, we shouldn't be attempting
331370 * to use it, as this only wastes precious airtime */
332− if (!mrr_capable && rate_sampling &&
371+ if (!mrr_capable &&
333372 (mi->r[ndx].probability > MINSTREL_FRAC(95, 100)))
334− ndx = mi->max_tp_rate[0];
335−
336− /* mrr setup for 1st stage */
337− ar[0].idx = mi->r[ndx].rix;
338− ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info);
339−
340− /* non mrr setup for 2nd stage */
341− if (!mrr_capable) {
342− if (!rate_sampling)
343− ar[0].count = mp->max_retry;
344− ar[1].idx = mi->lowest_rix;
345− ar[1].count = mp->max_retry;
346373 return;
347− }
348374
349− /* mrr setup for 2nd stage */
350− if (rate_sampling) {
351− if (indirect_rate_sampling)
352− mrr_ndx[0] = sample_ndx;
353− else
354− mrr_ndx[0] = mi->max_tp_rate[0];
355− } else {
356− mrr_ndx[0] = mi->max_tp_rate[1];
357− }
375+ mi->prev_sample = true;
358376
359− /* mrr setup for 3rd & 4th stage */
360− mrr_ndx[1] = mi->max_prob_rate;
361− mrr_ndx[2] = 0;
362− for (i = 1; i < 4; i++) {
363− ar[i].idx = mi->r[mrr_ndx[i - 1]].rix;
364− ar[i].count = mi->r[mrr_ndx[i - 1]].adjusted_retry_count;
365− }
377+ rate->idx = mi->r[ndx].rix;
378+ rate->count = minstrel_get_retry_count(&mi->r[ndx], info);
366379 }
367380
368381
@@ -412,12 +425,16 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, · 43 unmodified lines
412425 unsigned int i, n = 0;
413426 unsigned int t_slot = 9; /* FIXME: get real slot time */
414427
428+ mi->sta = sta;
415429 mi->lowest_rix = rate_lowest_index(sband, sta);
416430 ctl_rate = &sband->bitrates[mi->lowest_rix];
417431 mi->sp_ack_dur = ieee80211_frame_duration(sband->band, 10,
418432 ctl_rate->bitrate,
419433 !!(ctl_rate->flags & IEEE80211_RATE_ERP_G), 1);
420434
435+ memset(mi->max_tp_rate, 0, sizeof(mi->max_tp_rate));
436+ mi->max_prob_rate = 0;
437+
421438 for (i = 0; i < sband->n_bitrates; i++) {
422439 struct minstrel_rate *mr = &mi->r[n];
423440 unsigned int tx_time = 0, tx_time_cts = 0, tx_time_rtscts = 0;
@@ -460,6 +477,8 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, · 36 unmodified lines
460477 } while ((tx_time < mp->segment_size) &&
461478 (++mr->retry_count < mp->max_retry));
462479 mr->adjusted_retry_count = mr->retry_count;
480+ if (!(sband->bitrates[i].flags & IEEE80211_RATE_ERP_G))
481+ mr->retry_count_cts = mr->retry_count;
463482 }
464483
465484 for (i = n; i < sband->n_bitrates; i++) {
@@ -471,6 +490,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, · 5 unmodified lines
471490 mi->stats_update = jiffies;
472491
473492 init_sample_table(mi);
493+ minstrel_update_rates(mp, mi);
474494 }
475495
476496 static void *
net/mac80211/rc80211_minstrel.h+5−2
@@ -9,7 +9,8 @@ · 8 unmodified lines
99 #ifndef __RC_MINSTREL_H
1010 #define __RC_MINSTREL_H
1111
12−#define EWMA_LEVEL 75 /* ewma weighting factor [%] */
12+#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */
13+#define EWMA_DIV 128
1314 #define SAMPLE_COLUMNS 10 /* number of columns in sample table */
1415
1516
@@ -27,7 +28,7 @@ · 11 unmodified lines
2728 static inline int
2829 minstrel_ewma(int old, int new, int weight)
2930 {
30− return (new * (100 - weight) + old * weight) / 100;
31+ return (new * (EWMA_DIV - weight) + old * weight) / EWMA_DIV;
3132 }
3233
3334
@@ -62,6 +63,8 @@ struct minstrel_rate { · 28 unmodified lines
6263 };
6364
6465 struct minstrel_sta_info {
66+ struct ieee80211_sta *sta;
67+
6568 unsigned long stats_update;
6669 unsigned int sp_ack_dur;
6770 unsigned int rate_avg;
net/mac80211/rc80211_minstrel_debugfs.c+2−2
@@ -68,7 +68,7 @@ minstrel_stats_open(struct inode *inode, struct file *file) · 67 unmodified lines
6868
6969 file->private_data = ms;
7070 p = ms->buf;
71− p += sprintf(p, "rate throughput ewma prob this prob "
71+ p += sprintf(p, "rate throughput ewma prob this prob "
7272 "this succ/attempt success attempts\n");
7373 for (i = 0; i < mi->n_rates; i++) {
7474 struct minstrel_rate *mr = &mi->r[i];
@@ -86,7 +86,7 @@ minstrel_stats_open(struct inode *inode, struct file *file) · 11 unmodified lines
8686 eprob = MINSTREL_TRUNC(mr->probability * 1000);
8787
8888 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u "
89− "%3u(%3u) %8llu %8llu\n",
89+ " %3u(%3u) %8llu %8llu\n",
9090 tp / 10, tp % 10,
9191 eprob / 10, eprob % 10,
9292 prob / 10, prob % 10,
net/mac80211/rc80211_minstrel_ht.c+99−73
@@ -126,6 +126,9 @@ const struct mcs_group minstrel_mcs_groups[] = { · 125 unmodified lines
126126
127127 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
128128
129+static void
130+minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);
131+
129132 /*
130133 * Look up an MCS group index based on mac80211 rate information
131134 */
@@ -244,6 +247,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) · 112 unmodified lines
244247 struct minstrel_rate_stats *mr;
245248 int cur_prob, cur_prob_tp, cur_tp, cur_tp2;
246249 int group, i, index;
250+ bool mi_rates_valid = false;
247251
248252 if (mi->ampdu_packets > 0) {
249253 mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
@@ -254,11 +258,10 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) · 4 unmodified lines
254258
255259 mi->sample_slow = 0;
256260 mi->sample_count = 0;
257− mi->max_tp_rate = 0;
258− mi->max_tp_rate2 = 0;
259− mi->max_prob_rate = 0;
260261
261262 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
263+ bool mg_rates_valid = false;
264+
262265 cur_prob = 0;
263266 cur_prob_tp = 0;
264267 cur_tp = 0;
@@ -268,15 +271,24 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) · 3 unmodified lines
268271 if (!mg->supported)
269272 continue;
270273
271− mg->max_tp_rate = 0;
272− mg->max_tp_rate2 = 0;
273− mg->max_prob_rate = 0;
274274 mi->sample_count++;
275275
276276 for (i = 0; i < MCS_GROUP_RATES; i++) {
277277 if (!(mg->supported & BIT(i)))
278278 continue;
279279
280+ /* initialize rates selections starting indexes */
281+ if (!mg_rates_valid) {
282+ mg->max_tp_rate = mg->max_tp_rate2 =
283+ mg->max_prob_rate = i;
284+ if (!mi_rates_valid) {
285+ mi->max_tp_rate = mi->max_tp_rate2 =
286+ mi->max_prob_rate = i;
287+ mi_rates_valid = true;
288+ }
289+ mg_rates_valid = true;
290+ }
291+
280292 mr = &mg->rates[i];
281293 mr->retry_updated = false;
282294 index = MCS_GROUP_RATES * group + i;
@@ -456,7 +468,7 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband, · 173 unmodified lines
456468 struct ieee80211_tx_rate *ar = info->status.rates;
457469 struct minstrel_rate_stats *rate, *rate2;
458470 struct minstrel_priv *mp = priv;
459− bool last;
471+ bool last, update = false;
460472 int i;
461473
462474 if (!msp->is_ht)
@@ -505,21 +517,29 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband, · 42 unmodified lines
505517 rate = minstrel_get_ratestats(mi, mi->max_tp_rate);
506518 if (rate->attempts > 30 &&
507519 MINSTREL_FRAC(rate->success, rate->attempts) <
508− MINSTREL_FRAC(20, 100))
520+ MINSTREL_FRAC(20, 100)) {
509521 minstrel_downgrade_rate(mi, &mi->max_tp_rate, true);
522+ update = true;
523+ }
510524
511525 rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2);
512526 if (rate2->attempts > 30 &&
513527 MINSTREL_FRAC(rate2->success, rate2->attempts) <
514− MINSTREL_FRAC(20, 100))
528+ MINSTREL_FRAC(20, 100)) {
515529 minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false);
530+ update = true;
531+ }
516532
517533 if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
534+ update = true;
518535 minstrel_ht_update_stats(mp, mi);
519536 if (!(info->flags & IEEE80211_TX_CTL_AMPDU) &&
520537 mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP)
521538 minstrel_aggr_check(sta, skb);
522539 }
540+
541+ if (update)
542+ minstrel_ht_update_rates(mp, mi);
523543 }
524544
525545 static void
@@ -583,36 +603,71 @@ minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, · 57 unmodified lines
583603
584604 static void
585605 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
586− struct ieee80211_tx_rate *rate, int index,
587− bool sample, bool rtscts)
606+ struct ieee80211_sta_rates *ratetbl, int offset, int index)
588607 {
589608 const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
590609 struct minstrel_rate_stats *mr;
610+ u8 idx;
611+ u16 flags;
591612
592613 mr = minstrel_get_ratestats(mi, index);
593614 if (!mr->retry_updated)
594615 minstrel_calc_retransmit(mp, mi, index);
595616
596− if (sample)
597− rate->count = 1;
598− else if (mr->probability < MINSTREL_FRAC(20, 100))
599− rate->count = 2;
600− else if (rtscts)
601− rate->count = mr->retry_count_rtscts;
602− else
603− rate->count = mr->retry_count;
604−
605− rate->flags = 0;
606− if (rtscts)
607− rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
617+ if (mr->probability < MINSTREL_FRAC(20, 100) || !mr->retry_count) {
618+ ratetbl->rate[offset].count = 2;
619+ ratetbl->rate[offset].count_rts = 2;
620+ ratetbl->rate[offset].count_cts = 2;
621+ } else {
622+ ratetbl->rate[offset].count = mr->retry_count;
623+ ratetbl->rate[offset].count_cts = mr->retry_count;
624+ ratetbl->rate[offset].count_rts = mr->retry_count_rtscts;
625+ }
608626
609627 if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
610− rate->idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
628+ idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
629+ flags = 0;
630+ } else {
631+ idx = index % MCS_GROUP_RATES +
632+ (group->streams - 1) * MCS_GROUP_RATES;
633+ flags = IEEE80211_TX_RC_MCS | group->flags;
634+ }
635+
636+ if (offset > 0) {
637+ ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
638+ flags |= IEEE80211_TX_RC_USE_RTS_CTS;
639+ }
640+
641+ ratetbl->rate[offset].idx = idx;
642+ ratetbl->rate[offset].flags = flags;
643+}
644+
645+static void
646+minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
647+{
648+ struct ieee80211_sta_rates *rates;
649+ int i = 0;
650+
651+ rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
652+ if (!rates)
611653 return;
654+
655+ /* Start with max_tp_rate */
656+ minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate);
657+
658+ if (mp->hw->max_rates >= 3) {
659+ /* At least 3 tx rates supported, use max_tp_rate2 next */
660+ minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate2);
661+ }
662+
663+ if (mp->hw->max_rates >= 2) {
664+ /*
665+ * At least 2 tx rates supported, use max_prob_rate next */
666+ minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate);
612667 }
613668
614− rate->flags |= IEEE80211_TX_RC_MCS | group->flags;
615− rate->idx = index % MCS_GROUP_RATES + (group->streams - 1) * MCS_GROUP_RATES;
669+ rates->rate[i].idx = -1;
670+ rate_control_set_rates(mp->hw, mi->sta, rates);
616671 }
617672
618673 static inline int
@@ -702,13 +757,13 @@ static void · 83 unmodified lines
702757 minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
703758 struct ieee80211_tx_rate_control *txrc)
704759 {
760+ const struct mcs_group *sample_group;
705761 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
706− struct ieee80211_tx_rate *ar = info->status.rates;
762+ struct ieee80211_tx_rate *rate = &info->status.rates[0];
707763 struct minstrel_ht_sta_priv *msp = priv_sta;
708764 struct minstrel_ht_sta *mi = &msp->ht;
709765 struct minstrel_priv *mp = priv;
710766 int sample_idx;
711− bool sample = false;
712767
713768 if (rate_control_send_low(sta, priv_sta, txrc))
714769 return;
@@ -736,51 +791,6 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, · 21 unmodified lines
736791 }
737792 #endif
738793
739− if (sample_idx >= 0) {
740− sample = true;
741− minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx,
742− true, false);
743− info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
744− } else {
745− minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate,
746− false, false);
747− }
748−
749− if (mp->hw->max_rates >= 3) {
750− /*
751− * At least 3 tx rates supported, use
752− * sample_rate -> max_tp_rate -> max_prob_rate for sampling and
753− * max_tp_rate -> max_tp_rate2 -> max_prob_rate by default.
754− */
755− if (sample_idx >= 0)
756− minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate,
757− false, false);
758− else
759− minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2,
760− false, true);
761−
762− minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate,
763− false, !sample);
764−
765− ar[3].count = 0;
766− ar[3].idx = -1;
767− } else if (mp->hw->max_rates == 2) {
768− /*
769− * Only 2 tx rates supported, use
770− * sample_rate -> max_prob_rate for sampling and
771− * max_tp_rate -> max_prob_rate by default.
772− */
773− minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_prob_rate,
774− false, !sample);
775−
776− ar[2].count = 0;
777− ar[2].idx = -1;
778− } else {
779− /* Not using MRR, only use the first rate */
780− ar[1].count = 0;
781− ar[1].idx = -1;
782− }
783−
784794 mi->total_packets++;
785795
786796 /* wraparound */
@@ -788,6 +798,16 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, · 1 unmodified line
788798 mi->total_packets = 0;
789799 mi->sample_packets = 0;
790800 }
801+
802+ if (sample_idx < 0)
803+ return;
804+
805+ sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
806+ info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
807+ rate->idx = sample_idx % MCS_GROUP_RATES +
808+ (sample_group->streams - 1) * MCS_GROUP_RATES;
809+ rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
810+ rate->count = 1;
791811 }
792812
793813 static void
@@ -837,6 +857,8 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, · 43 unmodified lines
837857
838858 msp->is_ht = true;
839859 memset(mi, 0, sizeof(*mi));
860+
861+ mi->sta = sta;
840862 mi->stats_update = jiffies;
841863
842864 ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1);
@@ -898,6 +920,10 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, · 55 unmodified lines
898920 if (!n_supported)
899921 goto use_legacy;
900922
923+ /* create an initial rate table with the lowest supported rates */
924+ minstrel_ht_update_stats(mp, mi);
925+ minstrel_ht_update_rates(mp, mi);
926+
901927 return;
902928
903929 use_legacy:
net/mac80211/rc80211_minstrel_ht.h+2−0
@@ -65,6 +65,8 @@ struct minstrel_mcs_group_data { · 64 unmodified lines
6565 };
6666
6767 struct minstrel_ht_sta {
68+ struct ieee80211_sta *sta;
69+
6870 /* ampdu length (average, per sampling interval) */
6971 unsigned int ampdu_len;
7072 unsigned int ampdu_packets;
net/mac80211/rx.c+19−5
@@ -2085,6 +2085,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) · 2084 unmodified lines
20852085 }
20862086
20872087 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data;
2088+ fwd_hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_RETRY);
20882089 info = IEEE80211_SKB_CB(fwd_skb);
20892090 memset(info, 0, sizeof(*info));
20902091 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
@@ -2423,6 +2424,22 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) · 332 unmodified lines
24232424 }
24242425
24252426 break;
2427+ case WLAN_CATEGORY_PUBLIC:
2428+ if (len < IEEE80211_MIN_ACTION_SIZE + 1)
2429+ goto invalid;
2430+ if (sdata->vif.type != NL80211_IFTYPE_STATION)
2431+ break;
2432+ if (!rx->sta)
2433+ break;
2434+ if (!ether_addr_equal(mgmt->bssid, sdata->u.mgd.bssid))
2435+ break;
2436+ if (mgmt->u.action.u.ext_chan_switch.action_code !=
2437+ WLAN_PUB_ACTION_EXT_CHANSW_ANN)
2438+ break;
2439+ if (len < offsetof(struct ieee80211_mgmt,
2440+ u.action.u.ext_chan_switch.variable))
2441+ goto invalid;
2442+ goto queue;
24262443 case WLAN_CATEGORY_VHT:
24272444 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
24282445 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
@@ -2506,10 +2523,6 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) · 77 unmodified lines
25062523 ieee80211_process_measurement_req(sdata, mgmt, len);
25072524 goto handled;
25082525 case WLAN_ACTION_SPCT_CHL_SWITCH:
2509− if (len < (IEEE80211_MIN_ACTION_SIZE +
2510− sizeof(mgmt->u.action.u.chan_switch)))
2511− break;
2512−
25132526 if (sdata->vif.type != NL80211_IFTYPE_STATION)
25142527 break;
25152528
@@ -3042,7 +3055,8 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, · 526 unmodified lines
30423055 !ieee80211_is_probe_resp(hdr->frame_control) &&
30433056 !ieee80211_is_beacon(hdr->frame_control))
30443057 return 0;
3045− if (!ether_addr_equal(sdata->vif.addr, hdr->addr1))
3058+ if (!ether_addr_equal(sdata->vif.addr, hdr->addr1) &&
3059+ !multicast)
30463060 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
30473061 break;
30483062 default:
net/mac80211/scan.c+1−1
@@ -181,7 +181,7 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) · 180 unmodified lines
181181 if (baselen > skb->len)
182182 return;
183183
184− ieee802_11_parse_elems(elements, skb->len - baselen, &elems);
184+ ieee802_11_parse_elems(elements, skb->len - baselen, false, &elems);
185185
186186 channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq);
187187
net/mac80211/trace.h+4−4
@@ -990,23 +990,23 @@ TRACE_EVENT(drv_channel_switch, · 989 unmodified lines
990990
991991 TP_STRUCT__entry(
992992 LOCAL_ENTRY
993+ CHANDEF_ENTRY
993994 __field(u64, timestamp)
994995 __field(bool, block_tx)
995− __field(u16, freq)
996996 __field(u8, count)
997997 ),
998998
999999 TP_fast_assign(
10001000 LOCAL_ASSIGN;
1001+ CHANDEF_ASSIGN(&ch_switch->chandef)
10011002 __entry->timestamp = ch_switch->timestamp;
10021003 __entry->block_tx = ch_switch->block_tx;
1003− __entry->freq = ch_switch->channel->center_freq;
10041004 __entry->count = ch_switch->count;
10051005 ),
10061006
10071007 TP_printk(
1008− LOCAL_PR_FMT " new freq:%u count:%d",
1009− LOCAL_PR_ARG, __entry->freq, __entry->count
1008+ LOCAL_PR_FMT " new " CHANDEF_PR_FMT " count:%d",
1009+ LOCAL_PR_ARG, CHANDEF_PR_ARG, __entry->count
10101010 )
10111011 );
10121012
net/mac80211/tx.c+41−101
@@ -48,15 +48,15 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, · 47 unmodified lines
4848 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
4949
5050 /* assume HW handles this */
51− if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
51+ if (tx->rate.flags & IEEE80211_TX_RC_MCS)
5252 return 0;
5353
5454 /* uh huh? */
55− if (WARN_ON_ONCE(info->control.rates[0].idx < 0))
55+ if (WARN_ON_ONCE(tx->rate.idx < 0))
5656 return 0;
5757
5858 sband = local->hw.wiphy->bands[info->band];
59− txrate = &sband->bitrates[info->control.rates[0].idx];
59+ txrate = &sband->bitrates[tx->rate.idx];
6060
6161 erp = txrate->flags & IEEE80211_RATE_ERP_G;
6262
@@ -617,11 +617,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) · 554 unmodified lines
617617 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
618618 struct ieee80211_hdr *hdr = (void *)tx->skb->data;
619619 struct ieee80211_supported_band *sband;
620− struct ieee80211_rate *rate;
621− int i;
622620 u32 len;
623− bool inval = false, rts = false, short_preamble = false;
624621 struct ieee80211_tx_rate_control txrc;
622+ struct ieee80211_sta_rates *ratetbl = NULL;
625623 bool assoc = false;
626624
627625 memset(&txrc, 0, sizeof(txrc));
@@ -642,18 +640,23 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) · 14 unmodified lines
642640 txrc.max_rate_idx = -1;
643641 else
644642 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
645− memcpy(txrc.rate_idx_mcs_mask,
646− tx->sdata->rc_rateidx_mcs_mask[info->band],
647− sizeof(txrc.rate_idx_mcs_mask));
643+
644+ if (tx->sdata->rc_has_mcs_mask[info->band])
645+ txrc.rate_idx_mcs_mask =
646+ tx->sdata->rc_rateidx_mcs_mask[info->band];
647+
648648 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
649649 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
650650 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
651651
652652 /* set up RTS protection if desired */
653653 if (len > tx->local->hw.wiphy->rts_threshold) {
654− txrc.rts = rts = true;
654+ txrc.rts = true;
655655 }
656656
657+ info->control.use_rts = txrc.rts;
658+ info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot;
659+
657660 /*
658661 * Use short preamble if the BSS can handle it, but not for
659662 * management frames unless we know the receiver can handle
@@ -663,7 +666,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) · 3 unmodified lines
663666 if (tx->sdata->vif.bss_conf.use_short_preamble &&
664667 (ieee80211_is_data(hdr->frame_control) ||
665668 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE))))
666− txrc.short_preamble = short_preamble = true;
669+ txrc.short_preamble = true;
670+
671+ info->control.short_preamble = txrc.short_preamble;
667672
668673 if (tx->sta)
669674 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC);
@@ -687,16 +692,38 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) · 17 unmodified lines
687692 */
688693 rate_control_get_rate(tx->sdata, tx->sta, &txrc);
689694
690− if (unlikely(info->control.rates[0].idx < 0))
691− return TX_DROP;
695+ if (tx->sta && !info->control.skip_table)
696+ ratetbl = rcu_dereference(tx->sta->sta.rates);
697+
698+ if (unlikely(info->control.rates[0].idx < 0)) {
699+ if (ratetbl) {
700+ struct ieee80211_tx_rate rate = {
701+ .idx = ratetbl->rate[0].idx,
702+ .flags = ratetbl->rate[0].flags,
703+ .count = ratetbl->rate[0].count
704+ };
705+
706+ if (ratetbl->rate[0].idx < 0)
707+ return TX_DROP;
708+
709+ tx->rate = rate;
710+ } else {
711+ return TX_DROP;
712+ }
713+ } else {
714+ tx->rate = info->control.rates[0];
715+ }
692716
693717 if (txrc.reported_rate.idx < 0) {
694− txrc.reported_rate = info->control.rates[0];
718+ txrc.reported_rate = tx->rate;
695719 if (tx->sta && ieee80211_is_data(hdr->frame_control))
696720 tx->sta->last_tx_rate = txrc.reported_rate;
697721 } else if (tx->sta)
698722 tx->sta->last_tx_rate = txrc.reported_rate;
699723
724+ if (ratetbl)
725+ return TX_CONTINUE;
726+
700727 if (unlikely(!info->control.rates[0].count))
701728 info->control.rates[0].count = 1;
702729
@@ -704,91 +731,6 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) · 1 unmodified line
704731 (info->flags & IEEE80211_TX_CTL_NO_ACK)))
705732 info->control.rates[0].count = 1;
706733
707− if (is_multicast_ether_addr(hdr->addr1)) {
708− /*
709− * XXX: verify the rate is in the basic rateset
710− */
711− return TX_CONTINUE;
712− }
713−
714− /*
715− * set up the RTS/CTS rate as the fastest basic rate
716− * that is not faster than the data rate
717− *
718− * XXX: Should this check all retry rates?
719− */
720− if (!(info->control.rates[0].flags & IEEE80211_TX_RC_MCS)) {
721− s8 baserate = 0;
722−
723− rate = &sband->bitrates[info->control.rates[0].idx];
724−
725− for (i = 0; i < sband->n_bitrates; i++) {
726− /* must be a basic rate */
727− if (!(tx->sdata->vif.bss_conf.basic_rates & BIT(i)))
728− continue;
729− /* must not be faster than the data rate */
730− if (sband->bitrates[i].bitrate > rate->bitrate)
731− continue;
732− /* maximum */
733− if (sband->bitrates[baserate].bitrate <
734− sband->bitrates[i].bitrate)
735− baserate = i;
736− }
737−
738− info->control.rts_cts_rate_idx = baserate;
739− }
740−
741− for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
742− /*
743− * make sure there's no valid rate following
744− * an invalid one, just in case drivers don't
745− * take the API seriously to stop at -1.
746− */
747− if (inval) {
748− info->control.rates[i].idx = -1;
749− continue;
750− }
751− if (info->control.rates[i].idx < 0) {
752− inval = true;
753− continue;
754− }
755−
756− /*
757− * For now assume MCS is already set up correctly, this
758− * needs to be fixed.
759− */
760− if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) {
761− WARN_ON(info->control.rates[i].idx > 76);
762− continue;
763− }
764−
765− /* set up RTS protection if desired */
766− if (rts)
767− info->control.rates[i].flags |=
768− IEEE80211_TX_RC_USE_RTS_CTS;
769−
770− /* RC is busted */
771− if (WARN_ON_ONCE(info->control.rates[i].idx >=
772− sband->n_bitrates)) {
773− info->control.rates[i].idx = -1;
774− continue;
775− }
776−
777− rate = &sband->bitrates[info->control.rates[i].idx];
778−
779− /* set up short preamble */
780− if (short_preamble &&
781− rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
782− info->control.rates[i].flags |=
783− IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
784−
785− /* set up G protection */
786− if (!rts && tx->sdata->vif.bss_conf.use_cts_prot &&
787− rate->flags & IEEE80211_RATE_ERP_G)
788− info->control.rates[i].flags |=
789− IEEE80211_TX_RC_USE_CTS_PROTECT;
790− }
791−
792734 return TX_CONTINUE;
793735 }
794736
@@ -2502,8 +2444,6 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, · 1707 unmodified lines
25022444 txrc.max_rate_idx = -1;
25032445 else
25042446 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
2505− memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band],
2506− sizeof(txrc.rate_idx_mcs_mask));
25072447 txrc.bss = true;
25082448 rate_control_get_rate(sdata, NULL, &txrc);
25092449
net/mac80211/util.c+52−2
@@ -485,7 +485,8 @@ int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue) · 484 unmodified lines
485485 return true;
486486
487487 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
488− ret = !!local->queue_stop_reasons[queue];
488+ ret = test_bit(IEEE80211_QUEUE_STOP_REASON_DRIVER,
489+ &local->queue_stop_reasons[queue]);
489490 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
490491 return ret;
491492 }
@@ -660,7 +661,7 @@ void ieee80211_queue_delayed_work(struct ieee80211_hw *hw, · 168 unmodified lines
660661 }
661662 EXPORT_SYMBOL(ieee80211_queue_delayed_work);
662663
663−u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
664+u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action,
664665 struct ieee802_11_elems *elems,
665666 u64 filter, u32 crc)
666667 {
@@ -668,6 +669,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, · 1 unmodified line
668669 u8 *pos = start;
669670 bool calc_crc = filter != 0;
670671 DECLARE_BITMAP(seen_elems, 256);
672+ const u8 *ie;
671673
672674 bitmap_zero(seen_elems, 256);
673675 memset(elems, 0, sizeof(*elems));
@@ -715,6 +717,12 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, · 41 unmodified lines
715717 case WLAN_EID_COUNTRY:
716718 case WLAN_EID_PWR_CONSTRAINT:
717719 case WLAN_EID_TIMEOUT_INTERVAL:
720+ case WLAN_EID_SECONDARY_CHANNEL_OFFSET:
721+ case WLAN_EID_WIDE_BW_CHANNEL_SWITCH:
722+ /*
723+ * not listing WLAN_EID_CHANNEL_SWITCH_WRAPPER -- it seems possible
724+ * that if the content gets bigger it might be needed more than once
725+ */
718726 if (test_bit(id, seen_elems)) {
719727 elems->parse_error = true;
720728 left -= elen;
@@ -862,6 +870,48 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, · 141 unmodified lines
862870 }
863871 elems->ch_switch_ie = (void *)pos;
864872 break;
873+ case WLAN_EID_EXT_CHANSWITCH_ANN:
874+ if (elen != sizeof(struct ieee80211_ext_chansw_ie)) {
875+ elem_parse_failed = true;
876+ break;
877+ }
878+ elems->ext_chansw_ie = (void *)pos;
879+ break;
880+ case WLAN_EID_SECONDARY_CHANNEL_OFFSET:
881+ if (elen != sizeof(struct ieee80211_sec_chan_offs_ie)) {
882+ elem_parse_failed = true;
883+ break;
884+ }
885+ elems->sec_chan_offs = (void *)pos;
886+ break;
887+ case WLAN_EID_WIDE_BW_CHANNEL_SWITCH:
888+ if (!action ||
889+ elen != sizeof(*elems->wide_bw_chansw_ie)) {
890+ elem_parse_failed = true;
891+ break;
892+ }
893+ elems->wide_bw_chansw_ie = (void *)pos;
894+ break;
895+ case WLAN_EID_CHANNEL_SWITCH_WRAPPER:
896+ if (action) {
897+ elem_parse_failed = true;
898+ break;
899+ }
900+ /*
901+ * This is a bit tricky, but as we only care about
902+ * the wide bandwidth channel switch element, so
903+ * just parse it out manually.
904+ */
905+ ie = cfg80211_find_ie(WLAN_EID_WIDE_BW_CHANNEL_SWITCH,
906+ pos, elen);
907+ if (ie) {
908+ if (ie[1] == sizeof(*elems->wide_bw_chansw_ie))
909+ elems->wide_bw_chansw_ie =
910+ (void *)(ie + 2);
911+ else
912+ elem_parse_failed = true;
913+ }
914+ break;
865915 case WLAN_EID_COUNTRY:
866916 elems->country_elem = pos;
867917 elems->country_elem_len = elen;
net/rfkill/rfkill-gpio.c+5−2
@@ -131,6 +131,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev) · 130 unmodified lines
131131 rfkill->pwr_clk = clk_get(&pdev->dev, pdata->power_clk_name);
132132 if (IS_ERR(rfkill->pwr_clk)) {
133133 pr_warn("%s: can't find pwr_clk.\n", __func__);
134+ ret = PTR_ERR(rfkill->pwr_clk);
134135 goto fail_shutdown_name;
135136 }
136137 }
@@ -152,9 +153,11 @@ static int rfkill_gpio_probe(struct platform_device *pdev) · 15 unmodified lines
152153 }
153154
154155 rfkill->rfkill_dev = rfkill_alloc(pdata->name, &pdev->dev, pdata->type,
155− &rfkill_gpio_ops, rfkill);
156− if (!rfkill->rfkill_dev)
156+ &rfkill_gpio_ops, rfkill);
157+ if (!rfkill->rfkill_dev) {
158+ ret = -ENOMEM;
157159 goto fail_shutdown;
160+ }
158161
159162 ret = rfkill_register(rfkill->rfkill_dev);
160163 if (ret < 0)
net/wireless/core.h+3−0
@@ -88,6 +88,9 @@ struct cfg80211_registered_device { · 87 unmodified lines
8888
8989 struct delayed_work dfs_update_channels_wk;
9090
91+ /* netlink port which started critical protocol (0 means not started) */
92+ u32 crit_proto_nlportid;
93+
9194 /* must be last because of the way we do wiphy_priv(),
9295 * and it should at least be aligned to NETDEV_ALIGN */
9396 struct wiphy wiphy __aligned(NETDEV_ALIGN);
net/wireless/mlme.c+5−0
@@ -648,6 +648,11 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid) · 647 unmodified lines
648648
649649 spin_unlock_bh(&wdev->mgmt_registrations_lock);
650650
651+ if (nlportid && rdev->crit_proto_nlportid == nlportid) {
652+ rdev->crit_proto_nlportid = 0;
653+ rdev_crit_proto_stop(rdev, wdev);
654+ }
655+
651656 if (nlportid == wdev->ap_unexpected_nlportid)
652657 wdev->ap_unexpected_nlportid = 0;
653658 }
net/wireless/nl80211.c+210−75
@@ -447,62 +447,69 @@ nl80211_match_policy[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1] = { · 446 unmodified lines
447447 [NL80211_SCHED_SCAN_MATCH_ATTR_RSSI] = { .type = NLA_U32 },
448448 };
449449
450−/* ifidx get helper */
451−static int nl80211_get_ifidx(struct netlink_callback *cb)
450+static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
451+ struct netlink_callback *cb,
452+ struct cfg80211_registered_device **rdev,
453+ struct wireless_dev **wdev)
452454 {
453− int res;
454−
455− res = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
456− nl80211_fam.attrbuf, nl80211_fam.maxattr,
457− nl80211_policy);
458− if (res)
459− return res;
460−
461− if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
462− return -EINVAL;
455+ int err;
463456
464− res = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
465− if (!res)
466− return -EINVAL;
467− return res;
468−}
457+ rtnl_lock();
458+ mutex_lock(&cfg80211_mutex);
469459
470−static int nl80211_prepare_netdev_dump(struct sk_buff *skb,
471− struct netlink_callback *cb,
472− struct cfg80211_registered_device **rdev,
473− struct net_device **dev)
474−{
475− int ifidx = cb->args[0];
476− int err;
460+ if (!cb->args[0]) {
461+ err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
462+ nl80211_fam.attrbuf, nl80211_fam.maxattr,
463+ nl80211_policy);
464+ if (err)
465+ goto out_unlock;
477466
478− if (!ifidx)
479− ifidx = nl80211_get_ifidx(cb);
480− if (ifidx < 0)
481− return ifidx;
467+ *wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk),
468+ nl80211_fam.attrbuf);
469+ if (IS_ERR(*wdev)) {
470+ err = PTR_ERR(*wdev);
471+ goto out_unlock;
472+ }
473+ *rdev = wiphy_to_dev((*wdev)->wiphy);
474+ cb->args[0] = (*rdev)->wiphy_idx;
475+ cb->args[1] = (*wdev)->identifier;
476+ } else {
477+ struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]);
478+ struct wireless_dev *tmp;
482479
483− cb->args[0] = ifidx;
480+ if (!wiphy) {
481+ err = -ENODEV;
482+ goto out_unlock;
483+ }
484+ *rdev = wiphy_to_dev(wiphy);
485+ *wdev = NULL;
484486
485− rtnl_lock();
487+ mutex_lock(&(*rdev)->devlist_mtx);
488+ list_for_each_entry(tmp, &(*rdev)->wdev_list, list) {
489+ if (tmp->identifier == cb->args[1]) {
490+ *wdev = tmp;
491+ break;
492+ }
493+ }
494+ mutex_unlock(&(*rdev)->devlist_mtx);
486495
487− *dev = __dev_get_by_index(sock_net(skb->sk), ifidx);
488− if (!*dev) {
489− err = -ENODEV;
490− goto out_rtnl;
496+ if (!*wdev) {
497+ err = -ENODEV;
498+ goto out_unlock;
499+ }
491500 }
492501
493− *rdev = cfg80211_get_dev_from_ifindex(sock_net(skb->sk), ifidx);
494− if (IS_ERR(*rdev)) {
495− err = PTR_ERR(*rdev);
496− goto out_rtnl;
497− }
502+ cfg80211_lock_rdev(*rdev);
498503
504+ mutex_unlock(&cfg80211_mutex);
499505 return 0;
500− out_rtnl:
506+ out_unlock:
507+ mutex_unlock(&cfg80211_mutex);
501508 rtnl_unlock();
502509 return err;
503510 }
504511
505−static void nl80211_finish_netdev_dump(struct cfg80211_registered_device *rdev)
512+static void nl80211_finish_wdev_dump(struct cfg80211_registered_device *rdev)
506513 {
507514 cfg80211_unlock_rdev(rdev);
508515 rtnl_unlock();
@@ -1417,6 +1424,10 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev, · 908 unmodified lines
14171424 }
14181425 CMD(start_p2p_device, START_P2P_DEVICE);
14191426 CMD(set_mcast_rate, SET_MCAST_RATE);
1427+ if (split) {
1428+ CMD(crit_proto_start, CRIT_PROTOCOL_START);
1429+ CMD(crit_proto_stop, CRIT_PROTOCOL_STOP);
1430+ }
14201431
14211432 #ifdef CONFIG_NL80211_TESTMODE
14221433 CMD(testmode_cmd, TESTMODE);
@@ -3525,15 +3536,20 @@ static int nl80211_dump_station(struct sk_buff *skb, · 2102 unmodified lines
35253536 {
35263537 struct station_info sinfo;
35273538 struct cfg80211_registered_device *dev;
3528− struct net_device *netdev;
3539+ struct wireless_dev *wdev;
35293540 u8 mac_addr[ETH_ALEN];
3530− int sta_idx = cb->args[1];
3541+ int sta_idx = cb->args[2];
35313542 int err;
35323543
3533− err = nl80211_prepare_netdev_dump(skb, cb, &dev, &netdev);
3544+ err = nl80211_prepare_wdev_dump(skb, cb, &dev, &wdev);
35343545 if (err)
35353546 return err;
35363547
3548+ if (!wdev->netdev) {
3549+ err = -EINVAL;
3550+ goto out_err;
3551+ }
3552+
35373553 if (!dev->ops->dump_station) {
35383554 err = -EOPNOTSUPP;
35393555 goto out_err;
@@ -3541,7 +3557,7 @@ static int nl80211_dump_station(struct sk_buff *skb, · 1 unmodified line
35413557
35423558 while (1) {
35433559 memset(&sinfo, 0, sizeof(sinfo));
3544− err = rdev_dump_station(dev, netdev, sta_idx,
3560+ err = rdev_dump_station(dev, wdev->netdev, sta_idx,
35453561 mac_addr, &sinfo);
35463562 if (err == -ENOENT)
35473563 break;
@@ -3551,7 +3567,7 @@ static int nl80211_dump_station(struct sk_buff *skb, · 3 unmodified lines
35513567 if (nl80211_send_station(skb,
35523568 NETLINK_CB(cb->skb).portid,
35533569 cb->nlh->nlmsg_seq, NLM_F_MULTI,
3554− dev, netdev, mac_addr,
3570+ dev, wdev->netdev, mac_addr,
35553571 &sinfo) < 0)
35563572 goto out;
35573573
@@ -3560,10 +3576,10 @@ static int nl80211_dump_station(struct sk_buff *skb, · 2 unmodified lines
35603576
35613577
35623578 out:
3563− cb->args[1] = sta_idx;
3579+ cb->args[2] = sta_idx;
35643580 err = skb->len;
35653581 out_err:
3566− nl80211_finish_netdev_dump(dev);
3582+ nl80211_finish_wdev_dump(dev);
35673583
35683584 return err;
35693585 }
@@ -4167,13 +4183,13 @@ static int nl80211_dump_mpath(struct sk_buff *skb, · 597 unmodified lines
41674183 {
41684184 struct mpath_info pinfo;
41694185 struct cfg80211_registered_device *dev;
4170− struct net_device *netdev;
4186+ struct wireless_dev *wdev;
41714187 u8 dst[ETH_ALEN];
41724188 u8 next_hop[ETH_ALEN];
4173− int path_idx = cb->args[1];
4189+ int path_idx = cb->args[2];
41744190 int err;
41754191
4176− err = nl80211_prepare_netdev_dump(skb, cb, &dev, &netdev);
4192+ err = nl80211_prepare_wdev_dump(skb, cb, &dev, &wdev);
41774193 if (err)
41784194 return err;
41794195
@@ -4182,14 +4198,14 @@ static int nl80211_dump_mpath(struct sk_buff *skb, · 2 unmodified lines
41824198 goto out_err;
41834199 }
41844200
4185− if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) {
4201+ if (wdev->iftype != NL80211_IFTYPE_MESH_POINT) {
41864202 err = -EOPNOTSUPP;
41874203 goto out_err;
41884204 }
41894205
41904206 while (1) {
4191− err = rdev_dump_mpath(dev, netdev, path_idx, dst, next_hop,
4192− &pinfo);
4207+ err = rdev_dump_mpath(dev, wdev->netdev, path_idx, dst,
4208+ next_hop, &pinfo);
41934209 if (err == -ENOENT)
41944210 break;
41954211 if (err)
@@ -4197,7 +4213,7 @@ static int nl80211_dump_mpath(struct sk_buff *skb, · 1 unmodified line
41974213
41984214 if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).portid,
41994215 cb->nlh->nlmsg_seq, NLM_F_MULTI,
4200− netdev, dst, next_hop,
4216+ wdev->netdev, dst, next_hop,
42014217 &pinfo) < 0)
42024218 goto out;
42034219
@@ -4206,10 +4222,10 @@ static int nl80211_dump_mpath(struct sk_buff *skb, · 2 unmodified lines
42064222
42074223
42084224 out:
4209− cb->args[1] = path_idx;
4225+ cb->args[2] = path_idx;
42104226 err = skb->len;
42114227 out_err:
4212− nl80211_finish_netdev_dump(dev);
4228+ nl80211_finish_wdev_dump(dev);
42134229 return err;
42144230 }
42154231
@@ -5565,9 +5581,13 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, · 1349 unmodified lines
55655581
55665582 genl_dump_check_consistent(cb, hdr, &nl80211_fam);
55675583
5568− if (nla_put_u32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation) ||
5584+ if (nla_put_u32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation))
5585+ goto nla_put_failure;
5586+ if (wdev->netdev &&
55695587 nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex))
55705588 goto nla_put_failure;
5589+ if (nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
5590+ goto nla_put_failure;
55715591
55725592 bss = nla_nest_start(msg, NL80211_ATTR_BSS);
55735593 if (!bss)
@@ -5647,22 +5667,18 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, · 73 unmodified lines
56475667 return -EMSGSIZE;
56485668 }
56495669
5650−static int nl80211_dump_scan(struct sk_buff *skb,
5651− struct netlink_callback *cb)
5670+static int nl80211_dump_scan(struct sk_buff *skb, struct netlink_callback *cb)
56525671 {
56535672 struct cfg80211_registered_device *rdev;
5654− struct net_device *dev;
56555673 struct cfg80211_internal_bss *scan;
56565674 struct wireless_dev *wdev;
5657− int start = cb->args[1], idx = 0;
5675+ int start = cb->args[2], idx = 0;
56585676 int err;
56595677
5660− err = nl80211_prepare_netdev_dump(skb, cb, &rdev, &dev);
5678+ err = nl80211_prepare_wdev_dump(skb, cb, &rdev, &wdev);
56615679 if (err)
56625680 return err;
56635681
5664− wdev = dev->ieee80211_ptr;
5665−
56665682 wdev_lock(wdev);
56675683 spin_lock_bh(&rdev->bss_lock);
56685684 cfg80211_bss_expire(rdev);
@@ -5683,8 +5699,8 @@ static int nl80211_dump_scan(struct sk_buff *skb, · 14 unmodified lines
56835699 spin_unlock_bh(&rdev->bss_lock);
56845700 wdev_unlock(wdev);
56855701
5686− cb->args[1] = idx;
5687− nl80211_finish_netdev_dump(rdev);
5702+ cb->args[2] = idx;
5703+ nl80211_finish_wdev_dump(rdev);
56885704
56895705 return skb->len;
56905706 }
@@ -5753,14 +5769,19 @@ static int nl80211_dump_survey(struct sk_buff *skb, · 62 unmodified lines
57535769 {
57545770 struct survey_info survey;
57555771 struct cfg80211_registered_device *dev;
5756− struct net_device *netdev;
5757− int survey_idx = cb->args[1];
5772+ struct wireless_dev *wdev;
5773+ int survey_idx = cb->args[2];
57585774 int res;
57595775
5760− res = nl80211_prepare_netdev_dump(skb, cb, &dev, &netdev);
5776+ res = nl80211_prepare_wdev_dump(skb, cb, &dev, &wdev);
57615777 if (res)
57625778 return res;
57635779
5780+ if (!wdev->netdev) {
5781+ res = -EINVAL;
5782+ goto out_err;
5783+ }
5784+
57645785 if (!dev->ops->dump_survey) {
57655786 res = -EOPNOTSUPP;
57665787 goto out_err;
@@ -5769,7 +5790,7 @@ static int nl80211_dump_survey(struct sk_buff *skb, · 2 unmodified lines
57695790 while (1) {
57705791 struct ieee80211_channel *chan;
57715792
5772− res = rdev_dump_survey(dev, netdev, survey_idx, &survey);
5793+ res = rdev_dump_survey(dev, wdev->netdev, survey_idx, &survey);
57735794 if (res == -ENOENT)
57745795 break;
57755796 if (res)
@@ -5791,17 +5812,16 @@ static int nl80211_dump_survey(struct sk_buff *skb, · 15 unmodified lines
57915812 if (nl80211_send_survey(skb,
57925813 NETLINK_CB(cb->skb).portid,
57935814 cb->nlh->nlmsg_seq, NLM_F_MULTI,
5794− netdev,
5795− &survey) < 0)
5815+ wdev->netdev, &survey) < 0)
57965816 goto out;
57975817 survey_idx++;
57985818 }
57995819
58005820 out:
5801− cb->args[1] = survey_idx;
5821+ cb->args[2] = survey_idx;
58025822 res = skb->len;
58035823 out_err:
5804− nl80211_finish_netdev_dump(dev);
5824+ nl80211_finish_wdev_dump(dev);
58055825 return res;
58065826 }
58075827
@@ -8143,9 +8163,11 @@ static int nl80211_stop_p2p_device(struct sk_buff *skb, struct genl_info *info) · 2335 unmodified lines
81438163 if (!rdev->ops->stop_p2p_device)
81448164 return -EOPNOTSUPP;
81458165
8166+ mutex_lock(&rdev->devlist_mtx);
81468167 mutex_lock(&rdev->sched_scan_mtx);
81478168 cfg80211_stop_p2p_device(rdev, wdev);
81488169 mutex_unlock(&rdev->sched_scan_mtx);
8170+ mutex_unlock(&rdev->devlist_mtx);
81498171
81508172 return 0;
81518173 }
@@ -8198,6 +8220,64 @@ static int nl80211_update_ft_ies(struct sk_buff *skb, struct genl_info *info) · 46 unmodified lines
81988220 return rdev_update_ft_ies(rdev, dev, &ft_params);
81998221 }
82008222
8223+static int nl80211_crit_protocol_start(struct sk_buff *skb,
8224+ struct genl_info *info)
8225+{
8226+ struct cfg80211_registered_device *rdev = info->user_ptr[0];
8227+ struct wireless_dev *wdev = info->user_ptr[1];
8228+ enum nl80211_crit_proto_id proto = NL80211_CRIT_PROTO_UNSPEC;
8229+ u16 duration;
8230+ int ret;
8231+
8232+ if (!rdev->ops->crit_proto_start)
8233+ return -EOPNOTSUPP;
8234+
8235+ if (WARN_ON(!rdev->ops->crit_proto_stop))
8236+ return -EINVAL;
8237+
8238+ if (rdev->crit_proto_nlportid)
8239+ return -EBUSY;
8240+
8241+ /* determine protocol if provided */
8242+ if (info->attrs[NL80211_ATTR_CRIT_PROT_ID])
8243+ proto = nla_get_u16(info->attrs[NL80211_ATTR_CRIT_PROT_ID]);
8244+
8245+ if (proto >= NUM_NL80211_CRIT_PROTO)
8246+ return -EINVAL;
8247+
8248+ /* timeout must be provided */
8249+ if (!info->attrs[NL80211_ATTR_MAX_CRIT_PROT_DURATION])
8250+ return -EINVAL;
8251+
8252+ duration =
8253+ nla_get_u16(info->attrs[NL80211_ATTR_MAX_CRIT_PROT_DURATION]);
8254+
8255+ if (duration > NL80211_CRIT_PROTO_MAX_DURATION)
8256+ return -ERANGE;
8257+
8258+ ret = rdev_crit_proto_start(rdev, wdev, proto, duration);
8259+ if (!ret)
8260+ rdev->crit_proto_nlportid = info->snd_portid;
8261+
8262+ return ret;
8263+}
8264+
8265+static int nl80211_crit_protocol_stop(struct sk_buff *skb,
8266+ struct genl_info *info)
8267+{
8268+ struct cfg80211_registered_device *rdev = info->user_ptr[0];
8269+ struct wireless_dev *wdev = info->user_ptr[1];
8270+
8271+ if (!rdev->ops->crit_proto_stop)
8272+ return -EOPNOTSUPP;
8273+
8274+ if (rdev->crit_proto_nlportid) {
8275+ rdev->crit_proto_nlportid = 0;
8276+ rdev_crit_proto_stop(rdev, wdev);
8277+ }
8278+ return 0;
8279+}
8280+
82018281 #define NL80211_FLAG_NEED_WIPHY 0x01
82028282 #define NL80211_FLAG_NEED_NETDEV 0x02
82038283 #define NL80211_FLAG_NEED_RTNL 0x04
@@ -8887,6 +8967,22 @@ static struct genl_ops nl80211_ops[] = { · 683 unmodified lines
88878967 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
88888968 NL80211_FLAG_NEED_RTNL,
88898969 },
8970+ {
8971+ .cmd = NL80211_CMD_CRIT_PROTOCOL_START,
8972+ .doit = nl80211_crit_protocol_start,
8973+ .policy = nl80211_policy,
8974+ .flags = GENL_ADMIN_PERM,
8975+ .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
8976+ NL80211_FLAG_NEED_RTNL,
8977+ },
8978+ {
8979+ .cmd = NL80211_CMD_CRIT_PROTOCOL_STOP,
8980+ .doit = nl80211_crit_protocol_stop,
8981+ .policy = nl80211_policy,
8982+ .flags = GENL_ADMIN_PERM,
8983+ .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
8984+ NL80211_FLAG_NEED_RTNL,
8985+ }
88908986 };
88918987
88928988 static struct genl_multicast_group nl80211_mlme_mcgrp = {
@@ -10632,6 +10728,45 @@ void cfg80211_ft_event(struct net_device *netdev, · 1739 unmodified lines
1063210728 }
1063310729 EXPORT_SYMBOL(cfg80211_ft_event);
1063410730
10731+void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
10732+{
10733+ struct cfg80211_registered_device *rdev;
10734+ struct sk_buff *msg;
10735+ void *hdr;
10736+ u32 nlportid;
10737+
10738+ rdev = wiphy_to_dev(wdev->wiphy);
10739+ if (!rdev->crit_proto_nlportid)
10740+ return;
10741+
10742+ nlportid = rdev->crit_proto_nlportid;
10743+ rdev->crit_proto_nlportid = 0;
10744+
10745+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
10746+ if (!msg)
10747+ return;
10748+
10749+ hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CRIT_PROTOCOL_STOP);
10750+ if (!hdr)
10751+ goto nla_put_failure;
10752+
10753+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
10754+ nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
10755+ goto nla_put_failure;
10756+
10757+ genlmsg_end(msg, hdr);
10758+
10759+ genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);
10760+ return;
10761+
10762+ nla_put_failure:
10763+ if (hdr)
10764+ genlmsg_cancel(msg, hdr);
10765+ nlmsg_free(msg);
10766+
10767+}
10768+EXPORT_SYMBOL(cfg80211_crit_proto_stopped);
10769+
1063510770 /* initialisation/exit functions */
1063610771
1063710772 int nl80211_init(void)
net/wireless/rdev-ops.h+23−1
@@ -875,7 +875,7 @@ static inline void rdev_stop_p2p_device(struct cfg80211_registered_device *rdev, · 874 unmodified lines
875875 trace_rdev_stop_p2p_device(&rdev->wiphy, wdev);
876876 rdev->ops->stop_p2p_device(&rdev->wiphy, wdev);
877877 trace_rdev_return_void(&rdev->wiphy);
878−}
878+}
879879
880880 static inline int rdev_set_mac_acl(struct cfg80211_registered_device *rdev,
881881 struct net_device *dev,
@@ -901,4 +901,26 @@ static inline int rdev_update_ft_ies(struct cfg80211_registered_device *rdev, · 19 unmodified lines
901901 return ret;
902902 }
903903
904+static inline int rdev_crit_proto_start(struct cfg80211_registered_device *rdev,
905+ struct wireless_dev *wdev,
906+ enum nl80211_crit_proto_id protocol,
907+ u16 duration)
908+{
909+ int ret;
910+
911+ trace_rdev_crit_proto_start(&rdev->wiphy, wdev, protocol, duration);
912+ ret = rdev->ops->crit_proto_start(&rdev->wiphy, wdev,
913+ protocol, duration);
914+ trace_rdev_return_int(&rdev->wiphy, ret);
915+ return ret;
916+}
917+
918+static inline void rdev_crit_proto_stop(struct cfg80211_registered_device *rdev,
919+ struct wireless_dev *wdev)
920+{
921+ trace_rdev_crit_proto_stop(&rdev->wiphy, wdev);
922+ rdev->ops->crit_proto_stop(&rdev->wiphy, wdev);
923+ trace_rdev_return_void(&rdev->wiphy);
924+}
925+
904926 #endif /* __CFG80211_RDEV_OPS */
net/wireless/reg.c+1−1
@@ -855,7 +855,7 @@ static void handle_channel(struct wiphy *wiphy, · 854 unmodified lines
855855 return;
856856
857857 REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq);
858− chan->flags = IEEE80211_CHAN_DISABLED;
858+ chan->flags |= IEEE80211_CHAN_DISABLED;
859859 return;
860860 }
861861
net/wireless/trace.h+35−0
@@ -1806,6 +1806,41 @@ TRACE_EVENT(rdev_update_ft_ies, · 1805 unmodified lines
18061806 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->md)
18071807 );
18081808
1809+TRACE_EVENT(rdev_crit_proto_start,
1810+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
1811+ enum nl80211_crit_proto_id protocol, u16 duration),
1812+ TP_ARGS(wiphy, wdev, protocol, duration),
1813+ TP_STRUCT__entry(
1814+ WIPHY_ENTRY
1815+ WDEV_ENTRY
1816+ __field(u16, proto)
1817+ __field(u16, duration)
1818+ ),
1819+ TP_fast_assign(
1820+ WIPHY_ASSIGN;
1821+ WDEV_ASSIGN;
1822+ __entry->proto = protocol;
1823+ __entry->duration = duration;
1824+ ),
1825+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", proto=%x, duration=%u",
1826+ WIPHY_PR_ARG, WDEV_PR_ARG, __entry->proto, __entry->duration)
1827+);
1828+
1829+TRACE_EVENT(rdev_crit_proto_stop,
1830+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev),
1831+ TP_ARGS(wiphy, wdev),
1832+ TP_STRUCT__entry(
1833+ WIPHY_ENTRY
1834+ WDEV_ENTRY
1835+ ),
1836+ TP_fast_assign(
1837+ WIPHY_ASSIGN;
1838+ WDEV_ASSIGN;
1839+ ),
1840+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT,
1841+ WIPHY_PR_ARG, WDEV_PR_ARG)
1842+);
1843+
18091844 /*************************************************************
18101845 * cfg80211 exported functions traces *
18111846 *************************************************************/
net/wireless/util.c+24−4
@@ -1155,6 +1155,26 @@ int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, · 1154 unmodified lines
11551155 }
11561156 EXPORT_SYMBOL(cfg80211_get_p2p_attr);
11571157
1158+bool ieee80211_operating_class_to_band(u8 operating_class,
1159+ enum ieee80211_band *band)
1160+{
1161+ switch (operating_class) {
1162+ case 112:
1163+ case 115 ... 127:
1164+ *band = IEEE80211_BAND_5GHZ;
1165+ return true;
1166+ case 81:
1167+ case 82:
1168+ case 83:
1169+ case 84:
1170+ *band = IEEE80211_BAND_2GHZ;
1171+ return true;
1172+ }
1173+
1174+ return false;
1175+}
1176+EXPORT_SYMBOL(ieee80211_operating_class_to_band);
1177+
11581178 int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
11591179 u32 beacon_int)
11601180 {
@@ -1258,12 +1278,12 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, · 97 unmodified lines
12581278 list_for_each_entry(wdev_iter, &rdev->wdev_list, list) {
12591279 if (wdev_iter == wdev)
12601280 continue;
1261− if (wdev_iter->netdev) {
1262− if (!netif_running(wdev_iter->netdev))
1263− continue;
1264− } else if (wdev_iter->iftype == NL80211_IFTYPE_P2P_DEVICE) {
1281+ if (wdev_iter->iftype == NL80211_IFTYPE_P2P_DEVICE) {
12651282 if (!wdev_iter->p2p_started)
12661283 continue;
1284+ } else if (wdev_iter->netdev) {
1285+ if (!netif_running(wdev_iter->netdev))
1286+ continue;
12671287 } else {
12681288 WARN_ON(1);
12691289 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t