1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -234,6 +234,7 @@ struct ath_buf {
4 dma_addr_t bf_daddr; /* physical addr of desc */
5 dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */
7 + struct ieee80211_tx_rate rates[4];
8 struct ath_buf_state bf_state;
11 @@ -658,11 +659,10 @@ enum sc_op_flags {
12 struct ath_rate_table;
14 struct ath9k_vif_iter_data {
15 - const u8 *hw_macaddr; /* phy's hardware address, set
16 - * before starting iteration for
19 + u8 hw_macaddr[ETH_ALEN]; /* address of the first vif */
20 u8 mask[ETH_ALEN]; /* bssid mask */
21 + bool has_hw_macaddr;
23 int naps; /* number of AP vifs */
24 int nmeshes; /* number of mesh vifs */
25 int nstations; /* number of station vifs */
26 --- a/drivers/net/wireless/ath/ath9k/hw.c
27 +++ b/drivers/net/wireless/ath/ath9k/hw.c
28 @@ -1698,12 +1698,11 @@ static void ath9k_hw_reset_opmode(struct
30 ENABLE_REGWRITE_BUFFER(ah);
32 - REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr));
33 - REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4)
35 + REG_RMW(ah, AR_STA_ID1, macStaId1
36 | AR_STA_ID1_RTS_USE_DEF
37 | (ah->config.ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0)
38 - | ah->sta_id1_defaults);
39 + | ah->sta_id1_defaults,
40 + ~AR_STA_ID1_SADH_MASK);
41 ath_hw_setbssidmask(common);
42 REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna);
43 ath9k_hw_write_associd(ah);
44 --- a/drivers/net/wireless/ath/ath9k/main.c
45 +++ b/drivers/net/wireless/ath/ath9k/main.c
46 @@ -839,10 +839,14 @@ static void ath9k_vif_iter(void *data, u
47 struct ath9k_vif_iter_data *iter_data = data;
50 - if (iter_data->hw_macaddr)
51 + if (iter_data->has_hw_macaddr) {
52 for (i = 0; i < ETH_ALEN; i++)
54 ~(iter_data->hw_macaddr[i] ^ mac[i]);
56 + memcpy(iter_data->hw_macaddr, mac, ETH_ALEN);
57 + iter_data->has_hw_macaddr = true;
61 case NL80211_IFTYPE_AP:
62 @@ -891,7 +895,6 @@ void ath9k_calculate_iter_data(struct ie
63 * together with the BSSID mask when matching addresses.
65 memset(iter_data, 0, sizeof(*iter_data));
66 - iter_data->hw_macaddr = common->macaddr;
67 memset(&iter_data->mask, 0xff, ETH_ALEN);
70 @@ -901,6 +904,8 @@ void ath9k_calculate_iter_data(struct ie
71 ieee80211_iterate_active_interfaces_atomic(
72 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
73 ath9k_vif_iter, iter_data);
75 + memcpy(common->macaddr, iter_data->hw_macaddr, ETH_ALEN);
78 /* Called with sc->mutex held. */
79 --- a/drivers/net/wireless/ath/ath9k/reg.h
80 +++ b/drivers/net/wireless/ath/ath9k/reg.h
81 @@ -1493,9 +1493,6 @@ enum {
82 #define AR9271_RADIO_RF_RST 0x20
83 #define AR9271_GATE_MAC_CTL 0x4000
85 -#define AR_STA_ID0 0x8000
86 -#define AR_STA_ID1 0x8004
87 -#define AR_STA_ID1_SADH_MASK 0x0000FFFF
88 #define AR_STA_ID1_STA_AP 0x00010000
89 #define AR_STA_ID1_ADHOC 0x00020000
90 #define AR_STA_ID1_PWR_SAV 0x00040000
91 --- a/drivers/net/wireless/ath/hw.c
92 +++ b/drivers/net/wireless/ath/hw.c
94 void ath_hw_setbssidmask(struct ath_common *common)
96 void *ah = common->ah;
99 + REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr));
100 + id1 = REG_READ(ah, AR_STA_ID1) & ~AR_STA_ID1_SADH_MASK;
101 + id1 |= get_unaligned_le16(common->macaddr + 4);
102 + REG_WRITE(ah, AR_STA_ID1, id1);
104 REG_WRITE(ah, AR_BSSMSKL, get_unaligned_le32(common->bssidmask));
105 REG_WRITE(ah, AR_BSSMSKU, get_unaligned_le16(common->bssidmask + 4));
106 --- a/drivers/net/wireless/ath/reg.h
107 +++ b/drivers/net/wireless/ath/reg.h
109 #define AR_MIBC_CMC 0x00000004
110 #define AR_MIBC_MCS 0x00000008
112 +#define AR_STA_ID0 0x8000
113 +#define AR_STA_ID1 0x8004
114 +#define AR_STA_ID1_SADH_MASK 0x0000ffff
117 * BSSID mask registers. See ath_hw_set_bssid_mask()
118 * for detailed documentation about these registers.
119 --- a/drivers/net/wireless/iwlegacy/4965-mac.c
120 +++ b/drivers/net/wireless/iwlegacy/4965-mac.c
121 @@ -6059,7 +6059,7 @@ il4965_mac_channel_switch(struct ieee802
122 struct il_priv *il = hw->priv;
123 const struct il_channel_info *ch_info;
124 struct ieee80211_conf *conf = &hw->conf;
125 - struct ieee80211_channel *channel = ch_switch->channel;
126 + struct ieee80211_channel *channel = ch_switch->chandef.chan;
127 struct il_ht_config *ht_conf = &il->current_ht_config;
130 @@ -6096,23 +6096,21 @@ il4965_mac_channel_switch(struct ieee802
131 il->current_ht_config.smps = conf->smps_mode;
133 /* Configure HT40 channels */
134 - il->ht.enabled = conf_is_ht(conf);
135 - if (il->ht.enabled) {
136 - if (conf_is_ht40_minus(conf)) {
137 - il->ht.extension_chan_offset =
138 - IEEE80211_HT_PARAM_CHA_SEC_BELOW;
139 - il->ht.is_40mhz = true;
140 - } else if (conf_is_ht40_plus(conf)) {
141 - il->ht.extension_chan_offset =
142 - IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
143 - il->ht.is_40mhz = true;
145 - il->ht.extension_chan_offset =
146 - IEEE80211_HT_PARAM_CHA_SEC_NONE;
147 - il->ht.is_40mhz = false;
150 + switch (cfg80211_get_chandef_type(&ch_switch->chandef)) {
151 + case NL80211_CHAN_NO_HT:
152 + case NL80211_CHAN_HT20:
153 il->ht.is_40mhz = false;
154 + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
156 + case NL80211_CHAN_HT40MINUS:
157 + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
158 + il->ht.is_40mhz = true;
160 + case NL80211_CHAN_HT40PLUS:
161 + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
162 + il->ht.is_40mhz = true;
166 if ((le16_to_cpu(il->staging.channel) != ch))
167 il->staging.flags = 0;
168 --- a/drivers/net/wireless/iwlegacy/4965.c
169 +++ b/drivers/net/wireless/iwlegacy/4965.c
170 @@ -1493,7 +1493,7 @@ il4965_hw_channel_switch(struct il_priv
173 cmd.expect_beacon = 0;
174 - ch = ch_switch->channel->hw_value;
175 + ch = ch_switch->chandef.chan->hw_value;
176 cmd.channel = cpu_to_le16(ch);
177 cmd.rxon_flags = il->staging.flags;
178 cmd.rxon_filter_flags = il->staging.filter_flags;
179 --- a/drivers/net/wireless/iwlwifi/dvm/devices.c
180 +++ b/drivers/net/wireless/iwlwifi/dvm/devices.c
181 @@ -379,7 +379,7 @@ static int iwl5000_hw_channel_switch(str
184 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
185 - ch = ch_switch->channel->hw_value;
186 + ch = ch_switch->chandef.chan->hw_value;
187 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
188 ctx->active.channel, ch);
189 cmd.channel = cpu_to_le16(ch);
190 @@ -414,7 +414,8 @@ static int iwl5000_hw_channel_switch(str
192 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
194 - cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
195 + cmd.expect_beacon =
196 + ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
198 return iwl_dvm_send_cmd(priv, &hcmd);
200 @@ -540,7 +541,7 @@ static int iwl6000_hw_channel_switch(str
203 cmd->band = priv->band == IEEE80211_BAND_2GHZ;
204 - ch = ch_switch->channel->hw_value;
205 + ch = ch_switch->chandef.chan->hw_value;
206 IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
207 ctx->active.channel, ch);
208 cmd->channel = cpu_to_le16(ch);
209 @@ -575,7 +576,8 @@ static int iwl6000_hw_channel_switch(str
211 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
213 - cmd->expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
214 + cmd->expect_beacon =
215 + ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
217 err = iwl_dvm_send_cmd(priv, &hcmd);
219 --- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
220 +++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
221 @@ -970,7 +970,7 @@ static void iwlagn_mac_channel_switch(st
223 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
224 struct ieee80211_conf *conf = &hw->conf;
225 - struct ieee80211_channel *channel = ch_switch->channel;
226 + struct ieee80211_channel *channel = ch_switch->chandef.chan;
227 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
230 @@ -1008,11 +1008,21 @@ static void iwlagn_mac_channel_switch(st
231 priv->current_ht_config.smps = conf->smps_mode;
233 /* Configure HT40 channels */
234 - ctx->ht.enabled = conf_is_ht(conf);
235 - if (ctx->ht.enabled)
236 - iwlagn_config_ht40(conf, ctx);
238 + switch (cfg80211_get_chandef_type(&ch_switch->chandef)) {
239 + case NL80211_CHAN_NO_HT:
240 + case NL80211_CHAN_HT20:
241 ctx->ht.is_40mhz = false;
242 + ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
244 + case NL80211_CHAN_HT40MINUS:
245 + ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
246 + ctx->ht.is_40mhz = true;
248 + case NL80211_CHAN_HT40PLUS:
249 + ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
250 + ctx->ht.is_40mhz = true;
254 if ((le16_to_cpu(ctx->staging.channel) != ch))
255 ctx->staging.flags = 0;
256 --- a/drivers/net/wireless/iwlwifi/dvm/rxon.c
257 +++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c
258 @@ -1160,7 +1160,7 @@ int iwlagn_commit_rxon(struct iwl_priv *
261 void iwlagn_config_ht40(struct ieee80211_conf *conf,
262 - struct iwl_rxon_context *ctx)
263 + struct iwl_rxon_context *ctx)
265 if (conf_is_ht40_minus(conf)) {
266 ctx->ht.extension_chan_offset =
267 --- a/drivers/net/wireless/mac80211_hwsim.c
268 +++ b/drivers/net/wireless/mac80211_hwsim.c
270 #include <linux/if_arp.h>
271 #include <linux/rtnetlink.h>
272 #include <linux/etherdevice.h>
273 +#include <linux/platform_device.h>
274 #include <linux/debugfs.h>
275 #include <linux/module.h>
276 #include <linux/ktime.h>
277 @@ -717,9 +718,17 @@ static bool mac80211_hwsim_tx_frame_no_n
278 rx_status.flag |= RX_FLAG_MACTIME_START;
279 rx_status.freq = chan->center_freq;
280 rx_status.band = chan->band;
281 - rx_status.rate_idx = info->control.rates[0].idx;
282 - if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
283 - rx_status.flag |= RX_FLAG_HT;
284 + if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) {
285 + rx_status.rate_idx =
286 + ieee80211_rate_get_vht_mcs(&info->control.rates[0]);
287 + rx_status.vht_nss =
288 + ieee80211_rate_get_vht_nss(&info->control.rates[0]);
289 + rx_status.flag |= RX_FLAG_VHT;
291 + rx_status.rate_idx = info->control.rates[0].idx;
292 + if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
293 + rx_status.flag |= RX_FLAG_HT;
295 if (info->control.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
296 rx_status.flag |= RX_FLAG_40MHZ;
297 if (info->control.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
298 @@ -1687,6 +1696,7 @@ static void mac80211_hwsim_free(void)
299 debugfs_remove(data->debugfs_ps);
300 debugfs_remove(data->debugfs);
301 ieee80211_unregister_hw(data->hw);
302 + device_release_driver(data->dev);
303 device_unregister(data->dev);
304 ieee80211_free_hw(data->hw);
306 @@ -1695,7 +1705,9 @@ static void mac80211_hwsim_free(void)
309 static struct device_driver mac80211_hwsim_driver = {
310 - .name = "mac80211_hwsim"
311 + .name = "mac80211_hwsim",
312 + .bus = &platform_bus_type,
313 + .owner = THIS_MODULE,
316 static const struct net_device_ops hwsim_netdev_ops = {
317 @@ -2187,9 +2199,15 @@ static int __init init_mac80211_hwsim(vo
318 spin_lock_init(&hwsim_radio_lock);
319 INIT_LIST_HEAD(&hwsim_radios);
321 + err = driver_register(&mac80211_hwsim_driver);
325 hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim");
326 - if (IS_ERR(hwsim_class))
327 - return PTR_ERR(hwsim_class);
328 + if (IS_ERR(hwsim_class)) {
329 + err = PTR_ERR(hwsim_class);
330 + goto failed_unregister_driver;
333 memset(addr, 0, ETH_ALEN);
335 @@ -2211,12 +2229,20 @@ static int __init init_mac80211_hwsim(vo
337 if (IS_ERR(data->dev)) {
339 - "mac80211_hwsim: device_create "
340 - "failed (%ld)\n", PTR_ERR(data->dev));
341 + "mac80211_hwsim: device_create failed (%ld)\n",
342 + PTR_ERR(data->dev));
346 data->dev->driver = &mac80211_hwsim_driver;
347 + err = device_bind_driver(data->dev);
350 + "mac80211_hwsim: device_bind_driver failed (%d)\n",
355 skb_queue_head_init(&data->pending);
357 SET_IEEE80211_DEV(hw, data->dev);
358 @@ -2515,6 +2541,8 @@ failed_drvdata:
359 ieee80211_free_hw(hw);
361 mac80211_hwsim_free();
362 +failed_unregister_driver:
363 + driver_unregister(&mac80211_hwsim_driver);
366 module_init(init_mac80211_hwsim);
367 @@ -2527,5 +2555,6 @@ static void __exit exit_mac80211_hwsim(v
369 mac80211_hwsim_free();
370 unregister_netdev(hwsim_mon);
371 + driver_unregister(&mac80211_hwsim_driver);
373 module_exit(exit_mac80211_hwsim);
374 --- a/drivers/net/wireless/ti/wl12xx/cmd.c
375 +++ b/drivers/net/wireless/ti/wl12xx/cmd.c
376 @@ -301,7 +301,7 @@ int wl12xx_cmd_channel_switch(struct wl1
379 cmd->role_id = wlvif->role_id;
380 - cmd->channel = ch_switch->channel->hw_value;
381 + cmd->channel = ch_switch->chandef.chan->hw_value;
382 cmd->switch_time = ch_switch->count;
383 cmd->stop_tx = ch_switch->block_tx;
385 --- a/drivers/net/wireless/ti/wl18xx/cmd.c
386 +++ b/drivers/net/wireless/ti/wl18xx/cmd.c
387 @@ -42,11 +42,11 @@ int wl18xx_cmd_channel_switch(struct wl1
390 cmd->role_id = wlvif->role_id;
391 - cmd->channel = ch_switch->channel->hw_value;
392 + cmd->channel = ch_switch->chandef.chan->hw_value;
393 cmd->switch_time = ch_switch->count;
394 cmd->stop_tx = ch_switch->block_tx;
396 - switch (ch_switch->channel->band) {
397 + switch (ch_switch->chandef.chan->band) {
398 case IEEE80211_BAND_2GHZ:
399 cmd->band = WLCORE_BAND_2_4GHZ;
401 @@ -55,7 +55,7 @@ int wl18xx_cmd_channel_switch(struct wl1
404 wl1271_error("invalid channel switch band: %d",
405 - ch_switch->channel->band);
406 + ch_switch->chandef.chan->band);
410 --- a/include/linux/ieee80211.h
411 +++ b/include/linux/ieee80211.h
412 @@ -673,6 +673,36 @@ struct ieee80211_channel_sw_ie {
416 + * struct ieee80211_ext_chansw_ie
418 + * This structure represents the "Extended Channel Switch Announcement element"
420 +struct ieee80211_ext_chansw_ie {
422 + u8 new_operating_class;
428 + * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
429 + * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
431 + * This structure represents the "Secondary Channel Offset element"
433 +struct ieee80211_sec_chan_offs_ie {
438 + * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
440 +struct ieee80211_wide_bw_chansw_ie {
441 + u8 new_channel_width;
442 + u8 new_center_freq_seg0, new_center_freq_seg1;
446 * struct ieee80211_tim
448 * This structure refers to "Traffic Indication Map information element"
449 @@ -840,12 +870,15 @@ struct ieee80211_mgmt {
450 } __packed wme_action;
455 - struct ieee80211_channel_sw_ie sw_elem;
457 } __packed chan_switch;
460 + struct ieee80211_ext_chansw_ie data;
462 + } __packed ext_chan_switch;
468 @@ -1638,6 +1671,7 @@ enum ieee80211_eid {
470 WLAN_EID_HT_CAPABILITY = 45,
471 WLAN_EID_HT_OPERATION = 61,
472 + WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
476 @@ -1672,6 +1706,8 @@ enum ieee80211_eid {
477 WLAN_EID_VHT_CAPABILITY = 191,
478 WLAN_EID_VHT_OPERATION = 192,
479 WLAN_EID_OPMODE_NOTIF = 199,
480 + WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
481 + WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
484 WLAN_EID_NON_TX_BSSID_CAP = 83,
485 @@ -1795,6 +1831,7 @@ enum ieee80211_key_len {
487 /* Public action codes */
488 enum ieee80211_pub_actioncode {
489 + WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
490 WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
493 --- a/include/net/cfg80211.h
494 +++ b/include/net/cfg80211.h
495 @@ -753,6 +753,8 @@ int cfg80211_check_station_change(struct
496 * @STATION_INFO_LOCAL_PM: @local_pm filled
497 * @STATION_INFO_PEER_PM: @peer_pm filled
498 * @STATION_INFO_NONPEER_PM: @nonpeer_pm filled
499 + * @STATION_INFO_CHAIN_SIGNAL: @chain_signal filled
500 + * @STATION_INFO_CHAIN_SIGNAL_AVG: @chain_signal_avg filled
502 enum station_info_flags {
503 STATION_INFO_INACTIVE_TIME = 1<<0,
504 @@ -781,6 +783,8 @@ enum station_info_flags {
505 STATION_INFO_NONPEER_PM = 1<<23,
506 STATION_INFO_RX_BYTES64 = 1<<24,
507 STATION_INFO_TX_BYTES64 = 1<<25,
508 + STATION_INFO_CHAIN_SIGNAL = 1<<26,
509 + STATION_INFO_CHAIN_SIGNAL_AVG = 1<<27,
513 @@ -857,6 +861,8 @@ struct sta_bss_parameters {
517 +#define IEEE80211_MAX_CHAINS 4
520 * struct station_info - station information
522 @@ -874,6 +880,9 @@ struct sta_bss_parameters {
523 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
524 * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
525 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
526 + * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
527 + * @chain_signal: per-chain signal strength of last received packet in dBm
528 + * @chain_signal_avg: per-chain signal strength average in dBm
529 * @txrate: current unicast bitrate from this station
530 * @rxrate: current unicast bitrate to this station
531 * @rx_packets: packets received from this station
532 @@ -909,6 +918,11 @@ struct station_info {
538 + s8 chain_signal[IEEE80211_MAX_CHAINS];
539 + s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
541 struct rate_info txrate;
542 struct rate_info rxrate;
544 @@ -4027,6 +4041,17 @@ bool cfg80211_reg_can_beacon(struct wiph
545 void cfg80211_ch_switch_notify(struct net_device *dev,
546 struct cfg80211_chan_def *chandef);
549 + * ieee80211_operating_class_to_band - convert operating class to band
551 + * @operating_class: the operating class to convert
552 + * @band: band pointer to fill
554 + * Returns %true if the conversion was successful, %false otherwise.
556 +bool ieee80211_operating_class_to_band(u8 operating_class,
557 + enum ieee80211_band *band);
560 * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
561 * @dev: the device on which the operation is requested
562 --- a/include/net/mac80211.h
563 +++ b/include/net/mac80211.h
564 @@ -210,7 +210,7 @@ struct ieee80211_chanctx_conf {
565 * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note
566 * that it is only ever disabled for station mode.
567 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
568 - * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode)
569 + * @BSS_CHANGED_SSID: SSID changed for this BSS (AP and IBSS mode)
570 * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
571 * @BSS_CHANGED_PS: PS changed for this BSS (STA mode)
572 * @BSS_CHANGED_TXPOWER: TX power setting changed for this interface
573 @@ -327,7 +327,7 @@ enum ieee80211_rssi_event {
574 * your driver/device needs to do.
575 * @ps: power-save mode (STA only). This flag is NOT affected by
576 * offchannel/dynamic_ps operations.
577 - * @ssid: The SSID of the current vif. Only valid in AP-mode.
578 + * @ssid: The SSID of the current vif. Valid in AP and IBSS mode.
579 * @ssid_len: Length of SSID given in @ssid.
580 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
581 * @txpower: TX power in dBm
582 @@ -562,6 +562,9 @@ enum mac80211_rate_control_flags {
583 /* maximum number of rate stages */
584 #define IEEE80211_TX_MAX_RATES 4
586 +/* maximum number of rate table entries */
587 +#define IEEE80211_TX_RATE_TABLE_SIZE 4
590 * struct ieee80211_tx_rate - rate selection/status
592 @@ -602,8 +605,8 @@ static inline void ieee80211_rate_set_vh
596 - WARN_ON(nss & ~0x7);
597 - rate->idx = (nss << 4) | mcs;
598 + WARN_ON((nss - 1) & ~0x7);
599 + rate->idx = ((nss - 1) << 4) | mcs;
603 @@ -615,7 +618,7 @@ ieee80211_rate_get_vht_mcs(const struct
605 ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
607 - return rate->idx >> 4;
608 + return (rate->idx >> 4) + 1;
612 @@ -656,7 +659,11 @@ struct ieee80211_tx_info {
613 struct ieee80211_tx_rate rates[
614 IEEE80211_TX_MAX_RATES];
619 + u8 short_preamble:1;
623 /* only needed before rate control */
624 unsigned long jiffies;
625 @@ -677,6 +684,8 @@ struct ieee80211_tx_info {
627 struct ieee80211_tx_rate driver_rates[
628 IEEE80211_TX_MAX_RATES];
631 void *rate_driver_data[
632 IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
634 @@ -840,6 +849,9 @@ enum mac80211_rx_flags {
635 * @signal: signal strength when receiving this frame, either in dBm, in dB or
636 * unspecified depending on the hardware capabilities flags
637 * @IEEE80211_HW_SIGNAL_*
638 + * @chains: bitmask of receive chains for which separate signal strength
639 + * values were filled.
640 + * @chain_signal: per-chain signal strength, same format as @signal
641 * @antenna: antenna used
642 * @rate_idx: index of data rate into band's supported rates or MCS index if
643 * HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
644 @@ -871,6 +883,8 @@ struct ieee80211_rx_status {
649 + s8 chain_signal[IEEE80211_MAX_CHAINS];
650 u8 ampdu_delimiter_crc;
651 u8 vendor_radiotap_align;
652 u8 vendor_radiotap_oui[3];
653 @@ -1018,13 +1032,13 @@ struct ieee80211_conf {
654 * the driver passed into mac80211.
655 * @block_tx: Indicates whether transmission must be blocked before the
656 * scheduled channel switch, as indicated by the AP.
657 - * @channel: the new channel to switch to
658 + * @chandef: the new channel to switch to
659 * @count: the number of TBTT's until the channel switch event
661 struct ieee80211_channel_switch {
664 - struct ieee80211_channel *channel;
665 + struct cfg80211_chan_def chandef;
669 @@ -1222,6 +1236,24 @@ enum ieee80211_sta_rx_bandwidth {
673 + * struct ieee80211_sta_rates - station rate selection table
675 + * @rcu_head: RCU head used for freeing the table on update
676 + * @rates: transmit rates/flags to be used by default.
677 + * Overriding entries per-packet is possible by using cb tx control.
679 +struct ieee80211_sta_rates {
680 + struct rcu_head rcu_head;
687 + } rate[IEEE80211_TX_RATE_TABLE_SIZE];
691 * struct ieee80211_sta - station table entry
693 * A station table entry represents a station we are possibly
694 @@ -1248,6 +1280,7 @@ enum ieee80211_sta_rx_bandwidth {
695 * notifications and capabilities. The value is only valid after
696 * the station moves to associated state.
697 * @smps_mode: current SMPS mode (off, static or dynamic)
698 + * @tx_rates: rate control selection table
700 struct ieee80211_sta {
701 u32 supp_rates[IEEE80211_NUM_BANDS];
702 @@ -1261,6 +1294,7 @@ struct ieee80211_sta {
704 enum ieee80211_sta_rx_bandwidth bandwidth;
705 enum ieee80211_smps_mode smps_mode;
706 + struct ieee80211_sta_rates __rcu *rates;
709 u8 drv_priv[0] __aligned(sizeof(void *));
710 @@ -1416,6 +1450,9 @@ struct ieee80211_tx_control {
711 * for different virtual interfaces. See the doc section on HW queue
712 * control for more details.
714 + * @IEEE80211_HW_SUPPORTS_RC_TABLE: The driver supports using a rate
715 + * selection table provided by the rate control algorithm.
717 * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any
718 * P2P Interface. This will be honoured even if more than one interface
720 @@ -1448,6 +1485,7 @@ enum ieee80211_hw_flags {
721 IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21,
722 IEEE80211_HW_AP_LINK_PS = 1<<22,
723 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23,
724 + IEEE80211_HW_SUPPORTS_RC_TABLE = 1<<24,
725 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25,
726 IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26,
728 @@ -3144,6 +3182,25 @@ void ieee80211_sta_set_buffered(struct i
729 u8 tid, bool buffered);
732 + * ieee80211_get_tx_rates - get the selected transmit rates for a packet
734 + * Call this function in a driver with per-packet rate selection support
735 + * to combine the rate info in the packet tx info with the most recent
736 + * rate selection table for the station entry.
738 + * @vif: &struct ieee80211_vif pointer from the add_interface callback.
739 + * @sta: the receiver station to which this packet is sent.
740 + * @skb: the frame to be transmitted.
741 + * @dest: buffer for extracted rate/retry information
742 + * @max_rates: maximum number of rates to fetch
744 +void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
745 + struct ieee80211_sta *sta,
746 + struct sk_buff *skb,
747 + struct ieee80211_tx_rate *dest,
751 * ieee80211_tx_status - transmit status callback
753 * Call this function for all transmitted frames after they have been
754 @@ -4118,7 +4175,7 @@ void ieee80211_send_bar(struct ieee80211
755 * (deprecated; this will be removed once drivers get updated to use
757 * @rate_idx_mask: user-requested (legacy) rate mask
758 - * @rate_idx_mcs_mask: user-requested MCS rate mask
759 + * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
760 * @bss: whether this frame is sent out in AP or IBSS mode
762 struct ieee80211_tx_rate_control {
763 @@ -4130,7 +4187,7 @@ struct ieee80211_tx_rate_control {
764 bool rts, short_preamble;
767 - u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
768 + u8 *rate_idx_mcs_mask;
772 @@ -4219,6 +4276,22 @@ bool rate_usable_index_exists(struct iee
777 + * rate_control_set_rates - pass the sta rate selection to mac80211/driver
779 + * When not doing a rate control probe to test rates, rate control should pass
780 + * its rate selection to mac80211. If the driver supports receiving a station
781 + * rate table, it will use it to ensure that frames are always sent based on
782 + * the most recent rate control module decision.
784 + * @hw: pointer as obtained from ieee80211_alloc_hw()
785 + * @pubsta: &struct ieee80211_sta pointer to the target destination.
786 + * @rates: new tx rate set to be used for this station.
788 +int rate_control_set_rates(struct ieee80211_hw *hw,
789 + struct ieee80211_sta *pubsta,
790 + struct ieee80211_sta_rates *rates);
792 int ieee80211_rate_control_register(struct rate_control_ops *ops);
793 void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
795 --- a/net/mac80211/agg-rx.c
796 +++ b/net/mac80211/agg-rx.c
797 @@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
798 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
799 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
800 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
801 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
802 + memcpy(mgmt->bssid, da, ETH_ALEN);
804 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
805 IEEE80211_STYPE_ACTION);
806 --- a/net/mac80211/agg-tx.c
807 +++ b/net/mac80211/agg-tx.c
808 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
809 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
810 if (sdata->vif.type == NL80211_IFTYPE_AP ||
811 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
812 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
813 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
814 + sdata->vif.type == NL80211_IFTYPE_WDS)
815 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
816 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
817 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
818 @@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
819 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
820 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
821 sdata->vif.type != NL80211_IFTYPE_AP &&
822 + sdata->vif.type != NL80211_IFTYPE_WDS &&
823 sdata->vif.type != NL80211_IFTYPE_ADHOC)
826 --- a/net/mac80211/cfg.c
827 +++ b/net/mac80211/cfg.c
828 @@ -444,7 +444,7 @@ static void sta_set_sinfo(struct sta_inf
829 struct ieee80211_local *local = sdata->local;
830 struct timespec uptime;
835 sinfo->generation = sdata->local->sta_generation;
837 @@ -488,6 +488,17 @@ static void sta_set_sinfo(struct sta_inf
838 sinfo->signal = (s8)sta->last_signal;
839 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
842 + sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
843 + STATION_INFO_CHAIN_SIGNAL_AVG;
845 + sinfo->chains = sta->chains;
846 + for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
847 + sinfo->chain_signal[i] = sta->chain_signal_last[i];
848 + sinfo->chain_signal_avg[i] =
849 + (s8) -ewma_read(&sta->chain_signal_avg[i]);
853 sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
854 sta_set_rate_info_rx(sta, &sinfo->rxrate);
855 @@ -1052,6 +1063,7 @@ static int ieee80211_stop_ap(struct wiph
856 ieee80211_free_keys(sdata);
858 sdata->vif.bss_conf.enable_beacon = false;
859 + sdata->vif.bss_conf.ssid_len = 0;
860 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
861 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
863 @@ -2416,9 +2428,22 @@ static int ieee80211_set_bitrate_mask(st
866 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
867 + struct ieee80211_supported_band *sband = wiphy->bands[i];
870 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
871 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
872 sizeof(mask->control[i].mcs));
874 + sdata->rc_has_mcs_mask[i] = false;
878 + for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++)
879 + if (~sdata->rc_rateidx_mcs_mask[i][j]) {
880 + sdata->rc_has_mcs_mask[i] = true;
886 --- a/net/mac80211/chan.c
887 +++ b/net/mac80211/chan.c
888 @@ -57,6 +57,22 @@ ieee80211_find_chanctx(struct ieee80211_
892 +static bool ieee80211_is_radar_required(struct ieee80211_local *local)
894 + struct ieee80211_sub_if_data *sdata;
897 + list_for_each_entry_rcu(sdata, &local->interfaces, list) {
898 + if (sdata->radar_required) {
908 static struct ieee80211_chanctx *
909 ieee80211_new_chanctx(struct ieee80211_local *local,
910 const struct cfg80211_chan_def *chandef,
911 @@ -76,6 +92,9 @@ ieee80211_new_chanctx(struct ieee80211_l
912 ctx->conf.rx_chains_static = 1;
913 ctx->conf.rx_chains_dynamic = 1;
915 + ctx->conf.radar_enabled = ieee80211_is_radar_required(local);
916 + if (!local->use_chanctx)
917 + local->hw.conf.radar_enabled = ctx->conf.radar_enabled;
919 /* acquire mutex to prevent idle from changing */
920 mutex_lock(&local->mtx);
921 @@ -110,6 +129,7 @@ ieee80211_new_chanctx(struct ieee80211_l
922 static void ieee80211_free_chanctx(struct ieee80211_local *local,
923 struct ieee80211_chanctx *ctx)
925 + bool check_single_channel = false;
926 lockdep_assert_held(&local->chanctx_mtx);
928 WARN_ON_ONCE(ctx->refcount != 0);
929 @@ -119,6 +139,14 @@ static void ieee80211_free_chanctx(struc
930 chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
931 chandef->center_freq1 = chandef->chan->center_freq;
932 chandef->center_freq2 = 0;
934 + /* NOTE: Disabling radar is only valid here for
935 + * single channel context. To be sure, check it ...
937 + if (local->hw.conf.radar_enabled)
938 + check_single_channel = true;
939 + local->hw.conf.radar_enabled = false;
941 ieee80211_hw_config(local, 0);
943 drv_remove_chanctx(local, ctx);
944 @@ -127,6 +155,9 @@ static void ieee80211_free_chanctx(struc
945 list_del_rcu(&ctx->list);
946 kfree_rcu(ctx, rcu_head);
948 + /* throw a warning if this wasn't the only channel context. */
949 + WARN_ON(check_single_channel && !list_empty(&local->chanctx_list));
951 mutex_lock(&local->mtx);
952 ieee80211_recalc_idle(local);
953 mutex_unlock(&local->mtx);
954 @@ -238,19 +269,11 @@ static void __ieee80211_vif_release_chan
955 void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
956 struct ieee80211_chanctx *chanctx)
958 - struct ieee80211_sub_if_data *sdata;
959 - bool radar_enabled = false;
960 + bool radar_enabled;
962 lockdep_assert_held(&local->chanctx_mtx);
965 - list_for_each_entry_rcu(sdata, &local->interfaces, list) {
966 - if (sdata->radar_required) {
967 - radar_enabled = true;
972 + radar_enabled = ieee80211_is_radar_required(local);
974 if (radar_enabled == chanctx->conf.radar_enabled)
976 --- a/net/mac80211/debugfs_sta.c
977 +++ b/net/mac80211/debugfs_sta.c
978 @@ -66,11 +66,11 @@ static ssize_t sta_flags_read(struct fil
979 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
981 int res = scnprintf(buf, sizeof(buf),
982 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
983 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
984 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
985 TEST(PS_DRIVER), TEST(AUTHORIZED),
986 TEST(SHORT_PREAMBLE),
987 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
988 + TEST(WME), TEST(CLEAR_PS_FILT),
989 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
990 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
991 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
992 --- a/net/mac80211/ibss.c
993 +++ b/net/mac80211/ibss.c
994 @@ -209,6 +209,8 @@ static void __ieee80211_sta_join_ibss(st
995 sdata->vif.bss_conf.enable_beacon = true;
996 sdata->vif.bss_conf.beacon_int = beacon_int;
997 sdata->vif.bss_conf.basic_rates = basic_rates;
998 + sdata->vif.bss_conf.ssid_len = ifibss->ssid_len;
999 + memcpy(sdata->vif.bss_conf.ssid, ifibss->ssid, ifibss->ssid_len);
1000 bss_change = BSS_CHANGED_BEACON_INT;
1001 bss_change |= ieee80211_reset_erp_info(sdata);
1002 bss_change |= BSS_CHANGED_BSSID;
1003 @@ -217,6 +219,7 @@ static void __ieee80211_sta_join_ibss(st
1004 bss_change |= BSS_CHANGED_BASIC_RATES;
1005 bss_change |= BSS_CHANGED_HT;
1006 bss_change |= BSS_CHANGED_IBSS;
1007 + bss_change |= BSS_CHANGED_SSID;
1010 * In 5 GHz/802.11a, we can always use short slot time.
1011 @@ -911,7 +914,7 @@ void ieee80211_rx_mgmt_probe_beacon(stru
1014 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
1018 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
1020 @@ -1159,6 +1162,7 @@ int ieee80211_ibss_leave(struct ieee8021
1021 sdata->vif.bss_conf.ibss_joined = false;
1022 sdata->vif.bss_conf.ibss_creator = false;
1023 sdata->vif.bss_conf.enable_beacon = false;
1024 + sdata->vif.bss_conf.ssid_len = 0;
1025 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1026 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
1028 --- a/net/mac80211/ieee80211_i.h
1029 +++ b/net/mac80211/ieee80211_i.h
1030 @@ -156,6 +156,7 @@ struct ieee80211_tx_data {
1031 struct ieee80211_sub_if_data *sdata;
1032 struct sta_info *sta;
1033 struct ieee80211_key *key;
1034 + struct ieee80211_tx_rate rate;
1038 @@ -740,6 +741,8 @@ struct ieee80211_sub_if_data {
1040 /* bitmap of allowed (non-MCS) rate indexes for rate control */
1041 u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
1043 + bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
1044 u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
1047 @@ -1025,7 +1028,7 @@ struct ieee80211_local {
1048 enum mac80211_scan_state next_scan_state;
1049 struct delayed_work scan_work;
1050 struct ieee80211_sub_if_data __rcu *scan_sdata;
1051 - struct ieee80211_channel *csa_channel;
1052 + struct cfg80211_chan_def csa_chandef;
1053 /* For backward compatibility only -- do not use */
1054 struct cfg80211_chan_def _oper_chandef;
1056 @@ -1184,10 +1187,13 @@ struct ieee802_11_elems {
1058 const struct ieee80211_rann_ie *rann;
1059 const struct ieee80211_channel_sw_ie *ch_switch_ie;
1060 + const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1061 + const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
1062 const u8 *country_elem;
1063 const u8 *pwr_constr_elem;
1064 const struct ieee80211_timeout_interval_ie *timeout_int;
1065 const u8 *opmode_notif;
1066 + const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
1068 /* length of them, respectively */
1070 @@ -1258,10 +1264,6 @@ void ieee80211_recalc_ps_vif(struct ieee
1071 int ieee80211_max_network_latency(struct notifier_block *nb,
1072 unsigned long data, void *dummy);
1073 int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
1075 -ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1076 - const struct ieee80211_channel_sw_ie *sw_elem,
1077 - struct ieee80211_bss *bss, u64 timestamp);
1078 void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
1079 void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1080 struct sk_buff *skb);
1081 @@ -1499,13 +1501,13 @@ static inline void ieee80211_tx_skb(stru
1082 ieee80211_tx_skb_tid(sdata, skb, 7);
1085 -u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
1086 +u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action,
1087 struct ieee802_11_elems *elems,
1088 u64 filter, u32 crc);
1089 -static inline void ieee802_11_parse_elems(u8 *start, size_t len,
1090 +static inline void ieee802_11_parse_elems(u8 *start, size_t len, bool action,
1091 struct ieee802_11_elems *elems)
1093 - ieee802_11_parse_elems_crc(start, len, elems, 0, 0);
1094 + ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1097 u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
1098 --- a/net/mac80211/iface.c
1099 +++ b/net/mac80211/iface.c
1100 @@ -450,7 +450,6 @@ int ieee80211_do_open(struct wireless_de
1101 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
1102 struct net_device *dev = wdev->netdev;
1103 struct ieee80211_local *local = sdata->local;
1104 - struct sta_info *sta;
1107 u32 hw_reconf_flags = 0;
1108 @@ -609,30 +608,8 @@ int ieee80211_do_open(struct wireless_de
1110 set_bit(SDATA_STATE_RUNNING, &sdata->state);
1112 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
1113 - /* Create STA entry for the WDS peer */
1114 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1118 - goto err_del_interface;
1121 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1122 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1123 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1125 - res = sta_info_insert(sta);
1127 - /* STA has been freed */
1128 - goto err_del_interface;
1131 - rate_control_rate_init(sta);
1132 - netif_carrier_on(dev);
1133 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
1134 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
1135 rcu_assign_pointer(local->p2p_sdata, sdata);
1139 * set_multicast_list will be invoked by the networking core
1140 @@ -1092,6 +1069,74 @@ static void ieee80211_if_setup(struct ne
1141 dev->destructor = free_netdev;
1144 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1145 + struct sk_buff *skb)
1147 + struct ieee80211_local *local = sdata->local;
1148 + struct ieee80211_rx_status *rx_status;
1149 + struct ieee802_11_elems elems;
1150 + struct ieee80211_mgmt *mgmt;
1151 + struct sta_info *sta;
1156 + enum ieee80211_band band;
1157 + struct ieee80211_supported_band *sband;
1159 + rx_status = IEEE80211_SKB_RXCB(skb);
1160 + band = rx_status->band;
1161 + sband = local->hw.wiphy->bands[band];
1162 + mgmt = (struct ieee80211_mgmt *) skb->data;
1163 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
1165 + if (stype != IEEE80211_STYPE_BEACON)
1168 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
1169 + if (baselen > skb->len)
1172 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
1173 + skb->len - baselen, false, &elems);
1175 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
1179 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
1182 + rcu_read_unlock();
1183 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1191 + sta->last_rx = jiffies;
1192 + sta->sta.supp_rates[band] = rates;
1194 + if (elems.ht_cap_elem)
1195 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1196 + elems.ht_cap_elem, sta);
1198 + if (elems.wmm_param)
1199 + set_sta_flag(sta, WLAN_STA_WME);
1202 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1203 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1204 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1205 + rate_control_rate_init(sta);
1206 + sta_info_insert_rcu(sta);
1209 + rcu_read_unlock();
1212 static void ieee80211_iface_work(struct work_struct *work)
1214 struct ieee80211_sub_if_data *sdata =
1215 @@ -1196,6 +1241,9 @@ static void ieee80211_iface_work(struct
1217 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
1219 + case NL80211_IFTYPE_WDS:
1220 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
1223 WARN(1, "frame for unexpected interface type");
1225 --- a/net/mac80211/main.c
1226 +++ b/net/mac80211/main.c
1227 @@ -674,6 +674,7 @@ int ieee80211_register_hw(struct ieee802
1228 int channels, max_bitrates;
1229 bool supp_ht, supp_vht;
1230 netdev_features_t feature_whitelist;
1231 + struct cfg80211_chan_def dflt_chandef = {};
1232 static const u32 cipher_suites[] = {
1233 /* keep WEP first, it may be removed below */
1234 WLAN_CIPHER_SUITE_WEP40,
1235 @@ -751,19 +752,19 @@ int ieee80211_register_hw(struct ieee802
1236 sband = local->hw.wiphy->bands[band];
1239 - if (!local->use_chanctx && !local->_oper_chandef.chan) {
1241 + if (!dflt_chandef.chan) {
1242 + cfg80211_chandef_create(&dflt_chandef,
1243 + &sband->channels[0],
1244 + NL80211_CHAN_NO_HT);
1245 /* init channel we're on */
1246 - struct cfg80211_chan_def chandef = {
1247 - .chan = &sband->channels[0],
1248 - .width = NL80211_CHAN_NO_HT,
1249 - .center_freq1 = sband->channels[0].center_freq,
1252 - local->hw.conf.chandef = local->_oper_chandef = chandef;
1253 + if (!local->use_chanctx && !local->_oper_chandef.chan) {
1254 + local->hw.conf.chandef = dflt_chandef;
1255 + local->_oper_chandef = dflt_chandef;
1257 + local->monitor_chandef = dflt_chandef;
1259 - cfg80211_chandef_create(&local->monitor_chandef,
1260 - &sband->channels[0],
1261 - NL80211_CHAN_NO_HT);
1263 channels += sband->n_channels;
1265 if (max_bitrates < sband->n_bitrates)
1266 --- a/net/mac80211/mesh.c
1267 +++ b/net/mac80211/mesh.c
1268 @@ -838,7 +838,7 @@ ieee80211_mesh_rx_probe_req(struct ieee8
1272 - ieee802_11_parse_elems(pos, len - baselen, &elems);
1273 + ieee802_11_parse_elems(pos, len - baselen, false, &elems);
1275 /* 802.11-2012 10.1.4.3.2 */
1276 if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) &&
1277 @@ -899,7 +899,7 @@ static void ieee80211_mesh_rx_bcn_presp(
1280 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
1284 /* ignore non-mesh or secure / unsecure mismatch */
1285 if ((!elems.mesh_id || !elems.mesh_config) ||
1286 --- a/net/mac80211/mesh_hwmp.c
1287 +++ b/net/mac80211/mesh_hwmp.c
1288 @@ -880,7 +880,7 @@ void mesh_rx_path_sel_frame(struct ieee8
1290 baselen = (u8 *) mgmt->u.action.u.mesh_action.variable - (u8 *) mgmt;
1291 ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable,
1292 - len - baselen, &elems);
1293 + len - baselen, false, &elems);
1296 if (elems.preq_len != 37)
1297 --- a/net/mac80211/mesh_plink.c
1298 +++ b/net/mac80211/mesh_plink.c
1299 @@ -544,8 +544,8 @@ static void mesh_plink_timer(unsigned lo
1303 - "Mesh plink timer for %pM fired on state %d\n",
1304 - sta->sta.addr, sta->plink_state);
1305 + "Mesh plink timer for %pM fired on state %s\n",
1306 + sta->sta.addr, mplstates[sta->plink_state]);
1310 @@ -687,7 +687,7 @@ void mesh_rx_plink_frame(struct ieee8021
1314 - ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
1315 + ieee802_11_parse_elems(baseaddr, len - baselen, true, &elems);
1317 if (!elems.peering) {
1319 --- a/net/mac80211/mlme.c
1320 +++ b/net/mac80211/mlme.c
1321 @@ -289,6 +289,8 @@ ieee80211_determine_chantype(struct ieee
1323 /* 40 MHz (and 80 MHz) must be supported for VHT */
1324 ret = IEEE80211_STA_DISABLE_VHT;
1325 + /* also mark 40 MHz disabled */
1326 + ret |= IEEE80211_STA_DISABLE_40MHZ;
1330 @@ -303,12 +305,6 @@ ieee80211_determine_chantype(struct ieee
1332 vht_chandef.center_freq2 = 0;
1334 - if (vht_oper->center_freq_seg2_idx)
1335 - vht_chandef.center_freq2 =
1336 - ieee80211_channel_to_frequency(
1337 - vht_oper->center_freq_seg2_idx,
1340 switch (vht_oper->chan_width) {
1341 case IEEE80211_VHT_CHANWIDTH_USE_HT:
1342 vht_chandef.width = chandef->width;
1343 @@ -321,6 +317,10 @@ ieee80211_determine_chantype(struct ieee
1345 case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
1346 vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
1347 + vht_chandef.center_freq2 =
1348 + ieee80211_channel_to_frequency(
1349 + vht_oper->center_freq_seg2_idx,
1354 @@ -604,7 +604,6 @@ static void ieee80211_add_vht_ie(struct
1357 struct ieee80211_sta_vht_cap vht_cap;
1360 BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap));
1362 @@ -632,37 +631,6 @@ static void ieee80211_add_vht_ie(struct
1363 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)))
1364 cap &= ~IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
1366 - if (!(ap_vht_cap->vht_cap_info &
1367 - cpu_to_le32(IEEE80211_VHT_CAP_TXSTBC)))
1368 - cap &= ~(IEEE80211_VHT_CAP_RXSTBC_1 |
1369 - IEEE80211_VHT_CAP_RXSTBC_3 |
1370 - IEEE80211_VHT_CAP_RXSTBC_4);
1372 - for (i = 0; i < 8; i++) {
1373 - int shift = i * 2;
1374 - u16 mask = IEEE80211_VHT_MCS_NOT_SUPPORTED << shift;
1375 - u16 ap_mcs, our_mcs;
1377 - ap_mcs = (le16_to_cpu(ap_vht_cap->supp_mcs.tx_mcs_map) &
1379 - our_mcs = (le16_to_cpu(vht_cap.vht_mcs.rx_mcs_map) &
1382 - if (our_mcs == IEEE80211_VHT_MCS_NOT_SUPPORTED)
1387 - if (our_mcs <= ap_mcs)
1389 - /* fall through */
1390 - case IEEE80211_VHT_MCS_NOT_SUPPORTED:
1391 - vht_cap.vht_mcs.rx_mcs_map &= cpu_to_le16(~mask);
1392 - vht_cap.vht_mcs.rx_mcs_map |=
1393 - cpu_to_le16(ap_mcs << shift);
1397 /* reserve and fill IE */
1398 pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2);
1399 ieee80211_ie_build_vht_cap(pos, &vht_cap, cap);
1400 @@ -998,16 +966,7 @@ static void ieee80211_chswitch_work(stru
1401 if (!ifmgd->associated)
1405 - * FIXME: Here we are downgrading to NL80211_CHAN_WIDTH_20_NOHT
1406 - * and don't adjust our ht/vht settings
1407 - * This is wrong - we should behave according to the CSA params
1409 - local->_oper_chandef.chan = local->csa_channel;
1410 - local->_oper_chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
1411 - local->_oper_chandef.center_freq1 =
1412 - local->_oper_chandef.chan->center_freq;
1413 - local->_oper_chandef.center_freq2 = 0;
1414 + local->_oper_chandef = local->csa_chandef;
1416 if (!local->ops->channel_switch) {
1417 /* call "hw_config" only if doing sw channel switch */
1418 @@ -1054,56 +1013,193 @@ static void ieee80211_chswitch_timer(uns
1419 ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work);
1424 ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1425 - const struct ieee80211_channel_sw_ie *sw_elem,
1426 - struct ieee80211_bss *bss, u64 timestamp)
1427 + u64 timestamp, struct ieee802_11_elems *elems)
1429 - struct cfg80211_bss *cbss =
1430 - container_of((void *)bss, struct cfg80211_bss, priv);
1431 - struct ieee80211_channel *new_ch;
1432 + struct ieee80211_local *local = sdata->local;
1433 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1434 - int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num,
1435 - cbss->channel->band);
1436 + struct cfg80211_bss *cbss = ifmgd->associated;
1437 + struct ieee80211_bss *bss;
1438 struct ieee80211_chanctx *chanctx;
1439 + enum ieee80211_band new_band;
1444 + struct ieee80211_channel *new_chan;
1445 + struct cfg80211_chan_def new_chandef = {};
1446 + struct cfg80211_chan_def new_vht_chandef = {};
1447 + const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
1448 + const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
1449 + int secondary_channel_offset = -1;
1451 ASSERT_MGD_MTX(ifmgd);
1453 - if (!ifmgd->associated)
1457 - if (sdata->local->scanning)
1458 + if (local->scanning)
1461 - /* Disregard subsequent beacons if we are already running a timer
1462 - processing a CSA */
1464 + /* disregard subsequent announcements if we are already processing */
1465 if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED)
1468 - new_ch = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
1469 - if (!new_ch || new_ch->flags & IEEE80211_CHAN_DISABLED) {
1470 + sec_chan_offs = elems->sec_chan_offs;
1471 + wide_bw_chansw_ie = elems->wide_bw_chansw_ie;
1473 + if (ifmgd->flags & (IEEE80211_STA_DISABLE_HT |
1474 + IEEE80211_STA_DISABLE_40MHZ)) {
1475 + sec_chan_offs = NULL;
1476 + wide_bw_chansw_ie = NULL;
1479 + if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT)
1480 + wide_bw_chansw_ie = NULL;
1482 + if (elems->ext_chansw_ie) {
1483 + if (!ieee80211_operating_class_to_band(
1484 + elems->ext_chansw_ie->new_operating_class,
1487 + "cannot understand ECSA IE operating class %d, disconnecting\n",
1488 + elems->ext_chansw_ie->new_operating_class);
1489 + ieee80211_queue_work(&local->hw,
1490 + &ifmgd->csa_connection_drop_work);
1492 + new_chan_no = elems->ext_chansw_ie->new_ch_num;
1493 + count = elems->ext_chansw_ie->count;
1494 + mode = elems->ext_chansw_ie->mode;
1495 + } else if (elems->ch_switch_ie) {
1496 + new_band = cbss->channel->band;
1497 + new_chan_no = elems->ch_switch_ie->new_ch_num;
1498 + count = elems->ch_switch_ie->count;
1499 + mode = elems->ch_switch_ie->mode;
1501 + /* nothing here we understand */
1505 + bss = (void *)cbss->priv;
1507 + new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band);
1508 + new_chan = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
1509 + if (!new_chan || new_chan->flags & IEEE80211_CHAN_DISABLED) {
1511 "AP %pM switches to unsupported channel (%d MHz), disconnecting\n",
1512 ifmgd->associated->bssid, new_freq);
1513 - ieee80211_queue_work(&sdata->local->hw,
1514 + ieee80211_queue_work(&local->hw,
1515 + &ifmgd->csa_connection_drop_work);
1519 + if (sec_chan_offs) {
1520 + secondary_channel_offset = sec_chan_offs->sec_chan_offs;
1521 + } else if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
1522 + /* if HT is enabled and the IE not present, it's still HT */
1523 + secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
1526 + switch (secondary_channel_offset) {
1528 + /* secondary_channel_offset was present but is invalid */
1529 + case IEEE80211_HT_PARAM_CHA_SEC_NONE:
1530 + cfg80211_chandef_create(&new_chandef, new_chan,
1531 + NL80211_CHAN_HT20);
1533 + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
1534 + cfg80211_chandef_create(&new_chandef, new_chan,
1535 + NL80211_CHAN_HT40PLUS);
1537 + case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
1538 + cfg80211_chandef_create(&new_chandef, new_chan,
1539 + NL80211_CHAN_HT40MINUS);
1542 + cfg80211_chandef_create(&new_chandef, new_chan,
1543 + NL80211_CHAN_NO_HT);
1547 + if (wide_bw_chansw_ie) {
1548 + new_vht_chandef.chan = new_chan;
1549 + new_vht_chandef.center_freq1 =
1550 + ieee80211_channel_to_frequency(
1551 + wide_bw_chansw_ie->new_center_freq_seg0,
1554 + switch (wide_bw_chansw_ie->new_channel_width) {
1556 + /* hmmm, ignore VHT and use HT if present */
1557 + case IEEE80211_VHT_CHANWIDTH_USE_HT:
1558 + new_vht_chandef.chan = NULL;
1560 + case IEEE80211_VHT_CHANWIDTH_80MHZ:
1561 + new_vht_chandef.width = NL80211_CHAN_WIDTH_80;
1563 + case IEEE80211_VHT_CHANWIDTH_160MHZ:
1564 + new_vht_chandef.width = NL80211_CHAN_WIDTH_160;
1566 + case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
1567 + /* field is otherwise reserved */
1568 + new_vht_chandef.center_freq2 =
1569 + ieee80211_channel_to_frequency(
1570 + wide_bw_chansw_ie->new_center_freq_seg1,
1572 + new_vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
1575 + if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ &&
1576 + new_vht_chandef.width == NL80211_CHAN_WIDTH_80P80)
1577 + chandef_downgrade(&new_vht_chandef);
1578 + if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ &&
1579 + new_vht_chandef.width == NL80211_CHAN_WIDTH_160)
1580 + chandef_downgrade(&new_vht_chandef);
1581 + if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ &&
1582 + new_vht_chandef.width > NL80211_CHAN_WIDTH_20)
1583 + chandef_downgrade(&new_vht_chandef);
1586 + /* if VHT data is there validate & use it */
1587 + if (new_vht_chandef.chan) {
1588 + if (!cfg80211_chandef_compatible(&new_vht_chandef,
1591 + "AP %pM CSA has inconsistent channel data, disconnecting\n",
1592 + ifmgd->associated->bssid);
1593 + ieee80211_queue_work(&local->hw,
1594 + &ifmgd->csa_connection_drop_work);
1597 + new_chandef = new_vht_chandef;
1600 + if (!cfg80211_chandef_usable(local->hw.wiphy, &new_chandef,
1601 + IEEE80211_CHAN_DISABLED)) {
1603 + "AP %pM switches to unsupported channel (%d MHz, width:%d, CF1/2: %d/%d MHz), disconnecting\n",
1604 + ifmgd->associated->bssid, new_freq,
1605 + new_chandef.width, new_chandef.center_freq1,
1606 + new_chandef.center_freq2);
1607 + ieee80211_queue_work(&local->hw,
1608 &ifmgd->csa_connection_drop_work);
1612 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
1614 - if (sdata->local->use_chanctx) {
1615 + if (local->use_chanctx) {
1617 "not handling channel switch with channel contexts\n");
1618 - ieee80211_queue_work(&sdata->local->hw,
1619 + ieee80211_queue_work(&local->hw,
1620 &ifmgd->csa_connection_drop_work);
1624 - mutex_lock(&sdata->local->chanctx_mtx);
1625 + mutex_lock(&local->chanctx_mtx);
1626 if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) {
1627 - mutex_unlock(&sdata->local->chanctx_mtx);
1628 + mutex_unlock(&local->chanctx_mtx);
1631 chanctx = container_of(rcu_access_pointer(sdata->vif.chanctx_conf),
1632 @@ -1111,40 +1207,39 @@ ieee80211_sta_process_chanswitch(struct
1633 if (chanctx->refcount > 1) {
1635 "channel switch with multiple interfaces on the same channel, disconnecting\n");
1636 - ieee80211_queue_work(&sdata->local->hw,
1637 + ieee80211_queue_work(&local->hw,
1638 &ifmgd->csa_connection_drop_work);
1639 - mutex_unlock(&sdata->local->chanctx_mtx);
1640 + mutex_unlock(&local->chanctx_mtx);
1643 - mutex_unlock(&sdata->local->chanctx_mtx);
1644 + mutex_unlock(&local->chanctx_mtx);
1646 - sdata->local->csa_channel = new_ch;
1647 + local->csa_chandef = new_chandef;
1649 - if (sw_elem->mode)
1650 - ieee80211_stop_queues_by_reason(&sdata->local->hw,
1652 + ieee80211_stop_queues_by_reason(&local->hw,
1653 IEEE80211_MAX_QUEUE_MAP,
1654 IEEE80211_QUEUE_STOP_REASON_CSA);
1656 - if (sdata->local->ops->channel_switch) {
1657 + if (local->ops->channel_switch) {
1658 /* use driver's channel switch callback */
1659 struct ieee80211_channel_switch ch_switch = {
1660 .timestamp = timestamp,
1661 - .block_tx = sw_elem->mode,
1662 - .channel = new_ch,
1663 - .count = sw_elem->count,
1665 + .chandef = new_chandef,
1669 - drv_channel_switch(sdata->local, &ch_switch);
1670 + drv_channel_switch(local, &ch_switch);
1674 /* channel switch handled in software */
1675 - if (sw_elem->count <= 1)
1676 - ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
1678 + ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work);
1680 mod_timer(&ifmgd->chswitch_timer,
1681 - TU_TO_EXP_TIME(sw_elem->count *
1682 - cbss->beacon_interval));
1683 + TU_TO_EXP_TIME(count * cbss->beacon_interval));
1686 static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
1687 @@ -2120,7 +2215,6 @@ void ieee80211_beacon_loss(struct ieee80
1689 trace_api_beacon_loss(sdata);
1691 - WARN_ON(hw->flags & IEEE80211_HW_CONNECTION_MONITOR);
1692 sdata->u.mgd.connection_loss = false;
1693 ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work);
1695 @@ -2170,7 +2264,7 @@ static void ieee80211_auth_challenge(str
1698 pos = mgmt->u.auth.variable;
1699 - ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
1700 + ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
1701 if (!elems.challenge)
1703 auth_data->expected_transaction = 4;
1704 @@ -2435,7 +2529,7 @@ static bool ieee80211_assoc_success(stru
1707 pos = mgmt->u.assoc_resp.variable;
1708 - ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
1709 + ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
1711 if (!elems.supp_rates) {
1712 sdata_info(sdata, "no SuppRates element in AssocResp\n");
1713 @@ -2604,7 +2698,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee
1714 capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14))));
1716 pos = mgmt->u.assoc_resp.variable;
1717 - ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
1718 + ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
1720 if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
1721 elems.timeout_int &&
1722 @@ -2659,6 +2753,8 @@ static void ieee80211_rx_bss_info(struct
1723 struct ieee80211_channel *channel;
1724 bool need_ps = false;
1726 + lockdep_assert_held(&sdata->u.mgd.mtx);
1728 if ((sdata->u.mgd.associated &&
1729 ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) ||
1730 (sdata->u.mgd.assoc_data &&
1731 @@ -2689,7 +2785,8 @@ static void ieee80211_rx_bss_info(struct
1733 ieee80211_rx_bss_put(local, bss);
1735 - if (!sdata->u.mgd.associated)
1736 + if (!sdata->u.mgd.associated ||
1737 + !ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid))
1741 @@ -2698,10 +2795,8 @@ static void ieee80211_rx_bss_info(struct
1742 mutex_unlock(&local->iflist_mtx);
1745 - if (elems->ch_switch_ie &&
1746 - memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, ETH_ALEN) == 0)
1747 - ieee80211_sta_process_chanswitch(sdata, elems->ch_switch_ie,
1748 - bss, rx_status->mactime);
1749 + ieee80211_sta_process_chanswitch(sdata, rx_status->mactime, elems);
1754 @@ -2726,7 +2821,7 @@ static void ieee80211_rx_mgmt_probe_resp
1757 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
1761 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
1763 @@ -2809,7 +2904,7 @@ ieee80211_rx_mgmt_beacon(struct ieee8021
1764 if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon &&
1765 ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) {
1766 ieee802_11_parse_elems(mgmt->u.beacon.variable,
1767 - len - baselen, &elems);
1768 + len - baselen, false, &elems);
1770 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
1771 ifmgd->assoc_data->have_beacon = true;
1772 @@ -2919,7 +3014,7 @@ ieee80211_rx_mgmt_beacon(struct ieee8021
1774 ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4);
1775 ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable,
1776 - len - baselen, &elems,
1777 + len - baselen, false, &elems,
1778 care_about_ies, ncrc);
1780 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) {
1781 @@ -3066,6 +3161,8 @@ void ieee80211_sta_rx_queued_mgmt(struct
1782 enum rx_mgmt_action rma = RX_MGMT_NONE;
1783 u8 deauth_buf[IEEE80211_DEAUTH_FRAME_LEN];
1785 + struct ieee802_11_elems elems;
1788 rx_status = (struct ieee80211_rx_status *) skb->cb;
1789 mgmt = (struct ieee80211_mgmt *) skb->data;
1790 @@ -3095,14 +3192,48 @@ void ieee80211_sta_rx_queued_mgmt(struct
1791 rma = ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, &bss);
1793 case IEEE80211_STYPE_ACTION:
1794 - switch (mgmt->u.action.category) {
1795 - case WLAN_CATEGORY_SPECTRUM_MGMT:
1796 + if (mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) {
1797 + ies_len = skb->len -
1798 + offsetof(struct ieee80211_mgmt,
1799 + u.action.u.chan_switch.variable);
1804 + ieee802_11_parse_elems(
1805 + mgmt->u.action.u.chan_switch.variable,
1806 + ies_len, true, &elems);
1808 + if (elems.parse_error)
1811 ieee80211_sta_process_chanswitch(sdata,
1812 - &mgmt->u.action.u.chan_switch.sw_elem,
1813 - (void *)ifmgd->associated->priv,
1814 - rx_status->mactime);
1816 + rx_status->mactime,
1818 + } else if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) {
1819 + ies_len = skb->len -
1820 + offsetof(struct ieee80211_mgmt,
1821 + u.action.u.ext_chan_switch.variable);
1826 + ieee802_11_parse_elems(
1827 + mgmt->u.action.u.ext_chan_switch.variable,
1828 + ies_len, true, &elems);
1830 + if (elems.parse_error)
1833 + /* for the handling code pretend this was also an IE */
1834 + elems.ext_chansw_ie =
1835 + &mgmt->u.action.u.ext_chan_switch.data;
1837 + ieee80211_sta_process_chanswitch(sdata,
1838 + rx_status->mactime,
1843 mutex_unlock(&ifmgd->mtx);
1845 --- a/net/mac80211/pm.c
1846 +++ b/net/mac80211/pm.c
1847 @@ -38,8 +38,8 @@ int __ieee80211_suspend(struct ieee80211
1848 IEEE80211_MAX_QUEUE_MAP,
1849 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
1851 - /* flush out all packets */
1852 - synchronize_net();
1853 + /* flush out all packets and station cleanup call_rcu()s */
1856 ieee80211_flush_queues(local, NULL);
1858 --- a/net/mac80211/rate.c
1859 +++ b/net/mac80211/rate.c
1860 @@ -252,6 +252,25 @@ rate_lowest_non_cck_index(struct ieee802
1864 +static void __rate_control_send_low(struct ieee80211_hw *hw,
1865 + struct ieee80211_supported_band *sband,
1866 + struct ieee80211_sta *sta,
1867 + struct ieee80211_tx_info *info)
1869 + if ((sband->band != IEEE80211_BAND_2GHZ) ||
1870 + !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
1871 + info->control.rates[0].idx = rate_lowest_index(sband, sta);
1873 + info->control.rates[0].idx =
1874 + rate_lowest_non_cck_index(sband, sta);
1876 + info->control.rates[0].count =
1877 + (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
1878 + 1 : hw->max_rate_tries;
1880 + info->control.skip_table = 1;
1884 bool rate_control_send_low(struct ieee80211_sta *sta,
1886 @@ -262,16 +281,8 @@ bool rate_control_send_low(struct ieee80
1889 if (!sta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
1890 - if ((sband->band != IEEE80211_BAND_2GHZ) ||
1891 - !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
1892 - info->control.rates[0].idx =
1893 - rate_lowest_index(txrc->sband, sta);
1895 - info->control.rates[0].idx =
1896 - rate_lowest_non_cck_index(txrc->sband, sta);
1897 - info->control.rates[0].count =
1898 - (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
1899 - 1 : txrc->hw->max_rate_tries;
1900 + __rate_control_send_low(txrc->hw, sband, sta, info);
1902 if (!sta && txrc->bss) {
1903 mcast_rate = txrc->bss_conf->mcast_rate[sband->band];
1904 if (mcast_rate > 0) {
1905 @@ -355,7 +366,8 @@ static bool rate_idx_match_mcs_mask(stru
1908 static void rate_idx_match_mask(struct ieee80211_tx_rate *rate,
1909 - struct ieee80211_tx_rate_control *txrc,
1910 + struct ieee80211_supported_band *sband,
1911 + enum nl80211_chan_width chan_width,
1913 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN])
1915 @@ -375,27 +387,17 @@ static void rate_idx_match_mask(struct i
1916 IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
1917 alt_rate.count = rate->count;
1918 if (rate_idx_match_legacy_mask(&alt_rate,
1919 - txrc->sband->n_bitrates,
1921 + sband->n_bitrates, mask)) {
1926 - struct sk_buff *skb = txrc->skb;
1927 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1930 /* handle legacy rates */
1931 - if (rate_idx_match_legacy_mask(rate, txrc->sband->n_bitrates,
1933 + if (rate_idx_match_legacy_mask(rate, sband->n_bitrates, mask))
1936 /* if HT BSS, and we handle a data frame, also try HT rates */
1937 - if (txrc->bss_conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
1940 - fc = hdr->frame_control;
1941 - if (!ieee80211_is_data(fc))
1942 + if (chan_width == NL80211_CHAN_WIDTH_20_NOHT)
1946 @@ -408,7 +410,7 @@ static void rate_idx_match_mask(struct i
1948 alt_rate.flags |= IEEE80211_TX_RC_MCS;
1950 - if (txrc->bss_conf->chandef.width == NL80211_CHAN_WIDTH_40)
1951 + if (chan_width == NL80211_CHAN_WIDTH_40)
1952 alt_rate.flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
1954 if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) {
1955 @@ -426,6 +428,228 @@ static void rate_idx_match_mask(struct i
1959 +static void rate_fixup_ratelist(struct ieee80211_vif *vif,
1960 + struct ieee80211_supported_band *sband,
1961 + struct ieee80211_tx_info *info,
1962 + struct ieee80211_tx_rate *rates,
1965 + struct ieee80211_rate *rate;
1966 + bool inval = false;
1970 + * Set up the RTS/CTS rate as the fastest basic rate
1971 + * that is not faster than the data rate unless there
1972 + * is no basic rate slower than the data rate, in which
1973 + * case we pick the slowest basic rate
1975 + * XXX: Should this check all retry rates?
1977 + if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
1978 + u32 basic_rates = vif->bss_conf.basic_rates;
1979 + s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0;
1981 + rate = &sband->bitrates[rates[0].idx];
1983 + for (i = 0; i < sband->n_bitrates; i++) {
1984 + /* must be a basic rate */
1985 + if (!(basic_rates & BIT(i)))
1987 + /* must not be faster than the data rate */
1988 + if (sband->bitrates[i].bitrate > rate->bitrate)
1991 + if (sband->bitrates[baserate].bitrate <
1992 + sband->bitrates[i].bitrate)
1996 + info->control.rts_cts_rate_idx = baserate;
1999 + for (i = 0; i < max_rates; i++) {
2001 + * make sure there's no valid rate following
2002 + * an invalid one, just in case drivers don't
2003 + * take the API seriously to stop at -1.
2006 + rates[i].idx = -1;
2009 + if (rates[i].idx < 0) {
2015 + * For now assume MCS is already set up correctly, this
2016 + * needs to be fixed.
2018 + if (rates[i].flags & IEEE80211_TX_RC_MCS) {
2019 + WARN_ON(rates[i].idx > 76);
2021 + if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
2022 + info->control.use_cts_prot)
2024 + IEEE80211_TX_RC_USE_CTS_PROTECT;
2028 + if (rates[i].flags & IEEE80211_TX_RC_VHT_MCS) {
2029 + WARN_ON(ieee80211_rate_get_vht_mcs(&rates[i]) > 9);
2033 + /* set up RTS protection if desired */
2034 + if (info->control.use_rts) {
2035 + rates[i].flags |= IEEE80211_TX_RC_USE_RTS_CTS;
2036 + info->control.use_cts_prot = false;
2039 + /* RC is busted */
2040 + if (WARN_ON_ONCE(rates[i].idx >= sband->n_bitrates)) {
2041 + rates[i].idx = -1;
2045 + rate = &sband->bitrates[rates[i].idx];
2047 + /* set up short preamble */
2048 + if (info->control.short_preamble &&
2049 + rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
2050 + rates[i].flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
2052 + /* set up G protection */
2053 + if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
2054 + info->control.use_cts_prot &&
2055 + rate->flags & IEEE80211_RATE_ERP_G)
2056 + rates[i].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT;
2061 +static void rate_control_fill_sta_table(struct ieee80211_sta *sta,
2062 + struct ieee80211_tx_info *info,
2063 + struct ieee80211_tx_rate *rates,
2066 + struct ieee80211_sta_rates *ratetbl = NULL;
2069 + if (sta && !info->control.skip_table)
2070 + ratetbl = rcu_dereference(sta->rates);
2072 + /* Fill remaining rate slots with data from the sta rate table. */
2073 + max_rates = min_t(int, max_rates, IEEE80211_TX_RATE_TABLE_SIZE);
2074 + for (i = 0; i < max_rates; i++) {
2075 + if (i < ARRAY_SIZE(info->control.rates) &&
2076 + info->control.rates[i].idx >= 0 &&
2077 + info->control.rates[i].count) {
2078 + if (rates != info->control.rates)
2079 + rates[i] = info->control.rates[i];
2080 + } else if (ratetbl) {
2081 + rates[i].idx = ratetbl->rate[i].idx;
2082 + rates[i].flags = ratetbl->rate[i].flags;
2083 + if (info->control.use_rts)
2084 + rates[i].count = ratetbl->rate[i].count_rts;
2085 + else if (info->control.use_cts_prot)
2086 + rates[i].count = ratetbl->rate[i].count_cts;
2088 + rates[i].count = ratetbl->rate[i].count;
2090 + rates[i].idx = -1;
2091 + rates[i].count = 0;
2094 + if (rates[i].idx < 0 || !rates[i].count)
2099 +static void rate_control_apply_mask(struct ieee80211_sub_if_data *sdata,
2100 + struct ieee80211_sta *sta,
2101 + struct ieee80211_supported_band *sband,
2102 + struct ieee80211_tx_info *info,
2103 + struct ieee80211_tx_rate *rates,
2106 + enum nl80211_chan_width chan_width;
2107 + u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
2108 + bool has_mcs_mask;
2113 + * Try to enforce the rateidx mask the user wanted. skip this if the
2114 + * default mask (allow all rates) is used to save some processing for
2115 + * the common case.
2117 + mask = sdata->rc_rateidx_mask[info->band];
2118 + has_mcs_mask = sdata->rc_has_mcs_mask[info->band];
2119 + if (mask == (1 << sband->n_bitrates) - 1 && !has_mcs_mask)
2123 + memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
2124 + sizeof(mcs_mask));
2126 + memset(mcs_mask, 0xff, sizeof(mcs_mask));
2129 + /* Filter out rates that the STA does not support */
2130 + mask &= sta->supp_rates[info->band];
2131 + for (i = 0; i < sizeof(mcs_mask); i++)
2132 + mcs_mask[i] &= sta->ht_cap.mcs.rx_mask[i];
2136 + * Make sure the rate index selected for each TX rate is
2137 + * included in the configured mask and change the rate indexes
2140 + chan_width = sdata->vif.bss_conf.chandef.width;
2141 + for (i = 0; i < max_rates; i++) {
2142 + /* Skip invalid rates */
2143 + if (rates[i].idx < 0)
2146 + rate_idx_match_mask(&rates[i], sband, mask, chan_width,
2151 +void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
2152 + struct ieee80211_sta *sta,
2153 + struct sk_buff *skb,
2154 + struct ieee80211_tx_rate *dest,
2157 + struct ieee80211_sub_if_data *sdata;
2158 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
2159 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2160 + struct ieee80211_supported_band *sband;
2162 + rate_control_fill_sta_table(sta, info, dest, max_rates);
2167 + sdata = vif_to_sdata(vif);
2168 + sband = sdata->local->hw.wiphy->bands[info->band];
2170 + if (ieee80211_is_data(hdr->frame_control))
2171 + rate_control_apply_mask(sdata, sta, sband, info, dest, max_rates);
2173 + if (dest[0].idx < 0)
2174 + __rate_control_send_low(&sdata->local->hw, sband, sta, info);
2177 + rate_fixup_ratelist(vif, sband, info, dest, max_rates);
2179 +EXPORT_SYMBOL(ieee80211_get_tx_rates);
2181 void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
2182 struct sta_info *sta,
2183 struct ieee80211_tx_rate_control *txrc)
2184 @@ -435,8 +659,6 @@ void rate_control_get_rate(struct ieee80
2185 struct ieee80211_sta *ista = NULL;
2186 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
2189 - u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
2191 if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
2193 @@ -454,37 +676,27 @@ void rate_control_get_rate(struct ieee80
2195 ref->ops->get_rate(ref->priv, ista, priv_sta, txrc);
2198 - * Try to enforce the rateidx mask the user wanted. skip this if the
2199 - * default mask (allow all rates) is used to save some processing for
2200 - * the common case.
2202 - mask = sdata->rc_rateidx_mask[info->band];
2203 - memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
2204 - sizeof(mcs_mask));
2205 - if (mask != (1 << txrc->sband->n_bitrates) - 1) {
2207 - /* Filter out rates that the STA does not support */
2208 - mask &= sta->sta.supp_rates[info->band];
2209 - for (i = 0; i < sizeof(mcs_mask); i++)
2210 - mcs_mask[i] &= sta->sta.ht_cap.mcs.rx_mask[i];
2213 - * Make sure the rate index selected for each TX rate is
2214 - * included in the configured mask and change the rate indexes
2217 - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
2218 - /* Skip invalid rates */
2219 - if (info->control.rates[i].idx < 0)
2221 - rate_idx_match_mask(&info->control.rates[i], txrc,
2225 + if (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_RC_TABLE)
2228 - BUG_ON(info->control.rates[0].idx < 0);
2229 + ieee80211_get_tx_rates(&sdata->vif, ista, txrc->skb,
2230 + info->control.rates,
2231 + ARRAY_SIZE(info->control.rates));
2234 +int rate_control_set_rates(struct ieee80211_hw *hw,
2235 + struct ieee80211_sta *pubsta,
2236 + struct ieee80211_sta_rates *rates)
2238 + struct ieee80211_sta_rates *old = rcu_dereference(pubsta->rates);
2240 + rcu_assign_pointer(pubsta->rates, rates);
2242 + kfree_rcu(old, rcu_head);
2246 +EXPORT_SYMBOL(rate_control_set_rates);
2248 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
2250 --- a/net/mac80211/rc80211_minstrel.c
2251 +++ b/net/mac80211/rc80211_minstrel.c
2252 @@ -84,6 +84,50 @@ minstrel_sort_best_tp_rates(struct minst
2256 +minstrel_set_rate(struct minstrel_sta_info *mi, struct ieee80211_sta_rates *ratetbl,
2257 + int offset, int idx)
2259 + struct minstrel_rate *r = &mi->r[idx];
2261 + ratetbl->rate[offset].idx = r->rix;
2262 + ratetbl->rate[offset].count = r->adjusted_retry_count;
2263 + ratetbl->rate[offset].count_cts = r->retry_count_cts;
2264 + ratetbl->rate[offset].count_rts = r->retry_count_rtscts;
2268 +minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
2270 + struct ieee80211_sta_rates *ratetbl;
2273 + ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC);
2277 + /* Start with max_tp_rate */
2278 + minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[0]);
2280 + if (mp->hw->max_rates >= 3) {
2281 + /* At least 3 tx rates supported, use max_tp_rate2 next */
2282 + minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[1]);
2285 + if (mp->hw->max_rates >= 2) {
2286 + /* At least 2 tx rates supported, use max_prob_rate next */
2287 + minstrel_set_rate(mi, ratetbl, i++, mi->max_prob_rate);
2290 + /* Use lowest rate last */
2291 + ratetbl->rate[i].idx = mi->lowest_rix;
2292 + ratetbl->rate[i].count = mp->max_retry;
2293 + ratetbl->rate[i].count_cts = mp->max_retry;
2294 + ratetbl->rate[i].count_rts = mp->max_retry;
2296 + rate_control_set_rates(mp->hw, mi->sta, ratetbl);
2300 minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
2302 u8 tmp_tp_rate[MAX_THR_RATES];
2303 @@ -161,6 +205,8 @@ minstrel_update_stats(struct minstrel_pr
2305 /* Reset update timer */
2306 mi->stats_update = jiffies;
2308 + minstrel_update_rates(mp, mi);
2312 @@ -209,9 +255,9 @@ minstrel_get_retry_count(struct minstrel
2314 unsigned int retry = mr->adjusted_retry_count;
2316 - if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
2317 + if (info->control.use_rts)
2318 retry = max(2U, min(mr->retry_count_rtscts, retry));
2319 - else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
2320 + else if (info->control.use_cts_prot)
2321 retry = max(2U, min(mr->retry_count_cts, retry));
2324 @@ -240,13 +286,12 @@ minstrel_get_rate(void *priv, struct iee
2325 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2326 struct minstrel_sta_info *mi = priv_sta;
2327 struct minstrel_priv *mp = priv;
2328 - struct ieee80211_tx_rate *ar = info->control.rates;
2329 - unsigned int ndx, sample_ndx = 0;
2330 + struct ieee80211_tx_rate *rate = &info->control.rates[0];
2331 + struct minstrel_rate *msr, *mr;
2334 - bool indirect_rate_sampling = false;
2335 - bool rate_sampling = false;
2338 + bool prev_sample = mi->prev_sample;
2342 /* management/no-ack frames do not use rate control */
2343 @@ -262,107 +307,75 @@ minstrel_get_rate(void *priv, struct iee
2345 sampling_ratio = mp->lookaround_rate;
2347 - /* init rateindex [ndx] with max throughput rate */
2348 - ndx = mi->max_tp_rate[0];
2350 /* increase sum packet counter */
2353 delta = (mi->packet_count * sampling_ratio / 100) -
2354 (mi->sample_count + mi->sample_deferred / 2);
2356 - /* delta > 0: sampling required */
2357 - if ((delta > 0) && (mrr_capable || !mi->prev_sample)) {
2358 - struct minstrel_rate *msr;
2359 - if (mi->packet_count >= 10000) {
2360 - mi->sample_deferred = 0;
2361 - mi->sample_count = 0;
2362 - mi->packet_count = 0;
2363 - } else if (delta > mi->n_rates * 2) {
2364 - /* With multi-rate retry, not every planned sample
2365 - * attempt actually gets used, due to the way the retry
2366 - * chain is set up - [max_tp,sample,prob,lowest] for
2367 - * sample_rate < max_tp.
2369 - * If there's too much sampling backlog and the link
2370 - * starts getting worse, minstrel would start bursting
2371 - * out lots of sampling frames, which would result
2372 - * in a large throughput loss. */
2373 - mi->sample_count += (delta - mi->n_rates * 2);
2375 + /* delta < 0: no sampling required */
2376 + mi->prev_sample = false;
2377 + if (delta < 0 || (!mrr_capable && prev_sample))
2380 - /* get next random rate sample */
2381 - sample_ndx = minstrel_get_next_sample(mi);
2382 - msr = &mi->r[sample_ndx];
2383 - rate_sampling = true;
2385 - /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage)
2386 - * rate sampling method should be used.
2387 - * Respect such rates that are not sampled for 20 interations.
2389 - if (mrr_capable &&
2390 - msr->perfect_tx_time > mi->r[ndx].perfect_tx_time &&
2391 - msr->sample_skipped < 20)
2392 - indirect_rate_sampling = true;
2394 - if (!indirect_rate_sampling) {
2395 - if (msr->sample_limit != 0) {
2397 - mi->sample_count++;
2398 - if (msr->sample_limit > 0)
2399 - msr->sample_limit--;
2401 - rate_sampling = false;
2403 - /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark
2404 - * packets that have the sampling rate deferred to the
2405 - * second MRR stage. Increase the sample counter only
2406 - * if the deferred sample rate was actually used.
2407 - * Use the sample_deferred counter to make sure that
2408 - * the sampling is not done in large bursts */
2409 - info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
2410 - mi->sample_deferred++;
2412 + if (mi->packet_count >= 10000) {
2413 + mi->sample_deferred = 0;
2414 + mi->sample_count = 0;
2415 + mi->packet_count = 0;
2416 + } else if (delta > mi->n_rates * 2) {
2417 + /* With multi-rate retry, not every planned sample
2418 + * attempt actually gets used, due to the way the retry
2419 + * chain is set up - [max_tp,sample,prob,lowest] for
2420 + * sample_rate < max_tp.
2422 + * If there's too much sampling backlog and the link
2423 + * starts getting worse, minstrel would start bursting
2424 + * out lots of sampling frames, which would result
2425 + * in a large throughput loss. */
2426 + mi->sample_count += (delta - mi->n_rates * 2);
2429 + /* get next random rate sample */
2430 + ndx = minstrel_get_next_sample(mi);
2431 + msr = &mi->r[ndx];
2432 + mr = &mi->r[mi->max_tp_rate[0]];
2434 + /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage)
2435 + * rate sampling method should be used.
2436 + * Respect such rates that are not sampled for 20 interations.
2438 + if (mrr_capable &&
2439 + msr->perfect_tx_time > mr->perfect_tx_time &&
2440 + msr->sample_skipped < 20) {
2441 + /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark
2442 + * packets that have the sampling rate deferred to the
2443 + * second MRR stage. Increase the sample counter only
2444 + * if the deferred sample rate was actually used.
2445 + * Use the sample_deferred counter to make sure that
2446 + * the sampling is not done in large bursts */
2447 + info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
2449 + mi->sample_deferred++;
2451 + if (!msr->sample_limit != 0)
2454 + mi->sample_count++;
2455 + if (msr->sample_limit > 0)
2456 + msr->sample_limit--;
2458 - mi->prev_sample = rate_sampling;
2460 /* If we're not using MRR and the sampling rate already
2461 * has a probability of >95%, we shouldn't be attempting
2462 * to use it, as this only wastes precious airtime */
2463 - if (!mrr_capable && rate_sampling &&
2464 + if (!mrr_capable &&
2465 (mi->r[ndx].probability > MINSTREL_FRAC(95, 100)))
2466 - ndx = mi->max_tp_rate[0];
2468 - /* mrr setup for 1st stage */
2469 - ar[0].idx = mi->r[ndx].rix;
2470 - ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info);
2472 - /* non mrr setup for 2nd stage */
2473 - if (!mrr_capable) {
2474 - if (!rate_sampling)
2475 - ar[0].count = mp->max_retry;
2476 - ar[1].idx = mi->lowest_rix;
2477 - ar[1].count = mp->max_retry;
2481 - /* mrr setup for 2nd stage */
2482 - if (rate_sampling) {
2483 - if (indirect_rate_sampling)
2484 - mrr_ndx[0] = sample_ndx;
2486 - mrr_ndx[0] = mi->max_tp_rate[0];
2488 - mrr_ndx[0] = mi->max_tp_rate[1];
2490 + mi->prev_sample = true;
2492 - /* mrr setup for 3rd & 4th stage */
2493 - mrr_ndx[1] = mi->max_prob_rate;
2495 - for (i = 1; i < 4; i++) {
2496 - ar[i].idx = mi->r[mrr_ndx[i - 1]].rix;
2497 - ar[i].count = mi->r[mrr_ndx[i - 1]].adjusted_retry_count;
2499 + rate->idx = mi->r[ndx].rix;
2500 + rate->count = minstrel_get_retry_count(&mi->r[ndx], info);
2504 @@ -412,12 +425,16 @@ minstrel_rate_init(void *priv, struct ie
2505 unsigned int i, n = 0;
2506 unsigned int t_slot = 9; /* FIXME: get real slot time */
2509 mi->lowest_rix = rate_lowest_index(sband, sta);
2510 ctl_rate = &sband->bitrates[mi->lowest_rix];
2511 mi->sp_ack_dur = ieee80211_frame_duration(sband->band, 10,
2513 !!(ctl_rate->flags & IEEE80211_RATE_ERP_G), 1);
2515 + memset(mi->max_tp_rate, 0, sizeof(mi->max_tp_rate));
2516 + mi->max_prob_rate = 0;
2518 for (i = 0; i < sband->n_bitrates; i++) {
2519 struct minstrel_rate *mr = &mi->r[n];
2520 unsigned int tx_time = 0, tx_time_cts = 0, tx_time_rtscts = 0;
2521 @@ -460,6 +477,8 @@ minstrel_rate_init(void *priv, struct ie
2522 } while ((tx_time < mp->segment_size) &&
2523 (++mr->retry_count < mp->max_retry));
2524 mr->adjusted_retry_count = mr->retry_count;
2525 + if (!(sband->bitrates[i].flags & IEEE80211_RATE_ERP_G))
2526 + mr->retry_count_cts = mr->retry_count;
2529 for (i = n; i < sband->n_bitrates; i++) {
2530 @@ -471,6 +490,7 @@ minstrel_rate_init(void *priv, struct ie
2531 mi->stats_update = jiffies;
2533 init_sample_table(mi);
2534 + minstrel_update_rates(mp, mi);
2538 --- a/net/mac80211/rc80211_minstrel.h
2539 +++ b/net/mac80211/rc80211_minstrel.h
2541 #ifndef __RC_MINSTREL_H
2542 #define __RC_MINSTREL_H
2544 -#define EWMA_LEVEL 75 /* ewma weighting factor [%] */
2545 +#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */
2546 +#define EWMA_DIV 128
2547 #define SAMPLE_COLUMNS 10 /* number of columns in sample table */
2552 minstrel_ewma(int old, int new, int weight)
2554 - return (new * (100 - weight) + old * weight) / 100;
2555 + return (new * (EWMA_DIV - weight) + old * weight) / EWMA_DIV;
2559 @@ -62,6 +63,8 @@ struct minstrel_rate {
2562 struct minstrel_sta_info {
2563 + struct ieee80211_sta *sta;
2565 unsigned long stats_update;
2566 unsigned int sp_ack_dur;
2567 unsigned int rate_avg;
2568 --- a/net/mac80211/rc80211_minstrel_debugfs.c
2569 +++ b/net/mac80211/rc80211_minstrel_debugfs.c
2570 @@ -68,7 +68,7 @@ minstrel_stats_open(struct inode *inode,
2572 file->private_data = ms;
2574 - p += sprintf(p, "rate throughput ewma prob this prob "
2575 + p += sprintf(p, "rate throughput ewma prob this prob "
2576 "this succ/attempt success attempts\n");
2577 for (i = 0; i < mi->n_rates; i++) {
2578 struct minstrel_rate *mr = &mi->r[i];
2579 @@ -86,7 +86,7 @@ minstrel_stats_open(struct inode *inode,
2580 eprob = MINSTREL_TRUNC(mr->probability * 1000);
2582 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u "
2583 - "%3u(%3u) %8llu %8llu\n",
2584 + " %3u(%3u) %8llu %8llu\n",
2586 eprob / 10, eprob % 10,
2587 prob / 10, prob % 10,
2588 --- a/net/mac80211/rc80211_minstrel_ht.c
2589 +++ b/net/mac80211/rc80211_minstrel_ht.c
2590 @@ -126,6 +126,9 @@ const struct mcs_group minstrel_mcs_grou
2592 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
2595 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);
2598 * Look up an MCS group index based on mac80211 rate information
2600 @@ -244,6 +247,7 @@ minstrel_ht_update_stats(struct minstrel
2601 struct minstrel_rate_stats *mr;
2602 int cur_prob, cur_prob_tp, cur_tp, cur_tp2;
2603 int group, i, index;
2604 + bool mi_rates_valid = false;
2606 if (mi->ampdu_packets > 0) {
2607 mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
2608 @@ -254,11 +258,10 @@ minstrel_ht_update_stats(struct minstrel
2610 mi->sample_slow = 0;
2611 mi->sample_count = 0;
2612 - mi->max_tp_rate = 0;
2613 - mi->max_tp_rate2 = 0;
2614 - mi->max_prob_rate = 0;
2616 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
2617 + bool mg_rates_valid = false;
2622 @@ -268,15 +271,24 @@ minstrel_ht_update_stats(struct minstrel
2626 - mg->max_tp_rate = 0;
2627 - mg->max_tp_rate2 = 0;
2628 - mg->max_prob_rate = 0;
2631 for (i = 0; i < MCS_GROUP_RATES; i++) {
2632 if (!(mg->supported & BIT(i)))
2635 + /* initialize rates selections starting indexes */
2636 + if (!mg_rates_valid) {
2637 + mg->max_tp_rate = mg->max_tp_rate2 =
2638 + mg->max_prob_rate = i;
2639 + if (!mi_rates_valid) {
2640 + mi->max_tp_rate = mi->max_tp_rate2 =
2641 + mi->max_prob_rate = i;
2642 + mi_rates_valid = true;
2644 + mg_rates_valid = true;
2648 mr->retry_updated = false;
2649 index = MCS_GROUP_RATES * group + i;
2650 @@ -456,7 +468,7 @@ minstrel_ht_tx_status(void *priv, struct
2651 struct ieee80211_tx_rate *ar = info->status.rates;
2652 struct minstrel_rate_stats *rate, *rate2;
2653 struct minstrel_priv *mp = priv;
2655 + bool last, update = false;
2659 @@ -505,21 +517,29 @@ minstrel_ht_tx_status(void *priv, struct
2660 rate = minstrel_get_ratestats(mi, mi->max_tp_rate);
2661 if (rate->attempts > 30 &&
2662 MINSTREL_FRAC(rate->success, rate->attempts) <
2663 - MINSTREL_FRAC(20, 100))
2664 + MINSTREL_FRAC(20, 100)) {
2665 minstrel_downgrade_rate(mi, &mi->max_tp_rate, true);
2669 rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2);
2670 if (rate2->attempts > 30 &&
2671 MINSTREL_FRAC(rate2->success, rate2->attempts) <
2672 - MINSTREL_FRAC(20, 100))
2673 + MINSTREL_FRAC(20, 100)) {
2674 minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false);
2678 if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
2680 minstrel_ht_update_stats(mp, mi);
2681 if (!(info->flags & IEEE80211_TX_CTL_AMPDU) &&
2682 mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP)
2683 minstrel_aggr_check(sta, skb);
2687 + minstrel_ht_update_rates(mp, mi);
2691 @@ -580,39 +600,73 @@ minstrel_calc_retransmit(struct minstrel
2692 (++mr->retry_count < mp->max_retry));
2697 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
2698 - struct ieee80211_tx_rate *rate, int index,
2699 - bool sample, bool rtscts)
2700 + struct ieee80211_sta_rates *ratetbl, int offset, int index)
2702 const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
2703 struct minstrel_rate_stats *mr;
2707 mr = minstrel_get_ratestats(mi, index);
2708 if (!mr->retry_updated)
2709 minstrel_calc_retransmit(mp, mi, index);
2713 - else if (mr->probability < MINSTREL_FRAC(20, 100))
2716 - rate->count = mr->retry_count_rtscts;
2718 - rate->count = mr->retry_count;
2722 - rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
2723 + if (mr->probability < MINSTREL_FRAC(20, 100) || !mr->retry_count) {
2724 + ratetbl->rate[offset].count = 2;
2725 + ratetbl->rate[offset].count_rts = 2;
2726 + ratetbl->rate[offset].count_cts = 2;
2728 + ratetbl->rate[offset].count = mr->retry_count;
2729 + ratetbl->rate[offset].count_cts = mr->retry_count;
2730 + ratetbl->rate[offset].count_rts = mr->retry_count_rtscts;
2733 if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
2734 - rate->idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
2735 + idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
2738 + idx = index % MCS_GROUP_RATES +
2739 + (group->streams - 1) * MCS_GROUP_RATES;
2740 + flags = IEEE80211_TX_RC_MCS | group->flags;
2744 + ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
2745 + flags |= IEEE80211_TX_RC_USE_RTS_CTS;
2748 + ratetbl->rate[offset].idx = idx;
2749 + ratetbl->rate[offset].flags = flags;
2753 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
2755 + struct ieee80211_sta_rates *rates;
2758 + rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
2762 + /* Start with max_tp_rate */
2763 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate);
2765 + if (mp->hw->max_rates >= 3) {
2766 + /* At least 3 tx rates supported, use max_tp_rate2 next */
2767 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate2);
2770 + if (mp->hw->max_rates >= 2) {
2772 + * At least 2 tx rates supported, use max_prob_rate next */
2773 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate);
2776 - rate->flags |= IEEE80211_TX_RC_MCS | group->flags;
2777 - rate->idx = index % MCS_GROUP_RATES + (group->streams - 1) * MCS_GROUP_RATES;
2778 + rates->rate[i].idx = -1;
2779 + rate_control_set_rates(mp->hw, mi->sta, rates);
2783 @@ -702,13 +756,13 @@ static void
2784 minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
2785 struct ieee80211_tx_rate_control *txrc)
2787 + const struct mcs_group *sample_group;
2788 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
2789 - struct ieee80211_tx_rate *ar = info->status.rates;
2790 + struct ieee80211_tx_rate *rate = &info->status.rates[0];
2791 struct minstrel_ht_sta_priv *msp = priv_sta;
2792 struct minstrel_ht_sta *mi = &msp->ht;
2793 struct minstrel_priv *mp = priv;
2795 - bool sample = false;
2797 if (rate_control_send_low(sta, priv_sta, txrc))
2799 @@ -736,51 +790,6 @@ minstrel_ht_get_rate(void *priv, struct
2803 - if (sample_idx >= 0) {
2805 - minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx,
2807 - info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
2809 - minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate,
2813 - if (mp->hw->max_rates >= 3) {
2815 - * At least 3 tx rates supported, use
2816 - * sample_rate -> max_tp_rate -> max_prob_rate for sampling and
2817 - * max_tp_rate -> max_tp_rate2 -> max_prob_rate by default.
2819 - if (sample_idx >= 0)
2820 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate,
2823 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2,
2826 - minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate,
2831 - } else if (mp->hw->max_rates == 2) {
2833 - * Only 2 tx rates supported, use
2834 - * sample_rate -> max_prob_rate for sampling and
2835 - * max_tp_rate -> max_prob_rate by default.
2837 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_prob_rate,
2843 - /* Not using MRR, only use the first rate */
2848 mi->total_packets++;
2851 @@ -788,6 +797,16 @@ minstrel_ht_get_rate(void *priv, struct
2852 mi->total_packets = 0;
2853 mi->sample_packets = 0;
2856 + if (sample_idx < 0)
2859 + sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
2860 + info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
2861 + rate->idx = sample_idx % MCS_GROUP_RATES +
2862 + (sample_group->streams - 1) * MCS_GROUP_RATES;
2863 + rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
2868 @@ -837,6 +856,8 @@ minstrel_ht_update_caps(void *priv, stru
2871 memset(mi, 0, sizeof(*mi));
2874 mi->stats_update = jiffies;
2876 ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1);
2877 @@ -898,6 +919,9 @@ minstrel_ht_update_caps(void *priv, stru
2881 + minstrel_ht_update_stats(mp, mi);
2882 + minstrel_ht_update_rates(mp, mi);
2887 --- a/net/mac80211/rc80211_minstrel_ht.h
2888 +++ b/net/mac80211/rc80211_minstrel_ht.h
2889 @@ -65,6 +65,8 @@ struct minstrel_mcs_group_data {
2892 struct minstrel_ht_sta {
2893 + struct ieee80211_sta *sta;
2895 /* ampdu length (average, per sampling interval) */
2896 unsigned int ampdu_len;
2897 unsigned int ampdu_packets;
2898 --- a/net/mac80211/rx.c
2899 +++ b/net/mac80211/rx.c
2900 @@ -1372,6 +1372,7 @@ ieee80211_rx_h_sta_process(struct ieee80
2901 struct sk_buff *skb = rx->skb;
2902 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2903 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2908 @@ -1422,6 +1423,19 @@ ieee80211_rx_h_sta_process(struct ieee80
2909 ewma_add(&sta->avg_signal, -status->signal);
2912 + if (status->chains) {
2913 + sta->chains = status->chains;
2914 + for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) {
2915 + int signal = status->chain_signal[i];
2917 + if (!(status->chains & BIT(i)))
2920 + sta->chain_signal_last[i] = signal;
2921 + ewma_add(&sta->chain_signal_avg[i], -signal);
2926 * Change STA power saving mode only at the end of a frame
2927 * exchange sequence.
2928 @@ -2085,6 +2099,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
2931 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data;
2932 + fwd_hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_RETRY);
2933 info = IEEE80211_SKB_CB(fwd_skb);
2934 memset(info, 0, sizeof(*info));
2935 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
2936 @@ -2356,6 +2371,7 @@ ieee80211_rx_h_action(struct ieee80211_r
2937 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
2938 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
2939 sdata->vif.type != NL80211_IFTYPE_AP &&
2940 + sdata->vif.type != NL80211_IFTYPE_WDS &&
2941 sdata->vif.type != NL80211_IFTYPE_ADHOC)
2944 @@ -2423,6 +2439,22 @@ ieee80211_rx_h_action(struct ieee80211_r
2948 + case WLAN_CATEGORY_PUBLIC:
2949 + if (len < IEEE80211_MIN_ACTION_SIZE + 1)
2951 + if (sdata->vif.type != NL80211_IFTYPE_STATION)
2955 + if (!ether_addr_equal(mgmt->bssid, sdata->u.mgd.bssid))
2957 + if (mgmt->u.action.u.ext_chan_switch.action_code !=
2958 + WLAN_PUB_ACTION_EXT_CHANSW_ANN)
2960 + if (len < offsetof(struct ieee80211_mgmt,
2961 + u.action.u.ext_chan_switch.variable))
2964 case WLAN_CATEGORY_VHT:
2965 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
2966 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
2967 @@ -2506,10 +2538,6 @@ ieee80211_rx_h_action(struct ieee80211_r
2968 ieee80211_process_measurement_req(sdata, mgmt, len);
2970 case WLAN_ACTION_SPCT_CHL_SWITCH:
2971 - if (len < (IEEE80211_MIN_ACTION_SIZE +
2972 - sizeof(mgmt->u.action.u.chan_switch)))
2975 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2978 @@ -2695,14 +2723,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
2980 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
2981 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
2982 - sdata->vif.type != NL80211_IFTYPE_STATION)
2983 + sdata->vif.type != NL80211_IFTYPE_STATION &&
2984 + sdata->vif.type != NL80211_IFTYPE_WDS)
2985 return RX_DROP_MONITOR;
2988 case cpu_to_le16(IEEE80211_STYPE_AUTH):
2989 case cpu_to_le16(IEEE80211_STYPE_BEACON):
2990 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
2991 - /* process for all: mesh, mlme, ibss */
2992 + /* process for all: mesh, mlme, ibss, wds */
2994 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
2995 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
2996 @@ -3031,10 +3060,16 @@ static int prepare_for_handlers(struct i
2999 case NL80211_IFTYPE_WDS:
3000 - if (bssid || !ieee80211_is_data(hdr->frame_control))
3002 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
3005 + if (ieee80211_is_data(hdr->frame_control) ||
3006 + ieee80211_is_action(hdr->frame_control)) {
3007 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
3009 + } else if (!ieee80211_is_beacon(hdr->frame_control))
3013 case NL80211_IFTYPE_P2P_DEVICE:
3014 if (!ieee80211_is_public_action(hdr, skb->len) &&
3015 --- a/net/mac80211/scan.c
3016 +++ b/net/mac80211/scan.c
3017 @@ -181,7 +181,7 @@ void ieee80211_scan_rx(struct ieee80211_
3018 if (baselen > skb->len)
3021 - ieee802_11_parse_elems(elements, skb->len - baselen, &elems);
3022 + ieee802_11_parse_elems(elements, skb->len - baselen, false, &elems);
3024 channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq);
3026 --- a/net/mac80211/sta_info.h
3027 +++ b/net/mac80211/sta_info.h
3029 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
3031 * @WLAN_STA_WME: Station is a QoS-STA.
3032 - * @WLAN_STA_WDS: Station is one of our WDS peers.
3033 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
3034 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
3035 * frame to this station is transmitted.
3036 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
3037 WLAN_STA_AUTHORIZED,
3038 WLAN_STA_SHORT_PREAMBLE,
3041 WLAN_STA_CLEAR_PS_FILT,
3044 @@ -344,6 +342,11 @@ struct sta_info {
3046 struct ewma avg_signal;
3047 int last_ack_signal;
3050 + s8 chain_signal_last[IEEE80211_MAX_CHAINS];
3051 + struct ewma chain_signal_avg[IEEE80211_MAX_CHAINS];
3053 /* Plus 1 for non-QoS frames */
3054 __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
3056 --- a/net/mac80211/trace.h
3057 +++ b/net/mac80211/trace.h
3058 @@ -990,23 +990,23 @@ TRACE_EVENT(drv_channel_switch,
3063 __field(u64, timestamp)
3064 __field(bool, block_tx)
3065 - __field(u16, freq)
3071 + CHANDEF_ASSIGN(&ch_switch->chandef)
3072 __entry->timestamp = ch_switch->timestamp;
3073 __entry->block_tx = ch_switch->block_tx;
3074 - __entry->freq = ch_switch->channel->center_freq;
3075 __entry->count = ch_switch->count;
3079 - LOCAL_PR_FMT " new freq:%u count:%d",
3080 - LOCAL_PR_ARG, __entry->freq, __entry->count
3081 + LOCAL_PR_FMT " new " CHANDEF_PR_FMT " count:%d",
3082 + LOCAL_PR_ARG, CHANDEF_PR_ARG, __entry->count
3086 --- a/net/mac80211/tx.c
3087 +++ b/net/mac80211/tx.c
3088 @@ -48,15 +48,15 @@ static __le16 ieee80211_duration(struct
3089 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
3091 /* assume HW handles this */
3092 - if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
3093 + if (tx->rate.flags & IEEE80211_TX_RC_MCS)
3097 - if (WARN_ON_ONCE(info->control.rates[0].idx < 0))
3098 + if (WARN_ON_ONCE(tx->rate.idx < 0))
3101 sband = local->hw.wiphy->bands[info->band];
3102 - txrate = &sband->bitrates[info->control.rates[0].idx];
3103 + txrate = &sband->bitrates[tx->rate.idx];
3105 erp = txrate->flags & IEEE80211_RATE_ERP_G;
3107 @@ -617,11 +617,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3108 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
3109 struct ieee80211_hdr *hdr = (void *)tx->skb->data;
3110 struct ieee80211_supported_band *sband;
3111 - struct ieee80211_rate *rate;
3114 - bool inval = false, rts = false, short_preamble = false;
3115 struct ieee80211_tx_rate_control txrc;
3116 + struct ieee80211_sta_rates *ratetbl = NULL;
3119 memset(&txrc, 0, sizeof(txrc));
3120 @@ -642,18 +640,23 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3121 txrc.max_rate_idx = -1;
3123 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
3124 - memcpy(txrc.rate_idx_mcs_mask,
3125 - tx->sdata->rc_rateidx_mcs_mask[info->band],
3126 - sizeof(txrc.rate_idx_mcs_mask));
3128 + if (tx->sdata->rc_has_mcs_mask[info->band])
3129 + txrc.rate_idx_mcs_mask =
3130 + tx->sdata->rc_rateidx_mcs_mask[info->band];
3132 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
3133 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
3134 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
3136 /* set up RTS protection if desired */
3137 if (len > tx->local->hw.wiphy->rts_threshold) {
3138 - txrc.rts = rts = true;
3142 + info->control.use_rts = txrc.rts;
3143 + info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot;
3146 * Use short preamble if the BSS can handle it, but not for
3147 * management frames unless we know the receiver can handle
3148 @@ -663,7 +666,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3149 if (tx->sdata->vif.bss_conf.use_short_preamble &&
3150 (ieee80211_is_data(hdr->frame_control) ||
3151 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE))))
3152 - txrc.short_preamble = short_preamble = true;
3153 + txrc.short_preamble = true;
3155 + info->control.short_preamble = txrc.short_preamble;
3158 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC);
3159 @@ -687,16 +692,38 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3161 rate_control_get_rate(tx->sdata, tx->sta, &txrc);
3163 - if (unlikely(info->control.rates[0].idx < 0))
3165 + if (tx->sta && !info->control.skip_table)
3166 + ratetbl = rcu_dereference(tx->sta->sta.rates);
3168 + if (unlikely(info->control.rates[0].idx < 0)) {
3170 + struct ieee80211_tx_rate rate = {
3171 + .idx = ratetbl->rate[0].idx,
3172 + .flags = ratetbl->rate[0].flags,
3173 + .count = ratetbl->rate[0].count
3176 + if (ratetbl->rate[0].idx < 0)
3184 + tx->rate = info->control.rates[0];
3187 if (txrc.reported_rate.idx < 0) {
3188 - txrc.reported_rate = info->control.rates[0];
3189 + txrc.reported_rate = tx->rate;
3190 if (tx->sta && ieee80211_is_data(hdr->frame_control))
3191 tx->sta->last_tx_rate = txrc.reported_rate;
3193 tx->sta->last_tx_rate = txrc.reported_rate;
3196 + return TX_CONTINUE;
3198 if (unlikely(!info->control.rates[0].count))
3199 info->control.rates[0].count = 1;
3201 @@ -704,91 +731,6 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3202 (info->flags & IEEE80211_TX_CTL_NO_ACK)))
3203 info->control.rates[0].count = 1;
3205 - if (is_multicast_ether_addr(hdr->addr1)) {
3207 - * XXX: verify the rate is in the basic rateset
3209 - return TX_CONTINUE;
3213 - * set up the RTS/CTS rate as the fastest basic rate
3214 - * that is not faster than the data rate
3216 - * XXX: Should this check all retry rates?
3218 - if (!(info->control.rates[0].flags & IEEE80211_TX_RC_MCS)) {
3221 - rate = &sband->bitrates[info->control.rates[0].idx];
3223 - for (i = 0; i < sband->n_bitrates; i++) {
3224 - /* must be a basic rate */
3225 - if (!(tx->sdata->vif.bss_conf.basic_rates & BIT(i)))
3227 - /* must not be faster than the data rate */
3228 - if (sband->bitrates[i].bitrate > rate->bitrate)
3231 - if (sband->bitrates[baserate].bitrate <
3232 - sband->bitrates[i].bitrate)
3236 - info->control.rts_cts_rate_idx = baserate;
3239 - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
3241 - * make sure there's no valid rate following
3242 - * an invalid one, just in case drivers don't
3243 - * take the API seriously to stop at -1.
3246 - info->control.rates[i].idx = -1;
3249 - if (info->control.rates[i].idx < 0) {
3255 - * For now assume MCS is already set up correctly, this
3256 - * needs to be fixed.
3258 - if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) {
3259 - WARN_ON(info->control.rates[i].idx > 76);
3263 - /* set up RTS protection if desired */
3265 - info->control.rates[i].flags |=
3266 - IEEE80211_TX_RC_USE_RTS_CTS;
3268 - /* RC is busted */
3269 - if (WARN_ON_ONCE(info->control.rates[i].idx >=
3270 - sband->n_bitrates)) {
3271 - info->control.rates[i].idx = -1;
3275 - rate = &sband->bitrates[info->control.rates[i].idx];
3277 - /* set up short preamble */
3278 - if (short_preamble &&
3279 - rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
3280 - info->control.rates[i].flags |=
3281 - IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
3283 - /* set up G protection */
3284 - if (!rts && tx->sdata->vif.bss_conf.use_cts_prot &&
3285 - rate->flags & IEEE80211_RATE_ERP_G)
3286 - info->control.rates[i].flags |=
3287 - IEEE80211_TX_RC_USE_CTS_PROTECT;
3293 @@ -2508,8 +2450,6 @@ struct sk_buff *ieee80211_beacon_get_tim
3294 txrc.max_rate_idx = -1;
3296 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
3297 - memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band],
3298 - sizeof(txrc.rate_idx_mcs_mask));
3300 rate_control_get_rate(sdata, NULL, &txrc);
3302 --- a/net/mac80211/util.c
3303 +++ b/net/mac80211/util.c
3304 @@ -485,7 +485,8 @@ int ieee80211_queue_stopped(struct ieee8
3307 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
3308 - ret = !!local->queue_stop_reasons[queue];
3309 + ret = test_bit(IEEE80211_QUEUE_STOP_REASON_DRIVER,
3310 + &local->queue_stop_reasons[queue]);
3311 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
3314 @@ -660,7 +661,7 @@ void ieee80211_queue_delayed_work(struct
3316 EXPORT_SYMBOL(ieee80211_queue_delayed_work);
3318 -u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
3319 +u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action,
3320 struct ieee802_11_elems *elems,
3321 u64 filter, u32 crc)
3323 @@ -668,6 +669,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start
3325 bool calc_crc = filter != 0;
3326 DECLARE_BITMAP(seen_elems, 256);
3329 bitmap_zero(seen_elems, 256);
3330 memset(elems, 0, sizeof(*elems));
3331 @@ -715,6 +717,12 @@ u32 ieee802_11_parse_elems_crc(u8 *start
3332 case WLAN_EID_COUNTRY:
3333 case WLAN_EID_PWR_CONSTRAINT:
3334 case WLAN_EID_TIMEOUT_INTERVAL:
3335 + case WLAN_EID_SECONDARY_CHANNEL_OFFSET:
3336 + case WLAN_EID_WIDE_BW_CHANNEL_SWITCH:
3338 + * not listing WLAN_EID_CHANNEL_SWITCH_WRAPPER -- it seems possible
3339 + * that if the content gets bigger it might be needed more than once
3341 if (test_bit(id, seen_elems)) {
3342 elems->parse_error = true;
3344 @@ -862,6 +870,48 @@ u32 ieee802_11_parse_elems_crc(u8 *start
3346 elems->ch_switch_ie = (void *)pos;
3348 + case WLAN_EID_EXT_CHANSWITCH_ANN:
3349 + if (elen != sizeof(struct ieee80211_ext_chansw_ie)) {
3350 + elem_parse_failed = true;
3353 + elems->ext_chansw_ie = (void *)pos;
3355 + case WLAN_EID_SECONDARY_CHANNEL_OFFSET:
3356 + if (elen != sizeof(struct ieee80211_sec_chan_offs_ie)) {
3357 + elem_parse_failed = true;
3360 + elems->sec_chan_offs = (void *)pos;
3362 + case WLAN_EID_WIDE_BW_CHANNEL_SWITCH:
3364 + elen != sizeof(*elems->wide_bw_chansw_ie)) {
3365 + elem_parse_failed = true;
3368 + elems->wide_bw_chansw_ie = (void *)pos;
3370 + case WLAN_EID_CHANNEL_SWITCH_WRAPPER:
3372 + elem_parse_failed = true;
3376 + * This is a bit tricky, but as we only care about
3377 + * the wide bandwidth channel switch element, so
3378 + * just parse it out manually.
3380 + ie = cfg80211_find_ie(WLAN_EID_WIDE_BW_CHANNEL_SWITCH,
3383 + if (ie[1] == sizeof(*elems->wide_bw_chansw_ie))
3384 + elems->wide_bw_chansw_ie =
3387 + elem_parse_failed = true;
3390 case WLAN_EID_COUNTRY:
3391 elems->country_elem = pos;
3392 elems->country_elem_len = elen;
3393 --- a/net/wireless/reg.c
3394 +++ b/net/wireless/reg.c
3395 @@ -857,7 +857,7 @@ static void handle_channel(struct wiphy
3398 REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq);
3399 - chan->flags = IEEE80211_CHAN_DISABLED;
3400 + chan->flags |= IEEE80211_CHAN_DISABLED;
3404 --- a/net/wireless/util.c
3405 +++ b/net/wireless/util.c
3406 @@ -1156,6 +1156,26 @@ int cfg80211_get_p2p_attr(const u8 *ies,
3408 EXPORT_SYMBOL(cfg80211_get_p2p_attr);
3410 +bool ieee80211_operating_class_to_band(u8 operating_class,
3411 + enum ieee80211_band *band)
3413 + switch (operating_class) {
3416 + *band = IEEE80211_BAND_5GHZ;
3422 + *band = IEEE80211_BAND_2GHZ;
3428 +EXPORT_SYMBOL(ieee80211_operating_class_to_band);
3430 int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
3433 --- a/include/uapi/linux/nl80211.h
3434 +++ b/include/uapi/linux/nl80211.h
3435 @@ -1973,6 +1973,10 @@ enum nl80211_sta_bss_param {
3436 * @NL80211_STA_INFO_PEER_PM: peer mesh STA link-specific power mode
3437 * @NL80211_STA_INFO_NONPEER_PM: neighbor mesh STA power save mode towards
3439 + * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
3440 + * Contains a nested array of signal strength attributes (u8, dBm)
3441 + * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
3442 + * Same format as NL80211_STA_INFO_CHAIN_SIGNAL.
3443 * @__NL80211_STA_INFO_AFTER_LAST: internal
3444 * @NL80211_STA_INFO_MAX: highest possible station info attribute
3446 @@ -2002,6 +2006,8 @@ enum nl80211_sta_info {
3447 NL80211_STA_INFO_NONPEER_PM,
3448 NL80211_STA_INFO_RX_BYTES64,
3449 NL80211_STA_INFO_TX_BYTES64,
3450 + NL80211_STA_INFO_CHAIN_SIGNAL,
3451 + NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
3454 __NL80211_STA_INFO_AFTER_LAST,
3455 --- a/net/mac80211/sta_info.c
3456 +++ b/net/mac80211/sta_info.c
3457 @@ -358,6 +358,8 @@ struct sta_info *sta_info_alloc(struct i
3458 do_posix_clock_monotonic_gettime(&uptime);
3459 sta->last_connected = uptime.tv_sec;
3460 ewma_init(&sta->avg_signal, 1024, 8);
3461 + for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++)
3462 + ewma_init(&sta->chain_signal_avg[i], 1024, 8);
3464 if (sta_prepare_rate_control(local, sta, gfp)) {
3466 --- a/net/wireless/nl80211.c
3467 +++ b/net/wireless/nl80211.c
3468 @@ -3367,6 +3367,32 @@ static bool nl80211_put_sta_rate(struct
3472 +static bool nl80211_put_signal(struct sk_buff *msg, u8 mask, s8 *signal,
3481 + attr = nla_nest_start(msg, id);
3485 + for (i = 0; i < IEEE80211_MAX_CHAINS; i++) {
3486 + if (!(mask & BIT(i)))
3489 + if (nla_put_u8(msg, i, signal[i]))
3493 + nla_nest_end(msg, attr);
3498 static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq,
3500 struct cfg80211_registered_device *rdev,
3501 @@ -3438,6 +3464,18 @@ static int nl80211_send_station(struct s
3505 + if (sinfo->filled & STATION_INFO_CHAIN_SIGNAL) {
3506 + if (!nl80211_put_signal(msg, sinfo->chains,
3507 + sinfo->chain_signal,
3508 + NL80211_STA_INFO_CHAIN_SIGNAL))
3509 + goto nla_put_failure;
3511 + if (sinfo->filled & STATION_INFO_CHAIN_SIGNAL_AVG) {
3512 + if (!nl80211_put_signal(msg, sinfo->chains,
3513 + sinfo->chain_signal_avg,
3514 + NL80211_STA_INFO_CHAIN_SIGNAL_AVG))
3515 + goto nla_put_failure;
3517 if (sinfo->filled & STATION_INFO_TX_BITRATE) {
3518 if (!nl80211_put_sta_rate(msg, &sinfo->txrate,
3519 NL80211_STA_INFO_TX_BITRATE))
3520 --- a/drivers/net/wireless/ath/ath9k/init.c
3521 +++ b/drivers/net/wireless/ath/ath9k/init.c
3522 @@ -768,7 +768,8 @@ void ath9k_set_hw_capab(struct ath_softc
3523 IEEE80211_HW_SUPPORTS_PS |
3524 IEEE80211_HW_PS_NULLFUNC_STACK |
3525 IEEE80211_HW_SPECTRUM_MGMT |
3526 - IEEE80211_HW_REPORTS_TX_ACK_STATUS;
3527 + IEEE80211_HW_REPORTS_TX_ACK_STATUS |
3528 + IEEE80211_HW_SUPPORTS_RC_TABLE;
3530 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
3531 hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION;
3532 --- a/drivers/net/wireless/ath/ath9k/xmit.c
3533 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3534 @@ -157,6 +157,13 @@ static void ath_send_bar(struct ath_atx_
3535 seqno << IEEE80211_SEQ_SEQ_SHIFT);
3538 +static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
3539 + struct ath_buf *bf)
3541 + ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
3542 + ARRAY_SIZE(bf->rates));
3545 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
3547 struct ath_txq *txq = tid->ac->txq;
3548 @@ -189,6 +196,7 @@ static void ath_tx_flush_tid(struct ath_
3549 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
3552 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
3553 ath_tx_send_normal(sc, txq, NULL, skb);
3556 @@ -407,7 +415,7 @@ static void ath_tx_complete_aggr(struct
3558 tx_info = IEEE80211_SKB_CB(skb);
3560 - memcpy(rates, tx_info->control.rates, sizeof(rates));
3561 + memcpy(rates, bf->rates, sizeof(rates));
3563 retries = ts->ts_longretry + 1;
3564 for (i = 0; i < ts->ts_rateindex; i++)
3565 @@ -736,8 +744,6 @@ static int ath_compute_num_delims(struct
3568 #define FIRST_DESC_NDELIMS 60
3569 - struct sk_buff *skb = bf->bf_mpdu;
3570 - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
3571 u32 nsymbits, nsymbols;
3574 @@ -778,8 +784,8 @@ static int ath_compute_num_delims(struct
3575 if (tid->an->mpdudensity == 0)
3578 - rix = tx_info->control.rates[0].idx;
3579 - flags = tx_info->control.rates[0].flags;
3580 + rix = bf->rates[0].idx;
3581 + flags = bf->rates[0].flags;
3582 width = (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1 : 0;
3583 half_gi = (flags & IEEE80211_TX_RC_SHORT_GI) ? 1 : 0;
3585 @@ -858,6 +864,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_
3589 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
3590 aggr_limit = ath_lookup_rate(sc, bf, tid);
3593 @@ -998,14 +1005,14 @@ static void ath_buf_set_rate(struct ath_
3596 tx_info = IEEE80211_SKB_CB(skb);
3597 - rates = tx_info->control.rates;
3598 + rates = bf->rates;
3599 hdr = (struct ieee80211_hdr *)skb->data;
3601 /* set dur_update_en for l-sig computation except for PS-Poll frames */
3602 info->dur_update = !ieee80211_is_pspoll(hdr->frame_control);
3603 info->rtscts_rate = fi->rtscts_rate;
3605 - for (i = 0; i < 4; i++) {
3606 + for (i = 0; i < ARRAY_SIZE(bf->rates); i++) {
3607 bool is_40, is_sgi, is_sp;
3610 @@ -1743,6 +1750,7 @@ static void ath_tx_send_ampdu(struct ath
3614 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
3615 bf->bf_state.bf_type = BUF_AMPDU;
3616 INIT_LIST_HEAD(&bf_head);
3617 list_add(&bf->list, &bf_head);
3618 @@ -1892,49 +1900,6 @@ static struct ath_buf *ath_tx_setup_buff
3622 -/* FIXME: tx power */
3623 -static void ath_tx_start_dma(struct ath_softc *sc, struct sk_buff *skb,
3624 - struct ath_tx_control *txctl)
3626 - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
3627 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
3628 - struct ath_atx_tid *tid = NULL;
3629 - struct ath_buf *bf;
3632 - if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
3633 - tidno = ieee80211_get_qos_ctl(hdr)[0] &
3634 - IEEE80211_QOS_CTL_TID_MASK;
3635 - tid = ATH_AN_2_TID(txctl->an, tidno);
3637 - WARN_ON(tid->ac->txq != txctl->txq);
3640 - if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
3642 - * Try aggregation if it's a unicast data frame
3643 - * and the destination is HT capable.
3645 - ath_tx_send_ampdu(sc, tid, skb, txctl);
3647 - bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb);
3650 - dev_kfree_skb_any(skb);
3652 - ieee80211_free_txskb(sc->hw, skb);
3656 - bf->bf_state.bfs_paprd = txctl->paprd;
3659 - bf->bf_state.bfs_paprd_timestamp = jiffies;
3661 - ath_tx_send_normal(sc, txctl->txq, tid, skb);
3665 /* Upon failure caller should free skb */
3666 int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
3667 struct ath_tx_control *txctl)
3668 @@ -1945,8 +1910,11 @@ int ath_tx_start(struct ieee80211_hw *hw
3669 struct ieee80211_vif *vif = info->control.vif;
3670 struct ath_softc *sc = hw->priv;
3671 struct ath_txq *txq = txctl->txq;
3672 + struct ath_atx_tid *tid = NULL;
3673 + struct ath_buf *bf;
3674 int padpos, padsize;
3675 int frmlen = skb->len + FCS_LEN;
3679 /* NOTE: sta can be NULL according to net/mac80211.h */
3680 @@ -2002,8 +1970,41 @@ int ath_tx_start(struct ieee80211_hw *hw
3681 txq->stopped = true;
3684 - ath_tx_start_dma(sc, skb, txctl);
3685 + if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
3686 + tidno = ieee80211_get_qos_ctl(hdr)[0] &
3687 + IEEE80211_QOS_CTL_TID_MASK;
3688 + tid = ATH_AN_2_TID(txctl->an, tidno);
3690 + WARN_ON(tid->ac->txq != txctl->txq);
3693 + if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
3695 + * Try aggregation if it's a unicast data frame
3696 + * and the destination is HT capable.
3698 + ath_tx_send_ampdu(sc, tid, skb, txctl);
3702 + bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb);
3705 + dev_kfree_skb_any(skb);
3707 + ieee80211_free_txskb(sc->hw, skb);
3711 + bf->bf_state.bfs_paprd = txctl->paprd;
3714 + bf->bf_state.bfs_paprd_timestamp = jiffies;
3716 + ath_set_rates(vif, sta, bf);
3717 + ath_tx_send_normal(sc, txctl->txq, tid, skb);
3720 ath_txq_unlock(sc, txq);
3723 --- a/drivers/net/wireless/ath/ath9k/recv.c
3724 +++ b/drivers/net/wireless/ath/ath9k/recv.c
3725 @@ -124,7 +124,7 @@ static bool ath_rx_edma_buf_link(struct
3727 SKB_CB_ATHBUF(skb) = bf;
3728 ath9k_hw_addrxbuf_edma(ah, bf->bf_buf_addr, qtype);
3729 - skb_queue_tail(&rx_edma->rx_fifo, skb);
3730 + __skb_queue_tail(&rx_edma->rx_fifo, skb);
3734 @@ -155,7 +155,7 @@ static void ath_rx_remove_buffer(struct
3736 rx_edma = &sc->rx.rx_edma[qtype];
3738 - while ((skb = skb_dequeue(&rx_edma->rx_fifo)) != NULL) {
3739 + while ((skb = __skb_dequeue(&rx_edma->rx_fifo)) != NULL) {
3740 bf = SKB_CB_ATHBUF(skb);
3742 list_add_tail(&bf->list, &sc->rx.rxbuf);
3743 @@ -1287,13 +1287,13 @@ int ath_rx_tasklet(struct ath_softc *sc,
3744 goto requeue_drop_frag;
3747 - bf->bf_mpdu = requeue_skb;
3748 - bf->bf_buf_addr = new_buf_addr;
3750 /* Unmap the frame */
3751 dma_unmap_single(sc->dev, bf->bf_buf_addr,
3752 common->rx_bufsize, dma_type);
3754 + bf->bf_mpdu = requeue_skb;
3755 + bf->bf_buf_addr = new_buf_addr;
3757 skb_put(skb, rs.rs_datalen + ah->caps.rx_status_len);
3758 if (ah->caps.rx_status_len)
3759 skb_pull(skb, ah->caps.rx_status_len);