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);
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)
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" : ""
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),
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;
57 u32 hw_reconf_flags = 0;
58 @@ -629,30 +628,8 @@ int ieee80211_do_open(struct wireless_de
60 set_bit(SDATA_STATE_RUNNING, &sdata->state);
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,
68 - goto err_del_interface;
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);
75 - res = sta_info_insert(sta);
77 - /* STA has been freed */
78 - goto err_del_interface;
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);
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;
94 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
95 + struct sk_buff *skb)
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;
106 + enum ieee80211_band band;
107 + struct ieee80211_supported_band *sband;
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;
115 + if (stype != IEEE80211_STYPE_BEACON)
118 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
119 + if (baselen > skb->len)
122 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
123 + skb->len - baselen, false, &elems);
125 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
129 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
133 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
141 + sta->last_rx = jiffies;
142 + sta->sta.supp_rates[band] = rates;
144 + if (elems.ht_cap_elem)
145 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
146 + elems.ht_cap_elem, sta);
148 + if (elems.wmm_param)
149 + set_sta_flag(sta, WLAN_STA_WME);
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);
162 static void ieee80211_iface_work(struct work_struct *work)
164 struct ieee80211_sub_if_data *sdata =
165 @@ -1220,6 +1265,9 @@ static void ieee80211_iface_work(struct
167 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
169 + case NL80211_IFTYPE_WDS:
170 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
173 WARN(1, "frame for unexpected interface type");
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
179 sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
180 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
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];
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;
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);
203 - /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
204 - if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
206 + * Drop duplicate 802.11 retransmissions
207 + * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
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] ==
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)
224 @@ -2720,14 +2727,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
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;
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 */
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
245 case NL80211_IFTYPE_WDS:
246 - if (bssid || !ieee80211_is_data(hdr->frame_control))
248 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
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))
255 + } else if (!ieee80211_is_beacon(hdr->frame_control))
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
264 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
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 {
273 WLAN_STA_SHORT_PREAMBLE,
276 WLAN_STA_CLEAR_PS_FILT,
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_
283 static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno)
288 ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno,
289 seqno << IEEE80211_SEQ_SEQ_SHIFT);
291 @@ -146,6 +149,93 @@ static void ath_set_rates(struct ieee802
292 ARRAY_SIZE(bf->rates));
295 +static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
296 + struct sk_buff *skb)
300 + q = skb_get_queue_mapping(skb);
301 + if (txq == sc->tx.uapsdq)
302 + txq = sc->tx.txq_map[q];
304 + if (txq != sc->tx.txq_map[q])
307 + if (WARN_ON(--txq->pending_frames < 0))
308 + txq->pending_frames = 0;
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;
317 +static struct ath_atx_tid *
318 +ath_get_skb_tid(struct ath_softc *sc, struct ath_node *an, struct sk_buff *skb)
320 + struct ieee80211_hdr *hdr;
323 + hdr = (struct ieee80211_hdr *) skb->data;
324 + if (ieee80211_is_data_qos(hdr->frame_control))
325 + tidno = ieee80211_get_qos_ctl(hdr)[0];
327 + tidno &= IEEE80211_QOS_CTL_TID_MASK;
328 + return ATH_AN_2_TID(an, tidno);
331 +static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
333 + return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
336 +static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
338 + struct sk_buff *skb;
340 + skb = __skb_dequeue(&tid->retry_q);
342 + skb = __skb_dequeue(&tid->buf_q);
348 + * ath_tx_tid_change_state:
349 + * - clears a-mpdu flag of previous session
350 + * - force sequence number allocation to fix next BlockAck Window
353 +ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
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;
361 + skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
362 + fi = get_frame_info(skb);
365 + tx_info = IEEE80211_SKB_CB(skb);
366 + tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
371 + bf = ath_tx_setup_buffer(sc, txq, tid, skb);
373 + __skb_unlink(skb, &tid->buf_q);
374 + ath_txq_skb_done(sc, txq, skb);
375 + ieee80211_free_txskb(sc->hw, skb);
382 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
384 struct ath_txq *txq = tid->ac->txq;
385 @@ -160,27 +250,22 @@ static void ath_tx_flush_tid(struct ath_
387 memset(&ts, 0, sizeof(ts));
389 - while ((skb = __skb_dequeue(&tid->buf_q))) {
390 + while ((skb = __skb_dequeue(&tid->retry_q))) {
391 fi = get_frame_info(skb);
395 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
397 - ieee80211_free_txskb(sc->hw, skb);
400 + ath_txq_skb_done(sc, txq, skb);
401 + ieee80211_free_txskb(sc->hw, skb);
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);
412 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
413 - ath_tx_send_normal(sc, txq, NULL, skb);
416 + list_add_tail(&bf->list, &bf_head);
417 + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
421 @@ -209,13 +294,16 @@ static void ath_tx_update_baw(struct ath
424 static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
426 + struct ath_buf *bf)
428 + struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
429 + u16 seqno = bf->bf_state.seqno;
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;
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);
443 - while ((skb = __skb_dequeue(&tid->buf_q))) {
444 + while ((skb = ath_tid_dequeue(tid))) {
445 fi = get_frame_info(skb);
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;
453 bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH);
456 @@ -417,8 +504,7 @@ static void ath_tx_complete_aggr(struct
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;
466 @@ -430,7 +516,7 @@ static void ath_tx_complete_aggr(struct
467 * Only BlockAcks have a TID and therefore normal Acks cannot be
470 - if (isba && tidno != ts->tid)
471 + if (isba && tid->tidno != ts->tid)
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);
479 - if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
480 + if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) ||
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
487 ieee80211_sta_set_buffered(sta, tid->tidno, true);
489 - skb_queue_splice(&bf_pending, &tid->buf_q);
490 + skb_queue_splice_tail(&bf_pending, &tid->retry_q);
492 ath_tx_queue_tid(txq, tid);
494 @@ -618,7 +705,7 @@ static void ath_tx_process_buffer(struct
496 ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok);
498 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !flush)
500 ath_txq_schedule(sc, txq);
503 @@ -792,15 +879,20 @@ static int ath_compute_num_delims(struct
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)
510 + struct ieee80211_tx_info *tx_info;
511 struct ath_frame_info *fi;
517 - skb = skb_peek(&tid->buf_q);
518 + *q = &tid->retry_q;
519 + if (skb_queue_empty(*q))
522 + skb = skb_peek(*q);
526 @@ -810,11 +902,22 @@ ath_tx_get_tid_subframe(struct ath_softc
527 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
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);
537 + bf->bf_next = NULL;
538 + bf->bf_lastbf = bf;
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;
547 bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR;
548 seqno = bf->bf_state.seqno;
550 @@ -828,73 +931,52 @@ ath_tx_get_tid_subframe(struct ath_softc
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);
561 - bf->bf_next = NULL;
562 - bf->bf_lastbf = bf;
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,
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,
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;
592 + bool closed = false;
595 - bf = ath_tx_get_tid_subframe(sc, txq, tid);
597 - status = ATH_AGGR_BAW_CLOSED;
601 + aggr_limit = ath_lookup_rate(sc, bf, tid);
605 fi = get_frame_info(skb);
611 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
612 - aggr_limit = ath_lookup_rate(sc, bf, tid);
616 /* do not exceed aggregation limit */
617 al_delta = ATH_AGGR_DELIM_SZ + fi->framelen;
619 + if (aggr_limit < al + bpad + al_delta ||
620 + ath_lookup_legacy(bf) || nframes >= h_baw)
624 - ((aggr_limit < (al + bpad + al_delta + prev_al)) ||
625 - ath_lookup_legacy(bf))) {
626 - status = ATH_AGGR_LIMITED;
630 - tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
631 - if (nframes && (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE))
634 - /* do not exceed subframe limit */
635 - if (nframes >= min((int)h_baw, ATH_AMPDU_SUBFRAME_DEFAULT)) {
636 - status = ATH_AGGR_LIMITED;
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))
644 /* add padding for previous frame to aggregation length */
645 @@ -912,22 +994,37 @@ static enum ATH_AGGR_STATUS ath_tx_form_
648 /* link buffers of this frame to the aggregate */
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;
655 - __skb_unlink(skb, &tid->buf_q);
656 + __skb_unlink(skb, tid_q);
657 list_add_tail(&bf->list, bf_q);
659 bf_prev->bf_next = bf;
663 - } while (!skb_queue_empty(&tid->buf_q));
664 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
669 + } while (ath_tid_has_buffered(tid));
672 + bf->bf_lastbf = bf_prev;
674 + if (bf == bf_prev) {
675 + al = get_frame_info(bf->bf_mpdu)->framelen;
676 + bf->bf_state.bf_type = BUF_AMPDU;
678 + TX_STAT_INC(txq->axq_qnum, a_aggr);
688 @@ -1188,53 +1285,86 @@ static void ath_tx_fill_desc(struct ath_
692 -static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
693 - struct ath_atx_tid *tid)
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)
699 - struct ath_buf *bf;
700 - enum ATH_AGGR_STATUS status;
701 - struct ieee80211_tx_info *tx_info;
702 - struct list_head bf_q;
704 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
705 + struct sk_buff *skb;
709 - if (skb_queue_empty(&tid->buf_q))
711 + struct ieee80211_tx_info *tx_info;
714 - INIT_LIST_HEAD(&bf_q);
716 + __skb_unlink(skb, tid_q);
717 + list_add_tail(&bf->list, bf_q);
719 + bf_prev->bf_next = bf;
722 - status = ath_tx_form_aggr(sc, txq, tid, &bf_q, &aggr_len);
727 - * no frames picked up to be aggregated;
728 - * block-ack window is not open.
730 - if (list_empty(&bf_q))
731 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
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)
741 - if (tid->ac->clear_ps_filter) {
742 - tid->ac->clear_ps_filter = false;
743 - tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
745 - tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
747 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
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;
756 - TX_STAT_INC(txq->axq_qnum, a_aggr);
758 +static bool ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
759 + struct ath_atx_tid *tid, bool *stop)
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;
766 + bool aggr, last = true;
768 + if (!ath_tid_has_buffered(tid))
771 + INIT_LIST_HEAD(&bf_q);
773 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
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)) {
785 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
787 + last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
790 + ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
792 + if (list_empty(&bf_q))
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;
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);
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;
814 + /* force sequence number allocation for pending frames */
815 + ath_tx_tid_change_state(sc, txtid);
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 *
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);
831 @@ -1302,7 +1436,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
833 ath_txq_lock(sc, txq);
835 - buffered = !skb_queue_empty(&tid->buf_q);
836 + buffered = ath_tid_has_buffered(tid);
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;
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);
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;
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);
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;
866 @@ -1394,15 +1529,15 @@ void ath9k_release_buffered_frames(struc
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);
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;
885 bf_tail->bf_next = bf;
886 @@ -1412,7 +1547,7 @@ void ath9k_release_buffered_frames(struc
888 TX_STAT_INC(txq->axq_qnum, a_queued_hw);
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);
894 ath_txq_unlock_complete(sc, tid->ac->txq);
895 @@ -1665,25 +1800,27 @@ void ath_tx_cleanupq(struct ath_softc *s
897 void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
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;
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))
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)) {
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);
923 while (!list_empty(&ac->tid_q)) {
925 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
927 list_del(&tid->list);
928 @@ -1692,17 +1829,17 @@ void ath_txq_schedule(struct ath_softc *
932 - ath_tx_sched_aggr(sc, txq, tid);
933 + if (ath_tx_sched_aggr(sc, txq, tid, &stop))
937 * add tid to round-robin queue if more frames
938 * are pending for the tid
940 - if (!skb_queue_empty(&tid->buf_q))
941 + if (ath_tid_has_buffered(tid))
942 ath_tx_queue_tid(txq, tid);
944 - if (tid == last_tid ||
945 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
946 + if (stop || tid == last_tid)
950 @@ -1711,9 +1848,17 @@ void ath_txq_schedule(struct ath_softc *
951 list_add_tail(&ac->list, &txq->axq_acq);
954 - if (ac == last_ac ||
955 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
959 + if (ac == last_ac) {
964 + last_ac = list_entry(txq->axq_acq.prev,
965 + struct ath_atx_ac, list);
970 @@ -1792,57 +1937,6 @@ static void ath_tx_txqaddbuf(struct ath_
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)
978 - struct ath_frame_info *fi = get_frame_info(skb);
979 - struct list_head bf_head;
980 - struct ath_buf *bf;
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
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) {
994 - * Add this frame to software queue for scheduling later
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);
1004 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1006 - ieee80211_free_txskb(sc->hw, skb);
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);
1015 - /* Add sub-frame to BAW */
1016 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
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);
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)
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 */
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;
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;
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);
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);
1069 WARN_ON(tid->ac->txq != txctl->txq);
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;
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.
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);
1088 + ath_txq_schedule(sc, txq);
1092 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1094 + ath_txq_skb_done(sc, txq, skb);
1096 dev_kfree_skb_any(skb);
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;
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);
1110 __skb_queue_tail(&txq->complete_q, skb);
1112 - q = skb_get_queue_mapping(skb);
1113 - if (txq == sc->tx.uapsdq)
1114 - txq = sc->tx.txq_map[q];
1116 - if (txq == sc->tx.txq_map[q]) {
1117 - if (WARN_ON(--txq->pending_frames < 0))
1118 - txq->pending_frames = 0;
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;
1126 + ath_txq_skb_done(sc, txq, skb);
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
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);
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];
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++) {
1152 + ac->clear_ps_filter = true;
1153 ac->txq = sc->tx.txq_map[acno];
1154 INIT_LIST_HEAD(&ac->tid_q);
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;
1165 mutex_lock(&sc->mutex);
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);
1174 + an->no_ps_filter = true;
1175 + ath_tx_node_init(sc, an);
1177 mutex_unlock(&sc->mutex);
1180 @@ -1016,6 +1024,7 @@ static void ath9k_remove_interface(struc
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;
1186 ath_dbg(common, CONFIG, "Detach Interface\n");
1188 @@ -1030,6 +1039,8 @@ static void ath9k_remove_interface(struc
1189 ath9k_calculate_summary_state(hw, NULL);
1190 ath9k_ps_restore(sc);
1192 + ath_tx_node_cleanup(sc, &avp->mcast_node);
1194 mutex_unlock(&sc->mutex);
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;
1201 - if (!sta->ht_cap.ht_supported)
1205 case STA_NOTIFY_SLEEP:
1206 an->sleeping = true;
1207 @@ -2094,7 +2102,7 @@ static void ath9k_wow_add_pattern(struct
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;
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
1222 -mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
1224 +mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
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
1234 -wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
1235 +wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
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()
1243 -static int wl1271_convert_wowlan_pattern_to_rx_filter(
1244 - struct cfg80211_wowlan_trig_pkt_pattern *p,
1245 - struct wl12xx_rx_filter **f)
1247 +wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
1248 + struct wl12xx_rx_filter **f)
1251 struct wl12xx_rx_filter *filter;
1252 @@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
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;
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 {
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!
1276 -struct cfg80211_wowlan_trig_pkt_pattern {
1277 +struct cfg80211_pkt_pattern {
1281 @@ -1770,7 +1770,7 @@ struct cfg80211_wowlan {
1282 bool any, disconnect, magic_pkt, gtk_rekey_failure,
1283 eap_identity_req, four_way_handshake,
1285 - struct cfg80211_wowlan_trig_pkt_pattern *patterns;
1286 + struct cfg80211_pkt_pattern *patterns;
1287 struct cfg80211_wowlan_tcp *tcp;
1290 --- a/include/uapi/linux/nl80211.h
1291 +++ b/include/uapi/linux/nl80211.h
1292 @@ -3060,11 +3060,11 @@ enum nl80211_tx_power_setting {
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
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,
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,
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.
1347 -struct nl80211_wowlan_pattern_support {
1348 +struct nl80211_pattern_support {
1350 __u32 min_pattern_len;
1351 __u32 max_pattern_len;
1352 __u32 max_pkt_offset;
1353 } __attribute__((packed));
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
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.
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.
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;
1391 + /* For non-assoc STA, prevent buffering or frame transmission */
1392 + if (sta->sta_state < IEEE80211_STA_ASSOC)
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
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;
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;
1415 @@ -974,7 +976,7 @@ static int nl80211_send_wowlan(struct sk
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_
1427 state = kzalloc(sizeof(*state), GFP_KERNEL);
1433 state->filter_wiphy = -1;
1434 ret = nl80211_dump_wiphy_parse(skb, cb, state);
1436 @@ -6615,12 +6619,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
1438 void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
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];
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);
1450 EXPORT_SYMBOL(cfg80211_testmode_event);
1452 @@ -7593,12 +7599,11 @@ static int nl80211_send_wowlan_patterns(
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))
1468 nla_nest_end(msg, nl_pat);
1469 @@ -7939,7 +7944,7 @@ static int nl80211_set_wowlan(struct sk_
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];
1476 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
1478 @@ -7958,26 +7963,25 @@ static int nl80211_set_wowlan(struct sk_
1480 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
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);
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])
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]) !=
1497 + if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
1499 if (pat_len > wowlan->pattern_max_len ||
1500 pat_len < wowlan->pattern_min_len)
1503 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
1504 + if (!pat_tb[NL80211_PKTPAT_OFFSET])
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)
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]),
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]),
1527 @@ -10066,7 +10070,8 @@ void cfg80211_mgmt_tx_status(struct wire
1529 genlmsg_end(msg, hdr);
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);
1537 --- a/net/wireless/reg.c
1538 +++ b/net/wireless/reg.c
1539 @@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev
1541 void wiphy_regulatory_register(struct wiphy *wiphy)
1543 + struct regulatory_request *lr;
1545 if (!reg_dev_ignore_cell_hint(wiphy))
1546 reg_num_devs_support_basehint++;
1548 - wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
1549 + lr = get_last_request();
1550 + wiphy_update_regulatory(wiphy, lr->initiator);
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)
1557 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
1559 restore_regulatory_settings(true);
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,
1577 @@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct
1579 params->key, params->key_len,
1580 params->key_idx, NULL, 0);
1581 + case CFG80211_CONN_AUTH_FAILED:
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,
1590 + case CFG80211_CONN_ASSOC_FAILED:
1591 + cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
1593 + WLAN_REASON_DEAUTH_LEAVING, false);
1595 case CFG80211_CONN_DEAUTH:
1596 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
1598 WLAN_REASON_DEAUTH_LEAVING, false);
1599 + /* free directly, disconnected event already sent */
1600 + cfg80211_sme_free(wdev);
1604 @@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
1608 - wdev->conn->state = CFG80211_CONN_DEAUTH;
1609 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
1610 schedule_work(&rdev->conn_work);
1613 @@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
1615 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
1617 - cfg80211_sme_free(wdev);
1618 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
1623 + wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
1624 + schedule_work(&rdev->conn_work);
1627 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
1628 @@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
1630 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
1632 - cfg80211_sme_disassoc(wdev);
1633 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
1638 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
1639 + schedule_work(&rdev->conn_work);
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;
1649 - bool prev_sample = mi->prev_sample;
1654 @@ -314,6 +314,7 @@ minstrel_get_rate(void *priv, struct iee
1655 (mi->sample_count + mi->sample_deferred / 2);
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))
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);
1668 -void rt2x00queue_pause_queue(struct data_queue *queue)
1669 +void rt2x00queue_pause_queue_nocheck(struct data_queue *queue)
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))
1676 switch (queue->qid) {
1679 @@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data
1683 +void rt2x00queue_pause_queue(struct data_queue *queue)
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))
1690 + rt2x00queue_pause_queue_nocheck(queue);
1692 EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
1694 void rt2x00queue_unpause_queue(struct data_queue *queue)
1695 @@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_
1699 - rt2x00queue_pause_queue(queue);
1700 + rt2x00queue_pause_queue_nocheck(queue);
1702 queue->rt2x00dev->ops->lib->stop_queue(queue);
1704 --- a/net/mac80211/mlme.c
1705 +++ b/net/mac80211/mlme.c
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
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)
1726 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1727 struct cfg80211_chan_def vht_chandef;
1730 @@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee
1731 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
1733 /* check that channel matches the right operating channel */
1734 - if (channel->center_freq != ht_cfreq) {
1735 + if (!tracking && channel->center_freq != ht_cfreq) {
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
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);
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;
1755 @@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee
1760 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
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
1767 if (!cfg80211_chandef_valid(&vht_chandef)) {
1769 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
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
1776 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
1778 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
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;
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.
1794 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
1795 - IEEE80211_CHAN_DISABLED)) {
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;
1805 ret |= chandef_downgrade(chandef);
1808 - if (chandef->width != vht_chandef.width && verbose)
1809 + if (chandef->width != vht_chandef.width && !tracking)
1811 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
1813 @@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ie
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);
1821 * Downgrade the new channel if we associated with restricted
1822 @@ -3394,10 +3405,13 @@ static int ieee80211_probe_auth(struct i
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);
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);
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);
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);
1851 @@ -3829,7 +3847,7 @@ static int ieee80211_prep_channel(struct
1852 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
1858 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
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);
1865 case NL80211_IFTYPE_AP:
1866 + case NL80211_IFTYPE_P2P_GO:
1867 cfg80211_stop_ap(rdev, dev);
1870 --- a/drivers/net/wireless/rtlwifi/Kconfig
1871 +++ b/drivers/net/wireless/rtlwifi/Kconfig
1874 - tristate "Realtek wireless card support"
1875 +menuconfig RTL_CARDS
1876 + tristate "Realtek rtlwifi family of devices"
1878 - depends on MAC80211
1879 - select BACKPORT_FW_LOADER
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.
1885 - If you choose to build as a module, it'll be called rtlwifi.
1887 -config RTLWIFI_DEBUG
1888 - bool "Debugging output for rtlwifi driver family"
1889 - depends on RTLWIFI
1890 + depends on MAC80211 && (PCI || USB)
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.
1903 tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter"
1905 - depends on RTLWIFI && PCI
1907 select RTL8192C_COMMON
1909 + select RTLWIFI_PCI
1911 This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe
1912 wireless network adapters.
1913 @@ -33,7 +26,9 @@ config RTL8192CE
1915 tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter"
1917 - depends on RTLWIFI && PCI
1920 + select RTLWIFI_PCI
1922 This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe
1923 wireless network adapters.
1924 @@ -43,7 +38,9 @@ config RTL8192SE
1926 tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter"
1928 - depends on RTLWIFI && PCI
1931 + select RTLWIFI_PCI
1933 This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe
1934 wireless network adapters.
1935 @@ -53,7 +50,9 @@ config RTL8192DE
1937 tristate "Realtek RTL8723AE PCIe Wireless Network Adapter"
1939 - depends on RTLWIFI && PCI
1942 + select RTLWIFI_PCI
1944 This is the driver for Realtek RTL8723AE 802.11n PCIe
1945 wireless network adapters.
1946 @@ -63,7 +62,9 @@ config RTL8723AE
1948 tristate "Realtek RTL8188EE Wireless Network Adapter"
1950 - depends on RTLWIFI && PCI
1953 + select RTLWIFI_PCI
1955 This is the driver for Realtek RTL8188EE 802.11n PCIe
1956 wireless network adapters.
1957 @@ -73,7 +74,9 @@ config RTL8188EE
1959 tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter"
1961 - depends on RTLWIFI && USB
1964 + select RTLWIFI_USB
1965 select RTL8192C_COMMON
1967 This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB
1968 @@ -81,8 +84,32 @@ config RTL8192CU
1970 If you choose to build it as a module, it will be called rtl8192cu
1973 + tristate "Realtek common driver part"
1975 + select BACKPORT_FW_LOADER
1985 +config RTLWIFI_DEBUG
1986 + bool "Debugging output for rtlwifi driver family"
1987 + depends on RTLWIFI
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".
1994 config RTL8192C_COMMON
1997 depends on RTL8192CE || RTL8192CU
2001 --- a/drivers/net/wireless/rtlwifi/Makefile
2002 +++ b/drivers/net/wireless/rtlwifi/Makefile
2003 @@ -12,13 +12,11 @@ rtlwifi-objs := \
2005 rtl8192c_common-objs += \
2007 -ifneq ($(CONFIG_PCI),)
2008 -rtlwifi-objs += pci.o
2010 +obj-$(CPTCFG_RTLWIFI_PCI) += rtl_pci.o
2011 +rtl_pci-objs := pci.o
2013 -ifneq ($(CONFIG_USB),)
2014 -rtlwifi-objs += usb.o
2016 +obj-$(CPTCFG_RTLWIFI_USB) += rtl_usb.o
2017 +rtl_usb-objs := usb.o
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)
2025 return tid_to_ac[tid];
2027 +EXPORT_SYMBOL_GPL(rtl_tid_to_ac);
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);
2035 +EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
2037 void rtl_init_rfkill(struct ieee80211_hw *hw)
2039 @@ -440,6 +442,7 @@ void rtl_deinit_rfkill(struct ieee80211_
2041 wiphy_rfkill_stop_polling(hw->wiphy);
2043 +EXPORT_SYMBOL_GPL(rtl_deinit_rfkill);
2045 int rtl_init_core(struct ieee80211_hw *hw)
2047 @@ -490,10 +493,12 @@ int rtl_init_core(struct ieee80211_hw *h
2051 +EXPORT_SYMBOL_GPL(rtl_init_core);
2053 void rtl_deinit_core(struct ieee80211_hw *hw)
2056 +EXPORT_SYMBOL_GPL(rtl_deinit_core);
2058 void rtl_init_rx_config(struct ieee80211_hw *hw)
2060 @@ -502,6 +507,7 @@ void rtl_init_rx_config(struct ieee80211
2062 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf));
2064 +EXPORT_SYMBOL_GPL(rtl_init_rx_config);
2066 /*********************************************************
2068 @@ -880,6 +886,7 @@ bool rtl_tx_mgmt_proc(struct ieee80211_h
2072 +EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc);
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
2080 +EXPORT_SYMBOL_GPL(rtl_action_proc);
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_
2088 +EXPORT_SYMBOL_GPL(rtl_is_special_data);
2090 /*********************************************************
2092 @@ -1301,6 +1310,7 @@ void rtl_beacon_statistic(struct ieee802
2094 rtlpriv->link_info.bcn_rx_inperiod++;
2096 +EXPORT_SYMBOL_GPL(rtl_beacon_statistic);
2098 void rtl_watchdog_wq_callback(void *data)
2100 @@ -1794,6 +1804,7 @@ void rtl_recognize_peer(struct ieee80211
2102 mac->vendor = vendor;
2104 +EXPORT_SYMBOL_GPL(rtl_recognize_peer);
2106 /*********************************************************
2108 @@ -1850,6 +1861,7 @@ struct attribute_group rtl_attribute_gro
2110 .attrs = rtl_sysfs_entries,
2112 +EXPORT_SYMBOL_GPL(rtl_attribute_group);
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");
2120 -struct rtl_global_var global_var = {};
2121 +struct rtl_global_var rtl_global_var = {};
2122 +EXPORT_SYMBOL_GPL(rtl_global_var);
2124 static int __init rtl_core_module_init(void)
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");
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);
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,
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
2159 /*Init Debug flag enable condition */
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
2166 *pbuf = (u8) (value32 & 0xff);
2168 +EXPORT_SYMBOL_GPL(read_efuse_byte);
2170 void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
2172 --- a/drivers/net/wireless/rtlwifi/pci.c
2173 +++ b/drivers/net/wireless/rtlwifi/pci.c
2176 #include <linux/export.h>
2177 #include <linux/kmemleak.h>
2178 +#include <linux/module.h>
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");
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;
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
2201 spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags);
2203 +EXPORT_SYMBOL_GPL(rtl_ips_nic_on);
2207 @@ -518,6 +519,7 @@ void rtl_swlps_beacon(struct ieee80211_h
2208 "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed);
2211 +EXPORT_SYMBOL_GPL(rtl_swlps_beacon);
2213 void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
2215 @@ -922,3 +924,4 @@ void rtl_p2p_info(struct ieee80211_hw *h
2217 rtl_p2p_noa_ie(hw, data, len - FCS_LEN);
2219 +EXPORT_SYMBOL_GPL(rtl_p2p_info);
2220 --- a/drivers/net/wireless/rtlwifi/usb.c
2221 +++ b/drivers/net/wireless/rtlwifi/usb.c
2224 #include "rtl8192c/fw_common.h"
2225 #include <linux/export.h>
2226 +#include <linux/module.h>
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");
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
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 *
2250 #define ATH_TX_COMPLETE_POLL_INT 1000
2252 -enum ATH_AGGR_STATUS {
2254 - ATH_AGGR_BAW_CLOSED,
2258 #define ATH_TXFIFO_DEPTH 8
2260 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */
2261 @@ -212,8 +207,9 @@ struct ath_frame_info {
2263 enum ath9k_key_type keytype;
2268 + u8 baw_tracked : 1;
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 {
2284 + bool no_ps_filter;
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
2292 + struct ath_node mcast_node;
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
2302 +static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq,
2303 + char *buf, ssize_t size)
2307 + ath_txq_lock(sc, txq);
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);
2320 + ath_txq_unlock(sc, txq);
2324 static ssize_t read_file_queues(struct file *file, char __user *user_buf,
2325 size_t count, loff_t *ppos)
2327 @@ -624,24 +646,13 @@ static ssize_t read_file_queues(struct f
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]);
2333 - ath_txq_lock(sc, txq);
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);
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);
2351 + len += snprintf(buf + len, size - len, "(CAB): ");
2352 + len += print_queue(sc, sc->beacon.cabq, buf + len, size - len);