mac80211: merge upstream patch to suppress unnecessary ad-hoc mode scan with fixed...
[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 @@ -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 @@ -3059,10 +3067,16 @@ static int prepare_for_handlers(struct i
243 }
244 break;
245 case NL80211_IFTYPE_WDS:
246 - if (bssid || !ieee80211_is_data(hdr->frame_control))
247 - return 0;
248 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
249 return 0;
250 +
251 + if (ieee80211_is_data(hdr->frame_control) ||
252 + ieee80211_is_action(hdr->frame_control)) {
253 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
254 + return 0;
255 + } else if (!ieee80211_is_beacon(hdr->frame_control))
256 + return 0;
257 +
258 break;
259 case NL80211_IFTYPE_P2P_DEVICE:
260 if (!ieee80211_is_public_action(hdr, skb->len) &&
261 --- a/net/mac80211/sta_info.h
262 +++ b/net/mac80211/sta_info.h
263 @@ -32,7 +32,6 @@
264 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
265 * frames.
266 * @WLAN_STA_WME: Station is a QoS-STA.
267 - * @WLAN_STA_WDS: Station is one of our WDS peers.
268 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
269 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
270 * frame to this station is transmitted.
271 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
272 WLAN_STA_AUTHORIZED,
273 WLAN_STA_SHORT_PREAMBLE,
274 WLAN_STA_WME,
275 - WLAN_STA_WDS,
276 WLAN_STA_CLEAR_PS_FILT,
277 WLAN_STA_MFP,
278 WLAN_STA_BLOCK_BA,
279 --- a/drivers/net/wireless/ath/ath9k/xmit.c
280 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
281 @@ -135,6 +135,9 @@ static struct ath_frame_info *get_frame_
282
283 static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno)
284 {
285 + if (!tid->an->sta)
286 + return;
287 +
288 ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno,
289 seqno << IEEE80211_SEQ_SEQ_SHIFT);
290 }
291 @@ -146,6 +149,93 @@ 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 struct ath_atx_tid *
318 +ath_get_skb_tid(struct ath_softc *sc, struct ath_node *an, struct sk_buff *skb)
319 +{
320 + struct ieee80211_hdr *hdr;
321 + u8 tidno = 0;
322 +
323 + hdr = (struct ieee80211_hdr *) skb->data;
324 + if (ieee80211_is_data_qos(hdr->frame_control))
325 + tidno = ieee80211_get_qos_ctl(hdr)[0];
326 +
327 + tidno &= IEEE80211_QOS_CTL_TID_MASK;
328 + return ATH_AN_2_TID(an, tidno);
329 +}
330 +
331 +static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
332 +{
333 + return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
334 +}
335 +
336 +static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
337 +{
338 + struct sk_buff *skb;
339 +
340 + skb = __skb_dequeue(&tid->retry_q);
341 + if (!skb)
342 + skb = __skb_dequeue(&tid->buf_q);
343 +
344 + return skb;
345 +}
346 +
347 +/*
348 + * ath_tx_tid_change_state:
349 + * - clears a-mpdu flag of previous session
350 + * - force sequence number allocation to fix next BlockAck Window
351 + */
352 +static void
353 +ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
354 +{
355 + struct ath_txq *txq = tid->ac->txq;
356 + struct ieee80211_tx_info *tx_info;
357 + struct sk_buff *skb, *tskb;
358 + struct ath_buf *bf;
359 + struct ath_frame_info *fi;
360 +
361 + skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
362 + fi = get_frame_info(skb);
363 + bf = fi->bf;
364 +
365 + tx_info = IEEE80211_SKB_CB(skb);
366 + tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
367 +
368 + if (bf)
369 + continue;
370 +
371 + bf = ath_tx_setup_buffer(sc, txq, tid, skb);
372 + if (!bf) {
373 + __skb_unlink(skb, &tid->buf_q);
374 + ath_txq_skb_done(sc, txq, skb);
375 + ieee80211_free_txskb(sc->hw, skb);
376 + continue;
377 + }
378 + }
379 +
380 +}
381 +
382 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
383 {
384 struct ath_txq *txq = tid->ac->txq;
385 @@ -160,27 +250,22 @@ static void ath_tx_flush_tid(struct ath_
386
387 memset(&ts, 0, sizeof(ts));
388
389 - while ((skb = __skb_dequeue(&tid->buf_q))) {
390 + while ((skb = __skb_dequeue(&tid->retry_q))) {
391 fi = get_frame_info(skb);
392 bf = fi->bf;
393 -
394 if (!bf) {
395 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
396 - if (!bf) {
397 - ieee80211_free_txskb(sc->hw, skb);
398 - continue;
399 - }
400 + ath_txq_skb_done(sc, txq, skb);
401 + ieee80211_free_txskb(sc->hw, skb);
402 + continue;
403 }
404
405 - if (fi->retries) {
406 - list_add_tail(&bf->list, &bf_head);
407 + if (fi->baw_tracked) {
408 ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
409 - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
410 sendbar = true;
411 - } else {
412 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
413 - ath_tx_send_normal(sc, txq, NULL, skb);
414 }
415 +
416 + list_add_tail(&bf->list, &bf_head);
417 + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
418 }
419
420 if (sendbar) {
421 @@ -209,13 +294,16 @@ static void ath_tx_update_baw(struct ath
422 }
423
424 static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
425 - u16 seqno)
426 + struct ath_buf *bf)
427 {
428 + struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
429 + u16 seqno = bf->bf_state.seqno;
430 int index, cindex;
431
432 index = ATH_BA_INDEX(tid->seq_start, seqno);
433 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
434 __set_bit(cindex, tid->tx_buf);
435 + fi->baw_tracked = 1;
436
437 if (index >= ((tid->baw_tail - tid->baw_head) &
438 (ATH_TID_MAX_BUFS - 1))) {
439 @@ -243,7 +331,7 @@ static void ath_tid_drain(struct ath_sof
440 memset(&ts, 0, sizeof(ts));
441 INIT_LIST_HEAD(&bf_head);
442
443 - while ((skb = __skb_dequeue(&tid->buf_q))) {
444 + while ((skb = ath_tid_dequeue(tid))) {
445 fi = get_frame_info(skb);
446 bf = fi->bf;
447
448 @@ -380,7 +468,6 @@ static void ath_tx_complete_aggr(struct
449 struct ieee80211_tx_rate rates[4];
450 struct ath_frame_info *fi;
451 int nframes;
452 - u8 tidno;
453 bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH);
454 int i, retries;
455 int bar_index = -1;
456 @@ -417,8 +504,7 @@ static void ath_tx_complete_aggr(struct
457 }
458
459 an = (struct ath_node *)sta->drv_priv;
460 - tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
461 - tid = ATH_AN_2_TID(an, tidno);
462 + tid = ath_get_skb_tid(sc, an, skb);
463 seq_first = tid->seq_start;
464 isba = ts->ts_flags & ATH9K_TX_BA;
465
466 @@ -430,7 +516,7 @@ static void ath_tx_complete_aggr(struct
467 * Only BlockAcks have a TID and therefore normal Acks cannot be
468 * checked
469 */
470 - if (isba && tidno != ts->tid)
471 + if (isba && tid->tidno != ts->tid)
472 txok = false;
473
474 isaggr = bf_isaggr(bf);
475 @@ -466,7 +552,8 @@ static void ath_tx_complete_aggr(struct
476 tx_info = IEEE80211_SKB_CB(skb);
477 fi = get_frame_info(skb);
478
479 - if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
480 + if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) ||
481 + !tid->active) {
482 /*
483 * Outside of the current BlockAck window,
484 * maybe part of a previous session
485 @@ -560,7 +647,7 @@ static void ath_tx_complete_aggr(struct
486 if (an->sleeping)
487 ieee80211_sta_set_buffered(sta, tid->tidno, true);
488
489 - skb_queue_splice(&bf_pending, &tid->buf_q);
490 + skb_queue_splice_tail(&bf_pending, &tid->retry_q);
491 if (!an->sleeping) {
492 ath_tx_queue_tid(txq, tid);
493
494 @@ -618,7 +705,7 @@ static void ath_tx_process_buffer(struct
495 } else
496 ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok);
497
498 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !flush)
499 + if (!flush)
500 ath_txq_schedule(sc, txq);
501 }
502
503 @@ -792,15 +879,20 @@ static int ath_compute_num_delims(struct
504
505 static struct ath_buf *
506 ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
507 - struct ath_atx_tid *tid)
508 + struct ath_atx_tid *tid, struct sk_buff_head **q)
509 {
510 + struct ieee80211_tx_info *tx_info;
511 struct ath_frame_info *fi;
512 struct sk_buff *skb;
513 struct ath_buf *bf;
514 u16 seqno;
515
516 while (1) {
517 - skb = skb_peek(&tid->buf_q);
518 + *q = &tid->retry_q;
519 + if (skb_queue_empty(*q))
520 + *q = &tid->buf_q;
521 +
522 + skb = skb_peek(*q);
523 if (!skb)
524 break;
525
526 @@ -810,11 +902,22 @@ ath_tx_get_tid_subframe(struct ath_softc
527 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
528
529 if (!bf) {
530 - __skb_unlink(skb, &tid->buf_q);
531 + __skb_unlink(skb, *q);
532 + ath_txq_skb_done(sc, txq, skb);
533 ieee80211_free_txskb(sc->hw, skb);
534 continue;
535 }
536
537 + bf->bf_next = NULL;
538 + bf->bf_lastbf = bf;
539 +
540 + tx_info = IEEE80211_SKB_CB(skb);
541 + tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
542 + if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
543 + bf->bf_state.bf_type = 0;
544 + return bf;
545 + }
546 +
547 bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR;
548 seqno = bf->bf_state.seqno;
549
550 @@ -828,73 +931,52 @@ ath_tx_get_tid_subframe(struct ath_softc
551
552 INIT_LIST_HEAD(&bf_head);
553 list_add(&bf->list, &bf_head);
554 - __skb_unlink(skb, &tid->buf_q);
555 + __skb_unlink(skb, *q);
556 ath_tx_update_baw(sc, tid, seqno);
557 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
558 continue;
559 }
560
561 - bf->bf_next = NULL;
562 - bf->bf_lastbf = bf;
563 return bf;
564 }
565
566 return NULL;
567 }
568
569 -static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
570 - struct ath_txq *txq,
571 - struct ath_atx_tid *tid,
572 - struct list_head *bf_q,
573 - int *aggr_len)
574 +static bool
575 +ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
576 + struct ath_atx_tid *tid, struct list_head *bf_q,
577 + struct ath_buf *bf_first, struct sk_buff_head *tid_q,
578 + int *aggr_len)
579 {
580 #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
581 - struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL;
582 - int rl = 0, nframes = 0, ndelim, prev_al = 0;
583 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
584 + int nframes = 0, ndelim;
585 u16 aggr_limit = 0, al = 0, bpad = 0,
586 - al_delta, h_baw = tid->baw_size / 2;
587 - enum ATH_AGGR_STATUS status = ATH_AGGR_DONE;
588 + al_delta, h_baw = tid->baw_size / 2;
589 struct ieee80211_tx_info *tx_info;
590 struct ath_frame_info *fi;
591 struct sk_buff *skb;
592 + bool closed = false;
593
594 - do {
595 - bf = ath_tx_get_tid_subframe(sc, txq, tid);
596 - if (!bf) {
597 - status = ATH_AGGR_BAW_CLOSED;
598 - break;
599 - }
600 + bf = bf_first;
601 + aggr_limit = ath_lookup_rate(sc, bf, tid);
602
603 + do {
604 skb = bf->bf_mpdu;
605 fi = get_frame_info(skb);
606
607 - if (!bf_first)
608 - bf_first = bf;
609 -
610 - if (!rl) {
611 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
612 - aggr_limit = ath_lookup_rate(sc, bf, tid);
613 - rl = 1;
614 - }
615 -
616 /* do not exceed aggregation limit */
617 al_delta = ATH_AGGR_DELIM_SZ + fi->framelen;
618 + if (nframes) {
619 + if (aggr_limit < al + bpad + al_delta ||
620 + ath_lookup_legacy(bf) || nframes >= h_baw)
621 + break;
622
623 - if (nframes &&
624 - ((aggr_limit < (al + bpad + al_delta + prev_al)) ||
625 - ath_lookup_legacy(bf))) {
626 - status = ATH_AGGR_LIMITED;
627 - break;
628 - }
629 -
630 - tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
631 - if (nframes && (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE))
632 - break;
633 -
634 - /* do not exceed subframe limit */
635 - if (nframes >= min((int)h_baw, ATH_AMPDU_SUBFRAME_DEFAULT)) {
636 - status = ATH_AGGR_LIMITED;
637 - break;
638 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
639 + if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
640 + !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
641 + break;
642 }
643
644 /* add padding for previous frame to aggregation length */
645 @@ -912,22 +994,37 @@ static enum ATH_AGGR_STATUS ath_tx_form_
646 bf->bf_next = NULL;
647
648 /* link buffers of this frame to the aggregate */
649 - if (!fi->retries)
650 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
651 + if (!fi->baw_tracked)
652 + ath_tx_addto_baw(sc, tid, bf);
653 bf->bf_state.ndelim = ndelim;
654
655 - __skb_unlink(skb, &tid->buf_q);
656 + __skb_unlink(skb, tid_q);
657 list_add_tail(&bf->list, bf_q);
658 if (bf_prev)
659 bf_prev->bf_next = bf;
660
661 bf_prev = bf;
662
663 - } while (!skb_queue_empty(&tid->buf_q));
664 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
665 + if (!bf) {
666 + closed = true;
667 + break;
668 + }
669 + } while (ath_tid_has_buffered(tid));
670 +
671 + bf = bf_first;
672 + bf->bf_lastbf = bf_prev;
673 +
674 + if (bf == bf_prev) {
675 + al = get_frame_info(bf->bf_mpdu)->framelen;
676 + bf->bf_state.bf_type = BUF_AMPDU;
677 + } else {
678 + TX_STAT_INC(txq->axq_qnum, a_aggr);
679 + }
680
681 *aggr_len = al;
682
683 - return status;
684 + return closed;
685 #undef PADBYTES
686 }
687
688 @@ -1188,53 +1285,86 @@ static void ath_tx_fill_desc(struct ath_
689 }
690 }
691
692 -static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
693 - struct ath_atx_tid *tid)
694 +static void
695 +ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
696 + struct ath_atx_tid *tid, struct list_head *bf_q,
697 + struct ath_buf *bf_first, struct sk_buff_head *tid_q)
698 {
699 - struct ath_buf *bf;
700 - enum ATH_AGGR_STATUS status;
701 - struct ieee80211_tx_info *tx_info;
702 - struct list_head bf_q;
703 - int aggr_len;
704 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
705 + struct sk_buff *skb;
706 + int nframes = 0;
707
708 do {
709 - if (skb_queue_empty(&tid->buf_q))
710 - return;
711 + struct ieee80211_tx_info *tx_info;
712 + skb = bf->bf_mpdu;
713
714 - INIT_LIST_HEAD(&bf_q);
715 + nframes++;
716 + __skb_unlink(skb, tid_q);
717 + list_add_tail(&bf->list, bf_q);
718 + if (bf_prev)
719 + bf_prev->bf_next = bf;
720 + bf_prev = bf;
721
722 - status = ath_tx_form_aggr(sc, txq, tid, &bf_q, &aggr_len);
723 + if (nframes >= 2)
724 + break;
725
726 - /*
727 - * no frames picked up to be aggregated;
728 - * block-ack window is not open.
729 - */
730 - if (list_empty(&bf_q))
731 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
732 + if (!bf)
733 break;
734
735 - bf = list_first_entry(&bf_q, struct ath_buf, list);
736 - bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
737 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
738 + if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
739 + break;
740
741 - if (tid->ac->clear_ps_filter) {
742 - tid->ac->clear_ps_filter = false;
743 - tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
744 - } else {
745 - tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
746 - }
747 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
748 + } while (1);
749 +}
750
751 - /* if only one frame, send as non-aggregate */
752 - if (bf == bf->bf_lastbf) {
753 - aggr_len = get_frame_info(bf->bf_mpdu)->framelen;
754 - bf->bf_state.bf_type = BUF_AMPDU;
755 - } else {
756 - TX_STAT_INC(txq->axq_qnum, a_aggr);
757 - }
758 +static bool ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
759 + struct ath_atx_tid *tid, bool *stop)
760 +{
761 + struct ath_buf *bf;
762 + struct ieee80211_tx_info *tx_info;
763 + struct sk_buff_head *tid_q;
764 + struct list_head bf_q;
765 + int aggr_len = 0;
766 + bool aggr, last = true;
767 +
768 + if (!ath_tid_has_buffered(tid))
769 + return false;
770 +
771 + INIT_LIST_HEAD(&bf_q);
772 +
773 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
774 + if (!bf)
775 + return false;
776 +
777 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
778 + aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
779 + if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
780 + (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
781 + *stop = true;
782 + return false;
783 + }
784 +
785 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
786 + if (aggr)
787 + last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
788 + tid_q, &aggr_len);
789 + else
790 + ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
791 +
792 + if (list_empty(&bf_q))
793 + return false;
794 +
795 + if (tid->ac->clear_ps_filter || tid->an->no_ps_filter) {
796 + tid->ac->clear_ps_filter = false;
797 + tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
798 + }
799
800 - ath_tx_fill_desc(sc, bf, txq, aggr_len);
801 - ath_tx_txqaddbuf(sc, txq, &bf_q, false);
802 - } while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH &&
803 - status != ATH_AGGR_BAW_CLOSED);
804 + ath_tx_fill_desc(sc, bf, txq, aggr_len);
805 + ath_tx_txqaddbuf(sc, txq, &bf_q, false);
806 + return true;
807 }
808
809 int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
810 @@ -1258,6 +1388,9 @@ int ath_tx_aggr_start(struct ath_softc *
811 an->mpdudensity = density;
812 }
813
814 + /* force sequence number allocation for pending frames */
815 + ath_tx_tid_change_state(sc, txtid);
816 +
817 txtid->active = true;
818 txtid->paused = true;
819 *ssn = txtid->seq_start = txtid->seq_next;
820 @@ -1277,8 +1410,9 @@ void ath_tx_aggr_stop(struct ath_softc *
821
822 ath_txq_lock(sc, txq);
823 txtid->active = false;
824 - txtid->paused = true;
825 + txtid->paused = false;
826 ath_tx_flush_tid(sc, txtid);
827 + ath_tx_tid_change_state(sc, txtid);
828 ath_txq_unlock_complete(sc, txq);
829 }
830
831 @@ -1302,7 +1436,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
832
833 ath_txq_lock(sc, txq);
834
835 - buffered = !skb_queue_empty(&tid->buf_q);
836 + buffered = ath_tid_has_buffered(tid);
837
838 tid->sched = false;
839 list_del(&tid->list);
840 @@ -1334,7 +1468,7 @@ void ath_tx_aggr_wakeup(struct ath_softc
841 ath_txq_lock(sc, txq);
842 ac->clear_ps_filter = true;
843
844 - if (!skb_queue_empty(&tid->buf_q) && !tid->paused) {
845 + if (!tid->paused && ath_tid_has_buffered(tid)) {
846 ath_tx_queue_tid(txq, tid);
847 ath_txq_schedule(sc, txq);
848 }
849 @@ -1359,7 +1493,7 @@ void ath_tx_aggr_resume(struct ath_softc
850 tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
851 tid->paused = false;
852
853 - if (!skb_queue_empty(&tid->buf_q)) {
854 + if (ath_tid_has_buffered(tid)) {
855 ath_tx_queue_tid(txq, tid);
856 ath_txq_schedule(sc, txq);
857 }
858 @@ -1379,6 +1513,7 @@ void ath9k_release_buffered_frames(struc
859 struct ieee80211_tx_info *info;
860 struct list_head bf_q;
861 struct ath_buf *bf_tail = NULL, *bf;
862 + struct sk_buff_head *tid_q;
863 int sent = 0;
864 int i;
865
866 @@ -1394,15 +1529,15 @@ void ath9k_release_buffered_frames(struc
867 continue;
868
869 ath_txq_lock(sc, tid->ac->txq);
870 - while (!skb_queue_empty(&tid->buf_q) && nframes > 0) {
871 - bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid);
872 + while (nframes > 0) {
873 + bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
874 if (!bf)
875 break;
876
877 - __skb_unlink(bf->bf_mpdu, &tid->buf_q);
878 + __skb_unlink(bf->bf_mpdu, tid_q);
879 list_add_tail(&bf->list, &bf_q);
880 ath_set_rates(tid->an->vif, tid->an->sta, bf);
881 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
882 + ath_tx_addto_baw(sc, tid, bf);
883 bf->bf_state.bf_type &= ~BUF_AGGR;
884 if (bf_tail)
885 bf_tail->bf_next = bf;
886 @@ -1412,7 +1547,7 @@ void ath9k_release_buffered_frames(struc
887 sent++;
888 TX_STAT_INC(txq->axq_qnum, a_queued_hw);
889
890 - if (skb_queue_empty(&tid->buf_q))
891 + if (an->sta && !ath_tid_has_buffered(tid))
892 ieee80211_sta_set_buffered(an->sta, i, false);
893 }
894 ath_txq_unlock_complete(sc, tid->ac->txq);
895 @@ -1665,25 +1800,27 @@ void ath_tx_cleanupq(struct ath_softc *s
896 */
897 void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
898 {
899 - struct ath_atx_ac *ac, *ac_tmp, *last_ac;
900 + struct ath_atx_ac *ac, *last_ac;
901 struct ath_atx_tid *tid, *last_tid;
902 + bool sent = false;
903
904 if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) ||
905 - list_empty(&txq->axq_acq) ||
906 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
907 + list_empty(&txq->axq_acq))
908 return;
909
910 rcu_read_lock();
911
912 - ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
913 last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list);
914 + while (!list_empty(&txq->axq_acq)) {
915 + bool stop = false;
916
917 - list_for_each_entry_safe(ac, ac_tmp, &txq->axq_acq, list) {
918 + ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
919 last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
920 list_del(&ac->list);
921 ac->sched = false;
922
923 while (!list_empty(&ac->tid_q)) {
924 +
925 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
926 list);
927 list_del(&tid->list);
928 @@ -1692,17 +1829,17 @@ void ath_txq_schedule(struct ath_softc *
929 if (tid->paused)
930 continue;
931
932 - ath_tx_sched_aggr(sc, txq, tid);
933 + if (ath_tx_sched_aggr(sc, txq, tid, &stop))
934 + sent = true;
935
936 /*
937 * add tid to round-robin queue if more frames
938 * are pending for the tid
939 */
940 - if (!skb_queue_empty(&tid->buf_q))
941 + if (ath_tid_has_buffered(tid))
942 ath_tx_queue_tid(txq, tid);
943
944 - if (tid == last_tid ||
945 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
946 + if (stop || tid == last_tid)
947 break;
948 }
949
950 @@ -1711,9 +1848,17 @@ void ath_txq_schedule(struct ath_softc *
951 list_add_tail(&ac->list, &txq->axq_acq);
952 }
953
954 - if (ac == last_ac ||
955 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
956 + if (stop)
957 break;
958 +
959 + if (ac == last_ac) {
960 + if (!sent)
961 + break;
962 +
963 + sent = false;
964 + last_ac = list_entry(txq->axq_acq.prev,
965 + struct ath_atx_ac, list);
966 + }
967 }
968
969 rcu_read_unlock();
970 @@ -1792,57 +1937,6 @@ static void ath_tx_txqaddbuf(struct ath_
971 }
972 }
973
974 -static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_txq *txq,
975 - struct ath_atx_tid *tid, struct sk_buff *skb,
976 - struct ath_tx_control *txctl)
977 -{
978 - struct ath_frame_info *fi = get_frame_info(skb);
979 - struct list_head bf_head;
980 - struct ath_buf *bf;
981 -
982 - /*
983 - * Do not queue to h/w when any of the following conditions is true:
984 - * - there are pending frames in software queue
985 - * - the TID is currently paused for ADDBA/BAR request
986 - * - seqno is not within block-ack window
987 - * - h/w queue depth exceeds low water mark
988 - */
989 - if ((!skb_queue_empty(&tid->buf_q) || tid->paused ||
990 - !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) ||
991 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) &&
992 - txq != sc->tx.uapsdq) {
993 - /*
994 - * Add this frame to software queue for scheduling later
995 - * for aggregation.
996 - */
997 - TX_STAT_INC(txq->axq_qnum, a_queued_sw);
998 - __skb_queue_tail(&tid->buf_q, skb);
999 - if (!txctl->an || !txctl->an->sleeping)
1000 - ath_tx_queue_tid(txq, tid);
1001 - return;
1002 - }
1003 -
1004 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1005 - if (!bf) {
1006 - ieee80211_free_txskb(sc->hw, skb);
1007 - return;
1008 - }
1009 -
1010 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
1011 - bf->bf_state.bf_type = BUF_AMPDU;
1012 - INIT_LIST_HEAD(&bf_head);
1013 - list_add(&bf->list, &bf_head);
1014 -
1015 - /* Add sub-frame to BAW */
1016 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
1017 -
1018 - /* Queue to h/w without aggregation */
1019 - TX_STAT_INC(txq->axq_qnum, a_queued_hw);
1020 - bf->bf_lastbf = bf;
1021 - ath_tx_fill_desc(sc, bf, txq, fi->framelen);
1022 - ath_tx_txqaddbuf(sc, txq, &bf_head, false);
1023 -}
1024 -
1025 static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
1026 struct ath_atx_tid *tid, struct sk_buff *skb)
1027 {
1028 @@ -1985,6 +2079,7 @@ static int ath_tx_prepare(struct ieee802
1029 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1030 struct ieee80211_sta *sta = txctl->sta;
1031 struct ieee80211_vif *vif = info->control.vif;
1032 + struct ath_vif *avp;
1033 struct ath_softc *sc = hw->priv;
1034 int frmlen = skb->len + FCS_LEN;
1035 int padpos, padsize;
1036 @@ -1992,6 +2087,10 @@ static int ath_tx_prepare(struct ieee802
1037 /* NOTE: sta can be NULL according to net/mac80211.h */
1038 if (sta)
1039 txctl->an = (struct ath_node *)sta->drv_priv;
1040 + else if (vif && ieee80211_is_data(hdr->frame_control)) {
1041 + avp = (void *)vif->drv_priv;
1042 + txctl->an = &avp->mcast_node;
1043 + }
1044
1045 if (info->control.hw_key)
1046 frmlen += info->control.hw_key->icv_len;
1047 @@ -2041,7 +2140,6 @@ int ath_tx_start(struct ieee80211_hw *hw
1048 struct ath_txq *txq = txctl->txq;
1049 struct ath_atx_tid *tid = NULL;
1050 struct ath_buf *bf;
1051 - u8 tidno;
1052 int q;
1053 int ret;
1054
1055 @@ -2069,27 +2167,31 @@ int ath_tx_start(struct ieee80211_hw *hw
1056 ath_txq_unlock(sc, txq);
1057 txq = sc->tx.uapsdq;
1058 ath_txq_lock(sc, txq);
1059 - }
1060 -
1061 - if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
1062 - tidno = ieee80211_get_qos_ctl(hdr)[0] &
1063 - IEEE80211_QOS_CTL_TID_MASK;
1064 - tid = ATH_AN_2_TID(txctl->an, tidno);
1065 + } else if (txctl->an &&
1066 + ieee80211_is_data_present(hdr->frame_control)) {
1067 + tid = ath_get_skb_tid(sc, txctl->an, skb);
1068
1069 WARN_ON(tid->ac->txq != txctl->txq);
1070 - }
1071
1072 - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
1073 + if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
1074 + tid->ac->clear_ps_filter = true;
1075 +
1076 /*
1077 - * Try aggregation if it's a unicast data frame
1078 - * and the destination is HT capable.
1079 + * Add this frame to software queue for scheduling later
1080 + * for aggregation.
1081 */
1082 - ath_tx_send_ampdu(sc, txq, tid, skb, txctl);
1083 + TX_STAT_INC(txq->axq_qnum, a_queued_sw);
1084 + __skb_queue_tail(&tid->buf_q, skb);
1085 + if (!txctl->an->sleeping)
1086 + ath_tx_queue_tid(txq, tid);
1087 +
1088 + ath_txq_schedule(sc, txq);
1089 goto out;
1090 }
1091
1092 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1093 if (!bf) {
1094 + ath_txq_skb_done(sc, txq, skb);
1095 if (txctl->paprd)
1096 dev_kfree_skb_any(skb);
1097 else
1098 @@ -2189,7 +2291,7 @@ static void ath_tx_complete(struct ath_s
1099 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1100 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1101 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
1102 - int q, padpos, padsize;
1103 + int padpos, padsize;
1104 unsigned long flags;
1105
1106 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
1107 @@ -2225,21 +2327,7 @@ static void ath_tx_complete(struct ath_s
1108 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1109
1110 __skb_queue_tail(&txq->complete_q, skb);
1111 -
1112 - q = skb_get_queue_mapping(skb);
1113 - if (txq == sc->tx.uapsdq)
1114 - txq = sc->tx.txq_map[q];
1115 -
1116 - if (txq == sc->tx.txq_map[q]) {
1117 - if (WARN_ON(--txq->pending_frames < 0))
1118 - txq->pending_frames = 0;
1119 -
1120 - if (txq->stopped &&
1121 - txq->pending_frames < sc->tx.txq_max_pending[q]) {
1122 - ieee80211_wake_queue(sc->hw, q);
1123 - txq->stopped = false;
1124 - }
1125 - }
1126 + ath_txq_skb_done(sc, txq, skb);
1127 }
1128
1129 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
1130 @@ -2360,8 +2448,7 @@ static void ath_tx_processq(struct ath_s
1131
1132 if (list_empty(&txq->axq_q)) {
1133 txq->axq_link = NULL;
1134 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
1135 - ath_txq_schedule(sc, txq);
1136 + ath_txq_schedule(sc, txq);
1137 break;
1138 }
1139 bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
1140 @@ -2583,6 +2670,7 @@ void ath_tx_node_init(struct ath_softc *
1141 tid->paused = false;
1142 tid->active = false;
1143 __skb_queue_head_init(&tid->buf_q);
1144 + __skb_queue_head_init(&tid->retry_q);
1145 acno = TID_TO_WME_AC(tidno);
1146 tid->ac = &an->ac[acno];
1147 }
1148 @@ -2590,6 +2678,7 @@ void ath_tx_node_init(struct ath_softc *
1149 for (acno = 0, ac = &an->ac[acno];
1150 acno < IEEE80211_NUM_ACS; acno++, ac++) {
1151 ac->sched = false;
1152 + ac->clear_ps_filter = true;
1153 ac->txq = sc->tx.txq_map[acno];
1154 INIT_LIST_HEAD(&ac->tid_q);
1155 }
1156 --- a/drivers/net/wireless/ath/ath9k/main.c
1157 +++ b/drivers/net/wireless/ath/ath9k/main.c
1158 @@ -966,6 +966,8 @@ static int ath9k_add_interface(struct ie
1159 struct ath_softc *sc = hw->priv;
1160 struct ath_hw *ah = sc->sc_ah;
1161 struct ath_common *common = ath9k_hw_common(ah);
1162 + struct ath_vif *avp = (void *)vif->drv_priv;
1163 + struct ath_node *an = &avp->mcast_node;
1164
1165 mutex_lock(&sc->mutex);
1166
1167 @@ -979,6 +981,12 @@ static int ath9k_add_interface(struct ie
1168 if (ath9k_uses_beacons(vif->type))
1169 ath9k_beacon_assign_slot(sc, vif);
1170
1171 + an->sc = sc;
1172 + an->sta = NULL;
1173 + an->vif = vif;
1174 + an->no_ps_filter = true;
1175 + ath_tx_node_init(sc, an);
1176 +
1177 mutex_unlock(&sc->mutex);
1178 return 0;
1179 }
1180 @@ -1016,6 +1024,7 @@ static void ath9k_remove_interface(struc
1181 {
1182 struct ath_softc *sc = hw->priv;
1183 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1184 + struct ath_vif *avp = (void *)vif->drv_priv;
1185
1186 ath_dbg(common, CONFIG, "Detach Interface\n");
1187
1188 @@ -1030,6 +1039,8 @@ static void ath9k_remove_interface(struc
1189 ath9k_calculate_summary_state(hw, NULL);
1190 ath9k_ps_restore(sc);
1191
1192 + ath_tx_node_cleanup(sc, &avp->mcast_node);
1193 +
1194 mutex_unlock(&sc->mutex);
1195 }
1196
1197 @@ -1374,9 +1385,6 @@ static void ath9k_sta_notify(struct ieee
1198 struct ath_softc *sc = hw->priv;
1199 struct ath_node *an = (struct ath_node *) sta->drv_priv;
1200
1201 - if (!sta->ht_cap.ht_supported)
1202 - return;
1203 -
1204 switch (cmd) {
1205 case STA_NOTIFY_SLEEP:
1206 an->sleeping = true;
1207 @@ -2094,7 +2102,7 @@ static void ath9k_wow_add_pattern(struct
1208 {
1209 struct ath_hw *ah = sc->sc_ah;
1210 struct ath9k_wow_pattern *wow_pattern = NULL;
1211 - struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
1212 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
1213 int mask_len;
1214 s8 i = 0;
1215
1216 --- a/drivers/net/wireless/mwifiex/cfg80211.c
1217 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
1218 @@ -2298,8 +2298,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_in
1219
1220 #ifdef CONFIG_PM
1221 static bool
1222 -mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
1223 - s8 *byte_seq)
1224 +mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
1225 {
1226 int j, k, valid_byte_cnt = 0;
1227 bool dont_care_byte = false;
1228 --- a/drivers/net/wireless/ti/wlcore/main.c
1229 +++ b/drivers/net/wireless/ti/wlcore/main.c
1230 @@ -1315,7 +1315,7 @@ static struct sk_buff *wl12xx_alloc_dumm
1231
1232 #ifdef CONFIG_PM
1233 static int
1234 -wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
1235 +wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
1236 {
1237 int num_fields = 0, in_field = 0, fields_size = 0;
1238 int i, pattern_len = 0;
1239 @@ -1458,9 +1458,9 @@ void wl1271_rx_filter_flatten_fields(str
1240 * Allocates an RX filter returned through f
1241 * which needs to be freed using rx_filter_free()
1242 */
1243 -static int wl1271_convert_wowlan_pattern_to_rx_filter(
1244 - struct cfg80211_wowlan_trig_pkt_pattern *p,
1245 - struct wl12xx_rx_filter **f)
1246 +static int
1247 +wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
1248 + struct wl12xx_rx_filter **f)
1249 {
1250 int i, j, ret = 0;
1251 struct wl12xx_rx_filter *filter;
1252 @@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
1253
1254 /* Translate WoWLAN patterns into filters */
1255 for (i = 0; i < wow->n_patterns; i++) {
1256 - struct cfg80211_wowlan_trig_pkt_pattern *p;
1257 + struct cfg80211_pkt_pattern *p;
1258 struct wl12xx_rx_filter *filter = NULL;
1259
1260 p = &wow->patterns[i];
1261 --- a/include/net/cfg80211.h
1262 +++ b/include/net/cfg80211.h
1263 @@ -1698,7 +1698,7 @@ struct cfg80211_pmksa {
1264 };
1265
1266 /**
1267 - * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
1268 + * struct cfg80211_pkt_pattern - packet pattern
1269 * @mask: bitmask where to match pattern and where to ignore bytes,
1270 * one bit per byte, in same format as nl80211
1271 * @pattern: bytes to match where bitmask is 1
1272 @@ -1708,7 +1708,7 @@ struct cfg80211_pmksa {
1273 * Internal note: @mask and @pattern are allocated in one chunk of
1274 * memory, free @mask only!
1275 */
1276 -struct cfg80211_wowlan_trig_pkt_pattern {
1277 +struct cfg80211_pkt_pattern {
1278 u8 *mask, *pattern;
1279 int pattern_len;
1280 int pkt_offset;
1281 @@ -1770,7 +1770,7 @@ struct cfg80211_wowlan {
1282 bool any, disconnect, magic_pkt, gtk_rekey_failure,
1283 eap_identity_req, four_way_handshake,
1284 rfkill_release;
1285 - struct cfg80211_wowlan_trig_pkt_pattern *patterns;
1286 + struct cfg80211_pkt_pattern *patterns;
1287 struct cfg80211_wowlan_tcp *tcp;
1288 int n_patterns;
1289 };
1290 --- a/include/uapi/linux/nl80211.h
1291 +++ b/include/uapi/linux/nl80211.h
1292 @@ -3060,11 +3060,11 @@ enum nl80211_tx_power_setting {
1293 };
1294
1295 /**
1296 - * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
1297 - * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
1298 - * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
1299 + * enum nl80211_packet_pattern_attr - packet pattern attribute
1300 + * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
1301 + * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
1302 * a zero bit are ignored
1303 - * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
1304 + * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
1305 * a bit for each byte in the pattern. The lowest-order bit corresponds
1306 * to the first byte of the pattern, but the bytes of the pattern are
1307 * in a little-endian-like format, i.e. the 9th byte of the pattern
1308 @@ -3075,23 +3075,23 @@ enum nl80211_tx_power_setting {
1309 * Note that the pattern matching is done as though frames were not
1310 * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
1311 * first (including SNAP header unpacking) and then matched.
1312 - * @NL80211_WOWLAN_PKTPAT_OFFSET: packet offset, pattern is matched after
1313 + * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
1314 * these fixed number of bytes of received packet
1315 - * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
1316 - * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
1317 + * @NUM_NL80211_PKTPAT: number of attributes
1318 + * @MAX_NL80211_PKTPAT: max attribute number
1319 */
1320 -enum nl80211_wowlan_packet_pattern_attr {
1321 - __NL80211_WOWLAN_PKTPAT_INVALID,
1322 - NL80211_WOWLAN_PKTPAT_MASK,
1323 - NL80211_WOWLAN_PKTPAT_PATTERN,
1324 - NL80211_WOWLAN_PKTPAT_OFFSET,
1325 +enum nl80211_packet_pattern_attr {
1326 + __NL80211_PKTPAT_INVALID,
1327 + NL80211_PKTPAT_MASK,
1328 + NL80211_PKTPAT_PATTERN,
1329 + NL80211_PKTPAT_OFFSET,
1330
1331 - NUM_NL80211_WOWLAN_PKTPAT,
1332 - MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
1333 + NUM_NL80211_PKTPAT,
1334 + MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
1335 };
1336
1337 /**
1338 - * struct nl80211_wowlan_pattern_support - pattern support information
1339 + * struct nl80211_pattern_support - packet pattern support information
1340 * @max_patterns: maximum number of patterns supported
1341 * @min_pattern_len: minimum length of each pattern
1342 * @max_pattern_len: maximum length of each pattern
1343 @@ -3101,13 +3101,22 @@ enum nl80211_wowlan_packet_pattern_attr
1344 * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
1345 * capability information given by the kernel to userspace.
1346 */
1347 -struct nl80211_wowlan_pattern_support {
1348 +struct nl80211_pattern_support {
1349 __u32 max_patterns;
1350 __u32 min_pattern_len;
1351 __u32 max_pattern_len;
1352 __u32 max_pkt_offset;
1353 } __attribute__((packed));
1354
1355 +/* only for backward compatibility */
1356 +#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
1357 +#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
1358 +#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
1359 +#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
1360 +#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
1361 +#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
1362 +#define nl80211_wowlan_pattern_support nl80211_pattern_support
1363 +
1364 /**
1365 * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
1366 * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
1367 @@ -3127,7 +3136,7 @@ struct nl80211_wowlan_pattern_support {
1368 * pattern matching is done after the packet is converted to the MSDU.
1369 *
1370 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
1371 - * carrying a &struct nl80211_wowlan_pattern_support.
1372 + * carrying a &struct nl80211_pattern_support.
1373 *
1374 * When reporting wakeup. it is a u32 attribute containing the 0-based
1375 * index of the pattern that caused the wakeup, in the patterns passed
1376 @@ -3284,7 +3293,7 @@ struct nl80211_wowlan_tcp_data_token_fea
1377 * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
1378 * u32 attribute holding the maximum length
1379 * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
1380 - * feature advertising. The mask works like @NL80211_WOWLAN_PKTPAT_MASK
1381 + * feature advertising. The mask works like @NL80211_PKTPAT_MASK
1382 * but on the TCP payload only.
1383 * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
1384 * @MAX_NL80211_WOWLAN_TCP: highest attribute number
1385 --- a/net/mac80211/mesh_ps.c
1386 +++ b/net/mac80211/mesh_ps.c
1387 @@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(str
1388 enum nl80211_mesh_power_mode pm;
1389 bool do_buffer;
1390
1391 + /* For non-assoc STA, prevent buffering or frame transmission */
1392 + if (sta->sta_state < IEEE80211_STA_ASSOC)
1393 + return;
1394 +
1395 /*
1396 * use peer-specific power mode if peering is established and the
1397 * peer's power mode is known
1398 --- a/net/wireless/nl80211.c
1399 +++ b/net/wireless/nl80211.c
1400 @@ -441,10 +441,12 @@ static int nl80211_prepare_wdev_dump(str
1401 goto out_unlock;
1402 }
1403 *rdev = wiphy_to_dev((*wdev)->wiphy);
1404 - cb->args[0] = (*rdev)->wiphy_idx;
1405 + /* 0 is the first index - add 1 to parse only once */
1406 + cb->args[0] = (*rdev)->wiphy_idx + 1;
1407 cb->args[1] = (*wdev)->identifier;
1408 } else {
1409 - struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]);
1410 + /* subtract the 1 again here */
1411 + struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
1412 struct wireless_dev *tmp;
1413
1414 if (!wiphy) {
1415 @@ -974,7 +976,7 @@ static int nl80211_send_wowlan(struct sk
1416 return -ENOBUFS;
1417
1418 if (dev->wiphy.wowlan->n_patterns) {
1419 - struct nl80211_wowlan_pattern_support pat = {
1420 + struct nl80211_pattern_support pat = {
1421 .max_patterns = dev->wiphy.wowlan->n_patterns,
1422 .min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
1423 .max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
1424 @@ -1568,8 +1570,10 @@ static int nl80211_dump_wiphy(struct sk_
1425 rtnl_lock();
1426 if (!state) {
1427 state = kzalloc(sizeof(*state), GFP_KERNEL);
1428 - if (!state)
1429 + if (!state) {
1430 + rtnl_unlock();
1431 return -ENOMEM;
1432 + }
1433 state->filter_wiphy = -1;
1434 ret = nl80211_dump_wiphy_parse(skb, cb, state);
1435 if (ret) {
1436 @@ -6615,12 +6619,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
1437
1438 void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
1439 {
1440 + struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
1441 void *hdr = ((void **)skb->cb)[1];
1442 struct nlattr *data = ((void **)skb->cb)[2];
1443
1444 nla_nest_end(skb, data);
1445 genlmsg_end(skb, hdr);
1446 - genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
1447 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
1448 + nl80211_testmode_mcgrp.id, gfp);
1449 }
1450 EXPORT_SYMBOL(cfg80211_testmode_event);
1451 #endif
1452 @@ -7593,12 +7599,11 @@ static int nl80211_send_wowlan_patterns(
1453 if (!nl_pat)
1454 return -ENOBUFS;
1455 pat_len = wowlan->patterns[i].pattern_len;
1456 - if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
1457 - DIV_ROUND_UP(pat_len, 8),
1458 + if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
1459 wowlan->patterns[i].mask) ||
1460 - nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
1461 - pat_len, wowlan->patterns[i].pattern) ||
1462 - nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
1463 + nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
1464 + wowlan->patterns[i].pattern) ||
1465 + nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
1466 wowlan->patterns[i].pkt_offset))
1467 return -ENOBUFS;
1468 nla_nest_end(msg, nl_pat);
1469 @@ -7939,7 +7944,7 @@ static int nl80211_set_wowlan(struct sk_
1470 struct nlattr *pat;
1471 int n_patterns = 0;
1472 int rem, pat_len, mask_len, pkt_offset;
1473 - struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
1474 + struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
1475
1476 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
1477 rem)
1478 @@ -7958,26 +7963,25 @@ static int nl80211_set_wowlan(struct sk_
1479
1480 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
1481 rem) {
1482 - nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
1483 - nla_data(pat), nla_len(pat), NULL);
1484 + nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
1485 + nla_len(pat), NULL);
1486 err = -EINVAL;
1487 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
1488 - !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
1489 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
1490 + !pat_tb[NL80211_PKTPAT_PATTERN])
1491 goto error;
1492 - pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
1493 + pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
1494 mask_len = DIV_ROUND_UP(pat_len, 8);
1495 - if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
1496 - mask_len)
1497 + if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
1498 goto error;
1499 if (pat_len > wowlan->pattern_max_len ||
1500 pat_len < wowlan->pattern_min_len)
1501 goto error;
1502
1503 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
1504 + if (!pat_tb[NL80211_PKTPAT_OFFSET])
1505 pkt_offset = 0;
1506 else
1507 pkt_offset = nla_get_u32(
1508 - pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
1509 + pat_tb[NL80211_PKTPAT_OFFSET]);
1510 if (pkt_offset > wowlan->max_pkt_offset)
1511 goto error;
1512 new_triggers.patterns[i].pkt_offset = pkt_offset;
1513 @@ -7991,11 +7995,11 @@ static int nl80211_set_wowlan(struct sk_
1514 new_triggers.patterns[i].pattern =
1515 new_triggers.patterns[i].mask + mask_len;
1516 memcpy(new_triggers.patterns[i].mask,
1517 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
1518 + nla_data(pat_tb[NL80211_PKTPAT_MASK]),
1519 mask_len);
1520 new_triggers.patterns[i].pattern_len = pat_len;
1521 memcpy(new_triggers.patterns[i].pattern,
1522 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
1523 + nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
1524 pat_len);
1525 i++;
1526 }
1527 @@ -10066,7 +10070,8 @@ void cfg80211_mgmt_tx_status(struct wire
1528
1529 genlmsg_end(msg, hdr);
1530
1531 - genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
1532 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
1533 + nl80211_mlme_mcgrp.id, gfp);
1534 return;
1535
1536 nla_put_failure:
1537 --- a/net/wireless/reg.c
1538 +++ b/net/wireless/reg.c
1539 @@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev
1540
1541 void wiphy_regulatory_register(struct wiphy *wiphy)
1542 {
1543 + struct regulatory_request *lr;
1544 +
1545 if (!reg_dev_ignore_cell_hint(wiphy))
1546 reg_num_devs_support_basehint++;
1547
1548 - wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
1549 + lr = get_last_request();
1550 + wiphy_update_regulatory(wiphy, lr->initiator);
1551 }
1552
1553 void wiphy_regulatory_deregister(struct wiphy *wiphy)
1554 @@ -2279,7 +2282,9 @@ void wiphy_regulatory_deregister(struct
1555 static void reg_timeout_work(struct work_struct *work)
1556 {
1557 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
1558 + rtnl_lock();
1559 restore_regulatory_settings(true);
1560 + rtnl_unlock();
1561 }
1562
1563 int __init regulatory_init(void)
1564 --- a/net/wireless/sme.c
1565 +++ b/net/wireless/sme.c
1566 @@ -34,8 +34,10 @@ struct cfg80211_conn {
1567 CFG80211_CONN_SCAN_AGAIN,
1568 CFG80211_CONN_AUTHENTICATE_NEXT,
1569 CFG80211_CONN_AUTHENTICATING,
1570 + CFG80211_CONN_AUTH_FAILED,
1571 CFG80211_CONN_ASSOCIATE_NEXT,
1572 CFG80211_CONN_ASSOCIATING,
1573 + CFG80211_CONN_ASSOC_FAILED,
1574 CFG80211_CONN_DEAUTH,
1575 CFG80211_CONN_CONNECTED,
1576 } state;
1577 @@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct
1578 NULL, 0,
1579 params->key, params->key_len,
1580 params->key_idx, NULL, 0);
1581 + case CFG80211_CONN_AUTH_FAILED:
1582 + return -ENOTCONN;
1583 case CFG80211_CONN_ASSOCIATE_NEXT:
1584 BUG_ON(!rdev->ops->assoc);
1585 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
1586 @@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct
1587 WLAN_REASON_DEAUTH_LEAVING,
1588 false);
1589 return err;
1590 + case CFG80211_CONN_ASSOC_FAILED:
1591 + cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
1592 + NULL, 0,
1593 + WLAN_REASON_DEAUTH_LEAVING, false);
1594 + return -ENOTCONN;
1595 case CFG80211_CONN_DEAUTH:
1596 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
1597 NULL, 0,
1598 WLAN_REASON_DEAUTH_LEAVING, false);
1599 + /* free directly, disconnected event already sent */
1600 + cfg80211_sme_free(wdev);
1601 return 0;
1602 default:
1603 return 0;
1604 @@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
1605 return true;
1606 }
1607
1608 - wdev->conn->state = CFG80211_CONN_DEAUTH;
1609 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
1610 schedule_work(&rdev->conn_work);
1611 return false;
1612 }
1613 @@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
1614
1615 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
1616 {
1617 - cfg80211_sme_free(wdev);
1618 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
1619 +
1620 + if (!wdev->conn)
1621 + return;
1622 +
1623 + wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
1624 + schedule_work(&rdev->conn_work);
1625 }
1626
1627 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
1628 @@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
1629
1630 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
1631 {
1632 - cfg80211_sme_disassoc(wdev);
1633 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
1634 +
1635 + if (!wdev->conn)
1636 + return;
1637 +
1638 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
1639 + schedule_work(&rdev->conn_work);
1640 }
1641
1642 static int cfg80211_sme_connect(struct wireless_dev *wdev,
1643 --- a/net/mac80211/rc80211_minstrel.c
1644 +++ b/net/mac80211/rc80211_minstrel.c
1645 @@ -290,7 +290,7 @@ minstrel_get_rate(void *priv, struct iee
1646 struct minstrel_rate *msr, *mr;
1647 unsigned int ndx;
1648 bool mrr_capable;
1649 - bool prev_sample = mi->prev_sample;
1650 + bool prev_sample;
1651 int delta;
1652 int sampling_ratio;
1653
1654 @@ -314,6 +314,7 @@ minstrel_get_rate(void *priv, struct iee
1655 (mi->sample_count + mi->sample_deferred / 2);
1656
1657 /* delta < 0: no sampling required */
1658 + prev_sample = mi->prev_sample;
1659 mi->prev_sample = false;
1660 if (delta < 0 || (!mrr_capable && prev_sample))
1661 return;
1662 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
1663 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
1664 @@ -936,13 +936,8 @@ void rt2x00queue_index_inc(struct queue_
1665 spin_unlock_irqrestore(&queue->index_lock, irqflags);
1666 }
1667
1668 -void rt2x00queue_pause_queue(struct data_queue *queue)
1669 +void rt2x00queue_pause_queue_nocheck(struct data_queue *queue)
1670 {
1671 - if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
1672 - !test_bit(QUEUE_STARTED, &queue->flags) ||
1673 - test_and_set_bit(QUEUE_PAUSED, &queue->flags))
1674 - return;
1675 -
1676 switch (queue->qid) {
1677 case QID_AC_VO:
1678 case QID_AC_VI:
1679 @@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data
1680 break;
1681 }
1682 }
1683 +void rt2x00queue_pause_queue(struct data_queue *queue)
1684 +{
1685 + if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
1686 + !test_bit(QUEUE_STARTED, &queue->flags) ||
1687 + test_and_set_bit(QUEUE_PAUSED, &queue->flags))
1688 + return;
1689 +
1690 + rt2x00queue_pause_queue_nocheck(queue);
1691 +}
1692 EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
1693
1694 void rt2x00queue_unpause_queue(struct data_queue *queue)
1695 @@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_
1696 return;
1697 }
1698
1699 - rt2x00queue_pause_queue(queue);
1700 + rt2x00queue_pause_queue_nocheck(queue);
1701
1702 queue->rt2x00dev->ops->lib->stop_queue(queue);
1703
1704 --- a/net/mac80211/mlme.c
1705 +++ b/net/mac80211/mlme.c
1706 @@ -31,10 +31,12 @@
1707 #include "led.h"
1708
1709 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
1710 +#define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2)
1711 #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
1712 #define IEEE80211_AUTH_MAX_TRIES 3
1713 #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
1714 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
1715 +#define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)
1716 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
1717 #define IEEE80211_ASSOC_MAX_TRIES 3
1718
1719 @@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee
1720 struct ieee80211_channel *channel,
1721 const struct ieee80211_ht_operation *ht_oper,
1722 const struct ieee80211_vht_operation *vht_oper,
1723 - struct cfg80211_chan_def *chandef, bool verbose)
1724 + struct cfg80211_chan_def *chandef, bool tracking)
1725 {
1726 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1727 struct cfg80211_chan_def vht_chandef;
1728 u32 ht_cfreq, ret;
1729
1730 @@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee
1731 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
1732 channel->band);
1733 /* check that channel matches the right operating channel */
1734 - if (channel->center_freq != ht_cfreq) {
1735 + if (!tracking && channel->center_freq != ht_cfreq) {
1736 /*
1737 * It's possible that some APs are confused here;
1738 * Netgear WNDR3700 sometimes reports 4 higher than
1739 @@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee
1740 * since we look at probe response/beacon data here
1741 * it should be OK.
1742 */
1743 - if (verbose)
1744 - sdata_info(sdata,
1745 - "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
1746 - channel->center_freq, ht_cfreq,
1747 - ht_oper->primary_chan, channel->band);
1748 + sdata_info(sdata,
1749 + "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
1750 + channel->center_freq, ht_cfreq,
1751 + ht_oper->primary_chan, channel->band);
1752 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
1753 goto out;
1754 }
1755 @@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee
1756 channel->band);
1757 break;
1758 default:
1759 - if (verbose)
1760 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
1761 sdata_info(sdata,
1762 "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
1763 vht_oper->chan_width);
1764 @@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee
1765 }
1766
1767 if (!cfg80211_chandef_valid(&vht_chandef)) {
1768 - if (verbose)
1769 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
1770 sdata_info(sdata,
1771 "AP VHT information is invalid, disable VHT\n");
1772 ret = IEEE80211_STA_DISABLE_VHT;
1773 @@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee
1774 }
1775
1776 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
1777 - if (verbose)
1778 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
1779 sdata_info(sdata,
1780 "AP VHT information doesn't match HT, disable VHT\n");
1781 ret = IEEE80211_STA_DISABLE_VHT;
1782 @@ -333,18 +335,27 @@ out:
1783 if (ret & IEEE80211_STA_DISABLE_VHT)
1784 vht_chandef = *chandef;
1785
1786 + /*
1787 + * Ignore the DISABLED flag when we're already connected and only
1788 + * tracking the APs beacon for bandwidth changes - otherwise we
1789 + * might get disconnected here if we connect to an AP, update our
1790 + * regulatory information based on the AP's country IE and the
1791 + * information we have is wrong/outdated and disables the channel
1792 + * that we're actually using for the connection to the AP.
1793 + */
1794 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
1795 - IEEE80211_CHAN_DISABLED)) {
1796 + tracking ? 0 :
1797 + IEEE80211_CHAN_DISABLED)) {
1798 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
1799 ret = IEEE80211_STA_DISABLE_HT |
1800 IEEE80211_STA_DISABLE_VHT;
1801 - goto out;
1802 + break;
1803 }
1804
1805 ret |= chandef_downgrade(chandef);
1806 }
1807
1808 - if (chandef->width != vht_chandef.width && verbose)
1809 + if (chandef->width != vht_chandef.width && !tracking)
1810 sdata_info(sdata,
1811 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
1812
1813 @@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ie
1814
1815 /* calculate new channel (type) based on HT/VHT operation IEs */
1816 flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper,
1817 - vht_oper, &chandef, false);
1818 + vht_oper, &chandef, true);
1819
1820 /*
1821 * Downgrade the new channel if we associated with restricted
1822 @@ -3394,10 +3405,13 @@ static int ieee80211_probe_auth(struct i
1823
1824 if (tx_flags == 0) {
1825 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
1826 - ifmgd->auth_data->timeout_started = true;
1827 + auth_data->timeout_started = true;
1828 run_again(sdata, auth_data->timeout);
1829 } else {
1830 - auth_data->timeout_started = false;
1831 + auth_data->timeout =
1832 + round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
1833 + auth_data->timeout_started = true;
1834 + run_again(sdata, auth_data->timeout);
1835 }
1836
1837 return 0;
1838 @@ -3434,7 +3448,11 @@ static int ieee80211_do_assoc(struct iee
1839 assoc_data->timeout_started = true;
1840 run_again(sdata, assoc_data->timeout);
1841 } else {
1842 - assoc_data->timeout_started = false;
1843 + assoc_data->timeout =
1844 + round_jiffies_up(jiffies +
1845 + IEEE80211_ASSOC_TIMEOUT_LONG);
1846 + assoc_data->timeout_started = true;
1847 + run_again(sdata, assoc_data->timeout);
1848 }
1849
1850 return 0;
1851 @@ -3829,7 +3847,7 @@ static int ieee80211_prep_channel(struct
1852 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
1853 cbss->channel,
1854 ht_oper, vht_oper,
1855 - &chandef, true);
1856 + &chandef, false);
1857
1858 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
1859 local->rx_chains);
1860 --- a/net/wireless/core.c
1861 +++ b/net/wireless/core.c
1862 @@ -772,6 +772,7 @@ void cfg80211_leave(struct cfg80211_regi
1863 cfg80211_leave_mesh(rdev, dev);
1864 break;
1865 case NL80211_IFTYPE_AP:
1866 + case NL80211_IFTYPE_P2P_GO:
1867 cfg80211_stop_ap(rdev, dev);
1868 break;
1869 default:
1870 --- a/drivers/net/wireless/rtlwifi/Kconfig
1871 +++ b/drivers/net/wireless/rtlwifi/Kconfig
1872 @@ -1,29 +1,22 @@
1873 -config RTLWIFI
1874 - tristate "Realtek wireless card support"
1875 +menuconfig RTL_CARDS
1876 + tristate "Realtek rtlwifi family of devices"
1877 depends on m
1878 - depends on MAC80211
1879 - select BACKPORT_FW_LOADER
1880 - ---help---
1881 - This is common code for RTL8192CE/RTL8192CU/RTL8192SE/RTL8723AE
1882 - drivers. This module does nothing by itself - the various front-end
1883 - drivers need to be enabled to support any desired devices.
1884 -
1885 - If you choose to build as a module, it'll be called rtlwifi.
1886 -
1887 -config RTLWIFI_DEBUG
1888 - bool "Debugging output for rtlwifi driver family"
1889 - depends on RTLWIFI
1890 + depends on MAC80211 && (PCI || USB)
1891 default y
1892 ---help---
1893 - To use the module option that sets the dynamic-debugging level for,
1894 - the front-end driver, this parameter must be "Y". For memory-limited
1895 - systems, choose "N". If in doubt, choose "Y".
1896 + This option will enable support for the Realtek mac80211-based
1897 + wireless drivers. Drivers rtl8192ce, rtl8192cu, rtl8192se, rtl8192de,
1898 + rtl8723eu, and rtl8188eu share some common code.
1899 +
1900 +if RTL_CARDS
1901
1902 config RTL8192CE
1903 tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter"
1904 depends on m
1905 - depends on RTLWIFI && PCI
1906 + depends on PCI
1907 select RTL8192C_COMMON
1908 + select RTLWIFI
1909 + select RTLWIFI_PCI
1910 ---help---
1911 This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe
1912 wireless network adapters.
1913 @@ -33,7 +26,9 @@ config RTL8192CE
1914 config RTL8192SE
1915 tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter"
1916 depends on m
1917 - depends on RTLWIFI && PCI
1918 + depends on PCI
1919 + select RTLWIFI
1920 + select RTLWIFI_PCI
1921 ---help---
1922 This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe
1923 wireless network adapters.
1924 @@ -43,7 +38,9 @@ config RTL8192SE
1925 config RTL8192DE
1926 tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter"
1927 depends on m
1928 - depends on RTLWIFI && PCI
1929 + depends on PCI
1930 + select RTLWIFI
1931 + select RTLWIFI_PCI
1932 ---help---
1933 This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe
1934 wireless network adapters.
1935 @@ -53,7 +50,9 @@ config RTL8192DE
1936 config RTL8723AE
1937 tristate "Realtek RTL8723AE PCIe Wireless Network Adapter"
1938 depends on m
1939 - depends on RTLWIFI && PCI
1940 + depends on PCI
1941 + select RTLWIFI
1942 + select RTLWIFI_PCI
1943 ---help---
1944 This is the driver for Realtek RTL8723AE 802.11n PCIe
1945 wireless network adapters.
1946 @@ -63,7 +62,9 @@ config RTL8723AE
1947 config RTL8188EE
1948 tristate "Realtek RTL8188EE Wireless Network Adapter"
1949 depends on m
1950 - depends on RTLWIFI && PCI
1951 + depends on PCI
1952 + select RTLWIFI
1953 + select RTLWIFI_PCI
1954 ---help---
1955 This is the driver for Realtek RTL8188EE 802.11n PCIe
1956 wireless network adapters.
1957 @@ -73,7 +74,9 @@ config RTL8188EE
1958 config RTL8192CU
1959 tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter"
1960 depends on m
1961 - depends on RTLWIFI && USB
1962 + depends on USB
1963 + select RTLWIFI
1964 + select RTLWIFI_USB
1965 select RTL8192C_COMMON
1966 ---help---
1967 This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB
1968 @@ -81,8 +84,32 @@ config RTL8192CU
1969
1970 If you choose to build it as a module, it will be called rtl8192cu
1971
1972 +config RTLWIFI
1973 + tristate "Realtek common driver part"
1974 + depends on m
1975 + select BACKPORT_FW_LOADER
1976 +
1977 +config RTLWIFI_PCI
1978 + depends on m
1979 + tristate
1980 +
1981 +config RTLWIFI_USB
1982 + depends on m
1983 + tristate
1984 +
1985 +config RTLWIFI_DEBUG
1986 + bool "Debugging output for rtlwifi driver family"
1987 + depends on RTLWIFI
1988 + default y
1989 + ---help---
1990 + To use the module option that sets the dynamic-debugging level for,
1991 + the front-end driver, this parameter must be "Y". For memory-limited
1992 + systems, choose "N". If in doubt, choose "Y".
1993 +
1994 config RTL8192C_COMMON
1995 tristate
1996 depends on m
1997 depends on RTL8192CE || RTL8192CU
1998 default m
1999 +
2000 +endif
2001 --- a/drivers/net/wireless/rtlwifi/Makefile
2002 +++ b/drivers/net/wireless/rtlwifi/Makefile
2003 @@ -12,13 +12,11 @@ rtlwifi-objs := \
2004
2005 rtl8192c_common-objs += \
2006
2007 -ifneq ($(CONFIG_PCI),)
2008 -rtlwifi-objs += pci.o
2009 -endif
2010 +obj-$(CPTCFG_RTLWIFI_PCI) += rtl_pci.o
2011 +rtl_pci-objs := pci.o
2012
2013 -ifneq ($(CONFIG_USB),)
2014 -rtlwifi-objs += usb.o
2015 -endif
2016 +obj-$(CPTCFG_RTLWIFI_USB) += rtl_usb.o
2017 +rtl_usb-objs := usb.o
2018
2019 obj-$(CPTCFG_RTL8192C_COMMON) += rtl8192c/
2020 obj-$(CPTCFG_RTL8192CE) += rtl8192ce/
2021 --- a/drivers/net/wireless/rtlwifi/base.c
2022 +++ b/drivers/net/wireless/rtlwifi/base.c
2023 @@ -173,6 +173,7 @@ u8 rtl_tid_to_ac(u8 tid)
2024 {
2025 return tid_to_ac[tid];
2026 }
2027 +EXPORT_SYMBOL_GPL(rtl_tid_to_ac);
2028
2029 static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
2030 struct ieee80211_sta_ht_cap *ht_cap)
2031 @@ -407,6 +408,7 @@ void rtl_deinit_deferred_work(struct iee
2032 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
2033 cancel_delayed_work(&rtlpriv->works.fwevt_wq);
2034 }
2035 +EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
2036
2037 void rtl_init_rfkill(struct ieee80211_hw *hw)
2038 {
2039 @@ -440,6 +442,7 @@ void rtl_deinit_rfkill(struct ieee80211_
2040 {
2041 wiphy_rfkill_stop_polling(hw->wiphy);
2042 }
2043 +EXPORT_SYMBOL_GPL(rtl_deinit_rfkill);
2044
2045 int rtl_init_core(struct ieee80211_hw *hw)
2046 {
2047 @@ -490,10 +493,12 @@ int rtl_init_core(struct ieee80211_hw *h
2048
2049 return 0;
2050 }
2051 +EXPORT_SYMBOL_GPL(rtl_init_core);
2052
2053 void rtl_deinit_core(struct ieee80211_hw *hw)
2054 {
2055 }
2056 +EXPORT_SYMBOL_GPL(rtl_deinit_core);
2057
2058 void rtl_init_rx_config(struct ieee80211_hw *hw)
2059 {
2060 @@ -502,6 +507,7 @@ void rtl_init_rx_config(struct ieee80211
2061
2062 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf));
2063 }
2064 +EXPORT_SYMBOL_GPL(rtl_init_rx_config);
2065
2066 /*********************************************************
2067 *
2068 @@ -880,6 +886,7 @@ bool rtl_tx_mgmt_proc(struct ieee80211_h
2069
2070 return true;
2071 }
2072 +EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc);
2073
2074 void rtl_get_tcb_desc(struct ieee80211_hw *hw,
2075 struct ieee80211_tx_info *info,
2076 @@ -1053,6 +1060,7 @@ bool rtl_action_proc(struct ieee80211_hw
2077
2078 return true;
2079 }
2080 +EXPORT_SYMBOL_GPL(rtl_action_proc);
2081
2082 /*should call before software enc*/
2083 u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
2084 @@ -1126,6 +1134,7 @@ u8 rtl_is_special_data(struct ieee80211_
2085
2086 return false;
2087 }
2088 +EXPORT_SYMBOL_GPL(rtl_is_special_data);
2089
2090 /*********************************************************
2091 *
2092 @@ -1301,6 +1310,7 @@ void rtl_beacon_statistic(struct ieee802
2093
2094 rtlpriv->link_info.bcn_rx_inperiod++;
2095 }
2096 +EXPORT_SYMBOL_GPL(rtl_beacon_statistic);
2097
2098 void rtl_watchdog_wq_callback(void *data)
2099 {
2100 @@ -1794,6 +1804,7 @@ void rtl_recognize_peer(struct ieee80211
2101
2102 mac->vendor = vendor;
2103 }
2104 +EXPORT_SYMBOL_GPL(rtl_recognize_peer);
2105
2106 /*********************************************************
2107 *
2108 @@ -1850,6 +1861,7 @@ struct attribute_group rtl_attribute_gro
2109 .name = "rtlsysfs",
2110 .attrs = rtl_sysfs_entries,
2111 };
2112 +EXPORT_SYMBOL_GPL(rtl_attribute_group);
2113
2114 MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
2115 MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
2116 @@ -1857,7 +1869,8 @@ MODULE_AUTHOR("Larry Finger <Larry.FInge
2117 MODULE_LICENSE("GPL");
2118 MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
2119
2120 -struct rtl_global_var global_var = {};
2121 +struct rtl_global_var rtl_global_var = {};
2122 +EXPORT_SYMBOL_GPL(rtl_global_var);
2123
2124 static int __init rtl_core_module_init(void)
2125 {
2126 @@ -1865,8 +1878,8 @@ static int __init rtl_core_module_init(v
2127 pr_err("Unable to register rtl_rc, use default RC !!\n");
2128
2129 /* init some global vars */
2130 - INIT_LIST_HEAD(&global_var.glb_priv_list);
2131 - spin_lock_init(&global_var.glb_list_lock);
2132 + INIT_LIST_HEAD(&rtl_global_var.glb_priv_list);
2133 + spin_lock_init(&rtl_global_var.glb_list_lock);
2134
2135 return 0;
2136 }
2137 --- a/drivers/net/wireless/rtlwifi/base.h
2138 +++ b/drivers/net/wireless/rtlwifi/base.h
2139 @@ -147,7 +147,7 @@ void rtl_recognize_peer(struct ieee80211
2140 u8 rtl_tid_to_ac(u8 tid);
2141 extern struct attribute_group rtl_attribute_group;
2142 void rtl_easy_concurrent_retrytimer_callback(unsigned long data);
2143 -extern struct rtl_global_var global_var;
2144 +extern struct rtl_global_var rtl_global_var;
2145 int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
2146 bool isht, u8 desc_rate, bool first_ampdu);
2147 bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
2148 --- a/drivers/net/wireless/rtlwifi/core.c
2149 +++ b/drivers/net/wireless/rtlwifi/core.c
2150 @@ -1330,3 +1330,4 @@ const struct ieee80211_ops rtl_ops = {
2151 .rfkill_poll = rtl_op_rfkill_poll,
2152 .flush = rtl_op_flush,
2153 };
2154 +EXPORT_SYMBOL_GPL(rtl_ops);
2155 --- a/drivers/net/wireless/rtlwifi/debug.c
2156 +++ b/drivers/net/wireless/rtlwifi/debug.c
2157 @@ -51,3 +51,4 @@ void rtl_dbgp_flag_init(struct ieee80211
2158
2159 /*Init Debug flag enable condition */
2160 }
2161 +EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
2162 --- a/drivers/net/wireless/rtlwifi/efuse.c
2163 +++ b/drivers/net/wireless/rtlwifi/efuse.c
2164 @@ -229,6 +229,7 @@ void read_efuse_byte(struct ieee80211_hw
2165
2166 *pbuf = (u8) (value32 & 0xff);
2167 }
2168 +EXPORT_SYMBOL_GPL(read_efuse_byte);
2169
2170 void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
2171 {
2172 --- a/drivers/net/wireless/rtlwifi/pci.c
2173 +++ b/drivers/net/wireless/rtlwifi/pci.c
2174 @@ -35,6 +35,13 @@
2175 #include "efuse.h"
2176 #include <linux/export.h>
2177 #include <linux/kmemleak.h>
2178 +#include <linux/module.h>
2179 +
2180 +MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
2181 +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
2182 +MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
2183 +MODULE_LICENSE("GPL");
2184 +MODULE_DESCRIPTION("PCI basic driver for rtlwifi");
2185
2186 static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = {
2187 PCI_VENDOR_ID_INTEL,
2188 @@ -1899,7 +1906,7 @@ int rtl_pci_probe(struct pci_dev *pdev,
2189 rtlpriv->rtlhal.interface = INTF_PCI;
2190 rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data);
2191 rtlpriv->intf_ops = &rtl_pci_ops;
2192 - rtlpriv->glb_var = &global_var;
2193 + rtlpriv->glb_var = &rtl_global_var;
2194
2195 /*
2196 *init dbgp flags before all
2197 --- a/drivers/net/wireless/rtlwifi/ps.c
2198 +++ b/drivers/net/wireless/rtlwifi/ps.c
2199 @@ -269,6 +269,7 @@ void rtl_ips_nic_on(struct ieee80211_hw
2200
2201 spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags);
2202 }
2203 +EXPORT_SYMBOL_GPL(rtl_ips_nic_on);
2204
2205 /*for FW LPS*/
2206
2207 @@ -518,6 +519,7 @@ void rtl_swlps_beacon(struct ieee80211_h
2208 "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed);
2209 }
2210 }
2211 +EXPORT_SYMBOL_GPL(rtl_swlps_beacon);
2212
2213 void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
2214 {
2215 @@ -922,3 +924,4 @@ void rtl_p2p_info(struct ieee80211_hw *h
2216 else
2217 rtl_p2p_noa_ie(hw, data, len - FCS_LEN);
2218 }
2219 +EXPORT_SYMBOL_GPL(rtl_p2p_info);
2220 --- a/drivers/net/wireless/rtlwifi/usb.c
2221 +++ b/drivers/net/wireless/rtlwifi/usb.c
2222 @@ -32,6 +32,13 @@
2223 #include "ps.h"
2224 #include "rtl8192c/fw_common.h"
2225 #include <linux/export.h>
2226 +#include <linux/module.h>
2227 +
2228 +MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
2229 +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
2230 +MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
2231 +MODULE_LICENSE("GPL");
2232 +MODULE_DESCRIPTION("USB basic driver for rtlwifi");
2233
2234 #define REALTEK_USB_VENQT_READ 0xC0
2235 #define REALTEK_USB_VENQT_WRITE 0x40
2236 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2237 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
2238 @@ -137,7 +137,8 @@ int ath_descdma_setup(struct ath_softc *
2239 #define ATH_AGGR_ENCRYPTDELIM 10
2240 /* minimum h/w qdepth to be sustained to maximize aggregation */
2241 #define ATH_AGGR_MIN_QDEPTH 2
2242 -#define ATH_AMPDU_SUBFRAME_DEFAULT 32
2243 +/* minimum h/w qdepth for non-aggregated traffic */
2244 +#define ATH_NON_AGGR_MIN_QDEPTH 8
2245
2246 #define IEEE80211_SEQ_SEQ_SHIFT 4
2247 #define IEEE80211_SEQ_MAX 4096
2248 @@ -174,12 +175,6 @@ int ath_descdma_setup(struct ath_softc *
2249
2250 #define ATH_TX_COMPLETE_POLL_INT 1000
2251
2252 -enum ATH_AGGR_STATUS {
2253 - ATH_AGGR_DONE,
2254 - ATH_AGGR_BAW_CLOSED,
2255 - ATH_AGGR_LIMITED,
2256 -};
2257 -
2258 #define ATH_TXFIFO_DEPTH 8
2259 struct ath_txq {
2260 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */
2261 @@ -212,8 +207,9 @@ struct ath_frame_info {
2262 int framelen;
2263 enum ath9k_key_type keytype;
2264 u8 keyix;
2265 - u8 retries;
2266 u8 rtscts_rate;
2267 + u8 retries : 7;
2268 + u8 baw_tracked : 1;
2269 };
2270
2271 struct ath_buf_state {
2272 @@ -241,6 +237,7 @@ struct ath_buf {
2273 struct ath_atx_tid {
2274 struct list_head list;
2275 struct sk_buff_head buf_q;
2276 + struct sk_buff_head retry_q;
2277 struct ath_node *an;
2278 struct ath_atx_ac *ac;
2279 unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
2280 @@ -268,6 +265,7 @@ struct ath_node {
2281 u8 mpdudensity;
2282
2283 bool sleeping;
2284 + bool no_ps_filter;
2285
2286 #if defined(CPTCFG_MAC80211_DEBUGFS) && defined(CPTCFG_ATH9K_DEBUGFS)
2287 struct dentry *node_stat;
2288 @@ -367,6 +365,7 @@ void ath9k_release_buffered_frames(struc
2289 /********/
2290
2291 struct ath_vif {
2292 + struct ath_node mcast_node;
2293 int av_bslot;
2294 bool primary_sta_vif;
2295 __le64 tsf_adjust; /* TSF adjustment for staggered beacons */
2296 --- a/drivers/net/wireless/ath/ath9k/debug.c
2297 +++ b/drivers/net/wireless/ath/ath9k/debug.c
2298 @@ -607,6 +607,28 @@ static ssize_t read_file_xmit(struct fil
2299 return retval;
2300 }
2301
2302 +static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq,
2303 + char *buf, ssize_t size)
2304 +{
2305 + ssize_t len = 0;
2306 +
2307 + ath_txq_lock(sc, txq);
2308 +
2309 + len += snprintf(buf + len, size - len, "%s: %d ",
2310 + "qnum", txq->axq_qnum);
2311 + len += snprintf(buf + len, size - len, "%s: %2d ",
2312 + "qdepth", txq->axq_depth);
2313 + len += snprintf(buf + len, size - len, "%s: %2d ",
2314 + "ampdu-depth", txq->axq_ampdu_depth);
2315 + len += snprintf(buf + len, size - len, "%s: %3d ",
2316 + "pending", txq->pending_frames);
2317 + len += snprintf(buf + len, size - len, "%s: %d\n",
2318 + "stopped", txq->stopped);
2319 +
2320 + ath_txq_unlock(sc, txq);
2321 + return len;
2322 +}
2323 +
2324 static ssize_t read_file_queues(struct file *file, char __user *user_buf,
2325 size_t count, loff_t *ppos)
2326 {
2327 @@ -624,24 +646,13 @@ static ssize_t read_file_queues(struct f
2328
2329 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
2330 txq = sc->tx.txq_map[i];
2331 - len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
2332 -
2333 - ath_txq_lock(sc, txq);
2334 -
2335 - len += snprintf(buf + len, size - len, "%s: %d ",
2336 - "qnum", txq->axq_qnum);
2337 - len += snprintf(buf + len, size - len, "%s: %2d ",
2338 - "qdepth", txq->axq_depth);
2339 - len += snprintf(buf + len, size - len, "%s: %2d ",
2340 - "ampdu-depth", txq->axq_ampdu_depth);
2341 - len += snprintf(buf + len, size - len, "%s: %3d ",
2342 - "pending", txq->pending_frames);
2343 - len += snprintf(buf + len, size - len, "%s: %d\n",
2344 - "stopped", txq->stopped);
2345 -
2346 - ath_txq_unlock(sc, txq);
2347 + len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
2348 + len += print_queue(sc, txq, buf + len, size - len);
2349 }
2350
2351 + len += snprintf(buf + len, size - len, "(CAB): ");
2352 + len += print_queue(sc, sc->beacon.cabq, buf + len, size - len);
2353 +
2354 if (len > size)
2355 len = size;
2356
2357 --- a/net/mac80211/ibss.c
2358 +++ b/net/mac80211/ibss.c
2359 @@ -792,6 +792,17 @@ static void ieee80211_sta_find_ibss(stru
2360 return;
2361 }
2362
2363 + /* if a fixed bssid and a fixed freq have been provided create the IBSS
2364 + * directly and do not waste time scanning
2365 + */
2366 + if (ifibss->fixed_bssid && ifibss->fixed_channel) {
2367 + sdata_info(sdata, "Created IBSS using preconfigured BSSID %pM\n",
2368 + bssid);
2369 + ieee80211_sta_create_ibss(sdata);
2370 + return;
2371 + }
2372 +
2373 +
2374 ibss_dbg(sdata, "sta_find_ibss: did not try to join ibss\n");
2375
2376 /* Selected IBSS not found in current scan results - try to scan */