46e539bebfe94093d4a90bd62592c16abb76d65d
[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 @@ -250,9 +251,9 @@ struct ath_atx_tid {
12 int tidno;
13 int baw_head; /* first un-acked tx buffer */
14 int baw_tail; /* next unused tx buffer slot */
15 - int sched;
16 - int paused;
17 - u8 state;
18 + bool sched;
19 + bool paused;
20 + bool active;
21 };
22
23 struct ath_node {
24 @@ -273,10 +274,6 @@ struct ath_node {
25 #endif
26 };
27
28 -#define AGGR_CLEANUP BIT(1)
29 -#define AGGR_ADDBA_COMPLETE BIT(2)
30 -#define AGGR_ADDBA_PROGRESS BIT(3)
31 -
32 struct ath_tx_control {
33 struct ath_txq *txq;
34 struct ath_node *an;
35 @@ -299,6 +296,7 @@ struct ath_tx {
36 struct ath_txq txq[ATH9K_NUM_TX_QUEUES];
37 struct ath_descdma txdma;
38 struct ath_txq *txq_map[IEEE80211_NUM_ACS];
39 + struct ath_txq *uapsdq;
40 u32 txq_max_pending[IEEE80211_NUM_ACS];
41 u16 max_aggr_framelen[IEEE80211_NUM_ACS][4][32];
42 };
43 @@ -356,6 +354,11 @@ void ath_tx_aggr_resume(struct ath_softc
44 void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an);
45 void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,
46 struct ath_node *an);
47 +void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
48 + struct ieee80211_sta *sta,
49 + u16 tids, int nframes,
50 + enum ieee80211_frame_release_type reason,
51 + bool more_data);
52
53 /********/
54 /* VIFs */
55 @@ -410,6 +413,7 @@ struct ath_beacon {
56 struct ath_descdma bdma;
57 struct ath_txq *cabq;
58 struct list_head bbuf;
59 + int cabq_dur;
60
61 bool tx_processed;
62 bool tx_last;
63 @@ -658,11 +662,10 @@ enum sc_op_flags {
64 struct ath_rate_table;
65
66 struct ath9k_vif_iter_data {
67 - const u8 *hw_macaddr; /* phy's hardware address, set
68 - * before starting iteration for
69 - * valid bssid mask.
70 - */
71 + u8 hw_macaddr[ETH_ALEN]; /* address of the first vif */
72 u8 mask[ETH_ALEN]; /* bssid mask */
73 + bool has_hw_macaddr;
74 +
75 int naps; /* number of AP vifs */
76 int nmeshes; /* number of mesh vifs */
77 int nstations; /* number of station vifs */
78 --- a/drivers/net/wireless/ath/ath9k/hw.c
79 +++ b/drivers/net/wireless/ath/ath9k/hw.c
80 @@ -1171,6 +1171,7 @@ u32 ath9k_regd_get_ctl(struct ath_regula
81 static inline void ath9k_hw_set_dma(struct ath_hw *ah)
82 {
83 struct ath_common *common = ath9k_hw_common(ah);
84 + int txbuf_size;
85
86 ENABLE_REGWRITE_BUFFER(ah);
87
88 @@ -1224,13 +1225,17 @@ static inline void ath9k_hw_set_dma(stru
89 * So set the usable tx buf size also to half to
90 * avoid data/delimiter underruns
91 */
92 - REG_WRITE(ah, AR_PCU_TXBUF_CTRL,
93 - AR_9285_PCU_TXBUF_CTRL_USABLE_SIZE);
94 - } else if (!AR_SREV_9271(ah)) {
95 - REG_WRITE(ah, AR_PCU_TXBUF_CTRL,
96 - AR_PCU_TXBUF_CTRL_USABLE_SIZE);
97 + txbuf_size = AR_9285_PCU_TXBUF_CTRL_USABLE_SIZE;
98 + } else if (AR_SREV_9340_13_OR_LATER(ah)) {
99 + /* Uses fewer entries for AR934x v1.3+ to prevent rx overruns */
100 + txbuf_size = AR_9340_PCU_TXBUF_CTRL_USABLE_SIZE;
101 + } else {
102 + txbuf_size = AR_PCU_TXBUF_CTRL_USABLE_SIZE;
103 }
104
105 + if (!AR_SREV_9271(ah))
106 + REG_WRITE(ah, AR_PCU_TXBUF_CTRL, txbuf_size);
107 +
108 REGWRITE_BUFFER_FLUSH(ah);
109
110 if (AR_SREV_9300_20_OR_LATER(ah))
111 @@ -1305,9 +1310,13 @@ static bool ath9k_hw_set_reset(struct at
112 AR_RTC_RC_COLD_RESET | AR_RTC_RC_WARM_RESET;
113 } else {
114 tmpReg = REG_READ(ah, AR_INTR_SYNC_CAUSE);
115 - if (tmpReg &
116 - (AR_INTR_SYNC_LOCAL_TIMEOUT |
117 - AR_INTR_SYNC_RADM_CPL_TIMEOUT)) {
118 + if (AR_SREV_9340(ah))
119 + tmpReg &= AR9340_INTR_SYNC_LOCAL_TIMEOUT;
120 + else
121 + tmpReg &= AR_INTR_SYNC_LOCAL_TIMEOUT |
122 + AR_INTR_SYNC_RADM_CPL_TIMEOUT;
123 +
124 + if (tmpReg) {
125 u32 val;
126 REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0);
127
128 @@ -1366,7 +1375,10 @@ static bool ath9k_hw_set_reset(struct at
129
130 REGWRITE_BUFFER_FLUSH(ah);
131
132 - udelay(50);
133 + if (AR_SREV_9100(ah))
134 + mdelay(10);
135 + else
136 + udelay(50);
137
138 REG_WRITE(ah, AR_RTC_RC, 0);
139 if (!ath9k_hw_wait(ah, AR_RTC_RC, AR_RTC_RC_M, 0, AH_WAIT_TIMEOUT)) {
140 @@ -1377,8 +1389,12 @@ static bool ath9k_hw_set_reset(struct at
141 if (!AR_SREV_9100(ah))
142 REG_WRITE(ah, AR_RC, 0);
143
144 - if (AR_SREV_9100(ah))
145 + if (AR_SREV_9100(ah) && type != ATH9K_RESET_WARM) {
146 + if (ah->external_reset)
147 + ah->external_reset();
148 +
149 udelay(50);
150 + }
151
152 return true;
153 }
154 @@ -1464,7 +1480,8 @@ static bool ath9k_hw_chip_reset(struct a
155 reset_type = ATH9K_RESET_POWER_ON;
156 else
157 reset_type = ATH9K_RESET_COLD;
158 - } else if (ah->chip_fullsleep || REG_READ(ah, AR_Q_TXE) ||
159 + } else if (ah->chip_fullsleep ||
160 + REG_READ(ah, AR_Q_TXE) ||
161 (REG_READ(ah, AR_CR) & AR_CR_RXE))
162 reset_type = ATH9K_RESET_COLD;
163
164 @@ -1698,12 +1715,11 @@ static void ath9k_hw_reset_opmode(struct
165
166 ENABLE_REGWRITE_BUFFER(ah);
167
168 - REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr));
169 - REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4)
170 - | macStaId1
171 + REG_RMW(ah, AR_STA_ID1, macStaId1
172 | AR_STA_ID1_RTS_USE_DEF
173 | (ah->config.ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0)
174 - | ah->sta_id1_defaults);
175 + | ah->sta_id1_defaults,
176 + ~AR_STA_ID1_SADH_MASK);
177 ath_hw_setbssidmask(common);
178 REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna);
179 ath9k_hw_write_associd(ah);
180 --- a/drivers/net/wireless/ath/ath9k/main.c
181 +++ b/drivers/net/wireless/ath/ath9k/main.c
182 @@ -839,10 +839,14 @@ static void ath9k_vif_iter(void *data, u
183 struct ath9k_vif_iter_data *iter_data = data;
184 int i;
185
186 - if (iter_data->hw_macaddr)
187 + if (iter_data->has_hw_macaddr) {
188 for (i = 0; i < ETH_ALEN; i++)
189 iter_data->mask[i] &=
190 ~(iter_data->hw_macaddr[i] ^ mac[i]);
191 + } else {
192 + memcpy(iter_data->hw_macaddr, mac, ETH_ALEN);
193 + iter_data->has_hw_macaddr = true;
194 + }
195
196 switch (vif->type) {
197 case NL80211_IFTYPE_AP:
198 @@ -891,7 +895,6 @@ void ath9k_calculate_iter_data(struct ie
199 * together with the BSSID mask when matching addresses.
200 */
201 memset(iter_data, 0, sizeof(*iter_data));
202 - iter_data->hw_macaddr = common->macaddr;
203 memset(&iter_data->mask, 0xff, ETH_ALEN);
204
205 if (vif)
206 @@ -901,6 +904,8 @@ void ath9k_calculate_iter_data(struct ie
207 ieee80211_iterate_active_interfaces_atomic(
208 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
209 ath9k_vif_iter, iter_data);
210 +
211 + memcpy(common->macaddr, iter_data->hw_macaddr, ETH_ALEN);
212 }
213
214 /* Called with sc->mutex held. */
215 @@ -1327,6 +1332,7 @@ static int ath9k_sta_add(struct ieee8021
216 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
217 struct ath_node *an = (struct ath_node *) sta->drv_priv;
218 struct ieee80211_key_conf ps_key = { };
219 + int key;
220
221 ath_node_attach(sc, sta, vif);
222
223 @@ -1334,7 +1340,9 @@ static int ath9k_sta_add(struct ieee8021
224 vif->type != NL80211_IFTYPE_AP_VLAN)
225 return 0;
226
227 - an->ps_key = ath_key_config(common, vif, sta, &ps_key);
228 + key = ath_key_config(common, vif, sta, &ps_key);
229 + if (key > 0)
230 + an->ps_key = key;
231
232 return 0;
233 }
234 @@ -1351,6 +1359,7 @@ static void ath9k_del_ps_key(struct ath_
235 return;
236
237 ath_key_delete(common, &ps_key);
238 + an->ps_key = 0;
239 }
240
241 static int ath9k_sta_remove(struct ieee80211_hw *hw,
242 @@ -1678,6 +1687,7 @@ static int ath9k_ampdu_action(struct iee
243 u16 tid, u16 *ssn, u8 buf_size)
244 {
245 struct ath_softc *sc = hw->priv;
246 + bool flush = false;
247 int ret = 0;
248
249 local_bh_disable();
250 @@ -1694,12 +1704,14 @@ static int ath9k_ampdu_action(struct iee
251 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
252 ath9k_ps_restore(sc);
253 break;
254 - case IEEE80211_AMPDU_TX_STOP_CONT:
255 case IEEE80211_AMPDU_TX_STOP_FLUSH:
256 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
257 + flush = true;
258 + case IEEE80211_AMPDU_TX_STOP_CONT:
259 ath9k_ps_wakeup(sc);
260 ath_tx_aggr_stop(sc, sta, tid);
261 - ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
262 + if (!flush)
263 + ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
264 ath9k_ps_restore(sc);
265 break;
266 case IEEE80211_AMPDU_TX_OPERATIONAL:
267 @@ -2366,6 +2378,7 @@ struct ieee80211_ops ath9k_ops = {
268 .flush = ath9k_flush,
269 .tx_frames_pending = ath9k_tx_frames_pending,
270 .tx_last_beacon = ath9k_tx_last_beacon,
271 + .release_buffered_frames = ath9k_release_buffered_frames,
272 .get_stats = ath9k_get_stats,
273 .set_antenna = ath9k_set_antenna,
274 .get_antenna = ath9k_get_antenna,
275 --- a/drivers/net/wireless/ath/ath9k/reg.h
276 +++ b/drivers/net/wireless/ath/ath9k/reg.h
277 @@ -798,6 +798,10 @@
278 #define AR_SREV_REVISION_9485_10 0
279 #define AR_SREV_REVISION_9485_11 1
280 #define AR_SREV_VERSION_9340 0x300
281 +#define AR_SREV_REVISION_9340_10 0
282 +#define AR_SREV_REVISION_9340_11 1
283 +#define AR_SREV_REVISION_9340_12 2
284 +#define AR_SREV_REVISION_9340_13 3
285 #define AR_SREV_VERSION_9580 0x1C0
286 #define AR_SREV_REVISION_9580_10 4 /* AR9580 1.0 */
287 #define AR_SREV_VERSION_9462 0x280
288 @@ -897,6 +901,10 @@
289 #define AR_SREV_9340(_ah) \
290 (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9340))
291
292 +#define AR_SREV_9340_13_OR_LATER(_ah) \
293 + (AR_SREV_9340((_ah)) && \
294 + ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9340_13))
295 +
296 #define AR_SREV_9285E_20(_ah) \
297 (AR_SREV_9285_12_OR_LATER(_ah) && \
298 ((REG_READ(_ah, AR_AN_SYNTH9) & 0x7) == 0x1))
299 @@ -1007,6 +1015,8 @@ enum {
300 AR_INTR_SYNC_LOCAL_TIMEOUT |
301 AR_INTR_SYNC_MAC_SLEEP_ACCESS),
302
303 + AR9340_INTR_SYNC_LOCAL_TIMEOUT = 0x00000010,
304 +
305 AR_INTR_SYNC_SPURIOUS = 0xFFFFFFFF,
306
307 };
308 @@ -1493,9 +1503,6 @@ enum {
309 #define AR9271_RADIO_RF_RST 0x20
310 #define AR9271_GATE_MAC_CTL 0x4000
311
312 -#define AR_STA_ID0 0x8000
313 -#define AR_STA_ID1 0x8004
314 -#define AR_STA_ID1_SADH_MASK 0x0000FFFF
315 #define AR_STA_ID1_STA_AP 0x00010000
316 #define AR_STA_ID1_ADHOC 0x00020000
317 #define AR_STA_ID1_PWR_SAV 0x00040000
318 @@ -1884,6 +1891,7 @@ enum {
319 #define AR_PCU_TXBUF_CTRL_SIZE_MASK 0x7FF
320 #define AR_PCU_TXBUF_CTRL_USABLE_SIZE 0x700
321 #define AR_9285_PCU_TXBUF_CTRL_USABLE_SIZE 0x380
322 +#define AR_9340_PCU_TXBUF_CTRL_USABLE_SIZE 0x500
323
324 #define AR_PCU_MISC_MODE2 0x8344
325 #define AR_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE 0x00000002
326 --- a/drivers/net/wireless/ath/hw.c
327 +++ b/drivers/net/wireless/ath/hw.c
328 @@ -118,6 +118,12 @@
329 void ath_hw_setbssidmask(struct ath_common *common)
330 {
331 void *ah = common->ah;
332 + u32 id1;
333 +
334 + REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr));
335 + id1 = REG_READ(ah, AR_STA_ID1) & ~AR_STA_ID1_SADH_MASK;
336 + id1 |= get_unaligned_le16(common->macaddr + 4);
337 + REG_WRITE(ah, AR_STA_ID1, id1);
338
339 REG_WRITE(ah, AR_BSSMSKL, get_unaligned_le32(common->bssidmask));
340 REG_WRITE(ah, AR_BSSMSKU, get_unaligned_le16(common->bssidmask + 4));
341 --- a/drivers/net/wireless/ath/reg.h
342 +++ b/drivers/net/wireless/ath/reg.h
343 @@ -23,6 +23,10 @@
344 #define AR_MIBC_CMC 0x00000004
345 #define AR_MIBC_MCS 0x00000008
346
347 +#define AR_STA_ID0 0x8000
348 +#define AR_STA_ID1 0x8004
349 +#define AR_STA_ID1_SADH_MASK 0x0000ffff
350 +
351 /*
352 * BSSID mask registers. See ath_hw_set_bssid_mask()
353 * for detailed documentation about these registers.
354 --- a/drivers/net/wireless/iwlegacy/4965-mac.c
355 +++ b/drivers/net/wireless/iwlegacy/4965-mac.c
356 @@ -6059,7 +6059,7 @@ il4965_mac_channel_switch(struct ieee802
357 struct il_priv *il = hw->priv;
358 const struct il_channel_info *ch_info;
359 struct ieee80211_conf *conf = &hw->conf;
360 - struct ieee80211_channel *channel = ch_switch->channel;
361 + struct ieee80211_channel *channel = ch_switch->chandef.chan;
362 struct il_ht_config *ht_conf = &il->current_ht_config;
363 u16 ch;
364
365 @@ -6096,23 +6096,21 @@ il4965_mac_channel_switch(struct ieee802
366 il->current_ht_config.smps = conf->smps_mode;
367
368 /* Configure HT40 channels */
369 - il->ht.enabled = conf_is_ht(conf);
370 - if (il->ht.enabled) {
371 - if (conf_is_ht40_minus(conf)) {
372 - il->ht.extension_chan_offset =
373 - IEEE80211_HT_PARAM_CHA_SEC_BELOW;
374 - il->ht.is_40mhz = true;
375 - } else if (conf_is_ht40_plus(conf)) {
376 - il->ht.extension_chan_offset =
377 - IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
378 - il->ht.is_40mhz = true;
379 - } else {
380 - il->ht.extension_chan_offset =
381 - IEEE80211_HT_PARAM_CHA_SEC_NONE;
382 - il->ht.is_40mhz = false;
383 - }
384 - } else
385 + switch (cfg80211_get_chandef_type(&ch_switch->chandef)) {
386 + case NL80211_CHAN_NO_HT:
387 + case NL80211_CHAN_HT20:
388 il->ht.is_40mhz = false;
389 + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
390 + break;
391 + case NL80211_CHAN_HT40MINUS:
392 + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
393 + il->ht.is_40mhz = true;
394 + break;
395 + case NL80211_CHAN_HT40PLUS:
396 + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
397 + il->ht.is_40mhz = true;
398 + break;
399 + }
400
401 if ((le16_to_cpu(il->staging.channel) != ch))
402 il->staging.flags = 0;
403 --- a/drivers/net/wireless/iwlegacy/4965.c
404 +++ b/drivers/net/wireless/iwlegacy/4965.c
405 @@ -1493,7 +1493,7 @@ il4965_hw_channel_switch(struct il_priv
406
407 cmd.band = band;
408 cmd.expect_beacon = 0;
409 - ch = ch_switch->channel->hw_value;
410 + ch = ch_switch->chandef.chan->hw_value;
411 cmd.channel = cpu_to_le16(ch);
412 cmd.rxon_flags = il->staging.flags;
413 cmd.rxon_filter_flags = il->staging.filter_flags;
414 --- a/drivers/net/wireless/iwlwifi/dvm/devices.c
415 +++ b/drivers/net/wireless/iwlwifi/dvm/devices.c
416 @@ -379,7 +379,7 @@ static int iwl5000_hw_channel_switch(str
417 };
418
419 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
420 - ch = ch_switch->channel->hw_value;
421 + ch = ch_switch->chandef.chan->hw_value;
422 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
423 ctx->active.channel, ch);
424 cmd.channel = cpu_to_le16(ch);
425 @@ -414,7 +414,8 @@ static int iwl5000_hw_channel_switch(str
426 }
427 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
428 cmd.switch_time);
429 - cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
430 + cmd.expect_beacon =
431 + ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
432
433 return iwl_dvm_send_cmd(priv, &hcmd);
434 }
435 @@ -540,7 +541,7 @@ static int iwl6000_hw_channel_switch(str
436 hcmd.data[0] = cmd;
437
438 cmd->band = priv->band == IEEE80211_BAND_2GHZ;
439 - ch = ch_switch->channel->hw_value;
440 + ch = ch_switch->chandef.chan->hw_value;
441 IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
442 ctx->active.channel, ch);
443 cmd->channel = cpu_to_le16(ch);
444 @@ -575,7 +576,8 @@ static int iwl6000_hw_channel_switch(str
445 }
446 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
447 cmd->switch_time);
448 - cmd->expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
449 + cmd->expect_beacon =
450 + ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
451
452 err = iwl_dvm_send_cmd(priv, &hcmd);
453 kfree(cmd);
454 --- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
455 +++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
456 @@ -970,7 +970,7 @@ static void iwlagn_mac_channel_switch(st
457 {
458 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
459 struct ieee80211_conf *conf = &hw->conf;
460 - struct ieee80211_channel *channel = ch_switch->channel;
461 + struct ieee80211_channel *channel = ch_switch->chandef.chan;
462 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
463 /*
464 * MULTI-FIXME
465 @@ -1008,11 +1008,21 @@ static void iwlagn_mac_channel_switch(st
466 priv->current_ht_config.smps = conf->smps_mode;
467
468 /* Configure HT40 channels */
469 - ctx->ht.enabled = conf_is_ht(conf);
470 - if (ctx->ht.enabled)
471 - iwlagn_config_ht40(conf, ctx);
472 - else
473 + switch (cfg80211_get_chandef_type(&ch_switch->chandef)) {
474 + case NL80211_CHAN_NO_HT:
475 + case NL80211_CHAN_HT20:
476 ctx->ht.is_40mhz = false;
477 + ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
478 + break;
479 + case NL80211_CHAN_HT40MINUS:
480 + ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
481 + ctx->ht.is_40mhz = true;
482 + break;
483 + case NL80211_CHAN_HT40PLUS:
484 + ctx->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
485 + ctx->ht.is_40mhz = true;
486 + break;
487 + }
488
489 if ((le16_to_cpu(ctx->staging.channel) != ch))
490 ctx->staging.flags = 0;
491 --- a/drivers/net/wireless/iwlwifi/dvm/rxon.c
492 +++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c
493 @@ -1160,7 +1160,7 @@ int iwlagn_commit_rxon(struct iwl_priv *
494 }
495
496 void iwlagn_config_ht40(struct ieee80211_conf *conf,
497 - struct iwl_rxon_context *ctx)
498 + struct iwl_rxon_context *ctx)
499 {
500 if (conf_is_ht40_minus(conf)) {
501 ctx->ht.extension_chan_offset =
502 --- a/drivers/net/wireless/mac80211_hwsim.c
503 +++ b/drivers/net/wireless/mac80211_hwsim.c
504 @@ -25,6 +25,7 @@
505 #include <linux/if_arp.h>
506 #include <linux/rtnetlink.h>
507 #include <linux/etherdevice.h>
508 +#include <linux/platform_device.h>
509 #include <linux/debugfs.h>
510 #include <linux/module.h>
511 #include <linux/ktime.h>
512 @@ -717,9 +718,17 @@ static bool mac80211_hwsim_tx_frame_no_n
513 rx_status.flag |= RX_FLAG_MACTIME_START;
514 rx_status.freq = chan->center_freq;
515 rx_status.band = chan->band;
516 - rx_status.rate_idx = info->control.rates[0].idx;
517 - if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
518 - rx_status.flag |= RX_FLAG_HT;
519 + if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) {
520 + rx_status.rate_idx =
521 + ieee80211_rate_get_vht_mcs(&info->control.rates[0]);
522 + rx_status.vht_nss =
523 + ieee80211_rate_get_vht_nss(&info->control.rates[0]);
524 + rx_status.flag |= RX_FLAG_VHT;
525 + } else {
526 + rx_status.rate_idx = info->control.rates[0].idx;
527 + if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
528 + rx_status.flag |= RX_FLAG_HT;
529 + }
530 if (info->control.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
531 rx_status.flag |= RX_FLAG_40MHZ;
532 if (info->control.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
533 @@ -1687,6 +1696,7 @@ static void mac80211_hwsim_free(void)
534 debugfs_remove(data->debugfs_ps);
535 debugfs_remove(data->debugfs);
536 ieee80211_unregister_hw(data->hw);
537 + device_release_driver(data->dev);
538 device_unregister(data->dev);
539 ieee80211_free_hw(data->hw);
540 }
541 @@ -1695,7 +1705,9 @@ static void mac80211_hwsim_free(void)
542
543
544 static struct device_driver mac80211_hwsim_driver = {
545 - .name = "mac80211_hwsim"
546 + .name = "mac80211_hwsim",
547 + .bus = &platform_bus_type,
548 + .owner = THIS_MODULE,
549 };
550
551 static const struct net_device_ops hwsim_netdev_ops = {
552 @@ -2187,9 +2199,15 @@ static int __init init_mac80211_hwsim(vo
553 spin_lock_init(&hwsim_radio_lock);
554 INIT_LIST_HEAD(&hwsim_radios);
555
556 + err = driver_register(&mac80211_hwsim_driver);
557 + if (err)
558 + return err;
559 +
560 hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim");
561 - if (IS_ERR(hwsim_class))
562 - return PTR_ERR(hwsim_class);
563 + if (IS_ERR(hwsim_class)) {
564 + err = PTR_ERR(hwsim_class);
565 + goto failed_unregister_driver;
566 + }
567
568 memset(addr, 0, ETH_ALEN);
569 addr[0] = 0x02;
570 @@ -2211,12 +2229,20 @@ static int __init init_mac80211_hwsim(vo
571 "hwsim%d", i);
572 if (IS_ERR(data->dev)) {
573 printk(KERN_DEBUG
574 - "mac80211_hwsim: device_create "
575 - "failed (%ld)\n", PTR_ERR(data->dev));
576 + "mac80211_hwsim: device_create failed (%ld)\n",
577 + PTR_ERR(data->dev));
578 err = -ENOMEM;
579 goto failed_drvdata;
580 }
581 data->dev->driver = &mac80211_hwsim_driver;
582 + err = device_bind_driver(data->dev);
583 + if (err != 0) {
584 + printk(KERN_DEBUG
585 + "mac80211_hwsim: device_bind_driver failed (%d)\n",
586 + err);
587 + goto failed_hw;
588 + }
589 +
590 skb_queue_head_init(&data->pending);
591
592 SET_IEEE80211_DEV(hw, data->dev);
593 @@ -2515,6 +2541,8 @@ failed_drvdata:
594 ieee80211_free_hw(hw);
595 failed:
596 mac80211_hwsim_free();
597 +failed_unregister_driver:
598 + driver_unregister(&mac80211_hwsim_driver);
599 return err;
600 }
601 module_init(init_mac80211_hwsim);
602 @@ -2527,5 +2555,6 @@ static void __exit exit_mac80211_hwsim(v
603
604 mac80211_hwsim_free();
605 unregister_netdev(hwsim_mon);
606 + driver_unregister(&mac80211_hwsim_driver);
607 }
608 module_exit(exit_mac80211_hwsim);
609 --- a/drivers/net/wireless/ti/wl12xx/cmd.c
610 +++ b/drivers/net/wireless/ti/wl12xx/cmd.c
611 @@ -301,7 +301,7 @@ int wl12xx_cmd_channel_switch(struct wl1
612 }
613
614 cmd->role_id = wlvif->role_id;
615 - cmd->channel = ch_switch->channel->hw_value;
616 + cmd->channel = ch_switch->chandef.chan->hw_value;
617 cmd->switch_time = ch_switch->count;
618 cmd->stop_tx = ch_switch->block_tx;
619
620 --- a/drivers/net/wireless/ti/wl18xx/cmd.c
621 +++ b/drivers/net/wireless/ti/wl18xx/cmd.c
622 @@ -42,11 +42,11 @@ int wl18xx_cmd_channel_switch(struct wl1
623 }
624
625 cmd->role_id = wlvif->role_id;
626 - cmd->channel = ch_switch->channel->hw_value;
627 + cmd->channel = ch_switch->chandef.chan->hw_value;
628 cmd->switch_time = ch_switch->count;
629 cmd->stop_tx = ch_switch->block_tx;
630
631 - switch (ch_switch->channel->band) {
632 + switch (ch_switch->chandef.chan->band) {
633 case IEEE80211_BAND_2GHZ:
634 cmd->band = WLCORE_BAND_2_4GHZ;
635 break;
636 @@ -55,7 +55,7 @@ int wl18xx_cmd_channel_switch(struct wl1
637 break;
638 default:
639 wl1271_error("invalid channel switch band: %d",
640 - ch_switch->channel->band);
641 + ch_switch->chandef.chan->band);
642 ret = -EINVAL;
643 goto out_free;
644 }
645 --- a/include/linux/ieee80211.h
646 +++ b/include/linux/ieee80211.h
647 @@ -673,6 +673,36 @@ struct ieee80211_channel_sw_ie {
648 } __packed;
649
650 /**
651 + * struct ieee80211_ext_chansw_ie
652 + *
653 + * This structure represents the "Extended Channel Switch Announcement element"
654 + */
655 +struct ieee80211_ext_chansw_ie {
656 + u8 mode;
657 + u8 new_operating_class;
658 + u8 new_ch_num;
659 + u8 count;
660 +} __packed;
661 +
662 +/**
663 + * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
664 + * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
665 + * values here
666 + * This structure represents the "Secondary Channel Offset element"
667 + */
668 +struct ieee80211_sec_chan_offs_ie {
669 + u8 sec_chan_offs;
670 +} __packed;
671 +
672 +/**
673 + * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
674 + */
675 +struct ieee80211_wide_bw_chansw_ie {
676 + u8 new_channel_width;
677 + u8 new_center_freq_seg0, new_center_freq_seg1;
678 +} __packed;
679 +
680 +/**
681 * struct ieee80211_tim
682 *
683 * This structure refers to "Traffic Indication Map information element"
684 @@ -840,12 +870,15 @@ struct ieee80211_mgmt {
685 } __packed wme_action;
686 struct{
687 u8 action_code;
688 - u8 element_id;
689 - u8 length;
690 - struct ieee80211_channel_sw_ie sw_elem;
691 + u8 variable[0];
692 } __packed chan_switch;
693 struct{
694 u8 action_code;
695 + struct ieee80211_ext_chansw_ie data;
696 + u8 variable[0];
697 + } __packed ext_chan_switch;
698 + struct{
699 + u8 action_code;
700 u8 dialog_token;
701 u8 element_id;
702 u8 length;
703 @@ -1638,6 +1671,7 @@ enum ieee80211_eid {
704
705 WLAN_EID_HT_CAPABILITY = 45,
706 WLAN_EID_HT_OPERATION = 61,
707 + WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
708
709 WLAN_EID_RSN = 48,
710 WLAN_EID_MMIE = 76,
711 @@ -1672,6 +1706,8 @@ enum ieee80211_eid {
712 WLAN_EID_VHT_CAPABILITY = 191,
713 WLAN_EID_VHT_OPERATION = 192,
714 WLAN_EID_OPMODE_NOTIF = 199,
715 + WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
716 + WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
717
718 /* 802.11ad */
719 WLAN_EID_NON_TX_BSSID_CAP = 83,
720 @@ -1795,6 +1831,7 @@ enum ieee80211_key_len {
721
722 /* Public action codes */
723 enum ieee80211_pub_actioncode {
724 + WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
725 WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
726 };
727
728 --- a/include/net/cfg80211.h
729 +++ b/include/net/cfg80211.h
730 @@ -753,6 +753,8 @@ int cfg80211_check_station_change(struct
731 * @STATION_INFO_LOCAL_PM: @local_pm filled
732 * @STATION_INFO_PEER_PM: @peer_pm filled
733 * @STATION_INFO_NONPEER_PM: @nonpeer_pm filled
734 + * @STATION_INFO_CHAIN_SIGNAL: @chain_signal filled
735 + * @STATION_INFO_CHAIN_SIGNAL_AVG: @chain_signal_avg filled
736 */
737 enum station_info_flags {
738 STATION_INFO_INACTIVE_TIME = 1<<0,
739 @@ -781,6 +783,8 @@ enum station_info_flags {
740 STATION_INFO_NONPEER_PM = 1<<23,
741 STATION_INFO_RX_BYTES64 = 1<<24,
742 STATION_INFO_TX_BYTES64 = 1<<25,
743 + STATION_INFO_CHAIN_SIGNAL = 1<<26,
744 + STATION_INFO_CHAIN_SIGNAL_AVG = 1<<27,
745 };
746
747 /**
748 @@ -857,6 +861,8 @@ struct sta_bss_parameters {
749 u16 beacon_interval;
750 };
751
752 +#define IEEE80211_MAX_CHAINS 4
753 +
754 /**
755 * struct station_info - station information
756 *
757 @@ -874,6 +880,9 @@ struct sta_bss_parameters {
758 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
759 * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
760 * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
761 + * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
762 + * @chain_signal: per-chain signal strength of last received packet in dBm
763 + * @chain_signal_avg: per-chain signal strength average in dBm
764 * @txrate: current unicast bitrate from this station
765 * @rxrate: current unicast bitrate to this station
766 * @rx_packets: packets received from this station
767 @@ -909,6 +918,11 @@ struct station_info {
768 u8 plink_state;
769 s8 signal;
770 s8 signal_avg;
771 +
772 + u8 chains;
773 + s8 chain_signal[IEEE80211_MAX_CHAINS];
774 + s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
775 +
776 struct rate_info txrate;
777 struct rate_info rxrate;
778 u32 rx_packets;
779 @@ -954,6 +968,7 @@ enum monitor_flags {
780 MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
781 MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
782 MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
783 + MONITOR_FLAG_ACTIVE = 1<<NL80211_MNTR_FLAG_ACTIVE,
784 };
785
786 /**
787 @@ -4027,6 +4042,17 @@ bool cfg80211_reg_can_beacon(struct wiph
788 void cfg80211_ch_switch_notify(struct net_device *dev,
789 struct cfg80211_chan_def *chandef);
790
791 +/**
792 + * ieee80211_operating_class_to_band - convert operating class to band
793 + *
794 + * @operating_class: the operating class to convert
795 + * @band: band pointer to fill
796 + *
797 + * Returns %true if the conversion was successful, %false otherwise.
798 + */
799 +bool ieee80211_operating_class_to_band(u8 operating_class,
800 + enum ieee80211_band *band);
801 +
802 /*
803 * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
804 * @dev: the device on which the operation is requested
805 --- a/include/net/mac80211.h
806 +++ b/include/net/mac80211.h
807 @@ -210,7 +210,7 @@ struct ieee80211_chanctx_conf {
808 * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note
809 * that it is only ever disabled for station mode.
810 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
811 - * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode)
812 + * @BSS_CHANGED_SSID: SSID changed for this BSS (AP and IBSS mode)
813 * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
814 * @BSS_CHANGED_PS: PS changed for this BSS (STA mode)
815 * @BSS_CHANGED_TXPOWER: TX power setting changed for this interface
816 @@ -327,7 +327,7 @@ enum ieee80211_rssi_event {
817 * your driver/device needs to do.
818 * @ps: power-save mode (STA only). This flag is NOT affected by
819 * offchannel/dynamic_ps operations.
820 - * @ssid: The SSID of the current vif. Only valid in AP-mode.
821 + * @ssid: The SSID of the current vif. Valid in AP and IBSS mode.
822 * @ssid_len: Length of SSID given in @ssid.
823 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
824 * @txpower: TX power in dBm
825 @@ -459,6 +459,8 @@ struct ieee80211_bss_conf {
826 * @IEEE80211_TX_CTL_DONTFRAG: Don't fragment this packet even if it
827 * would be fragmented by size (this is optional, only used for
828 * monitor injection).
829 + * @IEEE80211_TX_CTL_PS_RESPONSE: This frame is a response to a poll
830 + * frame (PS-Poll or uAPSD).
831 *
832 * Note: If you have to add new flags to the enumeration, then don't
833 * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
834 @@ -494,6 +496,7 @@ enum mac80211_tx_control_flags {
835 IEEE80211_TX_STATUS_EOSP = BIT(28),
836 IEEE80211_TX_CTL_USE_MINRATE = BIT(29),
837 IEEE80211_TX_CTL_DONTFRAG = BIT(30),
838 + IEEE80211_TX_CTL_PS_RESPONSE = BIT(31),
839 };
840
841 #define IEEE80211_TX_CTL_STBC_SHIFT 23
842 @@ -562,6 +565,9 @@ enum mac80211_rate_control_flags {
843 /* maximum number of rate stages */
844 #define IEEE80211_TX_MAX_RATES 4
845
846 +/* maximum number of rate table entries */
847 +#define IEEE80211_TX_RATE_TABLE_SIZE 4
848 +
849 /**
850 * struct ieee80211_tx_rate - rate selection/status
851 *
852 @@ -602,8 +608,8 @@ static inline void ieee80211_rate_set_vh
853 u8 mcs, u8 nss)
854 {
855 WARN_ON(mcs & ~0xF);
856 - WARN_ON(nss & ~0x7);
857 - rate->idx = (nss << 4) | mcs;
858 + WARN_ON((nss - 1) & ~0x7);
859 + rate->idx = ((nss - 1) << 4) | mcs;
860 }
861
862 static inline u8
863 @@ -615,7 +621,7 @@ ieee80211_rate_get_vht_mcs(const struct
864 static inline u8
865 ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
866 {
867 - return rate->idx >> 4;
868 + return (rate->idx >> 4) + 1;
869 }
870
871 /**
872 @@ -656,7 +662,11 @@ struct ieee80211_tx_info {
873 struct ieee80211_tx_rate rates[
874 IEEE80211_TX_MAX_RATES];
875 s8 rts_cts_rate_idx;
876 - /* 3 bytes free */
877 + u8 use_rts:1;
878 + u8 use_cts_prot:1;
879 + u8 short_preamble:1;
880 + u8 skip_table:1;
881 + /* 2 bytes free */
882 };
883 /* only needed before rate control */
884 unsigned long jiffies;
885 @@ -677,6 +687,8 @@ struct ieee80211_tx_info {
886 struct {
887 struct ieee80211_tx_rate driver_rates[
888 IEEE80211_TX_MAX_RATES];
889 + u8 pad[4];
890 +
891 void *rate_driver_data[
892 IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
893 };
894 @@ -840,6 +852,9 @@ enum mac80211_rx_flags {
895 * @signal: signal strength when receiving this frame, either in dBm, in dB or
896 * unspecified depending on the hardware capabilities flags
897 * @IEEE80211_HW_SIGNAL_*
898 + * @chains: bitmask of receive chains for which separate signal strength
899 + * values were filled.
900 + * @chain_signal: per-chain signal strength, same format as @signal
901 * @antenna: antenna used
902 * @rate_idx: index of data rate into band's supported rates or MCS index if
903 * HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
904 @@ -871,6 +886,8 @@ struct ieee80211_rx_status {
905 u8 band;
906 u8 antenna;
907 s8 signal;
908 + u8 chains;
909 + s8 chain_signal[IEEE80211_MAX_CHAINS];
910 u8 ampdu_delimiter_crc;
911 u8 vendor_radiotap_align;
912 u8 vendor_radiotap_oui[3];
913 @@ -1018,13 +1035,13 @@ struct ieee80211_conf {
914 * the driver passed into mac80211.
915 * @block_tx: Indicates whether transmission must be blocked before the
916 * scheduled channel switch, as indicated by the AP.
917 - * @channel: the new channel to switch to
918 + * @chandef: the new channel to switch to
919 * @count: the number of TBTT's until the channel switch event
920 */
921 struct ieee80211_channel_switch {
922 u64 timestamp;
923 bool block_tx;
924 - struct ieee80211_channel *channel;
925 + struct cfg80211_chan_def chandef;
926 u8 count;
927 };
928
929 @@ -1222,6 +1239,24 @@ enum ieee80211_sta_rx_bandwidth {
930 };
931
932 /**
933 + * struct ieee80211_sta_rates - station rate selection table
934 + *
935 + * @rcu_head: RCU head used for freeing the table on update
936 + * @rates: transmit rates/flags to be used by default.
937 + * Overriding entries per-packet is possible by using cb tx control.
938 + */
939 +struct ieee80211_sta_rates {
940 + struct rcu_head rcu_head;
941 + struct {
942 + s8 idx;
943 + u8 count;
944 + u8 count_cts;
945 + u8 count_rts;
946 + u16 flags;
947 + } rate[IEEE80211_TX_RATE_TABLE_SIZE];
948 +};
949 +
950 +/**
951 * struct ieee80211_sta - station table entry
952 *
953 * A station table entry represents a station we are possibly
954 @@ -1248,6 +1283,7 @@ enum ieee80211_sta_rx_bandwidth {
955 * notifications and capabilities. The value is only valid after
956 * the station moves to associated state.
957 * @smps_mode: current SMPS mode (off, static or dynamic)
958 + * @tx_rates: rate control selection table
959 */
960 struct ieee80211_sta {
961 u32 supp_rates[IEEE80211_NUM_BANDS];
962 @@ -1261,6 +1297,7 @@ struct ieee80211_sta {
963 u8 rx_nss;
964 enum ieee80211_sta_rx_bandwidth bandwidth;
965 enum ieee80211_smps_mode smps_mode;
966 + struct ieee80211_sta_rates __rcu *rates;
967
968 /* must be last */
969 u8 drv_priv[0] __aligned(sizeof(void *));
970 @@ -1416,6 +1453,9 @@ struct ieee80211_tx_control {
971 * for different virtual interfaces. See the doc section on HW queue
972 * control for more details.
973 *
974 + * @IEEE80211_HW_SUPPORTS_RC_TABLE: The driver supports using a rate
975 + * selection table provided by the rate control algorithm.
976 + *
977 * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any
978 * P2P Interface. This will be honoured even if more than one interface
979 * is supported.
980 @@ -1448,6 +1488,7 @@ enum ieee80211_hw_flags {
981 IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21,
982 IEEE80211_HW_AP_LINK_PS = 1<<22,
983 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23,
984 + IEEE80211_HW_SUPPORTS_RC_TABLE = 1<<24,
985 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25,
986 IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26,
987 };
988 @@ -3144,6 +3185,25 @@ void ieee80211_sta_set_buffered(struct i
989 u8 tid, bool buffered);
990
991 /**
992 + * ieee80211_get_tx_rates - get the selected transmit rates for a packet
993 + *
994 + * Call this function in a driver with per-packet rate selection support
995 + * to combine the rate info in the packet tx info with the most recent
996 + * rate selection table for the station entry.
997 + *
998 + * @vif: &struct ieee80211_vif pointer from the add_interface callback.
999 + * @sta: the receiver station to which this packet is sent.
1000 + * @skb: the frame to be transmitted.
1001 + * @dest: buffer for extracted rate/retry information
1002 + * @max_rates: maximum number of rates to fetch
1003 + */
1004 +void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
1005 + struct ieee80211_sta *sta,
1006 + struct sk_buff *skb,
1007 + struct ieee80211_tx_rate *dest,
1008 + int max_rates);
1009 +
1010 +/**
1011 * ieee80211_tx_status - transmit status callback
1012 *
1013 * Call this function for all transmitted frames after they have been
1014 @@ -4118,7 +4178,7 @@ void ieee80211_send_bar(struct ieee80211
1015 * (deprecated; this will be removed once drivers get updated to use
1016 * rate_idx_mask)
1017 * @rate_idx_mask: user-requested (legacy) rate mask
1018 - * @rate_idx_mcs_mask: user-requested MCS rate mask
1019 + * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
1020 * @bss: whether this frame is sent out in AP or IBSS mode
1021 */
1022 struct ieee80211_tx_rate_control {
1023 @@ -4130,7 +4190,7 @@ struct ieee80211_tx_rate_control {
1024 bool rts, short_preamble;
1025 u8 max_rate_idx;
1026 u32 rate_idx_mask;
1027 - u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
1028 + u8 *rate_idx_mcs_mask;
1029 bool bss;
1030 };
1031
1032 @@ -4219,6 +4279,22 @@ bool rate_usable_index_exists(struct iee
1033 return false;
1034 }
1035
1036 +/**
1037 + * rate_control_set_rates - pass the sta rate selection to mac80211/driver
1038 + *
1039 + * When not doing a rate control probe to test rates, rate control should pass
1040 + * its rate selection to mac80211. If the driver supports receiving a station
1041 + * rate table, it will use it to ensure that frames are always sent based on
1042 + * the most recent rate control module decision.
1043 + *
1044 + * @hw: pointer as obtained from ieee80211_alloc_hw()
1045 + * @pubsta: &struct ieee80211_sta pointer to the target destination.
1046 + * @rates: new tx rate set to be used for this station.
1047 + */
1048 +int rate_control_set_rates(struct ieee80211_hw *hw,
1049 + struct ieee80211_sta *pubsta,
1050 + struct ieee80211_sta_rates *rates);
1051 +
1052 int ieee80211_rate_control_register(struct rate_control_ops *ops);
1053 void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
1054
1055 --- a/net/mac80211/agg-rx.c
1056 +++ b/net/mac80211/agg-rx.c
1057 @@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
1058 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1059 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1060 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
1061 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
1062 + memcpy(mgmt->bssid, da, ETH_ALEN);
1063
1064 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1065 IEEE80211_STYPE_ACTION);
1066 --- a/net/mac80211/agg-tx.c
1067 +++ b/net/mac80211/agg-tx.c
1068 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
1069 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
1070 if (sdata->vif.type == NL80211_IFTYPE_AP ||
1071 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1072 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
1073 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
1074 + sdata->vif.type == NL80211_IFTYPE_WDS)
1075 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
1076 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
1077 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1078 @@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
1079 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1080 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1081 sdata->vif.type != NL80211_IFTYPE_AP &&
1082 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1083 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1084 return -EINVAL;
1085
1086 --- a/net/mac80211/cfg.c
1087 +++ b/net/mac80211/cfg.c
1088 @@ -73,16 +73,19 @@ static int ieee80211_change_iface(struct
1089 struct ieee80211_local *local = sdata->local;
1090
1091 if (ieee80211_sdata_running(sdata)) {
1092 + u32 mask = MONITOR_FLAG_COOK_FRAMES |
1093 + MONITOR_FLAG_ACTIVE;
1094 +
1095 /*
1096 - * Prohibit MONITOR_FLAG_COOK_FRAMES to be
1097 - * changed while the interface is up.
1098 + * Prohibit MONITOR_FLAG_COOK_FRAMES and
1099 + * MONITOR_FLAG_ACTIVE to be changed while the
1100 + * interface is up.
1101 * Else we would need to add a lot of cruft
1102 * to update everything:
1103 * cooked_mntrs, monitor and all fif_* counters
1104 * reconfigure hardware
1105 */
1106 - if ((*flags & MONITOR_FLAG_COOK_FRAMES) !=
1107 - (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))
1108 + if ((*flags & mask) != (sdata->u.mntr_flags & mask))
1109 return -EBUSY;
1110
1111 ieee80211_adjust_monitor_flags(sdata, -1);
1112 @@ -444,7 +447,7 @@ static void sta_set_sinfo(struct sta_inf
1113 struct ieee80211_local *local = sdata->local;
1114 struct timespec uptime;
1115 u64 packets = 0;
1116 - int ac;
1117 + int i, ac;
1118
1119 sinfo->generation = sdata->local->sta_generation;
1120
1121 @@ -488,6 +491,17 @@ static void sta_set_sinfo(struct sta_inf
1122 sinfo->signal = (s8)sta->last_signal;
1123 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
1124 }
1125 + if (sta->chains) {
1126 + sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
1127 + STATION_INFO_CHAIN_SIGNAL_AVG;
1128 +
1129 + sinfo->chains = sta->chains;
1130 + for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
1131 + sinfo->chain_signal[i] = sta->chain_signal_last[i];
1132 + sinfo->chain_signal_avg[i] =
1133 + (s8) -ewma_read(&sta->chain_signal_avg[i]);
1134 + }
1135 + }
1136
1137 sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
1138 sta_set_rate_info_rx(sta, &sinfo->rxrate);
1139 @@ -1052,6 +1066,7 @@ static int ieee80211_stop_ap(struct wiph
1140 ieee80211_free_keys(sdata);
1141
1142 sdata->vif.bss_conf.enable_beacon = false;
1143 + sdata->vif.bss_conf.ssid_len = 0;
1144 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1145 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
1146
1147 @@ -2416,9 +2431,22 @@ static int ieee80211_set_bitrate_mask(st
1148 }
1149
1150 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
1151 + struct ieee80211_supported_band *sband = wiphy->bands[i];
1152 + int j;
1153 +
1154 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
1155 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
1156 sizeof(mask->control[i].mcs));
1157 +
1158 + sdata->rc_has_mcs_mask[i] = false;
1159 + if (!sband)
1160 + continue;
1161 +
1162 + for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++)
1163 + if (~sdata->rc_rateidx_mcs_mask[i][j]) {
1164 + sdata->rc_has_mcs_mask[i] = true;
1165 + break;
1166 + }
1167 }
1168
1169 return 0;
1170 --- a/net/mac80211/chan.c
1171 +++ b/net/mac80211/chan.c
1172 @@ -57,6 +57,22 @@ ieee80211_find_chanctx(struct ieee80211_
1173 return NULL;
1174 }
1175
1176 +static bool ieee80211_is_radar_required(struct ieee80211_local *local)
1177 +{
1178 + struct ieee80211_sub_if_data *sdata;
1179 +
1180 + rcu_read_lock();
1181 + list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1182 + if (sdata->radar_required) {
1183 + rcu_read_unlock();
1184 + return true;
1185 + }
1186 + }
1187 + rcu_read_unlock();
1188 +
1189 + return false;
1190 +}
1191 +
1192 static struct ieee80211_chanctx *
1193 ieee80211_new_chanctx(struct ieee80211_local *local,
1194 const struct cfg80211_chan_def *chandef,
1195 @@ -76,6 +92,9 @@ ieee80211_new_chanctx(struct ieee80211_l
1196 ctx->conf.rx_chains_static = 1;
1197 ctx->conf.rx_chains_dynamic = 1;
1198 ctx->mode = mode;
1199 + ctx->conf.radar_enabled = ieee80211_is_radar_required(local);
1200 + if (!local->use_chanctx)
1201 + local->hw.conf.radar_enabled = ctx->conf.radar_enabled;
1202
1203 /* acquire mutex to prevent idle from changing */
1204 mutex_lock(&local->mtx);
1205 @@ -110,6 +129,7 @@ ieee80211_new_chanctx(struct ieee80211_l
1206 static void ieee80211_free_chanctx(struct ieee80211_local *local,
1207 struct ieee80211_chanctx *ctx)
1208 {
1209 + bool check_single_channel = false;
1210 lockdep_assert_held(&local->chanctx_mtx);
1211
1212 WARN_ON_ONCE(ctx->refcount != 0);
1213 @@ -119,6 +139,14 @@ static void ieee80211_free_chanctx(struc
1214 chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
1215 chandef->center_freq1 = chandef->chan->center_freq;
1216 chandef->center_freq2 = 0;
1217 +
1218 + /* NOTE: Disabling radar is only valid here for
1219 + * single channel context. To be sure, check it ...
1220 + */
1221 + if (local->hw.conf.radar_enabled)
1222 + check_single_channel = true;
1223 + local->hw.conf.radar_enabled = false;
1224 +
1225 ieee80211_hw_config(local, 0);
1226 } else {
1227 drv_remove_chanctx(local, ctx);
1228 @@ -127,6 +155,9 @@ static void ieee80211_free_chanctx(struc
1229 list_del_rcu(&ctx->list);
1230 kfree_rcu(ctx, rcu_head);
1231
1232 + /* throw a warning if this wasn't the only channel context. */
1233 + WARN_ON(check_single_channel && !list_empty(&local->chanctx_list));
1234 +
1235 mutex_lock(&local->mtx);
1236 ieee80211_recalc_idle(local);
1237 mutex_unlock(&local->mtx);
1238 @@ -238,19 +269,11 @@ static void __ieee80211_vif_release_chan
1239 void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
1240 struct ieee80211_chanctx *chanctx)
1241 {
1242 - struct ieee80211_sub_if_data *sdata;
1243 - bool radar_enabled = false;
1244 + bool radar_enabled;
1245
1246 lockdep_assert_held(&local->chanctx_mtx);
1247
1248 - rcu_read_lock();
1249 - list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1250 - if (sdata->radar_required) {
1251 - radar_enabled = true;
1252 - break;
1253 - }
1254 - }
1255 - rcu_read_unlock();
1256 + radar_enabled = ieee80211_is_radar_required(local);
1257
1258 if (radar_enabled == chanctx->conf.radar_enabled)
1259 return;
1260 --- a/net/mac80211/debugfs_sta.c
1261 +++ b/net/mac80211/debugfs_sta.c
1262 @@ -66,11 +66,11 @@ static ssize_t sta_flags_read(struct fil
1263 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
1264
1265 int res = scnprintf(buf, sizeof(buf),
1266 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1267 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1268 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
1269 TEST(PS_DRIVER), TEST(AUTHORIZED),
1270 TEST(SHORT_PREAMBLE),
1271 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
1272 + TEST(WME), TEST(CLEAR_PS_FILT),
1273 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
1274 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
1275 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
1276 --- a/net/mac80211/ibss.c
1277 +++ b/net/mac80211/ibss.c
1278 @@ -209,6 +209,8 @@ static void __ieee80211_sta_join_ibss(st
1279 sdata->vif.bss_conf.enable_beacon = true;
1280 sdata->vif.bss_conf.beacon_int = beacon_int;
1281 sdata->vif.bss_conf.basic_rates = basic_rates;
1282 + sdata->vif.bss_conf.ssid_len = ifibss->ssid_len;
1283 + memcpy(sdata->vif.bss_conf.ssid, ifibss->ssid, ifibss->ssid_len);
1284 bss_change = BSS_CHANGED_BEACON_INT;
1285 bss_change |= ieee80211_reset_erp_info(sdata);
1286 bss_change |= BSS_CHANGED_BSSID;
1287 @@ -217,6 +219,7 @@ static void __ieee80211_sta_join_ibss(st
1288 bss_change |= BSS_CHANGED_BASIC_RATES;
1289 bss_change |= BSS_CHANGED_HT;
1290 bss_change |= BSS_CHANGED_IBSS;
1291 + bss_change |= BSS_CHANGED_SSID;
1292
1293 /*
1294 * In 5 GHz/802.11a, we can always use short slot time.
1295 @@ -911,7 +914,7 @@ void ieee80211_rx_mgmt_probe_beacon(stru
1296 return;
1297
1298 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
1299 - &elems);
1300 + false, &elems);
1301
1302 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
1303 }
1304 @@ -1159,6 +1162,7 @@ int ieee80211_ibss_leave(struct ieee8021
1305 sdata->vif.bss_conf.ibss_joined = false;
1306 sdata->vif.bss_conf.ibss_creator = false;
1307 sdata->vif.bss_conf.enable_beacon = false;
1308 + sdata->vif.bss_conf.ssid_len = 0;
1309 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1310 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
1311 BSS_CHANGED_IBSS);
1312 --- a/net/mac80211/ieee80211_i.h
1313 +++ b/net/mac80211/ieee80211_i.h
1314 @@ -156,6 +156,7 @@ struct ieee80211_tx_data {
1315 struct ieee80211_sub_if_data *sdata;
1316 struct sta_info *sta;
1317 struct ieee80211_key *key;
1318 + struct ieee80211_tx_rate rate;
1319
1320 unsigned int flags;
1321 };
1322 @@ -740,6 +741,8 @@ struct ieee80211_sub_if_data {
1323
1324 /* bitmap of allowed (non-MCS) rate indexes for rate control */
1325 u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
1326 +
1327 + bool rc_has_mcs_mask[IEEE80211_NUM_BANDS];
1328 u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
1329
1330 union {
1331 @@ -1025,7 +1028,7 @@ struct ieee80211_local {
1332 enum mac80211_scan_state next_scan_state;
1333 struct delayed_work scan_work;
1334 struct ieee80211_sub_if_data __rcu *scan_sdata;
1335 - struct ieee80211_channel *csa_channel;
1336 + struct cfg80211_chan_def csa_chandef;
1337 /* For backward compatibility only -- do not use */
1338 struct cfg80211_chan_def _oper_chandef;
1339
1340 @@ -1184,10 +1187,13 @@ struct ieee802_11_elems {
1341 const u8 *perr;
1342 const struct ieee80211_rann_ie *rann;
1343 const struct ieee80211_channel_sw_ie *ch_switch_ie;
1344 + const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
1345 + const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
1346 const u8 *country_elem;
1347 const u8 *pwr_constr_elem;
1348 const struct ieee80211_timeout_interval_ie *timeout_int;
1349 const u8 *opmode_notif;
1350 + const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
1351
1352 /* length of them, respectively */
1353 u8 ssid_len;
1354 @@ -1258,10 +1264,6 @@ void ieee80211_recalc_ps_vif(struct ieee
1355 int ieee80211_max_network_latency(struct notifier_block *nb,
1356 unsigned long data, void *dummy);
1357 int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata);
1358 -void
1359 -ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1360 - const struct ieee80211_channel_sw_ie *sw_elem,
1361 - struct ieee80211_bss *bss, u64 timestamp);
1362 void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata);
1363 void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1364 struct sk_buff *skb);
1365 @@ -1499,13 +1501,13 @@ static inline void ieee80211_tx_skb(stru
1366 ieee80211_tx_skb_tid(sdata, skb, 7);
1367 }
1368
1369 -u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
1370 +u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action,
1371 struct ieee802_11_elems *elems,
1372 u64 filter, u32 crc);
1373 -static inline void ieee802_11_parse_elems(u8 *start, size_t len,
1374 +static inline void ieee802_11_parse_elems(u8 *start, size_t len, bool action,
1375 struct ieee802_11_elems *elems)
1376 {
1377 - ieee802_11_parse_elems_crc(start, len, elems, 0, 0);
1378 + ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1379 }
1380
1381 u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
1382 --- a/net/mac80211/iface.c
1383 +++ b/net/mac80211/iface.c
1384 @@ -159,7 +159,8 @@ static int ieee80211_change_mtu(struct n
1385 return 0;
1386 }
1387
1388 -static int ieee80211_verify_mac(struct ieee80211_local *local, u8 *addr)
1389 +static int ieee80211_verify_mac(struct ieee80211_local *local, u8 *addr,
1390 + bool check_dup)
1391 {
1392 struct ieee80211_sub_if_data *sdata;
1393 u64 new, mask, tmp;
1394 @@ -179,10 +180,13 @@ static int ieee80211_verify_mac(struct i
1395 ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
1396 ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
1397
1398 + if (!check_dup)
1399 + return ret;
1400
1401 mutex_lock(&local->iflist_mtx);
1402 list_for_each_entry(sdata, &local->interfaces, list) {
1403 - if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
1404 + if (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
1405 + !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
1406 continue;
1407
1408 m = sdata->vif.addr;
1409 @@ -204,12 +208,17 @@ static int ieee80211_change_mac(struct n
1410 {
1411 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1412 struct sockaddr *sa = addr;
1413 + bool check_dup = true;
1414 int ret;
1415
1416 if (ieee80211_sdata_running(sdata))
1417 return -EBUSY;
1418
1419 - ret = ieee80211_verify_mac(sdata->local, sa->sa_data);
1420 + if (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
1421 + !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
1422 + check_dup = false;
1423 +
1424 + ret = ieee80211_verify_mac(sdata->local, sa->sa_data, check_dup);
1425 if (ret)
1426 return ret;
1427
1428 @@ -450,7 +459,6 @@ int ieee80211_do_open(struct wireless_de
1429 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
1430 struct net_device *dev = wdev->netdev;
1431 struct ieee80211_local *local = sdata->local;
1432 - struct sta_info *sta;
1433 u32 changed = 0;
1434 int res;
1435 u32 hw_reconf_flags = 0;
1436 @@ -474,6 +482,9 @@ int ieee80211_do_open(struct wireless_de
1437 master->control_port_protocol;
1438 sdata->control_port_no_encrypt =
1439 master->control_port_no_encrypt;
1440 + sdata->vif.cab_queue = master->vif.cab_queue;
1441 + memcpy(sdata->vif.hw_queue, master->vif.hw_queue,
1442 + sizeof(sdata->vif.hw_queue));
1443 break;
1444 }
1445 case NL80211_IFTYPE_AP:
1446 @@ -538,7 +549,11 @@ int ieee80211_do_open(struct wireless_de
1447 break;
1448 }
1449
1450 - if (local->monitors == 0 && local->open_count == 0) {
1451 + if (sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE) {
1452 + res = drv_add_interface(local, sdata);
1453 + if (res)
1454 + goto err_stop;
1455 + } else if (local->monitors == 0 && local->open_count == 0) {
1456 res = ieee80211_add_virtual_monitor(local);
1457 if (res)
1458 goto err_stop;
1459 @@ -609,30 +624,8 @@ int ieee80211_do_open(struct wireless_de
1460
1461 set_bit(SDATA_STATE_RUNNING, &sdata->state);
1462
1463 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
1464 - /* Create STA entry for the WDS peer */
1465 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1466 - GFP_KERNEL);
1467 - if (!sta) {
1468 - res = -ENOMEM;
1469 - goto err_del_interface;
1470 - }
1471 -
1472 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1473 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1474 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1475 -
1476 - res = sta_info_insert(sta);
1477 - if (res) {
1478 - /* STA has been freed */
1479 - goto err_del_interface;
1480 - }
1481 -
1482 - rate_control_rate_init(sta);
1483 - netif_carrier_on(dev);
1484 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
1485 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
1486 rcu_assign_pointer(local->p2p_sdata, sdata);
1487 - }
1488
1489 /*
1490 * set_multicast_list will be invoked by the networking core
1491 @@ -653,7 +646,11 @@ int ieee80211_do_open(struct wireless_de
1492
1493 ieee80211_recalc_ps(local, -1);
1494
1495 - if (dev) {
1496 + if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
1497 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
1498 + /* XXX: for AP_VLAN, actually track AP queues */
1499 + netif_tx_start_all_queues(dev);
1500 + } else if (dev) {
1501 unsigned long flags;
1502 int n_acs = IEEE80211_NUM_ACS;
1503 int ac;
1504 @@ -916,7 +913,11 @@ static void ieee80211_do_stop(struct iee
1505 mutex_lock(&local->mtx);
1506 ieee80211_recalc_idle(local);
1507 mutex_unlock(&local->mtx);
1508 - break;
1509 +
1510 + if (!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
1511 + break;
1512 +
1513 + /* fall through */
1514 default:
1515 if (going_down)
1516 drv_remove_interface(local, sdata);
1517 @@ -1075,7 +1076,7 @@ static const struct net_device_ops ieee8
1518 .ndo_start_xmit = ieee80211_monitor_start_xmit,
1519 .ndo_set_rx_mode = ieee80211_set_multicast_list,
1520 .ndo_change_mtu = ieee80211_change_mtu,
1521 - .ndo_set_mac_address = eth_mac_addr,
1522 + .ndo_set_mac_address = ieee80211_change_mac,
1523 .ndo_select_queue = ieee80211_monitor_select_queue,
1524 };
1525
1526 @@ -1092,6 +1093,74 @@ static void ieee80211_if_setup(struct ne
1527 dev->destructor = free_netdev;
1528 }
1529
1530 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1531 + struct sk_buff *skb)
1532 +{
1533 + struct ieee80211_local *local = sdata->local;
1534 + struct ieee80211_rx_status *rx_status;
1535 + struct ieee802_11_elems elems;
1536 + struct ieee80211_mgmt *mgmt;
1537 + struct sta_info *sta;
1538 + size_t baselen;
1539 + u32 rates = 0;
1540 + u16 stype;
1541 + bool new = false;
1542 + enum ieee80211_band band;
1543 + struct ieee80211_supported_band *sband;
1544 +
1545 + rx_status = IEEE80211_SKB_RXCB(skb);
1546 + band = rx_status->band;
1547 + sband = local->hw.wiphy->bands[band];
1548 + mgmt = (struct ieee80211_mgmt *) skb->data;
1549 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
1550 +
1551 + if (stype != IEEE80211_STYPE_BEACON)
1552 + return;
1553 +
1554 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
1555 + if (baselen > skb->len)
1556 + return;
1557 +
1558 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
1559 + skb->len - baselen, false, &elems);
1560 +
1561 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
1562 +
1563 + rcu_read_lock();
1564 +
1565 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
1566 +
1567 + if (!sta) {
1568 + rcu_read_unlock();
1569 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1570 + GFP_KERNEL);
1571 + if (!sta)
1572 + return;
1573 +
1574 + new = true;
1575 + }
1576 +
1577 + sta->last_rx = jiffies;
1578 + sta->sta.supp_rates[band] = rates;
1579 +
1580 + if (elems.ht_cap_elem)
1581 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1582 + elems.ht_cap_elem, sta);
1583 +
1584 + if (elems.wmm_param)
1585 + set_sta_flag(sta, WLAN_STA_WME);
1586 +
1587 + if (new) {
1588 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1589 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1590 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1591 + rate_control_rate_init(sta);
1592 + sta_info_insert_rcu(sta);
1593 + }
1594 +
1595 + rcu_read_unlock();
1596 +}
1597 +
1598 static void ieee80211_iface_work(struct work_struct *work)
1599 {
1600 struct ieee80211_sub_if_data *sdata =
1601 @@ -1196,6 +1265,9 @@ static void ieee80211_iface_work(struct
1602 break;
1603 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
1604 break;
1605 + case NL80211_IFTYPE_WDS:
1606 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
1607 + break;
1608 default:
1609 WARN(1, "frame for unexpected interface type");
1610 break;
1611 @@ -1718,6 +1790,15 @@ void ieee80211_remove_interfaces(struct
1612
1613 ASSERT_RTNL();
1614
1615 + /*
1616 + * Close all AP_VLAN interfaces first, as otherwise they
1617 + * might be closed while the AP interface they belong to
1618 + * is closed, causing unregister_netdevice_many() to crash.
1619 + */
1620 + list_for_each_entry(sdata, &local->interfaces, list)
1621 + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
1622 + dev_close(sdata->dev);
1623 +
1624 mutex_lock(&local->iflist_mtx);
1625 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
1626 list_del(&sdata->list);
1627 --- a/net/mac80211/main.c
1628 +++ b/net/mac80211/main.c
1629 @@ -674,6 +674,7 @@ int ieee80211_register_hw(struct ieee802
1630 int channels, max_bitrates;
1631 bool supp_ht, supp_vht;
1632 netdev_features_t feature_whitelist;
1633 + struct cfg80211_chan_def dflt_chandef = {};
1634 static const u32 cipher_suites[] = {
1635 /* keep WEP first, it may be removed below */
1636 WLAN_CIPHER_SUITE_WEP40,
1637 @@ -751,19 +752,19 @@ int ieee80211_register_hw(struct ieee802
1638 sband = local->hw.wiphy->bands[band];
1639 if (!sband)
1640 continue;
1641 - if (!local->use_chanctx && !local->_oper_chandef.chan) {
1642 +
1643 + if (!dflt_chandef.chan) {
1644 + cfg80211_chandef_create(&dflt_chandef,
1645 + &sband->channels[0],
1646 + NL80211_CHAN_NO_HT);
1647 /* init channel we're on */
1648 - struct cfg80211_chan_def chandef = {
1649 - .chan = &sband->channels[0],
1650 - .width = NL80211_CHAN_NO_HT,
1651 - .center_freq1 = sband->channels[0].center_freq,
1652 - .center_freq2 = 0
1653 - };
1654 - local->hw.conf.chandef = local->_oper_chandef = chandef;
1655 + if (!local->use_chanctx && !local->_oper_chandef.chan) {
1656 + local->hw.conf.chandef = dflt_chandef;
1657 + local->_oper_chandef = dflt_chandef;
1658 + }
1659 + local->monitor_chandef = dflt_chandef;
1660 }
1661 - cfg80211_chandef_create(&local->monitor_chandef,
1662 - &sband->channels[0],
1663 - NL80211_CHAN_NO_HT);
1664 +
1665 channels += sband->n_channels;
1666
1667 if (max_bitrates < sband->n_bitrates)
1668 --- a/net/mac80211/mesh.c
1669 +++ b/net/mac80211/mesh.c
1670 @@ -838,7 +838,7 @@ ieee80211_mesh_rx_probe_req(struct ieee8
1671 if (baselen > len)
1672 return;
1673
1674 - ieee802_11_parse_elems(pos, len - baselen, &elems);
1675 + ieee802_11_parse_elems(pos, len - baselen, false, &elems);
1676
1677 /* 802.11-2012 10.1.4.3.2 */
1678 if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) &&
1679 @@ -899,7 +899,7 @@ static void ieee80211_mesh_rx_bcn_presp(
1680 return;
1681
1682 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
1683 - &elems);
1684 + false, &elems);
1685
1686 /* ignore non-mesh or secure / unsecure mismatch */
1687 if ((!elems.mesh_id || !elems.mesh_config) ||
1688 --- a/net/mac80211/mesh_hwmp.c
1689 +++ b/net/mac80211/mesh_hwmp.c
1690 @@ -880,7 +880,7 @@ void mesh_rx_path_sel_frame(struct ieee8
1691
1692 baselen = (u8 *) mgmt->u.action.u.mesh_action.variable - (u8 *) mgmt;
1693 ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable,
1694 - len - baselen, &elems);
1695 + len - baselen, false, &elems);
1696
1697 if (elems.preq) {
1698 if (elems.preq_len != 37)
1699 --- a/net/mac80211/mesh_plink.c
1700 +++ b/net/mac80211/mesh_plink.c
1701 @@ -544,8 +544,8 @@ static void mesh_plink_timer(unsigned lo
1702 return;
1703 }
1704 mpl_dbg(sta->sdata,
1705 - "Mesh plink timer for %pM fired on state %d\n",
1706 - sta->sta.addr, sta->plink_state);
1707 + "Mesh plink timer for %pM fired on state %s\n",
1708 + sta->sta.addr, mplstates[sta->plink_state]);
1709 reason = 0;
1710 llid = sta->llid;
1711 plid = sta->plid;
1712 @@ -687,7 +687,7 @@ void mesh_rx_plink_frame(struct ieee8021
1713 baseaddr += 4;
1714 baselen += 4;
1715 }
1716 - ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
1717 + ieee802_11_parse_elems(baseaddr, len - baselen, true, &elems);
1718
1719 if (!elems.peering) {
1720 mpl_dbg(sdata,
1721 --- a/net/mac80211/mlme.c
1722 +++ b/net/mac80211/mlme.c
1723 @@ -289,6 +289,8 @@ ieee80211_determine_chantype(struct ieee
1724 } else {
1725 /* 40 MHz (and 80 MHz) must be supported for VHT */
1726 ret = IEEE80211_STA_DISABLE_VHT;
1727 + /* also mark 40 MHz disabled */
1728 + ret |= IEEE80211_STA_DISABLE_40MHZ;
1729 goto out;
1730 }
1731
1732 @@ -303,12 +305,6 @@ ieee80211_determine_chantype(struct ieee
1733 channel->band);
1734 vht_chandef.center_freq2 = 0;
1735
1736 - if (vht_oper->center_freq_seg2_idx)
1737 - vht_chandef.center_freq2 =
1738 - ieee80211_channel_to_frequency(
1739 - vht_oper->center_freq_seg2_idx,
1740 - channel->band);
1741 -
1742 switch (vht_oper->chan_width) {
1743 case IEEE80211_VHT_CHANWIDTH_USE_HT:
1744 vht_chandef.width = chandef->width;
1745 @@ -321,6 +317,10 @@ ieee80211_determine_chantype(struct ieee
1746 break;
1747 case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
1748 vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
1749 + vht_chandef.center_freq2 =
1750 + ieee80211_channel_to_frequency(
1751 + vht_oper->center_freq_seg2_idx,
1752 + channel->band);
1753 break;
1754 default:
1755 if (verbose)
1756 @@ -604,7 +604,6 @@ static void ieee80211_add_vht_ie(struct
1757 u8 *pos;
1758 u32 cap;
1759 struct ieee80211_sta_vht_cap vht_cap;
1760 - int i;
1761
1762 BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap));
1763
1764 @@ -632,37 +631,6 @@ static void ieee80211_add_vht_ie(struct
1765 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)))
1766 cap &= ~IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
1767
1768 - if (!(ap_vht_cap->vht_cap_info &
1769 - cpu_to_le32(IEEE80211_VHT_CAP_TXSTBC)))
1770 - cap &= ~(IEEE80211_VHT_CAP_RXSTBC_1 |
1771 - IEEE80211_VHT_CAP_RXSTBC_3 |
1772 - IEEE80211_VHT_CAP_RXSTBC_4);
1773 -
1774 - for (i = 0; i < 8; i++) {
1775 - int shift = i * 2;
1776 - u16 mask = IEEE80211_VHT_MCS_NOT_SUPPORTED << shift;
1777 - u16 ap_mcs, our_mcs;
1778 -
1779 - ap_mcs = (le16_to_cpu(ap_vht_cap->supp_mcs.tx_mcs_map) &
1780 - mask) >> shift;
1781 - our_mcs = (le16_to_cpu(vht_cap.vht_mcs.rx_mcs_map) &
1782 - mask) >> shift;
1783 -
1784 - if (our_mcs == IEEE80211_VHT_MCS_NOT_SUPPORTED)
1785 - continue;
1786 -
1787 - switch (ap_mcs) {
1788 - default:
1789 - if (our_mcs <= ap_mcs)
1790 - break;
1791 - /* fall through */
1792 - case IEEE80211_VHT_MCS_NOT_SUPPORTED:
1793 - vht_cap.vht_mcs.rx_mcs_map &= cpu_to_le16(~mask);
1794 - vht_cap.vht_mcs.rx_mcs_map |=
1795 - cpu_to_le16(ap_mcs << shift);
1796 - }
1797 - }
1798 -
1799 /* reserve and fill IE */
1800 pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2);
1801 ieee80211_ie_build_vht_cap(pos, &vht_cap, cap);
1802 @@ -998,16 +966,7 @@ static void ieee80211_chswitch_work(stru
1803 if (!ifmgd->associated)
1804 goto out;
1805
1806 - /*
1807 - * FIXME: Here we are downgrading to NL80211_CHAN_WIDTH_20_NOHT
1808 - * and don't adjust our ht/vht settings
1809 - * This is wrong - we should behave according to the CSA params
1810 - */
1811 - local->_oper_chandef.chan = local->csa_channel;
1812 - local->_oper_chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
1813 - local->_oper_chandef.center_freq1 =
1814 - local->_oper_chandef.chan->center_freq;
1815 - local->_oper_chandef.center_freq2 = 0;
1816 + local->_oper_chandef = local->csa_chandef;
1817
1818 if (!local->ops->channel_switch) {
1819 /* call "hw_config" only if doing sw channel switch */
1820 @@ -1054,56 +1013,208 @@ static void ieee80211_chswitch_timer(uns
1821 ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work);
1822 }
1823
1824 -void
1825 +static void
1826 ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1827 - const struct ieee80211_channel_sw_ie *sw_elem,
1828 - struct ieee80211_bss *bss, u64 timestamp)
1829 + u64 timestamp, struct ieee802_11_elems *elems,
1830 + bool beacon)
1831 {
1832 - struct cfg80211_bss *cbss =
1833 - container_of((void *)bss, struct cfg80211_bss, priv);
1834 - struct ieee80211_channel *new_ch;
1835 + struct ieee80211_local *local = sdata->local;
1836 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1837 - int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num,
1838 - cbss->channel->band);
1839 + struct cfg80211_bss *cbss = ifmgd->associated;
1840 + struct ieee80211_bss *bss;
1841 struct ieee80211_chanctx *chanctx;
1842 + enum ieee80211_band new_band;
1843 + int new_freq;
1844 + u8 new_chan_no;
1845 + u8 count;
1846 + u8 mode;
1847 + struct ieee80211_channel *new_chan;
1848 + struct cfg80211_chan_def new_chandef = {};
1849 + struct cfg80211_chan_def new_vht_chandef = {};
1850 + const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
1851 + const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
1852 + const struct ieee80211_ht_operation *ht_oper;
1853 + int secondary_channel_offset = -1;
1854
1855 ASSERT_MGD_MTX(ifmgd);
1856
1857 - if (!ifmgd->associated)
1858 + if (!cbss)
1859 + return;
1860 +
1861 + if (local->scanning)
1862 return;
1863
1864 - if (sdata->local->scanning)
1865 + /* disregard subsequent announcements if we are already processing */
1866 + if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED)
1867 return;
1868
1869 - /* Disregard subsequent beacons if we are already running a timer
1870 - processing a CSA */
1871 + sec_chan_offs = elems->sec_chan_offs;
1872 + wide_bw_chansw_ie = elems->wide_bw_chansw_ie;
1873 + ht_oper = elems->ht_operation;
1874 +
1875 + if (ifmgd->flags & (IEEE80211_STA_DISABLE_HT |
1876 + IEEE80211_STA_DISABLE_40MHZ)) {
1877 + sec_chan_offs = NULL;
1878 + wide_bw_chansw_ie = NULL;
1879 + /* only used for bandwidth here */
1880 + ht_oper = NULL;
1881 + }
1882
1883 - if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED)
1884 + if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT)
1885 + wide_bw_chansw_ie = NULL;
1886 +
1887 + if (elems->ext_chansw_ie) {
1888 + if (!ieee80211_operating_class_to_band(
1889 + elems->ext_chansw_ie->new_operating_class,
1890 + &new_band)) {
1891 + sdata_info(sdata,
1892 + "cannot understand ECSA IE operating class %d, disconnecting\n",
1893 + elems->ext_chansw_ie->new_operating_class);
1894 + ieee80211_queue_work(&local->hw,
1895 + &ifmgd->csa_connection_drop_work);
1896 + }
1897 + new_chan_no = elems->ext_chansw_ie->new_ch_num;
1898 + count = elems->ext_chansw_ie->count;
1899 + mode = elems->ext_chansw_ie->mode;
1900 + } else if (elems->ch_switch_ie) {
1901 + new_band = cbss->channel->band;
1902 + new_chan_no = elems->ch_switch_ie->new_ch_num;
1903 + count = elems->ch_switch_ie->count;
1904 + mode = elems->ch_switch_ie->mode;
1905 + } else {
1906 + /* nothing here we understand */
1907 return;
1908 + }
1909 +
1910 + bss = (void *)cbss->priv;
1911
1912 - new_ch = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
1913 - if (!new_ch || new_ch->flags & IEEE80211_CHAN_DISABLED) {
1914 + new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band);
1915 + new_chan = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
1916 + if (!new_chan || new_chan->flags & IEEE80211_CHAN_DISABLED) {
1917 sdata_info(sdata,
1918 "AP %pM switches to unsupported channel (%d MHz), disconnecting\n",
1919 ifmgd->associated->bssid, new_freq);
1920 - ieee80211_queue_work(&sdata->local->hw,
1921 + ieee80211_queue_work(&local->hw,
1922 + &ifmgd->csa_connection_drop_work);
1923 + return;
1924 + }
1925 +
1926 + if (!beacon && sec_chan_offs) {
1927 + secondary_channel_offset = sec_chan_offs->sec_chan_offs;
1928 + } else if (beacon && ht_oper) {
1929 + secondary_channel_offset =
1930 + ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
1931 + } else if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
1932 + /*
1933 + * If it's not a beacon, HT is enabled and the IE not present,
1934 + * it's 20 MHz, 802.11-2012 8.5.2.6:
1935 + * This element [the Secondary Channel Offset Element] is
1936 + * present when switching to a 40 MHz channel. It may be
1937 + * present when switching to a 20 MHz channel (in which
1938 + * case the secondary channel offset is set to SCN).
1939 + */
1940 + secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
1941 + }
1942 +
1943 + switch (secondary_channel_offset) {
1944 + default:
1945 + /* secondary_channel_offset was present but is invalid */
1946 + case IEEE80211_HT_PARAM_CHA_SEC_NONE:
1947 + cfg80211_chandef_create(&new_chandef, new_chan,
1948 + NL80211_CHAN_HT20);
1949 + break;
1950 + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
1951 + cfg80211_chandef_create(&new_chandef, new_chan,
1952 + NL80211_CHAN_HT40PLUS);
1953 + break;
1954 + case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
1955 + cfg80211_chandef_create(&new_chandef, new_chan,
1956 + NL80211_CHAN_HT40MINUS);
1957 + break;
1958 + case -1:
1959 + cfg80211_chandef_create(&new_chandef, new_chan,
1960 + NL80211_CHAN_NO_HT);
1961 + break;
1962 + }
1963 +
1964 + if (wide_bw_chansw_ie) {
1965 + new_vht_chandef.chan = new_chan;
1966 + new_vht_chandef.center_freq1 =
1967 + ieee80211_channel_to_frequency(
1968 + wide_bw_chansw_ie->new_center_freq_seg0,
1969 + new_band);
1970 +
1971 + switch (wide_bw_chansw_ie->new_channel_width) {
1972 + default:
1973 + /* hmmm, ignore VHT and use HT if present */
1974 + case IEEE80211_VHT_CHANWIDTH_USE_HT:
1975 + new_vht_chandef.chan = NULL;
1976 + break;
1977 + case IEEE80211_VHT_CHANWIDTH_80MHZ:
1978 + new_vht_chandef.width = NL80211_CHAN_WIDTH_80;
1979 + break;
1980 + case IEEE80211_VHT_CHANWIDTH_160MHZ:
1981 + new_vht_chandef.width = NL80211_CHAN_WIDTH_160;
1982 + break;
1983 + case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
1984 + /* field is otherwise reserved */
1985 + new_vht_chandef.center_freq2 =
1986 + ieee80211_channel_to_frequency(
1987 + wide_bw_chansw_ie->new_center_freq_seg1,
1988 + new_band);
1989 + new_vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
1990 + break;
1991 + }
1992 + if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ &&
1993 + new_vht_chandef.width == NL80211_CHAN_WIDTH_80P80)
1994 + chandef_downgrade(&new_vht_chandef);
1995 + if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ &&
1996 + new_vht_chandef.width == NL80211_CHAN_WIDTH_160)
1997 + chandef_downgrade(&new_vht_chandef);
1998 + if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ &&
1999 + new_vht_chandef.width > NL80211_CHAN_WIDTH_20)
2000 + chandef_downgrade(&new_vht_chandef);
2001 + }
2002 +
2003 + /* if VHT data is there validate & use it */
2004 + if (new_vht_chandef.chan) {
2005 + if (!cfg80211_chandef_compatible(&new_vht_chandef,
2006 + &new_chandef)) {
2007 + sdata_info(sdata,
2008 + "AP %pM CSA has inconsistent channel data, disconnecting\n",
2009 + ifmgd->associated->bssid);
2010 + ieee80211_queue_work(&local->hw,
2011 + &ifmgd->csa_connection_drop_work);
2012 + return;
2013 + }
2014 + new_chandef = new_vht_chandef;
2015 + }
2016 +
2017 + if (!cfg80211_chandef_usable(local->hw.wiphy, &new_chandef,
2018 + IEEE80211_CHAN_DISABLED)) {
2019 + sdata_info(sdata,
2020 + "AP %pM switches to unsupported channel (%d MHz, width:%d, CF1/2: %d/%d MHz), disconnecting\n",
2021 + ifmgd->associated->bssid, new_freq,
2022 + new_chandef.width, new_chandef.center_freq1,
2023 + new_chandef.center_freq2);
2024 + ieee80211_queue_work(&local->hw,
2025 &ifmgd->csa_connection_drop_work);
2026 return;
2027 }
2028
2029 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
2030
2031 - if (sdata->local->use_chanctx) {
2032 + if (local->use_chanctx) {
2033 sdata_info(sdata,
2034 "not handling channel switch with channel contexts\n");
2035 - ieee80211_queue_work(&sdata->local->hw,
2036 + ieee80211_queue_work(&local->hw,
2037 &ifmgd->csa_connection_drop_work);
2038 return;
2039 }
2040
2041 - mutex_lock(&sdata->local->chanctx_mtx);
2042 + mutex_lock(&local->chanctx_mtx);
2043 if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) {
2044 - mutex_unlock(&sdata->local->chanctx_mtx);
2045 + mutex_unlock(&local->chanctx_mtx);
2046 return;
2047 }
2048 chanctx = container_of(rcu_access_pointer(sdata->vif.chanctx_conf),
2049 @@ -1111,40 +1222,39 @@ ieee80211_sta_process_chanswitch(struct
2050 if (chanctx->refcount > 1) {
2051 sdata_info(sdata,
2052 "channel switch with multiple interfaces on the same channel, disconnecting\n");
2053 - ieee80211_queue_work(&sdata->local->hw,
2054 + ieee80211_queue_work(&local->hw,
2055 &ifmgd->csa_connection_drop_work);
2056 - mutex_unlock(&sdata->local->chanctx_mtx);
2057 + mutex_unlock(&local->chanctx_mtx);
2058 return;
2059 }
2060 - mutex_unlock(&sdata->local->chanctx_mtx);
2061 + mutex_unlock(&local->chanctx_mtx);
2062
2063 - sdata->local->csa_channel = new_ch;
2064 + local->csa_chandef = new_chandef;
2065
2066 - if (sw_elem->mode)
2067 - ieee80211_stop_queues_by_reason(&sdata->local->hw,
2068 + if (mode)
2069 + ieee80211_stop_queues_by_reason(&local->hw,
2070 IEEE80211_MAX_QUEUE_MAP,
2071 IEEE80211_QUEUE_STOP_REASON_CSA);
2072
2073 - if (sdata->local->ops->channel_switch) {
2074 + if (local->ops->channel_switch) {
2075 /* use driver's channel switch callback */
2076 struct ieee80211_channel_switch ch_switch = {
2077 .timestamp = timestamp,
2078 - .block_tx = sw_elem->mode,
2079 - .channel = new_ch,
2080 - .count = sw_elem->count,
2081 + .block_tx = mode,
2082 + .chandef = new_chandef,
2083 + .count = count,
2084 };
2085
2086 - drv_channel_switch(sdata->local, &ch_switch);
2087 + drv_channel_switch(local, &ch_switch);
2088 return;
2089 }
2090
2091 /* channel switch handled in software */
2092 - if (sw_elem->count <= 1)
2093 - ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work);
2094 + if (count <= 1)
2095 + ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work);
2096 else
2097 mod_timer(&ifmgd->chswitch_timer,
2098 - TU_TO_EXP_TIME(sw_elem->count *
2099 - cbss->beacon_interval));
2100 + TU_TO_EXP_TIME(count * cbss->beacon_interval));
2101 }
2102
2103 static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
2104 @@ -2120,7 +2230,6 @@ void ieee80211_beacon_loss(struct ieee80
2105
2106 trace_api_beacon_loss(sdata);
2107
2108 - WARN_ON(hw->flags & IEEE80211_HW_CONNECTION_MONITOR);
2109 sdata->u.mgd.connection_loss = false;
2110 ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work);
2111 }
2112 @@ -2170,7 +2279,7 @@ static void ieee80211_auth_challenge(str
2113 u32 tx_flags = 0;
2114
2115 pos = mgmt->u.auth.variable;
2116 - ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
2117 + ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
2118 if (!elems.challenge)
2119 return;
2120 auth_data->expected_transaction = 4;
2121 @@ -2435,7 +2544,7 @@ static bool ieee80211_assoc_success(stru
2122 }
2123
2124 pos = mgmt->u.assoc_resp.variable;
2125 - ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
2126 + ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
2127
2128 if (!elems.supp_rates) {
2129 sdata_info(sdata, "no SuppRates element in AssocResp\n");
2130 @@ -2604,7 +2713,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee
2131 capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14))));
2132
2133 pos = mgmt->u.assoc_resp.variable;
2134 - ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
2135 + ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems);
2136
2137 if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
2138 elems.timeout_int &&
2139 @@ -2659,6 +2768,8 @@ static void ieee80211_rx_bss_info(struct
2140 struct ieee80211_channel *channel;
2141 bool need_ps = false;
2142
2143 + lockdep_assert_held(&sdata->u.mgd.mtx);
2144 +
2145 if ((sdata->u.mgd.associated &&
2146 ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) ||
2147 (sdata->u.mgd.assoc_data &&
2148 @@ -2689,7 +2800,8 @@ static void ieee80211_rx_bss_info(struct
2149 if (bss)
2150 ieee80211_rx_bss_put(local, bss);
2151
2152 - if (!sdata->u.mgd.associated)
2153 + if (!sdata->u.mgd.associated ||
2154 + !ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid))
2155 return;
2156
2157 if (need_ps) {
2158 @@ -2698,10 +2810,9 @@ static void ieee80211_rx_bss_info(struct
2159 mutex_unlock(&local->iflist_mtx);
2160 }
2161
2162 - if (elems->ch_switch_ie &&
2163 - memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, ETH_ALEN) == 0)
2164 - ieee80211_sta_process_chanswitch(sdata, elems->ch_switch_ie,
2165 - bss, rx_status->mactime);
2166 + ieee80211_sta_process_chanswitch(sdata, rx_status->mactime,
2167 + elems, true);
2168 +
2169 }
2170
2171
2172 @@ -2726,7 +2837,7 @@ static void ieee80211_rx_mgmt_probe_resp
2173 return;
2174
2175 ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
2176 - &elems);
2177 + false, &elems);
2178
2179 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
2180
2181 @@ -2809,7 +2920,7 @@ ieee80211_rx_mgmt_beacon(struct ieee8021
2182 if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon &&
2183 ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) {
2184 ieee802_11_parse_elems(mgmt->u.beacon.variable,
2185 - len - baselen, &elems);
2186 + len - baselen, false, &elems);
2187
2188 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
2189 ifmgd->assoc_data->have_beacon = true;
2190 @@ -2919,7 +3030,7 @@ ieee80211_rx_mgmt_beacon(struct ieee8021
2191
2192 ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4);
2193 ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable,
2194 - len - baselen, &elems,
2195 + len - baselen, false, &elems,
2196 care_about_ies, ncrc);
2197
2198 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) {
2199 @@ -3066,6 +3177,8 @@ void ieee80211_sta_rx_queued_mgmt(struct
2200 enum rx_mgmt_action rma = RX_MGMT_NONE;
2201 u8 deauth_buf[IEEE80211_DEAUTH_FRAME_LEN];
2202 u16 fc;
2203 + struct ieee802_11_elems elems;
2204 + int ies_len;
2205
2206 rx_status = (struct ieee80211_rx_status *) skb->cb;
2207 mgmt = (struct ieee80211_mgmt *) skb->data;
2208 @@ -3095,14 +3208,48 @@ void ieee80211_sta_rx_queued_mgmt(struct
2209 rma = ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, &bss);
2210 break;
2211 case IEEE80211_STYPE_ACTION:
2212 - switch (mgmt->u.action.category) {
2213 - case WLAN_CATEGORY_SPECTRUM_MGMT:
2214 + if (mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) {
2215 + ies_len = skb->len -
2216 + offsetof(struct ieee80211_mgmt,
2217 + u.action.u.chan_switch.variable);
2218 +
2219 + if (ies_len < 0)
2220 + break;
2221 +
2222 + ieee802_11_parse_elems(
2223 + mgmt->u.action.u.chan_switch.variable,
2224 + ies_len, true, &elems);
2225 +
2226 + if (elems.parse_error)
2227 + break;
2228 +
2229 ieee80211_sta_process_chanswitch(sdata,
2230 - &mgmt->u.action.u.chan_switch.sw_elem,
2231 - (void *)ifmgd->associated->priv,
2232 - rx_status->mactime);
2233 - break;
2234 + rx_status->mactime,
2235 + &elems, false);
2236 + } else if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) {
2237 + ies_len = skb->len -
2238 + offsetof(struct ieee80211_mgmt,
2239 + u.action.u.ext_chan_switch.variable);
2240 +
2241 + if (ies_len < 0)
2242 + break;
2243 +
2244 + ieee802_11_parse_elems(
2245 + mgmt->u.action.u.ext_chan_switch.variable,
2246 + ies_len, true, &elems);
2247 +
2248 + if (elems.parse_error)
2249 + break;
2250 +
2251 + /* for the handling code pretend this was also an IE */
2252 + elems.ext_chansw_ie =
2253 + &mgmt->u.action.u.ext_chan_switch.data;
2254 +
2255 + ieee80211_sta_process_chanswitch(sdata,
2256 + rx_status->mactime,
2257 + &elems, false);
2258 }
2259 + break;
2260 }
2261 mutex_unlock(&ifmgd->mtx);
2262
2263 @@ -4197,7 +4344,7 @@ int ieee80211_mgd_deauth(struct ieee8021
2264 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2265 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
2266 bool tx = !req->local_state_change;
2267 - bool sent_frame = false;
2268 + bool report_frame = false;
2269
2270 mutex_lock(&ifmgd->mtx);
2271
2272 @@ -4214,7 +4361,7 @@ int ieee80211_mgd_deauth(struct ieee8021
2273 ieee80211_destroy_auth_data(sdata, false);
2274 mutex_unlock(&ifmgd->mtx);
2275
2276 - sent_frame = tx;
2277 + report_frame = true;
2278 goto out;
2279 }
2280
2281 @@ -4222,12 +4369,12 @@ int ieee80211_mgd_deauth(struct ieee8021
2282 ether_addr_equal(ifmgd->associated->bssid, req->bssid)) {
2283 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
2284 req->reason_code, tx, frame_buf);
2285 - sent_frame = tx;
2286 + report_frame = true;
2287 }
2288 mutex_unlock(&ifmgd->mtx);
2289
2290 out:
2291 - if (sent_frame)
2292 + if (report_frame)
2293 __cfg80211_send_deauth(sdata->dev, frame_buf,
2294 IEEE80211_DEAUTH_FRAME_LEN);
2295
2296 --- a/net/mac80211/pm.c
2297 +++ b/net/mac80211/pm.c
2298 @@ -38,8 +38,8 @@ int __ieee80211_suspend(struct ieee80211
2299 IEEE80211_MAX_QUEUE_MAP,
2300 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
2301
2302 - /* flush out all packets */
2303 - synchronize_net();
2304 + /* flush out all packets and station cleanup call_rcu()s */
2305 + rcu_barrier();
2306
2307 ieee80211_flush_queues(local, NULL);
2308
2309 --- a/net/mac80211/rate.c
2310 +++ b/net/mac80211/rate.c
2311 @@ -252,6 +252,25 @@ rate_lowest_non_cck_index(struct ieee802
2312 return 0;
2313 }
2314
2315 +static void __rate_control_send_low(struct ieee80211_hw *hw,
2316 + struct ieee80211_supported_band *sband,
2317 + struct ieee80211_sta *sta,
2318 + struct ieee80211_tx_info *info)
2319 +{
2320 + if ((sband->band != IEEE80211_BAND_2GHZ) ||
2321 + !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
2322 + info->control.rates[0].idx = rate_lowest_index(sband, sta);
2323 + else
2324 + info->control.rates[0].idx =
2325 + rate_lowest_non_cck_index(sband, sta);
2326 +
2327 + info->control.rates[0].count =
2328 + (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
2329 + 1 : hw->max_rate_tries;
2330 +
2331 + info->control.skip_table = 1;
2332 +}
2333 +
2334
2335 bool rate_control_send_low(struct ieee80211_sta *sta,
2336 void *priv_sta,
2337 @@ -262,16 +281,8 @@ bool rate_control_send_low(struct ieee80
2338 int mcast_rate;
2339
2340 if (!sta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
2341 - if ((sband->band != IEEE80211_BAND_2GHZ) ||
2342 - !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
2343 - info->control.rates[0].idx =
2344 - rate_lowest_index(txrc->sband, sta);
2345 - else
2346 - info->control.rates[0].idx =
2347 - rate_lowest_non_cck_index(txrc->sband, sta);
2348 - info->control.rates[0].count =
2349 - (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
2350 - 1 : txrc->hw->max_rate_tries;
2351 + __rate_control_send_low(txrc->hw, sband, sta, info);
2352 +
2353 if (!sta && txrc->bss) {
2354 mcast_rate = txrc->bss_conf->mcast_rate[sband->band];
2355 if (mcast_rate > 0) {
2356 @@ -355,7 +366,8 @@ static bool rate_idx_match_mcs_mask(stru
2357
2358
2359 static void rate_idx_match_mask(struct ieee80211_tx_rate *rate,
2360 - struct ieee80211_tx_rate_control *txrc,
2361 + struct ieee80211_supported_band *sband,
2362 + enum nl80211_chan_width chan_width,
2363 u32 mask,
2364 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN])
2365 {
2366 @@ -375,27 +387,17 @@ static void rate_idx_match_mask(struct i
2367 IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
2368 alt_rate.count = rate->count;
2369 if (rate_idx_match_legacy_mask(&alt_rate,
2370 - txrc->sband->n_bitrates,
2371 - mask)) {
2372 + sband->n_bitrates, mask)) {
2373 *rate = alt_rate;
2374 return;
2375 }
2376 } else {
2377 - struct sk_buff *skb = txrc->skb;
2378 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
2379 - __le16 fc;
2380 -
2381 /* handle legacy rates */
2382 - if (rate_idx_match_legacy_mask(rate, txrc->sband->n_bitrates,
2383 - mask))
2384 + if (rate_idx_match_legacy_mask(rate, sband->n_bitrates, mask))
2385 return;
2386
2387 /* if HT BSS, and we handle a data frame, also try HT rates */
2388 - if (txrc->bss_conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2389 - return;
2390 -
2391 - fc = hdr->frame_control;
2392 - if (!ieee80211_is_data(fc))
2393 + if (chan_width == NL80211_CHAN_WIDTH_20_NOHT)
2394 return;
2395
2396 alt_rate.idx = 0;
2397 @@ -408,7 +410,7 @@ static void rate_idx_match_mask(struct i
2398
2399 alt_rate.flags |= IEEE80211_TX_RC_MCS;
2400
2401 - if (txrc->bss_conf->chandef.width == NL80211_CHAN_WIDTH_40)
2402 + if (chan_width == NL80211_CHAN_WIDTH_40)
2403 alt_rate.flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
2404
2405 if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) {
2406 @@ -426,6 +428,228 @@ static void rate_idx_match_mask(struct i
2407 */
2408 }
2409
2410 +static void rate_fixup_ratelist(struct ieee80211_vif *vif,
2411 + struct ieee80211_supported_band *sband,
2412 + struct ieee80211_tx_info *info,
2413 + struct ieee80211_tx_rate *rates,
2414 + int max_rates)
2415 +{
2416 + struct ieee80211_rate *rate;
2417 + bool inval = false;
2418 + int i;
2419 +
2420 + /*
2421 + * Set up the RTS/CTS rate as the fastest basic rate
2422 + * that is not faster than the data rate unless there
2423 + * is no basic rate slower than the data rate, in which
2424 + * case we pick the slowest basic rate
2425 + *
2426 + * XXX: Should this check all retry rates?
2427 + */
2428 + if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
2429 + u32 basic_rates = vif->bss_conf.basic_rates;
2430 + s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0;
2431 +
2432 + rate = &sband->bitrates[rates[0].idx];
2433 +
2434 + for (i = 0; i < sband->n_bitrates; i++) {
2435 + /* must be a basic rate */
2436 + if (!(basic_rates & BIT(i)))
2437 + continue;
2438 + /* must not be faster than the data rate */
2439 + if (sband->bitrates[i].bitrate > rate->bitrate)
2440 + continue;
2441 + /* maximum */
2442 + if (sband->bitrates[baserate].bitrate <
2443 + sband->bitrates[i].bitrate)
2444 + baserate = i;
2445 + }
2446 +
2447 + info->control.rts_cts_rate_idx = baserate;
2448 + }
2449 +
2450 + for (i = 0; i < max_rates; i++) {
2451 + /*
2452 + * make sure there's no valid rate following
2453 + * an invalid one, just in case drivers don't
2454 + * take the API seriously to stop at -1.
2455 + */
2456 + if (inval) {
2457 + rates[i].idx = -1;
2458 + continue;
2459 + }
2460 + if (rates[i].idx < 0) {
2461 + inval = true;
2462 + continue;
2463 + }
2464 +
2465 + /*
2466 + * For now assume MCS is already set up correctly, this
2467 + * needs to be fixed.
2468 + */
2469 + if (rates[i].flags & IEEE80211_TX_RC_MCS) {
2470 + WARN_ON(rates[i].idx > 76);
2471 +
2472 + if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
2473 + info->control.use_cts_prot)
2474 + rates[i].flags |=
2475 + IEEE80211_TX_RC_USE_CTS_PROTECT;
2476 + continue;
2477 + }
2478 +
2479 + if (rates[i].flags & IEEE80211_TX_RC_VHT_MCS) {
2480 + WARN_ON(ieee80211_rate_get_vht_mcs(&rates[i]) > 9);
2481 + continue;
2482 + }
2483 +
2484 + /* set up RTS protection if desired */
2485 + if (info->control.use_rts) {
2486 + rates[i].flags |= IEEE80211_TX_RC_USE_RTS_CTS;
2487 + info->control.use_cts_prot = false;
2488 + }
2489 +
2490 + /* RC is busted */
2491 + if (WARN_ON_ONCE(rates[i].idx >= sband->n_bitrates)) {
2492 + rates[i].idx = -1;
2493 + continue;
2494 + }
2495 +
2496 + rate = &sband->bitrates[rates[i].idx];
2497 +
2498 + /* set up short preamble */
2499 + if (info->control.short_preamble &&
2500 + rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
2501 + rates[i].flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
2502 +
2503 + /* set up G protection */
2504 + if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
2505 + info->control.use_cts_prot &&
2506 + rate->flags & IEEE80211_RATE_ERP_G)
2507 + rates[i].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT;
2508 + }
2509 +}
2510 +
2511 +
2512 +static void rate_control_fill_sta_table(struct ieee80211_sta *sta,
2513 + struct ieee80211_tx_info *info,
2514 + struct ieee80211_tx_rate *rates,
2515 + int max_rates)
2516 +{
2517 + struct ieee80211_sta_rates *ratetbl = NULL;
2518 + int i;
2519 +
2520 + if (sta && !info->control.skip_table)
2521 + ratetbl = rcu_dereference(sta->rates);
2522 +
2523 + /* Fill remaining rate slots with data from the sta rate table. */
2524 + max_rates = min_t(int, max_rates, IEEE80211_TX_RATE_TABLE_SIZE);
2525 + for (i = 0; i < max_rates; i++) {
2526 + if (i < ARRAY_SIZE(info->control.rates) &&
2527 + info->control.rates[i].idx >= 0 &&
2528 + info->control.rates[i].count) {
2529 + if (rates != info->control.rates)
2530 + rates[i] = info->control.rates[i];
2531 + } else if (ratetbl) {
2532 + rates[i].idx = ratetbl->rate[i].idx;
2533 + rates[i].flags = ratetbl->rate[i].flags;
2534 + if (info->control.use_rts)
2535 + rates[i].count = ratetbl->rate[i].count_rts;
2536 + else if (info->control.use_cts_prot)
2537 + rates[i].count = ratetbl->rate[i].count_cts;
2538 + else
2539 + rates[i].count = ratetbl->rate[i].count;
2540 + } else {
2541 + rates[i].idx = -1;
2542 + rates[i].count = 0;
2543 + }
2544 +
2545 + if (rates[i].idx < 0 || !rates[i].count)
2546 + break;
2547 + }
2548 +}
2549 +
2550 +static void rate_control_apply_mask(struct ieee80211_sub_if_data *sdata,
2551 + struct ieee80211_sta *sta,
2552 + struct ieee80211_supported_band *sband,
2553 + struct ieee80211_tx_info *info,
2554 + struct ieee80211_tx_rate *rates,
2555 + int max_rates)
2556 +{
2557 + enum nl80211_chan_width chan_width;
2558 + u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
2559 + bool has_mcs_mask;
2560 + u32 mask;
2561 + int i;
2562 +
2563 + /*
2564 + * Try to enforce the rateidx mask the user wanted. skip this if the
2565 + * default mask (allow all rates) is used to save some processing for
2566 + * the common case.
2567 + */
2568 + mask = sdata->rc_rateidx_mask[info->band];
2569 + has_mcs_mask = sdata->rc_has_mcs_mask[info->band];
2570 + if (mask == (1 << sband->n_bitrates) - 1 && !has_mcs_mask)
2571 + return;
2572 +
2573 + if (has_mcs_mask)
2574 + memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
2575 + sizeof(mcs_mask));
2576 + else
2577 + memset(mcs_mask, 0xff, sizeof(mcs_mask));
2578 +
2579 + if (sta) {
2580 + /* Filter out rates that the STA does not support */
2581 + mask &= sta->supp_rates[info->band];
2582 + for (i = 0; i < sizeof(mcs_mask); i++)
2583 + mcs_mask[i] &= sta->ht_cap.mcs.rx_mask[i];
2584 + }
2585 +
2586 + /*
2587 + * Make sure the rate index selected for each TX rate is
2588 + * included in the configured mask and change the rate indexes
2589 + * if needed.
2590 + */
2591 + chan_width = sdata->vif.bss_conf.chandef.width;
2592 + for (i = 0; i < max_rates; i++) {
2593 + /* Skip invalid rates */
2594 + if (rates[i].idx < 0)
2595 + break;
2596 +
2597 + rate_idx_match_mask(&rates[i], sband, chan_width, mask,
2598 + mcs_mask);
2599 + }
2600 +}
2601 +
2602 +void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
2603 + struct ieee80211_sta *sta,
2604 + struct sk_buff *skb,
2605 + struct ieee80211_tx_rate *dest,
2606 + int max_rates)
2607 +{
2608 + struct ieee80211_sub_if_data *sdata;
2609 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
2610 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2611 + struct ieee80211_supported_band *sband;
2612 +
2613 + rate_control_fill_sta_table(sta, info, dest, max_rates);
2614 +
2615 + if (!vif)
2616 + return;
2617 +
2618 + sdata = vif_to_sdata(vif);
2619 + sband = sdata->local->hw.wiphy->bands[info->band];
2620 +
2621 + if (ieee80211_is_data(hdr->frame_control))
2622 + rate_control_apply_mask(sdata, sta, sband, info, dest, max_rates);
2623 +
2624 + if (dest[0].idx < 0)
2625 + __rate_control_send_low(&sdata->local->hw, sband, sta, info);
2626 +
2627 + if (sta)
2628 + rate_fixup_ratelist(vif, sband, info, dest, max_rates);
2629 +}
2630 +EXPORT_SYMBOL(ieee80211_get_tx_rates);
2631 +
2632 void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
2633 struct sta_info *sta,
2634 struct ieee80211_tx_rate_control *txrc)
2635 @@ -435,8 +659,6 @@ void rate_control_get_rate(struct ieee80
2636 struct ieee80211_sta *ista = NULL;
2637 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
2638 int i;
2639 - u32 mask;
2640 - u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
2641
2642 if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) {
2643 ista = &sta->sta;
2644 @@ -454,37 +676,27 @@ void rate_control_get_rate(struct ieee80
2645
2646 ref->ops->get_rate(ref->priv, ista, priv_sta, txrc);
2647
2648 - /*
2649 - * Try to enforce the rateidx mask the user wanted. skip this if the
2650 - * default mask (allow all rates) is used to save some processing for
2651 - * the common case.
2652 - */
2653 - mask = sdata->rc_rateidx_mask[info->band];
2654 - memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
2655 - sizeof(mcs_mask));
2656 - if (mask != (1 << txrc->sband->n_bitrates) - 1) {
2657 - if (sta) {
2658 - /* Filter out rates that the STA does not support */
2659 - mask &= sta->sta.supp_rates[info->band];
2660 - for (i = 0; i < sizeof(mcs_mask); i++)
2661 - mcs_mask[i] &= sta->sta.ht_cap.mcs.rx_mask[i];
2662 - }
2663 - /*
2664 - * Make sure the rate index selected for each TX rate is
2665 - * included in the configured mask and change the rate indexes
2666 - * if needed.
2667 - */
2668 - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
2669 - /* Skip invalid rates */
2670 - if (info->control.rates[i].idx < 0)
2671 - break;
2672 - rate_idx_match_mask(&info->control.rates[i], txrc,
2673 - mask, mcs_mask);
2674 - }
2675 - }
2676 + if (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_RC_TABLE)
2677 + return;
2678
2679 - BUG_ON(info->control.rates[0].idx < 0);
2680 + ieee80211_get_tx_rates(&sdata->vif, ista, txrc->skb,
2681 + info->control.rates,
2682 + ARRAY_SIZE(info->control.rates));
2683 +}
2684 +
2685 +int rate_control_set_rates(struct ieee80211_hw *hw,
2686 + struct ieee80211_sta *pubsta,
2687 + struct ieee80211_sta_rates *rates)
2688 +{
2689 + struct ieee80211_sta_rates *old = rcu_dereference(pubsta->rates);
2690 +
2691 + rcu_assign_pointer(pubsta->rates, rates);
2692 + if (old)
2693 + kfree_rcu(old, rcu_head);
2694 +
2695 + return 0;
2696 }
2697 +EXPORT_SYMBOL(rate_control_set_rates);
2698
2699 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
2700 const char *name)
2701 --- a/net/mac80211/rc80211_minstrel.c
2702 +++ b/net/mac80211/rc80211_minstrel.c
2703 @@ -84,6 +84,50 @@ minstrel_sort_best_tp_rates(struct minst
2704 }
2705
2706 static void
2707 +minstrel_set_rate(struct minstrel_sta_info *mi, struct ieee80211_sta_rates *ratetbl,
2708 + int offset, int idx)
2709 +{
2710 + struct minstrel_rate *r = &mi->r[idx];
2711 +
2712 + ratetbl->rate[offset].idx = r->rix;
2713 + ratetbl->rate[offset].count = r->adjusted_retry_count;
2714 + ratetbl->rate[offset].count_cts = r->retry_count_cts;
2715 + ratetbl->rate[offset].count_rts = r->retry_count_rtscts;
2716 +}
2717 +
2718 +static void
2719 +minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
2720 +{
2721 + struct ieee80211_sta_rates *ratetbl;
2722 + int i = 0;
2723 +
2724 + ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC);
2725 + if (!ratetbl)
2726 + return;
2727 +
2728 + /* Start with max_tp_rate */
2729 + minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[0]);
2730 +
2731 + if (mp->hw->max_rates >= 3) {
2732 + /* At least 3 tx rates supported, use max_tp_rate2 next */
2733 + minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[1]);
2734 + }
2735 +
2736 + if (mp->hw->max_rates >= 2) {
2737 + /* At least 2 tx rates supported, use max_prob_rate next */
2738 + minstrel_set_rate(mi, ratetbl, i++, mi->max_prob_rate);
2739 + }
2740 +
2741 + /* Use lowest rate last */
2742 + ratetbl->rate[i].idx = mi->lowest_rix;
2743 + ratetbl->rate[i].count = mp->max_retry;
2744 + ratetbl->rate[i].count_cts = mp->max_retry;
2745 + ratetbl->rate[i].count_rts = mp->max_retry;
2746 +
2747 + rate_control_set_rates(mp->hw, mi->sta, ratetbl);
2748 +}
2749 +
2750 +static void
2751 minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
2752 {
2753 u8 tmp_tp_rate[MAX_THR_RATES];
2754 @@ -161,6 +205,8 @@ minstrel_update_stats(struct minstrel_pr
2755
2756 /* Reset update timer */
2757 mi->stats_update = jiffies;
2758 +
2759 + minstrel_update_rates(mp, mi);
2760 }
2761
2762 static void
2763 @@ -209,9 +255,9 @@ minstrel_get_retry_count(struct minstrel
2764 {
2765 unsigned int retry = mr->adjusted_retry_count;
2766
2767 - if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
2768 + if (info->control.use_rts)
2769 retry = max(2U, min(mr->retry_count_rtscts, retry));
2770 - else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
2771 + else if (info->control.use_cts_prot)
2772 retry = max(2U, min(mr->retry_count_cts, retry));
2773 return retry;
2774 }
2775 @@ -240,13 +286,12 @@ minstrel_get_rate(void *priv, struct iee
2776 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2777 struct minstrel_sta_info *mi = priv_sta;
2778 struct minstrel_priv *mp = priv;
2779 - struct ieee80211_tx_rate *ar = info->control.rates;
2780 - unsigned int ndx, sample_ndx = 0;
2781 + struct ieee80211_tx_rate *rate = &info->control.rates[0];
2782 + struct minstrel_rate *msr, *mr;
2783 + unsigned int ndx;
2784 bool mrr_capable;
2785 - bool indirect_rate_sampling = false;
2786 - bool rate_sampling = false;
2787 - int i, delta;
2788 - int mrr_ndx[3];
2789 + bool prev_sample = mi->prev_sample;
2790 + int delta;
2791 int sampling_ratio;
2792
2793 /* management/no-ack frames do not use rate control */
2794 @@ -262,107 +307,75 @@ minstrel_get_rate(void *priv, struct iee
2795 else
2796 sampling_ratio = mp->lookaround_rate;
2797
2798 - /* init rateindex [ndx] with max throughput rate */
2799 - ndx = mi->max_tp_rate[0];
2800 -
2801 /* increase sum packet counter */
2802 mi->packet_count++;
2803
2804 delta = (mi->packet_count * sampling_ratio / 100) -
2805 (mi->sample_count + mi->sample_deferred / 2);
2806
2807 - /* delta > 0: sampling required */
2808 - if ((delta > 0) && (mrr_capable || !mi->prev_sample)) {
2809 - struct minstrel_rate *msr;
2810 - if (mi->packet_count >= 10000) {
2811 - mi->sample_deferred = 0;
2812 - mi->sample_count = 0;
2813 - mi->packet_count = 0;
2814 - } else if (delta > mi->n_rates * 2) {
2815 - /* With multi-rate retry, not every planned sample
2816 - * attempt actually gets used, due to the way the retry
2817 - * chain is set up - [max_tp,sample,prob,lowest] for
2818 - * sample_rate < max_tp.
2819 - *
2820 - * If there's too much sampling backlog and the link
2821 - * starts getting worse, minstrel would start bursting
2822 - * out lots of sampling frames, which would result
2823 - * in a large throughput loss. */
2824 - mi->sample_count += (delta - mi->n_rates * 2);
2825 - }
2826 + /* delta < 0: no sampling required */
2827 + mi->prev_sample = false;
2828 + if (delta < 0 || (!mrr_capable && prev_sample))
2829 + return;
2830
2831 - /* get next random rate sample */
2832 - sample_ndx = minstrel_get_next_sample(mi);
2833 - msr = &mi->r[sample_ndx];
2834 - rate_sampling = true;
2835 -
2836 - /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage)
2837 - * rate sampling method should be used.
2838 - * Respect such rates that are not sampled for 20 interations.
2839 - */
2840 - if (mrr_capable &&
2841 - msr->perfect_tx_time > mi->r[ndx].perfect_tx_time &&
2842 - msr->sample_skipped < 20)
2843 - indirect_rate_sampling = true;
2844 -
2845 - if (!indirect_rate_sampling) {
2846 - if (msr->sample_limit != 0) {
2847 - ndx = sample_ndx;
2848 - mi->sample_count++;
2849 - if (msr->sample_limit > 0)
2850 - msr->sample_limit--;
2851 - } else
2852 - rate_sampling = false;
2853 - } else {
2854 - /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark
2855 - * packets that have the sampling rate deferred to the
2856 - * second MRR stage. Increase the sample counter only
2857 - * if the deferred sample rate was actually used.
2858 - * Use the sample_deferred counter to make sure that
2859 - * the sampling is not done in large bursts */
2860 - info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
2861 - mi->sample_deferred++;
2862 - }
2863 + if (mi->packet_count >= 10000) {
2864 + mi->sample_deferred = 0;
2865 + mi->sample_count = 0;
2866 + mi->packet_count = 0;
2867 + } else if (delta > mi->n_rates * 2) {
2868 + /* With multi-rate retry, not every planned sample
2869 + * attempt actually gets used, due to the way the retry
2870 + * chain is set up - [max_tp,sample,prob,lowest] for
2871 + * sample_rate < max_tp.
2872 + *
2873 + * If there's too much sampling backlog and the link
2874 + * starts getting worse, minstrel would start bursting
2875 + * out lots of sampling frames, which would result
2876 + * in a large throughput loss. */
2877 + mi->sample_count += (delta - mi->n_rates * 2);
2878 + }
2879 +
2880 + /* get next random rate sample */
2881 + ndx = minstrel_get_next_sample(mi);
2882 + msr = &mi->r[ndx];
2883 + mr = &mi->r[mi->max_tp_rate[0]];
2884 +
2885 + /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage)
2886 + * rate sampling method should be used.
2887 + * Respect such rates that are not sampled for 20 interations.
2888 + */
2889 + if (mrr_capable &&
2890 + msr->perfect_tx_time > mr->perfect_tx_time &&
2891 + msr->sample_skipped < 20) {
2892 + /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark
2893 + * packets that have the sampling rate deferred to the
2894 + * second MRR stage. Increase the sample counter only
2895 + * if the deferred sample rate was actually used.
2896 + * Use the sample_deferred counter to make sure that
2897 + * the sampling is not done in large bursts */
2898 + info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
2899 + rate++;
2900 + mi->sample_deferred++;
2901 + } else {
2902 + if (!msr->sample_limit != 0)
2903 + return;
2904 +
2905 + mi->sample_count++;
2906 + if (msr->sample_limit > 0)
2907 + msr->sample_limit--;
2908 }
2909 - mi->prev_sample = rate_sampling;
2910
2911 /* If we're not using MRR and the sampling rate already
2912 * has a probability of >95%, we shouldn't be attempting
2913 * to use it, as this only wastes precious airtime */
2914 - if (!mrr_capable && rate_sampling &&
2915 + if (!mrr_capable &&
2916 (mi->r[ndx].probability > MINSTREL_FRAC(95, 100)))
2917 - ndx = mi->max_tp_rate[0];
2918 -
2919 - /* mrr setup for 1st stage */
2920 - ar[0].idx = mi->r[ndx].rix;
2921 - ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info);
2922 -
2923 - /* non mrr setup for 2nd stage */
2924 - if (!mrr_capable) {
2925 - if (!rate_sampling)
2926 - ar[0].count = mp->max_retry;
2927 - ar[1].idx = mi->lowest_rix;
2928 - ar[1].count = mp->max_retry;
2929 return;
2930 - }
2931
2932 - /* mrr setup for 2nd stage */
2933 - if (rate_sampling) {
2934 - if (indirect_rate_sampling)
2935 - mrr_ndx[0] = sample_ndx;
2936 - else
2937 - mrr_ndx[0] = mi->max_tp_rate[0];
2938 - } else {
2939 - mrr_ndx[0] = mi->max_tp_rate[1];
2940 - }
2941 + mi->prev_sample = true;
2942
2943 - /* mrr setup for 3rd & 4th stage */
2944 - mrr_ndx[1] = mi->max_prob_rate;
2945 - mrr_ndx[2] = 0;
2946 - for (i = 1; i < 4; i++) {
2947 - ar[i].idx = mi->r[mrr_ndx[i - 1]].rix;
2948 - ar[i].count = mi->r[mrr_ndx[i - 1]].adjusted_retry_count;
2949 - }
2950 + rate->idx = mi->r[ndx].rix;
2951 + rate->count = minstrel_get_retry_count(&mi->r[ndx], info);
2952 }
2953
2954
2955 @@ -412,12 +425,16 @@ minstrel_rate_init(void *priv, struct ie
2956 unsigned int i, n = 0;
2957 unsigned int t_slot = 9; /* FIXME: get real slot time */
2958
2959 + mi->sta = sta;
2960 mi->lowest_rix = rate_lowest_index(sband, sta);
2961 ctl_rate = &sband->bitrates[mi->lowest_rix];
2962 mi->sp_ack_dur = ieee80211_frame_duration(sband->band, 10,
2963 ctl_rate->bitrate,
2964 !!(ctl_rate->flags & IEEE80211_RATE_ERP_G), 1);
2965
2966 + memset(mi->max_tp_rate, 0, sizeof(mi->max_tp_rate));
2967 + mi->max_prob_rate = 0;
2968 +
2969 for (i = 0; i < sband->n_bitrates; i++) {
2970 struct minstrel_rate *mr = &mi->r[n];
2971 unsigned int tx_time = 0, tx_time_cts = 0, tx_time_rtscts = 0;
2972 @@ -460,6 +477,8 @@ minstrel_rate_init(void *priv, struct ie
2973 } while ((tx_time < mp->segment_size) &&
2974 (++mr->retry_count < mp->max_retry));
2975 mr->adjusted_retry_count = mr->retry_count;
2976 + if (!(sband->bitrates[i].flags & IEEE80211_RATE_ERP_G))
2977 + mr->retry_count_cts = mr->retry_count;
2978 }
2979
2980 for (i = n; i < sband->n_bitrates; i++) {
2981 @@ -471,6 +490,7 @@ minstrel_rate_init(void *priv, struct ie
2982 mi->stats_update = jiffies;
2983
2984 init_sample_table(mi);
2985 + minstrel_update_rates(mp, mi);
2986 }
2987
2988 static void *
2989 --- a/net/mac80211/rc80211_minstrel.h
2990 +++ b/net/mac80211/rc80211_minstrel.h
2991 @@ -9,7 +9,8 @@
2992 #ifndef __RC_MINSTREL_H
2993 #define __RC_MINSTREL_H
2994
2995 -#define EWMA_LEVEL 75 /* ewma weighting factor [%] */
2996 +#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */
2997 +#define EWMA_DIV 128
2998 #define SAMPLE_COLUMNS 10 /* number of columns in sample table */
2999
3000
3001 @@ -27,7 +28,7 @@
3002 static inline int
3003 minstrel_ewma(int old, int new, int weight)
3004 {
3005 - return (new * (100 - weight) + old * weight) / 100;
3006 + return (new * (EWMA_DIV - weight) + old * weight) / EWMA_DIV;
3007 }
3008
3009
3010 @@ -62,6 +63,8 @@ struct minstrel_rate {
3011 };
3012
3013 struct minstrel_sta_info {
3014 + struct ieee80211_sta *sta;
3015 +
3016 unsigned long stats_update;
3017 unsigned int sp_ack_dur;
3018 unsigned int rate_avg;
3019 --- a/net/mac80211/rc80211_minstrel_debugfs.c
3020 +++ b/net/mac80211/rc80211_minstrel_debugfs.c
3021 @@ -68,7 +68,7 @@ minstrel_stats_open(struct inode *inode,
3022
3023 file->private_data = ms;
3024 p = ms->buf;
3025 - p += sprintf(p, "rate throughput ewma prob this prob "
3026 + p += sprintf(p, "rate throughput ewma prob this prob "
3027 "this succ/attempt success attempts\n");
3028 for (i = 0; i < mi->n_rates; i++) {
3029 struct minstrel_rate *mr = &mi->r[i];
3030 @@ -86,7 +86,7 @@ minstrel_stats_open(struct inode *inode,
3031 eprob = MINSTREL_TRUNC(mr->probability * 1000);
3032
3033 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u "
3034 - "%3u(%3u) %8llu %8llu\n",
3035 + " %3u(%3u) %8llu %8llu\n",
3036 tp / 10, tp % 10,
3037 eprob / 10, eprob % 10,
3038 prob / 10, prob % 10,
3039 --- a/net/mac80211/rc80211_minstrel_ht.c
3040 +++ b/net/mac80211/rc80211_minstrel_ht.c
3041 @@ -126,6 +126,9 @@ const struct mcs_group minstrel_mcs_grou
3042
3043 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
3044
3045 +static void
3046 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi);
3047 +
3048 /*
3049 * Look up an MCS group index based on mac80211 rate information
3050 */
3051 @@ -244,6 +247,7 @@ minstrel_ht_update_stats(struct minstrel
3052 struct minstrel_rate_stats *mr;
3053 int cur_prob, cur_prob_tp, cur_tp, cur_tp2;
3054 int group, i, index;
3055 + bool mi_rates_valid = false;
3056
3057 if (mi->ampdu_packets > 0) {
3058 mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
3059 @@ -254,11 +258,10 @@ minstrel_ht_update_stats(struct minstrel
3060
3061 mi->sample_slow = 0;
3062 mi->sample_count = 0;
3063 - mi->max_tp_rate = 0;
3064 - mi->max_tp_rate2 = 0;
3065 - mi->max_prob_rate = 0;
3066
3067 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
3068 + bool mg_rates_valid = false;
3069 +
3070 cur_prob = 0;
3071 cur_prob_tp = 0;
3072 cur_tp = 0;
3073 @@ -268,15 +271,24 @@ minstrel_ht_update_stats(struct minstrel
3074 if (!mg->supported)
3075 continue;
3076
3077 - mg->max_tp_rate = 0;
3078 - mg->max_tp_rate2 = 0;
3079 - mg->max_prob_rate = 0;
3080 mi->sample_count++;
3081
3082 for (i = 0; i < MCS_GROUP_RATES; i++) {
3083 if (!(mg->supported & BIT(i)))
3084 continue;
3085
3086 + /* initialize rates selections starting indexes */
3087 + if (!mg_rates_valid) {
3088 + mg->max_tp_rate = mg->max_tp_rate2 =
3089 + mg->max_prob_rate = i;
3090 + if (!mi_rates_valid) {
3091 + mi->max_tp_rate = mi->max_tp_rate2 =
3092 + mi->max_prob_rate = i;
3093 + mi_rates_valid = true;
3094 + }
3095 + mg_rates_valid = true;
3096 + }
3097 +
3098 mr = &mg->rates[i];
3099 mr->retry_updated = false;
3100 index = MCS_GROUP_RATES * group + i;
3101 @@ -456,7 +468,7 @@ minstrel_ht_tx_status(void *priv, struct
3102 struct ieee80211_tx_rate *ar = info->status.rates;
3103 struct minstrel_rate_stats *rate, *rate2;
3104 struct minstrel_priv *mp = priv;
3105 - bool last;
3106 + bool last, update = false;
3107 int i;
3108
3109 if (!msp->is_ht)
3110 @@ -505,21 +517,29 @@ minstrel_ht_tx_status(void *priv, struct
3111 rate = minstrel_get_ratestats(mi, mi->max_tp_rate);
3112 if (rate->attempts > 30 &&
3113 MINSTREL_FRAC(rate->success, rate->attempts) <
3114 - MINSTREL_FRAC(20, 100))
3115 + MINSTREL_FRAC(20, 100)) {
3116 minstrel_downgrade_rate(mi, &mi->max_tp_rate, true);
3117 + update = true;
3118 + }
3119
3120 rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2);
3121 if (rate2->attempts > 30 &&
3122 MINSTREL_FRAC(rate2->success, rate2->attempts) <
3123 - MINSTREL_FRAC(20, 100))
3124 + MINSTREL_FRAC(20, 100)) {
3125 minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false);
3126 + update = true;
3127 + }
3128
3129 if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
3130 + update = true;
3131 minstrel_ht_update_stats(mp, mi);
3132 if (!(info->flags & IEEE80211_TX_CTL_AMPDU) &&
3133 mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP)
3134 minstrel_aggr_check(sta, skb);
3135 }
3136 +
3137 + if (update)
3138 + minstrel_ht_update_rates(mp, mi);
3139 }
3140
3141 static void
3142 @@ -580,39 +600,73 @@ minstrel_calc_retransmit(struct minstrel
3143 (++mr->retry_count < mp->max_retry));
3144 }
3145
3146 -
3147 static void
3148 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
3149 - struct ieee80211_tx_rate *rate, int index,
3150 - bool sample, bool rtscts)
3151 + struct ieee80211_sta_rates *ratetbl, int offset, int index)
3152 {
3153 const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
3154 struct minstrel_rate_stats *mr;
3155 + u8 idx;
3156 + u16 flags;
3157
3158 mr = minstrel_get_ratestats(mi, index);
3159 if (!mr->retry_updated)
3160 minstrel_calc_retransmit(mp, mi, index);
3161
3162 - if (sample)
3163 - rate->count = 1;
3164 - else if (mr->probability < MINSTREL_FRAC(20, 100))
3165 - rate->count = 2;
3166 - else if (rtscts)
3167 - rate->count = mr->retry_count_rtscts;
3168 - else
3169 - rate->count = mr->retry_count;
3170 -
3171 - rate->flags = 0;
3172 - if (rtscts)
3173 - rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
3174 + if (mr->probability < MINSTREL_FRAC(20, 100) || !mr->retry_count) {
3175 + ratetbl->rate[offset].count = 2;
3176 + ratetbl->rate[offset].count_rts = 2;
3177 + ratetbl->rate[offset].count_cts = 2;
3178 + } else {
3179 + ratetbl->rate[offset].count = mr->retry_count;
3180 + ratetbl->rate[offset].count_cts = mr->retry_count;
3181 + ratetbl->rate[offset].count_rts = mr->retry_count_rtscts;
3182 + }
3183
3184 if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
3185 - rate->idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
3186 + idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
3187 + flags = 0;
3188 + } else {
3189 + idx = index % MCS_GROUP_RATES +
3190 + (group->streams - 1) * MCS_GROUP_RATES;
3191 + flags = IEEE80211_TX_RC_MCS | group->flags;
3192 + }
3193 +
3194 + if (offset > 0) {
3195 + ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
3196 + flags |= IEEE80211_TX_RC_USE_RTS_CTS;
3197 + }
3198 +
3199 + ratetbl->rate[offset].idx = idx;
3200 + ratetbl->rate[offset].flags = flags;
3201 +}
3202 +
3203 +static void
3204 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
3205 +{
3206 + struct ieee80211_sta_rates *rates;
3207 + int i = 0;
3208 +
3209 + rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
3210 + if (!rates)
3211 return;
3212 +
3213 + /* Start with max_tp_rate */
3214 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate);
3215 +
3216 + if (mp->hw->max_rates >= 3) {
3217 + /* At least 3 tx rates supported, use max_tp_rate2 next */
3218 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate2);
3219 + }
3220 +
3221 + if (mp->hw->max_rates >= 2) {
3222 + /*
3223 + * At least 2 tx rates supported, use max_prob_rate next */
3224 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate);
3225 }
3226
3227 - rate->flags |= IEEE80211_TX_RC_MCS | group->flags;
3228 - rate->idx = index % MCS_GROUP_RATES + (group->streams - 1) * MCS_GROUP_RATES;
3229 + rates->rate[i].idx = -1;
3230 + rate_control_set_rates(mp->hw, mi->sta, rates);
3231 }
3232
3233 static inline int
3234 @@ -702,13 +756,13 @@ static void
3235 minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
3236 struct ieee80211_tx_rate_control *txrc)
3237 {
3238 + const struct mcs_group *sample_group;
3239 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
3240 - struct ieee80211_tx_rate *ar = info->status.rates;
3241 + struct ieee80211_tx_rate *rate = &info->status.rates[0];
3242 struct minstrel_ht_sta_priv *msp = priv_sta;
3243 struct minstrel_ht_sta *mi = &msp->ht;
3244 struct minstrel_priv *mp = priv;
3245 int sample_idx;
3246 - bool sample = false;
3247
3248 if (rate_control_send_low(sta, priv_sta, txrc))
3249 return;
3250 @@ -736,51 +790,6 @@ minstrel_ht_get_rate(void *priv, struct
3251 }
3252 #endif
3253
3254 - if (sample_idx >= 0) {
3255 - sample = true;
3256 - minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx,
3257 - true, false);
3258 - info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
3259 - } else {
3260 - minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate,
3261 - false, false);
3262 - }
3263 -
3264 - if (mp->hw->max_rates >= 3) {
3265 - /*
3266 - * At least 3 tx rates supported, use
3267 - * sample_rate -> max_tp_rate -> max_prob_rate for sampling and
3268 - * max_tp_rate -> max_tp_rate2 -> max_prob_rate by default.
3269 - */
3270 - if (sample_idx >= 0)
3271 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate,
3272 - false, false);
3273 - else
3274 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2,
3275 - false, true);
3276 -
3277 - minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate,
3278 - false, !sample);
3279 -
3280 - ar[3].count = 0;
3281 - ar[3].idx = -1;
3282 - } else if (mp->hw->max_rates == 2) {
3283 - /*
3284 - * Only 2 tx rates supported, use
3285 - * sample_rate -> max_prob_rate for sampling and
3286 - * max_tp_rate -> max_prob_rate by default.
3287 - */
3288 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_prob_rate,
3289 - false, !sample);
3290 -
3291 - ar[2].count = 0;
3292 - ar[2].idx = -1;
3293 - } else {
3294 - /* Not using MRR, only use the first rate */
3295 - ar[1].count = 0;
3296 - ar[1].idx = -1;
3297 - }
3298 -
3299 mi->total_packets++;
3300
3301 /* wraparound */
3302 @@ -788,6 +797,16 @@ minstrel_ht_get_rate(void *priv, struct
3303 mi->total_packets = 0;
3304 mi->sample_packets = 0;
3305 }
3306 +
3307 + if (sample_idx < 0)
3308 + return;
3309 +
3310 + sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
3311 + info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
3312 + rate->idx = sample_idx % MCS_GROUP_RATES +
3313 + (sample_group->streams - 1) * MCS_GROUP_RATES;
3314 + rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
3315 + rate->count = 1;
3316 }
3317
3318 static void
3319 @@ -837,6 +856,8 @@ minstrel_ht_update_caps(void *priv, stru
3320
3321 msp->is_ht = true;
3322 memset(mi, 0, sizeof(*mi));
3323 +
3324 + mi->sta = sta;
3325 mi->stats_update = jiffies;
3326
3327 ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1);
3328 @@ -898,6 +919,9 @@ minstrel_ht_update_caps(void *priv, stru
3329 if (!n_supported)
3330 goto use_legacy;
3331
3332 + minstrel_ht_update_stats(mp, mi);
3333 + minstrel_ht_update_rates(mp, mi);
3334 +
3335 return;
3336
3337 use_legacy:
3338 --- a/net/mac80211/rc80211_minstrel_ht.h
3339 +++ b/net/mac80211/rc80211_minstrel_ht.h
3340 @@ -65,6 +65,8 @@ struct minstrel_mcs_group_data {
3341 };
3342
3343 struct minstrel_ht_sta {
3344 + struct ieee80211_sta *sta;
3345 +
3346 /* ampdu length (average, per sampling interval) */
3347 unsigned int ampdu_len;
3348 unsigned int ampdu_packets;
3349 --- a/net/mac80211/rx.c
3350 +++ b/net/mac80211/rx.c
3351 @@ -1372,6 +1372,7 @@ ieee80211_rx_h_sta_process(struct ieee80
3352 struct sk_buff *skb = rx->skb;
3353 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
3354 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
3355 + int i;
3356
3357 if (!sta)
3358 return RX_CONTINUE;
3359 @@ -1422,6 +1423,19 @@ ieee80211_rx_h_sta_process(struct ieee80
3360 ewma_add(&sta->avg_signal, -status->signal);
3361 }
3362
3363 + if (status->chains) {
3364 + sta->chains = status->chains;
3365 + for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) {
3366 + int signal = status->chain_signal[i];
3367 +
3368 + if (!(status->chains & BIT(i)))
3369 + continue;
3370 +
3371 + sta->chain_signal_last[i] = signal;
3372 + ewma_add(&sta->chain_signal_avg[i], -signal);
3373 + }
3374 + }
3375 +
3376 /*
3377 * Change STA power saving mode only at the end of a frame
3378 * exchange sequence.
3379 @@ -2085,6 +2099,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
3380 }
3381
3382 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data;
3383 + fwd_hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_RETRY);
3384 info = IEEE80211_SKB_CB(fwd_skb);
3385 memset(info, 0, sizeof(*info));
3386 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
3387 @@ -2356,6 +2371,7 @@ ieee80211_rx_h_action(struct ieee80211_r
3388 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
3389 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
3390 sdata->vif.type != NL80211_IFTYPE_AP &&
3391 + sdata->vif.type != NL80211_IFTYPE_WDS &&
3392 sdata->vif.type != NL80211_IFTYPE_ADHOC)
3393 break;
3394
3395 @@ -2423,6 +2439,22 @@ ieee80211_rx_h_action(struct ieee80211_r
3396 }
3397
3398 break;
3399 + case WLAN_CATEGORY_PUBLIC:
3400 + if (len < IEEE80211_MIN_ACTION_SIZE + 1)
3401 + goto invalid;
3402 + if (sdata->vif.type != NL80211_IFTYPE_STATION)
3403 + break;
3404 + if (!rx->sta)
3405 + break;
3406 + if (!ether_addr_equal(mgmt->bssid, sdata->u.mgd.bssid))
3407 + break;
3408 + if (mgmt->u.action.u.ext_chan_switch.action_code !=
3409 + WLAN_PUB_ACTION_EXT_CHANSW_ANN)
3410 + break;
3411 + if (len < offsetof(struct ieee80211_mgmt,
3412 + u.action.u.ext_chan_switch.variable))
3413 + goto invalid;
3414 + goto queue;
3415 case WLAN_CATEGORY_VHT:
3416 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
3417 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
3418 @@ -2506,10 +2538,6 @@ ieee80211_rx_h_action(struct ieee80211_r
3419 ieee80211_process_measurement_req(sdata, mgmt, len);
3420 goto handled;
3421 case WLAN_ACTION_SPCT_CHL_SWITCH:
3422 - if (len < (IEEE80211_MIN_ACTION_SIZE +
3423 - sizeof(mgmt->u.action.u.chan_switch)))
3424 - break;
3425 -
3426 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3427 break;
3428
3429 @@ -2695,14 +2723,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
3430
3431 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
3432 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
3433 - sdata->vif.type != NL80211_IFTYPE_STATION)
3434 + sdata->vif.type != NL80211_IFTYPE_STATION &&
3435 + sdata->vif.type != NL80211_IFTYPE_WDS)
3436 return RX_DROP_MONITOR;
3437
3438 switch (stype) {
3439 case cpu_to_le16(IEEE80211_STYPE_AUTH):
3440 case cpu_to_le16(IEEE80211_STYPE_BEACON):
3441 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
3442 - /* process for all: mesh, mlme, ibss */
3443 + /* process for all: mesh, mlme, ibss, wds */
3444 break;
3445 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
3446 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
3447 @@ -3023,6 +3052,9 @@ static int prepare_for_handlers(struct i
3448 * and location updates. Note that mac80211
3449 * itself never looks at these frames.
3450 */
3451 + if (!multicast &&
3452 + !ether_addr_equal(sdata->vif.addr, hdr->addr1))
3453 + return 0;
3454 if (ieee80211_is_public_action(hdr, skb->len))
3455 return 1;
3456 if (!ieee80211_is_beacon(hdr->frame_control))
3457 @@ -3031,10 +3063,16 @@ static int prepare_for_handlers(struct i
3458 }
3459 break;
3460 case NL80211_IFTYPE_WDS:
3461 - if (bssid || !ieee80211_is_data(hdr->frame_control))
3462 - return 0;
3463 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
3464 return 0;
3465 +
3466 + if (ieee80211_is_data(hdr->frame_control) ||
3467 + ieee80211_is_action(hdr->frame_control)) {
3468 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
3469 + return 0;
3470 + } else if (!ieee80211_is_beacon(hdr->frame_control))
3471 + return 0;
3472 +
3473 break;
3474 case NL80211_IFTYPE_P2P_DEVICE:
3475 if (!ieee80211_is_public_action(hdr, skb->len) &&
3476 --- a/net/mac80211/scan.c
3477 +++ b/net/mac80211/scan.c
3478 @@ -181,7 +181,7 @@ void ieee80211_scan_rx(struct ieee80211_
3479 if (baselen > skb->len)
3480 return;
3481
3482 - ieee802_11_parse_elems(elements, skb->len - baselen, &elems);
3483 + ieee802_11_parse_elems(elements, skb->len - baselen, false, &elems);
3484
3485 channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq);
3486
3487 --- a/net/mac80211/sta_info.h
3488 +++ b/net/mac80211/sta_info.h
3489 @@ -32,7 +32,6 @@
3490 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
3491 * frames.
3492 * @WLAN_STA_WME: Station is a QoS-STA.
3493 - * @WLAN_STA_WDS: Station is one of our WDS peers.
3494 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
3495 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
3496 * frame to this station is transmitted.
3497 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
3498 WLAN_STA_AUTHORIZED,
3499 WLAN_STA_SHORT_PREAMBLE,
3500 WLAN_STA_WME,
3501 - WLAN_STA_WDS,
3502 WLAN_STA_CLEAR_PS_FILT,
3503 WLAN_STA_MFP,
3504 WLAN_STA_BLOCK_BA,
3505 @@ -344,6 +342,11 @@ struct sta_info {
3506 int last_signal;
3507 struct ewma avg_signal;
3508 int last_ack_signal;
3509 +
3510 + u8 chains;
3511 + s8 chain_signal_last[IEEE80211_MAX_CHAINS];
3512 + struct ewma chain_signal_avg[IEEE80211_MAX_CHAINS];
3513 +
3514 /* Plus 1 for non-QoS frames */
3515 __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
3516
3517 --- a/net/mac80211/trace.h
3518 +++ b/net/mac80211/trace.h
3519 @@ -990,23 +990,23 @@ TRACE_EVENT(drv_channel_switch,
3520
3521 TP_STRUCT__entry(
3522 LOCAL_ENTRY
3523 + CHANDEF_ENTRY
3524 __field(u64, timestamp)
3525 __field(bool, block_tx)
3526 - __field(u16, freq)
3527 __field(u8, count)
3528 ),
3529
3530 TP_fast_assign(
3531 LOCAL_ASSIGN;
3532 + CHANDEF_ASSIGN(&ch_switch->chandef)
3533 __entry->timestamp = ch_switch->timestamp;
3534 __entry->block_tx = ch_switch->block_tx;
3535 - __entry->freq = ch_switch->channel->center_freq;
3536 __entry->count = ch_switch->count;
3537 ),
3538
3539 TP_printk(
3540 - LOCAL_PR_FMT " new freq:%u count:%d",
3541 - LOCAL_PR_ARG, __entry->freq, __entry->count
3542 + LOCAL_PR_FMT " new " CHANDEF_PR_FMT " count:%d",
3543 + LOCAL_PR_ARG, CHANDEF_PR_ARG, __entry->count
3544 )
3545 );
3546
3547 --- a/net/mac80211/tx.c
3548 +++ b/net/mac80211/tx.c
3549 @@ -48,15 +48,15 @@ static __le16 ieee80211_duration(struct
3550 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
3551
3552 /* assume HW handles this */
3553 - if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
3554 + if (tx->rate.flags & IEEE80211_TX_RC_MCS)
3555 return 0;
3556
3557 /* uh huh? */
3558 - if (WARN_ON_ONCE(info->control.rates[0].idx < 0))
3559 + if (WARN_ON_ONCE(tx->rate.idx < 0))
3560 return 0;
3561
3562 sband = local->hw.wiphy->bands[info->band];
3563 - txrate = &sband->bitrates[info->control.rates[0].idx];
3564 + txrate = &sband->bitrates[tx->rate.idx];
3565
3566 erp = txrate->flags & IEEE80211_RATE_ERP_G;
3567
3568 @@ -617,11 +617,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3569 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
3570 struct ieee80211_hdr *hdr = (void *)tx->skb->data;
3571 struct ieee80211_supported_band *sband;
3572 - struct ieee80211_rate *rate;
3573 - int i;
3574 u32 len;
3575 - bool inval = false, rts = false, short_preamble = false;
3576 struct ieee80211_tx_rate_control txrc;
3577 + struct ieee80211_sta_rates *ratetbl = NULL;
3578 bool assoc = false;
3579
3580 memset(&txrc, 0, sizeof(txrc));
3581 @@ -642,18 +640,23 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3582 txrc.max_rate_idx = -1;
3583 else
3584 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
3585 - memcpy(txrc.rate_idx_mcs_mask,
3586 - tx->sdata->rc_rateidx_mcs_mask[info->band],
3587 - sizeof(txrc.rate_idx_mcs_mask));
3588 +
3589 + if (tx->sdata->rc_has_mcs_mask[info->band])
3590 + txrc.rate_idx_mcs_mask =
3591 + tx->sdata->rc_rateidx_mcs_mask[info->band];
3592 +
3593 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
3594 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
3595 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
3596
3597 /* set up RTS protection if desired */
3598 if (len > tx->local->hw.wiphy->rts_threshold) {
3599 - txrc.rts = rts = true;
3600 + txrc.rts = true;
3601 }
3602
3603 + info->control.use_rts = txrc.rts;
3604 + info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot;
3605 +
3606 /*
3607 * Use short preamble if the BSS can handle it, but not for
3608 * management frames unless we know the receiver can handle
3609 @@ -663,7 +666,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3610 if (tx->sdata->vif.bss_conf.use_short_preamble &&
3611 (ieee80211_is_data(hdr->frame_control) ||
3612 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE))))
3613 - txrc.short_preamble = short_preamble = true;
3614 + txrc.short_preamble = true;
3615 +
3616 + info->control.short_preamble = txrc.short_preamble;
3617
3618 if (tx->sta)
3619 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC);
3620 @@ -687,16 +692,38 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3621 */
3622 rate_control_get_rate(tx->sdata, tx->sta, &txrc);
3623
3624 - if (unlikely(info->control.rates[0].idx < 0))
3625 - return TX_DROP;
3626 + if (tx->sta && !info->control.skip_table)
3627 + ratetbl = rcu_dereference(tx->sta->sta.rates);
3628 +
3629 + if (unlikely(info->control.rates[0].idx < 0)) {
3630 + if (ratetbl) {
3631 + struct ieee80211_tx_rate rate = {
3632 + .idx = ratetbl->rate[0].idx,
3633 + .flags = ratetbl->rate[0].flags,
3634 + .count = ratetbl->rate[0].count
3635 + };
3636 +
3637 + if (ratetbl->rate[0].idx < 0)
3638 + return TX_DROP;
3639 +
3640 + tx->rate = rate;
3641 + } else {
3642 + return TX_DROP;
3643 + }
3644 + } else {
3645 + tx->rate = info->control.rates[0];
3646 + }
3647
3648 if (txrc.reported_rate.idx < 0) {
3649 - txrc.reported_rate = info->control.rates[0];
3650 + txrc.reported_rate = tx->rate;
3651 if (tx->sta && ieee80211_is_data(hdr->frame_control))
3652 tx->sta->last_tx_rate = txrc.reported_rate;
3653 } else if (tx->sta)
3654 tx->sta->last_tx_rate = txrc.reported_rate;
3655
3656 + if (ratetbl)
3657 + return TX_CONTINUE;
3658 +
3659 if (unlikely(!info->control.rates[0].count))
3660 info->control.rates[0].count = 1;
3661
3662 @@ -704,91 +731,6 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
3663 (info->flags & IEEE80211_TX_CTL_NO_ACK)))
3664 info->control.rates[0].count = 1;
3665
3666 - if (is_multicast_ether_addr(hdr->addr1)) {
3667 - /*
3668 - * XXX: verify the rate is in the basic rateset
3669 - */
3670 - return TX_CONTINUE;
3671 - }
3672 -
3673 - /*
3674 - * set up the RTS/CTS rate as the fastest basic rate
3675 - * that is not faster than the data rate
3676 - *
3677 - * XXX: Should this check all retry rates?
3678 - */
3679 - if (!(info->control.rates[0].flags & IEEE80211_TX_RC_MCS)) {
3680 - s8 baserate = 0;
3681 -
3682 - rate = &sband->bitrates[info->control.rates[0].idx];
3683 -
3684 - for (i = 0; i < sband->n_bitrates; i++) {
3685 - /* must be a basic rate */
3686 - if (!(tx->sdata->vif.bss_conf.basic_rates & BIT(i)))
3687 - continue;
3688 - /* must not be faster than the data rate */
3689 - if (sband->bitrates[i].bitrate > rate->bitrate)
3690 - continue;
3691 - /* maximum */
3692 - if (sband->bitrates[baserate].bitrate <
3693 - sband->bitrates[i].bitrate)
3694 - baserate = i;
3695 - }
3696 -
3697 - info->control.rts_cts_rate_idx = baserate;
3698 - }
3699 -
3700 - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
3701 - /*
3702 - * make sure there's no valid rate following
3703 - * an invalid one, just in case drivers don't
3704 - * take the API seriously to stop at -1.
3705 - */
3706 - if (inval) {
3707 - info->control.rates[i].idx = -1;
3708 - continue;
3709 - }
3710 - if (info->control.rates[i].idx < 0) {
3711 - inval = true;
3712 - continue;
3713 - }
3714 -
3715 - /*
3716 - * For now assume MCS is already set up correctly, this
3717 - * needs to be fixed.
3718 - */
3719 - if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) {
3720 - WARN_ON(info->control.rates[i].idx > 76);
3721 - continue;
3722 - }
3723 -
3724 - /* set up RTS protection if desired */
3725 - if (rts)
3726 - info->control.rates[i].flags |=
3727 - IEEE80211_TX_RC_USE_RTS_CTS;
3728 -
3729 - /* RC is busted */
3730 - if (WARN_ON_ONCE(info->control.rates[i].idx >=
3731 - sband->n_bitrates)) {
3732 - info->control.rates[i].idx = -1;
3733 - continue;
3734 - }
3735 -
3736 - rate = &sband->bitrates[info->control.rates[i].idx];
3737 -
3738 - /* set up short preamble */
3739 - if (short_preamble &&
3740 - rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
3741 - info->control.rates[i].flags |=
3742 - IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
3743 -
3744 - /* set up G protection */
3745 - if (!rts && tx->sdata->vif.bss_conf.use_cts_prot &&
3746 - rate->flags & IEEE80211_RATE_ERP_G)
3747 - info->control.rates[i].flags |=
3748 - IEEE80211_TX_RC_USE_CTS_PROTECT;
3749 - }
3750 -
3751 return TX_CONTINUE;
3752 }
3753
3754 @@ -2508,8 +2450,6 @@ struct sk_buff *ieee80211_beacon_get_tim
3755 txrc.max_rate_idx = -1;
3756 else
3757 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
3758 - memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band],
3759 - sizeof(txrc.rate_idx_mcs_mask));
3760 txrc.bss = true;
3761 rate_control_get_rate(sdata, NULL, &txrc);
3762
3763 --- a/net/mac80211/util.c
3764 +++ b/net/mac80211/util.c
3765 @@ -485,7 +485,8 @@ int ieee80211_queue_stopped(struct ieee8
3766 return true;
3767
3768 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
3769 - ret = !!local->queue_stop_reasons[queue];
3770 + ret = test_bit(IEEE80211_QUEUE_STOP_REASON_DRIVER,
3771 + &local->queue_stop_reasons[queue]);
3772 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
3773 return ret;
3774 }
3775 @@ -559,6 +560,9 @@ void ieee80211_iterate_active_interfaces
3776 list_for_each_entry(sdata, &local->interfaces, list) {
3777 switch (sdata->vif.type) {
3778 case NL80211_IFTYPE_MONITOR:
3779 + if (!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
3780 + continue;
3781 + break;
3782 case NL80211_IFTYPE_AP_VLAN:
3783 continue;
3784 default:
3785 @@ -597,6 +601,9 @@ void ieee80211_iterate_active_interfaces
3786 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
3787 switch (sdata->vif.type) {
3788 case NL80211_IFTYPE_MONITOR:
3789 + if (!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
3790 + continue;
3791 + break;
3792 case NL80211_IFTYPE_AP_VLAN:
3793 continue;
3794 default:
3795 @@ -660,7 +667,7 @@ void ieee80211_queue_delayed_work(struct
3796 }
3797 EXPORT_SYMBOL(ieee80211_queue_delayed_work);
3798
3799 -u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
3800 +u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action,
3801 struct ieee802_11_elems *elems,
3802 u64 filter, u32 crc)
3803 {
3804 @@ -668,6 +675,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start
3805 u8 *pos = start;
3806 bool calc_crc = filter != 0;
3807 DECLARE_BITMAP(seen_elems, 256);
3808 + const u8 *ie;
3809
3810 bitmap_zero(seen_elems, 256);
3811 memset(elems, 0, sizeof(*elems));
3812 @@ -715,6 +723,12 @@ u32 ieee802_11_parse_elems_crc(u8 *start
3813 case WLAN_EID_COUNTRY:
3814 case WLAN_EID_PWR_CONSTRAINT:
3815 case WLAN_EID_TIMEOUT_INTERVAL:
3816 + case WLAN_EID_SECONDARY_CHANNEL_OFFSET:
3817 + case WLAN_EID_WIDE_BW_CHANNEL_SWITCH:
3818 + /*
3819 + * not listing WLAN_EID_CHANNEL_SWITCH_WRAPPER -- it seems possible
3820 + * that if the content gets bigger it might be needed more than once
3821 + */
3822 if (test_bit(id, seen_elems)) {
3823 elems->parse_error = true;
3824 left -= elen;
3825 @@ -862,6 +876,48 @@ u32 ieee802_11_parse_elems_crc(u8 *start
3826 }
3827 elems->ch_switch_ie = (void *)pos;
3828 break;
3829 + case WLAN_EID_EXT_CHANSWITCH_ANN:
3830 + if (elen != sizeof(struct ieee80211_ext_chansw_ie)) {
3831 + elem_parse_failed = true;
3832 + break;
3833 + }
3834 + elems->ext_chansw_ie = (void *)pos;
3835 + break;
3836 + case WLAN_EID_SECONDARY_CHANNEL_OFFSET:
3837 + if (elen != sizeof(struct ieee80211_sec_chan_offs_ie)) {
3838 + elem_parse_failed = true;
3839 + break;
3840 + }
3841 + elems->sec_chan_offs = (void *)pos;
3842 + break;
3843 + case WLAN_EID_WIDE_BW_CHANNEL_SWITCH:
3844 + if (!action ||
3845 + elen != sizeof(*elems->wide_bw_chansw_ie)) {
3846 + elem_parse_failed = true;
3847 + break;
3848 + }
3849 + elems->wide_bw_chansw_ie = (void *)pos;
3850 + break;
3851 + case WLAN_EID_CHANNEL_SWITCH_WRAPPER:
3852 + if (action) {
3853 + elem_parse_failed = true;
3854 + break;
3855 + }
3856 + /*
3857 + * This is a bit tricky, but as we only care about
3858 + * the wide bandwidth channel switch element, so
3859 + * just parse it out manually.
3860 + */
3861 + ie = cfg80211_find_ie(WLAN_EID_WIDE_BW_CHANNEL_SWITCH,
3862 + pos, elen);
3863 + if (ie) {
3864 + if (ie[1] == sizeof(*elems->wide_bw_chansw_ie))
3865 + elems->wide_bw_chansw_ie =
3866 + (void *)(ie + 2);
3867 + else
3868 + elem_parse_failed = true;
3869 + }
3870 + break;
3871 case WLAN_EID_COUNTRY:
3872 elems->country_elem = pos;
3873 elems->country_elem_len = elen;
3874 --- a/net/wireless/reg.c
3875 +++ b/net/wireless/reg.c
3876 @@ -857,7 +857,7 @@ static void handle_channel(struct wiphy
3877 return;
3878
3879 REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq);
3880 - chan->flags = IEEE80211_CHAN_DISABLED;
3881 + chan->flags |= IEEE80211_CHAN_DISABLED;
3882 return;
3883 }
3884
3885 --- a/net/wireless/util.c
3886 +++ b/net/wireless/util.c
3887 @@ -1156,6 +1156,26 @@ int cfg80211_get_p2p_attr(const u8 *ies,
3888 }
3889 EXPORT_SYMBOL(cfg80211_get_p2p_attr);
3890
3891 +bool ieee80211_operating_class_to_band(u8 operating_class,
3892 + enum ieee80211_band *band)
3893 +{
3894 + switch (operating_class) {
3895 + case 112:
3896 + case 115 ... 127:
3897 + *band = IEEE80211_BAND_5GHZ;
3898 + return true;
3899 + case 81:
3900 + case 82:
3901 + case 83:
3902 + case 84:
3903 + *band = IEEE80211_BAND_2GHZ;
3904 + return true;
3905 + }
3906 +
3907 + return false;
3908 +}
3909 +EXPORT_SYMBOL(ieee80211_operating_class_to_band);
3910 +
3911 int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
3912 u32 beacon_int)
3913 {
3914 --- a/include/uapi/linux/nl80211.h
3915 +++ b/include/uapi/linux/nl80211.h
3916 @@ -1973,6 +1973,10 @@ enum nl80211_sta_bss_param {
3917 * @NL80211_STA_INFO_PEER_PM: peer mesh STA link-specific power mode
3918 * @NL80211_STA_INFO_NONPEER_PM: neighbor mesh STA power save mode towards
3919 * non-peer STA
3920 + * @NL80211_STA_INFO_CHAIN_SIGNAL: per-chain signal strength of last PPDU
3921 + * Contains a nested array of signal strength attributes (u8, dBm)
3922 + * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
3923 + * Same format as NL80211_STA_INFO_CHAIN_SIGNAL.
3924 * @__NL80211_STA_INFO_AFTER_LAST: internal
3925 * @NL80211_STA_INFO_MAX: highest possible station info attribute
3926 */
3927 @@ -2002,6 +2006,8 @@ enum nl80211_sta_info {
3928 NL80211_STA_INFO_NONPEER_PM,
3929 NL80211_STA_INFO_RX_BYTES64,
3930 NL80211_STA_INFO_TX_BYTES64,
3931 + NL80211_STA_INFO_CHAIN_SIGNAL,
3932 + NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
3933
3934 /* keep last */
3935 __NL80211_STA_INFO_AFTER_LAST,
3936 @@ -2395,6 +2401,8 @@ enum nl80211_survey_info {
3937 * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering
3938 * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing.
3939 * overrides all other flags.
3940 + * @NL80211_MNTR_FLAG_ACTIVE: use the configured MAC address
3941 + * and ACK incoming unicast packets.
3942 *
3943 * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
3944 * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
3945 @@ -2406,6 +2414,7 @@ enum nl80211_mntr_flags {
3946 NL80211_MNTR_FLAG_CONTROL,
3947 NL80211_MNTR_FLAG_OTHER_BSS,
3948 NL80211_MNTR_FLAG_COOK_FRAMES,
3949 + NL80211_MNTR_FLAG_ACTIVE,
3950
3951 /* keep last */
3952 __NL80211_MNTR_FLAG_AFTER_LAST,
3953 @@ -3557,6 +3566,7 @@ enum nl80211_feature_flags {
3954 NL80211_FEATURE_ADVERTISE_CHAN_LIMITS = 1 << 14,
3955 NL80211_FEATURE_FULL_AP_CLIENT_STATE = 1 << 15,
3956 NL80211_FEATURE_USERSPACE_MPM = 1 << 16,
3957 + NL80211_FEATURE_ACTIVE_MONITOR = 1 << 17,
3958 };
3959
3960 /**
3961 --- a/net/mac80211/sta_info.c
3962 +++ b/net/mac80211/sta_info.c
3963 @@ -358,6 +358,8 @@ struct sta_info *sta_info_alloc(struct i
3964 do_posix_clock_monotonic_gettime(&uptime);
3965 sta->last_connected = uptime.tv_sec;
3966 ewma_init(&sta->avg_signal, 1024, 8);
3967 + for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++)
3968 + ewma_init(&sta->chain_signal_avg[i], 1024, 8);
3969
3970 if (sta_prepare_rate_control(local, sta, gfp)) {
3971 kfree(sta);
3972 @@ -1130,6 +1132,7 @@ static void ieee80211_send_null_response
3973 * ends the poll/service period.
3974 */
3975 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER |
3976 + IEEE80211_TX_CTL_PS_RESPONSE |
3977 IEEE80211_TX_STATUS_EOSP |
3978 IEEE80211_TX_CTL_REQ_TX_STATUS;
3979
3980 @@ -1267,7 +1270,8 @@ ieee80211_sta_ps_deliver_response(struct
3981 * STA may still remain is PS mode after this frame
3982 * exchange.
3983 */
3984 - info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
3985 + info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER |
3986 + IEEE80211_TX_CTL_PS_RESPONSE;
3987
3988 /*
3989 * Use MoreData flag to indicate whether there are
3990 --- a/net/wireless/nl80211.c
3991 +++ b/net/wireless/nl80211.c
3992 @@ -2270,6 +2270,7 @@ static const struct nla_policy mntr_flag
3993 [NL80211_MNTR_FLAG_CONTROL] = { .type = NLA_FLAG },
3994 [NL80211_MNTR_FLAG_OTHER_BSS] = { .type = NLA_FLAG },
3995 [NL80211_MNTR_FLAG_COOK_FRAMES] = { .type = NLA_FLAG },
3996 + [NL80211_MNTR_FLAG_ACTIVE] = { .type = NLA_FLAG },
3997 };
3998
3999 static int parse_monitor_flags(struct nlattr *nla, u32 *mntrflags)
4000 @@ -2381,6 +2382,10 @@ static int nl80211_set_interface(struct
4001 change = true;
4002 }
4003
4004 + if (flags && (*flags & NL80211_MNTR_FLAG_ACTIVE) &&
4005 + !(rdev->wiphy.features & NL80211_FEATURE_ACTIVE_MONITOR))
4006 + return -EOPNOTSUPP;
4007 +
4008 if (change)
4009 err = cfg80211_change_iface(rdev, dev, ntype, flags, &params);
4010 else
4011 @@ -2438,6 +2443,11 @@ static int nl80211_new_interface(struct
4012 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
4013 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
4014 &flags);
4015 +
4016 + if (!err && (flags & NL80211_MNTR_FLAG_ACTIVE) &&
4017 + !(rdev->wiphy.features & NL80211_FEATURE_ACTIVE_MONITOR))
4018 + return -EOPNOTSUPP;
4019 +
4020 wdev = rdev_add_virtual_intf(rdev,
4021 nla_data(info->attrs[NL80211_ATTR_IFNAME]),
4022 type, err ? NULL : &flags, &params);
4023 @@ -3367,6 +3377,32 @@ static bool nl80211_put_sta_rate(struct
4024 return true;
4025 }
4026
4027 +static bool nl80211_put_signal(struct sk_buff *msg, u8 mask, s8 *signal,
4028 + int id)
4029 +{
4030 + void *attr;
4031 + int i = 0;
4032 +
4033 + if (!mask)
4034 + return true;
4035 +
4036 + attr = nla_nest_start(msg, id);
4037 + if (!attr)
4038 + return false;
4039 +
4040 + for (i = 0; i < IEEE80211_MAX_CHAINS; i++) {
4041 + if (!(mask & BIT(i)))
4042 + continue;
4043 +
4044 + if (nla_put_u8(msg, i, signal[i]))
4045 + return false;
4046 + }
4047 +
4048 + nla_nest_end(msg, attr);
4049 +
4050 + return true;
4051 +}
4052 +
4053 static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq,
4054 int flags,
4055 struct cfg80211_registered_device *rdev,
4056 @@ -3402,7 +3438,7 @@ static int nl80211_send_station(struct s
4057 (u32)sinfo->rx_bytes))
4058 goto nla_put_failure;
4059 if ((sinfo->filled & (STATION_INFO_TX_BYTES |
4060 - NL80211_STA_INFO_TX_BYTES64)) &&
4061 + STATION_INFO_TX_BYTES64)) &&
4062 nla_put_u32(msg, NL80211_STA_INFO_TX_BYTES,
4063 (u32)sinfo->tx_bytes))
4064 goto nla_put_failure;
4065 @@ -3438,6 +3474,18 @@ static int nl80211_send_station(struct s
4066 default:
4067 break;
4068 }
4069 + if (sinfo->filled & STATION_INFO_CHAIN_SIGNAL) {
4070 + if (!nl80211_put_signal(msg, sinfo->chains,
4071 + sinfo->chain_signal,
4072 + NL80211_STA_INFO_CHAIN_SIGNAL))
4073 + goto nla_put_failure;
4074 + }
4075 + if (sinfo->filled & STATION_INFO_CHAIN_SIGNAL_AVG) {
4076 + if (!nl80211_put_signal(msg, sinfo->chains,
4077 + sinfo->chain_signal_avg,
4078 + NL80211_STA_INFO_CHAIN_SIGNAL_AVG))
4079 + goto nla_put_failure;
4080 + }
4081 if (sinfo->filled & STATION_INFO_TX_BITRATE) {
4082 if (!nl80211_put_sta_rate(msg, &sinfo->txrate,
4083 NL80211_STA_INFO_TX_BITRATE))
4084 --- a/drivers/net/wireless/ath/ath9k/init.c
4085 +++ b/drivers/net/wireless/ath/ath9k/init.c
4086 @@ -433,6 +433,8 @@ static int ath9k_init_queues(struct ath_
4087 sc->config.cabqReadytime = ATH_CABQ_READY_TIME;
4088 ath_cabq_update(sc);
4089
4090 + sc->tx.uapsdq = ath_txq_setup(sc, ATH9K_TX_QUEUE_UAPSD, 0);
4091 +
4092 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
4093 sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i);
4094 sc->tx.txq_map[i]->mac80211_qnum = i;
4095 @@ -768,7 +770,8 @@ void ath9k_set_hw_capab(struct ath_softc
4096 IEEE80211_HW_SUPPORTS_PS |
4097 IEEE80211_HW_PS_NULLFUNC_STACK |
4098 IEEE80211_HW_SPECTRUM_MGMT |
4099 - IEEE80211_HW_REPORTS_TX_ACK_STATUS;
4100 + IEEE80211_HW_REPORTS_TX_ACK_STATUS |
4101 + IEEE80211_HW_SUPPORTS_RC_TABLE;
4102
4103 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
4104 hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION;
4105 @@ -776,6 +779,8 @@ void ath9k_set_hw_capab(struct ath_softc
4106 if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || ath9k_modparam_nohwcrypt)
4107 hw->flags |= IEEE80211_HW_MFP_CAPABLE;
4108
4109 + hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR;
4110 +
4111 hw->wiphy->interface_modes =
4112 BIT(NL80211_IFTYPE_P2P_GO) |
4113 BIT(NL80211_IFTYPE_P2P_CLIENT) |
4114 --- a/drivers/net/wireless/ath/ath9k/xmit.c
4115 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
4116 @@ -125,24 +125,6 @@ static void ath_tx_queue_tid(struct ath_
4117 list_add_tail(&ac->list, &txq->axq_acq);
4118 }
4119
4120 -static void ath_tx_resume_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
4121 -{
4122 - struct ath_txq *txq = tid->ac->txq;
4123 -
4124 - WARN_ON(!tid->paused);
4125 -
4126 - ath_txq_lock(sc, txq);
4127 - tid->paused = false;
4128 -
4129 - if (skb_queue_empty(&tid->buf_q))
4130 - goto unlock;
4131 -
4132 - ath_tx_queue_tid(txq, tid);
4133 - ath_txq_schedule(sc, txq);
4134 -unlock:
4135 - ath_txq_unlock_complete(sc, txq);
4136 -}
4137 -
4138 static struct ath_frame_info *get_frame_info(struct sk_buff *skb)
4139 {
4140 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
4141 @@ -157,6 +139,13 @@ static void ath_send_bar(struct ath_atx_
4142 seqno << IEEE80211_SEQ_SEQ_SHIFT);
4143 }
4144
4145 +static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
4146 + struct ath_buf *bf)
4147 +{
4148 + ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
4149 + ARRAY_SIZE(bf->rates));
4150 +}
4151 +
4152 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
4153 {
4154 struct ath_txq *txq = tid->ac->txq;
4155 @@ -189,15 +178,11 @@ static void ath_tx_flush_tid(struct ath_
4156 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
4157 sendbar = true;
4158 } else {
4159 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
4160 ath_tx_s