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