ath9k: merge a fix for tx processing issues with aggregation
[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 @@ -455,6 +455,15 @@ void ieee80211_sta_debugfs_add(struct st
49 DEBUGFS_ADD_COUNTER(tx_retry_count, tx_retry_count);
50 DEBUGFS_ADD_COUNTER(wep_weak_iv_count, wep_weak_iv_count);
51
52 + if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
53 + debugfs_create_x32("driver_buffered_tids", 0400,
54 + sta->debugfs.dir,
55 + (u32 *)&sta->driver_buffered_tids);
56 + else
57 + debugfs_create_x64("driver_buffered_tids", 0400,
58 + sta->debugfs.dir,
59 + (u64 *)&sta->driver_buffered_tids);
60 +
61 drv_sta_add_debugfs(local, sdata, &sta->sta, sta->debugfs.dir);
62 }
63
64 --- a/net/mac80211/iface.c
65 +++ b/net/mac80211/iface.c
66 @@ -274,6 +274,12 @@ static int ieee80211_check_concurrent_if
67 if (iftype == NL80211_IFTYPE_ADHOC &&
68 nsdata->vif.type == NL80211_IFTYPE_ADHOC)
69 return -EBUSY;
70 + /*
71 + * will not add another interface while any channel
72 + * switch is active.
73 + */
74 + if (nsdata->vif.csa_active)
75 + return -EBUSY;
76
77 /*
78 * The remaining checks are only performed for interfaces
79 @@ -463,7 +469,6 @@ int ieee80211_do_open(struct wireless_de
80 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
81 struct net_device *dev = wdev->netdev;
82 struct ieee80211_local *local = sdata->local;
83 - struct sta_info *sta;
84 u32 changed = 0;
85 int res;
86 u32 hw_reconf_flags = 0;
87 @@ -629,30 +634,8 @@ int ieee80211_do_open(struct wireless_de
88
89 set_bit(SDATA_STATE_RUNNING, &sdata->state);
90
91 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
92 - /* Create STA entry for the WDS peer */
93 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
94 - GFP_KERNEL);
95 - if (!sta) {
96 - res = -ENOMEM;
97 - goto err_del_interface;
98 - }
99 -
100 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
101 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
102 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
103 -
104 - res = sta_info_insert(sta);
105 - if (res) {
106 - /* STA has been freed */
107 - goto err_del_interface;
108 - }
109 -
110 - rate_control_rate_init(sta);
111 - netif_carrier_on(dev);
112 - } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
113 + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
114 rcu_assign_pointer(local->p2p_sdata, sdata);
115 - }
116
117 /*
118 * set_multicast_list will be invoked by the networking core
119 @@ -809,6 +792,8 @@ static void ieee80211_do_stop(struct iee
120 cancel_work_sync(&local->dynamic_ps_enable_work);
121
122 cancel_work_sync(&sdata->recalc_smps);
123 + sdata->vif.csa_active = false;
124 + cancel_work_sync(&sdata->csa_finalize_work);
125
126 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
127
128 @@ -1116,6 +1101,74 @@ static void ieee80211_if_setup(struct ne
129 dev->destructor = free_netdev;
130 }
131
132 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
133 + struct sk_buff *skb)
134 +{
135 + struct ieee80211_local *local = sdata->local;
136 + struct ieee80211_rx_status *rx_status;
137 + struct ieee802_11_elems elems;
138 + struct ieee80211_mgmt *mgmt;
139 + struct sta_info *sta;
140 + size_t baselen;
141 + u32 rates = 0;
142 + u16 stype;
143 + bool new = false;
144 + enum ieee80211_band band;
145 + struct ieee80211_supported_band *sband;
146 +
147 + rx_status = IEEE80211_SKB_RXCB(skb);
148 + band = rx_status->band;
149 + sband = local->hw.wiphy->bands[band];
150 + mgmt = (struct ieee80211_mgmt *) skb->data;
151 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
152 +
153 + if (stype != IEEE80211_STYPE_BEACON)
154 + return;
155 +
156 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
157 + if (baselen > skb->len)
158 + return;
159 +
160 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
161 + skb->len - baselen, false, &elems);
162 +
163 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
164 +
165 + rcu_read_lock();
166 +
167 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
168 +
169 + if (!sta) {
170 + rcu_read_unlock();
171 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
172 + GFP_KERNEL);
173 + if (!sta)
174 + return;
175 +
176 + new = true;
177 + }
178 +
179 + sta->last_rx = jiffies;
180 + sta->sta.supp_rates[band] = rates;
181 +
182 + if (elems.ht_cap_elem)
183 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
184 + elems.ht_cap_elem, sta);
185 +
186 + if (elems.wmm_param)
187 + set_sta_flag(sta, WLAN_STA_WME);
188 +
189 + if (new) {
190 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
191 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
192 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
193 + rate_control_rate_init(sta);
194 + sta_info_insert_rcu(sta);
195 + }
196 +
197 + rcu_read_unlock();
198 +}
199 +
200 static void ieee80211_iface_work(struct work_struct *work)
201 {
202 struct ieee80211_sub_if_data *sdata =
203 @@ -1220,6 +1273,9 @@ static void ieee80211_iface_work(struct
204 break;
205 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
206 break;
207 + case NL80211_IFTYPE_WDS:
208 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
209 + break;
210 default:
211 WARN(1, "frame for unexpected interface type");
212 break;
213 @@ -1282,6 +1338,7 @@ static void ieee80211_setup_sdata(struct
214 skb_queue_head_init(&sdata->skb_queue);
215 INIT_WORK(&sdata->work, ieee80211_iface_work);
216 INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work);
217 + INIT_WORK(&sdata->csa_finalize_work, ieee80211_csa_finalize_work);
218
219 switch (type) {
220 case NL80211_IFTYPE_P2P_GO:
221 --- a/net/mac80211/rc80211_minstrel_ht.c
222 +++ b/net/mac80211/rc80211_minstrel_ht.c
223 @@ -365,6 +365,14 @@ minstrel_ht_update_stats(struct minstrel
224 }
225 }
226
227 +#ifdef CPTCFG_MAC80211_DEBUGFS
228 + /* use fixed index if set */
229 + if (mp->fixed_rate_idx != -1) {
230 + mi->max_tp_rate = mp->fixed_rate_idx;
231 + mi->max_tp_rate2 = mp->fixed_rate_idx;
232 + mi->max_prob_rate = mp->fixed_rate_idx;
233 + }
234 +#endif
235
236 mi->stats_update = jiffies;
237 }
238 @@ -774,6 +782,11 @@ minstrel_ht_get_rate(void *priv, struct
239 info->flags |= mi->tx_flags;
240 minstrel_ht_check_cck_shortpreamble(mp, mi, txrc->short_preamble);
241
242 +#ifdef CPTCFG_MAC80211_DEBUGFS
243 + if (mp->fixed_rate_idx != -1)
244 + return;
245 +#endif
246 +
247 /* Don't use EAPOL frames for sampling on non-mrr hw */
248 if (mp->hw->max_rates == 1 &&
249 txrc->skb->protocol == cpu_to_be16(ETH_P_PAE))
250 @@ -781,16 +794,6 @@ minstrel_ht_get_rate(void *priv, struct
251 else
252 sample_idx = minstrel_get_sample_rate(mp, mi);
253
254 -#ifdef CPTCFG_MAC80211_DEBUGFS
255 - /* use fixed index if set */
256 - if (mp->fixed_rate_idx != -1) {
257 - mi->max_tp_rate = mp->fixed_rate_idx;
258 - mi->max_tp_rate2 = mp->fixed_rate_idx;
259 - mi->max_prob_rate = mp->fixed_rate_idx;
260 - sample_idx = -1;
261 - }
262 -#endif
263 -
264 mi->total_packets++;
265
266 /* wraparound */
267 @@ -804,10 +807,18 @@ minstrel_ht_get_rate(void *priv, struct
268
269 sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
270 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
271 + rate->count = 1;
272 +
273 + if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
274 + int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
275 + rate->idx = mp->cck_rates[idx];
276 + rate->flags = 0;
277 + return;
278 + }
279 +
280 rate->idx = sample_idx % MCS_GROUP_RATES +
281 (sample_group->streams - 1) * MCS_GROUP_RATES;
282 rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
283 - rate->count = 1;
284 }
285
286 static void
287 @@ -820,6 +831,9 @@ minstrel_ht_update_cck(struct minstrel_p
288 if (sband->band != IEEE80211_BAND_2GHZ)
289 return;
290
291 + if (!(mp->hw->flags & IEEE80211_HW_SUPPORTS_HT_CCK_RATES))
292 + return;
293 +
294 mi->cck_supported = 0;
295 mi->cck_supported_short = 0;
296 for (i = 0; i < 4; i++) {
297 --- a/net/mac80211/rx.c
298 +++ b/net/mac80211/rx.c
299 @@ -936,8 +936,14 @@ ieee80211_rx_h_check(struct ieee80211_rx
300 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
301 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
302
303 - /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
304 - if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
305 + /*
306 + * Drop duplicate 802.11 retransmissions
307 + * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
308 + */
309 + if (rx->skb->len >= 24 && rx->sta &&
310 + !ieee80211_is_ctl(hdr->frame_control) &&
311 + !ieee80211_is_qos_nullfunc(hdr->frame_control) &&
312 + !is_multicast_ether_addr(hdr->addr1)) {
313 if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
314 rx->sta->last_seq_ctrl[rx->seqno_idx] ==
315 hdr->seq_ctrl)) {
316 @@ -2369,6 +2375,7 @@ ieee80211_rx_h_action(struct ieee80211_r
317 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
318 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
319 sdata->vif.type != NL80211_IFTYPE_AP &&
320 + sdata->vif.type != NL80211_IFTYPE_WDS &&
321 sdata->vif.type != NL80211_IFTYPE_ADHOC)
322 break;
323
324 @@ -2720,14 +2727,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
325
326 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
327 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
328 - sdata->vif.type != NL80211_IFTYPE_STATION)
329 + sdata->vif.type != NL80211_IFTYPE_STATION &&
330 + sdata->vif.type != NL80211_IFTYPE_WDS)
331 return RX_DROP_MONITOR;
332
333 switch (stype) {
334 case cpu_to_le16(IEEE80211_STYPE_AUTH):
335 case cpu_to_le16(IEEE80211_STYPE_BEACON):
336 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
337 - /* process for all: mesh, mlme, ibss */
338 + /* process for all: mesh, mlme, ibss, wds */
339 break;
340 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
341 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
342 @@ -3059,10 +3067,16 @@ static int prepare_for_handlers(struct i
343 }
344 break;
345 case NL80211_IFTYPE_WDS:
346 - if (bssid || !ieee80211_is_data(hdr->frame_control))
347 - return 0;
348 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
349 return 0;
350 +
351 + if (ieee80211_is_data(hdr->frame_control) ||
352 + ieee80211_is_action(hdr->frame_control)) {
353 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
354 + return 0;
355 + } else if (!ieee80211_is_beacon(hdr->frame_control))
356 + return 0;
357 +
358 break;
359 case NL80211_IFTYPE_P2P_DEVICE:
360 if (!ieee80211_is_public_action(hdr, skb->len) &&
361 --- a/net/mac80211/sta_info.h
362 +++ b/net/mac80211/sta_info.h
363 @@ -32,7 +32,6 @@
364 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
365 * frames.
366 * @WLAN_STA_WME: Station is a QoS-STA.
367 - * @WLAN_STA_WDS: Station is one of our WDS peers.
368 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
369 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
370 * frame to this station is transmitted.
371 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
372 WLAN_STA_AUTHORIZED,
373 WLAN_STA_SHORT_PREAMBLE,
374 WLAN_STA_WME,
375 - WLAN_STA_WDS,
376 WLAN_STA_CLEAR_PS_FILT,
377 WLAN_STA_MFP,
378 WLAN_STA_BLOCK_BA,
379 --- a/drivers/net/wireless/ath/ath9k/xmit.c
380 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
381 @@ -135,6 +135,9 @@ static struct ath_frame_info *get_frame_
382
383 static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno)
384 {
385 + if (!tid->an->sta)
386 + return;
387 +
388 ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno,
389 seqno << IEEE80211_SEQ_SEQ_SHIFT);
390 }
391 @@ -146,6 +149,93 @@ static void ath_set_rates(struct ieee802
392 ARRAY_SIZE(bf->rates));
393 }
394
395 +static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
396 + struct sk_buff *skb)
397 +{
398 + int q;
399 +
400 + q = skb_get_queue_mapping(skb);
401 + if (txq == sc->tx.uapsdq)
402 + txq = sc->tx.txq_map[q];
403 +
404 + if (txq != sc->tx.txq_map[q])
405 + return;
406 +
407 + if (WARN_ON(--txq->pending_frames < 0))
408 + txq->pending_frames = 0;
409 +
410 + if (txq->stopped &&
411 + txq->pending_frames < sc->tx.txq_max_pending[q]) {
412 + ieee80211_wake_queue(sc->hw, q);
413 + txq->stopped = false;
414 + }
415 +}
416 +
417 +static struct ath_atx_tid *
418 +ath_get_skb_tid(struct ath_softc *sc, struct ath_node *an, struct sk_buff *skb)
419 +{
420 + struct ieee80211_hdr *hdr;
421 + u8 tidno = 0;
422 +
423 + hdr = (struct ieee80211_hdr *) skb->data;
424 + if (ieee80211_is_data_qos(hdr->frame_control))
425 + tidno = ieee80211_get_qos_ctl(hdr)[0];
426 +
427 + tidno &= IEEE80211_QOS_CTL_TID_MASK;
428 + return ATH_AN_2_TID(an, tidno);
429 +}
430 +
431 +static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
432 +{
433 + return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
434 +}
435 +
436 +static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
437 +{
438 + struct sk_buff *skb;
439 +
440 + skb = __skb_dequeue(&tid->retry_q);
441 + if (!skb)
442 + skb = __skb_dequeue(&tid->buf_q);
443 +
444 + return skb;
445 +}
446 +
447 +/*
448 + * ath_tx_tid_change_state:
449 + * - clears a-mpdu flag of previous session
450 + * - force sequence number allocation to fix next BlockAck Window
451 + */
452 +static void
453 +ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
454 +{
455 + struct ath_txq *txq = tid->ac->txq;
456 + struct ieee80211_tx_info *tx_info;
457 + struct sk_buff *skb, *tskb;
458 + struct ath_buf *bf;
459 + struct ath_frame_info *fi;
460 +
461 + skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
462 + fi = get_frame_info(skb);
463 + bf = fi->bf;
464 +
465 + tx_info = IEEE80211_SKB_CB(skb);
466 + tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
467 +
468 + if (bf)
469 + continue;
470 +
471 + bf = ath_tx_setup_buffer(sc, txq, tid, skb);
472 + if (!bf) {
473 + __skb_unlink(skb, &tid->buf_q);
474 + ath_txq_skb_done(sc, txq, skb);
475 + ieee80211_free_txskb(sc->hw, skb);
476 + continue;
477 + }
478 + }
479 +
480 +}
481 +
482 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
483 {
484 struct ath_txq *txq = tid->ac->txq;
485 @@ -160,27 +250,22 @@ static void ath_tx_flush_tid(struct ath_
486
487 memset(&ts, 0, sizeof(ts));
488
489 - while ((skb = __skb_dequeue(&tid->buf_q))) {
490 + while ((skb = __skb_dequeue(&tid->retry_q))) {
491 fi = get_frame_info(skb);
492 bf = fi->bf;
493 -
494 if (!bf) {
495 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
496 - if (!bf) {
497 - ieee80211_free_txskb(sc->hw, skb);
498 - continue;
499 - }
500 + ath_txq_skb_done(sc, txq, skb);
501 + ieee80211_free_txskb(sc->hw, skb);
502 + continue;
503 }
504
505 - if (fi->retries) {
506 - list_add_tail(&bf->list, &bf_head);
507 + if (fi->baw_tracked) {
508 ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
509 - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
510 sendbar = true;
511 - } else {
512 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
513 - ath_tx_send_normal(sc, txq, NULL, skb);
514 }
515 +
516 + list_add_tail(&bf->list, &bf_head);
517 + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
518 }
519
520 if (sendbar) {
521 @@ -209,13 +294,16 @@ static void ath_tx_update_baw(struct ath
522 }
523
524 static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
525 - u16 seqno)
526 + struct ath_buf *bf)
527 {
528 + struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
529 + u16 seqno = bf->bf_state.seqno;
530 int index, cindex;
531
532 index = ATH_BA_INDEX(tid->seq_start, seqno);
533 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
534 __set_bit(cindex, tid->tx_buf);
535 + fi->baw_tracked = 1;
536
537 if (index >= ((tid->baw_tail - tid->baw_head) &
538 (ATH_TID_MAX_BUFS - 1))) {
539 @@ -224,12 +312,6 @@ static void ath_tx_addto_baw(struct ath_
540 }
541 }
542
543 -/*
544 - * TODO: For frame(s) that are in the retry state, we will reuse the
545 - * sequence number(s) without setting the retry bit. The
546 - * alternative is to give up on these and BAR the receiver's window
547 - * forward.
548 - */
549 static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq,
550 struct ath_atx_tid *tid)
551
552 @@ -243,7 +325,7 @@ static void ath_tid_drain(struct ath_sof
553 memset(&ts, 0, sizeof(ts));
554 INIT_LIST_HEAD(&bf_head);
555
556 - while ((skb = __skb_dequeue(&tid->buf_q))) {
557 + while ((skb = ath_tid_dequeue(tid))) {
558 fi = get_frame_info(skb);
559 bf = fi->bf;
560
561 @@ -253,14 +335,8 @@ static void ath_tid_drain(struct ath_sof
562 }
563
564 list_add_tail(&bf->list, &bf_head);
565 -
566 - ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
567 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
568 }
569 -
570 - tid->seq_next = tid->seq_start;
571 - tid->baw_tail = tid->baw_head;
572 - tid->bar_index = -1;
573 }
574
575 static void ath_tx_set_retry(struct ath_softc *sc, struct ath_txq *txq,
576 @@ -323,6 +399,7 @@ static struct ath_buf* ath_clone_txbuf(s
577 tbf->bf_buf_addr = bf->bf_buf_addr;
578 memcpy(tbf->bf_desc, bf->bf_desc, sc->sc_ah->caps.tx_desc_len);
579 tbf->bf_state = bf->bf_state;
580 + tbf->bf_state.stale = false;
581
582 return tbf;
583 }
584 @@ -380,7 +457,6 @@ static void ath_tx_complete_aggr(struct
585 struct ieee80211_tx_rate rates[4];
586 struct ath_frame_info *fi;
587 int nframes;
588 - u8 tidno;
589 bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH);
590 int i, retries;
591 int bar_index = -1;
592 @@ -406,7 +482,7 @@ static void ath_tx_complete_aggr(struct
593 while (bf) {
594 bf_next = bf->bf_next;
595
596 - if (!bf->bf_stale || bf_next != NULL)
597 + if (!bf->bf_state.stale || bf_next != NULL)
598 list_move_tail(&bf->list, &bf_head);
599
600 ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0);
601 @@ -417,8 +493,7 @@ static void ath_tx_complete_aggr(struct
602 }
603
604 an = (struct ath_node *)sta->drv_priv;
605 - tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
606 - tid = ATH_AN_2_TID(an, tidno);
607 + tid = ath_get_skb_tid(sc, an, skb);
608 seq_first = tid->seq_start;
609 isba = ts->ts_flags & ATH9K_TX_BA;
610
611 @@ -430,7 +505,7 @@ static void ath_tx_complete_aggr(struct
612 * Only BlockAcks have a TID and therefore normal Acks cannot be
613 * checked
614 */
615 - if (isba && tidno != ts->tid)
616 + if (isba && tid->tidno != ts->tid)
617 txok = false;
618
619 isaggr = bf_isaggr(bf);
620 @@ -466,7 +541,8 @@ static void ath_tx_complete_aggr(struct
621 tx_info = IEEE80211_SKB_CB(skb);
622 fi = get_frame_info(skb);
623
624 - if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
625 + if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) ||
626 + !tid->active) {
627 /*
628 * Outside of the current BlockAck window,
629 * maybe part of a previous session
630 @@ -499,7 +575,7 @@ static void ath_tx_complete_aggr(struct
631 * not a holding desc.
632 */
633 INIT_LIST_HEAD(&bf_head);
634 - if (bf_next != NULL || !bf_last->bf_stale)
635 + if (bf_next != NULL || !bf_last->bf_state.stale)
636 list_move_tail(&bf->list, &bf_head);
637
638 if (!txpending) {
639 @@ -523,7 +599,7 @@ static void ath_tx_complete_aggr(struct
640 ieee80211_sta_eosp(sta);
641 }
642 /* retry the un-acked ones */
643 - if (bf->bf_next == NULL && bf_last->bf_stale) {
644 + if (bf->bf_next == NULL && bf_last->bf_state.stale) {
645 struct ath_buf *tbf;
646
647 tbf = ath_clone_txbuf(sc, bf_last);
648 @@ -560,7 +636,7 @@ static void ath_tx_complete_aggr(struct
649 if (an->sleeping)
650 ieee80211_sta_set_buffered(sta, tid->tidno, true);
651
652 - skb_queue_splice(&bf_pending, &tid->buf_q);
653 + skb_queue_splice_tail(&bf_pending, &tid->retry_q);
654 if (!an->sleeping) {
655 ath_tx_queue_tid(txq, tid);
656
657 @@ -618,7 +694,7 @@ static void ath_tx_process_buffer(struct
658 } else
659 ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok);
660
661 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !flush)
662 + if (!flush)
663 ath_txq_schedule(sc, txq);
664 }
665
666 @@ -792,15 +868,20 @@ static int ath_compute_num_delims(struct
667
668 static struct ath_buf *
669 ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
670 - struct ath_atx_tid *tid)
671 + struct ath_atx_tid *tid, struct sk_buff_head **q)
672 {
673 + struct ieee80211_tx_info *tx_info;
674 struct ath_frame_info *fi;
675 struct sk_buff *skb;
676 struct ath_buf *bf;
677 u16 seqno;
678
679 while (1) {
680 - skb = skb_peek(&tid->buf_q);
681 + *q = &tid->retry_q;
682 + if (skb_queue_empty(*q))
683 + *q = &tid->buf_q;
684 +
685 + skb = skb_peek(*q);
686 if (!skb)
687 break;
688
689 @@ -808,13 +889,26 @@ ath_tx_get_tid_subframe(struct ath_softc
690 bf = fi->bf;
691 if (!fi->bf)
692 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
693 + else
694 + bf->bf_state.stale = false;
695
696 if (!bf) {
697 - __skb_unlink(skb, &tid->buf_q);
698 + __skb_unlink(skb, *q);
699 + ath_txq_skb_done(sc, txq, skb);
700 ieee80211_free_txskb(sc->hw, skb);
701 continue;
702 }
703
704 + bf->bf_next = NULL;
705 + bf->bf_lastbf = bf;
706 +
707 + tx_info = IEEE80211_SKB_CB(skb);
708 + tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
709 + if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
710 + bf->bf_state.bf_type = 0;
711 + return bf;
712 + }
713 +
714 bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR;
715 seqno = bf->bf_state.seqno;
716
717 @@ -828,73 +922,52 @@ ath_tx_get_tid_subframe(struct ath_softc
718
719 INIT_LIST_HEAD(&bf_head);
720 list_add(&bf->list, &bf_head);
721 - __skb_unlink(skb, &tid->buf_q);
722 + __skb_unlink(skb, *q);
723 ath_tx_update_baw(sc, tid, seqno);
724 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
725 continue;
726 }
727
728 - bf->bf_next = NULL;
729 - bf->bf_lastbf = bf;
730 return bf;
731 }
732
733 return NULL;
734 }
735
736 -static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
737 - struct ath_txq *txq,
738 - struct ath_atx_tid *tid,
739 - struct list_head *bf_q,
740 - int *aggr_len)
741 +static bool
742 +ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
743 + struct ath_atx_tid *tid, struct list_head *bf_q,
744 + struct ath_buf *bf_first, struct sk_buff_head *tid_q,
745 + int *aggr_len)
746 {
747 #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
748 - struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL;
749 - int rl = 0, nframes = 0, ndelim, prev_al = 0;
750 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
751 + int nframes = 0, ndelim;
752 u16 aggr_limit = 0, al = 0, bpad = 0,
753 - al_delta, h_baw = tid->baw_size / 2;
754 - enum ATH_AGGR_STATUS status = ATH_AGGR_DONE;
755 + al_delta, h_baw = tid->baw_size / 2;
756 struct ieee80211_tx_info *tx_info;
757 struct ath_frame_info *fi;
758 struct sk_buff *skb;
759 + bool closed = false;
760
761 - do {
762 - bf = ath_tx_get_tid_subframe(sc, txq, tid);
763 - if (!bf) {
764 - status = ATH_AGGR_BAW_CLOSED;
765 - break;
766 - }
767 + bf = bf_first;
768 + aggr_limit = ath_lookup_rate(sc, bf, tid);
769
770 + do {
771 skb = bf->bf_mpdu;
772 fi = get_frame_info(skb);
773
774 - if (!bf_first)
775 - bf_first = bf;
776 -
777 - if (!rl) {
778 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
779 - aggr_limit = ath_lookup_rate(sc, bf, tid);
780 - rl = 1;
781 - }
782 -
783 /* do not exceed aggregation limit */
784 al_delta = ATH_AGGR_DELIM_SZ + fi->framelen;
785 + if (nframes) {
786 + if (aggr_limit < al + bpad + al_delta ||
787 + ath_lookup_legacy(bf) || nframes >= h_baw)
788 + break;
789
790 - if (nframes &&
791 - ((aggr_limit < (al + bpad + al_delta + prev_al)) ||
792 - ath_lookup_legacy(bf))) {
793 - status = ATH_AGGR_LIMITED;
794 - break;
795 - }
796 -
797 - tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
798 - if (nframes && (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE))
799 - break;
800 -
801 - /* do not exceed subframe limit */
802 - if (nframes >= min((int)h_baw, ATH_AMPDU_SUBFRAME_DEFAULT)) {
803 - status = ATH_AGGR_LIMITED;
804 - break;
805 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
806 + if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
807 + !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
808 + break;
809 }
810
811 /* add padding for previous frame to aggregation length */
812 @@ -912,22 +985,37 @@ static enum ATH_AGGR_STATUS ath_tx_form_
813 bf->bf_next = NULL;
814
815 /* link buffers of this frame to the aggregate */
816 - if (!fi->retries)
817 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
818 + if (!fi->baw_tracked)
819 + ath_tx_addto_baw(sc, tid, bf);
820 bf->bf_state.ndelim = ndelim;
821
822 - __skb_unlink(skb, &tid->buf_q);
823 + __skb_unlink(skb, tid_q);
824 list_add_tail(&bf->list, bf_q);
825 if (bf_prev)
826 bf_prev->bf_next = bf;
827
828 bf_prev = bf;
829
830 - } while (!skb_queue_empty(&tid->buf_q));
831 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
832 + if (!bf) {
833 + closed = true;
834 + break;
835 + }
836 + } while (ath_tid_has_buffered(tid));
837 +
838 + bf = bf_first;
839 + bf->bf_lastbf = bf_prev;
840 +
841 + if (bf == bf_prev) {
842 + al = get_frame_info(bf->bf_mpdu)->framelen;
843 + bf->bf_state.bf_type = BUF_AMPDU;
844 + } else {
845 + TX_STAT_INC(txq->axq_qnum, a_aggr);
846 + }
847
848 *aggr_len = al;
849
850 - return status;
851 + return closed;
852 #undef PADBYTES
853 }
854
855 @@ -999,7 +1087,7 @@ void ath_update_max_aggr_framelen(struct
856 }
857
858 static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
859 - struct ath_tx_info *info, int len)
860 + struct ath_tx_info *info, int len, bool rts)
861 {
862 struct ath_hw *ah = sc->sc_ah;
863 struct sk_buff *skb;
864 @@ -1008,6 +1096,7 @@ static void ath_buf_set_rate(struct ath_
865 const struct ieee80211_rate *rate;
866 struct ieee80211_hdr *hdr;
867 struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
868 + u32 rts_thresh = sc->hw->wiphy->rts_threshold;
869 int i;
870 u8 rix = 0;
871
872 @@ -1030,7 +1119,17 @@ static void ath_buf_set_rate(struct ath_
873 rix = rates[i].idx;
874 info->rates[i].Tries = rates[i].count;
875
876 - if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
877 + /*
878 + * Handle RTS threshold for unaggregated HT frames.
879 + */
880 + if (bf_isampdu(bf) && !bf_isaggr(bf) &&
881 + (rates[i].flags & IEEE80211_TX_RC_MCS) &&
882 + unlikely(rts_thresh != (u32) -1)) {
883 + if (!rts_thresh || (len > rts_thresh))
884 + rts = true;
885 + }
886 +
887 + if (rts || rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
888 info->rates[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
889 info->flags |= ATH9K_TXDESC_RTSENA;
890 } else if (rates[i].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
891 @@ -1123,6 +1222,8 @@ static void ath_tx_fill_desc(struct ath_
892 struct ath_hw *ah = sc->sc_ah;
893 struct ath_buf *bf_first = NULL;
894 struct ath_tx_info info;
895 + u32 rts_thresh = sc->hw->wiphy->rts_threshold;
896 + bool rts = false;
897
898 memset(&info, 0, sizeof(info));
899 info.is_first = true;
900 @@ -1159,7 +1260,22 @@ static void ath_tx_fill_desc(struct ath_
901 info.flags |= (u32) bf->bf_state.bfs_paprd <<
902 ATH9K_TXDESC_PAPRD_S;
903
904 - ath_buf_set_rate(sc, bf, &info, len);
905 + /*
906 + * mac80211 doesn't handle RTS threshold for HT because
907 + * the decision has to be taken based on AMPDU length
908 + * and aggregation is done entirely inside ath9k.
909 + * Set the RTS/CTS flag for the first subframe based
910 + * on the threshold.
911 + */
912 + if (aggr && (bf == bf_first) &&
913 + unlikely(rts_thresh != (u32) -1)) {
914 + /*
915 + * "len" is the size of the entire AMPDU.
916 + */
917 + if (!rts_thresh || (len > rts_thresh))
918 + rts = true;
919 + }
920 + ath_buf_set_rate(sc, bf, &info, len, rts);
921 }
922
923 info.buf_addr[0] = bf->bf_buf_addr;
924 @@ -1188,53 +1304,86 @@ static void ath_tx_fill_desc(struct ath_
925 }
926 }
927
928 -static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
929 - struct ath_atx_tid *tid)
930 +static void
931 +ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
932 + struct ath_atx_tid *tid, struct list_head *bf_q,
933 + struct ath_buf *bf_first, struct sk_buff_head *tid_q)
934 {
935 - struct ath_buf *bf;
936 - enum ATH_AGGR_STATUS status;
937 - struct ieee80211_tx_info *tx_info;
938 - struct list_head bf_q;
939 - int aggr_len;
940 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
941 + struct sk_buff *skb;
942 + int nframes = 0;
943
944 do {
945 - if (skb_queue_empty(&tid->buf_q))
946 - return;
947 + struct ieee80211_tx_info *tx_info;
948 + skb = bf->bf_mpdu;
949
950 - INIT_LIST_HEAD(&bf_q);
951 + nframes++;
952 + __skb_unlink(skb, tid_q);
953 + list_add_tail(&bf->list, bf_q);
954 + if (bf_prev)
955 + bf_prev->bf_next = bf;
956 + bf_prev = bf;
957
958 - status = ath_tx_form_aggr(sc, txq, tid, &bf_q, &aggr_len);
959 + if (nframes >= 2)
960 + break;
961
962 - /*
963 - * no frames picked up to be aggregated;
964 - * block-ack window is not open.
965 - */
966 - if (list_empty(&bf_q))
967 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
968 + if (!bf)
969 break;
970
971 - bf = list_first_entry(&bf_q, struct ath_buf, list);
972 - bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
973 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
974 + if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
975 + break;
976
977 - if (tid->ac->clear_ps_filter) {
978 - tid->ac->clear_ps_filter = false;
979 - tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
980 - } else {
981 - tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
982 - }
983 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
984 + } while (1);
985 +}
986
987 - /* if only one frame, send as non-aggregate */
988 - if (bf == bf->bf_lastbf) {
989 - aggr_len = get_frame_info(bf->bf_mpdu)->framelen;
990 - bf->bf_state.bf_type = BUF_AMPDU;
991 - } else {
992 - TX_STAT_INC(txq->axq_qnum, a_aggr);
993 - }
994 +static bool ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
995 + struct ath_atx_tid *tid, bool *stop)
996 +{
997 + struct ath_buf *bf;
998 + struct ieee80211_tx_info *tx_info;
999 + struct sk_buff_head *tid_q;
1000 + struct list_head bf_q;
1001 + int aggr_len = 0;
1002 + bool aggr, last = true;
1003 +
1004 + if (!ath_tid_has_buffered(tid))
1005 + return false;
1006 +
1007 + INIT_LIST_HEAD(&bf_q);
1008 +
1009 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
1010 + if (!bf)
1011 + return false;
1012 +
1013 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
1014 + aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
1015 + if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
1016 + (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
1017 + *stop = true;
1018 + return false;
1019 + }
1020
1021 - ath_tx_fill_desc(sc, bf, txq, aggr_len);
1022 - ath_tx_txqaddbuf(sc, txq, &bf_q, false);
1023 - } while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH &&
1024 - status != ATH_AGGR_BAW_CLOSED);
1025 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
1026 + if (aggr)
1027 + last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
1028 + tid_q, &aggr_len);
1029 + else
1030 + ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
1031 +
1032 + if (list_empty(&bf_q))
1033 + return false;
1034 +
1035 + if (tid->ac->clear_ps_filter || tid->an->no_ps_filter) {
1036 + tid->ac->clear_ps_filter = false;
1037 + tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
1038 + }
1039 +
1040 + ath_tx_fill_desc(sc, bf, txq, aggr_len);
1041 + ath_tx_txqaddbuf(sc, txq, &bf_q, false);
1042 + return true;
1043 }
1044
1045 int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
1046 @@ -1258,6 +1407,9 @@ int ath_tx_aggr_start(struct ath_softc *
1047 an->mpdudensity = density;
1048 }
1049
1050 + /* force sequence number allocation for pending frames */
1051 + ath_tx_tid_change_state(sc, txtid);
1052 +
1053 txtid->active = true;
1054 txtid->paused = true;
1055 *ssn = txtid->seq_start = txtid->seq_next;
1056 @@ -1277,8 +1429,9 @@ void ath_tx_aggr_stop(struct ath_softc *
1057
1058 ath_txq_lock(sc, txq);
1059 txtid->active = false;
1060 - txtid->paused = true;
1061 + txtid->paused = false;
1062 ath_tx_flush_tid(sc, txtid);
1063 + ath_tx_tid_change_state(sc, txtid);
1064 ath_txq_unlock_complete(sc, txq);
1065 }
1066
1067 @@ -1302,7 +1455,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
1068
1069 ath_txq_lock(sc, txq);
1070
1071 - buffered = !skb_queue_empty(&tid->buf_q);
1072 + buffered = ath_tid_has_buffered(tid);
1073
1074 tid->sched = false;
1075 list_del(&tid->list);
1076 @@ -1334,7 +1487,7 @@ void ath_tx_aggr_wakeup(struct ath_softc
1077 ath_txq_lock(sc, txq);
1078 ac->clear_ps_filter = true;
1079
1080 - if (!skb_queue_empty(&tid->buf_q) && !tid->paused) {
1081 + if (!tid->paused && ath_tid_has_buffered(tid)) {
1082 ath_tx_queue_tid(txq, tid);
1083 ath_txq_schedule(sc, txq);
1084 }
1085 @@ -1359,7 +1512,7 @@ void ath_tx_aggr_resume(struct ath_softc
1086 tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
1087 tid->paused = false;
1088
1089 - if (!skb_queue_empty(&tid->buf_q)) {
1090 + if (ath_tid_has_buffered(tid)) {
1091 ath_tx_queue_tid(txq, tid);
1092 ath_txq_schedule(sc, txq);
1093 }
1094 @@ -1379,6 +1532,7 @@ void ath9k_release_buffered_frames(struc
1095 struct ieee80211_tx_info *info;
1096 struct list_head bf_q;
1097 struct ath_buf *bf_tail = NULL, *bf;
1098 + struct sk_buff_head *tid_q;
1099 int sent = 0;
1100 int i;
1101
1102 @@ -1394,15 +1548,15 @@ void ath9k_release_buffered_frames(struc
1103 continue;
1104
1105 ath_txq_lock(sc, tid->ac->txq);
1106 - while (!skb_queue_empty(&tid->buf_q) && nframes > 0) {
1107 - bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid);
1108 + while (nframes > 0) {
1109 + bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
1110 if (!bf)
1111 break;
1112
1113 - __skb_unlink(bf->bf_mpdu, &tid->buf_q);
1114 + __skb_unlink(bf->bf_mpdu, tid_q);
1115 list_add_tail(&bf->list, &bf_q);
1116 ath_set_rates(tid->an->vif, tid->an->sta, bf);
1117 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
1118 + ath_tx_addto_baw(sc, tid, bf);
1119 bf->bf_state.bf_type &= ~BUF_AGGR;
1120 if (bf_tail)
1121 bf_tail->bf_next = bf;
1122 @@ -1412,7 +1566,7 @@ void ath9k_release_buffered_frames(struc
1123 sent++;
1124 TX_STAT_INC(txq->axq_qnum, a_queued_hw);
1125
1126 - if (skb_queue_empty(&tid->buf_q))
1127 + if (an->sta && !ath_tid_has_buffered(tid))
1128 ieee80211_sta_set_buffered(an->sta, i, false);
1129 }
1130 ath_txq_unlock_complete(sc, tid->ac->txq);
1131 @@ -1571,7 +1725,7 @@ static void ath_drain_txq_list(struct at
1132 while (!list_empty(list)) {
1133 bf = list_first_entry(list, struct ath_buf, list);
1134
1135 - if (bf->bf_stale) {
1136 + if (bf->bf_state.stale) {
1137 list_del(&bf->list);
1138
1139 ath_tx_return_buffer(sc, bf);
1140 @@ -1665,25 +1819,27 @@ void ath_tx_cleanupq(struct ath_softc *s
1141 */
1142 void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
1143 {
1144 - struct ath_atx_ac *ac, *ac_tmp, *last_ac;
1145 + struct ath_atx_ac *ac, *last_ac;
1146 struct ath_atx_tid *tid, *last_tid;
1147 + bool sent = false;
1148
1149 if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) ||
1150 - list_empty(&txq->axq_acq) ||
1151 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1152 + list_empty(&txq->axq_acq))
1153 return;
1154
1155 rcu_read_lock();
1156
1157 - ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
1158 last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list);
1159 + while (!list_empty(&txq->axq_acq)) {
1160 + bool stop = false;
1161
1162 - list_for_each_entry_safe(ac, ac_tmp, &txq->axq_acq, list) {
1163 + ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
1164 last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
1165 list_del(&ac->list);
1166 ac->sched = false;
1167
1168 while (!list_empty(&ac->tid_q)) {
1169 +
1170 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
1171 list);
1172 list_del(&tid->list);
1173 @@ -1692,17 +1848,17 @@ void ath_txq_schedule(struct ath_softc *
1174 if (tid->paused)
1175 continue;
1176
1177 - ath_tx_sched_aggr(sc, txq, tid);
1178 + if (ath_tx_sched_aggr(sc, txq, tid, &stop))
1179 + sent = true;
1180
1181 /*
1182 * add tid to round-robin queue if more frames
1183 * are pending for the tid
1184 */
1185 - if (!skb_queue_empty(&tid->buf_q))
1186 + if (ath_tid_has_buffered(tid))
1187 ath_tx_queue_tid(txq, tid);
1188
1189 - if (tid == last_tid ||
1190 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1191 + if (stop || tid == last_tid)
1192 break;
1193 }
1194
1195 @@ -1711,9 +1867,17 @@ void ath_txq_schedule(struct ath_softc *
1196 list_add_tail(&ac->list, &txq->axq_acq);
1197 }
1198
1199 - if (ac == last_ac ||
1200 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1201 + if (stop)
1202 break;
1203 +
1204 + if (ac == last_ac) {
1205 + if (!sent)
1206 + break;
1207 +
1208 + sent = false;
1209 + last_ac = list_entry(txq->axq_acq.prev,
1210 + struct ath_atx_ac, list);
1211 + }
1212 }
1213
1214 rcu_read_unlock();
1215 @@ -1792,57 +1956,6 @@ static void ath_tx_txqaddbuf(struct ath_
1216 }
1217 }
1218
1219 -static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_txq *txq,
1220 - struct ath_atx_tid *tid, struct sk_buff *skb,
1221 - struct ath_tx_control *txctl)
1222 -{
1223 - struct ath_frame_info *fi = get_frame_info(skb);
1224 - struct list_head bf_head;
1225 - struct ath_buf *bf;
1226 -
1227 - /*
1228 - * Do not queue to h/w when any of the following conditions is true:
1229 - * - there are pending frames in software queue
1230 - * - the TID is currently paused for ADDBA/BAR request
1231 - * - seqno is not within block-ack window
1232 - * - h/w queue depth exceeds low water mark
1233 - */
1234 - if ((!skb_queue_empty(&tid->buf_q) || tid->paused ||
1235 - !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) ||
1236 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) &&
1237 - txq != sc->tx.uapsdq) {
1238 - /*
1239 - * Add this frame to software queue for scheduling later
1240 - * for aggregation.
1241 - */
1242 - TX_STAT_INC(txq->axq_qnum, a_queued_sw);
1243 - __skb_queue_tail(&tid->buf_q, skb);
1244 - if (!txctl->an || !txctl->an->sleeping)
1245 - ath_tx_queue_tid(txq, tid);
1246 - return;
1247 - }
1248 -
1249 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1250 - if (!bf) {
1251 - ieee80211_free_txskb(sc->hw, skb);
1252 - return;
1253 - }
1254 -
1255 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
1256 - bf->bf_state.bf_type = BUF_AMPDU;
1257 - INIT_LIST_HEAD(&bf_head);
1258 - list_add(&bf->list, &bf_head);
1259 -
1260 - /* Add sub-frame to BAW */
1261 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
1262 -
1263 - /* Queue to h/w without aggregation */
1264 - TX_STAT_INC(txq->axq_qnum, a_queued_hw);
1265 - bf->bf_lastbf = bf;
1266 - ath_tx_fill_desc(sc, bf, txq, fi->framelen);
1267 - ath_tx_txqaddbuf(sc, txq, &bf_head, false);
1268 -}
1269 -
1270 static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
1271 struct ath_atx_tid *tid, struct sk_buff *skb)
1272 {
1273 @@ -1985,6 +2098,7 @@ static int ath_tx_prepare(struct ieee802
1274 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1275 struct ieee80211_sta *sta = txctl->sta;
1276 struct ieee80211_vif *vif = info->control.vif;
1277 + struct ath_vif *avp;
1278 struct ath_softc *sc = hw->priv;
1279 int frmlen = skb->len + FCS_LEN;
1280 int padpos, padsize;
1281 @@ -1992,6 +2106,10 @@ static int ath_tx_prepare(struct ieee802
1282 /* NOTE: sta can be NULL according to net/mac80211.h */
1283 if (sta)
1284 txctl->an = (struct ath_node *)sta->drv_priv;
1285 + else if (vif && ieee80211_is_data(hdr->frame_control)) {
1286 + avp = (void *)vif->drv_priv;
1287 + txctl->an = &avp->mcast_node;
1288 + }
1289
1290 if (info->control.hw_key)
1291 frmlen += info->control.hw_key->icv_len;
1292 @@ -2041,7 +2159,6 @@ int ath_tx_start(struct ieee80211_hw *hw
1293 struct ath_txq *txq = txctl->txq;
1294 struct ath_atx_tid *tid = NULL;
1295 struct ath_buf *bf;
1296 - u8 tidno;
1297 int q;
1298 int ret;
1299
1300 @@ -2069,27 +2186,31 @@ int ath_tx_start(struct ieee80211_hw *hw
1301 ath_txq_unlock(sc, txq);
1302 txq = sc->tx.uapsdq;
1303 ath_txq_lock(sc, txq);
1304 - }
1305 -
1306 - if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
1307 - tidno = ieee80211_get_qos_ctl(hdr)[0] &
1308 - IEEE80211_QOS_CTL_TID_MASK;
1309 - tid = ATH_AN_2_TID(txctl->an, tidno);
1310 + } else if (txctl->an &&
1311 + ieee80211_is_data_present(hdr->frame_control)) {
1312 + tid = ath_get_skb_tid(sc, txctl->an, skb);
1313
1314 WARN_ON(tid->ac->txq != txctl->txq);
1315 - }
1316
1317 - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
1318 + if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
1319 + tid->ac->clear_ps_filter = true;
1320 +
1321 /*
1322 - * Try aggregation if it's a unicast data frame
1323 - * and the destination is HT capable.
1324 + * Add this frame to software queue for scheduling later
1325 + * for aggregation.
1326 */
1327 - ath_tx_send_ampdu(sc, txq, tid, skb, txctl);
1328 + TX_STAT_INC(txq->axq_qnum, a_queued_sw);
1329 + __skb_queue_tail(&tid->buf_q, skb);
1330 + if (!txctl->an->sleeping)
1331 + ath_tx_queue_tid(txq, tid);
1332 +
1333 + ath_txq_schedule(sc, txq);
1334 goto out;
1335 }
1336
1337 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1338 if (!bf) {
1339 + ath_txq_skb_done(sc, txq, skb);
1340 if (txctl->paprd)
1341 dev_kfree_skb_any(skb);
1342 else
1343 @@ -2142,7 +2263,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
1344
1345 bf->bf_lastbf = bf;
1346 ath_set_rates(vif, NULL, bf);
1347 - ath_buf_set_rate(sc, bf, &info, fi->framelen);
1348 + ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
1349 duration += info.rates[0].PktDuration;
1350 if (bf_tail)
1351 bf_tail->bf_next = bf;
1352 @@ -2189,7 +2310,7 @@ static void ath_tx_complete(struct ath_s
1353 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1354 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1355 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
1356 - int q, padpos, padsize;
1357 + int padpos, padsize;
1358 unsigned long flags;
1359
1360 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
1361 @@ -2225,21 +2346,7 @@ static void ath_tx_complete(struct ath_s
1362 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1363
1364 __skb_queue_tail(&txq->complete_q, skb);
1365 -
1366 - q = skb_get_queue_mapping(skb);
1367 - if (txq == sc->tx.uapsdq)
1368 - txq = sc->tx.txq_map[q];
1369 -
1370 - if (txq == sc->tx.txq_map[q]) {
1371 - if (WARN_ON(--txq->pending_frames < 0))
1372 - txq->pending_frames = 0;
1373 -
1374 - if (txq->stopped &&
1375 - txq->pending_frames < sc->tx.txq_max_pending[q]) {
1376 - ieee80211_wake_queue(sc->hw, q);
1377 - txq->stopped = false;
1378 - }
1379 - }
1380 + ath_txq_skb_done(sc, txq, skb);
1381 }
1382
1383 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
1384 @@ -2360,8 +2467,7 @@ static void ath_tx_processq(struct ath_s
1385
1386 if (list_empty(&txq->axq_q)) {
1387 txq->axq_link = NULL;
1388 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
1389 - ath_txq_schedule(sc, txq);
1390 + ath_txq_schedule(sc, txq);
1391 break;
1392 }
1393 bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
1394 @@ -2375,7 +2481,7 @@ static void ath_tx_processq(struct ath_s
1395 * it with the STALE flag.
1396 */
1397 bf_held = NULL;
1398 - if (bf->bf_stale) {
1399 + if (bf->bf_state.stale) {
1400 bf_held = bf;
1401 if (list_is_last(&bf_held->list, &txq->axq_q))
1402 break;
1403 @@ -2399,7 +2505,7 @@ static void ath_tx_processq(struct ath_s
1404 * however leave the last descriptor back as the holding
1405 * descriptor for hw.
1406 */
1407 - lastbf->bf_stale = true;
1408 + lastbf->bf_state.stale = true;
1409 INIT_LIST_HEAD(&bf_head);
1410 if (!list_is_singular(&lastbf->list))
1411 list_cut_position(&bf_head,
1412 @@ -2470,7 +2576,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1413 }
1414
1415 bf = list_first_entry(fifo_list, struct ath_buf, list);
1416 - if (bf->bf_stale) {
1417 + if (bf->bf_state.stale) {
1418 list_del(&bf->list);
1419 ath_tx_return_buffer(sc, bf);
1420 bf = list_first_entry(fifo_list, struct ath_buf, list);
1421 @@ -2492,7 +2598,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1422 ath_tx_txqaddbuf(sc, txq, &bf_q, true);
1423 }
1424 } else {
1425 - lastbf->bf_stale = true;
1426 + lastbf->bf_state.stale = true;
1427 if (bf != lastbf)
1428 list_cut_position(&bf_head, fifo_list,
1429 lastbf->list.prev);
1430 @@ -2583,6 +2689,7 @@ void ath_tx_node_init(struct ath_softc *
1431 tid->paused = false;
1432 tid->active = false;
1433 __skb_queue_head_init(&tid->buf_q);
1434 + __skb_queue_head_init(&tid->retry_q);
1435 acno = TID_TO_WME_AC(tidno);
1436 tid->ac = &an->ac[acno];
1437 }
1438 @@ -2590,6 +2697,7 @@ void ath_tx_node_init(struct ath_softc *
1439 for (acno = 0, ac = &an->ac[acno];
1440 acno < IEEE80211_NUM_ACS; acno++, ac++) {
1441 ac->sched = false;
1442 + ac->clear_ps_filter = true;
1443 ac->txq = sc->tx.txq_map[acno];
1444 INIT_LIST_HEAD(&ac->tid_q);
1445 }
1446 --- a/drivers/net/wireless/ath/ath9k/main.c
1447 +++ b/drivers/net/wireless/ath/ath9k/main.c
1448 @@ -173,8 +173,7 @@ static void ath_restart_work(struct ath_
1449 {
1450 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
1451
1452 - if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9485(sc->sc_ah) ||
1453 - AR_SREV_9550(sc->sc_ah))
1454 + if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah))
1455 ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
1456 msecs_to_jiffies(ATH_PLL_WORK_INTERVAL));
1457
1458 @@ -238,9 +237,6 @@ static bool ath_complete_reset(struct at
1459 ath_restart_work(sc);
1460 }
1461
1462 - if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3)
1463 - ath_ant_comb_update(sc);
1464 -
1465 ieee80211_wake_queues(sc->hw);
1466
1467 return true;
1468 @@ -966,6 +962,8 @@ static int ath9k_add_interface(struct ie
1469 struct ath_softc *sc = hw->priv;
1470 struct ath_hw *ah = sc->sc_ah;
1471 struct ath_common *common = ath9k_hw_common(ah);
1472 + struct ath_vif *avp = (void *)vif->drv_priv;
1473 + struct ath_node *an = &avp->mcast_node;
1474
1475 mutex_lock(&sc->mutex);
1476
1477 @@ -979,6 +977,12 @@ static int ath9k_add_interface(struct ie
1478 if (ath9k_uses_beacons(vif->type))
1479 ath9k_beacon_assign_slot(sc, vif);
1480
1481 + an->sc = sc;
1482 + an->sta = NULL;
1483 + an->vif = vif;
1484 + an->no_ps_filter = true;
1485 + ath_tx_node_init(sc, an);
1486 +
1487 mutex_unlock(&sc->mutex);
1488 return 0;
1489 }
1490 @@ -1016,6 +1020,7 @@ static void ath9k_remove_interface(struc
1491 {
1492 struct ath_softc *sc = hw->priv;
1493 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1494 + struct ath_vif *avp = (void *)vif->drv_priv;
1495
1496 ath_dbg(common, CONFIG, "Detach Interface\n");
1497
1498 @@ -1030,6 +1035,8 @@ static void ath9k_remove_interface(struc
1499 ath9k_calculate_summary_state(hw, NULL);
1500 ath9k_ps_restore(sc);
1501
1502 + ath_tx_node_cleanup(sc, &avp->mcast_node);
1503 +
1504 mutex_unlock(&sc->mutex);
1505 }
1506
1507 @@ -1193,8 +1200,6 @@ static int ath9k_config(struct ieee80211
1508
1509 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
1510 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
1511 - enum nl80211_channel_type channel_type =
1512 - cfg80211_get_chandef_type(&conf->chandef);
1513 int pos = curchan->hw_value;
1514 int old_pos = -1;
1515 unsigned long flags;
1516 @@ -1202,8 +1207,8 @@ static int ath9k_config(struct ieee80211
1517 if (ah->curchan)
1518 old_pos = ah->curchan - &ah->channels[0];
1519
1520 - ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n",
1521 - curchan->center_freq, channel_type);
1522 + ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
1523 + curchan->center_freq, hw->conf.chandef.width);
1524
1525 /* update survey stats for the old channel before switching */
1526 spin_lock_irqsave(&common->cc_lock, flags);
1527 @@ -1211,7 +1216,7 @@ static int ath9k_config(struct ieee80211
1528 spin_unlock_irqrestore(&common->cc_lock, flags);
1529
1530 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
1531 - curchan, channel_type);
1532 + &conf->chandef);
1533
1534 /*
1535 * If the operating channel changes, change the survey in-use flags
1536 @@ -1374,9 +1379,6 @@ static void ath9k_sta_notify(struct ieee
1537 struct ath_softc *sc = hw->priv;
1538 struct ath_node *an = (struct ath_node *) sta->drv_priv;
1539
1540 - if (!sta->ht_cap.ht_supported)
1541 - return;
1542 -
1543 switch (cmd) {
1544 case STA_NOTIFY_SLEEP:
1545 an->sleeping = true;
1546 @@ -2094,7 +2096,7 @@ static void ath9k_wow_add_pattern(struct
1547 {
1548 struct ath_hw *ah = sc->sc_ah;
1549 struct ath9k_wow_pattern *wow_pattern = NULL;
1550 - struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
1551 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
1552 int mask_len;
1553 s8 i = 0;
1554
1555 --- a/drivers/net/wireless/mwifiex/cfg80211.c
1556 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
1557 @@ -2298,8 +2298,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_in
1558
1559 #ifdef CONFIG_PM
1560 static bool
1561 -mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
1562 - s8 *byte_seq)
1563 +mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
1564 {
1565 int j, k, valid_byte_cnt = 0;
1566 bool dont_care_byte = false;
1567 --- a/drivers/net/wireless/ti/wlcore/main.c
1568 +++ b/drivers/net/wireless/ti/wlcore/main.c
1569 @@ -1315,7 +1315,7 @@ static struct sk_buff *wl12xx_alloc_dumm
1570
1571 #ifdef CONFIG_PM
1572 static int
1573 -wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
1574 +wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
1575 {
1576 int num_fields = 0, in_field = 0, fields_size = 0;
1577 int i, pattern_len = 0;
1578 @@ -1458,9 +1458,9 @@ void wl1271_rx_filter_flatten_fields(str
1579 * Allocates an RX filter returned through f
1580 * which needs to be freed using rx_filter_free()
1581 */
1582 -static int wl1271_convert_wowlan_pattern_to_rx_filter(
1583 - struct cfg80211_wowlan_trig_pkt_pattern *p,
1584 - struct wl12xx_rx_filter **f)
1585 +static int
1586 +wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
1587 + struct wl12xx_rx_filter **f)
1588 {
1589 int i, j, ret = 0;
1590 struct wl12xx_rx_filter *filter;
1591 @@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
1592
1593 /* Translate WoWLAN patterns into filters */
1594 for (i = 0; i < wow->n_patterns; i++) {
1595 - struct cfg80211_wowlan_trig_pkt_pattern *p;
1596 + struct cfg80211_pkt_pattern *p;
1597 struct wl12xx_rx_filter *filter = NULL;
1598
1599 p = &wow->patterns[i];
1600 --- a/include/net/cfg80211.h
1601 +++ b/include/net/cfg80211.h
1602 @@ -639,6 +639,30 @@ struct cfg80211_ap_settings {
1603 };
1604
1605 /**
1606 + * struct cfg80211_csa_settings - channel switch settings
1607 + *
1608 + * Used for channel switch
1609 + *
1610 + * @chandef: defines the channel to use after the switch
1611 + * @beacon_csa: beacon data while performing the switch
1612 + * @counter_offset_beacon: offset for the counter within the beacon (tail)
1613 + * @counter_offset_presp: offset for the counter within the probe response
1614 + * @beacon_after: beacon data to be used on the new channel
1615 + * @radar_required: whether radar detection is required on the new channel
1616 + * @block_tx: whether transmissions should be blocked while changing
1617 + * @count: number of beacons until switch
1618 + */
1619 +struct cfg80211_csa_settings {
1620 + struct cfg80211_chan_def chandef;
1621 + struct cfg80211_beacon_data beacon_csa;
1622 + u16 counter_offset_beacon, counter_offset_presp;
1623 + struct cfg80211_beacon_data beacon_after;
1624 + bool radar_required;
1625 + bool block_tx;
1626 + u8 count;
1627 +};
1628 +
1629 +/**
1630 * enum station_parameters_apply_mask - station parameter values to apply
1631 * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
1632 * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
1633 @@ -1698,7 +1722,7 @@ struct cfg80211_pmksa {
1634 };
1635
1636 /**
1637 - * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
1638 + * struct cfg80211_pkt_pattern - packet pattern
1639 * @mask: bitmask where to match pattern and where to ignore bytes,
1640 * one bit per byte, in same format as nl80211
1641 * @pattern: bytes to match where bitmask is 1
1642 @@ -1708,7 +1732,7 @@ struct cfg80211_pmksa {
1643 * Internal note: @mask and @pattern are allocated in one chunk of
1644 * memory, free @mask only!
1645 */
1646 -struct cfg80211_wowlan_trig_pkt_pattern {
1647 +struct cfg80211_pkt_pattern {
1648 u8 *mask, *pattern;
1649 int pattern_len;
1650 int pkt_offset;
1651 @@ -1770,7 +1794,7 @@ struct cfg80211_wowlan {
1652 bool any, disconnect, magic_pkt, gtk_rekey_failure,
1653 eap_identity_req, four_way_handshake,
1654 rfkill_release;
1655 - struct cfg80211_wowlan_trig_pkt_pattern *patterns;
1656 + struct cfg80211_pkt_pattern *patterns;
1657 struct cfg80211_wowlan_tcp *tcp;
1658 int n_patterns;
1659 };
1660 @@ -2071,6 +2095,8 @@ struct cfg80211_update_ft_ies_params {
1661 * driver can take the most appropriate actions.
1662 * @crit_proto_stop: Indicates critical protocol no longer needs increased link
1663 * reliability. This operation can not fail.
1664 + *
1665 + * @channel_switch: initiate channel-switch procedure (with CSA)
1666 */
1667 struct cfg80211_ops {
1668 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
1669 @@ -2306,6 +2332,10 @@ struct cfg80211_ops {
1670 u16 duration);
1671 void (*crit_proto_stop)(struct wiphy *wiphy,
1672 struct wireless_dev *wdev);
1673 +
1674 + int (*channel_switch)(struct wiphy *wiphy,
1675 + struct net_device *dev,
1676 + struct cfg80211_csa_settings *params);
1677 };
1678
1679 /*
1680 @@ -2371,6 +2401,8 @@ struct cfg80211_ops {
1681 * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
1682 * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
1683 * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
1684 + * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
1685 + * beaconing mode (AP, IBSS, Mesh, ...).
1686 */
1687 enum wiphy_flags {
1688 WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0),
1689 @@ -2395,6 +2427,7 @@ enum wiphy_flags {
1690 WIPHY_FLAG_OFFCHAN_TX = BIT(20),
1691 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
1692 WIPHY_FLAG_SUPPORTS_5_10_MHZ = BIT(22),
1693 + WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
1694 };
1695
1696 /**
1697 --- a/include/uapi/linux/nl80211.h
1698 +++ b/include/uapi/linux/nl80211.h
1699 @@ -648,6 +648,16 @@
1700 * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
1701 * return back to normal.
1702 *
1703 + * @NL80211_CMD_CHANNEL_SWITCH: Perform a channel switch by announcing the
1704 + * the new channel information (Channel Switch Announcement - CSA)
1705 + * in the beacon for some time (as defined in the
1706 + * %NL80211_ATTR_CH_SWITCH_COUNT parameter) and then change to the
1707 + * new channel. Userspace provides the new channel information (using
1708 + * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel
1709 + * width). %NL80211_ATTR_CH_SWITCH_BLOCK_TX may be supplied to inform
1710 + * other station that transmission must be blocked until the channel
1711 + * switch is complete.
1712 + *
1713 * @NL80211_CMD_MAX: highest used command number
1714 * @__NL80211_CMD_AFTER_LAST: internal use
1715 */
1716 @@ -810,6 +820,8 @@ enum nl80211_commands {
1717 NL80211_CMD_CRIT_PROTOCOL_START,
1718 NL80211_CMD_CRIT_PROTOCOL_STOP,
1719
1720 + NL80211_CMD_CHANNEL_SWITCH,
1721 +
1722 /* add new commands above here */
1723
1724 /* used to define NL80211_CMD_MAX below */
1725 @@ -1436,6 +1448,18 @@ enum nl80211_commands {
1726 * allowed to be used with the first @NL80211_CMD_SET_STATION command to
1727 * update a TDLS peer STA entry.
1728 *
1729 + * @NL80211_ATTR_CH_SWITCH_COUNT: u32 attribute specifying the number of TBTT's
1730 + * until the channel switch event.
1731 + * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission
1732 + * must be blocked on the current channel (before the channel switch
1733 + * operation).
1734 + * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
1735 + * for the time while performing a channel switch.
1736 + * @NL80211_ATTR_CSA_C_OFF_BEACON: Offset of the channel switch counter
1737 + * field in the beacons tail (%NL80211_ATTR_BEACON_TAIL).
1738 + * @NL80211_ATTR_CSA_C_OFF_PRESP: Offset of the channel switch counter
1739 + * field in the probe response (%NL80211_ATTR_PROBE_RESP).
1740 + *
1741 * @NL80211_ATTR_MAX: highest attribute number currently defined
1742 * @__NL80211_ATTR_AFTER_LAST: internal use
1743 */
1744 @@ -1736,6 +1760,12 @@ enum nl80211_attrs {
1745
1746 NL80211_ATTR_PEER_AID,
1747
1748 + NL80211_ATTR_CH_SWITCH_COUNT,
1749 + NL80211_ATTR_CH_SWITCH_BLOCK_TX,
1750 + NL80211_ATTR_CSA_IES,
1751 + NL80211_ATTR_CSA_C_OFF_BEACON,
1752 + NL80211_ATTR_CSA_C_OFF_PRESP,
1753 +
1754 /* add attributes here, update the policy in nl80211.c */
1755
1756 __NL80211_ATTR_AFTER_LAST,
1757 @@ -3060,11 +3090,11 @@ enum nl80211_tx_power_setting {
1758 };
1759
1760 /**
1761 - * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
1762 - * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
1763 - * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
1764 + * enum nl80211_packet_pattern_attr - packet pattern attribute
1765 + * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
1766 + * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
1767 * a zero bit are ignored
1768 - * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
1769 + * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
1770 * a bit for each byte in the pattern. The lowest-order bit corresponds
1771 * to the first byte of the pattern, but the bytes of the pattern are
1772 * in a little-endian-like format, i.e. the 9th byte of the pattern
1773 @@ -3075,23 +3105,23 @@ enum nl80211_tx_power_setting {
1774 * Note that the pattern matching is done as though frames were not
1775 * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
1776 * first (including SNAP header unpacking) and then matched.
1777 - * @NL80211_WOWLAN_PKTPAT_OFFSET: packet offset, pattern is matched after
1778 + * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
1779 * these fixed number of bytes of received packet
1780 - * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
1781 - * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
1782 + * @NUM_NL80211_PKTPAT: number of attributes
1783 + * @MAX_NL80211_PKTPAT: max attribute number
1784 */
1785 -enum nl80211_wowlan_packet_pattern_attr {
1786 - __NL80211_WOWLAN_PKTPAT_INVALID,
1787 - NL80211_WOWLAN_PKTPAT_MASK,
1788 - NL80211_WOWLAN_PKTPAT_PATTERN,
1789 - NL80211_WOWLAN_PKTPAT_OFFSET,
1790 +enum nl80211_packet_pattern_attr {
1791 + __NL80211_PKTPAT_INVALID,
1792 + NL80211_PKTPAT_MASK,
1793 + NL80211_PKTPAT_PATTERN,
1794 + NL80211_PKTPAT_OFFSET,
1795
1796 - NUM_NL80211_WOWLAN_PKTPAT,
1797 - MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
1798 + NUM_NL80211_PKTPAT,
1799 + MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
1800 };
1801
1802 /**
1803 - * struct nl80211_wowlan_pattern_support - pattern support information
1804 + * struct nl80211_pattern_support - packet pattern support information
1805 * @max_patterns: maximum number of patterns supported
1806 * @min_pattern_len: minimum length of each pattern
1807 * @max_pattern_len: maximum length of each pattern
1808 @@ -3101,13 +3131,22 @@ enum nl80211_wowlan_packet_pattern_attr
1809 * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
1810 * capability information given by the kernel to userspace.
1811 */
1812 -struct nl80211_wowlan_pattern_support {
1813 +struct nl80211_pattern_support {
1814 __u32 max_patterns;
1815 __u32 min_pattern_len;
1816 __u32 max_pattern_len;
1817 __u32 max_pkt_offset;
1818 } __attribute__((packed));
1819
1820 +/* only for backward compatibility */
1821 +#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
1822 +#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
1823 +#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
1824 +#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
1825 +#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
1826 +#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
1827 +#define nl80211_wowlan_pattern_support nl80211_pattern_support
1828 +
1829 /**
1830 * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
1831 * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
1832 @@ -3127,7 +3166,7 @@ struct nl80211_wowlan_pattern_support {
1833 * pattern matching is done after the packet is converted to the MSDU.
1834 *
1835 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
1836 - * carrying a &struct nl80211_wowlan_pattern_support.
1837 + * carrying a &struct nl80211_pattern_support.
1838 *
1839 * When reporting wakeup. it is a u32 attribute containing the 0-based
1840 * index of the pattern that caused the wakeup, in the patterns passed
1841 @@ -3284,7 +3323,7 @@ struct nl80211_wowlan_tcp_data_token_fea
1842 * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
1843 * u32 attribute holding the maximum length
1844 * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
1845 - * feature advertising. The mask works like @NL80211_WOWLAN_PKTPAT_MASK
1846 + * feature advertising. The mask works like @NL80211_PKTPAT_MASK
1847 * but on the TCP payload only.
1848 * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
1849 * @MAX_NL80211_WOWLAN_TCP: highest attribute number
1850 --- a/net/mac80211/mesh_ps.c
1851 +++ b/net/mac80211/mesh_ps.c
1852 @@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(str
1853 enum nl80211_mesh_power_mode pm;
1854 bool do_buffer;
1855
1856 + /* For non-assoc STA, prevent buffering or frame transmission */
1857 + if (sta->sta_state < IEEE80211_STA_ASSOC)
1858 + return;
1859 +
1860 /*
1861 * use peer-specific power mode if peering is established and the
1862 * peer's power mode is known
1863 --- a/net/wireless/nl80211.c
1864 +++ b/net/wireless/nl80211.c
1865 @@ -349,6 +349,11 @@ static const struct nla_policy nl80211_p
1866 [NL80211_ATTR_IE_RIC] = { .type = NLA_BINARY,
1867 .len = IEEE80211_MAX_DATA_LEN },
1868 [NL80211_ATTR_PEER_AID] = { .type = NLA_U16 },
1869 + [NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 },
1870 + [NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG },
1871 + [NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED },
1872 + [NL80211_ATTR_CSA_C_OFF_BEACON] = { .type = NLA_U16 },
1873 + [NL80211_ATTR_CSA_C_OFF_PRESP] = { .type = NLA_U16 },
1874 };
1875
1876 /* policy for the key attributes */
1877 @@ -441,10 +446,12 @@ static int nl80211_prepare_wdev_dump(str
1878 goto out_unlock;
1879 }
1880 *rdev = wiphy_to_dev((*wdev)->wiphy);
1881 - cb->args[0] = (*rdev)->wiphy_idx;
1882 + /* 0 is the first index - add 1 to parse only once */
1883 + cb->args[0] = (*rdev)->wiphy_idx + 1;
1884 cb->args[1] = (*wdev)->identifier;
1885 } else {
1886 - struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]);
1887 + /* subtract the 1 again here */
1888 + struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
1889 struct wireless_dev *tmp;
1890
1891 if (!wiphy) {
1892 @@ -974,7 +981,7 @@ static int nl80211_send_wowlan(struct sk
1893 return -ENOBUFS;
1894
1895 if (dev->wiphy.wowlan->n_patterns) {
1896 - struct nl80211_wowlan_pattern_support pat = {
1897 + struct nl80211_pattern_support pat = {
1898 .max_patterns = dev->wiphy.wowlan->n_patterns,
1899 .min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
1900 .max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
1901 @@ -1393,6 +1400,8 @@ static int nl80211_send_wiphy(struct cfg
1902 if (state->split) {
1903 CMD(crit_proto_start, CRIT_PROTOCOL_START);
1904 CMD(crit_proto_stop, CRIT_PROTOCOL_STOP);
1905 + if (dev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)
1906 + CMD(channel_switch, CHANNEL_SWITCH);
1907 }
1908
1909 #ifdef CPTCFG_NL80211_TESTMODE
1910 @@ -1568,8 +1577,10 @@ static int nl80211_dump_wiphy(struct sk_
1911 rtnl_lock();
1912 if (!state) {
1913 state = kzalloc(sizeof(*state), GFP_KERNEL);
1914 - if (!state)
1915 + if (!state) {
1916 + rtnl_unlock();
1917 return -ENOMEM;
1918 + }
1919 state->filter_wiphy = -1;
1920 ret = nl80211_dump_wiphy_parse(skb, cb, state);
1921 if (ret) {
1922 @@ -2620,8 +2631,8 @@ static int nl80211_get_key(struct sk_buf
1923
1924 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
1925 NL80211_CMD_NEW_KEY);
1926 - if (IS_ERR(hdr))
1927 - return PTR_ERR(hdr);
1928 + if (!hdr)
1929 + return -ENOBUFS;
1930
1931 cookie.msg = msg;
1932 cookie.idx = key_idx;
1933 @@ -4770,9 +4781,9 @@ do { \
1934 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, 0, 1,
1935 mask, NL80211_MESHCONF_FORWARDING,
1936 nla_get_u8);
1937 - FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, 1, 255,
1938 + FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0,
1939 mask, NL80211_MESHCONF_RSSI_THRESHOLD,
1940 - nla_get_u32);
1941 + nla_get_s32);
1942 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16,
1943 mask, NL80211_MESHCONF_HT_OPMODE,
1944 nla_get_u16);
1945 @@ -5578,6 +5589,111 @@ static int nl80211_start_radar_detection
1946 return err;
1947 }
1948
1949 +static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
1950 +{
1951 + struct cfg80211_registered_device *rdev = info->user_ptr[0];
1952 + struct net_device *dev = info->user_ptr[1];
1953 + struct wireless_dev *wdev = dev->ieee80211_ptr;
1954 + struct cfg80211_csa_settings params;
1955 + /* csa_attrs is defined static to avoid waste of stack size - this
1956 + * function is called under RTNL lock, so this should not be a problem.
1957 + */
1958 + static struct nlattr *csa_attrs[NL80211_ATTR_MAX+1];
1959 + u8 radar_detect_width = 0;
1960 + int err;
1961 +
1962 + if (!rdev->ops->channel_switch ||
1963 + !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
1964 + return -EOPNOTSUPP;
1965 +
1966 + /* may add IBSS support later */
1967 + if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
1968 + dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
1969 + return -EOPNOTSUPP;
1970 +
1971 + memset(&params, 0, sizeof(params));
1972 +
1973 + if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] ||
1974 + !info->attrs[NL80211_ATTR_CH_SWITCH_COUNT])
1975 + return -EINVAL;
1976 +
1977 + /* only important for AP, IBSS and mesh create IEs internally */
1978 + if (!info->attrs[NL80211_ATTR_CSA_IES])
1979 + return -EINVAL;
1980 +
1981 + /* useless if AP is not running */
1982 + if (!wdev->beacon_interval)
1983 + return -EINVAL;
1984 +
1985 + params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
1986 +
1987 + err = nl80211_parse_beacon(info->attrs, &params.beacon_after);
1988 + if (err)
1989 + return err;
1990 +
1991 + err = nla_parse_nested(csa_attrs, NL80211_ATTR_MAX,
1992 + info->attrs[NL80211_ATTR_CSA_IES],
1993 + nl80211_policy);
1994 + if (err)
1995 + return err;
1996 +
1997 + err = nl80211_parse_beacon(csa_attrs, &params.beacon_csa);
1998 + if (err)
1999 + return err;
2000 +
2001 + if (!csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON])
2002 + return -EINVAL;
2003 +
2004 + params.counter_offset_beacon =
2005 + nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]);
2006 + if (params.counter_offset_beacon >= params.beacon_csa.tail_len)
2007 + return -EINVAL;
2008 +
2009 + /* sanity check - counters should be the same */
2010 + if (params.beacon_csa.tail[params.counter_offset_beacon] !=
2011 + params.count)
2012 + return -EINVAL;
2013 +
2014 + if (csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]) {
2015 + params.counter_offset_presp =
2016 + nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]);
2017 + if (params.counter_offset_presp >=
2018 + params.beacon_csa.probe_resp_len)
2019 + return -EINVAL;
2020 +
2021 + if (params.beacon_csa.probe_resp[params.counter_offset_presp] !=
2022 + params.count)
2023 + return -EINVAL;
2024 + }
2025 +
2026 + err = nl80211_parse_chandef(rdev, info, &params.chandef);
2027 + if (err)
2028 + return err;
2029 +
2030 + if (!cfg80211_reg_can_beacon(&rdev->wiphy, &params.chandef))
2031 + return -EINVAL;
2032 +
2033 + err = cfg80211_chandef_dfs_required(wdev->wiphy, &params.chandef);
2034 + if (err < 0) {
2035 + return err;
2036 + } else if (err) {
2037 + radar_detect_width = BIT(params.chandef.width);
2038 + params.radar_required = true;
2039 + }
2040 +
2041 + err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype,
2042 + params.chandef.chan,
2043 + CHAN_MODE_SHARED,
2044 + radar_detect_width);
2045 + if (err)
2046 + return err;
2047 +
2048 + if (info->attrs[NL80211_ATTR_CH_SWITCH_BLOCK_TX])
2049 + params.block_tx = true;
2050 +
2051 + return rdev_channel_switch(rdev, dev, &params);
2052 +}
2053 +
2054 static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
2055 u32 seq, int flags,
2056 struct cfg80211_registered_device *rdev,
2057 @@ -6507,6 +6623,9 @@ static int nl80211_testmode_dump(struct
2058 NL80211_CMD_TESTMODE);
2059 struct nlattr *tmdata;
2060
2061 + if (!hdr)
2062 + break;
2063 +
2064 if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
2065 genlmsg_cancel(skb, hdr);
2066 break;
2067 @@ -6615,12 +6734,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
2068
2069 void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
2070 {
2071 + struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
2072 void *hdr = ((void **)skb->cb)[1];
2073 struct nlattr *data = ((void **)skb->cb)[2];
2074
2075 nla_nest_end(skb, data);
2076 genlmsg_end(skb, hdr);
2077 - genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
2078 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
2079 + nl80211_testmode_mcgrp.id, gfp);
2080 }
2081 EXPORT_SYMBOL(cfg80211_testmode_event);
2082 #endif
2083 @@ -6949,9 +7070,8 @@ static int nl80211_remain_on_channel(str
2084
2085 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2086 NL80211_CMD_REMAIN_ON_CHANNEL);
2087 -
2088 - if (IS_ERR(hdr)) {
2089 - err = PTR_ERR(hdr);
2090 + if (!hdr) {
2091 + err = -ENOBUFS;
2092 goto free_msg;
2093 }
2094
2095 @@ -7249,9 +7369,8 @@ static int nl80211_tx_mgmt(struct sk_buf
2096
2097 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2098 NL80211_CMD_FRAME);
2099 -
2100 - if (IS_ERR(hdr)) {
2101 - err = PTR_ERR(hdr);
2102 + if (!hdr) {
2103 + err = -ENOBUFS;
2104 goto free_msg;
2105 }
2106 }
2107 @@ -7593,12 +7712,11 @@ static int nl80211_send_wowlan_patterns(
2108 if (!nl_pat)
2109 return -ENOBUFS;
2110 pat_len = wowlan->patterns[i].pattern_len;
2111 - if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
2112 - DIV_ROUND_UP(pat_len, 8),
2113 + if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
2114 wowlan->patterns[i].mask) ||
2115 - nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
2116 - pat_len, wowlan->patterns[i].pattern) ||
2117 - nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
2118 + nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
2119 + wowlan->patterns[i].pattern) ||
2120 + nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
2121 wowlan->patterns[i].pkt_offset))
2122 return -ENOBUFS;
2123 nla_nest_end(msg, nl_pat);
2124 @@ -7939,7 +8057,7 @@ static int nl80211_set_wowlan(struct sk_
2125 struct nlattr *pat;
2126 int n_patterns = 0;
2127 int rem, pat_len, mask_len, pkt_offset;
2128 - struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
2129 + struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
2130
2131 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
2132 rem)
2133 @@ -7958,26 +8076,25 @@ static int nl80211_set_wowlan(struct sk_
2134
2135 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
2136 rem) {
2137 - nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
2138 - nla_data(pat), nla_len(pat), NULL);
2139 + nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
2140 + nla_len(pat), NULL);
2141 err = -EINVAL;
2142 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
2143 - !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
2144 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
2145 + !pat_tb[NL80211_PKTPAT_PATTERN])
2146 goto error;
2147 - pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
2148 + pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
2149 mask_len = DIV_ROUND_UP(pat_len, 8);
2150 - if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
2151 - mask_len)
2152 + if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
2153 goto error;
2154 if (pat_len > wowlan->pattern_max_len ||
2155 pat_len < wowlan->pattern_min_len)
2156 goto error;
2157
2158 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
2159 + if (!pat_tb[NL80211_PKTPAT_OFFSET])
2160 pkt_offset = 0;
2161 else
2162 pkt_offset = nla_get_u32(
2163 - pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
2164 + pat_tb[NL80211_PKTPAT_OFFSET]);
2165 if (pkt_offset > wowlan->max_pkt_offset)
2166 goto error;
2167 new_triggers.patterns[i].pkt_offset = pkt_offset;
2168 @@ -7991,11 +8108,11 @@ static int nl80211_set_wowlan(struct sk_
2169 new_triggers.patterns[i].pattern =
2170 new_triggers.patterns[i].mask + mask_len;
2171 memcpy(new_triggers.patterns[i].mask,
2172 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
2173 + nla_data(pat_tb[NL80211_PKTPAT_MASK]),
2174 mask_len);
2175 new_triggers.patterns[i].pattern_len = pat_len;
2176 memcpy(new_triggers.patterns[i].pattern,
2177 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
2178 + nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
2179 pat_len);
2180 i++;
2181 }
2182 @@ -8130,9 +8247,8 @@ static int nl80211_probe_client(struct s
2183
2184 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2185 NL80211_CMD_PROBE_CLIENT);
2186 -
2187 - if (IS_ERR(hdr)) {
2188 - err = PTR_ERR(hdr);
2189 + if (!hdr) {
2190 + err = -ENOBUFS;
2191 goto free_msg;
2192 }
2193
2194 @@ -9041,7 +9157,15 @@ static struct genl_ops nl80211_ops[] = {
2195 .flags = GENL_ADMIN_PERM,
2196 .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
2197 NL80211_FLAG_NEED_RTNL,
2198 - }
2199 + },
2200 + {
2201 + .cmd = NL80211_CMD_CHANNEL_SWITCH,
2202 + .doit = nl80211_channel_switch,
2203 + .policy = nl80211_policy,
2204 + .flags = GENL_ADMIN_PERM,
2205 + .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
2206 + NL80211_FLAG_NEED_RTNL,
2207 + },
2208 };
2209
2210 static struct genl_multicast_group nl80211_mlme_mcgrp = {
2211 @@ -10066,7 +10190,8 @@ void cfg80211_mgmt_tx_status(struct wire
2212
2213 genlmsg_end(msg, hdr);
2214
2215 - genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
2216 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
2217 + nl80211_mlme_mcgrp.id, gfp);
2218 return;
2219
2220 nla_put_failure:
2221 --- a/net/wireless/reg.c
2222 +++ b/net/wireless/reg.c
2223 @@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev
2224
2225 void wiphy_regulatory_register(struct wiphy *wiphy)
2226 {
2227 + struct regulatory_request *lr;
2228 +
2229 if (!reg_dev_ignore_cell_hint(wiphy))
2230 reg_num_devs_support_basehint++;
2231
2232 - wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
2233 + lr = get_last_request();
2234 + wiphy_update_regulatory(wiphy, lr->initiator);
2235 }
2236
2237 void wiphy_regulatory_deregister(struct wiphy *wiphy)
2238 @@ -2279,7 +2282,9 @@ void wiphy_regulatory_deregister(struct
2239 static void reg_timeout_work(struct work_struct *work)
2240 {
2241 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
2242 + rtnl_lock();
2243 restore_regulatory_settings(true);
2244 + rtnl_unlock();
2245 }
2246
2247 int __init regulatory_init(void)
2248 --- a/net/wireless/sme.c
2249 +++ b/net/wireless/sme.c
2250 @@ -34,8 +34,10 @@ struct cfg80211_conn {
2251 CFG80211_CONN_SCAN_AGAIN,
2252 CFG80211_CONN_AUTHENTICATE_NEXT,
2253 CFG80211_CONN_AUTHENTICATING,
2254 + CFG80211_CONN_AUTH_FAILED,
2255 CFG80211_CONN_ASSOCIATE_NEXT,
2256 CFG80211_CONN_ASSOCIATING,
2257 + CFG80211_CONN_ASSOC_FAILED,
2258 CFG80211_CONN_DEAUTH,
2259 CFG80211_CONN_CONNECTED,
2260 } state;
2261 @@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct
2262 NULL, 0,
2263 params->key, params->key_len,
2264 params->key_idx, NULL, 0);
2265 + case CFG80211_CONN_AUTH_FAILED:
2266 + return -ENOTCONN;
2267 case CFG80211_CONN_ASSOCIATE_NEXT:
2268 BUG_ON(!rdev->ops->assoc);
2269 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
2270 @@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct
2271 WLAN_REASON_DEAUTH_LEAVING,
2272 false);
2273 return err;
2274 + case CFG80211_CONN_ASSOC_FAILED:
2275 + cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
2276 + NULL, 0,
2277 + WLAN_REASON_DEAUTH_LEAVING, false);
2278 + return -ENOTCONN;
2279 case CFG80211_CONN_DEAUTH:
2280 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
2281 NULL, 0,
2282 WLAN_REASON_DEAUTH_LEAVING, false);
2283 + /* free directly, disconnected event already sent */
2284 + cfg80211_sme_free(wdev);
2285 return 0;
2286 default:
2287 return 0;
2288 @@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
2289 return true;
2290 }
2291
2292 - wdev->conn->state = CFG80211_CONN_DEAUTH;
2293 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
2294 schedule_work(&rdev->conn_work);
2295 return false;
2296 }
2297 @@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
2298
2299 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
2300 {
2301 - cfg80211_sme_free(wdev);
2302 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
2303 +
2304 + if (!wdev->conn)
2305 + return;
2306 +
2307 + wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
2308 + schedule_work(&rdev->conn_work);
2309 }
2310
2311 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
2312 @@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
2313
2314 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
2315 {
2316 - cfg80211_sme_disassoc(wdev);
2317 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
2318 +
2319 + if (!wdev->conn)
2320 + return;
2321 +
2322 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
2323 + schedule_work(&rdev->conn_work);
2324 }
2325
2326 static int cfg80211_sme_connect(struct wireless_dev *wdev,
2327 @@ -953,21 +976,19 @@ int cfg80211_disconnect(struct cfg80211_
2328 struct net_device *dev, u16 reason, bool wextev)
2329 {
2330 struct wireless_dev *wdev = dev->ieee80211_ptr;
2331 - int err;
2332 + int err = 0;
2333
2334 ASSERT_WDEV_LOCK(wdev);
2335
2336 kfree(wdev->connect_keys);
2337 wdev->connect_keys = NULL;
2338
2339 - if (wdev->conn) {
2340 + if (wdev->conn)
2341 err = cfg80211_sme_disconnect(wdev, reason);
2342 - } else if (!rdev->ops->disconnect) {
2343 + else if (!rdev->ops->disconnect)
2344 cfg80211_mlme_down(rdev, dev);
2345 - err = 0;
2346 - } else {
2347 + else if (wdev->current_bss)
2348 err = rdev_disconnect(rdev, dev, reason);
2349 - }
2350
2351 return err;
2352 }
2353 --- a/net/mac80211/rc80211_minstrel.c
2354 +++ b/net/mac80211/rc80211_minstrel.c
2355 @@ -203,6 +203,15 @@ minstrel_update_stats(struct minstrel_pr
2356 memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate));
2357 mi->max_prob_rate = tmp_prob_rate;
2358
2359 +#ifdef CPTCFG_MAC80211_DEBUGFS
2360 + /* use fixed index if set */
2361 + if (mp->fixed_rate_idx != -1) {
2362 + mi->max_tp_rate[0] = mp->fixed_rate_idx;
2363 + mi->max_tp_rate[1] = mp->fixed_rate_idx;
2364 + mi->max_prob_rate = mp->fixed_rate_idx;
2365 + }
2366 +#endif
2367 +
2368 /* Reset update timer */
2369 mi->stats_update = jiffies;
2370
2371 @@ -290,7 +299,7 @@ minstrel_get_rate(void *priv, struct iee
2372 struct minstrel_rate *msr, *mr;
2373 unsigned int ndx;
2374 bool mrr_capable;
2375 - bool prev_sample = mi->prev_sample;
2376 + bool prev_sample;
2377 int delta;
2378 int sampling_ratio;
2379
2380 @@ -310,10 +319,16 @@ minstrel_get_rate(void *priv, struct iee
2381 /* increase sum packet counter */
2382 mi->packet_count++;
2383
2384 +#ifdef CPTCFG_MAC80211_DEBUGFS
2385 + if (mp->fixed_rate_idx != -1)
2386 + return;
2387 +#endif
2388 +
2389 delta = (mi->packet_count * sampling_ratio / 100) -
2390 (mi->sample_count + mi->sample_deferred / 2);
2391
2392 /* delta < 0: no sampling required */
2393 + prev_sample = mi->prev_sample;
2394 mi->prev_sample = false;
2395 if (delta < 0 || (!mrr_capable && prev_sample))
2396 return;
2397 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
2398 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
2399 @@ -936,13 +936,8 @@ void rt2x00queue_index_inc(struct queue_
2400 spin_unlock_irqrestore(&queue->index_lock, irqflags);
2401 }
2402
2403 -void rt2x00queue_pause_queue(struct data_queue *queue)
2404 +void rt2x00queue_pause_queue_nocheck(struct data_queue *queue)
2405 {
2406 - if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
2407 - !test_bit(QUEUE_STARTED, &queue->flags) ||
2408 - test_and_set_bit(QUEUE_PAUSED, &queue->flags))
2409 - return;
2410 -
2411 switch (queue->qid) {
2412 case QID_AC_VO:
2413 case QID_AC_VI:
2414 @@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data
2415 break;
2416 }
2417 }
2418 +void rt2x00queue_pause_queue(struct data_queue *queue)
2419 +{
2420 + if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
2421 + !test_bit(QUEUE_STARTED, &queue->flags) ||
2422 + test_and_set_bit(QUEUE_PAUSED, &queue->flags))
2423 + return;
2424 +
2425 + rt2x00queue_pause_queue_nocheck(queue);
2426 +}
2427 EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
2428
2429 void rt2x00queue_unpause_queue(struct data_queue *queue)
2430 @@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_
2431 return;
2432 }
2433
2434 - rt2x00queue_pause_queue(queue);
2435 + rt2x00queue_pause_queue_nocheck(queue);
2436
2437 queue->rt2x00dev->ops->lib->stop_queue(queue);
2438
2439 --- a/net/mac80211/mlme.c
2440 +++ b/net/mac80211/mlme.c
2441 @@ -31,10 +31,12 @@
2442 #include "led.h"
2443
2444 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
2445 +#define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2)
2446 #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
2447 #define IEEE80211_AUTH_MAX_TRIES 3
2448 #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
2449 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
2450 +#define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)
2451 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
2452 #define IEEE80211_ASSOC_MAX_TRIES 3
2453
2454 @@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee
2455 struct ieee80211_channel *channel,
2456 const struct ieee80211_ht_operation *ht_oper,
2457 const struct ieee80211_vht_operation *vht_oper,
2458 - struct cfg80211_chan_def *chandef, bool verbose)
2459 + struct cfg80211_chan_def *chandef, bool tracking)
2460 {
2461 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2462 struct cfg80211_chan_def vht_chandef;
2463 u32 ht_cfreq, ret;
2464
2465 @@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee
2466 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
2467 channel->band);
2468 /* check that channel matches the right operating channel */
2469 - if (channel->center_freq != ht_cfreq) {
2470 + if (!tracking && channel->center_freq != ht_cfreq) {
2471 /*
2472 * It's possible that some APs are confused here;
2473 * Netgear WNDR3700 sometimes reports 4 higher than
2474 @@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee
2475 * since we look at probe response/beacon data here
2476 * it should be OK.
2477 */
2478 - if (verbose)
2479 - sdata_info(sdata,
2480 - "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
2481 - channel->center_freq, ht_cfreq,
2482 - ht_oper->primary_chan, channel->band);
2483 + sdata_info(sdata,
2484 + "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
2485 + channel->center_freq, ht_cfreq,
2486 + ht_oper->primary_chan, channel->band);
2487 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
2488 goto out;
2489 }
2490 @@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee
2491 channel->band);
2492 break;
2493 default:
2494 - if (verbose)
2495 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2496 sdata_info(sdata,
2497 "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
2498 vht_oper->chan_width);
2499 @@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee
2500 }
2501
2502 if (!cfg80211_chandef_valid(&vht_chandef)) {
2503 - if (verbose)
2504 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2505 sdata_info(sdata,
2506 "AP VHT information is invalid, disable VHT\n");
2507 ret = IEEE80211_STA_DISABLE_VHT;
2508 @@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee
2509 }
2510
2511 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
2512 - if (verbose)
2513 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2514 sdata_info(sdata,
2515 "AP VHT information doesn't match HT, disable VHT\n");
2516 ret = IEEE80211_STA_DISABLE_VHT;
2517 @@ -333,18 +335,27 @@ out:
2518 if (ret & IEEE80211_STA_DISABLE_VHT)
2519 vht_chandef = *chandef;
2520
2521 + /*
2522 + * Ignore the DISABLED flag when we're already connected and only
2523 + * tracking the APs beacon for bandwidth changes - otherwise we
2524 + * might get disconnected here if we connect to an AP, update our
2525 + * regulatory information based on the AP's country IE and the
2526 + * information we have is wrong/outdated and disables the channel
2527 + * that we're actually using for the connection to the AP.
2528 + */
2529 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
2530 - IEEE80211_CHAN_DISABLED)) {
2531 + tracking ? 0 :
2532 + IEEE80211_CHAN_DISABLED)) {
2533 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
2534 ret = IEEE80211_STA_DISABLE_HT |
2535 IEEE80211_STA_DISABLE_VHT;
2536 - goto out;
2537 + break;
2538 }
2539
2540 ret |= chandef_downgrade(chandef);
2541 }
2542
2543 - if (chandef->width != vht_chandef.width && verbose)
2544 + if (chandef->width != vht_chandef.width && !tracking)
2545 sdata_info(sdata,
2546 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
2547
2548 @@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ie
2549
2550 /* calculate new channel (type) based on HT/VHT operation IEs */
2551 flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper,
2552 - vht_oper, &chandef, false);
2553 + vht_oper, &chandef, true);
2554
2555 /*
2556 * Downgrade the new channel if we associated with restricted
2557 @@ -1043,6 +1054,13 @@ ieee80211_sta_process_chanswitch(struct
2558 if (!ieee80211_operating_class_to_band(
2559 elems->ext_chansw_ie->new_operating_class,
2560 &new_band)) {
2561 + /*
2562 + * Some APs send invalid ECSA IEs in probe response
2563 + * frames, so check for these and ignore them.
2564 + */
2565 + if (beacon && elems->ext_chansw_ie->new_ch_num == 0 &&
2566 + elems->ext_chansw_ie->new_operating_class == 0)
2567 + return;
2568 sdata_info(sdata,
2569 "cannot understand ECSA IE operating class %d, disconnecting\n",
2570 elems->ext_chansw_ie->new_operating_class);
2571 @@ -1110,6 +1128,15 @@ ieee80211_sta_process_chanswitch(struct
2572 case -1:
2573 cfg80211_chandef_create(&new_chandef, new_chan,
2574 NL80211_CHAN_NO_HT);
2575 + /* keep width for 5/10 MHz channels */
2576 + switch (sdata->vif.bss_conf.chandef.width) {
2577 + case NL80211_CHAN_WIDTH_5:
2578 + case NL80211_CHAN_WIDTH_10:
2579 + new_chandef.width = sdata->vif.bss_conf.chandef.width;
2580 + break;
2581 + default:
2582 + break;
2583 + }
2584 break;
2585 }
2586
2587 @@ -3394,10 +3421,13 @@ static int ieee80211_probe_auth(struct i
2588
2589 if (tx_flags == 0) {
2590 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
2591 - ifmgd->auth_data->timeout_started = true;
2592 + auth_data->timeout_started = true;
2593 run_again(sdata, auth_data->timeout);
2594 } else {
2595 - auth_data->timeout_started = false;
2596 + auth_data->timeout =
2597 + round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
2598 + auth_data->timeout_started = true;
2599 + run_again(sdata, auth_data->timeout);
2600 }
2601
2602 return 0;
2603 @@ -3434,7 +3464,11 @@ static int ieee80211_do_assoc(struct iee
2604 assoc_data->timeout_started = true;
2605 run_again(sdata, assoc_data->timeout);
2606 } else {
2607 - assoc_data->timeout_started = false;
2608 + assoc_data->timeout =
2609 + round_jiffies_up(jiffies +
2610 + IEEE80211_ASSOC_TIMEOUT_LONG);
2611 + assoc_data->timeout_started = true;
2612 + run_again(sdata, assoc_data->timeout);
2613 }
2614
2615 return 0;
2616 @@ -3829,7 +3863,7 @@ static int ieee80211_prep_channel(struct
2617 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
2618 cbss->channel,
2619 ht_oper, vht_oper,
2620 - &chandef, true);
2621 + &chandef, false);
2622
2623 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
2624 local->rx_chains);
2625 --- a/net/wireless/core.c
2626 +++ b/net/wireless/core.c
2627 @@ -772,6 +772,7 @@ void cfg80211_leave(struct cfg80211_regi
2628 cfg80211_leave_mesh(rdev, dev);
2629 break;
2630 case NL80211_IFTYPE_AP:
2631 + case NL80211_IFTYPE_P2P_GO:
2632 cfg80211_stop_ap(rdev, dev);
2633 break;
2634 default:
2635 --- a/drivers/net/wireless/rtlwifi/Kconfig
2636 +++ b/drivers/net/wireless/rtlwifi/Kconfig
2637 @@ -1,29 +1,22 @@
2638 -config RTLWIFI
2639 - tristate "Realtek wireless card support"
2640 +menuconfig RTL_CARDS
2641 + tristate "Realtek rtlwifi family of devices"
2642 depends on m
2643 - depends on MAC80211
2644 - select BACKPORT_FW_LOADER
2645 - ---help---
2646 - This is common code for RTL8192CE/RTL8192CU/RTL8192SE/RTL8723AE
2647 - drivers. This module does nothing by itself - the various front-end
2648 - drivers need to be enabled to support any desired devices.
2649 -
2650 - If you choose to build as a module, it'll be called rtlwifi.
2651 -
2652 -config RTLWIFI_DEBUG
2653 - bool "Debugging output for rtlwifi driver family"
2654 - depends on RTLWIFI
2655 + depends on MAC80211 && (PCI || USB)
2656 default y
2657 ---help---
2658 - To use the module option that sets the dynamic-debugging level for,
2659 - the front-end driver, this parameter must be "Y". For memory-limited
2660 - systems, choose "N". If in doubt, choose "Y".
2661 + This option will enable support for the Realtek mac80211-based
2662 + wireless drivers. Drivers rtl8192ce, rtl8192cu, rtl8192se, rtl8192de,
2663 + rtl8723eu, and rtl8188eu share some common code.
2664 +
2665 +if RTL_CARDS
2666
2667 config RTL8192CE
2668 tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter"
2669 depends on m
2670 - depends on RTLWIFI && PCI
2671 + depends on PCI
2672 select RTL8192C_COMMON
2673 + select RTLWIFI
2674 + select RTLWIFI_PCI
2675 ---help---
2676 This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe
2677 wireless network adapters.
2678 @@ -33,7 +26,9 @@ config RTL8192CE
2679 config RTL8192SE
2680 tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter"
2681 depends on m
2682 - depends on RTLWIFI && PCI
2683 + depends on PCI
2684 + select RTLWIFI
2685 + select RTLWIFI_PCI
2686 ---help---
2687 This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe
2688 wireless network adapters.
2689 @@ -43,7 +38,9 @@ config RTL8192SE
2690 config RTL8192DE
2691 tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter"
2692 depends on m
2693 - depends on RTLWIFI && PCI
2694 + depends on PCI
2695 + select RTLWIFI
2696 + select RTLWIFI_PCI
2697 ---help---
2698 This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe
2699 wireless network adapters.
2700 @@ -53,7 +50,9 @@ config RTL8192DE
2701 config RTL8723AE
2702 tristate "Realtek RTL8723AE PCIe Wireless Network Adapter"
2703 depends on m
2704 - depends on RTLWIFI && PCI
2705 + depends on PCI
2706 + select RTLWIFI
2707 + select RTLWIFI_PCI
2708 ---help---
2709 This is the driver for Realtek RTL8723AE 802.11n PCIe
2710 wireless network adapters.
2711 @@ -63,7 +62,9 @@ config RTL8723AE
2712 config RTL8188EE
2713 tristate "Realtek RTL8188EE Wireless Network Adapter"
2714 depends on m
2715 - depends on RTLWIFI && PCI
2716 + depends on PCI
2717 + select RTLWIFI
2718 + select RTLWIFI_PCI
2719 ---help---
2720 This is the driver for Realtek RTL8188EE 802.11n PCIe
2721 wireless network adapters.
2722 @@ -73,7 +74,9 @@ config RTL8188EE
2723 config RTL8192CU
2724 tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter"
2725 depends on m
2726 - depends on RTLWIFI && USB
2727 + depends on USB
2728 + select RTLWIFI
2729 + select RTLWIFI_USB
2730 select RTL8192C_COMMON
2731 ---help---
2732 This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB
2733 @@ -81,8 +84,32 @@ config RTL8192CU
2734
2735 If you choose to build it as a module, it will be called rtl8192cu
2736
2737 +config RTLWIFI
2738 + tristate
2739 + depends on m
2740 + select BACKPORT_FW_LOADER
2741 +
2742 +config RTLWIFI_PCI
2743 + tristate
2744 + depends on m
2745 +
2746 +config RTLWIFI_USB
2747 + tristate
2748 + depends on m
2749 +
2750 +config RTLWIFI_DEBUG
2751 + bool "Debugging output for rtlwifi driver family"
2752 + depends on RTLWIFI
2753 + default y
2754 + ---help---
2755 + To use the module option that sets the dynamic-debugging level for,
2756 + the front-end driver, this parameter must be "Y". For memory-limited
2757 + systems, choose "N". If in doubt, choose "Y".
2758 +
2759 config RTL8192C_COMMON
2760 tristate
2761 depends on m
2762 depends on RTL8192CE || RTL8192CU
2763 - default m
2764 + default y
2765 +
2766 +endif
2767 --- a/drivers/net/wireless/rtlwifi/Makefile
2768 +++ b/drivers/net/wireless/rtlwifi/Makefile
2769 @@ -12,13 +12,11 @@ rtlwifi-objs := \
2770
2771 rtl8192c_common-objs += \
2772
2773 -ifneq ($(CONFIG_PCI),)
2774 -rtlwifi-objs += pci.o
2775 -endif
2776 +obj-$(CPTCFG_RTLWIFI_PCI) += rtl_pci.o
2777 +rtl_pci-objs := pci.o
2778
2779 -ifneq ($(CONFIG_USB),)
2780 -rtlwifi-objs += usb.o
2781 -endif
2782 +obj-$(CPTCFG_RTLWIFI_USB) += rtl_usb.o
2783 +rtl_usb-objs := usb.o
2784
2785 obj-$(CPTCFG_RTL8192C_COMMON) += rtl8192c/
2786 obj-$(CPTCFG_RTL8192CE) += rtl8192ce/
2787 --- a/drivers/net/wireless/rtlwifi/ps.h
2788 +++ b/drivers/net/wireless/rtlwifi/ps.h
2789 @@ -49,5 +49,6 @@ void rtl_swlps_rf_awake(struct ieee80211
2790 void rtl_swlps_rf_sleep(struct ieee80211_hw *hw);
2791 void rtl_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
2792 void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len);
2793 +void rtl_lps_change_work_callback(struct work_struct *work);
2794
2795 #endif
2796 --- a/drivers/net/wireless/rtlwifi/base.c
2797 +++ b/drivers/net/wireless/rtlwifi/base.c
2798 @@ -173,6 +173,7 @@ u8 rtl_tid_to_ac(u8 tid)
2799 {
2800 return tid_to_ac[tid];
2801 }
2802 +EXPORT_SYMBOL_GPL(rtl_tid_to_ac);
2803
2804 static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
2805 struct ieee80211_sta_ht_cap *ht_cap)
2806 @@ -407,6 +408,7 @@ void rtl_deinit_deferred_work(struct iee
2807 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
2808 cancel_delayed_work(&rtlpriv->works.fwevt_wq);
2809 }
2810 +EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
2811
2812 void rtl_init_rfkill(struct ieee80211_hw *hw)
2813 {
2814 @@ -440,6 +442,7 @@ void rtl_deinit_rfkill(struct ieee80211_
2815 {
2816 wiphy_rfkill_stop_polling(hw->wiphy);
2817 }
2818 +EXPORT_SYMBOL_GPL(rtl_deinit_rfkill);
2819
2820 int rtl_init_core(struct ieee80211_hw *hw)
2821 {
2822 @@ -490,10 +493,12 @@ int rtl_init_core(struct ieee80211_hw *h
2823
2824 return 0;
2825 }
2826 +EXPORT_SYMBOL_GPL(rtl_init_core);
2827
2828 void rtl_deinit_core(struct ieee80211_hw *hw)
2829 {
2830 }
2831 +EXPORT_SYMBOL_GPL(rtl_deinit_core);
2832
2833 void rtl_init_rx_config(struct ieee80211_hw *hw)
2834 {
2835 @@ -502,6 +507,7 @@ void rtl_init_rx_config(struct ieee80211
2836
2837 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf));
2838 }
2839 +EXPORT_SYMBOL_GPL(rtl_init_rx_config);
2840
2841 /*********************************************************
2842 *
2843 @@ -880,6 +886,7 @@ bool rtl_tx_mgmt_proc(struct ieee80211_h
2844
2845 return true;
2846 }
2847 +EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc);
2848
2849 void rtl_get_tcb_desc(struct ieee80211_hw *hw,
2850 struct ieee80211_tx_info *info,
2851 @@ -1053,6 +1060,7 @@ bool rtl_action_proc(struct ieee80211_hw
2852
2853 return true;
2854 }
2855 +EXPORT_SYMBOL_GPL(rtl_action_proc);
2856
2857 /*should call before software enc*/
2858 u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
2859 @@ -1126,6 +1134,7 @@ u8 rtl_is_special_data(struct ieee80211_
2860
2861 return false;
2862 }
2863 +EXPORT_SYMBOL_GPL(rtl_is_special_data);
2864
2865 /*********************************************************
2866 *
2867 @@ -1301,6 +1310,7 @@ void rtl_beacon_statistic(struct ieee802
2868
2869 rtlpriv->link_info.bcn_rx_inperiod++;
2870 }
2871 +EXPORT_SYMBOL_GPL(rtl_beacon_statistic);
2872
2873 void rtl_watchdog_wq_callback(void *data)
2874 {
2875 @@ -1794,6 +1804,7 @@ void rtl_recognize_peer(struct ieee80211
2876
2877 mac->vendor = vendor;
2878 }
2879 +EXPORT_SYMBOL_GPL(rtl_recognize_peer);
2880
2881 /*********************************************************
2882 *
2883 @@ -1850,6 +1861,7 @@ struct attribute_group rtl_attribute_gro
2884 .name = "rtlsysfs",
2885 .attrs = rtl_sysfs_entries,
2886 };
2887 +EXPORT_SYMBOL_GPL(rtl_attribute_group);
2888
2889 MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
2890 MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
2891 @@ -1857,7 +1869,8 @@ MODULE_AUTHOR("Larry Finger <Larry.FInge
2892 MODULE_LICENSE("GPL");
2893 MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
2894
2895 -struct rtl_global_var global_var = {};
2896 +struct rtl_global_var rtl_global_var = {};
2897 +EXPORT_SYMBOL_GPL(rtl_global_var);
2898
2899 static int __init rtl_core_module_init(void)
2900 {
2901 @@ -1865,8 +1878,8 @@ static int __init rtl_core_module_init(v
2902 pr_err("Unable to register rtl_rc, use default RC !!\n");
2903
2904 /* init some global vars */
2905 - INIT_LIST_HEAD(&global_var.glb_priv_list);
2906 - spin_lock_init(&global_var.glb_list_lock);
2907 + INIT_LIST_HEAD(&rtl_global_var.glb_priv_list);
2908 + spin_lock_init(&rtl_global_var.glb_list_lock);
2909
2910 return 0;
2911 }
2912 --- a/drivers/net/wireless/rtlwifi/base.h
2913 +++ b/drivers/net/wireless/rtlwifi/base.h
2914 @@ -147,7 +147,7 @@ void rtl_recognize_peer(struct ieee80211
2915 u8 rtl_tid_to_ac(u8 tid);
2916 extern struct attribute_group rtl_attribute_group;
2917 void rtl_easy_concurrent_retrytimer_callback(unsigned long data);
2918 -extern struct rtl_global_var global_var;
2919 +extern struct rtl_global_var rtl_global_var;
2920 int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
2921 bool isht, u8 desc_rate, bool first_ampdu);
2922 bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
2923 --- a/drivers/net/wireless/rtlwifi/core.c
2924 +++ b/drivers/net/wireless/rtlwifi/core.c
2925 @@ -1330,3 +1330,4 @@ const struct ieee80211_ops rtl_ops = {
2926 .rfkill_poll = rtl_op_rfkill_poll,
2927 .flush = rtl_op_flush,
2928 };
2929 +EXPORT_SYMBOL_GPL(rtl_ops);
2930 --- a/drivers/net/wireless/rtlwifi/debug.c
2931 +++ b/drivers/net/wireless/rtlwifi/debug.c
2932 @@ -51,3 +51,4 @@ void rtl_dbgp_flag_init(struct ieee80211
2933
2934 /*Init Debug flag enable condition */
2935 }
2936 +EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
2937 --- a/drivers/net/wireless/rtlwifi/efuse.c
2938 +++ b/drivers/net/wireless/rtlwifi/efuse.c
2939 @@ -229,6 +229,7 @@ void read_efuse_byte(struct ieee80211_hw
2940
2941 *pbuf = (u8) (value32 & 0xff);
2942 }
2943 +EXPORT_SYMBOL_GPL(read_efuse_byte);
2944
2945 void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
2946 {
2947 --- a/drivers/net/wireless/rtlwifi/pci.c
2948 +++ b/drivers/net/wireless/rtlwifi/pci.c
2949 @@ -35,6 +35,13 @@
2950 #include "efuse.h"
2951 #include <linux/export.h>
2952 #include <linux/kmemleak.h>
2953 +#include <linux/module.h>
2954 +
2955 +MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
2956 +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
2957 +MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
2958 +MODULE_LICENSE("GPL");
2959 +MODULE_DESCRIPTION("PCI basic driver for rtlwifi");
2960
2961 static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = {
2962 PCI_VENDOR_ID_INTEL,
2963 @@ -1008,19 +1015,6 @@ static void _rtl_pci_prepare_bcn_tasklet
2964 return;
2965 }
2966
2967 -static void rtl_lps_change_work_callback(struct work_struct *work)
2968 -{
2969 - struct rtl_works *rtlworks =
2970 - container_of(work, struct rtl_works, lps_change_work);
2971 - struct ieee80211_hw *hw = rtlworks->hw;
2972 - struct rtl_priv *rtlpriv = rtl_priv(hw);
2973 -
2974 - if (rtlpriv->enter_ps)
2975 - rtl_lps_enter(hw);
2976 - else
2977 - rtl_lps_leave(hw);
2978 -}
2979 -
2980 static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
2981 {
2982 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
2983 @@ -1899,7 +1893,7 @@ int rtl_pci_probe(struct pci_dev *pdev,
2984 rtlpriv->rtlhal.interface = INTF_PCI;
2985 rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data);
2986 rtlpriv->intf_ops = &rtl_pci_ops;
2987 - rtlpriv->glb_var = &global_var;
2988 + rtlpriv->glb_var = &rtl_global_var;
2989
2990 /*
2991 *init dbgp flags before all
2992 --- a/drivers/net/wireless/rtlwifi/ps.c
2993 +++ b/drivers/net/wireless/rtlwifi/ps.c
2994 @@ -269,6 +269,7 @@ void rtl_ips_nic_on(struct ieee80211_hw
2995
2996 spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags);
2997 }
2998 +EXPORT_SYMBOL_GPL(rtl_ips_nic_on);
2999
3000 /*for FW LPS*/
3001
3002 @@ -518,6 +519,7 @@ void rtl_swlps_beacon(struct ieee80211_h
3003 "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed);
3004 }
3005 }
3006 +EXPORT_SYMBOL_GPL(rtl_swlps_beacon);
3007
3008 void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
3009 {
3010 @@ -611,6 +613,19 @@ void rtl_swlps_rf_sleep(struct ieee80211
3011 MSECS(sleep_intv * mac->vif->bss_conf.beacon_int - 40));
3012 }
3013
3014 +void rtl_lps_change_work_callback(struct work_struct *work)
3015 +{
3016 + struct rtl_works *rtlworks =
3017 + container_of(work, struct rtl_works, lps_change_work);
3018 + struct ieee80211_hw *hw = rtlworks->hw;
3019 + struct rtl_priv *rtlpriv = rtl_priv(hw);
3020 +
3021 + if (rtlpriv->enter_ps)
3022 + rtl_lps_enter(hw);
3023 + else
3024 + rtl_lps_leave(hw);
3025 +}
3026 +EXPORT_SYMBOL_GPL(rtl_lps_change_work_callback);
3027
3028 void rtl_swlps_wq_callback(void *data)
3029 {
3030 @@ -922,3 +937,4 @@ void rtl_p2p_info(struct ieee80211_hw *h
3031 else
3032 rtl_p2p_noa_ie(hw, data, len - FCS_LEN);
3033 }
3034 +EXPORT_SYMBOL_GPL(rtl_p2p_info);
3035 --- a/drivers/net/wireless/rtlwifi/usb.c
3036 +++ b/drivers/net/wireless/rtlwifi/usb.c
3037 @@ -32,6 +32,13 @@
3038 #include "ps.h"
3039 #include "rtl8192c/fw_common.h"
3040 #include <linux/export.h>
3041 +#include <linux/module.h>
3042 +
3043 +MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
3044 +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
3045 +MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
3046 +MODULE_LICENSE("GPL");
3047 +MODULE_DESCRIPTION("USB basic driver for rtlwifi");
3048
3049 #define REALTEK_USB_VENQT_READ 0xC0
3050 #define REALTEK_USB_VENQT_WRITE 0x40
3051 @@ -1070,6 +1077,8 @@ int rtl_usb_probe(struct usb_interface *
3052 spin_lock_init(&rtlpriv->locks.usb_lock);
3053 INIT_WORK(&rtlpriv->works.fill_h2c_cmd,
3054 rtl_fill_h2c_cmd_work_callback);
3055 + INIT_WORK(&rtlpriv->works.lps_change_work,
3056 + rtl_lps_change_work_callback);
3057
3058 rtlpriv->usb_data_index = 0;
3059 init_completion(&rtlpriv->firmware_loading_complete);
3060 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
3061 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3062 @@ -72,17 +72,12 @@ struct ath_config {
3063 /*************************/
3064
3065 #define ATH_TXBUF_RESET(_bf) do { \
3066 - (_bf)->bf_stale = false; \
3067 (_bf)->bf_lastbf = NULL; \
3068 (_bf)->bf_next = NULL; \
3069 memset(&((_bf)->bf_state), 0, \
3070 sizeof(struct ath_buf_state)); \
3071 } while (0)
3072
3073 -#define ATH_RXBUF_RESET(_bf) do { \
3074 - (_bf)->bf_stale = false; \
3075 - } while (0)
3076 -
3077 /**
3078 * enum buffer_type - Buffer type flags
3079 *
3080 @@ -137,7 +132,8 @@ int ath_descdma_setup(struct ath_softc *
3081 #define ATH_AGGR_ENCRYPTDELIM 10
3082 /* minimum h/w qdepth to be sustained to maximize aggregation */
3083 #define ATH_AGGR_MIN_QDEPTH 2
3084 -#define ATH_AMPDU_SUBFRAME_DEFAULT 32
3085 +/* minimum h/w qdepth for non-aggregated traffic */
3086 +#define ATH_NON_AGGR_MIN_QDEPTH 8
3087
3088 #define IEEE80211_SEQ_SEQ_SHIFT 4
3089 #define IEEE80211_SEQ_MAX 4096
3090 @@ -174,12 +170,6 @@ int ath_descdma_setup(struct ath_softc *
3091
3092 #define ATH_TX_COMPLETE_POLL_INT 1000
3093
3094 -enum ATH_AGGR_STATUS {
3095 - ATH_AGGR_DONE,
3096 - ATH_AGGR_BAW_CLOSED,
3097 - ATH_AGGR_LIMITED,
3098 -};
3099 -
3100 #define ATH_TXFIFO_DEPTH 8
3101 struct ath_txq {
3102 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */
3103 @@ -201,10 +191,10 @@ struct ath_txq {
3104
3105 struct ath_atx_ac {
3106 struct ath_txq *txq;
3107 - int sched;
3108 struct list_head list;
3109 struct list_head tid_q;
3110 bool clear_ps_filter;
3111 + bool sched;
3112 };
3113
3114 struct ath_frame_info {
3115 @@ -212,14 +202,16 @@ struct ath_frame_info {
3116 int framelen;
3117 enum ath9k_key_type keytype;
3118 u8 keyix;
3119 - u8 retries;
3120 u8 rtscts_rate;
3121 + u8 retries : 7;
3122 + u8 baw_tracked : 1;
3123 };
3124
3125 struct ath_buf_state {
3126 u8 bf_type;
3127 u8 bfs_paprd;
3128 u8 ndelim;
3129 + bool stale;
3130 u16 seqno;
3131 unsigned long bfs_paprd_timestamp;
3132 };
3133 @@ -233,7 +225,6 @@ struct ath_buf {
3134 void *bf_desc; /* virtual addr of desc */
3135 dma_addr_t bf_daddr; /* physical addr of desc */
3136 dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */
3137 - bool bf_stale;
3138 struct ieee80211_tx_rate rates[4];
3139 struct ath_buf_state bf_state;
3140 };
3141 @@ -241,16 +232,18 @@ struct ath_buf {
3142 struct ath_atx_tid {
3143 struct list_head list;
3144 struct sk_buff_head buf_q;
3145 + struct sk_buff_head retry_q;
3146 struct ath_node *an;
3147 struct ath_atx_ac *ac;
3148 unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
3149 - int bar_index;
3150 u16 seq_start;
3151 u16 seq_next;
3152 u16 baw_size;
3153 - int tidno;
3154 + u8 tidno;
3155 int baw_head; /* first un-acked tx buffer */
3156 int baw_tail; /* next unused tx buffer slot */
3157 +
3158 + s8 bar_index;
3159 bool sched;
3160 bool paused;
3161 bool active;
3162 @@ -262,12 +255,13 @@ struct ath_node {
3163 struct ieee80211_vif *vif; /* interface with which we're associated */
3164 struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
3165 struct ath_atx_ac ac[IEEE80211_NUM_ACS];
3166 - int ps_key;
3167
3168 u16 maxampdu;
3169 u8 mpdudensity;
3170 + s8 ps_key;
3171
3172 bool sleeping;
3173 + bool no_ps_filter;
3174
3175 #if defined(CPTCFG_MAC80211_DEBUGFS) && defined(CPTCFG_ATH9K_DEBUGFS)
3176 struct dentry *node_stat;
3177 @@ -317,6 +311,7 @@ struct ath_rx {
3178 struct ath_descdma rxdma;
3179 struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX];
3180
3181 + struct ath_buf *buf_hold;
3182 struct sk_buff *frag;
3183
3184 u32 ampdu_ref;
3185 @@ -367,6 +362,7 @@ void ath9k_release_buffered_frames(struc
3186 /********/
3187
3188 struct ath_vif {
3189 + struct ath_node mcast_node;
3190 int av_bslot;
3191 bool primary_sta_vif;
3192 __le64 tsf_adjust; /* TSF adjustment for staggered beacons */
3193 @@ -585,19 +581,14 @@ static inline void ath_fill_led_pin(stru
3194 #define ATH_ANT_DIV_COMB_MAX_COUNT 100
3195 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30
3196 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20
3197 +#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50
3198 +#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50
3199
3200 #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1
3201 #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4
3202 #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2
3203 #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2
3204
3205 -enum ath9k_ant_div_comb_lna_conf {
3206 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2,
3207 - ATH_ANT_DIV_COMB_LNA2,
3208 - ATH_ANT_DIV_COMB_LNA1,
3209 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2,
3210 -};
3211 -
3212 struct ath_ant_comb {
3213 u16 count;
3214 u16 total_pkt_count;
3215 @@ -614,27 +605,36 @@ struct ath_ant_comb {
3216 int rssi_first;
3217 int rssi_second;
3218 int rssi_third;
3219 + int ant_ratio;
3220 + int ant_ratio2;
3221 bool alt_good;
3222 int quick_scan_cnt;
3223 - int main_conf;
3224 + enum ath9k_ant_div_comb_lna_conf main_conf;
3225 enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf;
3226 enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf;
3227 bool first_ratio;
3228 bool second_ratio;
3229 unsigned long scan_start_time;
3230 +
3231 + /*
3232 + * Card-specific config values.
3233 + */
3234 + int low_rssi_thresh;
3235 + int fast_div_bias;
3236 };
3237
3238 void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
3239 -void ath_ant_comb_update(struct ath_softc *sc);
3240
3241 /********************/
3242 /* Main driver core */
3243 /********************/
3244
3245 -#define ATH9K_PCI_CUS198 0x0001
3246 -#define ATH9K_PCI_CUS230 0x0002
3247 -#define ATH9K_PCI_CUS217 0x0004
3248 -#define ATH9K_PCI_WOW 0x0008
3249 +#define ATH9K_PCI_CUS198 0x0001
3250 +#define ATH9K_PCI_CUS230 0x0002
3251 +#define ATH9K_PCI_CUS217 0x0004
3252 +#define ATH9K_PCI_WOW 0x0008
3253 +#define ATH9K_PCI_BT_ANT_DIV 0x0010
3254 +#define ATH9K_PCI_D3_L1_WAR 0x0020
3255
3256 /*
3257 * Default cache line size, in bytes.
3258 --- a/drivers/net/wireless/ath/ath9k/debug.c
3259 +++ b/drivers/net/wireless/ath/ath9k/debug.c
3260 @@ -270,25 +270,29 @@ static const struct file_operations fops
3261 .llseek = default_llseek,
3262 };
3263
3264 -static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
3265 - size_t count, loff_t *ppos)
3266 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
3267 +
3268 +static ssize_t read_file_bt_ant_diversity(struct file *file,
3269 + char __user *user_buf,
3270 + size_t count, loff_t *ppos)
3271 {
3272 struct ath_softc *sc = file->private_data;
3273 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
3274 char buf[32];
3275 unsigned int len;
3276
3277 - len = sprintf(buf, "%d\n", common->antenna_diversity);
3278 + len = sprintf(buf, "%d\n", common->bt_ant_diversity);
3279 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
3280 }
3281
3282 -static ssize_t write_file_ant_diversity(struct file *file,
3283 - const char __user *user_buf,
3284 - size_t count, loff_t *ppos)
3285 +static ssize_t write_file_bt_ant_diversity(struct file *file,
3286 + const char __user *user_buf,
3287 + size_t count, loff_t *ppos)
3288 {
3289 struct ath_softc *sc = file->private_data;
3290 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
3291 - unsigned long antenna_diversity;
3292 + struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps;
3293 + unsigned long bt_ant_diversity;
3294 char buf[32];
3295 ssize_t len;
3296
3297 @@ -296,26 +300,147 @@ static ssize_t write_file_ant_diversity(
3298 if (copy_from_user(buf, user_buf, len))
3299 return -EFAULT;
3300
3301 - if (!AR_SREV_9565(sc->sc_ah))
3302 + if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV))
3303 goto exit;
3304
3305 buf[len] = '\0';
3306 - if (strict_strtoul(buf, 0, &antenna_diversity))
3307 + if (kstrtoul(buf, 0, &bt_ant_diversity))
3308 return -EINVAL;
3309
3310 - common->antenna_diversity = !!antenna_diversity;
3311 + common->bt_ant_diversity = !!bt_ant_diversity;
3312 ath9k_ps_wakeup(sc);
3313 - ath_ant_comb_update(sc);
3314 - ath_dbg(common, CONFIG, "Antenna diversity: %d\n",
3315 - common->antenna_diversity);
3316 + ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity);
3317 + ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n",
3318 + common->bt_ant_diversity);
3319 ath9k_ps_restore(sc);
3320 exit:
3321 return count;
3322 }
3323
3324 -static const struct file_operations fops_ant_diversity = {
3325 - .read = read_file_ant_diversity,
3326 - .write = write_file_ant_diversity,
3327 +static const struct file_operations fops_bt_ant_diversity = {
3328 + .read = read_file_bt_ant_diversity,
3329 + .write = write_file_bt_ant_diversity,
3330 + .open = simple_open,
3331 + .owner = THIS_MODULE,
3332 + .llseek = default_llseek,
3333 +};
3334 +
3335 +#endif
3336 +
3337 +void ath9k_debug_stat_ant(struct ath_softc *sc,
3338 + struct ath_hw_antcomb_conf *div_ant_conf,
3339 + int main_rssi_avg, int alt_rssi_avg)
3340 +{
3341 + struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
3342 + struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
3343 +
3344 + as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++;
3345 + as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++;
3346 +
3347 + as_main->rssi_avg = main_rssi_avg;
3348 + as_alt->rssi_avg = alt_rssi_avg;
3349 +}
3350 +
3351 +static ssize_t read_file_antenna_diversity(struct file *file,
3352 + char __user *user_buf,
3353 + size_t count, loff_t *ppos)
3354 +{
3355 + struct ath_softc *sc = file->private_data;
3356 + struct ath_hw *ah = sc->sc_ah;
3357 + struct ath9k_hw_capabilities *pCap = &ah->caps;
3358 + struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
3359 + struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
3360 + struct ath_hw_antcomb_conf div_ant_conf;
3361 + unsigned int len = 0, size = 1024;
3362 + ssize_t retval = 0;
3363 + char *buf;
3364 + char *lna_conf_str[4] = {"LNA1_MINUS_LNA2",
3365 + "LNA2",
3366 + "LNA1",
3367 + "LNA1_PLUS_LNA2"};
3368 +
3369 + buf = kzalloc(size, GFP_KERNEL);
3370 + if (buf == NULL)
3371 + return -ENOMEM;
3372 +
3373 + if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) {
3374 + len += snprintf(buf + len, size - len, "%s\n",
3375 + "Antenna Diversity Combining is disabled");
3376 + goto exit;
3377 + }
3378 +
3379 + ath9k_ps_wakeup(sc);
3380 + ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
3381 + len += snprintf(buf + len, size - len, "Current MAIN config : %s\n",
3382 + lna_conf_str[div_ant_conf.main_lna_conf]);
3383 + len += snprintf(buf + len, size - len, "Current ALT config : %s\n",
3384 + lna_conf_str[div_ant_conf.alt_lna_conf]);
3385 + len += snprintf(buf + len, size - len, "Average MAIN RSSI : %d\n",
3386 + as_main->rssi_avg);
3387 + len += snprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n",
3388 + as_alt->rssi_avg);
3389 + ath9k_ps_restore(sc);
3390 +
3391 + len += snprintf(buf + len, size - len, "Packet Receive Cnt:\n");
3392 + len += snprintf(buf + len, size - len, "-------------------\n");
3393 +
3394 + len += snprintf(buf + len, size - len, "%30s%15s\n",
3395 + "MAIN", "ALT");
3396 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3397 + "TOTAL COUNT",
3398 + as_main->recv_cnt,
3399 + as_alt->recv_cnt);
3400 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3401 + "LNA1",
3402 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1],
3403 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]);
3404 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3405 + "LNA2",
3406 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2],
3407 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]);
3408 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3409 + "LNA1 + LNA2",
3410 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
3411 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
3412 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3413 + "LNA1 - LNA2",
3414 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
3415 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
3416 +
3417 + len += snprintf(buf + len, size - len, "\nLNA Config Attempts:\n");
3418 + len += snprintf(buf + len, size - len, "--------------------\n");
3419 +
3420 + len += snprintf(buf + len, size - len, "%30s%15s\n",
3421 + "MAIN", "ALT");
3422 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3423 + "LNA1",
3424 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1],
3425 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]);
3426 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3427 + "LNA2",
3428 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2],
3429 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]);
3430 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3431 + "LNA1 + LNA2",
3432 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
3433 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
3434 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3435 + "LNA1 - LNA2",
3436 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
3437 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
3438 +
3439 +exit:
3440 + if (len > size)
3441 + len = size;
3442 +
3443 + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
3444 + kfree(buf);
3445 +
3446 + return retval;
3447 +}
3448 +
3449 +static const struct file_operations fops_antenna_diversity = {
3450 + .read = read_file_antenna_diversity,
3451 .open = simple_open,
3452 .owner = THIS_MODULE,
3453 .llseek = default_llseek,
3454 @@ -607,6 +732,28 @@ static ssize_t read_file_xmit(struct fil
3455 return retval;
3456 }
3457
3458 +static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq,
3459 + char *buf, ssize_t size)
3460 +{
3461 + ssize_t len = 0;
3462 +
3463 + ath_txq_lock(sc, txq);
3464 +
3465 + len += snprintf(buf + len, size - len, "%s: %d ",
3466 + "qnum", txq->axq_qnum);
3467 + len += snprintf(buf + len, size - len, "%s: %2d ",
3468 + "qdepth", txq->axq_depth);
3469 + len += snprintf(buf + len, size - len, "