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