ath9k: fix tx queueing issues after background scans
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/net/mac80211/agg-rx.c
2 +++ b/net/mac80211/agg-rx.c
3 @@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
4 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
5 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
6 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
7 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
8 + memcpy(mgmt->bssid, da, ETH_ALEN);
9
10 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
11 IEEE80211_STYPE_ACTION);
12 --- a/net/mac80211/agg-tx.c
13 +++ b/net/mac80211/agg-tx.c
14 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
15 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
16 if (sdata->vif.type == NL80211_IFTYPE_AP ||
17 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
18 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
19 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
20 + sdata->vif.type == NL80211_IFTYPE_WDS)
21 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
22 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
23 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
24 @@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
25 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
26 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
27 sdata->vif.type != NL80211_IFTYPE_AP &&
28 + sdata->vif.type != NL80211_IFTYPE_WDS &&
29 sdata->vif.type != NL80211_IFTYPE_ADHOC)
30 return -EINVAL;
31
32 --- a/net/mac80211/debugfs_sta.c
33 +++ b/net/mac80211/debugfs_sta.c
34 @@ -66,11 +66,11 @@ static ssize_t sta_flags_read(struct fil
35 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
36
37 int res = scnprintf(buf, sizeof(buf),
38 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
39 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
40 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
41 TEST(PS_DRIVER), TEST(AUTHORIZED),
42 TEST(SHORT_PREAMBLE),
43 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
44 + TEST(WME), TEST(CLEAR_PS_FILT),
45 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
46 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
47 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
48 --- a/net/mac80211/iface.c
49 +++ b/net/mac80211/iface.c
50 @@ -463,7 +463,6 @@ int ieee80211_do_open(struct wireless_de
51 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
52 struct net_device *dev = wdev->netdev;
53 struct ieee80211_local *local = sdata->local;
54 - struct sta_info *sta;
55 u32 changed = 0;
56 int res;
57 u32 hw_reconf_flags = 0;
58 @@ -629,30 +628,8 @@ int ieee80211_do_open(struct wireless_de
59
60 set_bit(SDATA_STATE_RUNNING, &sdata->state);
61
62 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
63 - /* Create STA entry for the WDS peer */
64 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
65 - GFP_KERNEL);
66 - if (!sta) {
67 - res = -ENOMEM;
68 - goto err_del_interface;
69 - }
70 -
71 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
72 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
73 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
74 -
75 - res = sta_info_insert(sta);
76 - if (res) {
77 - /* STA has been freed */
78 - goto err_del_interface;
79 - }
80 -
81 - rate_control_rate_init(sta);
82 - netif_carrier_on(dev);
83 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
84 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
85 rcu_assign_pointer(local->p2p_sdata, sdata);
86 - }
87
88 /*
89 * set_multicast_list will be invoked by the networking core
90 @@ -1116,6 +1093,74 @@ static void ieee80211_if_setup(struct ne
91 dev->destructor = free_netdev;
92 }
93
94 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
95 + struct sk_buff *skb)
96 +{
97 + struct ieee80211_local *local = sdata->local;
98 + struct ieee80211_rx_status *rx_status;
99 + struct ieee802_11_elems elems;
100 + struct ieee80211_mgmt *mgmt;
101 + struct sta_info *sta;
102 + size_t baselen;
103 + u32 rates = 0;
104 + u16 stype;
105 + bool new = false;
106 + enum ieee80211_band band;
107 + struct ieee80211_supported_band *sband;
108 +
109 + rx_status = IEEE80211_SKB_RXCB(skb);
110 + band = rx_status->band;
111 + sband = local->hw.wiphy->bands[band];
112 + mgmt = (struct ieee80211_mgmt *) skb->data;
113 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
114 +
115 + if (stype != IEEE80211_STYPE_BEACON)
116 + return;
117 +
118 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
119 + if (baselen > skb->len)
120 + return;
121 +
122 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
123 + skb->len - baselen, false, &elems);
124 +
125 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
126 +
127 + rcu_read_lock();
128 +
129 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
130 +
131 + if (!sta) {
132 + rcu_read_unlock();
133 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
134 + GFP_KERNEL);
135 + if (!sta)
136 + return;
137 +
138 + new = true;
139 + }
140 +
141 + sta->last_rx = jiffies;
142 + sta->sta.supp_rates[band] = rates;
143 +
144 + if (elems.ht_cap_elem)
145 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
146 + elems.ht_cap_elem, sta);
147 +
148 + if (elems.wmm_param)
149 + set_sta_flag(sta, WLAN_STA_WME);
150 +
151 + if (new) {
152 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
153 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
154 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
155 + rate_control_rate_init(sta);
156 + sta_info_insert_rcu(sta);
157 + }
158 +
159 + rcu_read_unlock();
160 +}
161 +
162 static void ieee80211_iface_work(struct work_struct *work)
163 {
164 struct ieee80211_sub_if_data *sdata =
165 @@ -1220,6 +1265,9 @@ static void ieee80211_iface_work(struct
166 break;
167 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
168 break;
169 + case NL80211_IFTYPE_WDS:
170 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
171 + break;
172 default:
173 WARN(1, "frame for unexpected interface type");
174 break;
175 --- a/net/mac80211/rc80211_minstrel_ht.c
176 +++ b/net/mac80211/rc80211_minstrel_ht.c
177 @@ -804,10 +804,18 @@ minstrel_ht_get_rate(void *priv, struct
178
179 sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
180 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
181 + rate->count = 1;
182 +
183 + if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
184 + int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
185 + rate->idx = mp->cck_rates[idx];
186 + rate->flags = 0;
187 + return;
188 + }
189 +
190 rate->idx = sample_idx % MCS_GROUP_RATES +
191 (sample_group->streams - 1) * MCS_GROUP_RATES;
192 rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
193 - rate->count = 1;
194 }
195
196 static void
197 --- a/net/mac80211/rx.c
198 +++ b/net/mac80211/rx.c
199 @@ -936,8 +936,14 @@ ieee80211_rx_h_check(struct ieee80211_rx
200 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
201 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
202
203 - /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
204 - if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
205 + /*
206 + * Drop duplicate 802.11 retransmissions
207 + * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
208 + */
209 + if (rx->skb->len >= 24 && rx->sta &&
210 + !ieee80211_is_ctl(hdr->frame_control) &&
211 + !ieee80211_is_qos_nullfunc(hdr->frame_control) &&
212 + !is_multicast_ether_addr(hdr->addr1)) {
213 if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
214 rx->sta->last_seq_ctrl[rx->seqno_idx] ==
215 hdr->seq_ctrl)) {
216 @@ -2369,6 +2375,7 @@ ieee80211_rx_h_action(struct ieee80211_r
217 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
218 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
219 sdata->vif.type != NL80211_IFTYPE_AP &&
220 + sdata->vif.type != NL80211_IFTYPE_WDS &&
221 sdata->vif.type != NL80211_IFTYPE_ADHOC)
222 break;
223
224 @@ -2720,14 +2727,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
225
226 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
227 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
228 - sdata->vif.type != NL80211_IFTYPE_STATION)
229 + sdata->vif.type != NL80211_IFTYPE_STATION &&
230 + sdata->vif.type != NL80211_IFTYPE_WDS)
231 return RX_DROP_MONITOR;
232
233 switch (stype) {
234 case cpu_to_le16(IEEE80211_STYPE_AUTH):
235 case cpu_to_le16(IEEE80211_STYPE_BEACON):
236 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
237 - /* process for all: mesh, mlme, ibss */
238 + /* process for all: mesh, mlme, ibss, wds */
239 break;
240 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
241 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
242 @@ -3008,6 +3016,9 @@ static int prepare_for_handlers(struct i
243 case NL80211_IFTYPE_ADHOC:
244 if (!bssid)
245 return 0;
246 + if (ether_addr_equal(sdata->vif.addr, hdr->addr2) ||
247 + ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2))
248 + return 0;
249 if (ieee80211_is_beacon(hdr->frame_control)) {
250 return 1;
251 } else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) {
252 @@ -3059,10 +3070,16 @@ static int prepare_for_handlers(struct i
253 }
254 break;
255 case NL80211_IFTYPE_WDS:
256 - if (bssid || !ieee80211_is_data(hdr->frame_control))
257 - return 0;
258 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
259 return 0;
260 +
261 + if (ieee80211_is_data(hdr->frame_control) ||
262 + ieee80211_is_action(hdr->frame_control)) {
263 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
264 + return 0;
265 + } else if (!ieee80211_is_beacon(hdr->frame_control))
266 + return 0;
267 +
268 break;
269 case NL80211_IFTYPE_P2P_DEVICE:
270 if (!ieee80211_is_public_action(hdr, skb->len) &&
271 --- a/net/mac80211/sta_info.h
272 +++ b/net/mac80211/sta_info.h
273 @@ -32,7 +32,6 @@
274 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
275 * frames.
276 * @WLAN_STA_WME: Station is a QoS-STA.
277 - * @WLAN_STA_WDS: Station is one of our WDS peers.
278 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
279 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
280 * frame to this station is transmitted.
281 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
282 WLAN_STA_AUTHORIZED,
283 WLAN_STA_SHORT_PREAMBLE,
284 WLAN_STA_WME,
285 - WLAN_STA_WDS,
286 WLAN_STA_CLEAR_PS_FILT,
287 WLAN_STA_MFP,
288 WLAN_STA_BLOCK_BA,
289 --- a/drivers/net/wireless/ath/ath9k/xmit.c
290 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
291 @@ -146,6 +146,28 @@ static void ath_set_rates(struct ieee802
292 ARRAY_SIZE(bf->rates));
293 }
294
295 +static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
296 + struct sk_buff *skb)
297 +{
298 + int q;
299 +
300 + q = skb_get_queue_mapping(skb);
301 + if (txq == sc->tx.uapsdq)
302 + txq = sc->tx.txq_map[q];
303 +
304 + if (txq != sc->tx.txq_map[q])
305 + return;
306 +
307 + if (WARN_ON(--txq->pending_frames < 0))
308 + txq->pending_frames = 0;
309 +
310 + if (txq->stopped &&
311 + txq->pending_frames < sc->tx.txq_max_pending[q]) {
312 + ieee80211_wake_queue(sc->hw, q);
313 + txq->stopped = false;
314 + }
315 +}
316 +
317 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
318 {
319 struct ath_txq *txq = tid->ac->txq;
320 @@ -167,6 +189,7 @@ static void ath_tx_flush_tid(struct ath_
321 if (!bf) {
322 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
323 if (!bf) {
324 + ath_txq_skb_done(sc, txq, skb);
325 ieee80211_free_txskb(sc->hw, skb);
326 continue;
327 }
328 @@ -811,6 +834,7 @@ ath_tx_get_tid_subframe(struct ath_softc
329
330 if (!bf) {
331 __skb_unlink(skb, &tid->buf_q);
332 + ath_txq_skb_done(sc, txq, skb);
333 ieee80211_free_txskb(sc->hw, skb);
334 continue;
335 }
336 @@ -1824,6 +1848,7 @@ static void ath_tx_send_ampdu(struct ath
337
338 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
339 if (!bf) {
340 + ath_txq_skb_done(sc, txq, skb);
341 ieee80211_free_txskb(sc->hw, skb);
342 return;
343 }
344 @@ -2090,6 +2115,7 @@ int ath_tx_start(struct ieee80211_hw *hw
345
346 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
347 if (!bf) {
348 + ath_txq_skb_done(sc, txq, skb);
349 if (txctl->paprd)
350 dev_kfree_skb_any(skb);
351 else
352 @@ -2189,7 +2215,7 @@ static void ath_tx_complete(struct ath_s
353 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
354 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
355 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
356 - int q, padpos, padsize;
357 + int padpos, padsize;
358 unsigned long flags;
359
360 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
361 @@ -2225,21 +2251,7 @@ static void ath_tx_complete(struct ath_s
362 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
363
364 __skb_queue_tail(&txq->complete_q, skb);
365 -
366 - q = skb_get_queue_mapping(skb);
367 - if (txq == sc->tx.uapsdq)
368 - txq = sc->tx.txq_map[q];
369 -
370 - if (txq == sc->tx.txq_map[q]) {
371 - if (WARN_ON(--txq->pending_frames < 0))
372 - txq->pending_frames = 0;
373 -
374 - if (txq->stopped &&
375 - txq->pending_frames < sc->tx.txq_max_pending[q]) {
376 - ieee80211_wake_queue(sc->hw, q);
377 - txq->stopped = false;
378 - }
379 - }
380 + ath_txq_skb_done(sc, txq, skb);
381 }
382
383 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
384 --- a/drivers/net/wireless/ath/ath9k/main.c
385 +++ b/drivers/net/wireless/ath/ath9k/main.c
386 @@ -209,6 +209,7 @@ static bool ath_complete_reset(struct at
387 struct ath_hw *ah = sc->sc_ah;
388 struct ath_common *common = ath9k_hw_common(ah);
389 unsigned long flags;
390 + int i;
391
392 if (ath_startrecv(sc) != 0) {
393 ath_err(common, "Unable to restart recv logic\n");
394 @@ -236,6 +237,15 @@ static bool ath_complete_reset(struct at
395 }
396 work:
397 ath_restart_work(sc);
398 +
399 + for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
400 + if (!ATH_TXQ_SETUP(sc, i))
401 + continue;
402 +
403 + spin_lock_bh(&sc->tx.txq[i].axq_lock);
404 + ath_txq_schedule(sc, &sc->tx.txq[i]);
405 + spin_unlock_bh(&sc->tx.txq[i].axq_lock);
406 + }
407 }
408
409 if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3)
410 @@ -543,21 +553,10 @@ chip_reset:
411
412 static int ath_reset(struct ath_softc *sc)
413 {
414 - int i, r;
415 + int r;
416
417 ath9k_ps_wakeup(sc);
418 -
419 r = ath_reset_internal(sc, NULL);
420 -
421 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
422 - if (!ATH_TXQ_SETUP(sc, i))
423 - continue;
424 -
425 - spin_lock_bh(&sc->tx.txq[i].axq_lock);
426 - ath_txq_schedule(sc, &sc->tx.txq[i]);
427 - spin_unlock_bh(&sc->tx.txq[i].axq_lock);
428 - }
429 -
430 ath9k_ps_restore(sc);
431
432 return r;
433 @@ -2094,7 +2093,7 @@ static void ath9k_wow_add_pattern(struct
434 {
435 struct ath_hw *ah = sc->sc_ah;
436 struct ath9k_wow_pattern *wow_pattern = NULL;
437 - struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
438 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
439 int mask_len;
440 s8 i = 0;
441
442 --- a/drivers/net/wireless/mwifiex/cfg80211.c
443 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
444 @@ -2298,8 +2298,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_in
445
446 #ifdef CONFIG_PM
447 static bool
448 -mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
449 - s8 *byte_seq)
450 +mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
451 {
452 int j, k, valid_byte_cnt = 0;
453 bool dont_care_byte = false;
454 --- a/drivers/net/wireless/ti/wlcore/main.c
455 +++ b/drivers/net/wireless/ti/wlcore/main.c
456 @@ -1315,7 +1315,7 @@ static struct sk_buff *wl12xx_alloc_dumm
457
458 #ifdef CONFIG_PM
459 static int
460 -wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
461 +wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
462 {
463 int num_fields = 0, in_field = 0, fields_size = 0;
464 int i, pattern_len = 0;
465 @@ -1458,9 +1458,9 @@ void wl1271_rx_filter_flatten_fields(str
466 * Allocates an RX filter returned through f
467 * which needs to be freed using rx_filter_free()
468 */
469 -static int wl1271_convert_wowlan_pattern_to_rx_filter(
470 - struct cfg80211_wowlan_trig_pkt_pattern *p,
471 - struct wl12xx_rx_filter **f)
472 +static int
473 +wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
474 + struct wl12xx_rx_filter **f)
475 {
476 int i, j, ret = 0;
477 struct wl12xx_rx_filter *filter;
478 @@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
479
480 /* Translate WoWLAN patterns into filters */
481 for (i = 0; i < wow->n_patterns; i++) {
482 - struct cfg80211_wowlan_trig_pkt_pattern *p;
483 + struct cfg80211_pkt_pattern *p;
484 struct wl12xx_rx_filter *filter = NULL;
485
486 p = &wow->patterns[i];
487 --- a/include/net/cfg80211.h
488 +++ b/include/net/cfg80211.h
489 @@ -1698,7 +1698,7 @@ struct cfg80211_pmksa {
490 };
491
492 /**
493 - * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
494 + * struct cfg80211_pkt_pattern - packet pattern
495 * @mask: bitmask where to match pattern and where to ignore bytes,
496 * one bit per byte, in same format as nl80211
497 * @pattern: bytes to match where bitmask is 1
498 @@ -1708,7 +1708,7 @@ struct cfg80211_pmksa {
499 * Internal note: @mask and @pattern are allocated in one chunk of
500 * memory, free @mask only!
501 */
502 -struct cfg80211_wowlan_trig_pkt_pattern {
503 +struct cfg80211_pkt_pattern {
504 u8 *mask, *pattern;
505 int pattern_len;
506 int pkt_offset;
507 @@ -1770,7 +1770,7 @@ struct cfg80211_wowlan {
508 bool any, disconnect, magic_pkt, gtk_rekey_failure,
509 eap_identity_req, four_way_handshake,
510 rfkill_release;
511 - struct cfg80211_wowlan_trig_pkt_pattern *patterns;
512 + struct cfg80211_pkt_pattern *patterns;
513 struct cfg80211_wowlan_tcp *tcp;
514 int n_patterns;
515 };
516 --- a/include/uapi/linux/nl80211.h
517 +++ b/include/uapi/linux/nl80211.h
518 @@ -3060,11 +3060,11 @@ enum nl80211_tx_power_setting {
519 };
520
521 /**
522 - * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
523 - * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
524 - * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
525 + * enum nl80211_packet_pattern_attr - packet pattern attribute
526 + * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
527 + * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
528 * a zero bit are ignored
529 - * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
530 + * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
531 * a bit for each byte in the pattern. The lowest-order bit corresponds
532 * to the first byte of the pattern, but the bytes of the pattern are
533 * in a little-endian-like format, i.e. the 9th byte of the pattern
534 @@ -3075,23 +3075,23 @@ enum nl80211_tx_power_setting {
535 * Note that the pattern matching is done as though frames were not
536 * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
537 * first (including SNAP header unpacking) and then matched.
538 - * @NL80211_WOWLAN_PKTPAT_OFFSET: packet offset, pattern is matched after
539 + * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
540 * these fixed number of bytes of received packet
541 - * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
542 - * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
543 + * @NUM_NL80211_PKTPAT: number of attributes
544 + * @MAX_NL80211_PKTPAT: max attribute number
545 */
546 -enum nl80211_wowlan_packet_pattern_attr {
547 - __NL80211_WOWLAN_PKTPAT_INVALID,
548 - NL80211_WOWLAN_PKTPAT_MASK,
549 - NL80211_WOWLAN_PKTPAT_PATTERN,
550 - NL80211_WOWLAN_PKTPAT_OFFSET,
551 +enum nl80211_packet_pattern_attr {
552 + __NL80211_PKTPAT_INVALID,
553 + NL80211_PKTPAT_MASK,
554 + NL80211_PKTPAT_PATTERN,
555 + NL80211_PKTPAT_OFFSET,
556
557 - NUM_NL80211_WOWLAN_PKTPAT,
558 - MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
559 + NUM_NL80211_PKTPAT,
560 + MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
561 };
562
563 /**
564 - * struct nl80211_wowlan_pattern_support - pattern support information
565 + * struct nl80211_pattern_support - packet pattern support information
566 * @max_patterns: maximum number of patterns supported
567 * @min_pattern_len: minimum length of each pattern
568 * @max_pattern_len: maximum length of each pattern
569 @@ -3101,13 +3101,22 @@ enum nl80211_wowlan_packet_pattern_attr
570 * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
571 * capability information given by the kernel to userspace.
572 */
573 -struct nl80211_wowlan_pattern_support {
574 +struct nl80211_pattern_support {
575 __u32 max_patterns;
576 __u32 min_pattern_len;
577 __u32 max_pattern_len;
578 __u32 max_pkt_offset;
579 } __attribute__((packed));
580
581 +/* only for backward compatibility */
582 +#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
583 +#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
584 +#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
585 +#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
586 +#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
587 +#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
588 +#define nl80211_wowlan_pattern_support nl80211_pattern_support
589 +
590 /**
591 * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
592 * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
593 @@ -3127,7 +3136,7 @@ struct nl80211_wowlan_pattern_support {
594 * pattern matching is done after the packet is converted to the MSDU.
595 *
596 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
597 - * carrying a &struct nl80211_wowlan_pattern_support.
598 + * carrying a &struct nl80211_pattern_support.
599 *
600 * When reporting wakeup. it is a u32 attribute containing the 0-based
601 * index of the pattern that caused the wakeup, in the patterns passed
602 @@ -3284,7 +3293,7 @@ struct nl80211_wowlan_tcp_data_token_fea
603 * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
604 * u32 attribute holding the maximum length
605 * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
606 - * feature advertising. The mask works like @NL80211_WOWLAN_PKTPAT_MASK
607 + * feature advertising. The mask works like @NL80211_PKTPAT_MASK
608 * but on the TCP payload only.
609 * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
610 * @MAX_NL80211_WOWLAN_TCP: highest attribute number
611 --- a/net/mac80211/mesh_ps.c
612 +++ b/net/mac80211/mesh_ps.c
613 @@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(str
614 enum nl80211_mesh_power_mode pm;
615 bool do_buffer;
616
617 + /* For non-assoc STA, prevent buffering or frame transmission */
618 + if (sta->sta_state < IEEE80211_STA_ASSOC)
619 + return;
620 +
621 /*
622 * use peer-specific power mode if peering is established and the
623 * peer's power mode is known
624 --- a/net/wireless/nl80211.c
625 +++ b/net/wireless/nl80211.c
626 @@ -441,10 +441,12 @@ static int nl80211_prepare_wdev_dump(str
627 goto out_unlock;
628 }
629 *rdev = wiphy_to_dev((*wdev)->wiphy);
630 - cb->args[0] = (*rdev)->wiphy_idx;
631 + /* 0 is the first index - add 1 to parse only once */
632 + cb->args[0] = (*rdev)->wiphy_idx + 1;
633 cb->args[1] = (*wdev)->identifier;
634 } else {
635 - struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]);
636 + /* subtract the 1 again here */
637 + struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
638 struct wireless_dev *tmp;
639
640 if (!wiphy) {
641 @@ -974,7 +976,7 @@ static int nl80211_send_wowlan(struct sk
642 return -ENOBUFS;
643
644 if (dev->wiphy.wowlan->n_patterns) {
645 - struct nl80211_wowlan_pattern_support pat = {
646 + struct nl80211_pattern_support pat = {
647 .max_patterns = dev->wiphy.wowlan->n_patterns,
648 .min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
649 .max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
650 @@ -1568,8 +1570,10 @@ static int nl80211_dump_wiphy(struct sk_
651 rtnl_lock();
652 if (!state) {
653 state = kzalloc(sizeof(*state), GFP_KERNEL);
654 - if (!state)
655 + if (!state) {
656 + rtnl_unlock();
657 return -ENOMEM;
658 + }
659 state->filter_wiphy = -1;
660 ret = nl80211_dump_wiphy_parse(skb, cb, state);
661 if (ret) {
662 @@ -6615,12 +6619,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
663
664 void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
665 {
666 + struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
667 void *hdr = ((void **)skb->cb)[1];
668 struct nlattr *data = ((void **)skb->cb)[2];
669
670 nla_nest_end(skb, data);
671 genlmsg_end(skb, hdr);
672 - genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
673 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
674 + nl80211_testmode_mcgrp.id, gfp);
675 }
676 EXPORT_SYMBOL(cfg80211_testmode_event);
677 #endif
678 @@ -7593,12 +7599,11 @@ static int nl80211_send_wowlan_patterns(
679 if (!nl_pat)
680 return -ENOBUFS;
681 pat_len = wowlan->patterns[i].pattern_len;
682 - if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
683 - DIV_ROUND_UP(pat_len, 8),
684 + if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
685 wowlan->patterns[i].mask) ||
686 - nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
687 - pat_len, wowlan->patterns[i].pattern) ||
688 - nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
689 + nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
690 + wowlan->patterns[i].pattern) ||
691 + nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
692 wowlan->patterns[i].pkt_offset))
693 return -ENOBUFS;
694 nla_nest_end(msg, nl_pat);
695 @@ -7939,7 +7944,7 @@ static int nl80211_set_wowlan(struct sk_
696 struct nlattr *pat;
697 int n_patterns = 0;
698 int rem, pat_len, mask_len, pkt_offset;
699 - struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
700 + struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
701
702 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
703 rem)
704 @@ -7958,26 +7963,25 @@ static int nl80211_set_wowlan(struct sk_
705
706 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
707 rem) {
708 - nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
709 - nla_data(pat), nla_len(pat), NULL);
710 + nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
711 + nla_len(pat), NULL);
712 err = -EINVAL;
713 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
714 - !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
715 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
716 + !pat_tb[NL80211_PKTPAT_PATTERN])
717 goto error;
718 - pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
719 + pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
720 mask_len = DIV_ROUND_UP(pat_len, 8);
721 - if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
722 - mask_len)
723 + if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
724 goto error;
725 if (pat_len > wowlan->pattern_max_len ||
726 pat_len < wowlan->pattern_min_len)
727 goto error;
728
729 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
730 + if (!pat_tb[NL80211_PKTPAT_OFFSET])
731 pkt_offset = 0;
732 else
733 pkt_offset = nla_get_u32(
734 - pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
735 + pat_tb[NL80211_PKTPAT_OFFSET]);
736 if (pkt_offset > wowlan->max_pkt_offset)
737 goto error;
738 new_triggers.patterns[i].pkt_offset = pkt_offset;
739 @@ -7991,11 +7995,11 @@ static int nl80211_set_wowlan(struct sk_
740 new_triggers.patterns[i].pattern =
741 new_triggers.patterns[i].mask + mask_len;
742 memcpy(new_triggers.patterns[i].mask,
743 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
744 + nla_data(pat_tb[NL80211_PKTPAT_MASK]),
745 mask_len);
746 new_triggers.patterns[i].pattern_len = pat_len;
747 memcpy(new_triggers.patterns[i].pattern,
748 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
749 + nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
750 pat_len);
751 i++;
752 }
753 @@ -10066,7 +10070,8 @@ void cfg80211_mgmt_tx_status(struct wire
754
755 genlmsg_end(msg, hdr);
756
757 - genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
758 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
759 + nl80211_mlme_mcgrp.id, gfp);
760 return;
761
762 nla_put_failure:
763 --- a/net/wireless/reg.c
764 +++ b/net/wireless/reg.c
765 @@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev
766
767 void wiphy_regulatory_register(struct wiphy *wiphy)
768 {
769 + struct regulatory_request *lr;
770 +
771 if (!reg_dev_ignore_cell_hint(wiphy))
772 reg_num_devs_support_basehint++;
773
774 - wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
775 + lr = get_last_request();
776 + wiphy_update_regulatory(wiphy, lr->initiator);
777 }
778
779 void wiphy_regulatory_deregister(struct wiphy *wiphy)
780 @@ -2279,7 +2282,9 @@ void wiphy_regulatory_deregister(struct
781 static void reg_timeout_work(struct work_struct *work)
782 {
783 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
784 + rtnl_lock();
785 restore_regulatory_settings(true);
786 + rtnl_unlock();
787 }
788
789 int __init regulatory_init(void)
790 --- a/net/wireless/sme.c
791 +++ b/net/wireless/sme.c
792 @@ -34,8 +34,10 @@ struct cfg80211_conn {
793 CFG80211_CONN_SCAN_AGAIN,
794 CFG80211_CONN_AUTHENTICATE_NEXT,
795 CFG80211_CONN_AUTHENTICATING,
796 + CFG80211_CONN_AUTH_FAILED,
797 CFG80211_CONN_ASSOCIATE_NEXT,
798 CFG80211_CONN_ASSOCIATING,
799 + CFG80211_CONN_ASSOC_FAILED,
800 CFG80211_CONN_DEAUTH,
801 CFG80211_CONN_CONNECTED,
802 } state;
803 @@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct
804 NULL, 0,
805 params->key, params->key_len,
806 params->key_idx, NULL, 0);
807 + case CFG80211_CONN_AUTH_FAILED:
808 + return -ENOTCONN;
809 case CFG80211_CONN_ASSOCIATE_NEXT:
810 BUG_ON(!rdev->ops->assoc);
811 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
812 @@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct
813 WLAN_REASON_DEAUTH_LEAVING,
814 false);
815 return err;
816 + case CFG80211_CONN_ASSOC_FAILED:
817 + cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
818 + NULL, 0,
819 + WLAN_REASON_DEAUTH_LEAVING, false);
820 + return -ENOTCONN;
821 case CFG80211_CONN_DEAUTH:
822 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
823 NULL, 0,
824 WLAN_REASON_DEAUTH_LEAVING, false);
825 + /* free directly, disconnected event already sent */
826 + cfg80211_sme_free(wdev);
827 return 0;
828 default:
829 return 0;
830 @@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
831 return true;
832 }
833
834 - wdev->conn->state = CFG80211_CONN_DEAUTH;
835 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
836 schedule_work(&rdev->conn_work);
837 return false;
838 }
839 @@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
840
841 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
842 {
843 - cfg80211_sme_free(wdev);
844 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
845 +
846 + if (!wdev->conn)
847 + return;
848 +
849 + wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
850 + schedule_work(&rdev->conn_work);
851 }
852
853 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
854 @@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
855
856 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
857 {
858 - cfg80211_sme_disassoc(wdev);
859 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
860 +
861 + if (!wdev->conn)
862 + return;
863 +
864 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
865 + schedule_work(&rdev->conn_work);
866 }
867
868 static int cfg80211_sme_connect(struct wireless_dev *wdev,
869 --- a/net/mac80211/rc80211_minstrel.c
870 +++ b/net/mac80211/rc80211_minstrel.c
871 @@ -290,7 +290,7 @@ minstrel_get_rate(void *priv, struct iee
872 struct minstrel_rate *msr, *mr;
873 unsigned int ndx;
874 bool mrr_capable;
875 - bool prev_sample = mi->prev_sample;
876 + bool prev_sample;
877 int delta;
878 int sampling_ratio;
879
880 @@ -314,6 +314,7 @@ minstrel_get_rate(void *priv, struct iee
881 (mi->sample_count + mi->sample_deferred / 2);
882
883 /* delta < 0: no sampling required */
884 + prev_sample = mi->prev_sample;
885 mi->prev_sample = false;
886 if (delta < 0 || (!mrr_capable && prev_sample))
887 return;
888 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
889 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
890 @@ -936,13 +936,8 @@ void rt2x00queue_index_inc(struct queue_
891 spin_unlock_irqrestore(&queue->index_lock, irqflags);
892 }
893
894 -void rt2x00queue_pause_queue(struct data_queue *queue)
895 +void rt2x00queue_pause_queue_nocheck(struct data_queue *queue)
896 {
897 - if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
898 - !test_bit(QUEUE_STARTED, &queue->flags) ||
899 - test_and_set_bit(QUEUE_PAUSED, &queue->flags))
900 - return;
901 -
902 switch (queue->qid) {
903 case QID_AC_VO:
904 case QID_AC_VI:
905 @@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data
906 break;
907 }
908 }
909 +void rt2x00queue_pause_queue(struct data_queue *queue)
910 +{
911 + if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
912 + !test_bit(QUEUE_STARTED, &queue->flags) ||
913 + test_and_set_bit(QUEUE_PAUSED, &queue->flags))
914 + return;
915 +
916 + rt2x00queue_pause_queue_nocheck(queue);
917 +}
918 EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
919
920 void rt2x00queue_unpause_queue(struct data_queue *queue)
921 @@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_
922 return;
923 }
924
925 - rt2x00queue_pause_queue(queue);
926 + rt2x00queue_pause_queue_nocheck(queue);
927
928 queue->rt2x00dev->ops->lib->stop_queue(queue);
929
930 --- a/net/mac80211/mlme.c
931 +++ b/net/mac80211/mlme.c
932 @@ -31,10 +31,12 @@
933 #include "led.h"
934
935 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
936 +#define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2)
937 #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
938 #define IEEE80211_AUTH_MAX_TRIES 3
939 #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
940 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
941 +#define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)
942 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
943 #define IEEE80211_ASSOC_MAX_TRIES 3
944
945 @@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee
946 struct ieee80211_channel *channel,
947 const struct ieee80211_ht_operation *ht_oper,
948 const struct ieee80211_vht_operation *vht_oper,
949 - struct cfg80211_chan_def *chandef, bool verbose)
950 + struct cfg80211_chan_def *chandef, bool tracking)
951 {
952 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
953 struct cfg80211_chan_def vht_chandef;
954 u32 ht_cfreq, ret;
955
956 @@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee
957 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
958 channel->band);
959 /* check that channel matches the right operating channel */
960 - if (channel->center_freq != ht_cfreq) {
961 + if (!tracking && channel->center_freq != ht_cfreq) {
962 /*
963 * It's possible that some APs are confused here;
964 * Netgear WNDR3700 sometimes reports 4 higher than
965 @@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee
966 * since we look at probe response/beacon data here
967 * it should be OK.
968 */
969 - if (verbose)
970 - sdata_info(sdata,
971 - "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
972 - channel->center_freq, ht_cfreq,
973 - ht_oper->primary_chan, channel->band);
974 + sdata_info(sdata,
975 + "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
976 + channel->center_freq, ht_cfreq,
977 + ht_oper->primary_chan, channel->band);
978 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
979 goto out;
980 }
981 @@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee
982 channel->band);
983 break;
984 default:
985 - if (verbose)
986 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
987 sdata_info(sdata,
988 "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
989 vht_oper->chan_width);
990 @@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee
991 }
992
993 if (!cfg80211_chandef_valid(&vht_chandef)) {
994 - if (verbose)
995 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
996 sdata_info(sdata,
997 "AP VHT information is invalid, disable VHT\n");
998 ret = IEEE80211_STA_DISABLE_VHT;
999 @@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee
1000 }
1001
1002 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
1003 - if (verbose)
1004 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
1005 sdata_info(sdata,
1006 "AP VHT information doesn't match HT, disable VHT\n");
1007 ret = IEEE80211_STA_DISABLE_VHT;
1008 @@ -333,18 +335,27 @@ out:
1009 if (ret & IEEE80211_STA_DISABLE_VHT)
1010 vht_chandef = *chandef;
1011
1012 + /*
1013 + * Ignore the DISABLED flag when we're already connected and only
1014 + * tracking the APs beacon for bandwidth changes - otherwise we
1015 + * might get disconnected here if we connect to an AP, update our
1016 + * regulatory information based on the AP's country IE and the
1017 + * information we have is wrong/outdated and disables the channel
1018 + * that we're actually using for the connection to the AP.
1019 + */
1020 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
1021 - IEEE80211_CHAN_DISABLED)) {
1022 + tracking ? 0 :
1023 + IEEE80211_CHAN_DISABLED)) {
1024 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
1025 ret = IEEE80211_STA_DISABLE_HT |
1026 IEEE80211_STA_DISABLE_VHT;
1027 - goto out;
1028 + break;
1029 }
1030
1031 ret |= chandef_downgrade(chandef);
1032 }
1033
1034 - if (chandef->width != vht_chandef.width && verbose)
1035 + if (chandef->width != vht_chandef.width && !tracking)
1036 sdata_info(sdata,
1037 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
1038
1039 @@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ie
1040
1041 /* calculate new channel (type) based on HT/VHT operation IEs */
1042 flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper,
1043 - vht_oper, &chandef, false);
1044 + vht_oper, &chandef, true);
1045
1046 /*
1047 * Downgrade the new channel if we associated with restricted
1048 @@ -3394,10 +3405,13 @@ static int ieee80211_probe_auth(struct i
1049
1050 if (tx_flags == 0) {
1051 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
1052 - ifmgd->auth_data->timeout_started = true;
1053 + auth_data->timeout_started = true;
1054 run_again(sdata, auth_data->timeout);
1055 } else {
1056 - auth_data->timeout_started = false;
1057 + auth_data->timeout =
1058 + round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
1059 + auth_data->timeout_started = true;
1060 + run_again(sdata, auth_data->timeout);
1061 }
1062
1063 return 0;
1064 @@ -3434,7 +3448,11 @@ static int ieee80211_do_assoc(struct iee
1065 assoc_data->timeout_started = true;
1066 run_again(sdata, assoc_data->timeout);
1067 } else {
1068 - assoc_data->timeout_started = false;
1069 + assoc_data->timeout =
1070 + round_jiffies_up(jiffies +
1071 + IEEE80211_ASSOC_TIMEOUT_LONG);
1072 + assoc_data->timeout_started = true;
1073 + run_again(sdata, assoc_data->timeout);
1074 }
1075
1076 return 0;
1077 @@ -3829,7 +3847,7 @@ static int ieee80211_prep_channel(struct
1078 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
1079 cbss->channel,
1080 ht_oper, vht_oper,
1081 - &chandef, true);
1082 + &chandef, false);
1083
1084 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
1085 local->rx_chains);
1086 --- a/net/wireless/core.c
1087 +++ b/net/wireless/core.c
1088 @@ -772,6 +772,7 @@ void cfg80211_leave(struct cfg80211_regi
1089 cfg80211_leave_mesh(rdev, dev);
1090 break;
1091 case NL80211_IFTYPE_AP:
1092 + case NL80211_IFTYPE_P2P_GO:
1093 cfg80211_stop_ap(rdev, dev);
1094 break;
1095 default:
1096 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
1097 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
1098 @@ -5404,19 +5404,20 @@ int rt2800_enable_radio(struct rt2x00_de
1099 rt2800_init_registers(rt2x00dev)))
1100 return -EIO;
1101
1102 + if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev)))
1103 + return -EIO;
1104 +
1105 /*
1106 * Send signal to firmware during boot time.
1107 */
1108 rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
1109 rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
1110 - if (rt2x00_is_usb(rt2x00dev)) {
1111 + if (rt2x00_is_usb(rt2x00dev))
1112 rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0);
1113 - rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0);
1114 - }
1115 + rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0);
1116 msleep(1);
1117
1118 - if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev) ||
1119 - rt2800_wait_bbp_ready(rt2x00dev)))
1120 + if (unlikely(rt2800_wait_bbp_ready(rt2x00dev)))
1121 return -EIO;
1122
1123 rt2800_init_bbp(rt2x00dev);
1124 --- a/net/mac80211/main.c
1125 +++ b/net/mac80211/main.c
1126 @@ -101,7 +101,7 @@ static u32 ieee80211_hw_conf_chan(struct
1127 struct ieee80211_sub_if_data *sdata;
1128 struct cfg80211_chan_def chandef = {};
1129 u32 changed = 0;
1130 - int power;
1131 + int power = 0;
1132 u32 offchannel_flag;
1133
1134 offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;
1135 @@ -155,16 +155,16 @@ static u32 ieee80211_hw_conf_chan(struct
1136 changed |= IEEE80211_CONF_CHANGE_SMPS;
1137 }
1138
1139 - power = chandef.chan->max_power;
1140 -
1141 rcu_read_lock();
1142 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1143 if (!rcu_access_pointer(sdata->vif.chanctx_conf))
1144 continue;
1145 - power = min(power, sdata->vif.bss_conf.txpower);
1146 + power = max(power, sdata->vif.bss_conf.txpower);
1147 }
1148 rcu_read_unlock();
1149
1150 + power = min(power, chandef.chan->max_power);
1151 +
1152 if (local->hw.conf.power_level != power) {
1153 changed |= IEEE80211_CONF_CHANGE_POWER;
1154 local->hw.conf.power_level = power;
1155 --- a/net/mac80211/cfg.c
1156 +++ b/net/mac80211/cfg.c
1157 @@ -3332,7 +3332,7 @@ static int ieee80211_probe_client(struct
1158 return -EINVAL;
1159 }
1160 band = chanctx_conf->def.chan->band;
1161 - sta = sta_info_get(sdata, peer);
1162 + sta = sta_info_get_bss(sdata, peer);
1163 if (sta) {
1164 qos = test_sta_flag(sta, WLAN_STA_WME);
1165 } else {
1166 --- a/net/mac80211/status.c
1167 +++ b/net/mac80211/status.c
1168 @@ -180,6 +180,9 @@ static void ieee80211_frame_acked(struct
1169 struct ieee80211_local *local = sta->local;
1170 struct ieee80211_sub_if_data *sdata = sta->sdata;
1171
1172 + if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
1173 + sta->last_rx = jiffies;
1174 +
1175 if (ieee80211_is_data_qos(mgmt->frame_control)) {
1176 struct ieee80211_hdr *hdr = (void *) skb->data;
1177 u8 *qc = ieee80211_get_qos_ctl(hdr);
1178 --- a/net/mac80211/tx.c
1179 +++ b/net/mac80211/tx.c
1180 @@ -1101,7 +1101,8 @@ ieee80211_tx_prepare(struct ieee80211_su
1181 tx->sta = rcu_dereference(sdata->u.vlan.sta);
1182 if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr)
1183 return TX_DROP;
1184 - } else if (info->flags & IEEE80211_TX_CTL_INJECTED ||
1185 + } else if (info->flags & (IEEE80211_TX_CTL_INJECTED |
1186 + IEEE80211_TX_INTFL_NL80211_FRAME_TX) ||
1187 tx->sdata->control_port_protocol == tx->skb->protocol) {
1188 tx->sta = sta_info_get_bss(sdata, hdr->addr1);
1189 }