654d6aabe8797eaeff1c8010cb493452adaf76a1
[openwrt/svn-archive/archive.git] / package / kernel / 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 @@ -2369,6 +2369,7 @@ ieee80211_rx_h_action(struct ieee80211_r
200 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
201 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
202 sdata->vif.type != NL80211_IFTYPE_AP &&
203 + sdata->vif.type != NL80211_IFTYPE_WDS &&
204 sdata->vif.type != NL80211_IFTYPE_ADHOC)
205 break;
206
207 @@ -2720,14 +2721,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
208
209 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
210 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
211 - sdata->vif.type != NL80211_IFTYPE_STATION)
212 + sdata->vif.type != NL80211_IFTYPE_STATION &&
213 + sdata->vif.type != NL80211_IFTYPE_WDS)
214 return RX_DROP_MONITOR;
215
216 switch (stype) {
217 case cpu_to_le16(IEEE80211_STYPE_AUTH):
218 case cpu_to_le16(IEEE80211_STYPE_BEACON):
219 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
220 - /* process for all: mesh, mlme, ibss */
221 + /* process for all: mesh, mlme, ibss, wds */
222 break;
223 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
224 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
225 @@ -3059,10 +3061,16 @@ static int prepare_for_handlers(struct i
226 }
227 break;
228 case NL80211_IFTYPE_WDS:
229 - if (bssid || !ieee80211_is_data(hdr->frame_control))
230 - return 0;
231 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
232 return 0;
233 +
234 + if (ieee80211_is_data(hdr->frame_control) ||
235 + ieee80211_is_action(hdr->frame_control)) {
236 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
237 + return 0;
238 + } else if (!ieee80211_is_beacon(hdr->frame_control))
239 + return 0;
240 +
241 break;
242 case NL80211_IFTYPE_P2P_DEVICE:
243 if (!ieee80211_is_public_action(hdr, skb->len) &&
244 --- a/net/mac80211/sta_info.h
245 +++ b/net/mac80211/sta_info.h
246 @@ -32,7 +32,6 @@
247 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
248 * frames.
249 * @WLAN_STA_WME: Station is a QoS-STA.
250 - * @WLAN_STA_WDS: Station is one of our WDS peers.
251 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
252 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
253 * frame to this station is transmitted.
254 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
255 WLAN_STA_AUTHORIZED,
256 WLAN_STA_SHORT_PREAMBLE,
257 WLAN_STA_WME,
258 - WLAN_STA_WDS,
259 WLAN_STA_CLEAR_PS_FILT,
260 WLAN_STA_MFP,
261 WLAN_STA_BLOCK_BA,
262 --- a/drivers/net/wireless/ath/ath9k/xmit.c
263 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
264 @@ -146,6 +146,28 @@ static void ath_set_rates(struct ieee802
265 ARRAY_SIZE(bf->rates));
266 }
267
268 +static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
269 + struct sk_buff *skb)
270 +{
271 + int q;
272 +
273 + q = skb_get_queue_mapping(skb);
274 + if (txq == sc->tx.uapsdq)
275 + txq = sc->tx.txq_map[q];
276 +
277 + if (txq != sc->tx.txq_map[q])
278 + return;
279 +
280 + if (WARN_ON(--txq->pending_frames < 0))
281 + txq->pending_frames = 0;
282 +
283 + if (txq->stopped &&
284 + txq->pending_frames < sc->tx.txq_max_pending[q]) {
285 + ieee80211_wake_queue(sc->hw, q);
286 + txq->stopped = false;
287 + }
288 +}
289 +
290 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
291 {
292 struct ath_txq *txq = tid->ac->txq;
293 @@ -167,6 +189,7 @@ static void ath_tx_flush_tid(struct ath_
294 if (!bf) {
295 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
296 if (!bf) {
297 + ath_txq_skb_done(sc, txq, skb);
298 ieee80211_free_txskb(sc->hw, skb);
299 continue;
300 }
301 @@ -811,6 +834,7 @@ ath_tx_get_tid_subframe(struct ath_softc
302
303 if (!bf) {
304 __skb_unlink(skb, &tid->buf_q);
305 + ath_txq_skb_done(sc, txq, skb);
306 ieee80211_free_txskb(sc->hw, skb);
307 continue;
308 }
309 @@ -1824,6 +1848,7 @@ static void ath_tx_send_ampdu(struct ath
310
311 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
312 if (!bf) {
313 + ath_txq_skb_done(sc, txq, skb);
314 ieee80211_free_txskb(sc->hw, skb);
315 return;
316 }
317 @@ -2090,6 +2115,7 @@ int ath_tx_start(struct ieee80211_hw *hw
318
319 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
320 if (!bf) {
321 + ath_txq_skb_done(sc, txq, skb);
322 if (txctl->paprd)
323 dev_kfree_skb_any(skb);
324 else
325 @@ -2189,7 +2215,7 @@ static void ath_tx_complete(struct ath_s
326 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
327 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
328 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
329 - int q, padpos, padsize;
330 + int padpos, padsize;
331 unsigned long flags;
332
333 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
334 @@ -2225,21 +2251,7 @@ static void ath_tx_complete(struct ath_s
335 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
336
337 __skb_queue_tail(&txq->complete_q, skb);
338 -
339 - q = skb_get_queue_mapping(skb);
340 - if (txq == sc->tx.uapsdq)
341 - txq = sc->tx.txq_map[q];
342 -
343 - if (txq == sc->tx.txq_map[q]) {
344 - if (WARN_ON(--txq->pending_frames < 0))
345 - txq->pending_frames = 0;
346 -
347 - if (txq->stopped &&
348 - txq->pending_frames < sc->tx.txq_max_pending[q]) {
349 - ieee80211_wake_queue(sc->hw, q);
350 - txq->stopped = false;
351 - }
352 - }
353 + ath_txq_skb_done(sc, txq, skb);
354 }
355
356 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
357 --- a/drivers/net/wireless/ath/ath9k/main.c
358 +++ b/drivers/net/wireless/ath/ath9k/main.c
359 @@ -2094,7 +2094,7 @@ static void ath9k_wow_add_pattern(struct
360 {
361 struct ath_hw *ah = sc->sc_ah;
362 struct ath9k_wow_pattern *wow_pattern = NULL;
363 - struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
364 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
365 int mask_len;
366 s8 i = 0;
367
368 --- a/drivers/net/wireless/mwifiex/cfg80211.c
369 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
370 @@ -2298,8 +2298,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_in
371
372 #ifdef CONFIG_PM
373 static bool
374 -mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
375 - s8 *byte_seq)
376 +mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
377 {
378 int j, k, valid_byte_cnt = 0;
379 bool dont_care_byte = false;
380 --- a/drivers/net/wireless/ti/wlcore/main.c
381 +++ b/drivers/net/wireless/ti/wlcore/main.c
382 @@ -1315,7 +1315,7 @@ static struct sk_buff *wl12xx_alloc_dumm
383
384 #ifdef CONFIG_PM
385 static int
386 -wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
387 +wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
388 {
389 int num_fields = 0, in_field = 0, fields_size = 0;
390 int i, pattern_len = 0;
391 @@ -1458,9 +1458,9 @@ void wl1271_rx_filter_flatten_fields(str
392 * Allocates an RX filter returned through f
393 * which needs to be freed using rx_filter_free()
394 */
395 -static int wl1271_convert_wowlan_pattern_to_rx_filter(
396 - struct cfg80211_wowlan_trig_pkt_pattern *p,
397 - struct wl12xx_rx_filter **f)
398 +static int
399 +wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
400 + struct wl12xx_rx_filter **f)
401 {
402 int i, j, ret = 0;
403 struct wl12xx_rx_filter *filter;
404 @@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
405
406 /* Translate WoWLAN patterns into filters */
407 for (i = 0; i < wow->n_patterns; i++) {
408 - struct cfg80211_wowlan_trig_pkt_pattern *p;
409 + struct cfg80211_pkt_pattern *p;
410 struct wl12xx_rx_filter *filter = NULL;
411
412 p = &wow->patterns[i];
413 --- a/include/net/cfg80211.h
414 +++ b/include/net/cfg80211.h
415 @@ -1698,7 +1698,7 @@ struct cfg80211_pmksa {
416 };
417
418 /**
419 - * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
420 + * struct cfg80211_pkt_pattern - packet pattern
421 * @mask: bitmask where to match pattern and where to ignore bytes,
422 * one bit per byte, in same format as nl80211
423 * @pattern: bytes to match where bitmask is 1
424 @@ -1708,7 +1708,7 @@ struct cfg80211_pmksa {
425 * Internal note: @mask and @pattern are allocated in one chunk of
426 * memory, free @mask only!
427 */
428 -struct cfg80211_wowlan_trig_pkt_pattern {
429 +struct cfg80211_pkt_pattern {
430 u8 *mask, *pattern;
431 int pattern_len;
432 int pkt_offset;
433 @@ -1770,7 +1770,7 @@ struct cfg80211_wowlan {
434 bool any, disconnect, magic_pkt, gtk_rekey_failure,
435 eap_identity_req, four_way_handshake,
436 rfkill_release;
437 - struct cfg80211_wowlan_trig_pkt_pattern *patterns;
438 + struct cfg80211_pkt_pattern *patterns;
439 struct cfg80211_wowlan_tcp *tcp;
440 int n_patterns;
441 };
442 --- a/include/uapi/linux/nl80211.h
443 +++ b/include/uapi/linux/nl80211.h
444 @@ -3060,11 +3060,11 @@ enum nl80211_tx_power_setting {
445 };
446
447 /**
448 - * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
449 - * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
450 - * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
451 + * enum nl80211_packet_pattern_attr - packet pattern attribute
452 + * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
453 + * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
454 * a zero bit are ignored
455 - * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
456 + * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
457 * a bit for each byte in the pattern. The lowest-order bit corresponds
458 * to the first byte of the pattern, but the bytes of the pattern are
459 * in a little-endian-like format, i.e. the 9th byte of the pattern
460 @@ -3075,23 +3075,23 @@ enum nl80211_tx_power_setting {
461 * Note that the pattern matching is done as though frames were not
462 * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
463 * first (including SNAP header unpacking) and then matched.
464 - * @NL80211_WOWLAN_PKTPAT_OFFSET: packet offset, pattern is matched after
465 + * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
466 * these fixed number of bytes of received packet
467 - * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
468 - * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
469 + * @NUM_NL80211_PKTPAT: number of attributes
470 + * @MAX_NL80211_PKTPAT: max attribute number
471 */
472 -enum nl80211_wowlan_packet_pattern_attr {
473 - __NL80211_WOWLAN_PKTPAT_INVALID,
474 - NL80211_WOWLAN_PKTPAT_MASK,
475 - NL80211_WOWLAN_PKTPAT_PATTERN,
476 - NL80211_WOWLAN_PKTPAT_OFFSET,
477 +enum nl80211_packet_pattern_attr {
478 + __NL80211_PKTPAT_INVALID,
479 + NL80211_PKTPAT_MASK,
480 + NL80211_PKTPAT_PATTERN,
481 + NL80211_PKTPAT_OFFSET,
482
483 - NUM_NL80211_WOWLAN_PKTPAT,
484 - MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
485 + NUM_NL80211_PKTPAT,
486 + MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
487 };
488
489 /**
490 - * struct nl80211_wowlan_pattern_support - pattern support information
491 + * struct nl80211_pattern_support - packet pattern support information
492 * @max_patterns: maximum number of patterns supported
493 * @min_pattern_len: minimum length of each pattern
494 * @max_pattern_len: maximum length of each pattern
495 @@ -3101,13 +3101,22 @@ enum nl80211_wowlan_packet_pattern_attr
496 * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
497 * capability information given by the kernel to userspace.
498 */
499 -struct nl80211_wowlan_pattern_support {
500 +struct nl80211_pattern_support {
501 __u32 max_patterns;
502 __u32 min_pattern_len;
503 __u32 max_pattern_len;
504 __u32 max_pkt_offset;
505 } __attribute__((packed));
506
507 +/* only for backward compatibility */
508 +#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
509 +#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
510 +#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
511 +#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
512 +#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
513 +#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
514 +#define nl80211_wowlan_pattern_support nl80211_pattern_support
515 +
516 /**
517 * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
518 * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
519 @@ -3127,7 +3136,7 @@ struct nl80211_wowlan_pattern_support {
520 * pattern matching is done after the packet is converted to the MSDU.
521 *
522 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
523 - * carrying a &struct nl80211_wowlan_pattern_support.
524 + * carrying a &struct nl80211_pattern_support.
525 *
526 * When reporting wakeup. it is a u32 attribute containing the 0-based
527 * index of the pattern that caused the wakeup, in the patterns passed
528 @@ -3284,7 +3293,7 @@ struct nl80211_wowlan_tcp_data_token_fea
529 * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
530 * u32 attribute holding the maximum length
531 * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
532 - * feature advertising. The mask works like @NL80211_WOWLAN_PKTPAT_MASK
533 + * feature advertising. The mask works like @NL80211_PKTPAT_MASK
534 * but on the TCP payload only.
535 * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
536 * @MAX_NL80211_WOWLAN_TCP: highest attribute number
537 --- a/net/mac80211/mesh_ps.c
538 +++ b/net/mac80211/mesh_ps.c
539 @@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(str
540 enum nl80211_mesh_power_mode pm;
541 bool do_buffer;
542
543 + /* For non-assoc STA, prevent buffering or frame transmission */
544 + if (sta->sta_state < IEEE80211_STA_ASSOC)
545 + return;
546 +
547 /*
548 * use peer-specific power mode if peering is established and the
549 * peer's power mode is known
550 --- a/net/wireless/nl80211.c
551 +++ b/net/wireless/nl80211.c
552 @@ -974,7 +974,7 @@ static int nl80211_send_wowlan(struct sk
553 return -ENOBUFS;
554
555 if (dev->wiphy.wowlan->n_patterns) {
556 - struct nl80211_wowlan_pattern_support pat = {
557 + struct nl80211_pattern_support pat = {
558 .max_patterns = dev->wiphy.wowlan->n_patterns,
559 .min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
560 .max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
561 @@ -1568,8 +1568,10 @@ static int nl80211_dump_wiphy(struct sk_
562 rtnl_lock();
563 if (!state) {
564 state = kzalloc(sizeof(*state), GFP_KERNEL);
565 - if (!state)
566 + if (!state) {
567 + rtnl_unlock();
568 return -ENOMEM;
569 + }
570 state->filter_wiphy = -1;
571 ret = nl80211_dump_wiphy_parse(skb, cb, state);
572 if (ret) {
573 @@ -6615,12 +6617,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
574
575 void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
576 {
577 + struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
578 void *hdr = ((void **)skb->cb)[1];
579 struct nlattr *data = ((void **)skb->cb)[2];
580
581 nla_nest_end(skb, data);
582 genlmsg_end(skb, hdr);
583 - genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
584 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
585 + nl80211_testmode_mcgrp.id, gfp);
586 }
587 EXPORT_SYMBOL(cfg80211_testmode_event);
588 #endif
589 @@ -7593,12 +7597,11 @@ static int nl80211_send_wowlan_patterns(
590 if (!nl_pat)
591 return -ENOBUFS;
592 pat_len = wowlan->patterns[i].pattern_len;
593 - if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
594 - DIV_ROUND_UP(pat_len, 8),
595 + if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
596 wowlan->patterns[i].mask) ||
597 - nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
598 - pat_len, wowlan->patterns[i].pattern) ||
599 - nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
600 + nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
601 + wowlan->patterns[i].pattern) ||
602 + nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
603 wowlan->patterns[i].pkt_offset))
604 return -ENOBUFS;
605 nla_nest_end(msg, nl_pat);
606 @@ -7939,7 +7942,7 @@ static int nl80211_set_wowlan(struct sk_
607 struct nlattr *pat;
608 int n_patterns = 0;
609 int rem, pat_len, mask_len, pkt_offset;
610 - struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
611 + struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
612
613 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
614 rem)
615 @@ -7958,26 +7961,25 @@ static int nl80211_set_wowlan(struct sk_
616
617 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
618 rem) {
619 - nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
620 - nla_data(pat), nla_len(pat), NULL);
621 + nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
622 + nla_len(pat), NULL);
623 err = -EINVAL;
624 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
625 - !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
626 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
627 + !pat_tb[NL80211_PKTPAT_PATTERN])
628 goto error;
629 - pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
630 + pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
631 mask_len = DIV_ROUND_UP(pat_len, 8);
632 - if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
633 - mask_len)
634 + if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
635 goto error;
636 if (pat_len > wowlan->pattern_max_len ||
637 pat_len < wowlan->pattern_min_len)
638 goto error;
639
640 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
641 + if (!pat_tb[NL80211_PKTPAT_OFFSET])
642 pkt_offset = 0;
643 else
644 pkt_offset = nla_get_u32(
645 - pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
646 + pat_tb[NL80211_PKTPAT_OFFSET]);
647 if (pkt_offset > wowlan->max_pkt_offset)
648 goto error;
649 new_triggers.patterns[i].pkt_offset = pkt_offset;
650 @@ -7991,11 +7993,11 @@ static int nl80211_set_wowlan(struct sk_
651 new_triggers.patterns[i].pattern =
652 new_triggers.patterns[i].mask + mask_len;
653 memcpy(new_triggers.patterns[i].mask,
654 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
655 + nla_data(pat_tb[NL80211_PKTPAT_MASK]),
656 mask_len);
657 new_triggers.patterns[i].pattern_len = pat_len;
658 memcpy(new_triggers.patterns[i].pattern,
659 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
660 + nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
661 pat_len);
662 i++;
663 }
664 @@ -10066,7 +10068,8 @@ void cfg80211_mgmt_tx_status(struct wire
665
666 genlmsg_end(msg, hdr);
667
668 - genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
669 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
670 + nl80211_mlme_mcgrp.id, gfp);
671 return;
672
673 nla_put_failure:
674 --- a/net/wireless/reg.c
675 +++ b/net/wireless/reg.c
676 @@ -2279,7 +2279,9 @@ void wiphy_regulatory_deregister(struct
677 static void reg_timeout_work(struct work_struct *work)
678 {
679 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
680 + rtnl_lock();
681 restore_regulatory_settings(true);
682 + rtnl_unlock();
683 }
684
685 int __init regulatory_init(void)
686 --- a/net/wireless/sme.c
687 +++ b/net/wireless/sme.c
688 @@ -34,8 +34,10 @@ struct cfg80211_conn {
689 CFG80211_CONN_SCAN_AGAIN,
690 CFG80211_CONN_AUTHENTICATE_NEXT,
691 CFG80211_CONN_AUTHENTICATING,
692 + CFG80211_CONN_AUTH_FAILED,
693 CFG80211_CONN_ASSOCIATE_NEXT,
694 CFG80211_CONN_ASSOCIATING,
695 + CFG80211_CONN_ASSOC_FAILED,
696 CFG80211_CONN_DEAUTH,
697 CFG80211_CONN_CONNECTED,
698 } state;
699 @@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct
700 NULL, 0,
701 params->key, params->key_len,
702 params->key_idx, NULL, 0);
703 + case CFG80211_CONN_AUTH_FAILED:
704 + return -ENOTCONN;
705 case CFG80211_CONN_ASSOCIATE_NEXT:
706 BUG_ON(!rdev->ops->assoc);
707 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
708 @@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct
709 WLAN_REASON_DEAUTH_LEAVING,
710 false);
711 return err;
712 + case CFG80211_CONN_ASSOC_FAILED:
713 + cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
714 + NULL, 0,
715 + WLAN_REASON_DEAUTH_LEAVING, false);
716 + return -ENOTCONN;
717 case CFG80211_CONN_DEAUTH:
718 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
719 NULL, 0,
720 WLAN_REASON_DEAUTH_LEAVING, false);
721 + /* free directly, disconnected event already sent */
722 + cfg80211_sme_free(wdev);
723 return 0;
724 default:
725 return 0;
726 @@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
727 return true;
728 }
729
730 - wdev->conn->state = CFG80211_CONN_DEAUTH;
731 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
732 schedule_work(&rdev->conn_work);
733 return false;
734 }
735 @@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
736
737 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
738 {
739 - cfg80211_sme_free(wdev);
740 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
741 +
742 + if (!wdev->conn)
743 + return;
744 +
745 + wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
746 + schedule_work(&rdev->conn_work);
747 }
748
749 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
750 @@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
751
752 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
753 {
754 - cfg80211_sme_disassoc(wdev);
755 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
756 +
757 + if (!wdev->conn)
758 + return;
759 +
760 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
761 + schedule_work(&rdev->conn_work);
762 }
763
764 static int cfg80211_sme_connect(struct wireless_dev *wdev,