d47c6261efc82e6b4b39abd2f30721531f81fe1e
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 300-pending_work.patch
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 */
6 bool bf_stale;
7 + struct ieee80211_tx_rate rates[4];
8 struct ath_buf_state bf_state;
9 };
10
11 @@ -658,11 +659,10 @@ enum sc_op_flags {
12 struct ath_rate_table;
13
14 struct ath9k_vif_iter_data {
15 - const u8 *hw_macaddr; /* phy's hardware address, set
16 - * before starting iteration for
17 - * valid bssid mask.
18 - */
19 + u8 hw_macaddr[ETH_ALEN]; /* address of the first vif */
20 u8 mask[ETH_ALEN]; /* bssid mask */
21 + bool has_hw_macaddr;
22 +
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
29
30 ENABLE_REGWRITE_BUFFER(ah);
31
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)
34 - | macStaId1
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;
48 int i;
49
50 - if (iter_data->hw_macaddr)
51 + if (iter_data->has_hw_macaddr) {
52 for (i = 0; i < ETH_ALEN; i++)
53 iter_data->mask[i] &=
54 ~(iter_data->hw_macaddr[i] ^ mac[i]);
55 + } else {
56 + memcpy(iter_data->hw_macaddr, mac, ETH_ALEN);
57 + iter_data->has_hw_macaddr = true;
58 + }
59
60 switch (vif->type) {
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.
64 */
65 memset(iter_data, 0, sizeof(*iter_data));
66 - iter_data->hw_macaddr = common->macaddr;
67 memset(&iter_data->mask, 0xff, ETH_ALEN);
68
69 if (vif)
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);
74 +
75 + memcpy(common->macaddr, iter_data->hw_macaddr, ETH_ALEN);
76 }
77
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
84
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
93 @@ -118,6 +118,12 @@
94 void ath_hw_setbssidmask(struct ath_common *common)
95 {
96 void *ah = common->ah;
97 + u32 id1;
98 +
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);
103
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
108 @@ -23,6 +23,10 @@
109 #define AR_MIBC_CMC 0x00000004
110 #define AR_MIBC_MCS 0x00000008
111
112 +#define AR_STA_ID0 0x8000
113 +#define AR_STA_ID1 0x8004
114 +#define AR_STA_ID1_SADH_MASK 0x0000ffff
115 +
116 /*
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;
128 u16 ch;
129
130 @@ -6096,23 +6096,21 @@ il4965_mac_channel_switch(struct ieee802
131 il->current_ht_config.smps = conf->smps_mode;
132
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;
144 - } else {
145 - il->ht.extension_chan_offset =
146 - IEEE80211_HT_PARAM_CHA_SEC_NONE;
147 - il->ht.is_40mhz = false;
148 - }
149 - } else
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;
155 + break;
156 + case NL80211_CHAN_HT40MINUS:
157 + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
158 + il->ht.is_40mhz = true;
159 + break;
160 + case NL80211_CHAN_HT40PLUS:
161 + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
162 + il->ht.is_40mhz = true;
163 + break;
164 + }
165
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
171
172 cmd.band = band;
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
182 };
183
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
191 }
192 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
193 cmd.switch_time);
194 - cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
195 + cmd.expect_beacon =
196 + ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
197
198 return iwl_dvm_send_cmd(priv, &hcmd);
199 }
200 @@ -540,7 +541,7 @@ static int iwl6000_hw_channel_switch(str
201 hcmd.data[0] = cmd;
202
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
210 }
211 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
212 cmd->switch_time);
213 - cmd->expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
214 + cmd->expect_beacon =
215 + ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
216
217 err = iwl_dvm_send_cmd(priv, &hcmd);
218 kfree(cmd);
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
222 {
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;
228 /*
229 * MULTI-FIXME
230 @@ -1008,11 +1008,21 @@ static void iwlagn_mac_channel_switch(st
231 priv->current_ht_config.smps = conf->smps_mode;
232
233 /* Configure HT40 channels */
234 - ctx->ht.enabled = conf_is_ht(conf);
235 - if (ctx->ht.enabled)
236 - iwlagn_config_ht40(conf, ctx);
237 - else
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;
243 + break;
244 + case NL80211_CHAN_HT40MINUS:
245 + ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
246 + ctx->ht.is_40mhz = true;
247 + break;
248 + case NL80211_CHAN_HT40PLUS:
249 + ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
250 + ctx->ht.is_40mhz = true;
251 + break;
252 + }
253
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 *
259 }
260
261 void iwlagn_config_ht40(struct ieee80211_conf *conf,
262 - struct iwl_rxon_context *ctx)
263 + struct iwl_rxon_context *ctx)
264 {
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
269 @@ -25,6 +25,7 @@
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;
290 + } else {
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;
294 + }
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);
305 }
306 @@ -1695,7 +1705,9 @@ static void mac80211_hwsim_free(void)
307
308
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,
314 };
315
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);
320
321 + err = driver_register(&mac80211_hwsim_driver);
322 + if (err)
323 + return err;
324 +
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;
331 + }
332
333 memset(addr, 0, ETH_ALEN);
334 addr[0] = 0x02;
335 @@ -2211,12 +2229,20 @@ static int __init init_mac80211_hwsim(vo
336 "hwsim%d", i);
337 if (IS_ERR(data->dev)) {
338 printk(KERN_DEBUG
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));
343 err = -ENOMEM;
344 goto failed_drvdata;
345 }
346 data->dev->driver = &mac80211_hwsim_driver;
347 + err = device_bind_driver(data->dev);
348 + if (err != 0) {
349 + printk(KERN_DEBUG
350 + "mac80211_hwsim: device_bind_driver failed (%d)\n",
351 + err);
352 + goto failed_hw;
353 + }
354 +
355 skb_queue_head_init(&data->pending);
356
357 SET_IEEE80211_DEV(hw, data->dev);
358 @@ -2515,6 +2541,8 @@ failed_drvdata:
359 ieee80211_free_hw(hw);
360 failed:
361 mac80211_hwsim_free();
362 +failed_unregister_driver:
363 + driver_unregister(&mac80211_hwsim_driver);
364 return err;
365 }
366 module_init(init_mac80211_hwsim);
367 @@ -2527,5 +2555,6 @@ static void __exit exit_mac80211_hwsim(v
368
369 mac80211_hwsim_free();
370 unregister_netdev(hwsim_mon);
371 + driver_unregister(&mac80211_hwsim_driver);
372 }
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
377 }
378
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;
384
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
388 }
389
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;
395
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;
400 break;
401 @@ -55,7 +55,7 @@ int wl18xx_cmd_channel_switch(struct wl1
402 break;
403 default:
404 wl1271_error("invalid channel switch band: %d",
405 - ch_switch->channel->band);
406 + ch_switch->chandef.chan->band);
407 ret = -EINVAL;
408 goto out_free;
409 }
410 --- a/include/linux/ieee80211.h
411 +++ b/include/linux/ieee80211.h
412 @@ -673,6 +673,36 @@ struct ieee80211_channel_sw_ie {
413 } __packed;
414
415 /**
416 + * struct ieee80211_ext_chansw_ie
417 + *
418 + * This structure represents the "Extended Channel Switch Announcement element"
419 + */
420 +struct ieee80211_ext_chansw_ie {
421 + u8 mode;
422 + u8 new_operating_class;
423 + u8 new_ch_num;
424 + u8 count;
425 +} __packed;
426 +
427 +/**
428 + * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
429 + * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
430 + * values here
431 + * This structure represents the "Secondary Channel Offset element"
432 + */
433 +struct ieee80211_sec_chan_offs_ie {
434 + u8 sec_chan_offs;
435 +} __packed;
436 +
437 +/**
438 + * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
439 + */
440 +struct ieee80211_wide_bw_chansw_ie {
441 + u8 new_channel_width;
442 + u8 new_center_freq_seg0, new_center_freq_seg1;
443 +} __packed;
444 +
445 +/**
446 * struct ieee80211_tim
447 *
448 * This structure refers to "Traffic Indication Map information element"
449 @@ -840,12 +870,15 @@ struct ieee80211_mgmt {
450 } __packed wme_action;
451 struct{
452 u8 action_code;
453 - u8 element_id;
454 - u8 length;
455 - struct ieee80211_channel_sw_ie sw_elem;
456 + u8 variable[0];
457 } __packed chan_switch;
458 struct{
459 u8 action_code;
460 + struct ieee80211_ext_chansw_ie data;
461 + u8 variable[0];
462 + } __packed ext_chan_switch;
463 + struct{
464 + u8 action_code;
465 u8 dialog_token;
466 u8 element_id;
467 u8 length;
468 @@ -1638,6 +1671,7 @@ enum ieee80211_eid {
469
470 WLAN_EID_HT_CAPABILITY = 45,
471 WLAN_EID_HT_OPERATION = 61,
472 + WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
473
474 WLAN_EID_RSN = 48,
475 WLAN_EID_MMIE = 76,
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,
482
483 /* 802.11ad */
484 WLAN_EID_NON_TX_BSSID_CAP = 83,
485 @@ -1795,6 +1831,7 @@ enum ieee80211_key_len {
486
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,
491 };
492
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
501 */
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,
510 };
511
512 /**
513 @@ -857,6 +861,8 @@ struct sta_bss_parameters {
514 u16 beacon_interval;
515 };
516
517 +#define IEEE80211_MAX_CHAINS 4
518 +
519 /**
520 * struct station_info - station information
521 *
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 {
533 u8 plink_state;
534 s8 signal;
535 s8 signal_avg;
536 +
537 + u8 chains;
538 + s8 chain_signal[IEEE80211_MAX_CHAINS];
539 + s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
540 +
541 struct rate_info txrate;
542 struct rate_info rxrate;
543 u32 rx_packets;
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);
547
548 +/**
549 + * ieee80211_operating_class_to_band - convert operating class to band
550 + *
551 + * @operating_class: the operating class to convert
552 + * @band: band pointer to fill
553 + *
554 + * Returns %true if the conversion was successful, %false otherwise.
555 + */
556 +bool ieee80211_operating_class_to_band(u8 operating_class,
557 + enum ieee80211_band *band);
558 +
559 /*
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
585
586 +/* maximum number of rate table entries */
587 +#define IEEE80211_TX_RATE_TABLE_SIZE 4
588 +
589 /**
590 * struct ieee80211_tx_rate - rate selection/status
591 *
592 @@ -602,8 +605,8 @@ static inline void ieee80211_rate_set_vh
593 u8 mcs, u8 nss)
594 {
595 WARN_ON(mcs & ~0xF);
596 - WARN_ON(nss & ~0x7);
597 - rate->idx = (nss << 4) | mcs;
598 + WARN_ON((nss - 1) & ~0x7);
599 + rate->idx = ((nss - 1) << 4) | mcs;
600 }
601
602 static inline u8
603 @@ -615,7 +618,7 @@ ieee80211_rate_get_vht_mcs(const struct
604 static inline u8
605 ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
606 {
607 - return rate->idx >> 4;
608 + return (rate->idx >> 4) + 1;
609 }
610
611 /**
612 @@ -656,7 +659,11 @@ struct ieee80211_tx_info {
613 struct ieee80211_tx_rate rates[
614 IEEE80211_TX_MAX_RATES];
615 s8 rts_cts_rate_idx;
616 - /* 3 bytes free */
617 + u8 use_rts:1;
618 + u8 use_cts_prot:1;
619 + u8 short_preamble:1;
620 + u8 skip_table:1;
621 + /* 2 bytes free */
622 };
623 /* only needed before rate control */
624 unsigned long jiffies;
625 @@ -677,6 +684,8 @@ struct ieee80211_tx_info {
626 struct {
627 struct ieee80211_tx_rate driver_rates[
628 IEEE80211_TX_MAX_RATES];
629 + u8 pad[4];
630 +
631 void *rate_driver_data[
632 IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
633 };
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 {
645 u8 band;
646 u8 antenna;
647 s8 signal;
648 + u8 chains;
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
660 */
661 struct ieee80211_channel_switch {
662 u64 timestamp;
663 bool block_tx;
664 - struct ieee80211_channel *channel;
665 + struct cfg80211_chan_def chandef;
666 u8 count;
667 };
668
669 @@ -1222,6 +1236,24 @@ enum ieee80211_sta_rx_bandwidth {
670 };
671
672 /**
673 + * struct ieee80211_sta_rates - station rate selection table
674 + *
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.
678 + */
679 +struct ieee80211_sta_rates {
680 + struct rcu_head rcu_head;
681 + struct {
682 + s8 idx;
683 + u8 count;
684 + u8 count_cts;
685 + u8 count_rts;
686 + u16 flags;
687 + } rate[IEEE80211_TX_RATE_TABLE_SIZE];
688 +};
689 +
690 +/**
691 * struct ieee80211_sta - station table entry
692 *
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
699 */
700 struct ieee80211_sta {
701 u32 supp_rates[IEEE80211_NUM_BANDS];
702 @@ -1261,6 +1294,7 @@ struct ieee80211_sta {
703 u8 rx_nss;
704 enum ieee80211_sta_rx_bandwidth bandwidth;
705 enum ieee80211_smps_mode smps_mode;
706 + struct ieee80211_sta_rates __rcu *rates;
707
708 /* must be last */
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.
713 *
714 + * @IEEE80211_HW_SUPPORTS_RC_TABLE: The driver supports using a rate
715 + * selection table provided by the rate control algorithm.
716 + *
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
719 * is supported.
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,
727 };
728 @@ -3144,6 +3182,25 @@ void ieee80211_sta_set_buffered(struct i
729 u8 tid, bool buffered);
730
731 /**
732 + * ieee80211_get_tx_rates - get the selected transmit rates for a packet
733 + *
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.
737 + *
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
743 + */
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,
748 + int max_rates);
749 +
750 +/**
751 * ieee80211_tx_status - transmit status callback
752 *
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
756 * rate_idx_mask)
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
761 */
762 struct ieee80211_tx_rate_control {
763 @@ -4130,7 +4187,7 @@ struct ieee80211_tx_rate_control {
764 bool rts, short_preamble;
765 u8 max_rate_idx;
766 u32 rate_idx_mask;
767 - u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
768 + u8 *rate_idx_mcs_mask;
769 bool bss;
770 };
771
772 @@ -4219,6 +4276,22 @@ bool rate_usable_index_exists(struct iee
773 return false;
774 }
775
776 +/**
777 + * rate_control_set_rates - pass the sta rate selection to mac80211/driver
778 + *
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.
783 + *
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.
787 + */
788 +int rate_control_set_rates(struct ieee80211_hw *hw,
789 + struct ieee80211_sta *pubsta,
790 + struct ieee80211_sta_rates *rates);
791 +
792 int ieee80211_rate_control_register(struct rate_control_ops *ops);
793 void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
794
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);
803
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)
824 return -EINVAL;
825
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;
831 u64 packets = 0;
832 - int ac;
833 + int i, ac;
834
835 sinfo->generation = sdata->local->sta_generation;
836
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);
840 }
841 + if (sta->chains) {
842 + sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
843 + STATION_INFO_CHAIN_SIGNAL_AVG;
844 +
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]);
850 + }
851 + }
852
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);
857
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);
862
863 @@ -2416,9 +2428,22 @@ static int ieee80211_set_bitrate_mask(st
864 }
865
866 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
867 + struct ieee80211_supported_band *sband = wiphy->bands[i];
868 + int j;
869 +
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));
873 +
874 + sdata->rc_has_mcs_mask[i] = false;
875 + if (!sband)
876 + continue;
877 +
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;
881 + break;
882 + }
883 }
884
885 return 0;
886 --- a/net/mac80211/chan.c
887 +++ b/net/mac80211/chan.c
888 @@ -57,6 +57,22 @@ ieee80211_find_chanctx(struct ieee80211_
889 return NULL;
890 }
891
892 +static bool ieee80211_is_radar_required(struct ieee80211_local *local)
893 +{
894 + struct ieee80211_sub_if_data *sdata;
895 +
896 + rcu_read_lock();
897 + list_for_each_entry_rcu(sdata, &local->interfaces, list) {
898 + if (sdata->radar_required) {
899 + rcu_read_unlock();
900 + return true;
901 + }
902 + }
903 + rcu_read_unlock();
904 +
905 + return false;
906 +}
907 +
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;
914 ctx->mode = mode;
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;
918
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)
924 {
925 + bool check_single_channel = false;
926 lockdep_assert_held(&local->chanctx_mtx);
927
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;
933 +
934 + /* NOTE: Disabling radar is only valid here for
935 + * single channel context. To be sure, check it ...
936 + */
937 + if (local->hw.conf.radar_enabled)
938 + check_single_channel = true;
939 + local->hw.conf.radar_enabled = false;
940 +
941 ieee80211_hw_config(local, 0);
942 } else {
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);
947
948 + /* throw a warning if this wasn't the only channel context. */
949 + WARN_ON(check_single_channel && !list_empty(&local->chanctx_list));
950 +
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)
957 {
958 - struct ieee80211_sub_if_data *sdata;
959 - bool radar_enabled = false;
960 + bool radar_enabled;
961
962 lockdep_assert_held(&local->chanctx_mtx);
963
964 - rcu_read_lock();
965 - list_for_each_entry_rcu(sdata, &local->interfaces, list) {
966 - if (sdata->radar_required) {
967 - radar_enabled = true;
968 - break;
969 - }
970 - }
971 - rcu_read_unlock();
972 + radar_enabled = ieee80211_is_radar_required(local);
973
974 if (radar_enabled == chanctx->conf.radar_enabled)
975 return;
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" : ""
980
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;
1008
1009 /*
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
1012 return;
1013
1014 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
1015 - &elems);
1016 + false, &elems);
1017
1018 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
1019 }
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 |
1027 BSS_CHANGED_IBSS);
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;
1035
1036 unsigned int flags;
1037 };
1038 @@ -740,6 +741,8 @@ struct ieee80211_sub_if_data {
1039
1040 /* bitmap of allowed (non-MCS) rate indexes for rate control */
1041 u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
1042 +
1043 + bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
1044 u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
1045
1046 union {
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;
1055
1056 @@ -1184,10 +1187,13 @@ struct ieee802_11_elems {
1057 const u8 *perr;
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;
1067
1068 /* length of them, respectively */
1069 u8 ssid_len;
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);
1074 -void
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);
1083 }
1084
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)
1092 {
1093 - ieee802_11_parse_elems_crc(start, len, elems, 0, 0);
1094 + ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1095 }
1096
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;
1105 u32 changed = 0;
1106 int res;
1107 u32 hw_reconf_flags = 0;
1108 @@ -609,30 +608,8 @@ int ieee80211_do_open(struct wireless_de
1109
1110 set_bit(SDATA_STATE_RUNNING, &sdata->state);
1111
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,
1115 - GFP_KERNEL);
1116 - if (!sta) {
1117 - res = -ENOMEM;
1118 - goto err_del_interface;
1119 - }
1120 -
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);
1124 -
1125 - res = sta_info_insert(sta);
1126 - if (res) {
1127 - /* STA has been freed */
1128 - goto err_del_interface;
1129 - }
1130 -
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);
1136 - }
1137
1138 /*
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;
1142 }
1143
1144 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1145 + struct sk_buff *skb)
1146 +{
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;
1152 + size_t baselen;
1153 + u32 rates = 0;
1154 + u16 stype;
1155 + bool new = false;
1156 + enum ieee80211_band band;
1157 + struct ieee80211_supported_band *sband;
1158 +
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;
1164 +
1165 + if (stype != IEEE80211_STYPE_BEACON)
1166 + return;
1167 +
1168 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
1169 + if (baselen > skb->len)
1170 + return;
1171 +
1172 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
1173 + skb->len - baselen, false, &elems);
1174 +
1175 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
1176 +
1177 + rcu_read_lock();
1178 +
1179 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
1180 +
1181 + if (!sta) {
1182 + rcu_read_unlock();
1183 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1184 + GFP_KERNEL);
1185 + if (!sta)
1186 + return;
1187 +
1188 + new = true;
1189 + }
1190 +
1191 + sta->last_rx = jiffies;
1192 + sta->sta.supp_rates[band] = rates;
1193 +
1194 + if (elems.ht_cap_elem)
1195 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1196 + elems.ht_cap_elem, sta);
1197 +
1198 + if (elems.wmm_param)
1199 + set_sta_flag(sta, WLAN_STA_WME);
1200 +
1201 + if (new) {
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);
1207 + }
1208 +
1209 + rcu_read_unlock();
1210 +}
1211 +
1212 static void ieee80211_iface_work(struct work_struct *work)
1213 {
1214 struct ieee80211_sub_if_data *sdata =
1215 @@ -1196,6 +1241,9 @@ static void ieee80211_iface_work(struct
1216 break;
1217 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
1218 break;
1219 + case NL80211_IFTYPE_WDS:
1220 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
1221 + break;
1222 default:
1223 WARN(1, "frame for unexpected interface type");
1224 break;
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];
1237 if (!sband)
1238 continue;
1239 - if (!local->use_chanctx && !local->_oper_chandef.chan) {
1240 +
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,
1250 - .center_freq2 = 0
1251 - };
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;
1256 + }
1257 + local->monitor_chandef = dflt_chandef;
1258 }
1259 - cfg80211_chandef_create(&local->monitor_chandef,
1260 - &sband->channels[0],
1261 - NL80211_CHAN_NO_HT);
1262 +
1263 channels += sband->n_channels;
1264
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
1269 if (baselen > len)
1270 return;
1271
1272 - ieee802_11_parse_elems(pos, len - baselen, &elems);
1273 + ieee802_11_parse_elems(pos, len - baselen, false, &elems);
1274
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(
1278 return;
1279
1280 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
1281 - &elems);
1282 + false, &elems);
1283
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
1289
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);
1294
1295 if (elems.preq) {
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
1300 return;
1301 }
1302 mpl_dbg(sta->sdata,
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]);
1307 reason = 0;
1308 llid = sta->llid;
1309 plid = sta->plid;
1310 @@ -687,7 +687,7 @@ void mesh_rx_plink_frame(struct ieee8021
1311 baseaddr += 4;
1312 baselen += 4;
1313 }
1314 - ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
1315 + ieee802_11_parse_elems(baseaddr, len - baselen, true, &elems);
1316
1317 if (!elems.peering) {
1318 mpl_dbg(sdata,
1319 --- a/net/mac80211/mlme.c
1320 +++ b/net/mac80211/mlme.c
1321 @@ -289,6 +289,8 @@ ieee80211_determine_chantype(struct ieee
1322 } else {
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;
1327 goto out;
1328 }
1329
1330 @@ -303,12 +305,6 @@ ieee80211_determine_chantype(struct ieee
1331 channel->band);
1332 vht_chandef.center_freq2 = 0;
1333
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,
1338 - channel->band);
1339 -
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
1344 break;
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,
1350 + channel->band);
1351 break;
1352 default:
1353 if (verbose)
1354 @@ -604,7 +604,6 @@ static void ieee80211_add_vht_ie(struct
1355 u8 *pos;
1356 u32 cap;
1357 struct ieee80211_sta_vht_cap vht_cap;
1358 - int i;
1359
1360 BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap));
1361
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;
1365
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);
1371 -
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;
1376 -
1377 - ap_mcs = (le16_to_cpu(ap_vht_cap->supp_mcs.tx_mcs_map) &
1378 - mask) >> shift;
1379 - our_mcs = (le16_to_cpu(vht_cap.vht_mcs.rx_mcs_map) &
1380 - mask) >> shift;
1381 -
1382 - if (our_mcs == IEEE80211_VHT_MCS_NOT_SUPPORTED)
1383 - continue;
1384 -
1385 - switch (ap_mcs) {
1386 - default:
1387 - if (our_mcs <= ap_mcs)
1388 - break;
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);
1394 - }
1395 - }
1396 -
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)
1402 goto out;
1403
1404 - /*
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
1408 - */
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;
1415
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);
1420 }
1421
1422 -void
1423 +static void
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)
1428 {
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;
1440 + int new_freq;
1441 + u8 new_chan_no;
1442 + u8 count;
1443 + u8 mode;
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;
1450
1451 ASSERT_MGD_MTX(ifmgd);
1452
1453 - if (!ifmgd->associated)
1454 + if (!cbss)
1455 return;
1456
1457 - if (sdata->local->scanning)
1458 + if (local->scanning)
1459 return;
1460
1461 - /* Disregard subsequent beacons if we are already running a timer
1462 - processing a CSA */
1463 -
1464 + /* disregard subsequent announcements if we are already processing */
1465 if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED)
1466 return;
1467
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;
1472 +
1473 + if (ifmgd->flags & (IEEE80211_STA_DISABLE_HT |
1474 + IEEE80211_STA_DISABLE_40MHZ)) {
1475 + sec_chan_offs = NULL;
1476 + wide_bw_chansw_ie = NULL;
1477 + }
1478 +
1479 + if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT)
1480 + wide_bw_chansw_ie = NULL;
1481 +
1482 + if (elems->ext_chansw_ie) {
1483 + if (!ieee80211_operating_class_to_band(
1484 + elems->ext_chansw_ie->new_operating_class,
1485 + &new_band)) {
1486 + sdata_info(sdata,
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);
1491 + }
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;
1500 + } else {
1501 + /* nothing here we understand */
1502 + return;
1503 + }
1504 +
1505 + bss = (void *)cbss->priv;
1506 +
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) {
1510 sdata_info(sdata,
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);
1516 + return;
1517 + }
1518 +
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;
1524 + }
1525 +
1526 + switch (secondary_channel_offset) {
1527 + default:
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);
1532 + break;
1533 + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
1534 + cfg80211_chandef_create(&new_chandef, new_chan,
1535 + NL80211_CHAN_HT40PLUS);
1536 + break;
1537 + case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
1538 + cfg80211_chandef_create(&new_chandef, new_chan,
1539 + NL80211_CHAN_HT40MINUS);
1540 + break;
1541 + case -1:
1542 + cfg80211_chandef_create(&new_chandef, new_chan,
1543 + NL80211_CHAN_NO_HT);
1544 + break;
1545 + }
1546 +
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,
1552 + new_band);
1553 +
1554 + switch (wide_bw_chansw_ie->new_channel_width) {
1555 + default:
1556 + /* hmmm, ignore VHT and use HT if present */
1557 + case IEEE80211_VHT_CHANWIDTH_USE_HT:
1558 + new_vht_chandef.chan = NULL;
1559 + break;
1560 + case IEEE80211_VHT_CHANWIDTH_80MHZ:
1561 + new_vht_chandef.width = NL80211_CHAN_WIDTH_80;
1562 + break;
1563 + case IEEE80211_VHT_CHANWIDTH_160MHZ:
1564 + new_vht_chandef.width = NL80211_CHAN_WIDTH_160;
1565 + break;
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,
1571 + new_band);
1572 + new_vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
1573 + break;
1574 + }
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);
1584 + }
1585 +
1586 + /* if VHT data is there validate & use it */
1587 + if (new_vht_chandef.chan) {
1588 + if (!cfg80211_chandef_compatible(&new_vht_chandef,
1589 + &new_chandef)) {
1590 + sdata_info(sdata,
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);
1595 + return;
1596 + }
1597 + new_chandef = new_vht_chandef;
1598 + }
1599 +
1600 + if (!cfg80211_chandef_usable(local->hw.wiphy, &new_chandef,
1601 + IEEE80211_CHAN_DISABLED)) {
1602 + sdata_info(sdata,
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);
1609 return;
1610 }
1611
1612 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
1613
1614 - if (sdata->local->use_chanctx) {
1615 + if (local->use_chanctx) {
1616 sdata_info(sdata,
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);
1621 return;
1622 }
1623
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);
1629 return;
1630 }
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) {
1634 sdata_info(sdata,
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);
1641 return;
1642 }
1643 - mutex_unlock(&sdata->local->chanctx_mtx);
1644 + mutex_unlock(&local->chanctx_mtx);
1645
1646 - sdata->local->csa_channel = new_ch;
1647 + local->csa_chandef = new_chandef;
1648
1649 - if (sw_elem->mode)
1650 - ieee80211_stop_queues_by_reason(&sdata->local->hw,
1651 + if (mode)
1652 + ieee80211_stop_queues_by_reason(&local->hw,
1653 IEEE80211_MAX_QUEUE_MAP,
1654 IEEE80211_QUEUE_STOP_REASON_CSA);
1655
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,
1664 + .block_tx = mode,
1665 + .chandef = new_chandef,
1666 + .count = count,
1667 };
1668
1669 - drv_channel_switch(sdata->local, &ch_switch);
1670 + drv_channel_switch(local, &ch_switch);
1671 return;
1672 }
1673
1674 /* channel switch handled in software */
1675 - if (sw_elem->count <= 1)
1676 - ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
1677 + if (count <= 1)
1678 + ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work);
1679 else
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));
1684 }
1685
1686 static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
1687 @@ -2120,7 +2215,6 @@ void ieee80211_beacon_loss(struct ieee80
1688
1689 trace_api_beacon_loss(sdata);
1690
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);
1694 }
1695 @@ -2170,7 +2264,7 @@ static void ieee80211_auth_challenge(str
1696 u32 tx_flags = 0;
1697
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)
1702 return;
1703 auth_data->expected_transaction = 4;
1704 @@ -2435,7 +2529,7 @@ static bool ieee80211_assoc_success(stru
1705 }
1706
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);
1710
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))));
1715
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);
1719
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;
1725
1726 + lockdep_assert_held(&sdata->u.mgd.mtx);
1727 +
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
1732 if (bss)
1733 ieee80211_rx_bss_put(local, bss);
1734
1735 - if (!sdata->u.mgd.associated)
1736 + if (!sdata->u.mgd.associated ||
1737 + !ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid))
1738 return;
1739
1740 if (need_ps) {
1741 @@ -2698,10 +2795,8 @@ static void ieee80211_rx_bss_info(struct
1742 mutex_unlock(&local->iflist_mtx);
1743 }
1744
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);
1750 +
1751 }
1752
1753
1754 @@ -2726,7 +2821,7 @@ static void ieee80211_rx_mgmt_probe_resp
1755 return;
1756
1757 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
1758 - &elems);
1759 + false, &elems);
1760
1761 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
1762
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);
1769
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
1773
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);
1779
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];
1784 u16 fc;
1785 + struct ieee802_11_elems elems;
1786 + int ies_len;
1787
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);
1792 break;
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);
1800 +
1801 + if (ies_len < 0)
1802 + break;
1803 +
1804 + ieee802_11_parse_elems(
1805 + mgmt->u.action.u.chan_switch.variable,
1806 + ies_len, true, &elems);
1807 +
1808 + if (elems.parse_error)
1809 + break;
1810 +
1811 ieee80211_sta_process_chanswitch(sdata,
1812 - &mgmt->u.action.u.chan_switch.sw_elem,
1813 - (void *)ifmgd->associated->priv,
1814 - rx_status->mactime);
1815 - break;
1816 + rx_status->mactime,
1817 + &elems);
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);
1822 +
1823 + if (ies_len < 0)
1824 + break;
1825 +
1826 + ieee802_11_parse_elems(
1827 + mgmt->u.action.u.ext_chan_switch.variable,
1828 + ies_len, true, &elems);
1829 +
1830 + if (elems.parse_error)
1831 + break;
1832 +
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;
1836 +
1837 + ieee80211_sta_process_chanswitch(sdata,
1838 + rx_status->mactime,
1839 + &elems);
1840 }
1841 + break;
1842 }
1843 mutex_unlock(&ifmgd->mtx);
1844
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);
1850
1851 - /* flush out all packets */
1852 - synchronize_net();
1853 + /* flush out all packets and station cleanup call_rcu()s */
1854 + rcu_barrier();
1855
1856 ieee80211_flush_queues(local, NULL);
1857
1858 --- a/net/mac80211/rate.c
1859 +++ b/net/mac80211/rate.c
1860 @@ -252,6 +252,25 @@ rate_lowest_non_cck_index(struct ieee802
1861 return 0;
1862 }
1863
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)
1868 +{
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);
1872 + else
1873 + info->control.rates[0].idx =
1874 + rate_lowest_non_cck_index(sband, sta);
1875 +
1876 + info->control.rates[0].count =
1877 + (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
1878 + 1 : hw->max_rate_tries;
1879 +
1880 + info->control.skip_table = 1;
1881 +}
1882 +
1883
1884 bool rate_control_send_low(struct ieee80211_sta *sta,
1885 void *priv_sta,
1886 @@ -262,16 +281,8 @@ bool rate_control_send_low(struct ieee80
1887 int mcast_rate;
1888
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);
1894 - else
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);
1901 +
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
1906
1907
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,
1912 u32 mask,
1913 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN])
1914 {
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,
1920 - mask)) {
1921 + sband->n_bitrates, mask)) {
1922 *rate = alt_rate;
1923 return;
1924 }
1925 } else {
1926 - struct sk_buff *skb = txrc->skb;
1927 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1928 - __le16 fc;
1929 -
1930 /* handle legacy rates */
1931 - if (rate_idx_match_legacy_mask(rate, txrc->sband->n_bitrates,
1932 - mask))
1933 + if (rate_idx_match_legacy_mask(rate, sband->n_bitrates, mask))
1934 return;
1935
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)
1938 - return;
1939 -
1940 - fc = hdr->frame_control;
1941 - if (!ieee80211_is_data(fc))
1942 + if (chan_width == NL80211_CHAN_WIDTH_20_NOHT)
1943 return;
1944
1945 alt_rate.idx = 0;
1946 @@ -408,7 +410,7 @@ static void rate_idx_match_mask(struct i
1947
1948 alt_rate.flags |= IEEE80211_TX_RC_MCS;
1949
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;
1953
1954 if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) {
1955 @@ -426,6 +428,228 @@ static void rate_idx_match_mask(struct i
1956 */
1957 }
1958
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,
1963 + int max_rates)
1964 +{
1965 + struct ieee80211_rate *rate;
1966 + bool inval = false;
1967 + int i;
1968 +
1969 + /*
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
1974 + *
1975 + * XXX: Should this check all retry rates?
1976 + */
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;
1980 +
1981 + rate = &sband->bitrates[rates[0].idx];
1982 +
1983 + for (i = 0; i < sband->n_bitrates; i++) {
1984 + /* must be a basic rate */
1985 + if (!(basic_rates & BIT(i)))
1986 + continue;
1987 + /* must not be faster than the data rate */
1988 + if (sband->bitrates[i].bitrate > rate->bitrate)
1989 + continue;
1990 + /* maximum */
1991 + if (sband->bitrates[baserate].bitrate <
1992 + sband->bitrates[i].bitrate)
1993 + baserate = i;
1994 + }
1995 +
1996 + info->control.rts_cts_rate_idx = baserate;
1997 + }
1998 +
1999 + for (i = 0; i < max_rates; i++) {
2000 + /*
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.
2004 + */
2005 + if (inval) {
2006 + rates[i].idx = -1;
2007 + continue;
2008 + }
2009 + if (rates[i].idx < 0) {
2010 + inval = true;
2011 + continue;
2012 + }
2013 +
2014 + /*
2015 + * For now assume MCS is already set up correctly, this
2016 + * needs to be fixed.
2017 + */
2018 + if (rates[i].flags & IEEE80211_TX_RC_MCS) {
2019 + WARN_ON(rates[i].idx > 76);
2020 +
2021 + if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
2022 + info->control.use_cts_prot)
2023 + rates[i].flags |=
2024 + IEEE80211_TX_RC_USE_CTS_PROTECT;
2025 + continue;
2026 + }
2027 +
2028 + if (rates[i].flags & IEEE80211_TX_RC_VHT_MCS) {
2029 + WARN_ON(ieee80211_rate_get_vht_mcs(&rates[i]) > 9);
2030 + continue;
2031 + }
2032 +
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;
2037 + }
2038 +
2039 + /* RC is busted */
2040 + if (WARN_ON_ONCE(rates[i].idx >= sband->n_bitrates)) {
2041 + rates[i].idx = -1;
2042 + continue;
2043 + }
2044 +
2045 + rate = &sband->bitrates[rates[i].idx];
2046 +
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;
2051 +
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;
2057 + }
2058 +}
2059 +
2060 +
2061 +static void rate_control_fill_sta_table(struct ieee80211_sta *sta,
2062 + struct ieee80211_tx_info *info,
2063 + struct ieee80211_tx_rate *rates,
2064 + int max_rates)
2065 +{
2066 + struct ieee80211_sta_rates *ratetbl = NULL;
2067 + int i;
2068 +
2069 + if (sta && !info->control.skip_table)
2070 + ratetbl = rcu_dereference(sta->rates);
2071 +
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;
2087 + else
2088 + rates[i].count = ratetbl->rate[i].count;
2089 + } else {
2090 + rates[i].idx = -1;
2091 + rates[i].count = 0;
2092 + }
2093 +
2094 + if (rates[i].idx < 0 || !rates[i].count)
2095 + break;
2096 + }
2097 +}
2098 +
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,
2104 + int max_rates)
2105 +{
2106 + enum nl80211_chan_width chan_width;
2107 + u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
2108 + bool has_mcs_mask;
2109 + u32 mask;
2110 + int i;
2111 +
2112 + /*
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.
2116 + */
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)
2120 + return;
2121 +
2122 + if (has_mcs_mask)
2123 + memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
2124 + sizeof(mcs_mask));
2125 + else
2126 + memset(mcs_mask, 0xff, sizeof(mcs_mask));
2127 +
2128 + if (sta) {
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];
2133 + }
2134 +
2135 + /*
2136 + * Make sure the rate index selected for each TX rate is
2137 + * included in the configured mask and change the rate indexes
2138 + * if needed.
2139 + */
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)
2144 + break;
2145 +
2146 + rate_idx_match_mask(&rates[i], sband, mask, chan_width,
2147 + mcs_mask);
2148 + }
2149 +}
2150 +
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,
2155 + int max_rates)
2156 +{
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;
2161 +
2162 + rate_control_fill_sta_table(sta, info, dest, max_rates);
2163 +
2164 + if (!vif)
2165 + return;
2166 +
2167 + sdata = vif_to_sdata(vif);
2168 + sband = sdata->local->hw.wiphy->bands[info->band];
2169 +
2170 + if (ieee80211_is_data(hdr->frame_control))
2171 + rate_control_apply_mask(sdata, sta, sband, info, dest, max_rates);
2172 +
2173 + if (dest[0].idx < 0)
2174 + __rate_control_send_low(&sdata->local->hw, sband, sta, info);
2175 +
2176 + if (sta)
2177 + rate_fixup_ratelist(vif, sband, info, dest, max_rates);
2178 +}
2179 +EXPORT_SYMBOL(ieee80211_get_tx_rates);
2180 +
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);
2187 int i;
2188 - u32 mask;
2189 - u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
2190
2191 if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
2192 ista = &sta->sta;
2193 @@ -454,37 +676,27 @@ void rate_control_get_rate(struct ieee80
2194
2195 ref->ops->get_rate(ref->priv, ista, priv_sta, txrc);
2196
2197 - /*
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.
2201 - */
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) {
2206 - if (sta) {
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];
2211 - }
2212 - /*
2213 - * Make sure the rate index selected for each TX rate is
2214 - * included in the configured mask and change the rate indexes
2215 - * if needed.
2216 - */
2217 - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
2218 - /* Skip invalid rates */
2219 - if (info->control.rates[i].idx < 0)
2220 - break;
2221 - rate_idx_match_mask(&info->control.rates[i], txrc,
2222 - mask, mcs_mask);
2223 - }
2224 - }
2225 + if (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_RC_TABLE)
2226 + return;
2227
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));
2232 +}
2233 +
2234 +int rate_control_set_rates(struct ieee80211_hw *hw,
2235 + struct ieee80211_sta *pubsta,
2236 + struct ieee80211_sta_rates *rates)
2237 +{
2238 + struct ieee80211_sta_rates *old = rcu_dereference(pubsta->rates);
2239 +
2240 + rcu_assign_pointer(pubsta->rates, rates);
2241 + if (old)
2242 + kfree_rcu(old, rcu_head);
2243 +
2244 + return 0;
2245 }
2246 +EXPORT_SYMBOL(rate_control_set_rates);
2247
2248 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
2249 const char *name)
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
2253 }
2254
2255 static void
2256 +minstrel_set_rate(struct minstrel_sta_info *mi, struct ieee80211_sta_rates *ratetbl,
2257 + int offset, int idx)
2258 +{
2259 + struct minstrel_rate *r = &mi->r[idx];
2260 +
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;
2265 +}
2266 +
2267 +static void
2268 +minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
2269 +{
2270 + struct ieee80211_sta_rates *ratetbl;
2271 + int i = 0;
2272 +
2273 + ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC);
2274 + if (!ratetbl)
2275 + return;
2276 +
2277 + /* Start with max_tp_rate */
2278 + minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[0]);
2279 +
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]);
2283 + }
2284 +
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);
2288 + }
2289 +
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;
2295 +
2296 + rate_control_set_rates(mp->hw, mi->sta, ratetbl);
2297 +}
2298 +
2299 +static void
2300 minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
2301 {
2302 u8 tmp_tp_rate[MAX_THR_RATES];
2303 @@ -161,6 +205,8 @@ minstrel_update_stats(struct minstrel_pr
2304
2305 /* Reset update timer */
2306 mi->stats_update = jiffies;
2307 +
2308 + minstrel_update_rates(mp, mi);
2309 }
2310
2311 static void
2312 @@ -209,9 +255,9 @@ minstrel_get_retry_count(struct minstrel
2313 {
2314 unsigned int retry = mr->adjusted_retry_count;
2315
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));
2322 return retry;
2323 }
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;
2332 + unsigned int ndx;
2333 bool mrr_capable;
2334 - bool indirect_rate_sampling = false;
2335 - bool rate_sampling = false;
2336 - int i, delta;
2337 - int mrr_ndx[3];
2338 + bool prev_sample = mi->prev_sample;
2339 + int delta;
2340 int sampling_ratio;
2341
2342 /* management/no-ack frames do not use rate control */
2343 @@ -262,107 +307,75 @@ minstrel_get_rate(void *priv, struct iee
2344 else
2345 sampling_ratio = mp->lookaround_rate;
2346
2347 - /* init rateindex [ndx] with max throughput rate */
2348 - ndx = mi->max_tp_rate[0];
2349 -
2350 /* increase sum packet counter */
2351 mi->packet_count++;
2352
2353 delta = (mi->packet_count * sampling_ratio / 100) -
2354 (mi->sample_count + mi->sample_deferred / 2);
2355
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.
2368 - *
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);
2374 - }
2375 + /* delta < 0: no sampling required */
2376 + mi->prev_sample = false;
2377 + if (delta < 0 || (!mrr_capable && prev_sample))
2378 + return;
2379
2380 - /* get next random rate sample */
2381 - sample_ndx = minstrel_get_next_sample(mi);
2382 - msr = &mi->r[sample_ndx];
2383 - rate_sampling = true;
2384 -
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.
2388 - */
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;
2393 -
2394 - if (!indirect_rate_sampling) {
2395 - if (msr->sample_limit != 0) {
2396 - ndx = sample_ndx;
2397 - mi->sample_count++;
2398 - if (msr->sample_limit > 0)
2399 - msr->sample_limit--;
2400 - } else
2401 - rate_sampling = false;
2402 - } else {
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++;
2411 - }
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.
2421 + *
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);
2427 + }
2428 +
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]];
2433 +
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.
2437 + */
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;
2448 + rate++;
2449 + mi->sample_deferred++;
2450 + } else {
2451 + if (!msr->sample_limit != 0)
2452 + return;
2453 +
2454 + mi->sample_count++;
2455 + if (msr->sample_limit > 0)
2456 + msr->sample_limit--;
2457 }
2458 - mi->prev_sample = rate_sampling;
2459
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];
2467 -
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);
2471 -
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;
2478 return;
2479 - }
2480
2481 - /* mrr setup for 2nd stage */
2482 - if (rate_sampling) {
2483 - if (indirect_rate_sampling)
2484 - mrr_ndx[0] = sample_ndx;
2485 - else
2486 - mrr_ndx[0] = mi->max_tp_rate[0];
2487 - } else {
2488 - mrr_ndx[0] = mi->max_tp_rate[1];
2489 - }
2490 + mi->prev_sample = true;
2491
2492 - /* mrr setup for 3rd & 4th stage */
2493 - mrr_ndx[1] = mi->max_prob_rate;
2494 - mrr_ndx[2] = 0;
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;
2498 - }
2499 + rate->idx = mi->r[ndx].rix;
2500 + rate->count = minstrel_get_retry_count(&mi->r[ndx], info);
2501 }
2502
2503
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 */
2507
2508 + mi->sta = sta;
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,
2512 ctl_rate->bitrate,
2513 !!(ctl_rate->flags & IEEE80211_RATE_ERP_G), 1);
2514
2515 + memset(mi->max_tp_rate, 0, sizeof(mi->max_tp_rate));
2516 + mi->max_prob_rate = 0;
2517 +
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;
2527 }
2528
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;
2532
2533 init_sample_table(mi);
2534 + minstrel_update_rates(mp, mi);
2535 }
2536
2537 static void *
2538 --- a/net/mac80211/rc80211_minstrel.h
2539 +++ b/net/mac80211/rc80211_minstrel.h
2540 @@ -9,7 +9,8 @@
2541 #ifndef __RC_MINSTREL_H
2542 #define __RC_MINSTREL_H
2543
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 */
2548
2549
2550 @@ -27,7 +28,7 @@
2551 static inline int
2552 minstrel_ewma(int old, int new, int weight)
2553 {
2554 - return (new * (100 - weight) + old * weight) / 100;
2555 + return (new * (EWMA_DIV - weight) + old * weight) / EWMA_DIV;
2556 }
2557
2558
2559 @@ -62,6 +63,8 @@ struct minstrel_rate {
2560 };
2561
2562 struct minstrel_sta_info {
2563 + struct ieee80211_sta *sta;
2564 +
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,
2571
2572 file->private_data = ms;
2573 p = ms->buf;
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);
2581
2582 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u "
2583 - "%3u(%3u) %8llu %8llu\n",
2584 + " %3u(%3u) %8llu %8llu\n",
2585 tp / 10, tp % 10,
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
2591
2592 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
2593
2594 +static void
2595 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);
2596 +
2597 /*
2598 * Look up an MCS group index based on mac80211 rate information
2599 */
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;
2605
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
2609
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;
2615
2616 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
2617 + bool mg_rates_valid = false;
2618 +
2619 cur_prob = 0;
2620 cur_prob_tp = 0;
2621 cur_tp = 0;
2622 @@ -268,15 +271,24 @@ minstrel_ht_update_stats(struct minstrel
2623 if (!mg->supported)
2624 continue;
2625
2626 - mg->max_tp_rate = 0;
2627 - mg->max_tp_rate2 = 0;
2628 - mg->max_prob_rate = 0;
2629 mi->sample_count++;
2630
2631 for (i = 0; i < MCS_GROUP_RATES; i++) {
2632 if (!(mg->supported & BIT(i)))
2633 continue;
2634
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;
2643 + }
2644 + mg_rates_valid = true;
2645 + }
2646 +
2647 mr = &mg->rates[i];
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;
2654 - bool last;
2655 + bool last, update = false;
2656 int i;
2657
2658 if (!msp->is_ht)
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);
2666 + update = true;
2667 + }
2668
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);
2675 + update = true;
2676 + }
2677
2678 if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
2679 + update = true;
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);
2684 }
2685 +
2686 + if (update)
2687 + minstrel_ht_update_rates(mp, mi);
2688 }
2689
2690 static void
2691 @@ -580,39 +600,73 @@ minstrel_calc_retransmit(struct minstrel
2692 (++mr->retry_count < mp->max_retry));
2693 }
2694
2695 -
2696 static void
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)
2701 {
2702 const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
2703 struct minstrel_rate_stats *mr;
2704 + u8 idx;
2705 + u16 flags;
2706
2707 mr = minstrel_get_ratestats(mi, index);
2708 if (!mr->retry_updated)
2709 minstrel_calc_retransmit(mp, mi, index);
2710
2711 - if (sample)
2712 - rate->count = 1;
2713 - else if (mr->probability < MINSTREL_FRAC(20, 100))
2714 - rate->count = 2;
2715 - else if (rtscts)
2716 - rate->count = mr->retry_count_rtscts;
2717 - else
2718 - rate->count = mr->retry_count;
2719 -
2720 - rate->flags = 0;
2721 - if (rtscts)
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;
2727 + } else {
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;
2731 + }
2732
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)];
2736 + flags = 0;
2737 + } else {
2738 + idx = index % MCS_GROUP_RATES +
2739 + (group->streams - 1) * MCS_GROUP_RATES;
2740 + flags = IEEE80211_TX_RC_MCS | group->flags;
2741 + }
2742 +
2743 + if (offset > 0) {
2744 + ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
2745 + flags |= IEEE80211_TX_RC_USE_RTS_CTS;
2746 + }
2747 +
2748 + ratetbl->rate[offset].idx = idx;
2749 + ratetbl->rate[offset].flags = flags;
2750 +}
2751 +
2752 +static void
2753 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
2754 +{
2755 + struct ieee80211_sta_rates *rates;
2756 + int i = 0;
2757 +
2758 + rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
2759 + if (!rates)
2760 return;
2761 +
2762 + /* Start with max_tp_rate */
2763 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate);
2764 +
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);
2768 + }
2769 +
2770 + if (mp->hw->max_rates >= 2) {
2771 + /*
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);
2774 }
2775
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);
2780 }
2781
2782 static inline int
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)
2786 {
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;
2794 int sample_idx;
2795 - bool sample = false;
2796
2797 if (rate_control_send_low(sta, priv_sta, txrc))
2798 return;
2799 @@ -736,51 +790,6 @@ minstrel_ht_get_rate(void *priv, struct
2800 }
2801 #endif
2802
2803 - if (sample_idx >= 0) {
2804 - sample = true;
2805 - minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx,
2806 - true, false);
2807 - info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
2808 - } else {
2809 - minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate,
2810 - false, false);
2811 - }
2812 -
2813 - if (mp->hw->max_rates >= 3) {
2814 - /*
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.
2818 - */
2819 - if (sample_idx >= 0)
2820 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate,
2821 - false, false);
2822 - else
2823 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2,
2824 - false, true);
2825 -
2826 - minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate,
2827 - false, !sample);
2828 -
2829 - ar[3].count = 0;
2830 - ar[3].idx = -1;
2831 - } else if (mp->hw->max_rates == 2) {
2832 - /*
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.
2836 - */
2837 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_prob_rate,
2838 - false, !sample);
2839 -
2840 - ar[2].count = 0;
2841 - ar[2].idx = -1;
2842 - } else {
2843 - /* Not using MRR, only use the first rate */
2844 - ar[1].count = 0;
2845 - ar[1].idx = -1;
2846 - }
2847 -
2848 mi->total_packets++;
2849
2850 /* wraparound */
2851 @@ -788,6 +797,16 @@ minstrel_ht_get_rate(void *priv, struct
2852 mi->total_packets = 0;
2853 mi->sample_packets = 0;
2854 }
2855 +
2856 + if (sample_idx < 0)
2857 + return;
2858 +
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;
2864 + rate->count = 1;
2865 }
2866
2867 static void
2868 @@ -837,6 +856,8 @@ minstrel_ht_update_caps(void *priv, stru
2869
2870 msp->is_ht = true;
2871 memset(mi, 0, sizeof(*mi));
2872 +
2873 + mi->sta = sta;
2874 mi->stats_update = jiffies;
2875
2876 ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1);
2877 @@ -898,6 +919,9 @@ minstrel_ht_update_caps(void *priv, stru
2878 if (!n_supported)
2879 goto use_legacy;
2880
2881 + minstrel_ht_update_stats(mp, mi);
2882 + minstrel_ht_update_rates(mp, mi);
2883 +
2884 return;
2885
2886 use_legacy:
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 {
2890 };
2891
2892 struct minstrel_ht_sta {
2893 + struct ieee80211_sta *sta;
2894 +
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;
2904 + int i;
2905
2906 if (!sta)
2907 return RX_CONTINUE;
2908 @@ -1422,6 +1423,19 @@ ieee80211_rx_h_sta_process(struct ieee80
2909 ewma_add(&sta->avg_signal, -status->signal);
2910 }
2911
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];
2916 +
2917 + if (!(status->chains & BIT(i)))
2918 + continue;
2919 +
2920 + sta->chain_signal_last[i] = signal;
2921 + ewma_add(&sta->chain_signal_avg[i], -signal);
2922 + }
2923 + }
2924 +
2925 /*
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
2929 }
2930
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)
2942 break;
2943
2944 @@ -2423,6 +2439,22 @@ ieee80211_rx_h_action(struct ieee80211_r
2945 }
2946
2947 break;
2948 + case WLAN_CATEGORY_PUBLIC:
2949 + if (len < IEEE80211_MIN_ACTION_SIZE + 1)
2950 + goto invalid;
2951 + if (sdata->vif.type != NL80211_IFTYPE_STATION)
2952 + break;
2953 + if (!rx->sta)
2954 + break;
2955 + if (!ether_addr_equal(mgmt->bssid, sdata->u.mgd.bssid))
2956 + break;
2957 + if (mgmt->u.action.u.ext_chan_switch.action_code !=
2958 + WLAN_PUB_ACTION_EXT_CHANSW_ANN)
2959 + break;
2960 + if (len < offsetof(struct ieee80211_mgmt,
2961 + u.action.u.ext_chan_switch.variable))
2962 + goto invalid;
2963 + goto queue;
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);
2969 goto handled;
2970 case WLAN_ACTION_SPCT_CHL_SWITCH:
2971 - if (len < (IEEE80211_MIN_ACTION_SIZE +
2972 - sizeof(mgmt->u.action.u.chan_switch)))
2973 - break;
2974 -
2975 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2976 break;
2977
2978 @@ -2695,14 +2723,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
2979
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;
2986
2987 switch (stype) {
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 */
2993 break;
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
2997 }
2998 break;
2999 case NL80211_IFTYPE_WDS:
3000 - if (bssid || !ieee80211_is_data(hdr->frame_control))
3001 - return 0;
3002 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
3003 return 0;
3004 +
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))
3008 + return 0;
3009 + } else if (!ieee80211_is_beacon(hdr->frame_control))
3010 + return 0;
3011 +
3012 break;
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)
3019 return;
3020
3021 - ieee802_11_parse_elems(elements, skb->len - baselen, &elems);
3022 + ieee802_11_parse_elems(elements, skb->len - baselen, false, &elems);
3023
3024 channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq);
3025
3026 --- a/net/mac80211/sta_info.h
3027 +++ b/net/mac80211/sta_info.h
3028 @@ -32,7 +32,6 @@
3029 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
3030 * frames.
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,
3039 WLAN_STA_WME,
3040 - WLAN_STA_WDS,
3041 WLAN_STA_CLEAR_PS_FILT,
3042 WLAN_STA_MFP,
3043 WLAN_STA_BLOCK_BA,
3044 @@ -344,6 +342,11 @@ struct sta_info {
3045 int last_signal;
3046 struct ewma avg_signal;
3047 int last_ack_signal;
3048 +
3049 + u8 chains;
3050 + s8 chain_signal_last[IEEE80211_MAX_CHAINS];
3051 + struct ewma chain_signal_avg[IEEE80211_MAX_CHAINS];
3052 +
3053 /* Plus 1 for non-QoS frames */
3054 __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
3055
3056 --- a/net/mac80211/trace.h
3057 +++ b/net/mac80211/trace.h
3058 @@ -990,23 +990,23 @@ TRACE_EVENT(drv_channel_switch,
3059
3060 TP_STRUCT__entry(
3061 LOCAL_ENTRY
3062 + CHANDEF_ENTRY
3063 __field(u64, timestamp)
3064 __field(bool, block_tx)
3065 - __field(u16, freq)
3066 __field(u8, count)
3067 ),
3068
3069 TP_fast_assign(
3070 LOCAL_ASSIGN;
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;
3076 ),
3077
3078 TP_printk(
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
3083 )
3084 );
3085
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);
3090
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)
3094 return 0;
3095
3096 /* uh huh? */
3097 - if (WARN_ON_ONCE(info->control.rates[0].idx < 0))
3098 + if (WARN_ON_ONCE(tx->rate.idx < 0))
3099 return 0;
3100
3101 sband = local->hw.wiphy->bands[info->band];
3102 - txrate = &sband->bitrates[info->control.rates[0].idx];
3103 + txrate = &sband->bitrates[tx->rate.idx];
3104
3105 erp = txrate->flags & IEEE80211_RATE_ERP_G;
3106
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;
3112 - int i;
3113 u32 len;
3114 - bool inval = false, rts = false, short_preamble = false;
3115 struct ieee80211_tx_rate_control txrc;
3116 + struct ieee80211_sta_rates *ratetbl = NULL;
3117 bool assoc = false;
3118
3119 memset(&txrc, 0, sizeof(txrc));
3120 @@ -642,18 +640,23 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3121 txrc.max_rate_idx = -1;
3122 else
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));
3127 +
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];
3131 +
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);
3135
3136 /* set up RTS protection if desired */
3137 if (len > tx->local->hw.wiphy->rts_threshold) {
3138 - txrc.rts = rts = true;
3139 + txrc.rts = true;
3140 }
3141
3142 + info->control.use_rts = txrc.rts;
3143 + info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot;
3144 +
3145 /*
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;
3154 +
3155 + info->control.short_preamble = txrc.short_preamble;
3156
3157 if (tx->sta)
3158 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC);
3159 @@ -687,16 +692,38 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3160 */
3161 rate_control_get_rate(tx->sdata, tx->sta, &txrc);
3162
3163 - if (unlikely(info->control.rates[0].idx < 0))
3164 - return TX_DROP;
3165 + if (tx->sta && !info->control.skip_table)
3166 + ratetbl = rcu_dereference(tx->sta->sta.rates);
3167 +
3168 + if (unlikely(info->control.rates[0].idx < 0)) {
3169 + if (ratetbl) {
3170 + struct ieee80211_tx_rate rate = {
3171 + .idx = ratetbl->rate[0].idx,
3172 + .flags = ratetbl->rate[0].flags,
3173 + .count = ratetbl->rate[0].count
3174 + };
3175 +
3176 + if (ratetbl->rate[0].idx < 0)
3177 + return TX_DROP;
3178 +
3179 + tx->rate = rate;
3180 + } else {
3181 + return TX_DROP;
3182 + }
3183 + } else {
3184 + tx->rate = info->control.rates[0];
3185 + }
3186
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;
3192 } else if (tx->sta)
3193 tx->sta->last_tx_rate = txrc.reported_rate;
3194
3195 + if (ratetbl)
3196 + return TX_CONTINUE;
3197 +
3198 if (unlikely(!info->control.rates[0].count))
3199 info->control.rates[0].count = 1;
3200
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;
3204
3205 - if (is_multicast_ether_addr(hdr->addr1)) {
3206 - /*
3207 - * XXX: verify the rate is in the basic rateset
3208 - */
3209 - return TX_CONTINUE;
3210 - }
3211 -
3212 - /*
3213 - * set up the RTS/CTS rate as the fastest basic rate
3214 - * that is not faster than the data rate
3215 - *
3216 - * XXX: Should this check all retry rates?
3217 - */
3218 - if (!(info->control.rates[0].flags & IEEE80211_TX_RC_MCS)) {
3219 - s8 baserate = 0;
3220 -
3221 - rate = &sband->bitrates[info->control.rates[0].idx];
3222 -
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)))
3226 - continue;
3227 - /* must not be faster than the data rate */
3228 - if (sband->bitrates[i].bitrate > rate->bitrate)
3229 - continue;
3230 - /* maximum */
3231 - if (sband->bitrates[baserate].bitrate <
3232 - sband->bitrates[i].bitrate)
3233 - baserate = i;
3234 - }
3235 -
3236 - info->control.rts_cts_rate_idx = baserate;
3237 - }
3238 -
3239 - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
3240 - /*
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.
3244 - */
3245 - if (inval) {
3246 - info->control.rates[i].idx = -1;
3247 - continue;
3248 - }
3249 - if (info->control.rates[i].idx < 0) {
3250 - inval = true;
3251 - continue;
3252 - }
3253 -
3254 - /*
3255 - * For now assume MCS is already set up correctly, this
3256 - * needs to be fixed.
3257 - */
3258 - if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) {
3259 - WARN_ON(info->control.rates[i].idx > 76);
3260 - continue;
3261 - }
3262 -
3263 - /* set up RTS protection if desired */
3264 - if (rts)
3265 - info->control.rates[i].flags |=
3266 - IEEE80211_TX_RC_USE_RTS_CTS;
3267 -
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;
3272 - continue;
3273 - }
3274 -
3275 - rate = &sband->bitrates[info->control.rates[i].idx];
3276 -
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;
3282 -
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;
3288 - }
3289 -
3290 return TX_CONTINUE;
3291 }
3292
3293 @@ -2508,8 +2450,6 @@ struct sk_buff *ieee80211_beacon_get_tim
3294 txrc.max_rate_idx = -1;
3295 else
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));
3299 txrc.bss = true;
3300 rate_control_get_rate(sdata, NULL, &txrc);
3301
3302 --- a/net/mac80211/util.c
3303 +++ b/net/mac80211/util.c
3304 @@ -485,7 +485,8 @@ int ieee80211_queue_stopped(struct ieee8
3305 return true;
3306
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);
3312 return ret;
3313 }
3314 @@ -660,7 +661,7 @@ void ieee80211_queue_delayed_work(struct
3315 }
3316 EXPORT_SYMBOL(ieee80211_queue_delayed_work);
3317
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)
3322 {
3323 @@ -668,6 +669,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start
3324 u8 *pos = start;
3325 bool calc_crc = filter != 0;
3326 DECLARE_BITMAP(seen_elems, 256);
3327 + const u8 *ie;
3328
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:
3337 + /*
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
3340 + */
3341 if (test_bit(id, seen_elems)) {
3342 elems->parse_error = true;
3343 left -= elen;
3344 @@ -862,6 +870,48 @@ u32 ieee802_11_parse_elems_crc(u8 *start
3345 }
3346 elems->ch_switch_ie = (void *)pos;
3347 break;
3348 + case WLAN_EID_EXT_CHANSWITCH_ANN:
3349 + if (elen != sizeof(struct ieee80211_ext_chansw_ie)) {
3350 + elem_parse_failed = true;
3351 + break;
3352 + }
3353 + elems->ext_chansw_ie = (void *)pos;
3354 + break;
3355 + case WLAN_EID_SECONDARY_CHANNEL_OFFSET:
3356 + if (elen != sizeof(struct ieee80211_sec_chan_offs_ie)) {
3357 + elem_parse_failed = true;
3358 + break;
3359 + }
3360 + elems->sec_chan_offs = (void *)pos;
3361 + break;
3362 + case WLAN_EID_WIDE_BW_CHANNEL_SWITCH:
3363 + if (!action ||
3364 + elen != sizeof(*elems->wide_bw_chansw_ie)) {
3365 + elem_parse_failed = true;
3366 + break;
3367 + }
3368 + elems->wide_bw_chansw_ie = (void *)pos;
3369 + break;
3370 + case WLAN_EID_CHANNEL_SWITCH_WRAPPER:
3371 + if (action) {
3372 + elem_parse_failed = true;
3373 + break;
3374 + }
3375 + /*
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.
3379 + */
3380 + ie = cfg80211_find_ie(WLAN_EID_WIDE_BW_CHANNEL_SWITCH,
3381 + pos, elen);
3382 + if (ie) {
3383 + if (ie[1] == sizeof(*elems->wide_bw_chansw_ie))
3384 + elems->wide_bw_chansw_ie =
3385 + (void *)(ie + 2);
3386 + else
3387 + elem_parse_failed = true;
3388 + }
3389 + break;
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
3396 return;
3397
3398 REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq);
3399 - chan->flags = IEEE80211_CHAN_DISABLED;
3400 + chan->flags |= IEEE80211_CHAN_DISABLED;
3401 return;
3402 }
3403
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,
3407 }
3408 EXPORT_SYMBOL(cfg80211_get_p2p_attr);
3409
3410 +bool ieee80211_operating_class_to_band(u8 operating_class,
3411 + enum ieee80211_band *band)
3412 +{
3413 + switch (operating_class) {
3414 + case 112:
3415 + case 115 ... 127:
3416 + *band = IEEE80211_BAND_5GHZ;
3417 + return true;
3418 + case 81:
3419 + case 82:
3420 + case 83:
3421 + case 84:
3422 + *band = IEEE80211_BAND_2GHZ;
3423 + return true;
3424 + }
3425 +
3426 + return false;
3427 +}
3428 +EXPORT_SYMBOL(ieee80211_operating_class_to_band);
3429 +
3430 int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
3431 u32 beacon_int)
3432 {
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
3438 * non-peer STA
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
3445 */
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,
3452
3453 /* keep last */
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);
3463
3464 if (sta_prepare_rate_control(local, sta, gfp)) {
3465 kfree(sta);
3466 --- a/net/wireless/nl80211.c
3467 +++ b/net/wireless/nl80211.c
3468 @@ -3367,6 +3367,32 @@ static bool nl80211_put_sta_rate(struct
3469 return true;
3470 }
3471
3472 +static bool nl80211_put_signal(struct sk_buff *msg, u8 mask, s8 *signal,
3473 + int id)
3474 +{
3475 + void *attr;
3476 + int i = 0;
3477 +
3478 + if (!mask)
3479 + return true;
3480 +
3481 + attr = nla_nest_start(msg, id);
3482 + if (!attr)
3483 + return false;
3484 +
3485 + for (i = 0; i < IEEE80211_MAX_CHAINS; i++) {
3486 + if (!(mask & BIT(i)))
3487 + continue;
3488 +
3489 + if (nla_put_u8(msg, i, signal[i]))
3490 + return false;
3491 + }
3492 +
3493 + nla_nest_end(msg, attr);
3494 +
3495 + return true;
3496 +}
3497 +
3498 static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq,
3499 int flags,
3500 struct cfg80211_registered_device *rdev,
3501 @@ -3438,6 +3464,18 @@ static int nl80211_send_station(struct s
3502 default:
3503 break;
3504 }
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;
3510 + }
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;
3516 + }
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;
3529
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);
3536 }
3537
3538 +static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
3539 + struct ath_buf *bf)
3540 +{
3541 + ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
3542 + ARRAY_SIZE(bf->rates));
3543 +}
3544 +
3545 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
3546 {
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);
3550 sendbar = true;
3551 } else {
3552 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
3553 ath_tx_send_normal(sc, txq, NULL, skb);
3554 }
3555 }
3556 @@ -407,7 +415,7 @@ static void ath_tx_complete_aggr(struct
3557
3558 tx_info = IEEE80211_SKB_CB(skb);
3559
3560 - memcpy(rates, tx_info->control.rates, sizeof(rates));
3561 + memcpy(rates, bf->rates, sizeof(rates));
3562
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
3566 bool first_subfrm)
3567 {
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;
3572 u16 minlen;
3573 u8 flags, rix;
3574 @@ -778,8 +784,8 @@ static int ath_compute_num_delims(struct
3575 if (tid->an->mpdudensity == 0)
3576 return ndelim;
3577
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;
3584
3585 @@ -858,6 +864,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_
3586 bf_first = bf;
3587
3588 if (!rl) {
3589 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
3590 aggr_limit = ath_lookup_rate(sc, bf, tid);
3591 rl = 1;
3592 }
3593 @@ -998,14 +1005,14 @@ static void ath_buf_set_rate(struct ath_
3594
3595 skb = bf->bf_mpdu;
3596 tx_info = IEEE80211_SKB_CB(skb);
3597 - rates = tx_info->control.rates;
3598 + rates = bf->rates;
3599 hdr = (struct ieee80211_hdr *)skb->data;
3600
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;
3604
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;
3608 int phy;
3609
3610 @@ -1743,6 +1750,7 @@ static void ath_tx_send_ampdu(struct ath
3611 return;
3612 }
3613
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
3619 return bf;
3620 }
3621
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)
3625 -{
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;
3630 - u8 tidno;
3631 -
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);
3636 -
3637 - WARN_ON(tid->ac->txq != txctl->txq);
3638 - }
3639 -
3640 - if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
3641 - /*
3642 - * Try aggregation if it's a unicast data frame
3643 - * and the destination is HT capable.
3644 - */
3645 - ath_tx_send_ampdu(sc, tid, skb, txctl);
3646 - } else {
3647 - bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb);
3648 - if (!bf) {
3649 - if (txctl->paprd)
3650 - dev_kfree_skb_any(skb);
3651 - else
3652 - ieee80211_free_txskb(sc->hw, skb);
3653 - return;
3654 - }
3655 -
3656 - bf->bf_state.bfs_paprd = txctl->paprd;
3657 -
3658 - if (txctl->paprd)
3659 - bf->bf_state.bfs_paprd_timestamp = jiffies;
3660 -
3661 - ath_tx_send_normal(sc, txctl->txq, tid, skb);
3662 - }
3663 -}
3664 -
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;
3676 + u8 tidno;
3677 int q;
3678
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;
3682 }
3683
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);
3689 +
3690 + WARN_ON(tid->ac->txq != txctl->txq);
3691 + }
3692 +
3693 + if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
3694 + /*
3695 + * Try aggregation if it's a unicast data frame
3696 + * and the destination is HT capable.
3697 + */
3698 + ath_tx_send_ampdu(sc, tid, skb, txctl);
3699 + goto out;
3700 + }
3701 +
3702 + bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb);
3703 + if (!bf) {
3704 + if (txctl->paprd)
3705 + dev_kfree_skb_any(skb);
3706 + else
3707 + ieee80211_free_txskb(sc->hw, skb);
3708 + goto out;
3709 + }
3710 +
3711 + bf->bf_state.bfs_paprd = txctl->paprd;
3712 +
3713 + if (txctl->paprd)
3714 + bf->bf_state.bfs_paprd_timestamp = jiffies;
3715 +
3716 + ath_set_rates(vif, sta, bf);
3717 + ath_tx_send_normal(sc, txctl->txq, tid, skb);
3718
3719 +out:
3720 ath_txq_unlock(sc, txq);
3721
3722 return 0;
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
3726
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);
3731
3732 return true;
3733 }
3734 @@ -155,7 +155,7 @@ static void ath_rx_remove_buffer(struct
3735
3736 rx_edma = &sc->rx.rx_edma[qtype];
3737
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);
3741 BUG_ON(!bf);
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;
3745 }
3746
3747 - bf->bf_mpdu = requeue_skb;
3748 - bf->bf_buf_addr = new_buf_addr;
3749 -
3750 /* Unmap the frame */
3751 dma_unmap_single(sc->dev, bf->bf_buf_addr,
3752 common->rx_bufsize, dma_type);
3753
3754 + bf->bf_mpdu = requeue_skb;
3755 + bf->bf_buf_addr = new_buf_addr;
3756 +
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);