be7b52a8df0ab928bd28e6f0b7426ff61da46bd7
[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 @@ -2094,7 +2094,7 @@ static void ath9k_wow_add_pattern(struct
387 {
388 struct ath_hw *ah = sc->sc_ah;
389 struct ath9k_wow_pattern *wow_pattern = NULL;
390 - struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
391 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
392 int mask_len;
393 s8 i = 0;
394
395 --- a/drivers/net/wireless/mwifiex/cfg80211.c
396 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
397 @@ -2298,8 +2298,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_in
398
399 #ifdef CONFIG_PM
400 static bool
401 -mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
402 - s8 *byte_seq)
403 +mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
404 {
405 int j, k, valid_byte_cnt = 0;
406 bool dont_care_byte = false;
407 --- a/drivers/net/wireless/ti/wlcore/main.c
408 +++ b/drivers/net/wireless/ti/wlcore/main.c
409 @@ -1315,7 +1315,7 @@ static struct sk_buff *wl12xx_alloc_dumm
410
411 #ifdef CONFIG_PM
412 static int
413 -wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
414 +wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
415 {
416 int num_fields = 0, in_field = 0, fields_size = 0;
417 int i, pattern_len = 0;
418 @@ -1458,9 +1458,9 @@ void wl1271_rx_filter_flatten_fields(str
419 * Allocates an RX filter returned through f
420 * which needs to be freed using rx_filter_free()
421 */
422 -static int wl1271_convert_wowlan_pattern_to_rx_filter(
423 - struct cfg80211_wowlan_trig_pkt_pattern *p,
424 - struct wl12xx_rx_filter **f)
425 +static int
426 +wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
427 + struct wl12xx_rx_filter **f)
428 {
429 int i, j, ret = 0;
430 struct wl12xx_rx_filter *filter;
431 @@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
432
433 /* Translate WoWLAN patterns into filters */
434 for (i = 0; i < wow->n_patterns; i++) {
435 - struct cfg80211_wowlan_trig_pkt_pattern *p;
436 + struct cfg80211_pkt_pattern *p;
437 struct wl12xx_rx_filter *filter = NULL;
438
439 p = &wow->patterns[i];
440 --- a/include/net/cfg80211.h
441 +++ b/include/net/cfg80211.h
442 @@ -1698,7 +1698,7 @@ struct cfg80211_pmksa {
443 };
444
445 /**
446 - * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
447 + * struct cfg80211_pkt_pattern - packet pattern
448 * @mask: bitmask where to match pattern and where to ignore bytes,
449 * one bit per byte, in same format as nl80211
450 * @pattern: bytes to match where bitmask is 1
451 @@ -1708,7 +1708,7 @@ struct cfg80211_pmksa {
452 * Internal note: @mask and @pattern are allocated in one chunk of
453 * memory, free @mask only!
454 */
455 -struct cfg80211_wowlan_trig_pkt_pattern {
456 +struct cfg80211_pkt_pattern {
457 u8 *mask, *pattern;
458 int pattern_len;
459 int pkt_offset;
460 @@ -1770,7 +1770,7 @@ struct cfg80211_wowlan {
461 bool any, disconnect, magic_pkt, gtk_rekey_failure,
462 eap_identity_req, four_way_handshake,
463 rfkill_release;
464 - struct cfg80211_wowlan_trig_pkt_pattern *patterns;
465 + struct cfg80211_pkt_pattern *patterns;
466 struct cfg80211_wowlan_tcp *tcp;
467 int n_patterns;
468 };
469 --- a/include/uapi/linux/nl80211.h
470 +++ b/include/uapi/linux/nl80211.h
471 @@ -3060,11 +3060,11 @@ enum nl80211_tx_power_setting {
472 };
473
474 /**
475 - * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
476 - * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
477 - * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
478 + * enum nl80211_packet_pattern_attr - packet pattern attribute
479 + * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
480 + * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
481 * a zero bit are ignored
482 - * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
483 + * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
484 * a bit for each byte in the pattern. The lowest-order bit corresponds
485 * to the first byte of the pattern, but the bytes of the pattern are
486 * in a little-endian-like format, i.e. the 9th byte of the pattern
487 @@ -3075,23 +3075,23 @@ enum nl80211_tx_power_setting {
488 * Note that the pattern matching is done as though frames were not
489 * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
490 * first (including SNAP header unpacking) and then matched.
491 - * @NL80211_WOWLAN_PKTPAT_OFFSET: packet offset, pattern is matched after
492 + * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
493 * these fixed number of bytes of received packet
494 - * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
495 - * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
496 + * @NUM_NL80211_PKTPAT: number of attributes
497 + * @MAX_NL80211_PKTPAT: max attribute number
498 */
499 -enum nl80211_wowlan_packet_pattern_attr {
500 - __NL80211_WOWLAN_PKTPAT_INVALID,
501 - NL80211_WOWLAN_PKTPAT_MASK,
502 - NL80211_WOWLAN_PKTPAT_PATTERN,
503 - NL80211_WOWLAN_PKTPAT_OFFSET,
504 +enum nl80211_packet_pattern_attr {
505 + __NL80211_PKTPAT_INVALID,
506 + NL80211_PKTPAT_MASK,
507 + NL80211_PKTPAT_PATTERN,
508 + NL80211_PKTPAT_OFFSET,
509
510 - NUM_NL80211_WOWLAN_PKTPAT,
511 - MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
512 + NUM_NL80211_PKTPAT,
513 + MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
514 };
515
516 /**
517 - * struct nl80211_wowlan_pattern_support - pattern support information
518 + * struct nl80211_pattern_support - packet pattern support information
519 * @max_patterns: maximum number of patterns supported
520 * @min_pattern_len: minimum length of each pattern
521 * @max_pattern_len: maximum length of each pattern
522 @@ -3101,13 +3101,22 @@ enum nl80211_wowlan_packet_pattern_attr
523 * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
524 * capability information given by the kernel to userspace.
525 */
526 -struct nl80211_wowlan_pattern_support {
527 +struct nl80211_pattern_support {
528 __u32 max_patterns;
529 __u32 min_pattern_len;
530 __u32 max_pattern_len;
531 __u32 max_pkt_offset;
532 } __attribute__((packed));
533
534 +/* only for backward compatibility */
535 +#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
536 +#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
537 +#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
538 +#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
539 +#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
540 +#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
541 +#define nl80211_wowlan_pattern_support nl80211_pattern_support
542 +
543 /**
544 * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
545 * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
546 @@ -3127,7 +3136,7 @@ struct nl80211_wowlan_pattern_support {
547 * pattern matching is done after the packet is converted to the MSDU.
548 *
549 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
550 - * carrying a &struct nl80211_wowlan_pattern_support.
551 + * carrying a &struct nl80211_pattern_support.
552 *
553 * When reporting wakeup. it is a u32 attribute containing the 0-based
554 * index of the pattern that caused the wakeup, in the patterns passed
555 @@ -3284,7 +3293,7 @@ struct nl80211_wowlan_tcp_data_token_fea
556 * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
557 * u32 attribute holding the maximum length
558 * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
559 - * feature advertising. The mask works like @NL80211_WOWLAN_PKTPAT_MASK
560 + * feature advertising. The mask works like @NL80211_PKTPAT_MASK
561 * but on the TCP payload only.
562 * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
563 * @MAX_NL80211_WOWLAN_TCP: highest attribute number
564 --- a/net/mac80211/mesh_ps.c
565 +++ b/net/mac80211/mesh_ps.c
566 @@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(str
567 enum nl80211_mesh_power_mode pm;
568 bool do_buffer;
569
570 + /* For non-assoc STA, prevent buffering or frame transmission */
571 + if (sta->sta_state < IEEE80211_STA_ASSOC)
572 + return;
573 +
574 /*
575 * use peer-specific power mode if peering is established and the
576 * peer's power mode is known
577 --- a/net/wireless/nl80211.c
578 +++ b/net/wireless/nl80211.c
579 @@ -441,10 +441,12 @@ static int nl80211_prepare_wdev_dump(str
580 goto out_unlock;
581 }
582 *rdev = wiphy_to_dev((*wdev)->wiphy);
583 - cb->args[0] = (*rdev)->wiphy_idx;
584 + /* 0 is the first index - add 1 to parse only once */
585 + cb->args[0] = (*rdev)->wiphy_idx + 1;
586 cb->args[1] = (*wdev)->identifier;
587 } else {
588 - struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]);
589 + /* subtract the 1 again here */
590 + struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
591 struct wireless_dev *tmp;
592
593 if (!wiphy) {
594 @@ -974,7 +976,7 @@ static int nl80211_send_wowlan(struct sk
595 return -ENOBUFS;
596
597 if (dev->wiphy.wowlan->n_patterns) {
598 - struct nl80211_wowlan_pattern_support pat = {
599 + struct nl80211_pattern_support pat = {
600 .max_patterns = dev->wiphy.wowlan->n_patterns,
601 .min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
602 .max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
603 @@ -1568,8 +1570,10 @@ static int nl80211_dump_wiphy(struct sk_
604 rtnl_lock();
605 if (!state) {
606 state = kzalloc(sizeof(*state), GFP_KERNEL);
607 - if (!state)
608 + if (!state) {
609 + rtnl_unlock();
610 return -ENOMEM;
611 + }
612 state->filter_wiphy = -1;
613 ret = nl80211_dump_wiphy_parse(skb, cb, state);
614 if (ret) {
615 @@ -6615,12 +6619,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
616
617 void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
618 {
619 + struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
620 void *hdr = ((void **)skb->cb)[1];
621 struct nlattr *data = ((void **)skb->cb)[2];
622
623 nla_nest_end(skb, data);
624 genlmsg_end(skb, hdr);
625 - genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
626 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
627 + nl80211_testmode_mcgrp.id, gfp);
628 }
629 EXPORT_SYMBOL(cfg80211_testmode_event);
630 #endif
631 @@ -7593,12 +7599,11 @@ static int nl80211_send_wowlan_patterns(
632 if (!nl_pat)
633 return -ENOBUFS;
634 pat_len = wowlan->patterns[i].pattern_len;
635 - if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
636 - DIV_ROUND_UP(pat_len, 8),
637 + if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
638 wowlan->patterns[i].mask) ||
639 - nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
640 - pat_len, wowlan->patterns[i].pattern) ||
641 - nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
642 + nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
643 + wowlan->patterns[i].pattern) ||
644 + nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
645 wowlan->patterns[i].pkt_offset))
646 return -ENOBUFS;
647 nla_nest_end(msg, nl_pat);
648 @@ -7939,7 +7944,7 @@ static int nl80211_set_wowlan(struct sk_
649 struct nlattr *pat;
650 int n_patterns = 0;
651 int rem, pat_len, mask_len, pkt_offset;
652 - struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
653 + struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
654
655 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
656 rem)
657 @@ -7958,26 +7963,25 @@ static int nl80211_set_wowlan(struct sk_
658
659 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
660 rem) {
661 - nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
662 - nla_data(pat), nla_len(pat), NULL);
663 + nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
664 + nla_len(pat), NULL);
665 err = -EINVAL;
666 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
667 - !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
668 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
669 + !pat_tb[NL80211_PKTPAT_PATTERN])
670 goto error;
671 - pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
672 + pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
673 mask_len = DIV_ROUND_UP(pat_len, 8);
674 - if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
675 - mask_len)
676 + if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
677 goto error;
678 if (pat_len > wowlan->pattern_max_len ||
679 pat_len < wowlan->pattern_min_len)
680 goto error;
681
682 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
683 + if (!pat_tb[NL80211_PKTPAT_OFFSET])
684 pkt_offset = 0;
685 else
686 pkt_offset = nla_get_u32(
687 - pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
688 + pat_tb[NL80211_PKTPAT_OFFSET]);
689 if (pkt_offset > wowlan->max_pkt_offset)
690 goto error;
691 new_triggers.patterns[i].pkt_offset = pkt_offset;
692 @@ -7991,11 +7995,11 @@ static int nl80211_set_wowlan(struct sk_
693 new_triggers.patterns[i].pattern =
694 new_triggers.patterns[i].mask + mask_len;
695 memcpy(new_triggers.patterns[i].mask,
696 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
697 + nla_data(pat_tb[NL80211_PKTPAT_MASK]),
698 mask_len);
699 new_triggers.patterns[i].pattern_len = pat_len;
700 memcpy(new_triggers.patterns[i].pattern,
701 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
702 + nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
703 pat_len);
704 i++;
705 }
706 @@ -10066,7 +10070,8 @@ void cfg80211_mgmt_tx_status(struct wire
707
708 genlmsg_end(msg, hdr);
709
710 - genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
711 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
712 + nl80211_mlme_mcgrp.id, gfp);
713 return;
714
715 nla_put_failure:
716 --- a/net/wireless/reg.c
717 +++ b/net/wireless/reg.c
718 @@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev
719
720 void wiphy_regulatory_register(struct wiphy *wiphy)
721 {
722 + struct regulatory_request *lr;
723 +
724 if (!reg_dev_ignore_cell_hint(wiphy))
725 reg_num_devs_support_basehint++;
726
727 - wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
728 + lr = get_last_request();
729 + wiphy_update_regulatory(wiphy, lr->initiator);
730 }
731
732 void wiphy_regulatory_deregister(struct wiphy *wiphy)
733 @@ -2279,7 +2282,9 @@ void wiphy_regulatory_deregister(struct
734 static void reg_timeout_work(struct work_struct *work)
735 {
736 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
737 + rtnl_lock();
738 restore_regulatory_settings(true);
739 + rtnl_unlock();
740 }
741
742 int __init regulatory_init(void)
743 --- a/net/wireless/sme.c
744 +++ b/net/wireless/sme.c
745 @@ -34,8 +34,10 @@ struct cfg80211_conn {
746 CFG80211_CONN_SCAN_AGAIN,
747 CFG80211_CONN_AUTHENTICATE_NEXT,
748 CFG80211_CONN_AUTHENTICATING,
749 + CFG80211_CONN_AUTH_FAILED,
750 CFG80211_CONN_ASSOCIATE_NEXT,
751 CFG80211_CONN_ASSOCIATING,
752 + CFG80211_CONN_ASSOC_FAILED,
753 CFG80211_CONN_DEAUTH,
754 CFG80211_CONN_CONNECTED,
755 } state;
756 @@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct
757 NULL, 0,
758 params->key, params->key_len,
759 params->key_idx, NULL, 0);
760 + case CFG80211_CONN_AUTH_FAILED:
761 + return -ENOTCONN;
762 case CFG80211_CONN_ASSOCIATE_NEXT:
763 BUG_ON(!rdev->ops->assoc);
764 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
765 @@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct
766 WLAN_REASON_DEAUTH_LEAVING,
767 false);
768 return err;
769 + case CFG80211_CONN_ASSOC_FAILED:
770 + cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
771 + NULL, 0,
772 + WLAN_REASON_DEAUTH_LEAVING, false);
773 + return -ENOTCONN;
774 case CFG80211_CONN_DEAUTH:
775 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
776 NULL, 0,
777 WLAN_REASON_DEAUTH_LEAVING, false);
778 + /* free directly, disconnected event already sent */
779 + cfg80211_sme_free(wdev);
780 return 0;
781 default:
782 return 0;
783 @@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
784 return true;
785 }
786
787 - wdev->conn->state = CFG80211_CONN_DEAUTH;
788 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
789 schedule_work(&rdev->conn_work);
790 return false;
791 }
792 @@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
793
794 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
795 {
796 - cfg80211_sme_free(wdev);
797 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
798 +
799 + if (!wdev->conn)
800 + return;
801 +
802 + wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
803 + schedule_work(&rdev->conn_work);
804 }
805
806 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
807 @@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
808
809 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
810 {
811 - cfg80211_sme_disassoc(wdev);
812 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
813 +
814 + if (!wdev->conn)
815 + return;
816 +
817 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
818 + schedule_work(&rdev->conn_work);
819 }
820
821 static int cfg80211_sme_connect(struct wireless_dev *wdev,
822 --- a/net/mac80211/rc80211_minstrel.c
823 +++ b/net/mac80211/rc80211_minstrel.c
824 @@ -290,7 +290,7 @@ minstrel_get_rate(void *priv, struct iee
825 struct minstrel_rate *msr, *mr;
826 unsigned int ndx;
827 bool mrr_capable;
828 - bool prev_sample = mi->prev_sample;
829 + bool prev_sample;
830 int delta;
831 int sampling_ratio;
832
833 @@ -314,6 +314,7 @@ minstrel_get_rate(void *priv, struct iee
834 (mi->sample_count + mi->sample_deferred / 2);
835
836 /* delta < 0: no sampling required */
837 + prev_sample = mi->prev_sample;
838 mi->prev_sample = false;
839 if (delta < 0 || (!mrr_capable && prev_sample))
840 return;
841 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
842 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
843 @@ -936,13 +936,8 @@ void rt2x00queue_index_inc(struct queue_
844 spin_unlock_irqrestore(&queue->index_lock, irqflags);
845 }
846
847 -void rt2x00queue_pause_queue(struct data_queue *queue)
848 +void rt2x00queue_pause_queue_nocheck(struct data_queue *queue)
849 {
850 - if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
851 - !test_bit(QUEUE_STARTED, &queue->flags) ||
852 - test_and_set_bit(QUEUE_PAUSED, &queue->flags))
853 - return;
854 -
855 switch (queue->qid) {
856 case QID_AC_VO:
857 case QID_AC_VI:
858 @@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data
859 break;
860 }
861 }
862 +void rt2x00queue_pause_queue(struct data_queue *queue)
863 +{
864 + if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
865 + !test_bit(QUEUE_STARTED, &queue->flags) ||
866 + test_and_set_bit(QUEUE_PAUSED, &queue->flags))
867 + return;
868 +
869 + rt2x00queue_pause_queue_nocheck(queue);
870 +}
871 EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
872
873 void rt2x00queue_unpause_queue(struct data_queue *queue)
874 @@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_
875 return;
876 }
877
878 - rt2x00queue_pause_queue(queue);
879 + rt2x00queue_pause_queue_nocheck(queue);
880
881 queue->rt2x00dev->ops->lib->stop_queue(queue);
882
883 --- a/net/mac80211/mlme.c
884 +++ b/net/mac80211/mlme.c
885 @@ -31,10 +31,12 @@
886 #include "led.h"
887
888 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
889 +#define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2)
890 #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
891 #define IEEE80211_AUTH_MAX_TRIES 3
892 #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
893 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
894 +#define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)
895 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
896 #define IEEE80211_ASSOC_MAX_TRIES 3
897
898 @@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee
899 struct ieee80211_channel *channel,
900 const struct ieee80211_ht_operation *ht_oper,
901 const struct ieee80211_vht_operation *vht_oper,
902 - struct cfg80211_chan_def *chandef, bool verbose)
903 + struct cfg80211_chan_def *chandef, bool tracking)
904 {
905 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
906 struct cfg80211_chan_def vht_chandef;
907 u32 ht_cfreq, ret;
908
909 @@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee
910 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
911 channel->band);
912 /* check that channel matches the right operating channel */
913 - if (channel->center_freq != ht_cfreq) {
914 + if (!tracking && channel->center_freq != ht_cfreq) {
915 /*
916 * It's possible that some APs are confused here;
917 * Netgear WNDR3700 sometimes reports 4 higher than
918 @@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee
919 * since we look at probe response/beacon data here
920 * it should be OK.
921 */
922 - if (verbose)
923 - sdata_info(sdata,
924 - "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
925 - channel->center_freq, ht_cfreq,
926 - ht_oper->primary_chan, channel->band);
927 + sdata_info(sdata,
928 + "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
929 + channel->center_freq, ht_cfreq,
930 + ht_oper->primary_chan, channel->band);
931 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
932 goto out;
933 }
934 @@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee
935 channel->band);
936 break;
937 default:
938 - if (verbose)
939 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
940 sdata_info(sdata,
941 "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
942 vht_oper->chan_width);
943 @@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee
944 }
945
946 if (!cfg80211_chandef_valid(&vht_chandef)) {
947 - if (verbose)
948 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
949 sdata_info(sdata,
950 "AP VHT information is invalid, disable VHT\n");
951 ret = IEEE80211_STA_DISABLE_VHT;
952 @@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee
953 }
954
955 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
956 - if (verbose)
957 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
958 sdata_info(sdata,
959 "AP VHT information doesn't match HT, disable VHT\n");
960 ret = IEEE80211_STA_DISABLE_VHT;
961 @@ -333,18 +335,27 @@ out:
962 if (ret & IEEE80211_STA_DISABLE_VHT)
963 vht_chandef = *chandef;
964
965 + /*
966 + * Ignore the DISABLED flag when we're already connected and only
967 + * tracking the APs beacon for bandwidth changes - otherwise we
968 + * might get disconnected here if we connect to an AP, update our
969 + * regulatory information based on the AP's country IE and the
970 + * information we have is wrong/outdated and disables the channel
971 + * that we're actually using for the connection to the AP.
972 + */
973 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
974 - IEEE80211_CHAN_DISABLED)) {
975 + tracking ? 0 :
976 + IEEE80211_CHAN_DISABLED)) {
977 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
978 ret = IEEE80211_STA_DISABLE_HT |
979 IEEE80211_STA_DISABLE_VHT;
980 - goto out;
981 + break;
982 }
983
984 ret |= chandef_downgrade(chandef);
985 }
986
987 - if (chandef->width != vht_chandef.width && verbose)
988 + if (chandef->width != vht_chandef.width && !tracking)
989 sdata_info(sdata,
990 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
991
992 @@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ie
993
994 /* calculate new channel (type) based on HT/VHT operation IEs */
995 flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper,
996 - vht_oper, &chandef, false);
997 + vht_oper, &chandef, true);
998
999 /*
1000 * Downgrade the new channel if we associated with restricted
1001 @@ -3394,10 +3405,13 @@ static int ieee80211_probe_auth(struct i
1002
1003 if (tx_flags == 0) {
1004 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
1005 - ifmgd->auth_data->timeout_started = true;
1006 + auth_data->timeout_started = true;
1007 run_again(sdata, auth_data->timeout);
1008 } else {
1009 - auth_data->timeout_started = false;
1010 + auth_data->timeout =
1011 + round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
1012 + auth_data->timeout_started = true;
1013 + run_again(sdata, auth_data->timeout);
1014 }
1015
1016 return 0;
1017 @@ -3434,7 +3448,11 @@ static int ieee80211_do_assoc(struct iee
1018 assoc_data->timeout_started = true;
1019 run_again(sdata, assoc_data->timeout);
1020 } else {
1021 - assoc_data->timeout_started = false;
1022 + assoc_data->timeout =
1023 + round_jiffies_up(jiffies +
1024 + IEEE80211_ASSOC_TIMEOUT_LONG);
1025 + assoc_data->timeout_started = true;
1026 + run_again(sdata, assoc_data->timeout);
1027 }
1028
1029 return 0;
1030 @@ -3829,7 +3847,7 @@ static int ieee80211_prep_channel(struct
1031 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
1032 cbss->channel,
1033 ht_oper, vht_oper,
1034 - &chandef, true);
1035 + &chandef, false);
1036
1037 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
1038 local->rx_chains);
1039 --- a/net/wireless/core.c
1040 +++ b/net/wireless/core.c
1041 @@ -772,6 +772,7 @@ void cfg80211_leave(struct cfg80211_regi
1042 cfg80211_leave_mesh(rdev, dev);
1043 break;
1044 case NL80211_IFTYPE_AP:
1045 + case NL80211_IFTYPE_P2P_GO:
1046 cfg80211_stop_ap(rdev, dev);
1047 break;
1048 default:
1049 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
1050 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
1051 @@ -5404,19 +5404,20 @@ int rt2800_enable_radio(struct rt2x00_de
1052 rt2800_init_registers(rt2x00dev)))
1053 return -EIO;
1054
1055 + if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev)))
1056 + return -EIO;
1057 +
1058 /*
1059 * Send signal to firmware during boot time.
1060 */
1061 rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
1062 rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
1063 - if (rt2x00_is_usb(rt2x00dev)) {
1064 + if (rt2x00_is_usb(rt2x00dev))
1065 rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0);
1066 - rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0);
1067 - }
1068 + rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0);
1069 msleep(1);
1070
1071 - if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev) ||
1072 - rt2800_wait_bbp_ready(rt2x00dev)))
1073 + if (unlikely(rt2800_wait_bbp_ready(rt2x00dev)))
1074 return -EIO;
1075
1076 rt2800_init_bbp(rt2x00dev);
1077 --- a/net/mac80211/main.c
1078 +++ b/net/mac80211/main.c
1079 @@ -101,7 +101,7 @@ static u32 ieee80211_hw_conf_chan(struct
1080 struct ieee80211_sub_if_data *sdata;
1081 struct cfg80211_chan_def chandef = {};
1082 u32 changed = 0;
1083 - int power;
1084 + int power = 0;
1085 u32 offchannel_flag;
1086
1087 offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;
1088 @@ -155,16 +155,16 @@ static u32 ieee80211_hw_conf_chan(struct
1089 changed |= IEEE80211_CONF_CHANGE_SMPS;
1090 }
1091
1092 - power = chandef.chan->max_power;
1093 -
1094 rcu_read_lock();
1095 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1096 if (!rcu_access_pointer(sdata->vif.chanctx_conf))
1097 continue;
1098 - power = min(power, sdata->vif.bss_conf.txpower);
1099 + power = max(power, sdata->vif.bss_conf.txpower);
1100 }
1101 rcu_read_unlock();
1102
1103 + power = min(power, chandef.chan->max_power);
1104 +
1105 if (local->hw.conf.power_level != power) {
1106 changed |= IEEE80211_CONF_CHANGE_POWER;
1107 local->hw.conf.power_level = power;
1108 --- a/net/mac80211/cfg.c
1109 +++ b/net/mac80211/cfg.c
1110 @@ -3332,7 +3332,7 @@ static int ieee80211_probe_client(struct
1111 return -EINVAL;
1112 }
1113 band = chanctx_conf->def.chan->band;
1114 - sta = sta_info_get(sdata, peer);
1115 + sta = sta_info_get_bss(sdata, peer);
1116 if (sta) {
1117 qos = test_sta_flag(sta, WLAN_STA_WME);
1118 } else {
1119 --- a/net/mac80211/status.c
1120 +++ b/net/mac80211/status.c
1121 @@ -180,6 +180,9 @@ static void ieee80211_frame_acked(struct
1122 struct ieee80211_local *local = sta->local;
1123 struct ieee80211_sub_if_data *sdata = sta->sdata;
1124
1125 + if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
1126 + sta->last_rx = jiffies;
1127 +
1128 if (ieee80211_is_data_qos(mgmt->frame_control)) {
1129 struct ieee80211_hdr *hdr = (void *) skb->data;
1130 u8 *qc = ieee80211_get_qos_ctl(hdr);
1131 --- a/net/mac80211/tx.c
1132 +++ b/net/mac80211/tx.c
1133 @@ -1101,7 +1101,8 @@ ieee80211_tx_prepare(struct ieee80211_su
1134 tx->sta = rcu_dereference(sdata->u.vlan.sta);
1135 if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr)
1136 return TX_DROP;
1137 - } else if (info->flags & IEEE80211_TX_CTL_INJECTED ||
1138 + } else if (info->flags & (IEEE80211_TX_CTL_INJECTED |
1139 + IEEE80211_TX_INTFL_NL80211_FRAME_TX) ||
1140 tx->sdata->control_port_protocol == tx->skb->protocol) {
1141 tx->sta = sta_info_get_bss(sdata, hdr->addr1);
1142 }