1 --- a/net/mac80211/agg-rx.c
2 +++ b/net/mac80211/agg-rx.c
3 @@ -204,6 +204,8 @@ static void ieee80211_send_addba_resp(st
4 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
5 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
6 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
7 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
8 + memcpy(mgmt->bssid, da, ETH_ALEN);
10 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
11 IEEE80211_STYPE_ACTION);
12 --- a/net/mac80211/agg-tx.c
13 +++ b/net/mac80211/agg-tx.c
14 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
15 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
16 if (sdata->vif.type == NL80211_IFTYPE_AP ||
17 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
18 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
19 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
20 + sdata->vif.type == NL80211_IFTYPE_WDS)
21 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
22 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
23 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
24 @@ -527,6 +528,7 @@ int ieee80211_start_tx_ba_session(struct
25 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
26 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
27 sdata->vif.type != NL80211_IFTYPE_AP &&
28 + sdata->vif.type != NL80211_IFTYPE_WDS &&
29 sdata->vif.type != NL80211_IFTYPE_ADHOC)
32 --- a/net/mac80211/debugfs_sta.c
33 +++ b/net/mac80211/debugfs_sta.c
34 @@ -66,11 +66,11 @@ static ssize_t sta_flags_read(struct fil
35 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
37 int res = scnprintf(buf, sizeof(buf),
38 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
39 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
40 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
41 TEST(PS_DRIVER), TEST(AUTHORIZED),
43 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
44 + TEST(WME), TEST(CLEAR_PS_FILT),
45 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
46 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
47 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
48 @@ -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);
52 + if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
53 + debugfs_create_x32("driver_buffered_tids", 0400,
55 + (u32 *)&sta->driver_buffered_tids);
57 + debugfs_create_x64("driver_buffered_tids", 0400,
59 + (u64 *)&sta->driver_buffered_tids);
61 drv_sta_add_debugfs(local, sdata, &sta->sta, sta->debugfs.dir);
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)
71 + * will not add another interface while any channel
74 + if (nsdata->vif.csa_active)
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;
86 u32 hw_reconf_flags = 0;
87 @@ -629,30 +634,8 @@ int ieee80211_do_open(struct wireless_de
89 set_bit(SDATA_STATE_RUNNING, &sdata->state);
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,
97 - goto err_del_interface;
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);
104 - res = sta_info_insert(sta);
106 - /* STA has been freed */
107 - goto err_del_interface;
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);
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);
122 cancel_work_sync(&sdata->recalc_smps);
123 + sdata->vif.csa_active = false;
124 + cancel_work_sync(&sdata->csa_finalize_work);
126 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
128 @@ -1116,6 +1101,74 @@ static void ieee80211_if_setup(struct ne
129 dev->destructor = free_netdev;
132 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
133 + struct sk_buff *skb)
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;
144 + enum ieee80211_band band;
145 + struct ieee80211_supported_band *sband;
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;
153 + if (stype != IEEE80211_STYPE_BEACON)
156 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
157 + if (baselen > skb->len)
160 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
161 + skb->len - baselen, false, &elems);
163 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
167 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
171 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
179 + sta->last_rx = jiffies;
180 + sta->sta.supp_rates[band] = rates;
182 + if (elems.ht_cap_elem)
183 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
184 + elems.ht_cap_elem, sta);
186 + if (elems.wmm_param)
187 + set_sta_flag(sta, WLAN_STA_WME);
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);
200 static void ieee80211_iface_work(struct work_struct *work)
202 struct ieee80211_sub_if_data *sdata =
203 @@ -1220,6 +1273,9 @@ static void ieee80211_iface_work(struct
205 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
207 + case NL80211_IFTYPE_WDS:
208 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
211 WARN(1, "frame for unexpected interface type");
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);
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
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;
236 mi->stats_update = jiffies;
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);
242 +#ifdef CPTCFG_MAC80211_DEBUGFS
243 + if (mp->fixed_rate_idx != -1)
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
252 sample_idx = minstrel_get_sample_rate(mp, mi);
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;
267 @@ -804,10 +807,18 @@ minstrel_ht_get_rate(void *priv, struct
269 sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
270 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
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];
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;
287 @@ -820,6 +831,9 @@ minstrel_ht_update_cck(struct minstrel_p
288 if (sband->band != IEEE80211_BAND_2GHZ)
291 + if (!(mp->hw->flags & IEEE80211_HW_SUPPORTS_HT_CCK_RATES))
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);
303 - /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
304 - if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
306 + * Drop duplicate 802.11 retransmissions
307 + * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
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] ==
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)
324 @@ -2720,14 +2727,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
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;
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 */
340 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
341 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
342 @@ -3008,6 +3016,9 @@ static int prepare_for_handlers(struct i
343 case NL80211_IFTYPE_ADHOC:
346 + if (ether_addr_equal(sdata->vif.addr, hdr->addr2) ||
347 + ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2))
349 if (ieee80211_is_beacon(hdr->frame_control)) {
351 } else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) {
352 @@ -3059,10 +3070,16 @@ static int prepare_for_handlers(struct i
355 case NL80211_IFTYPE_WDS:
356 - if (bssid || !ieee80211_is_data(hdr->frame_control))
358 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
361 + if (ieee80211_is_data(hdr->frame_control) ||
362 + ieee80211_is_action(hdr->frame_control)) {
363 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
365 + } else if (!ieee80211_is_beacon(hdr->frame_control))
369 case NL80211_IFTYPE_P2P_DEVICE:
370 if (!ieee80211_is_public_action(hdr, skb->len) &&
371 --- a/net/mac80211/sta_info.h
372 +++ b/net/mac80211/sta_info.h
374 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
376 * @WLAN_STA_WME: Station is a QoS-STA.
377 - * @WLAN_STA_WDS: Station is one of our WDS peers.
378 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
379 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
380 * frame to this station is transmitted.
381 @@ -66,7 +65,6 @@ enum ieee80211_sta_info_flags {
383 WLAN_STA_SHORT_PREAMBLE,
386 WLAN_STA_CLEAR_PS_FILT,
389 --- a/drivers/net/wireless/ath/ath9k/xmit.c
390 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
391 @@ -135,6 +135,9 @@ static struct ath_frame_info *get_frame_
393 static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno)
398 ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno,
399 seqno << IEEE80211_SEQ_SEQ_SHIFT);
401 @@ -146,6 +149,93 @@ static void ath_set_rates(struct ieee802
402 ARRAY_SIZE(bf->rates));
405 +static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
406 + struct sk_buff *skb)
410 + q = skb_get_queue_mapping(skb);
411 + if (txq == sc->tx.uapsdq)
412 + txq = sc->tx.txq_map[q];
414 + if (txq != sc->tx.txq_map[q])
417 + if (WARN_ON(--txq->pending_frames < 0))
418 + txq->pending_frames = 0;
420 + if (txq->stopped &&
421 + txq->pending_frames < sc->tx.txq_max_pending[q]) {
422 + ieee80211_wake_queue(sc->hw, q);
423 + txq->stopped = false;
427 +static struct ath_atx_tid *
428 +ath_get_skb_tid(struct ath_softc *sc, struct ath_node *an, struct sk_buff *skb)
430 + struct ieee80211_hdr *hdr;
433 + hdr = (struct ieee80211_hdr *) skb->data;
434 + if (ieee80211_is_data_qos(hdr->frame_control))
435 + tidno = ieee80211_get_qos_ctl(hdr)[0];
437 + tidno &= IEEE80211_QOS_CTL_TID_MASK;
438 + return ATH_AN_2_TID(an, tidno);
441 +static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
443 + return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
446 +static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
448 + struct sk_buff *skb;
450 + skb = __skb_dequeue(&tid->retry_q);
452 + skb = __skb_dequeue(&tid->buf_q);
458 + * ath_tx_tid_change_state:
459 + * - clears a-mpdu flag of previous session
460 + * - force sequence number allocation to fix next BlockAck Window
463 +ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
465 + struct ath_txq *txq = tid->ac->txq;
466 + struct ieee80211_tx_info *tx_info;
467 + struct sk_buff *skb, *tskb;
468 + struct ath_buf *bf;
469 + struct ath_frame_info *fi;
471 + skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
472 + fi = get_frame_info(skb);
475 + tx_info = IEEE80211_SKB_CB(skb);
476 + tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
481 + bf = ath_tx_setup_buffer(sc, txq, tid, skb);
483 + __skb_unlink(skb, &tid->buf_q);
484 + ath_txq_skb_done(sc, txq, skb);
485 + ieee80211_free_txskb(sc->hw, skb);
492 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
494 struct ath_txq *txq = tid->ac->txq;
495 @@ -160,27 +250,22 @@ static void ath_tx_flush_tid(struct ath_
497 memset(&ts, 0, sizeof(ts));
499 - while ((skb = __skb_dequeue(&tid->buf_q))) {
500 + while ((skb = __skb_dequeue(&tid->retry_q))) {
501 fi = get_frame_info(skb);
505 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
507 - ieee80211_free_txskb(sc->hw, skb);
510 + ath_txq_skb_done(sc, txq, skb);
511 + ieee80211_free_txskb(sc->hw, skb);
516 - list_add_tail(&bf->list, &bf_head);
517 + if (fi->baw_tracked) {
518 ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
519 - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
522 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
523 - ath_tx_send_normal(sc, txq, NULL, skb);
526 + list_add_tail(&bf->list, &bf_head);
527 + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
531 @@ -209,13 +294,16 @@ static void ath_tx_update_baw(struct ath
534 static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
536 + struct ath_buf *bf)
538 + struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
539 + u16 seqno = bf->bf_state.seqno;
542 index = ATH_BA_INDEX(tid->seq_start, seqno);
543 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
544 __set_bit(cindex, tid->tx_buf);
545 + fi->baw_tracked = 1;
547 if (index >= ((tid->baw_tail - tid->baw_head) &
548 (ATH_TID_MAX_BUFS - 1))) {
549 @@ -224,12 +312,6 @@ static void ath_tx_addto_baw(struct ath_
554 - * TODO: For frame(s) that are in the retry state, we will reuse the
555 - * sequence number(s) without setting the retry bit. The
556 - * alternative is to give up on these and BAR the receiver's window
559 static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq,
560 struct ath_atx_tid *tid)
562 @@ -243,7 +325,7 @@ static void ath_tid_drain(struct ath_sof
563 memset(&ts, 0, sizeof(ts));
564 INIT_LIST_HEAD(&bf_head);
566 - while ((skb = __skb_dequeue(&tid->buf_q))) {
567 + while ((skb = ath_tid_dequeue(tid))) {
568 fi = get_frame_info(skb);
571 @@ -253,14 +335,8 @@ static void ath_tid_drain(struct ath_sof
574 list_add_tail(&bf->list, &bf_head);
576 - ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
577 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
580 - tid->seq_next = tid->seq_start;
581 - tid->baw_tail = tid->baw_head;
582 - tid->bar_index = -1;
585 static void ath_tx_set_retry(struct ath_softc *sc, struct ath_txq *txq,
586 @@ -323,6 +399,7 @@ static struct ath_buf* ath_clone_txbuf(s
587 tbf->bf_buf_addr = bf->bf_buf_addr;
588 memcpy(tbf->bf_desc, bf->bf_desc, sc->sc_ah->caps.tx_desc_len);
589 tbf->bf_state = bf->bf_state;
590 + tbf->bf_state.stale = false;
594 @@ -380,7 +457,6 @@ static void ath_tx_complete_aggr(struct
595 struct ieee80211_tx_rate rates[4];
596 struct ath_frame_info *fi;
599 bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH);
602 @@ -406,7 +482,7 @@ static void ath_tx_complete_aggr(struct
604 bf_next = bf->bf_next;
606 - if (!bf->bf_stale || bf_next != NULL)
607 + if (!bf->bf_state.stale || bf_next != NULL)
608 list_move_tail(&bf->list, &bf_head);
610 ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0);
611 @@ -417,8 +493,7 @@ static void ath_tx_complete_aggr(struct
614 an = (struct ath_node *)sta->drv_priv;
615 - tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
616 - tid = ATH_AN_2_TID(an, tidno);
617 + tid = ath_get_skb_tid(sc, an, skb);
618 seq_first = tid->seq_start;
619 isba = ts->ts_flags & ATH9K_TX_BA;
621 @@ -430,7 +505,7 @@ static void ath_tx_complete_aggr(struct
622 * Only BlockAcks have a TID and therefore normal Acks cannot be
625 - if (isba && tidno != ts->tid)
626 + if (isba && tid->tidno != ts->tid)
629 isaggr = bf_isaggr(bf);
630 @@ -466,7 +541,8 @@ static void ath_tx_complete_aggr(struct
631 tx_info = IEEE80211_SKB_CB(skb);
632 fi = get_frame_info(skb);
634 - if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
635 + if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) ||
638 * Outside of the current BlockAck window,
639 * maybe part of a previous session
640 @@ -499,7 +575,7 @@ static void ath_tx_complete_aggr(struct
641 * not a holding desc.
643 INIT_LIST_HEAD(&bf_head);
644 - if (bf_next != NULL || !bf_last->bf_stale)
645 + if (bf_next != NULL || !bf_last->bf_state.stale)
646 list_move_tail(&bf->list, &bf_head);
649 @@ -523,7 +599,7 @@ static void ath_tx_complete_aggr(struct
650 ieee80211_sta_eosp(sta);
652 /* retry the un-acked ones */
653 - if (bf->bf_next == NULL && bf_last->bf_stale) {
654 + if (bf->bf_next == NULL && bf_last->bf_state.stale) {
657 tbf = ath_clone_txbuf(sc, bf_last);
658 @@ -560,7 +636,7 @@ static void ath_tx_complete_aggr(struct
660 ieee80211_sta_set_buffered(sta, tid->tidno, true);
662 - skb_queue_splice(&bf_pending, &tid->buf_q);
663 + skb_queue_splice_tail(&bf_pending, &tid->retry_q);
665 ath_tx_queue_tid(txq, tid);
667 @@ -618,7 +694,7 @@ static void ath_tx_process_buffer(struct
669 ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok);
671 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !flush)
673 ath_txq_schedule(sc, txq);
676 @@ -792,15 +868,20 @@ static int ath_compute_num_delims(struct
678 static struct ath_buf *
679 ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
680 - struct ath_atx_tid *tid)
681 + struct ath_atx_tid *tid, struct sk_buff_head **q)
683 + struct ieee80211_tx_info *tx_info;
684 struct ath_frame_info *fi;
690 - skb = skb_peek(&tid->buf_q);
691 + *q = &tid->retry_q;
692 + if (skb_queue_empty(*q))
695 + skb = skb_peek(*q);
699 @@ -808,13 +889,26 @@ ath_tx_get_tid_subframe(struct ath_softc
702 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
704 + bf->bf_state.stale = false;
707 - __skb_unlink(skb, &tid->buf_q);
708 + __skb_unlink(skb, *q);
709 + ath_txq_skb_done(sc, txq, skb);
710 ieee80211_free_txskb(sc->hw, skb);
714 + bf->bf_next = NULL;
715 + bf->bf_lastbf = bf;
717 + tx_info = IEEE80211_SKB_CB(skb);
718 + tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
719 + if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
720 + bf->bf_state.bf_type = 0;
724 bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR;
725 seqno = bf->bf_state.seqno;
727 @@ -828,73 +922,52 @@ ath_tx_get_tid_subframe(struct ath_softc
729 INIT_LIST_HEAD(&bf_head);
730 list_add(&bf->list, &bf_head);
731 - __skb_unlink(skb, &tid->buf_q);
732 + __skb_unlink(skb, *q);
733 ath_tx_update_baw(sc, tid, seqno);
734 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
738 - bf->bf_next = NULL;
739 - bf->bf_lastbf = bf;
746 -static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
747 - struct ath_txq *txq,
748 - struct ath_atx_tid *tid,
749 - struct list_head *bf_q,
752 +ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
753 + struct ath_atx_tid *tid, struct list_head *bf_q,
754 + struct ath_buf *bf_first, struct sk_buff_head *tid_q,
757 #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
758 - struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL;
759 - int rl = 0, nframes = 0, ndelim, prev_al = 0;
760 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
761 + int nframes = 0, ndelim;
762 u16 aggr_limit = 0, al = 0, bpad = 0,
763 - al_delta, h_baw = tid->baw_size / 2;
764 - enum ATH_AGGR_STATUS status = ATH_AGGR_DONE;
765 + al_delta, h_baw = tid->baw_size / 2;
766 struct ieee80211_tx_info *tx_info;
767 struct ath_frame_info *fi;
769 + bool closed = false;
772 - bf = ath_tx_get_tid_subframe(sc, txq, tid);
774 - status = ATH_AGGR_BAW_CLOSED;
778 + aggr_limit = ath_lookup_rate(sc, bf, tid);
782 fi = get_frame_info(skb);
788 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
789 - aggr_limit = ath_lookup_rate(sc, bf, tid);
793 /* do not exceed aggregation limit */
794 al_delta = ATH_AGGR_DELIM_SZ + fi->framelen;
796 + if (aggr_limit < al + bpad + al_delta ||
797 + ath_lookup_legacy(bf) || nframes >= h_baw)
801 - ((aggr_limit < (al + bpad + al_delta + prev_al)) ||
802 - ath_lookup_legacy(bf))) {
803 - status = ATH_AGGR_LIMITED;
807 - tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
808 - if (nframes && (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE))
811 - /* do not exceed subframe limit */
812 - if (nframes >= min((int)h_baw, ATH_AMPDU_SUBFRAME_DEFAULT)) {
813 - status = ATH_AGGR_LIMITED;
815 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
816 + if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
817 + !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
821 /* add padding for previous frame to aggregation length */
822 @@ -912,22 +985,37 @@ static enum ATH_AGGR_STATUS ath_tx_form_
825 /* link buffers of this frame to the aggregate */
827 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
828 + if (!fi->baw_tracked)
829 + ath_tx_addto_baw(sc, tid, bf);
830 bf->bf_state.ndelim = ndelim;
832 - __skb_unlink(skb, &tid->buf_q);
833 + __skb_unlink(skb, tid_q);
834 list_add_tail(&bf->list, bf_q);
836 bf_prev->bf_next = bf;
840 - } while (!skb_queue_empty(&tid->buf_q));
841 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
846 + } while (ath_tid_has_buffered(tid));
849 + bf->bf_lastbf = bf_prev;
851 + if (bf == bf_prev) {
852 + al = get_frame_info(bf->bf_mpdu)->framelen;
853 + bf->bf_state.bf_type = BUF_AMPDU;
855 + TX_STAT_INC(txq->axq_qnum, a_aggr);
865 @@ -999,7 +1087,7 @@ void ath_update_max_aggr_framelen(struct
868 static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
869 - struct ath_tx_info *info, int len)
870 + struct ath_tx_info *info, int len, bool rts)
872 struct ath_hw *ah = sc->sc_ah;
874 @@ -1008,6 +1096,7 @@ static void ath_buf_set_rate(struct ath_
875 const struct ieee80211_rate *rate;
876 struct ieee80211_hdr *hdr;
877 struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
878 + u32 rts_thresh = sc->hw->wiphy->rts_threshold;
882 @@ -1030,7 +1119,17 @@ static void ath_buf_set_rate(struct ath_
884 info->rates[i].Tries = rates[i].count;
886 - if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
888 + * Handle RTS threshold for unaggregated HT frames.
890 + if (bf_isampdu(bf) && !bf_isaggr(bf) &&
891 + (rates[i].flags & IEEE80211_TX_RC_MCS) &&
892 + unlikely(rts_thresh != (u32) -1)) {
893 + if (!rts_thresh || (len > rts_thresh))
897 + if (rts || rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
898 info->rates[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
899 info->flags |= ATH9K_TXDESC_RTSENA;
900 } else if (rates[i].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
901 @@ -1123,6 +1222,8 @@ static void ath_tx_fill_desc(struct ath_
902 struct ath_hw *ah = sc->sc_ah;
903 struct ath_buf *bf_first = NULL;
904 struct ath_tx_info info;
905 + u32 rts_thresh = sc->hw->wiphy->rts_threshold;
908 memset(&info, 0, sizeof(info));
909 info.is_first = true;
910 @@ -1159,7 +1260,22 @@ static void ath_tx_fill_desc(struct ath_
911 info.flags |= (u32) bf->bf_state.bfs_paprd <<
912 ATH9K_TXDESC_PAPRD_S;
914 - ath_buf_set_rate(sc, bf, &info, len);
916 + * mac80211 doesn't handle RTS threshold for HT because
917 + * the decision has to be taken based on AMPDU length
918 + * and aggregation is done entirely inside ath9k.
919 + * Set the RTS/CTS flag for the first subframe based
920 + * on the threshold.
922 + if (aggr && (bf == bf_first) &&
923 + unlikely(rts_thresh != (u32) -1)) {
925 + * "len" is the size of the entire AMPDU.
927 + if (!rts_thresh || (len > rts_thresh))
930 + ath_buf_set_rate(sc, bf, &info, len, rts);
933 info.buf_addr[0] = bf->bf_buf_addr;
934 @@ -1188,64 +1304,101 @@ static void ath_tx_fill_desc(struct ath_
938 -static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
939 - struct ath_atx_tid *tid)
941 +ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
942 + struct ath_atx_tid *tid, struct list_head *bf_q,
943 + struct ath_buf *bf_first, struct sk_buff_head *tid_q)
945 - struct ath_buf *bf;
946 - enum ATH_AGGR_STATUS status;
947 - struct ieee80211_tx_info *tx_info;
948 - struct list_head bf_q;
950 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
951 + struct sk_buff *skb;
955 - if (skb_queue_empty(&tid->buf_q))
957 + struct ieee80211_tx_info *tx_info;
960 - INIT_LIST_HEAD(&bf_q);
962 + __skb_unlink(skb, tid_q);
963 + list_add_tail(&bf->list, bf_q);
965 + bf_prev->bf_next = bf;
968 - status = ath_tx_form_aggr(sc, txq, tid, &bf_q, &aggr_len);
973 - * no frames picked up to be aggregated;
974 - * block-ack window is not open.
976 - if (list_empty(&bf_q))
977 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
981 - bf = list_first_entry(&bf_q, struct ath_buf, list);
982 - bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
983 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
984 + if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
987 - if (tid->ac->clear_ps_filter) {
988 - tid->ac->clear_ps_filter = false;
989 - tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
991 - tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
993 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
997 - /* if only one frame, send as non-aggregate */
998 - if (bf == bf->bf_lastbf) {
999 - aggr_len = get_frame_info(bf->bf_mpdu)->framelen;
1000 - bf->bf_state.bf_type = BUF_AMPDU;
1002 - TX_STAT_INC(txq->axq_qnum, a_aggr);
1004 +static bool ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
1005 + struct ath_atx_tid *tid, bool *stop)
1007 + struct ath_buf *bf;
1008 + struct ieee80211_tx_info *tx_info;
1009 + struct sk_buff_head *tid_q;
1010 + struct list_head bf_q;
1012 + bool aggr, last = true;
1014 + if (!ath_tid_has_buffered(tid))
1017 + INIT_LIST_HEAD(&bf_q);
1019 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
1023 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
1024 + aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
1025 + if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
1026 + (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
1031 - ath_tx_fill_desc(sc, bf, txq, aggr_len);
1032 - ath_tx_txqaddbuf(sc, txq, &bf_q, false);
1033 - } while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH &&
1034 - status != ATH_AGGR_BAW_CLOSED);
1035 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
1037 + last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
1038 + tid_q, &aggr_len);
1040 + ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
1042 + if (list_empty(&bf_q))
1045 + if (tid->ac->clear_ps_filter || tid->an->no_ps_filter) {
1046 + tid->ac->clear_ps_filter = false;
1047 + tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
1050 + ath_tx_fill_desc(sc, bf, txq, aggr_len);
1051 + ath_tx_txqaddbuf(sc, txq, &bf_q, false);
1055 int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
1058 struct ath_atx_tid *txtid;
1059 + struct ath_txq *txq;
1060 struct ath_node *an;
1063 an = (struct ath_node *)sta->drv_priv;
1064 txtid = ATH_AN_2_TID(an, tid);
1065 + txq = txtid->ac->txq;
1067 + ath_txq_lock(sc, txq);
1069 /* update ampdu factor/density, they may have changed. This may happen
1070 * in HT IBSS when a beacon with HT-info is received after the station
1071 @@ -1258,6 +1411,9 @@ int ath_tx_aggr_start(struct ath_softc *
1072 an->mpdudensity = density;
1075 + /* force sequence number allocation for pending frames */
1076 + ath_tx_tid_change_state(sc, txtid);
1078 txtid->active = true;
1079 txtid->paused = true;
1080 *ssn = txtid->seq_start = txtid->seq_next;
1081 @@ -1266,6 +1422,8 @@ int ath_tx_aggr_start(struct ath_softc *
1082 memset(txtid->tx_buf, 0, sizeof(txtid->tx_buf));
1083 txtid->baw_head = txtid->baw_tail = 0;
1085 + ath_txq_unlock_complete(sc, txq);
1090 @@ -1277,8 +1435,9 @@ void ath_tx_aggr_stop(struct ath_softc *
1092 ath_txq_lock(sc, txq);
1093 txtid->active = false;
1094 - txtid->paused = true;
1095 + txtid->paused = false;
1096 ath_tx_flush_tid(sc, txtid);
1097 + ath_tx_tid_change_state(sc, txtid);
1098 ath_txq_unlock_complete(sc, txq);
1101 @@ -1302,7 +1461,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
1103 ath_txq_lock(sc, txq);
1105 - buffered = !skb_queue_empty(&tid->buf_q);
1106 + buffered = ath_tid_has_buffered(tid);
1109 list_del(&tid->list);
1110 @@ -1334,7 +1493,7 @@ void ath_tx_aggr_wakeup(struct ath_softc
1111 ath_txq_lock(sc, txq);
1112 ac->clear_ps_filter = true;
1114 - if (!skb_queue_empty(&tid->buf_q) && !tid->paused) {
1115 + if (!tid->paused && ath_tid_has_buffered(tid)) {
1116 ath_tx_queue_tid(txq, tid);
1117 ath_txq_schedule(sc, txq);
1119 @@ -1359,7 +1518,7 @@ void ath_tx_aggr_resume(struct ath_softc
1120 tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
1121 tid->paused = false;
1123 - if (!skb_queue_empty(&tid->buf_q)) {
1124 + if (ath_tid_has_buffered(tid)) {
1125 ath_tx_queue_tid(txq, tid);
1126 ath_txq_schedule(sc, txq);
1128 @@ -1379,6 +1538,7 @@ void ath9k_release_buffered_frames(struc
1129 struct ieee80211_tx_info *info;
1130 struct list_head bf_q;
1131 struct ath_buf *bf_tail = NULL, *bf;
1132 + struct sk_buff_head *tid_q;
1136 @@ -1394,16 +1554,18 @@ void ath9k_release_buffered_frames(struc
1139 ath_txq_lock(sc, tid->ac->txq);
1140 - while (!skb_queue_empty(&tid->buf_q) && nframes > 0) {
1141 - bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid);
1142 + while (nframes > 0) {
1143 + bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
1147 - __skb_unlink(bf->bf_mpdu, &tid->buf_q);
1148 + __skb_unlink(bf->bf_mpdu, tid_q);
1149 list_add_tail(&bf->list, &bf_q);
1150 ath_set_rates(tid->an->vif, tid->an->sta, bf);
1151 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
1152 - bf->bf_state.bf_type &= ~BUF_AGGR;
1153 + if (bf_isampdu(bf)) {
1154 + ath_tx_addto_baw(sc, tid, bf);
1155 + bf->bf_state.bf_type &= ~BUF_AGGR;
1158 bf_tail->bf_next = bf;
1160 @@ -1412,7 +1574,7 @@ void ath9k_release_buffered_frames(struc
1162 TX_STAT_INC(txq->axq_qnum, a_queued_hw);
1164 - if (skb_queue_empty(&tid->buf_q))
1165 + if (an->sta && !ath_tid_has_buffered(tid))
1166 ieee80211_sta_set_buffered(an->sta, i, false);
1168 ath_txq_unlock_complete(sc, tid->ac->txq);
1169 @@ -1571,7 +1733,7 @@ static void ath_drain_txq_list(struct at
1170 while (!list_empty(list)) {
1171 bf = list_first_entry(list, struct ath_buf, list);
1173 - if (bf->bf_stale) {
1174 + if (bf->bf_state.stale) {
1175 list_del(&bf->list);
1177 ath_tx_return_buffer(sc, bf);
1178 @@ -1665,25 +1827,27 @@ void ath_tx_cleanupq(struct ath_softc *s
1180 void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
1182 - struct ath_atx_ac *ac, *ac_tmp, *last_ac;
1183 + struct ath_atx_ac *ac, *last_ac;
1184 struct ath_atx_tid *tid, *last_tid;
1185 + bool sent = false;
1187 if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) ||
1188 - list_empty(&txq->axq_acq) ||
1189 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1190 + list_empty(&txq->axq_acq))
1195 - ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
1196 last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list);
1197 + while (!list_empty(&txq->axq_acq)) {
1198 + bool stop = false;
1200 - list_for_each_entry_safe(ac, ac_tmp, &txq->axq_acq, list) {
1201 + ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
1202 last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
1203 list_del(&ac->list);
1206 while (!list_empty(&ac->tid_q)) {
1208 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
1210 list_del(&tid->list);
1211 @@ -1692,17 +1856,17 @@ void ath_txq_schedule(struct ath_softc *
1215 - ath_tx_sched_aggr(sc, txq, tid);
1216 + if (ath_tx_sched_aggr(sc, txq, tid, &stop))
1220 * add tid to round-robin queue if more frames
1221 * are pending for the tid
1223 - if (!skb_queue_empty(&tid->buf_q))
1224 + if (ath_tid_has_buffered(tid))
1225 ath_tx_queue_tid(txq, tid);
1227 - if (tid == last_tid ||
1228 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1229 + if (stop || tid == last_tid)
1233 @@ -1711,9 +1875,17 @@ void ath_txq_schedule(struct ath_softc *
1234 list_add_tail(&ac->list, &txq->axq_acq);
1237 - if (ac == last_ac ||
1238 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1242 + if (ac == last_ac) {
1247 + last_ac = list_entry(txq->axq_acq.prev,
1248 + struct ath_atx_ac, list);
1253 @@ -1787,74 +1959,28 @@ static void ath_tx_txqaddbuf(struct ath_
1254 if (bf_is_ampdu_not_probing(bf))
1255 txq->axq_ampdu_depth++;
1257 - bf = bf->bf_lastbf->bf_next;
1258 + bf_last = bf->bf_lastbf;
1259 + bf = bf_last->bf_next;
1260 + bf_last->bf_next = NULL;
1265 -static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_txq *txq,
1266 - struct ath_atx_tid *tid, struct sk_buff *skb,
1267 - struct ath_tx_control *txctl)
1269 - struct ath_frame_info *fi = get_frame_info(skb);
1270 - struct list_head bf_head;
1271 - struct ath_buf *bf;
1274 - * Do not queue to h/w when any of the following conditions is true:
1275 - * - there are pending frames in software queue
1276 - * - the TID is currently paused for ADDBA/BAR request
1277 - * - seqno is not within block-ack window
1278 - * - h/w queue depth exceeds low water mark
1280 - if ((!skb_queue_empty(&tid->buf_q) || tid->paused ||
1281 - !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) ||
1282 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) &&
1283 - txq != sc->tx.uapsdq) {
1285 - * Add this frame to software queue for scheduling later
1286 - * for aggregation.
1288 - TX_STAT_INC(txq->axq_qnum, a_queued_sw);
1289 - __skb_queue_tail(&tid->buf_q, skb);
1290 - if (!txctl->an || !txctl->an->sleeping)
1291 - ath_tx_queue_tid(txq, tid);
1295 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1297 - ieee80211_free_txskb(sc->hw, skb);
1301 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
1302 - bf->bf_state.bf_type = BUF_AMPDU;
1303 - INIT_LIST_HEAD(&bf_head);
1304 - list_add(&bf->list, &bf_head);
1306 - /* Add sub-frame to BAW */
1307 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
1309 - /* Queue to h/w without aggregation */
1310 - TX_STAT_INC(txq->axq_qnum, a_queued_hw);
1311 - bf->bf_lastbf = bf;
1312 - ath_tx_fill_desc(sc, bf, txq, fi->framelen);
1313 - ath_tx_txqaddbuf(sc, txq, &bf_head, false);
1316 static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
1317 struct ath_atx_tid *tid, struct sk_buff *skb)
1319 + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1320 struct ath_frame_info *fi = get_frame_info(skb);
1321 struct list_head bf_head;
1322 - struct ath_buf *bf;
1325 + struct ath_buf *bf = fi->bf;
1327 INIT_LIST_HEAD(&bf_head);
1328 list_add_tail(&bf->list, &bf_head);
1329 bf->bf_state.bf_type = 0;
1330 + if (tid && (tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
1331 + bf->bf_state.bf_type = BUF_AMPDU;
1332 + ath_tx_addto_baw(sc, tid, bf);
1337 @@ -1985,6 +2111,7 @@ static int ath_tx_prepare(struct ieee802
1338 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1339 struct ieee80211_sta *sta = txctl->sta;
1340 struct ieee80211_vif *vif = info->control.vif;
1341 + struct ath_vif *avp;
1342 struct ath_softc *sc = hw->priv;
1343 int frmlen = skb->len + FCS_LEN;
1344 int padpos, padsize;
1345 @@ -1992,6 +2119,10 @@ static int ath_tx_prepare(struct ieee802
1346 /* NOTE: sta can be NULL according to net/mac80211.h */
1348 txctl->an = (struct ath_node *)sta->drv_priv;
1349 + else if (vif && ieee80211_is_data(hdr->frame_control)) {
1350 + avp = (void *)vif->drv_priv;
1351 + txctl->an = &avp->mcast_node;
1354 if (info->control.hw_key)
1355 frmlen += info->control.hw_key->icv_len;
1356 @@ -2041,7 +2172,6 @@ int ath_tx_start(struct ieee80211_hw *hw
1357 struct ath_txq *txq = txctl->txq;
1358 struct ath_atx_tid *tid = NULL;
1364 @@ -2069,27 +2199,31 @@ int ath_tx_start(struct ieee80211_hw *hw
1365 ath_txq_unlock(sc, txq);
1366 txq = sc->tx.uapsdq;
1367 ath_txq_lock(sc, txq);
1370 - if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
1371 - tidno = ieee80211_get_qos_ctl(hdr)[0] &
1372 - IEEE80211_QOS_CTL_TID_MASK;
1373 - tid = ATH_AN_2_TID(txctl->an, tidno);
1374 + } else if (txctl->an &&
1375 + ieee80211_is_data_present(hdr->frame_control)) {
1376 + tid = ath_get_skb_tid(sc, txctl->an, skb);
1378 WARN_ON(tid->ac->txq != txctl->txq);
1381 - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
1382 + if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
1383 + tid->ac->clear_ps_filter = true;
1386 - * Try aggregation if it's a unicast data frame
1387 - * and the destination is HT capable.
1388 + * Add this frame to software queue for scheduling later
1389 + * for aggregation.
1391 - ath_tx_send_ampdu(sc, txq, tid, skb, txctl);
1392 + TX_STAT_INC(txq->axq_qnum, a_queued_sw);
1393 + __skb_queue_tail(&tid->buf_q, skb);
1394 + if (!txctl->an->sleeping)
1395 + ath_tx_queue_tid(txq, tid);
1397 + ath_txq_schedule(sc, txq);
1401 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1403 + ath_txq_skb_done(sc, txq, skb);
1405 dev_kfree_skb_any(skb);
1407 @@ -2142,7 +2276,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
1410 ath_set_rates(vif, NULL, bf);
1411 - ath_buf_set_rate(sc, bf, &info, fi->framelen);
1412 + ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
1413 duration += info.rates[0].PktDuration;
1415 bf_tail->bf_next = bf;
1416 @@ -2189,7 +2323,7 @@ static void ath_tx_complete(struct ath_s
1417 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1418 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1419 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
1420 - int q, padpos, padsize;
1421 + int padpos, padsize;
1422 unsigned long flags;
1424 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
1425 @@ -2225,21 +2359,7 @@ static void ath_tx_complete(struct ath_s
1426 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1428 __skb_queue_tail(&txq->complete_q, skb);
1430 - q = skb_get_queue_mapping(skb);
1431 - if (txq == sc->tx.uapsdq)
1432 - txq = sc->tx.txq_map[q];
1434 - if (txq == sc->tx.txq_map[q]) {
1435 - if (WARN_ON(--txq->pending_frames < 0))
1436 - txq->pending_frames = 0;
1438 - if (txq->stopped &&
1439 - txq->pending_frames < sc->tx.txq_max_pending[q]) {
1440 - ieee80211_wake_queue(sc->hw, q);
1441 - txq->stopped = false;
1444 + ath_txq_skb_done(sc, txq, skb);
1447 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
1448 @@ -2360,8 +2480,7 @@ static void ath_tx_processq(struct ath_s
1450 if (list_empty(&txq->axq_q)) {
1451 txq->axq_link = NULL;
1452 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
1453 - ath_txq_schedule(sc, txq);
1454 + ath_txq_schedule(sc, txq);
1457 bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
1458 @@ -2375,7 +2494,7 @@ static void ath_tx_processq(struct ath_s
1459 * it with the STALE flag.
1462 - if (bf->bf_stale) {
1463 + if (bf->bf_state.stale) {
1465 if (list_is_last(&bf_held->list, &txq->axq_q))
1467 @@ -2399,7 +2518,7 @@ static void ath_tx_processq(struct ath_s
1468 * however leave the last descriptor back as the holding
1469 * descriptor for hw.
1471 - lastbf->bf_stale = true;
1472 + lastbf->bf_state.stale = true;
1473 INIT_LIST_HEAD(&bf_head);
1474 if (!list_is_singular(&lastbf->list))
1475 list_cut_position(&bf_head,
1476 @@ -2470,7 +2589,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1479 bf = list_first_entry(fifo_list, struct ath_buf, list);
1480 - if (bf->bf_stale) {
1481 + if (bf->bf_state.stale) {
1482 list_del(&bf->list);
1483 ath_tx_return_buffer(sc, bf);
1484 bf = list_first_entry(fifo_list, struct ath_buf, list);
1485 @@ -2492,7 +2611,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1486 ath_tx_txqaddbuf(sc, txq, &bf_q, true);
1489 - lastbf->bf_stale = true;
1490 + lastbf->bf_state.stale = true;
1492 list_cut_position(&bf_head, fifo_list,
1494 @@ -2583,6 +2702,7 @@ void ath_tx_node_init(struct ath_softc *
1495 tid->paused = false;
1496 tid->active = false;
1497 __skb_queue_head_init(&tid->buf_q);
1498 + __skb_queue_head_init(&tid->retry_q);
1499 acno = TID_TO_WME_AC(tidno);
1500 tid->ac = &an->ac[acno];
1502 @@ -2590,6 +2710,7 @@ void ath_tx_node_init(struct ath_softc *
1503 for (acno = 0, ac = &an->ac[acno];
1504 acno < IEEE80211_NUM_ACS; acno++, ac++) {
1506 + ac->clear_ps_filter = true;
1507 ac->txq = sc->tx.txq_map[acno];
1508 INIT_LIST_HEAD(&ac->tid_q);
1510 --- a/drivers/net/wireless/ath/ath9k/main.c
1511 +++ b/drivers/net/wireless/ath/ath9k/main.c
1512 @@ -173,8 +173,7 @@ static void ath_restart_work(struct ath_
1514 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
1516 - if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9485(sc->sc_ah) ||
1517 - AR_SREV_9550(sc->sc_ah))
1518 + if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah))
1519 ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
1520 msecs_to_jiffies(ATH_PLL_WORK_INTERVAL));
1522 @@ -209,6 +208,7 @@ static bool ath_complete_reset(struct at
1523 struct ath_hw *ah = sc->sc_ah;
1524 struct ath_common *common = ath9k_hw_common(ah);
1525 unsigned long flags;
1528 if (ath_startrecv(sc) != 0) {
1529 ath_err(common, "Unable to restart recv logic\n");
1530 @@ -236,10 +236,16 @@ static bool ath_complete_reset(struct at
1533 ath_restart_work(sc);
1536 - if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3)
1537 - ath_ant_comb_update(sc);
1538 + for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1539 + if (!ATH_TXQ_SETUP(sc, i))
1542 + spin_lock_bh(&sc->tx.txq[i].axq_lock);
1543 + ath_txq_schedule(sc, &sc->tx.txq[i]);
1544 + spin_unlock_bh(&sc->tx.txq[i].axq_lock);
1548 ieee80211_wake_queues(sc->hw);
1550 @@ -543,21 +549,10 @@ chip_reset:
1552 static int ath_reset(struct ath_softc *sc)
1557 ath9k_ps_wakeup(sc);
1559 r = ath_reset_internal(sc, NULL);
1561 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1562 - if (!ATH_TXQ_SETUP(sc, i))
1565 - spin_lock_bh(&sc->tx.txq[i].axq_lock);
1566 - ath_txq_schedule(sc, &sc->tx.txq[i]);
1567 - spin_unlock_bh(&sc->tx.txq[i].axq_lock);
1570 ath9k_ps_restore(sc);
1573 @@ -966,6 +961,8 @@ static int ath9k_add_interface(struct ie
1574 struct ath_softc *sc = hw->priv;
1575 struct ath_hw *ah = sc->sc_ah;
1576 struct ath_common *common = ath9k_hw_common(ah);
1577 + struct ath_vif *avp = (void *)vif->drv_priv;
1578 + struct ath_node *an = &avp->mcast_node;
1580 mutex_lock(&sc->mutex);
1582 @@ -979,6 +976,12 @@ static int ath9k_add_interface(struct ie
1583 if (ath9k_uses_beacons(vif->type))
1584 ath9k_beacon_assign_slot(sc, vif);
1589 + an->no_ps_filter = true;
1590 + ath_tx_node_init(sc, an);
1592 mutex_unlock(&sc->mutex);
1595 @@ -1016,6 +1019,7 @@ static void ath9k_remove_interface(struc
1597 struct ath_softc *sc = hw->priv;
1598 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1599 + struct ath_vif *avp = (void *)vif->drv_priv;
1601 ath_dbg(common, CONFIG, "Detach Interface\n");
1603 @@ -1030,6 +1034,8 @@ static void ath9k_remove_interface(struc
1604 ath9k_calculate_summary_state(hw, NULL);
1605 ath9k_ps_restore(sc);
1607 + ath_tx_node_cleanup(sc, &avp->mcast_node);
1609 mutex_unlock(&sc->mutex);
1612 @@ -1193,8 +1199,6 @@ static int ath9k_config(struct ieee80211
1614 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
1615 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
1616 - enum nl80211_channel_type channel_type =
1617 - cfg80211_get_chandef_type(&conf->chandef);
1618 int pos = curchan->hw_value;
1620 unsigned long flags;
1621 @@ -1202,8 +1206,8 @@ static int ath9k_config(struct ieee80211
1623 old_pos = ah->curchan - &ah->channels[0];
1625 - ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n",
1626 - curchan->center_freq, channel_type);
1627 + ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
1628 + curchan->center_freq, hw->conf.chandef.width);
1630 /* update survey stats for the old channel before switching */
1631 spin_lock_irqsave(&common->cc_lock, flags);
1632 @@ -1211,7 +1215,7 @@ static int ath9k_config(struct ieee80211
1633 spin_unlock_irqrestore(&common->cc_lock, flags);
1635 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
1636 - curchan, channel_type);
1640 * If the operating channel changes, change the survey in-use flags
1641 @@ -1374,9 +1378,6 @@ static void ath9k_sta_notify(struct ieee
1642 struct ath_softc *sc = hw->priv;
1643 struct ath_node *an = (struct ath_node *) sta->drv_priv;
1645 - if (!sta->ht_cap.ht_supported)
1649 case STA_NOTIFY_SLEEP:
1650 an->sleeping = true;
1651 @@ -2094,7 +2095,7 @@ static void ath9k_wow_add_pattern(struct
1653 struct ath_hw *ah = sc->sc_ah;
1654 struct ath9k_wow_pattern *wow_pattern = NULL;
1655 - struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
1656 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
1660 --- a/drivers/net/wireless/mwifiex/cfg80211.c
1661 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
1662 @@ -2298,8 +2298,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_in
1666 -mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
1668 +mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
1670 int j, k, valid_byte_cnt = 0;
1671 bool dont_care_byte = false;
1672 --- a/drivers/net/wireless/ti/wlcore/main.c
1673 +++ b/drivers/net/wireless/ti/wlcore/main.c
1674 @@ -1315,7 +1315,7 @@ static struct sk_buff *wl12xx_alloc_dumm
1678 -wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
1679 +wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
1681 int num_fields = 0, in_field = 0, fields_size = 0;
1682 int i, pattern_len = 0;
1683 @@ -1458,9 +1458,9 @@ void wl1271_rx_filter_flatten_fields(str
1684 * Allocates an RX filter returned through f
1685 * which needs to be freed using rx_filter_free()
1687 -static int wl1271_convert_wowlan_pattern_to_rx_filter(
1688 - struct cfg80211_wowlan_trig_pkt_pattern *p,
1689 - struct wl12xx_rx_filter **f)
1691 +wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
1692 + struct wl12xx_rx_filter **f)
1695 struct wl12xx_rx_filter *filter;
1696 @@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
1698 /* Translate WoWLAN patterns into filters */
1699 for (i = 0; i < wow->n_patterns; i++) {
1700 - struct cfg80211_wowlan_trig_pkt_pattern *p;
1701 + struct cfg80211_pkt_pattern *p;
1702 struct wl12xx_rx_filter *filter = NULL;
1704 p = &wow->patterns[i];
1705 --- a/include/net/cfg80211.h
1706 +++ b/include/net/cfg80211.h
1707 @@ -639,6 +639,30 @@ struct cfg80211_ap_settings {
1711 + * struct cfg80211_csa_settings - channel switch settings
1713 + * Used for channel switch
1715 + * @chandef: defines the channel to use after the switch
1716 + * @beacon_csa: beacon data while performing the switch
1717 + * @counter_offset_beacon: offset for the counter within the beacon (tail)
1718 + * @counter_offset_presp: offset for the counter within the probe response
1719 + * @beacon_after: beacon data to be used on the new channel
1720 + * @radar_required: whether radar detection is required on the new channel
1721 + * @block_tx: whether transmissions should be blocked while changing
1722 + * @count: number of beacons until switch
1724 +struct cfg80211_csa_settings {
1725 + struct cfg80211_chan_def chandef;
1726 + struct cfg80211_beacon_data beacon_csa;
1727 + u16 counter_offset_beacon, counter_offset_presp;
1728 + struct cfg80211_beacon_data beacon_after;
1729 + bool radar_required;
1735 * enum station_parameters_apply_mask - station parameter values to apply
1736 * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
1737 * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
1738 @@ -1698,7 +1722,7 @@ struct cfg80211_pmksa {
1742 - * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
1743 + * struct cfg80211_pkt_pattern - packet pattern
1744 * @mask: bitmask where to match pattern and where to ignore bytes,
1745 * one bit per byte, in same format as nl80211
1746 * @pattern: bytes to match where bitmask is 1
1747 @@ -1708,7 +1732,7 @@ struct cfg80211_pmksa {
1748 * Internal note: @mask and @pattern are allocated in one chunk of
1749 * memory, free @mask only!
1751 -struct cfg80211_wowlan_trig_pkt_pattern {
1752 +struct cfg80211_pkt_pattern {
1756 @@ -1770,7 +1794,7 @@ struct cfg80211_wowlan {
1757 bool any, disconnect, magic_pkt, gtk_rekey_failure,
1758 eap_identity_req, four_way_handshake,
1760 - struct cfg80211_wowlan_trig_pkt_pattern *patterns;
1761 + struct cfg80211_pkt_pattern *patterns;
1762 struct cfg80211_wowlan_tcp *tcp;
1765 @@ -2071,6 +2095,8 @@ struct cfg80211_update_ft_ies_params {
1766 * driver can take the most appropriate actions.
1767 * @crit_proto_stop: Indicates critical protocol no longer needs increased link
1768 * reliability. This operation can not fail.
1770 + * @channel_switch: initiate channel-switch procedure (with CSA)
1772 struct cfg80211_ops {
1773 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
1774 @@ -2306,6 +2332,10 @@ struct cfg80211_ops {
1776 void (*crit_proto_stop)(struct wiphy *wiphy,
1777 struct wireless_dev *wdev);
1779 + int (*channel_switch)(struct wiphy *wiphy,
1780 + struct net_device *dev,
1781 + struct cfg80211_csa_settings *params);
1785 @@ -2371,6 +2401,8 @@ struct cfg80211_ops {
1786 * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
1787 * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
1788 * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
1789 + * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
1790 + * beaconing mode (AP, IBSS, Mesh, ...).
1793 WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0),
1794 @@ -2395,6 +2427,7 @@ enum wiphy_flags {
1795 WIPHY_FLAG_OFFCHAN_TX = BIT(20),
1796 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
1797 WIPHY_FLAG_SUPPORTS_5_10_MHZ = BIT(22),
1798 + WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
1802 --- a/include/uapi/linux/nl80211.h
1803 +++ b/include/uapi/linux/nl80211.h
1804 @@ -648,6 +648,16 @@
1805 * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
1806 * return back to normal.
1808 + * @NL80211_CMD_CHANNEL_SWITCH: Perform a channel switch by announcing the
1809 + * the new channel information (Channel Switch Announcement - CSA)
1810 + * in the beacon for some time (as defined in the
1811 + * %NL80211_ATTR_CH_SWITCH_COUNT parameter) and then change to the
1812 + * new channel. Userspace provides the new channel information (using
1813 + * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel
1814 + * width). %NL80211_ATTR_CH_SWITCH_BLOCK_TX may be supplied to inform
1815 + * other station that transmission must be blocked until the channel
1816 + * switch is complete.
1818 * @NL80211_CMD_MAX: highest used command number
1819 * @__NL80211_CMD_AFTER_LAST: internal use
1821 @@ -810,6 +820,8 @@ enum nl80211_commands {
1822 NL80211_CMD_CRIT_PROTOCOL_START,
1823 NL80211_CMD_CRIT_PROTOCOL_STOP,
1825 + NL80211_CMD_CHANNEL_SWITCH,
1827 /* add new commands above here */
1829 /* used to define NL80211_CMD_MAX below */
1830 @@ -1436,6 +1448,18 @@ enum nl80211_commands {
1831 * allowed to be used with the first @NL80211_CMD_SET_STATION command to
1832 * update a TDLS peer STA entry.
1834 + * @NL80211_ATTR_CH_SWITCH_COUNT: u32 attribute specifying the number of TBTT's
1835 + * until the channel switch event.
1836 + * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission
1837 + * must be blocked on the current channel (before the channel switch
1839 + * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
1840 + * for the time while performing a channel switch.
1841 + * @NL80211_ATTR_CSA_C_OFF_BEACON: Offset of the channel switch counter
1842 + * field in the beacons tail (%NL80211_ATTR_BEACON_TAIL).
1843 + * @NL80211_ATTR_CSA_C_OFF_PRESP: Offset of the channel switch counter
1844 + * field in the probe response (%NL80211_ATTR_PROBE_RESP).
1846 * @NL80211_ATTR_MAX: highest attribute number currently defined
1847 * @__NL80211_ATTR_AFTER_LAST: internal use
1849 @@ -1736,6 +1760,12 @@ enum nl80211_attrs {
1851 NL80211_ATTR_PEER_AID,
1853 + NL80211_ATTR_CH_SWITCH_COUNT,
1854 + NL80211_ATTR_CH_SWITCH_BLOCK_TX,
1855 + NL80211_ATTR_CSA_IES,
1856 + NL80211_ATTR_CSA_C_OFF_BEACON,
1857 + NL80211_ATTR_CSA_C_OFF_PRESP,
1859 /* add attributes here, update the policy in nl80211.c */
1861 __NL80211_ATTR_AFTER_LAST,
1862 @@ -3060,11 +3090,11 @@ enum nl80211_tx_power_setting {
1866 - * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
1867 - * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
1868 - * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
1869 + * enum nl80211_packet_pattern_attr - packet pattern attribute
1870 + * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
1871 + * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
1872 * a zero bit are ignored
1873 - * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
1874 + * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
1875 * a bit for each byte in the pattern. The lowest-order bit corresponds
1876 * to the first byte of the pattern, but the bytes of the pattern are
1877 * in a little-endian-like format, i.e. the 9th byte of the pattern
1878 @@ -3075,23 +3105,23 @@ enum nl80211_tx_power_setting {
1879 * Note that the pattern matching is done as though frames were not
1880 * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
1881 * first (including SNAP header unpacking) and then matched.
1882 - * @NL80211_WOWLAN_PKTPAT_OFFSET: packet offset, pattern is matched after
1883 + * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
1884 * these fixed number of bytes of received packet
1885 - * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
1886 - * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
1887 + * @NUM_NL80211_PKTPAT: number of attributes
1888 + * @MAX_NL80211_PKTPAT: max attribute number
1890 -enum nl80211_wowlan_packet_pattern_attr {
1891 - __NL80211_WOWLAN_PKTPAT_INVALID,
1892 - NL80211_WOWLAN_PKTPAT_MASK,
1893 - NL80211_WOWLAN_PKTPAT_PATTERN,
1894 - NL80211_WOWLAN_PKTPAT_OFFSET,
1895 +enum nl80211_packet_pattern_attr {
1896 + __NL80211_PKTPAT_INVALID,
1897 + NL80211_PKTPAT_MASK,
1898 + NL80211_PKTPAT_PATTERN,
1899 + NL80211_PKTPAT_OFFSET,
1901 - NUM_NL80211_WOWLAN_PKTPAT,
1902 - MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
1903 + NUM_NL80211_PKTPAT,
1904 + MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
1908 - * struct nl80211_wowlan_pattern_support - pattern support information
1909 + * struct nl80211_pattern_support - packet pattern support information
1910 * @max_patterns: maximum number of patterns supported
1911 * @min_pattern_len: minimum length of each pattern
1912 * @max_pattern_len: maximum length of each pattern
1913 @@ -3101,13 +3131,22 @@ enum nl80211_wowlan_packet_pattern_attr
1914 * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
1915 * capability information given by the kernel to userspace.
1917 -struct nl80211_wowlan_pattern_support {
1918 +struct nl80211_pattern_support {
1920 __u32 min_pattern_len;
1921 __u32 max_pattern_len;
1922 __u32 max_pkt_offset;
1923 } __attribute__((packed));
1925 +/* only for backward compatibility */
1926 +#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
1927 +#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
1928 +#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
1929 +#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
1930 +#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
1931 +#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
1932 +#define nl80211_wowlan_pattern_support nl80211_pattern_support
1935 * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
1936 * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
1937 @@ -3127,7 +3166,7 @@ struct nl80211_wowlan_pattern_support {
1938 * pattern matching is done after the packet is converted to the MSDU.
1940 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
1941 - * carrying a &struct nl80211_wowlan_pattern_support.
1942 + * carrying a &struct nl80211_pattern_support.
1944 * When reporting wakeup. it is a u32 attribute containing the 0-based
1945 * index of the pattern that caused the wakeup, in the patterns passed
1946 @@ -3284,7 +3323,7 @@ struct nl80211_wowlan_tcp_data_token_fea
1947 * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
1948 * u32 attribute holding the maximum length
1949 * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
1950 - * feature advertising. The mask works like @NL80211_WOWLAN_PKTPAT_MASK
1951 + * feature advertising. The mask works like @NL80211_PKTPAT_MASK
1952 * but on the TCP payload only.
1953 * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
1954 * @MAX_NL80211_WOWLAN_TCP: highest attribute number
1955 --- a/net/mac80211/mesh_ps.c
1956 +++ b/net/mac80211/mesh_ps.c
1957 @@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(str
1958 enum nl80211_mesh_power_mode pm;
1961 + /* For non-assoc STA, prevent buffering or frame transmission */
1962 + if (sta->sta_state < IEEE80211_STA_ASSOC)
1966 * use peer-specific power mode if peering is established and the
1967 * peer's power mode is known
1968 --- a/net/wireless/nl80211.c
1969 +++ b/net/wireless/nl80211.c
1970 @@ -349,6 +349,11 @@ static const struct nla_policy nl80211_p
1971 [NL80211_ATTR_IE_RIC] = { .type = NLA_BINARY,
1972 .len = IEEE80211_MAX_DATA_LEN },
1973 [NL80211_ATTR_PEER_AID] = { .type = NLA_U16 },
1974 + [NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 },
1975 + [NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG },
1976 + [NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED },
1977 + [NL80211_ATTR_CSA_C_OFF_BEACON] = { .type = NLA_U16 },
1978 + [NL80211_ATTR_CSA_C_OFF_PRESP] = { .type = NLA_U16 },
1981 /* policy for the key attributes */
1982 @@ -441,10 +446,12 @@ static int nl80211_prepare_wdev_dump(str
1985 *rdev = wiphy_to_dev((*wdev)->wiphy);
1986 - cb->args[0] = (*rdev)->wiphy_idx;
1987 + /* 0 is the first index - add 1 to parse only once */
1988 + cb->args[0] = (*rdev)->wiphy_idx + 1;
1989 cb->args[1] = (*wdev)->identifier;
1991 - struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]);
1992 + /* subtract the 1 again here */
1993 + struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
1994 struct wireless_dev *tmp;
1997 @@ -974,7 +981,7 @@ static int nl80211_send_wowlan(struct sk
2000 if (dev->wiphy.wowlan->n_patterns) {
2001 - struct nl80211_wowlan_pattern_support pat = {
2002 + struct nl80211_pattern_support pat = {
2003 .max_patterns = dev->wiphy.wowlan->n_patterns,
2004 .min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
2005 .max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
2006 @@ -1393,6 +1400,8 @@ static int nl80211_send_wiphy(struct cfg
2008 CMD(crit_proto_start, CRIT_PROTOCOL_START);
2009 CMD(crit_proto_stop, CRIT_PROTOCOL_STOP);
2010 + if (dev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)
2011 + CMD(channel_switch, CHANNEL_SWITCH);
2014 #ifdef CPTCFG_NL80211_TESTMODE
2015 @@ -1568,8 +1577,10 @@ static int nl80211_dump_wiphy(struct sk_
2018 state = kzalloc(sizeof(*state), GFP_KERNEL);
2024 state->filter_wiphy = -1;
2025 ret = nl80211_dump_wiphy_parse(skb, cb, state);
2027 @@ -2620,8 +2631,8 @@ static int nl80211_get_key(struct sk_buf
2029 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2030 NL80211_CMD_NEW_KEY);
2032 - return PTR_ERR(hdr);
2037 cookie.idx = key_idx;
2038 @@ -4770,9 +4781,9 @@ do { \
2039 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, 0, 1,
2040 mask, NL80211_MESHCONF_FORWARDING,
2042 - FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, 1, 255,
2043 + FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0,
2044 mask, NL80211_MESHCONF_RSSI_THRESHOLD,
2047 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16,
2048 mask, NL80211_MESHCONF_HT_OPMODE,
2050 @@ -5578,6 +5589,111 @@ static int nl80211_start_radar_detection
2054 +static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
2056 + struct cfg80211_registered_device *rdev = info->user_ptr[0];
2057 + struct net_device *dev = info->user_ptr[1];
2058 + struct wireless_dev *wdev = dev->ieee80211_ptr;
2059 + struct cfg80211_csa_settings params;
2060 + /* csa_attrs is defined static to avoid waste of stack size - this
2061 + * function is called under RTNL lock, so this should not be a problem.
2063 + static struct nlattr *csa_attrs[NL80211_ATTR_MAX+1];
2064 + u8 radar_detect_width = 0;
2067 + if (!rdev->ops->channel_switch ||
2068 + !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
2069 + return -EOPNOTSUPP;
2071 + /* may add IBSS support later */
2072 + if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
2073 + dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
2074 + return -EOPNOTSUPP;
2076 + memset(¶ms, 0, sizeof(params));
2078 + if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] ||
2079 + !info->attrs[NL80211_ATTR_CH_SWITCH_COUNT])
2082 + /* only important for AP, IBSS and mesh create IEs internally */
2083 + if (!info->attrs[NL80211_ATTR_CSA_IES])
2086 + /* useless if AP is not running */
2087 + if (!wdev->beacon_interval)
2090 + params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
2092 + err = nl80211_parse_beacon(info->attrs, ¶ms.beacon_after);
2096 + err = nla_parse_nested(csa_attrs, NL80211_ATTR_MAX,
2097 + info->attrs[NL80211_ATTR_CSA_IES],
2102 + err = nl80211_parse_beacon(csa_attrs, ¶ms.beacon_csa);
2106 + if (!csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON])
2109 + params.counter_offset_beacon =
2110 + nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]);
2111 + if (params.counter_offset_beacon >= params.beacon_csa.tail_len)
2114 + /* sanity check - counters should be the same */
2115 + if (params.beacon_csa.tail[params.counter_offset_beacon] !=
2119 + if (csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]) {
2120 + params.counter_offset_presp =
2121 + nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]);
2122 + if (params.counter_offset_presp >=
2123 + params.beacon_csa.probe_resp_len)
2126 + if (params.beacon_csa.probe_resp[params.counter_offset_presp] !=
2131 + err = nl80211_parse_chandef(rdev, info, ¶ms.chandef);
2135 + if (!cfg80211_reg_can_beacon(&rdev->wiphy, ¶ms.chandef))
2138 + err = cfg80211_chandef_dfs_required(wdev->wiphy, ¶ms.chandef);
2142 + radar_detect_width = BIT(params.chandef.width);
2143 + params.radar_required = true;
2146 + err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype,
2147 + params.chandef.chan,
2149 + radar_detect_width);
2153 + if (info->attrs[NL80211_ATTR_CH_SWITCH_BLOCK_TX])
2154 + params.block_tx = true;
2156 + return rdev_channel_switch(rdev, dev, ¶ms);
2159 static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
2161 struct cfg80211_registered_device *rdev,
2162 @@ -6507,6 +6623,9 @@ static int nl80211_testmode_dump(struct
2163 NL80211_CMD_TESTMODE);
2164 struct nlattr *tmdata;
2169 if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
2170 genlmsg_cancel(skb, hdr);
2172 @@ -6615,12 +6734,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
2174 void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
2176 + struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
2177 void *hdr = ((void **)skb->cb)[1];
2178 struct nlattr *data = ((void **)skb->cb)[2];
2180 nla_nest_end(skb, data);
2181 genlmsg_end(skb, hdr);
2182 - genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
2183 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
2184 + nl80211_testmode_mcgrp.id, gfp);
2186 EXPORT_SYMBOL(cfg80211_testmode_event);
2188 @@ -6949,9 +7070,8 @@ static int nl80211_remain_on_channel(str
2190 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2191 NL80211_CMD_REMAIN_ON_CHANNEL);
2193 - if (IS_ERR(hdr)) {
2194 - err = PTR_ERR(hdr);
2200 @@ -7249,9 +7369,8 @@ static int nl80211_tx_mgmt(struct sk_buf
2202 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2205 - if (IS_ERR(hdr)) {
2206 - err = PTR_ERR(hdr);
2212 @@ -7593,12 +7712,11 @@ static int nl80211_send_wowlan_patterns(
2215 pat_len = wowlan->patterns[i].pattern_len;
2216 - if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
2217 - DIV_ROUND_UP(pat_len, 8),
2218 + if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
2219 wowlan->patterns[i].mask) ||
2220 - nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
2221 - pat_len, wowlan->patterns[i].pattern) ||
2222 - nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
2223 + nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
2224 + wowlan->patterns[i].pattern) ||
2225 + nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
2226 wowlan->patterns[i].pkt_offset))
2228 nla_nest_end(msg, nl_pat);
2229 @@ -7939,7 +8057,7 @@ static int nl80211_set_wowlan(struct sk_
2232 int rem, pat_len, mask_len, pkt_offset;
2233 - struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
2234 + struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
2236 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
2238 @@ -7958,26 +8076,25 @@ static int nl80211_set_wowlan(struct sk_
2240 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
2242 - nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
2243 - nla_data(pat), nla_len(pat), NULL);
2244 + nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
2245 + nla_len(pat), NULL);
2247 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
2248 - !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
2249 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
2250 + !pat_tb[NL80211_PKTPAT_PATTERN])
2252 - pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
2253 + pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
2254 mask_len = DIV_ROUND_UP(pat_len, 8);
2255 - if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
2257 + if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
2259 if (pat_len > wowlan->pattern_max_len ||
2260 pat_len < wowlan->pattern_min_len)
2263 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
2264 + if (!pat_tb[NL80211_PKTPAT_OFFSET])
2267 pkt_offset = nla_get_u32(
2268 - pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
2269 + pat_tb[NL80211_PKTPAT_OFFSET]);
2270 if (pkt_offset > wowlan->max_pkt_offset)
2272 new_triggers.patterns[i].pkt_offset = pkt_offset;
2273 @@ -7991,11 +8108,11 @@ static int nl80211_set_wowlan(struct sk_
2274 new_triggers.patterns[i].pattern =
2275 new_triggers.patterns[i].mask + mask_len;
2276 memcpy(new_triggers.patterns[i].mask,
2277 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
2278 + nla_data(pat_tb[NL80211_PKTPAT_MASK]),
2280 new_triggers.patterns[i].pattern_len = pat_len;
2281 memcpy(new_triggers.patterns[i].pattern,
2282 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
2283 + nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
2287 @@ -8130,9 +8247,8 @@ static int nl80211_probe_client(struct s
2289 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2290 NL80211_CMD_PROBE_CLIENT);
2292 - if (IS_ERR(hdr)) {
2293 - err = PTR_ERR(hdr);
2299 @@ -9041,7 +9157,15 @@ static struct genl_ops nl80211_ops[] = {
2300 .flags = GENL_ADMIN_PERM,
2301 .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
2302 NL80211_FLAG_NEED_RTNL,
2306 + .cmd = NL80211_CMD_CHANNEL_SWITCH,
2307 + .doit = nl80211_channel_switch,
2308 + .policy = nl80211_policy,
2309 + .flags = GENL_ADMIN_PERM,
2310 + .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
2311 + NL80211_FLAG_NEED_RTNL,
2315 static struct genl_multicast_group nl80211_mlme_mcgrp = {
2316 @@ -10066,7 +10190,8 @@ void cfg80211_mgmt_tx_status(struct wire
2318 genlmsg_end(msg, hdr);
2320 - genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
2321 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
2322 + nl80211_mlme_mcgrp.id, gfp);
2326 --- a/net/wireless/reg.c
2327 +++ b/net/wireless/reg.c
2328 @@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev
2330 void wiphy_regulatory_register(struct wiphy *wiphy)
2332 + struct regulatory_request *lr;
2334 if (!reg_dev_ignore_cell_hint(wiphy))
2335 reg_num_devs_support_basehint++;
2337 - wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
2338 + lr = get_last_request();
2339 + wiphy_update_regulatory(wiphy, lr->initiator);
2342 void wiphy_regulatory_deregister(struct wiphy *wiphy)
2343 @@ -2279,7 +2282,9 @@ void wiphy_regulatory_deregister(struct
2344 static void reg_timeout_work(struct work_struct *work)
2346 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
2348 restore_regulatory_settings(true);
2352 int __init regulatory_init(void)
2353 --- a/net/wireless/sme.c
2354 +++ b/net/wireless/sme.c
2355 @@ -34,8 +34,10 @@ struct cfg80211_conn {
2356 CFG80211_CONN_SCAN_AGAIN,
2357 CFG80211_CONN_AUTHENTICATE_NEXT,
2358 CFG80211_CONN_AUTHENTICATING,
2359 + CFG80211_CONN_AUTH_FAILED,
2360 CFG80211_CONN_ASSOCIATE_NEXT,
2361 CFG80211_CONN_ASSOCIATING,
2362 + CFG80211_CONN_ASSOC_FAILED,
2363 CFG80211_CONN_DEAUTH,
2364 CFG80211_CONN_CONNECTED,
2366 @@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct
2368 params->key, params->key_len,
2369 params->key_idx, NULL, 0);
2370 + case CFG80211_CONN_AUTH_FAILED:
2372 case CFG80211_CONN_ASSOCIATE_NEXT:
2373 BUG_ON(!rdev->ops->assoc);
2374 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
2375 @@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct
2376 WLAN_REASON_DEAUTH_LEAVING,
2379 + case CFG80211_CONN_ASSOC_FAILED:
2380 + cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
2382 + WLAN_REASON_DEAUTH_LEAVING, false);
2384 case CFG80211_CONN_DEAUTH:
2385 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
2387 WLAN_REASON_DEAUTH_LEAVING, false);
2388 + /* free directly, disconnected event already sent */
2389 + cfg80211_sme_free(wdev);
2393 @@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
2397 - wdev->conn->state = CFG80211_CONN_DEAUTH;
2398 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
2399 schedule_work(&rdev->conn_work);
2402 @@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
2404 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
2406 - cfg80211_sme_free(wdev);
2407 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
2412 + wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
2413 + schedule_work(&rdev->conn_work);
2416 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
2417 @@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
2419 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
2421 - cfg80211_sme_disassoc(wdev);
2422 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
2427 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
2428 + schedule_work(&rdev->conn_work);
2431 static int cfg80211_sme_connect(struct wireless_dev *wdev,
2432 @@ -953,21 +976,19 @@ int cfg80211_disconnect(struct cfg80211_
2433 struct net_device *dev, u16 reason, bool wextev)
2435 struct wireless_dev *wdev = dev->ieee80211_ptr;
2439 ASSERT_WDEV_LOCK(wdev);
2441 kfree(wdev->connect_keys);
2442 wdev->connect_keys = NULL;
2446 err = cfg80211_sme_disconnect(wdev, reason);
2447 - } else if (!rdev->ops->disconnect) {
2448 + else if (!rdev->ops->disconnect)
2449 cfg80211_mlme_down(rdev, dev);
2452 + else if (wdev->current_bss)
2453 err = rdev_disconnect(rdev, dev, reason);
2458 --- a/net/mac80211/rc80211_minstrel.c
2459 +++ b/net/mac80211/rc80211_minstrel.c
2460 @@ -203,6 +203,15 @@ minstrel_update_stats(struct minstrel_pr
2461 memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate));
2462 mi->max_prob_rate = tmp_prob_rate;
2464 +#ifdef CPTCFG_MAC80211_DEBUGFS
2465 + /* use fixed index if set */
2466 + if (mp->fixed_rate_idx != -1) {
2467 + mi->max_tp_rate[0] = mp->fixed_rate_idx;
2468 + mi->max_tp_rate[1] = mp->fixed_rate_idx;
2469 + mi->max_prob_rate = mp->fixed_rate_idx;
2473 /* Reset update timer */
2474 mi->stats_update = jiffies;
2476 @@ -290,7 +299,7 @@ minstrel_get_rate(void *priv, struct iee
2477 struct minstrel_rate *msr, *mr;
2480 - bool prev_sample = mi->prev_sample;
2485 @@ -310,10 +319,16 @@ minstrel_get_rate(void *priv, struct iee
2486 /* increase sum packet counter */
2489 +#ifdef CPTCFG_MAC80211_DEBUGFS
2490 + if (mp->fixed_rate_idx != -1)
2494 delta = (mi->packet_count * sampling_ratio / 100) -
2495 (mi->sample_count + mi->sample_deferred / 2);
2497 /* delta < 0: no sampling required */
2498 + prev_sample = mi->prev_sample;
2499 mi->prev_sample = false;
2500 if (delta < 0 || (!mrr_capable && prev_sample))
2502 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
2503 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
2504 @@ -936,13 +936,8 @@ void rt2x00queue_index_inc(struct queue_
2505 spin_unlock_irqrestore(&queue->index_lock, irqflags);
2508 -void rt2x00queue_pause_queue(struct data_queue *queue)
2509 +void rt2x00queue_pause_queue_nocheck(struct data_queue *queue)
2511 - if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
2512 - !test_bit(QUEUE_STARTED, &queue->flags) ||
2513 - test_and_set_bit(QUEUE_PAUSED, &queue->flags))
2516 switch (queue->qid) {
2519 @@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data
2523 +void rt2x00queue_pause_queue(struct data_queue *queue)
2525 + if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
2526 + !test_bit(QUEUE_STARTED, &queue->flags) ||
2527 + test_and_set_bit(QUEUE_PAUSED, &queue->flags))
2530 + rt2x00queue_pause_queue_nocheck(queue);
2532 EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
2534 void rt2x00queue_unpause_queue(struct data_queue *queue)
2535 @@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_
2539 - rt2x00queue_pause_queue(queue);
2540 + rt2x00queue_pause_queue_nocheck(queue);
2542 queue->rt2x00dev->ops->lib->stop_queue(queue);
2544 --- a/net/mac80211/mlme.c
2545 +++ b/net/mac80211/mlme.c
2549 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
2550 +#define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2)
2551 #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
2552 #define IEEE80211_AUTH_MAX_TRIES 3
2553 #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
2554 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
2555 +#define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)
2556 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
2557 #define IEEE80211_ASSOC_MAX_TRIES 3
2559 @@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee
2560 struct ieee80211_channel *channel,
2561 const struct ieee80211_ht_operation *ht_oper,
2562 const struct ieee80211_vht_operation *vht_oper,
2563 - struct cfg80211_chan_def *chandef, bool verbose)
2564 + struct cfg80211_chan_def *chandef, bool tracking)
2566 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2567 struct cfg80211_chan_def vht_chandef;
2570 @@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee
2571 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
2573 /* check that channel matches the right operating channel */
2574 - if (channel->center_freq != ht_cfreq) {
2575 + if (!tracking && channel->center_freq != ht_cfreq) {
2577 * It's possible that some APs are confused here;
2578 * Netgear WNDR3700 sometimes reports 4 higher than
2579 @@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee
2580 * since we look at probe response/beacon data here
2585 - "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
2586 - channel->center_freq, ht_cfreq,
2587 - ht_oper->primary_chan, channel->band);
2589 + "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
2590 + channel->center_freq, ht_cfreq,
2591 + ht_oper->primary_chan, channel->band);
2592 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
2595 @@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee
2600 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2602 "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
2603 vht_oper->chan_width);
2604 @@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee
2607 if (!cfg80211_chandef_valid(&vht_chandef)) {
2609 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2611 "AP VHT information is invalid, disable VHT\n");
2612 ret = IEEE80211_STA_DISABLE_VHT;
2613 @@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee
2616 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
2618 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2620 "AP VHT information doesn't match HT, disable VHT\n");
2621 ret = IEEE80211_STA_DISABLE_VHT;
2622 @@ -333,18 +335,27 @@ out:
2623 if (ret & IEEE80211_STA_DISABLE_VHT)
2624 vht_chandef = *chandef;
2627 + * Ignore the DISABLED flag when we're already connected and only
2628 + * tracking the APs beacon for bandwidth changes - otherwise we
2629 + * might get disconnected here if we connect to an AP, update our
2630 + * regulatory information based on the AP's country IE and the
2631 + * information we have is wrong/outdated and disables the channel
2632 + * that we're actually using for the connection to the AP.
2634 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
2635 - IEEE80211_CHAN_DISABLED)) {
2637 + IEEE80211_CHAN_DISABLED)) {
2638 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
2639 ret = IEEE80211_STA_DISABLE_HT |
2640 IEEE80211_STA_DISABLE_VHT;
2645 ret |= chandef_downgrade(chandef);
2648 - if (chandef->width != vht_chandef.width && verbose)
2649 + if (chandef->width != vht_chandef.width && !tracking)
2651 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
2653 @@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ie
2655 /* calculate new channel (type) based on HT/VHT operation IEs */
2656 flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper,
2657 - vht_oper, &chandef, false);
2658 + vht_oper, &chandef, true);
2661 * Downgrade the new channel if we associated with restricted
2662 @@ -1043,6 +1054,13 @@ ieee80211_sta_process_chanswitch(struct
2663 if (!ieee80211_operating_class_to_band(
2664 elems->ext_chansw_ie->new_operating_class,
2667 + * Some APs send invalid ECSA IEs in probe response
2668 + * frames, so check for these and ignore them.
2670 + if (beacon && elems->ext_chansw_ie->new_ch_num == 0 &&
2671 + elems->ext_chansw_ie->new_operating_class == 0)
2674 "cannot understand ECSA IE operating class %d, disconnecting\n",
2675 elems->ext_chansw_ie->new_operating_class);
2676 @@ -1110,6 +1128,15 @@ ieee80211_sta_process_chanswitch(struct
2678 cfg80211_chandef_create(&new_chandef, new_chan,
2679 NL80211_CHAN_NO_HT);
2680 + /* keep width for 5/10 MHz channels */
2681 + switch (sdata->vif.bss_conf.chandef.width) {
2682 + case NL80211_CHAN_WIDTH_5:
2683 + case NL80211_CHAN_WIDTH_10:
2684 + new_chandef.width = sdata->vif.bss_conf.chandef.width;
2692 @@ -3394,10 +3421,13 @@ static int ieee80211_probe_auth(struct i
2694 if (tx_flags == 0) {
2695 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
2696 - ifmgd->auth_data->timeout_started = true;
2697 + auth_data->timeout_started = true;
2698 run_again(sdata, auth_data->timeout);
2700 - auth_data->timeout_started = false;
2701 + auth_data->timeout =
2702 + round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
2703 + auth_data->timeout_started = true;
2704 + run_again(sdata, auth_data->timeout);
2708 @@ -3434,7 +3464,11 @@ static int ieee80211_do_assoc(struct iee
2709 assoc_data->timeout_started = true;
2710 run_again(sdata, assoc_data->timeout);
2712 - assoc_data->timeout_started = false;
2713 + assoc_data->timeout =
2714 + round_jiffies_up(jiffies +
2715 + IEEE80211_ASSOC_TIMEOUT_LONG);
2716 + assoc_data->timeout_started = true;
2717 + run_again(sdata, assoc_data->timeout);
2721 @@ -3829,7 +3863,7 @@ static int ieee80211_prep_channel(struct
2722 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
2728 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
2730 --- a/net/wireless/core.c
2731 +++ b/net/wireless/core.c
2732 @@ -772,6 +772,7 @@ void cfg80211_leave(struct cfg80211_regi
2733 cfg80211_leave_mesh(rdev, dev);
2735 case NL80211_IFTYPE_AP:
2736 + case NL80211_IFTYPE_P2P_GO:
2737 cfg80211_stop_ap(rdev, dev);
2740 --- a/drivers/net/wireless/rtlwifi/Kconfig
2741 +++ b/drivers/net/wireless/rtlwifi/Kconfig
2744 - tristate "Realtek wireless card support"
2745 +menuconfig RTL_CARDS
2746 + tristate "Realtek rtlwifi family of devices"
2748 - depends on MAC80211
2749 - select BACKPORT_FW_LOADER
2751 - This is common code for RTL8192CE/RTL8192CU/RTL8192SE/RTL8723AE
2752 - drivers. This module does nothing by itself - the various front-end
2753 - drivers need to be enabled to support any desired devices.
2755 - If you choose to build as a module, it'll be called rtlwifi.
2757 -config RTLWIFI_DEBUG
2758 - bool "Debugging output for rtlwifi driver family"
2759 - depends on RTLWIFI
2760 + depends on MAC80211 && (PCI || USB)
2763 - To use the module option that sets the dynamic-debugging level for,
2764 - the front-end driver, this parameter must be "Y". For memory-limited
2765 - systems, choose "N". If in doubt, choose "Y".
2766 + This option will enable support for the Realtek mac80211-based
2767 + wireless drivers. Drivers rtl8192ce, rtl8192cu, rtl8192se, rtl8192de,
2768 + rtl8723eu, and rtl8188eu share some common code.
2773 tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter"
2775 - depends on RTLWIFI && PCI
2777 select RTL8192C_COMMON
2779 + select RTLWIFI_PCI
2781 This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe
2782 wireless network adapters.
2783 @@ -33,7 +26,9 @@ config RTL8192CE
2785 tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter"
2787 - depends on RTLWIFI && PCI
2790 + select RTLWIFI_PCI
2792 This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe
2793 wireless network adapters.
2794 @@ -43,7 +38,9 @@ config RTL8192SE
2796 tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter"
2798 - depends on RTLWIFI && PCI
2801 + select RTLWIFI_PCI
2803 This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe
2804 wireless network adapters.
2805 @@ -53,7 +50,9 @@ config RTL8192DE
2807 tristate "Realtek RTL8723AE PCIe Wireless Network Adapter"
2809 - depends on RTLWIFI && PCI
2812 + select RTLWIFI_PCI
2814 This is the driver for Realtek RTL8723AE 802.11n PCIe
2815 wireless network adapters.
2816 @@ -63,7 +62,9 @@ config RTL8723AE
2818 tristate "Realtek RTL8188EE Wireless Network Adapter"
2820 - depends on RTLWIFI && PCI
2823 + select RTLWIFI_PCI
2825 This is the driver for Realtek RTL8188EE 802.11n PCIe
2826 wireless network adapters.
2827 @@ -73,7 +74,9 @@ config RTL8188EE
2829 tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter"
2831 - depends on RTLWIFI && USB
2834 + select RTLWIFI_USB
2835 select RTL8192C_COMMON
2837 This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB
2838 @@ -81,8 +84,32 @@ config RTL8192CU
2840 If you choose to build it as a module, it will be called rtl8192cu
2845 + select BACKPORT_FW_LOADER
2855 +config RTLWIFI_DEBUG
2856 + bool "Debugging output for rtlwifi driver family"
2857 + depends on RTLWIFI
2860 + To use the module option that sets the dynamic-debugging level for,
2861 + the front-end driver, this parameter must be "Y". For memory-limited
2862 + systems, choose "N". If in doubt, choose "Y".
2864 config RTL8192C_COMMON
2867 depends on RTL8192CE || RTL8192CU
2872 --- a/drivers/net/wireless/rtlwifi/Makefile
2873 +++ b/drivers/net/wireless/rtlwifi/Makefile
2874 @@ -12,13 +12,11 @@ rtlwifi-objs := \
2876 rtl8192c_common-objs += \
2878 -ifneq ($(CONFIG_PCI),)
2879 -rtlwifi-objs += pci.o
2881 +obj-$(CPTCFG_RTLWIFI_PCI) += rtl_pci.o
2882 +rtl_pci-objs := pci.o
2884 -ifneq ($(CONFIG_USB),)
2885 -rtlwifi-objs += usb.o
2887 +obj-$(CPTCFG_RTLWIFI_USB) += rtl_usb.o
2888 +rtl_usb-objs := usb.o
2890 obj-$(CPTCFG_RTL8192C_COMMON) += rtl8192c/
2891 obj-$(CPTCFG_RTL8192CE) += rtl8192ce/
2892 --- a/drivers/net/wireless/rtlwifi/ps.h
2893 +++ b/drivers/net/wireless/rtlwifi/ps.h
2894 @@ -49,5 +49,6 @@ void rtl_swlps_rf_awake(struct ieee80211
2895 void rtl_swlps_rf_sleep(struct ieee80211_hw *hw);
2896 void rtl_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
2897 void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len);
2898 +void rtl_lps_change_work_callback(struct work_struct *work);
2901 --- a/drivers/net/wireless/rtlwifi/base.c
2902 +++ b/drivers/net/wireless/rtlwifi/base.c
2903 @@ -173,6 +173,7 @@ u8 rtl_tid_to_ac(u8 tid)
2905 return tid_to_ac[tid];
2907 +EXPORT_SYMBOL_GPL(rtl_tid_to_ac);
2909 static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
2910 struct ieee80211_sta_ht_cap *ht_cap)
2911 @@ -407,6 +408,7 @@ void rtl_deinit_deferred_work(struct iee
2912 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
2913 cancel_delayed_work(&rtlpriv->works.fwevt_wq);
2915 +EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
2917 void rtl_init_rfkill(struct ieee80211_hw *hw)
2919 @@ -440,6 +442,7 @@ void rtl_deinit_rfkill(struct ieee80211_
2921 wiphy_rfkill_stop_polling(hw->wiphy);
2923 +EXPORT_SYMBOL_GPL(rtl_deinit_rfkill);
2925 int rtl_init_core(struct ieee80211_hw *hw)
2927 @@ -490,10 +493,12 @@ int rtl_init_core(struct ieee80211_hw *h
2931 +EXPORT_SYMBOL_GPL(rtl_init_core);
2933 void rtl_deinit_core(struct ieee80211_hw *hw)
2936 +EXPORT_SYMBOL_GPL(rtl_deinit_core);
2938 void rtl_init_rx_config(struct ieee80211_hw *hw)
2940 @@ -502,6 +507,7 @@ void rtl_init_rx_config(struct ieee80211
2942 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf));
2944 +EXPORT_SYMBOL_GPL(rtl_init_rx_config);
2946 /*********************************************************
2948 @@ -880,6 +886,7 @@ bool rtl_tx_mgmt_proc(struct ieee80211_h
2952 +EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc);
2954 void rtl_get_tcb_desc(struct ieee80211_hw *hw,
2955 struct ieee80211_tx_info *info,
2956 @@ -1053,6 +1060,7 @@ bool rtl_action_proc(struct ieee80211_hw
2960 +EXPORT_SYMBOL_GPL(rtl_action_proc);
2962 /*should call before software enc*/
2963 u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
2964 @@ -1126,6 +1134,7 @@ u8 rtl_is_special_data(struct ieee80211_
2968 +EXPORT_SYMBOL_GPL(rtl_is_special_data);
2970 /*********************************************************
2972 @@ -1301,6 +1310,7 @@ void rtl_beacon_statistic(struct ieee802
2974 rtlpriv->link_info.bcn_rx_inperiod++;
2976 +EXPORT_SYMBOL_GPL(rtl_beacon_statistic);
2978 void rtl_watchdog_wq_callback(void *data)
2980 @@ -1794,6 +1804,7 @@ void rtl_recognize_peer(struct ieee80211
2982 mac->vendor = vendor;
2984 +EXPORT_SYMBOL_GPL(rtl_recognize_peer);
2986 /*********************************************************
2988 @@ -1850,6 +1861,7 @@ struct attribute_group rtl_attribute_gro
2990 .attrs = rtl_sysfs_entries,
2992 +EXPORT_SYMBOL_GPL(rtl_attribute_group);
2994 MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
2995 MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
2996 @@ -1857,7 +1869,8 @@ MODULE_AUTHOR("Larry Finger <Larry.FInge
2997 MODULE_LICENSE("GPL");
2998 MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
3000 -struct rtl_global_var global_var = {};
3001 +struct rtl_global_var rtl_global_var = {};
3002 +EXPORT_SYMBOL_GPL(rtl_global_var);
3004 static int __init rtl_core_module_init(void)
3006 @@ -1865,8 +1878,8 @@ static int __init rtl_core_module_init(v
3007 pr_err("Unable to register rtl_rc, use default RC !!\n");
3009 /* init some global vars */
3010 - INIT_LIST_HEAD(&global_var.glb_priv_list);
3011 - spin_lock_init(&global_var.glb_list_lock);
3012 + INIT_LIST_HEAD(&rtl_global_var.glb_priv_list);
3013 + spin_lock_init(&rtl_global_var.glb_list_lock);
3017 --- a/drivers/net/wireless/rtlwifi/base.h
3018 +++ b/drivers/net/wireless/rtlwifi/base.h
3019 @@ -147,7 +147,7 @@ void rtl_recognize_peer(struct ieee80211
3020 u8 rtl_tid_to_ac(u8 tid);
3021 extern struct attribute_group rtl_attribute_group;
3022 void rtl_easy_concurrent_retrytimer_callback(unsigned long data);
3023 -extern struct rtl_global_var global_var;
3024 +extern struct rtl_global_var rtl_global_var;
3025 int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
3026 bool isht, u8 desc_rate, bool first_ampdu);
3027 bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
3028 --- a/drivers/net/wireless/rtlwifi/core.c
3029 +++ b/drivers/net/wireless/rtlwifi/core.c
3030 @@ -1330,3 +1330,4 @@ const struct ieee80211_ops rtl_ops = {
3031 .rfkill_poll = rtl_op_rfkill_poll,
3032 .flush = rtl_op_flush,
3034 +EXPORT_SYMBOL_GPL(rtl_ops);
3035 --- a/drivers/net/wireless/rtlwifi/debug.c
3036 +++ b/drivers/net/wireless/rtlwifi/debug.c
3037 @@ -51,3 +51,4 @@ void rtl_dbgp_flag_init(struct ieee80211
3039 /*Init Debug flag enable condition */
3041 +EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
3042 --- a/drivers/net/wireless/rtlwifi/efuse.c
3043 +++ b/drivers/net/wireless/rtlwifi/efuse.c
3044 @@ -229,6 +229,7 @@ void read_efuse_byte(struct ieee80211_hw
3046 *pbuf = (u8) (value32 & 0xff);
3048 +EXPORT_SYMBOL_GPL(read_efuse_byte);
3050 void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
3052 --- a/drivers/net/wireless/rtlwifi/pci.c
3053 +++ b/drivers/net/wireless/rtlwifi/pci.c
3056 #include <linux/export.h>
3057 #include <linux/kmemleak.h>
3058 +#include <linux/module.h>
3060 +MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
3061 +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
3062 +MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
3063 +MODULE_LICENSE("GPL");
3064 +MODULE_DESCRIPTION("PCI basic driver for rtlwifi");
3066 static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = {
3067 PCI_VENDOR_ID_INTEL,
3068 @@ -1008,19 +1015,6 @@ static void _rtl_pci_prepare_bcn_tasklet
3072 -static void rtl_lps_change_work_callback(struct work_struct *work)
3074 - struct rtl_works *rtlworks =
3075 - container_of(work, struct rtl_works, lps_change_work);
3076 - struct ieee80211_hw *hw = rtlworks->hw;
3077 - struct rtl_priv *rtlpriv = rtl_priv(hw);
3079 - if (rtlpriv->enter_ps)
3080 - rtl_lps_enter(hw);
3082 - rtl_lps_leave(hw);
3085 static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
3087 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
3088 @@ -1899,7 +1893,7 @@ int rtl_pci_probe(struct pci_dev *pdev,
3089 rtlpriv->rtlhal.interface = INTF_PCI;
3090 rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data);
3091 rtlpriv->intf_ops = &rtl_pci_ops;
3092 - rtlpriv->glb_var = &global_var;
3093 + rtlpriv->glb_var = &rtl_global_var;
3096 *init dbgp flags before all
3097 --- a/drivers/net/wireless/rtlwifi/ps.c
3098 +++ b/drivers/net/wireless/rtlwifi/ps.c
3099 @@ -269,6 +269,7 @@ void rtl_ips_nic_on(struct ieee80211_hw
3101 spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags);
3103 +EXPORT_SYMBOL_GPL(rtl_ips_nic_on);
3107 @@ -518,6 +519,7 @@ void rtl_swlps_beacon(struct ieee80211_h
3108 "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed);
3111 +EXPORT_SYMBOL_GPL(rtl_swlps_beacon);
3113 void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
3115 @@ -611,6 +613,19 @@ void rtl_swlps_rf_sleep(struct ieee80211
3116 MSECS(sleep_intv * mac->vif->bss_conf.beacon_int - 40));
3119 +void rtl_lps_change_work_callback(struct work_struct *work)
3121 + struct rtl_works *rtlworks =
3122 + container_of(work, struct rtl_works, lps_change_work);
3123 + struct ieee80211_hw *hw = rtlworks->hw;
3124 + struct rtl_priv *rtlpriv = rtl_priv(hw);
3126 + if (rtlpriv->enter_ps)
3127 + rtl_lps_enter(hw);
3129 + rtl_lps_leave(hw);
3131 +EXPORT_SYMBOL_GPL(rtl_lps_change_work_callback);
3133 void rtl_swlps_wq_callback(void *data)
3135 @@ -922,3 +937,4 @@ void rtl_p2p_info(struct ieee80211_hw *h
3137 rtl_p2p_noa_ie(hw, data, len - FCS_LEN);
3139 +EXPORT_SYMBOL_GPL(rtl_p2p_info);
3140 --- a/drivers/net/wireless/rtlwifi/usb.c
3141 +++ b/drivers/net/wireless/rtlwifi/usb.c
3144 #include "rtl8192c/fw_common.h"
3145 #include <linux/export.h>
3146 +#include <linux/module.h>
3148 +MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
3149 +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
3150 +MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
3151 +MODULE_LICENSE("GPL");
3152 +MODULE_DESCRIPTION("USB basic driver for rtlwifi");
3154 #define REALTEK_USB_VENQT_READ 0xC0
3155 #define REALTEK_USB_VENQT_WRITE 0x40
3156 @@ -1070,6 +1077,8 @@ int rtl_usb_probe(struct usb_interface *
3157 spin_lock_init(&rtlpriv->locks.usb_lock);
3158 INIT_WORK(&rtlpriv->works.fill_h2c_cmd,
3159 rtl_fill_h2c_cmd_work_callback);
3160 + INIT_WORK(&rtlpriv->works.lps_change_work,
3161 + rtl_lps_change_work_callback);
3163 rtlpriv->usb_data_index = 0;
3164 init_completion(&rtlpriv->firmware_loading_complete);
3165 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
3166 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3167 @@ -72,17 +72,12 @@ struct ath_config {
3168 /*************************/
3170 #define ATH_TXBUF_RESET(_bf) do { \
3171 - (_bf)->bf_stale = false; \
3172 (_bf)->bf_lastbf = NULL; \
3173 (_bf)->bf_next = NULL; \
3174 memset(&((_bf)->bf_state), 0, \
3175 sizeof(struct ath_buf_state)); \
3178 -#define ATH_RXBUF_RESET(_bf) do { \
3179 - (_bf)->bf_stale = false; \
3183 * enum buffer_type - Buffer type flags
3185 @@ -137,7 +132,8 @@ int ath_descdma_setup(struct ath_softc *
3186 #define ATH_AGGR_ENCRYPTDELIM 10
3187 /* minimum h/w qdepth to be sustained to maximize aggregation */
3188 #define ATH_AGGR_MIN_QDEPTH 2
3189 -#define ATH_AMPDU_SUBFRAME_DEFAULT 32
3190 +/* minimum h/w qdepth for non-aggregated traffic */
3191 +#define ATH_NON_AGGR_MIN_QDEPTH 8
3193 #define IEEE80211_SEQ_SEQ_SHIFT 4
3194 #define IEEE80211_SEQ_MAX 4096
3195 @@ -174,12 +170,6 @@ int ath_descdma_setup(struct ath_softc *
3197 #define ATH_TX_COMPLETE_POLL_INT 1000
3199 -enum ATH_AGGR_STATUS {
3201 - ATH_AGGR_BAW_CLOSED,
3205 #define ATH_TXFIFO_DEPTH 8
3207 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */
3208 @@ -201,10 +191,10 @@ struct ath_txq {
3211 struct ath_txq *txq;
3213 struct list_head list;
3214 struct list_head tid_q;
3215 bool clear_ps_filter;
3219 struct ath_frame_info {
3220 @@ -212,14 +202,16 @@ struct ath_frame_info {
3222 enum ath9k_key_type keytype;
3227 + u8 baw_tracked : 1;
3230 struct ath_buf_state {
3236 unsigned long bfs_paprd_timestamp;
3238 @@ -233,7 +225,6 @@ struct ath_buf {
3239 void *bf_desc; /* virtual addr of desc */
3240 dma_addr_t bf_daddr; /* physical addr of desc */
3241 dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */
3243 struct ieee80211_tx_rate rates[4];
3244 struct ath_buf_state bf_state;
3246 @@ -241,16 +232,18 @@ struct ath_buf {
3247 struct ath_atx_tid {
3248 struct list_head list;
3249 struct sk_buff_head buf_q;
3250 + struct sk_buff_head retry_q;
3251 struct ath_node *an;
3252 struct ath_atx_ac *ac;
3253 unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
3260 int baw_head; /* first un-acked tx buffer */
3261 int baw_tail; /* next unused tx buffer slot */
3267 @@ -262,12 +255,13 @@ struct ath_node {
3268 struct ieee80211_vif *vif; /* interface with which we're associated */
3269 struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
3270 struct ath_atx_ac ac[IEEE80211_NUM_ACS];
3278 + bool no_ps_filter;
3280 #if defined(CPTCFG_MAC80211_DEBUGFS) && defined(CPTCFG_ATH9K_DEBUGFS)
3281 struct dentry *node_stat;
3282 @@ -317,6 +311,7 @@ struct ath_rx {
3283 struct ath_descdma rxdma;
3284 struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX];
3286 + struct ath_buf *buf_hold;
3287 struct sk_buff *frag;
3290 @@ -367,6 +362,7 @@ void ath9k_release_buffered_frames(struc
3294 + struct ath_node mcast_node;
3296 bool primary_sta_vif;
3297 __le64 tsf_adjust; /* TSF adjustment for staggered beacons */
3298 @@ -585,19 +581,14 @@ static inline void ath_fill_led_pin(stru
3299 #define ATH_ANT_DIV_COMB_MAX_COUNT 100
3300 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30
3301 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20
3302 +#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50
3303 +#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50
3305 #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1
3306 #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4
3307 #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2
3308 #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2
3310 -enum ath9k_ant_div_comb_lna_conf {
3311 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2,
3312 - ATH_ANT_DIV_COMB_LNA2,
3313 - ATH_ANT_DIV_COMB_LNA1,
3314 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2,
3317 struct ath_ant_comb {
3319 u16 total_pkt_count;
3320 @@ -614,27 +605,36 @@ struct ath_ant_comb {
3329 + enum ath9k_ant_div_comb_lna_conf main_conf;
3330 enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf;
3331 enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf;
3334 unsigned long scan_start_time;
3337 + * Card-specific config values.
3339 + int low_rssi_thresh;
3340 + int fast_div_bias;
3343 void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
3344 -void ath_ant_comb_update(struct ath_softc *sc);
3346 /********************/
3347 /* Main driver core */
3348 /********************/
3350 -#define ATH9K_PCI_CUS198 0x0001
3351 -#define ATH9K_PCI_CUS230 0x0002
3352 -#define ATH9K_PCI_CUS217 0x0004
3353 -#define ATH9K_PCI_WOW 0x0008
3354 +#define ATH9K_PCI_CUS198 0x0001
3355 +#define ATH9K_PCI_CUS230 0x0002
3356 +#define ATH9K_PCI_CUS217 0x0004
3357 +#define ATH9K_PCI_WOW 0x0008
3358 +#define ATH9K_PCI_BT_ANT_DIV 0x0010
3359 +#define ATH9K_PCI_D3_L1_WAR 0x0020
3362 * Default cache line size, in bytes.
3363 --- a/drivers/net/wireless/ath/ath9k/debug.c
3364 +++ b/drivers/net/wireless/ath/ath9k/debug.c
3365 @@ -270,25 +270,29 @@ static const struct file_operations fops
3366 .llseek = default_llseek,
3369 -static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
3370 - size_t count, loff_t *ppos)
3371 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
3373 +static ssize_t read_file_bt_ant_diversity(struct file *file,
3374 + char __user *user_buf,
3375 + size_t count, loff_t *ppos)
3377 struct ath_softc *sc = file->private_data;
3378 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
3382 - len = sprintf(buf, "%d\n", common->antenna_diversity);
3383 + len = sprintf(buf, "%d\n", common->bt_ant_diversity);
3384 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
3387 -static ssize_t write_file_ant_diversity(struct file *file,
3388 - const char __user *user_buf,
3389 - size_t count, loff_t *ppos)
3390 +static ssize_t write_file_bt_ant_diversity(struct file *file,
3391 + const char __user *user_buf,
3392 + size_t count, loff_t *ppos)
3394 struct ath_softc *sc = file->private_data;
3395 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
3396 - unsigned long antenna_diversity;
3397 + struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps;
3398 + unsigned long bt_ant_diversity;
3402 @@ -296,26 +300,147 @@ static ssize_t write_file_ant_diversity(
3403 if (copy_from_user(buf, user_buf, len))
3406 - if (!AR_SREV_9565(sc->sc_ah))
3407 + if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV))
3411 - if (strict_strtoul(buf, 0, &antenna_diversity))
3412 + if (kstrtoul(buf, 0, &bt_ant_diversity))
3415 - common->antenna_diversity = !!antenna_diversity;
3416 + common->bt_ant_diversity = !!bt_ant_diversity;
3417 ath9k_ps_wakeup(sc);
3418 - ath_ant_comb_update(sc);
3419 - ath_dbg(common, CONFIG, "Antenna diversity: %d\n",
3420 - common->antenna_diversity);
3421 + ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity);
3422 + ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n",
3423 + common->bt_ant_diversity);
3424 ath9k_ps_restore(sc);
3429 -static const struct file_operations fops_ant_diversity = {
3430 - .read = read_file_ant_diversity,
3431 - .write = write_file_ant_diversity,
3432 +static const struct file_operations fops_bt_ant_diversity = {
3433 + .read = read_file_bt_ant_diversity,
3434 + .write = write_file_bt_ant_diversity,
3435 + .open = simple_open,
3436 + .owner = THIS_MODULE,
3437 + .llseek = default_llseek,
3442 +void ath9k_debug_stat_ant(struct ath_softc *sc,
3443 + struct ath_hw_antcomb_conf *div_ant_conf,
3444 + int main_rssi_avg, int alt_rssi_avg)
3446 + struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
3447 + struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
3449 + as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++;
3450 + as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++;
3452 + as_main->rssi_avg = main_rssi_avg;
3453 + as_alt->rssi_avg = alt_rssi_avg;
3456 +static ssize_t read_file_antenna_diversity(struct file *file,
3457 + char __user *user_buf,
3458 + size_t count, loff_t *ppos)
3460 + struct ath_softc *sc = file->private_data;
3461 + struct ath_hw *ah = sc->sc_ah;
3462 + struct ath9k_hw_capabilities *pCap = &ah->caps;
3463 + struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
3464 + struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
3465 + struct ath_hw_antcomb_conf div_ant_conf;
3466 + unsigned int len = 0, size = 1024;
3467 + ssize_t retval = 0;
3469 + char *lna_conf_str[4] = {"LNA1_MINUS_LNA2",
3472 + "LNA1_PLUS_LNA2"};
3474 + buf = kzalloc(size, GFP_KERNEL);
3478 + if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) {
3479 + len += snprintf(buf + len, size - len, "%s\n",
3480 + "Antenna Diversity Combining is disabled");
3484 + ath9k_ps_wakeup(sc);
3485 + ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
3486 + len += snprintf(buf + len, size - len, "Current MAIN config : %s\n",
3487 + lna_conf_str[div_ant_conf.main_lna_conf]);
3488 + len += snprintf(buf + len, size - len, "Current ALT config : %s\n",
3489 + lna_conf_str[div_ant_conf.alt_lna_conf]);
3490 + len += snprintf(buf + len, size - len, "Average MAIN RSSI : %d\n",
3491 + as_main->rssi_avg);
3492 + len += snprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n",
3493 + as_alt->rssi_avg);
3494 + ath9k_ps_restore(sc);
3496 + len += snprintf(buf + len, size - len, "Packet Receive Cnt:\n");
3497 + len += snprintf(buf + len, size - len, "-------------------\n");
3499 + len += snprintf(buf + len, size - len, "%30s%15s\n",
3501 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3503 + as_main->recv_cnt,
3504 + as_alt->recv_cnt);
3505 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3507 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1],
3508 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]);
3509 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3511 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2],
3512 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]);
3513 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3515 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
3516 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
3517 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3519 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
3520 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
3522 + len += snprintf(buf + len, size - len, "\nLNA Config Attempts:\n");
3523 + len += snprintf(buf + len, size - len, "--------------------\n");
3525 + len += snprintf(buf + len, size - len, "%30s%15s\n",
3527 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3529 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1],
3530 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]);
3531 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3533 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2],
3534 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]);
3535 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3537 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
3538 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
3539 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3541 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
3542 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
3548 + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
3554 +static const struct file_operations fops_antenna_diversity = {
3555 + .read = read_file_antenna_diversity,
3556 .open = simple_open,
3557 .owner = THIS_MODULE,
3558 .llseek = default_llseek,
3559 @@ -607,6 +732,28 @@ static ssize_t read_file_xmit(struct fil
3563 +static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq,
3564 + char *buf, ssize_t size)
3568 + ath_txq_lock(sc, txq);
3570 + len += snprintf(buf + len, size - len, "%s: %d ",
3571 + "qnum", txq->axq_qnum);
3572 + len += snprintf(buf + len, size - len, "%s: %2d ",
3573 + "qdepth", txq->axq_depth);
3574 + len += snprintf(buf + len, size - len, "%s: %2d ",
3575 + "ampdu-depth", txq->axq_ampdu_depth);
3576 + len += snprintf(buf + len, size - len, "%s: %3d ",
3577 + "pending", txq->pending_frames);
3578 + len += snprintf(buf + len, size - len, "%s: %d\n",
3579 + "stopped", txq->stopped);
3581 + ath_txq_unlock(sc, txq);
3585 static ssize_t read_file_queues(struct file *file, char __user *user_buf,
3586 size_t count, loff_t *ppos)
3588 @@ -624,24 +771,13 @@ static ssize_t read_file_queues(struct f
3590 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
3591 txq = sc->tx.txq_map[i];
3592 - len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
3594 - ath_txq_lock(sc, txq);
3596 - len += snprintf(buf + len, size - len, "%s: %d ",
3597 - "qnum", txq->axq_qnum);
3598 - len += snprintf(buf + len, size - len, "%s: %2d ",
3599 - "qdepth", txq->axq_depth);
3600 - len += snprintf(buf + len, size - len, "%s: %2d ",
3601 - "ampdu-depth", txq->axq_ampdu_depth);
3602 - len += snprintf(buf + len, size - len, "%s: %3d ",
3603 - "pending", txq->pending_frames);
3604 - len += snprintf(buf + len, size - len, "%s: %d\n",
3605 - "stopped", txq->stopped);
3607 - ath_txq_unlock(sc, txq);
3608 + len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
3609 + len += print_queue(sc, txq, buf + len, size - len);
3612 + len += snprintf(buf + len, size - len, "(CAB): ");
3613 + len += print_queue(sc, sc->beacon.cabq, buf + len, size - len);
3618 @@ -1818,9 +1954,11 @@ int ath9k_init_debug(struct ath_hw *ah)
3619 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
3620 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
3621 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
3622 - debugfs_create_file("diversity", S_IRUSR | S_IWUSR,
3623 - sc->debug.debugfs_phy, sc, &fops_ant_diversity);
3624 + debugfs_create_file("antenna_diversity", S_IRUSR,
3625 + sc->debug.debugfs_phy, sc, &fops_antenna_diversity);
3626 #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
3627 + debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR,
3628 + sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity);
3629 debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc,
3632 --- a/net/mac80211/ibss.c
3633 +++ b/net/mac80211/ibss.c
3636 #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ)
3637 #define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ)
3638 +#define IEEE80211_IBSS_RSN_INACTIVITY_LIMIT (10 * HZ)
3640 #define IEEE80211_IBSS_MAX_STA_ENTRIES 128
3643 static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
3644 const u8 *bssid, const int beacon_int,
3645 - struct ieee80211_channel *chan,
3646 + struct cfg80211_chan_def *req_chandef,
3647 const u32 basic_rates,
3648 const u16 capability, u64 tsf,
3650 @@ -51,6 +52,7 @@ static void __ieee80211_sta_join_ibss(st
3652 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
3653 struct cfg80211_chan_def chandef;
3654 + struct ieee80211_channel *chan;
3655 struct beacon_data *presp;
3658 @@ -81,7 +83,9 @@ static void __ieee80211_sta_join_ibss(st
3660 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
3662 - chandef = ifibss->chandef;
3663 + /* make a copy of the chandef, it could be modified below. */
3664 + chandef = *req_chandef;
3665 + chan = chandef.chan;
3666 if (!cfg80211_reg_can_beacon(local->hw.wiphy, &chandef)) {
3667 chandef.width = NL80211_CHAN_WIDTH_20;
3668 chandef.center_freq1 = chan->center_freq;
3669 @@ -259,10 +263,12 @@ static void ieee80211_sta_join_ibss(stru
3670 struct cfg80211_bss *cbss =
3671 container_of((void *)bss, struct cfg80211_bss, priv);
3672 struct ieee80211_supported_band *sband;
3673 + struct cfg80211_chan_def chandef;
3676 u16 beacon_int = cbss->beacon_interval;
3677 const struct cfg80211_bss_ies *ies;
3678 + enum nl80211_channel_type chan_type;
3681 sdata_assert_lock(sdata);
3682 @@ -270,6 +276,26 @@ static void ieee80211_sta_join_ibss(stru
3683 if (beacon_int < 10)
3686 + switch (sdata->u.ibss.chandef.width) {
3687 + case NL80211_CHAN_WIDTH_20_NOHT:
3688 + case NL80211_CHAN_WIDTH_20:
3689 + case NL80211_CHAN_WIDTH_40:
3690 + chan_type = cfg80211_get_chandef_type(&sdata->u.ibss.chandef);
3691 + cfg80211_chandef_create(&chandef, cbss->channel, chan_type);
3693 + case NL80211_CHAN_WIDTH_5:
3694 + case NL80211_CHAN_WIDTH_10:
3695 + cfg80211_chandef_create(&chandef, cbss->channel,
3696 + NL80211_CHAN_WIDTH_20_NOHT);
3697 + chandef.width = sdata->u.ibss.chandef.width;
3700 + /* fall back to 20 MHz for unsupported modes */
3701 + cfg80211_chandef_create(&chandef, cbss->channel,
3702 + NL80211_CHAN_WIDTH_20_NOHT);
3706 sband = sdata->local->hw.wiphy->bands[cbss->channel->band];
3709 @@ -294,7 +320,7 @@ static void ieee80211_sta_join_ibss(stru
3711 __ieee80211_sta_join_ibss(sdata, cbss->bssid,
3718 @@ -672,6 +698,33 @@ static int ieee80211_sta_active_ibss(str
3722 +static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
3724 + struct ieee80211_local *local = sdata->local;
3725 + struct sta_info *sta, *tmp;
3726 + unsigned long exp_time = IEEE80211_IBSS_INACTIVITY_LIMIT;
3727 + unsigned long exp_rsn_time = IEEE80211_IBSS_RSN_INACTIVITY_LIMIT;
3729 + mutex_lock(&local->sta_mtx);
3731 + list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
3732 + if (sdata != sta->sdata)
3735 + if (time_after(jiffies, sta->last_rx + exp_time) ||
3736 + (time_after(jiffies, sta->last_rx + exp_rsn_time) &&
3737 + sta->sta_state != IEEE80211_STA_AUTHORIZED)) {
3738 + sta_dbg(sta->sdata, "expiring inactive %sSTA %pM\n",
3739 + sta->sta_state != IEEE80211_STA_AUTHORIZED ?
3740 + "not authorized " : "", sta->sta.addr);
3742 + WARN_ON(__sta_info_destroy(sta));
3746 + mutex_unlock(&local->sta_mtx);
3750 * This function is called with state == IEEE80211_IBSS_MLME_JOINED
3752 @@ -685,7 +738,7 @@ static void ieee80211_sta_merge_ibss(str
3753 mod_timer(&ifibss->timer,
3754 round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL));
3756 - ieee80211_sta_expire(sdata, IEEE80211_IBSS_INACTIVITY_LIMIT);
3757 + ieee80211_ibss_sta_expire(sdata);
3759 if (time_before(jiffies, ifibss->last_scan_completed +
3760 IEEE80211_IBSS_MERGE_INTERVAL))
3761 @@ -736,7 +789,7 @@ static void ieee80211_sta_create_ibss(st
3762 sdata->drop_unencrypted = 0;
3764 __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int,
3765 - ifibss->chandef.chan, ifibss->basic_rates,
3766 + &ifibss->chandef, ifibss->basic_rates,
3767 capability, 0, true);
3770 @@ -792,6 +845,17 @@ static void ieee80211_sta_find_ibss(stru
3774 + /* if a fixed bssid and a fixed freq have been provided create the IBSS
3775 + * directly and do not waste time scanning
3777 + if (ifibss->fixed_bssid && ifibss->fixed_channel) {
3778 + sdata_info(sdata, "Created IBSS using preconfigured BSSID %pM\n",
3780 + ieee80211_sta_create_ibss(sdata);
3785 ibss_dbg(sdata, "sta_find_ibss: did not try to join ibss\n");
3787 /* Selected IBSS not found in current scan results - try to scan */
3788 @@ -1138,6 +1202,7 @@ int ieee80211_ibss_leave(struct ieee8021
3789 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
3790 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
3792 + ieee80211_vif_release_channel(sdata);
3796 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
3797 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
3798 @@ -632,6 +632,22 @@ static void ar9003_hw_override_ini(struc
3800 REG_SET_BIT(ah, AR_PHY_CCK_DETECT,
3801 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
3803 + if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
3804 + REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE,
3805 + AR_GLB_SWREG_DISCONT_EN_BT_WLAN);
3807 + if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
3808 + AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL))
3809 + ah->enabled_cals |= TX_IQ_CAL;
3811 + ah->enabled_cals &= ~TX_IQ_CAL;
3813 + if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE)
3814 + ah->enabled_cals |= TX_CL_CAL;
3816 + ah->enabled_cals &= ~TX_CL_CAL;
3820 static void ar9003_hw_prog_ini(struct ath_hw *ah,
3821 @@ -814,29 +830,12 @@ static int ar9003_hw_process_ini(struct
3822 if (chan->channel == 2484)
3823 ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1);
3825 - if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
3826 - REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE,
3827 - AR_GLB_SWREG_DISCONT_EN_BT_WLAN);
3829 ah->modes_index = modesIndex;
3830 ar9003_hw_override_ini(ah);
3831 ar9003_hw_set_channel_regs(ah, chan);
3832 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
3833 ath9k_hw_apply_txpower(ah, chan, false);
3835 - if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
3836 - if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
3837 - AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL))
3838 - ah->enabled_cals |= TX_IQ_CAL;
3840 - ah->enabled_cals &= ~TX_IQ_CAL;
3842 - if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE)
3843 - ah->enabled_cals |= TX_CL_CAL;
3845 - ah->enabled_cals &= ~TX_CL_CAL;
3851 @@ -1173,6 +1172,10 @@ skip_ws_det:
3852 * is_on == 0 means MRC CCK is OFF (more noise imm)
3854 bool is_on = param ? 1 : 0;
3856 + if (ah->caps.rx_chainmask == 1)
3859 REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
3860 AR_PHY_MRC_CCK_ENABLE, is_on);
3861 REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
3862 @@ -1413,65 +1416,111 @@ static void ar9003_hw_antdiv_comb_conf_s
3863 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
3866 -static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
3868 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
3870 +static void ar9003_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
3872 + struct ath9k_hw_capabilities *pCap = &ah->caps;
3876 - if (!AR_SREV_9565(ah))
3877 + if (!AR_SREV_9485(ah) && !AR_SREV_9565(ah))
3880 - ah->shared_chain_lnadiv = enable;
3881 + if (AR_SREV_9485(ah)) {
3882 + regval = ar9003_hw_ant_ctrl_common_2_get(ah,
3883 + IS_CHAN_2GHZ(ah->curchan));
3885 + regval &= ~AR_SWITCH_TABLE_COM2_ALL;
3886 + regval |= ah->config.ant_ctrl_comm2g_switch_enable;
3888 + REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2,
3889 + AR_SWITCH_TABLE_COM2_ALL, regval);
3892 ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
3895 + * Set MAIN/ALT LNA conf.
3896 + * Set MAIN/ALT gain_tb.
3898 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
3899 regval &= (~AR_ANT_DIV_CTRL_ALL);
3900 regval |= (ant_div_ctl1 & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
3901 - regval &= ~AR_PHY_ANT_DIV_LNADIV;
3902 - regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
3905 - regval |= AR_ANT_DIV_ENABLE;
3907 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
3909 - regval = REG_READ(ah, AR_PHY_CCK_DETECT);
3910 - regval &= ~AR_FAST_DIV_ENABLE;
3911 - regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
3914 - regval |= AR_FAST_DIV_ENABLE;
3916 - REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
3919 - REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
3920 - (1 << AR_PHY_ANT_SW_RX_PROT_S));
3921 - if (ah->curchan && IS_CHAN_2GHZ(ah->curchan))
3922 - REG_SET_BIT(ah, AR_PHY_RESTART,
3923 - AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
3924 - REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
3925 - AR_BTCOEX_WL_LNADIV_FORCE_ON);
3927 - REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE);
3928 - REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
3929 - (1 << AR_PHY_ANT_SW_RX_PROT_S));
3930 - REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE);
3931 - REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
3932 - AR_BTCOEX_WL_LNADIV_FORCE_ON);
3934 + if (AR_SREV_9485_11_OR_LATER(ah)) {
3936 + * Enable LNA diversity.
3938 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
3939 - regval &= ~(AR_PHY_ANT_DIV_MAIN_LNACONF |
3940 - AR_PHY_ANT_DIV_ALT_LNACONF |
3941 - AR_PHY_ANT_DIV_MAIN_GAINTB |
3942 - AR_PHY_ANT_DIV_ALT_GAINTB);
3943 - regval |= (AR_PHY_ANT_DIV_LNA1 << AR_PHY_ANT_DIV_MAIN_LNACONF_S);
3944 - regval |= (AR_PHY_ANT_DIV_LNA2 << AR_PHY_ANT_DIV_ALT_LNACONF_S);
3945 + regval &= ~AR_PHY_ANT_DIV_LNADIV;
3946 + regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
3948 + regval |= AR_ANT_DIV_ENABLE;
3950 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
3953 + * Enable fast antenna diversity.
3955 + regval = REG_READ(ah, AR_PHY_CCK_DETECT);
3956 + regval &= ~AR_FAST_DIV_ENABLE;
3957 + regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
3959 + regval |= AR_FAST_DIV_ENABLE;
3961 + REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
3963 + if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
3964 + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
3965 + regval &= (~(AR_PHY_ANT_DIV_MAIN_LNACONF |
3966 + AR_PHY_ANT_DIV_ALT_LNACONF |
3967 + AR_PHY_ANT_DIV_ALT_GAINTB |
3968 + AR_PHY_ANT_DIV_MAIN_GAINTB));
3970 + * Set MAIN to LNA1 and ALT to LNA2 at the
3973 + regval |= (ATH_ANT_DIV_COMB_LNA1 <<
3974 + AR_PHY_ANT_DIV_MAIN_LNACONF_S);
3975 + regval |= (ATH_ANT_DIV_COMB_LNA2 <<
3976 + AR_PHY_ANT_DIV_ALT_LNACONF_S);
3977 + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
3979 + } else if (AR_SREV_9565(ah)) {
3981 + REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
3982 + (1 << AR_PHY_ANT_SW_RX_PROT_S));
3983 + if (ah->curchan && IS_CHAN_2GHZ(ah->curchan))
3984 + REG_SET_BIT(ah, AR_PHY_RESTART,
3985 + AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
3986 + REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
3987 + AR_BTCOEX_WL_LNADIV_FORCE_ON);
3989 + REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE);
3990 + REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
3991 + (1 << AR_PHY_ANT_SW_RX_PROT_S));
3992 + REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE);
3993 + REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
3994 + AR_BTCOEX_WL_LNADIV_FORCE_ON);
3996 + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
3997 + regval &= ~(AR_PHY_ANT_DIV_MAIN_LNACONF |
3998 + AR_PHY_ANT_DIV_ALT_LNACONF |
3999 + AR_PHY_ANT_DIV_MAIN_GAINTB |
4000 + AR_PHY_ANT_DIV_ALT_GAINTB);
4001 + regval |= (ATH_ANT_DIV_COMB_LNA1 <<
4002 + AR_PHY_ANT_DIV_MAIN_LNACONF_S);
4003 + regval |= (ATH_ANT_DIV_COMB_LNA2 <<
4004 + AR_PHY_ANT_DIV_ALT_LNACONF_S);
4005 + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
4012 static int ar9003_hw_fast_chan_change(struct ath_hw *ah,
4013 struct ath9k_channel *chan,
4015 @@ -1518,6 +1567,18 @@ static int ar9003_hw_fast_chan_change(st
4017 REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites);
4019 + if (AR_SREV_9462_20_OR_LATER(ah)) {
4021 + * CUS217 mix LNA mode.
4023 + if (ar9003_hw_get_rx_gain_idx(ah) == 2) {
4024 + REG_WRITE_ARRAY(&ah->ini_modes_rxgain_bb_core,
4026 + REG_WRITE_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
4027 + modesIndex, regWrites);
4032 * For 5GHz channels requiring Fast Clock, apply
4033 * different modal values.
4034 @@ -1528,7 +1589,11 @@ static int ar9003_hw_fast_chan_change(st
4035 if (AR_SREV_9565(ah))
4036 REG_WRITE_ARRAY(&ah->iniModesFastClock, 1, regWrites);
4038 - REG_WRITE_ARRAY(&ah->iniAdditional, 1, regWrites);
4040 + * JAPAN regulatory.
4042 + if (chan->channel == 2484)
4043 + ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1);
4045 ah->modes_index = modesIndex;
4046 *ini_reloaded = true;
4047 @@ -1631,11 +1696,14 @@ void ar9003_hw_attach_phy_ops(struct ath
4049 ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get;
4050 ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set;
4051 - ops->antctrl_shared_chain_lnadiv = ar9003_hw_antctrl_shared_chain_lnadiv;
4052 ops->spectral_scan_config = ar9003_hw_spectral_scan_config;
4053 ops->spectral_scan_trigger = ar9003_hw_spectral_scan_trigger;
4054 ops->spectral_scan_wait = ar9003_hw_spectral_scan_wait;
4056 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
4057 + ops->set_bt_ant_diversity = ar9003_hw_set_bt_ant_diversity;
4060 ar9003_hw_set_nf_limits(ah);
4061 ar9003_hw_set_radar_conf(ah);
4062 memcpy(ah->nf_regs, ar9300_cca_regs, sizeof(ah->nf_regs));
4063 --- a/drivers/net/wireless/ath/ath9k/recv.c
4064 +++ b/drivers/net/wireless/ath/ath9k/recv.c
4065 @@ -42,8 +42,6 @@ static void ath_rx_buf_link(struct ath_s
4066 struct ath_desc *ds;
4067 struct sk_buff *skb;
4069 - ATH_RXBUF_RESET(bf);
4072 ds->ds_link = 0; /* link to null */
4073 ds->ds_data = bf->bf_buf_addr;
4074 @@ -70,6 +68,14 @@ static void ath_rx_buf_link(struct ath_s
4075 sc->rx.rxlink = &ds->ds_link;
4078 +static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_buf *bf)
4080 + if (sc->rx.buf_hold)
4081 + ath_rx_buf_link(sc, sc->rx.buf_hold);
4083 + sc->rx.buf_hold = bf;
4086 static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
4088 /* XXX block beacon interrupts */
4089 @@ -117,7 +123,6 @@ static bool ath_rx_edma_buf_link(struct
4093 - ATH_RXBUF_RESET(bf);
4094 memset(skb->data, 0, ah->caps.rx_status_len);
4095 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
4096 ah->caps.rx_status_len, DMA_TO_DEVICE);
4097 @@ -185,7 +190,7 @@ static void ath_rx_edma_cleanup(struct a
4099 static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size)
4101 - skb_queue_head_init(&rx_edma->rx_fifo);
4102 + __skb_queue_head_init(&rx_edma->rx_fifo);
4103 rx_edma->rx_fifo_hwsize = size;
4106 @@ -432,6 +437,7 @@ int ath_startrecv(struct ath_softc *sc)
4107 if (list_empty(&sc->rx.rxbuf))
4110 + sc->rx.buf_hold = NULL;
4111 sc->rx.rxlink = NULL;
4112 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) {
4113 ath_rx_buf_link(sc, bf);
4114 @@ -677,6 +683,9 @@ static struct ath_buf *ath_get_next_rx_b
4117 bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list);
4118 + if (bf == sc->rx.buf_hold)
4124 @@ -755,7 +764,6 @@ static bool ath9k_rx_accept(struct ath_c
4125 bool is_mc, is_valid_tkip, strip_mic, mic_error;
4126 struct ath_hw *ah = common->ah;
4128 - u8 rx_status_len = ah->caps.rx_status_len;
4130 fc = hdr->frame_control;
4132 @@ -777,25 +785,6 @@ static bool ath9k_rx_accept(struct ath_c
4133 !test_bit(rx_stats->rs_keyix, common->ccmp_keymap))
4134 rx_stats->rs_status &= ~ATH9K_RXERR_KEYMISS;
4136 - if (!rx_stats->rs_datalen) {
4137 - RX_STAT_INC(rx_len_err);
4142 - * rs_status follows rs_datalen so if rs_datalen is too large
4143 - * we can take a hint that hardware corrupted it, so ignore
4146 - if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len)) {
4147 - RX_STAT_INC(rx_len_err);
4151 - /* Only use error bits from the last fragment */
4152 - if (rx_stats->rs_more)
4155 mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
4156 !ieee80211_has_morefrags(fc) &&
4157 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
4158 @@ -814,8 +803,6 @@ static bool ath9k_rx_accept(struct ath_c
4159 rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
4162 - if (rx_stats->rs_status & ATH9K_RXERR_PHY)
4165 if ((rx_stats->rs_status & ATH9K_RXERR_DECRYPT) ||
4166 (!is_mc && (rx_stats->rs_status & ATH9K_RXERR_KEYMISS))) {
4167 @@ -898,129 +885,65 @@ static int ath9k_process_rate(struct ath
4169 static void ath9k_process_rssi(struct ath_common *common,
4170 struct ieee80211_hw *hw,
4171 - struct ieee80211_hdr *hdr,
4172 - struct ath_rx_status *rx_stats)
4173 + struct ath_rx_status *rx_stats,
4174 + struct ieee80211_rx_status *rxs)
4176 struct ath_softc *sc = hw->priv;
4177 struct ath_hw *ah = common->ah;
4179 int rssi = rx_stats->rs_rssi;
4181 - if (!rx_stats->is_mybeacon ||
4182 - ((ah->opmode != NL80211_IFTYPE_STATION) &&
4183 - (ah->opmode != NL80211_IFTYPE_ADHOC)))
4185 + * RSSI is not available for subframes in an A-MPDU.
4187 + if (rx_stats->rs_moreaggr) {
4188 + rxs->flag |= RX_FLAG_NO_SIGNAL_VAL;
4191 - if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr)
4192 - ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
4194 - last_rssi = sc->last_rssi;
4195 - if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
4196 - rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
4200 - /* Update Beacon RSSI, this is used by ANI. */
4201 - ah->stats.avgbrssi = rssi;
4205 - * For Decrypt or Demic errors, we only mark packet status here and always push
4206 - * up the frame up to let mac80211 handle the actual error case, be it no
4207 - * decryption key or real decryption error. This let us keep statistics there.
4209 -static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
4210 - struct ieee80211_hdr *hdr,
4211 - struct ath_rx_status *rx_stats,
4212 - struct ieee80211_rx_status *rx_status,
4213 - bool *decrypt_error)
4215 - struct ieee80211_hw *hw = sc->hw;
4216 - struct ath_hw *ah = sc->sc_ah;
4217 - struct ath_common *common = ath9k_hw_common(ah);
4218 - bool discard_current = sc->rx.discard_next;
4220 - sc->rx.discard_next = rx_stats->rs_more;
4221 - if (discard_current)
4226 - * everything but the rate is checked here, the rate check is done
4227 - * separately to avoid doing two lookups for a rate for each frame.
4228 + * Check if the RSSI for the last subframe in an A-MPDU
4229 + * or an unaggregated frame is valid.
4231 - if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error))
4234 - /* Only use status info from the last fragment */
4235 - if (rx_stats->rs_more)
4237 + if (rx_stats->rs_rssi == ATH9K_RSSI_BAD) {
4238 + rxs->flag |= RX_FLAG_NO_SIGNAL_VAL;
4242 - if (ath9k_process_rate(common, hw, rx_stats, rx_status))
4245 + * Update Beacon RSSI, this is used by ANI.
4247 + if (rx_stats->is_mybeacon &&
4248 + ((ah->opmode == NL80211_IFTYPE_STATION) ||
4249 + (ah->opmode == NL80211_IFTYPE_ADHOC))) {
4250 + ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
4251 + last_rssi = sc->last_rssi;
4253 - ath9k_process_rssi(common, hw, hdr, rx_stats);
4254 + if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
4255 + rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
4259 - rx_status->band = hw->conf.chandef.chan->band;
4260 - rx_status->freq = hw->conf.chandef.chan->center_freq;
4261 - rx_status->signal = ah->noise + rx_stats->rs_rssi;
4262 - rx_status->antenna = rx_stats->rs_antenna;
4263 - rx_status->flag |= RX_FLAG_MACTIME_END;
4264 - if (rx_stats->rs_moreaggr)
4265 - rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
4266 + ah->stats.avgbrssi = rssi;
4269 - sc->rx.discard_next = false;
4271 + rxs->signal = ah->noise + rx_stats->rs_rssi;
4274 -static void ath9k_rx_skb_postprocess(struct ath_common *common,
4275 - struct sk_buff *skb,
4276 - struct ath_rx_status *rx_stats,
4277 - struct ieee80211_rx_status *rxs,
4278 - bool decrypt_error)
4279 +static void ath9k_process_tsf(struct ath_rx_status *rs,
4280 + struct ieee80211_rx_status *rxs,
4283 - struct ath_hw *ah = common->ah;
4284 - struct ieee80211_hdr *hdr;
4285 - int hdrlen, padpos, padsize;
4288 + u32 tsf_lower = tsf & 0xffffffff;
4290 - /* see if any padding is done by the hw and remove it */
4291 - hdr = (struct ieee80211_hdr *) skb->data;
4292 - hdrlen = ieee80211_get_hdrlen_from_skb(skb);
4293 - fc = hdr->frame_control;
4294 - padpos = ieee80211_hdrlen(fc);
4295 + rxs->mactime = (tsf & ~0xffffffffULL) | rs->rs_tstamp;
4296 + if (rs->rs_tstamp > tsf_lower &&
4297 + unlikely(rs->rs_tstamp - tsf_lower > 0x10000000))
4298 + rxs->mactime -= 0x100000000ULL;
4300 - /* The MAC header is padded to have 32-bit boundary if the
4301 - * packet payload is non-zero. The general calculation for
4302 - * padsize would take into account odd header lengths:
4303 - * padsize = (4 - padpos % 4) % 4; However, since only
4304 - * even-length headers are used, padding can only be 0 or 2
4305 - * bytes and we can optimize this a bit. In addition, we must
4306 - * not try to remove padding from short control frames that do
4307 - * not have payload. */
4308 - padsize = padpos & 3;
4309 - if (padsize && skb->len>=padpos+padsize+FCS_LEN) {
4310 - memmove(skb->data + padsize, skb->data, padpos);
4311 - skb_pull(skb, padsize);
4314 - keyix = rx_stats->rs_keyix;
4316 - if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error &&
4317 - ieee80211_has_protected(fc)) {
4318 - rxs->flag |= RX_FLAG_DECRYPTED;
4319 - } else if (ieee80211_has_protected(fc)
4320 - && !decrypt_error && skb->len >= hdrlen + 4) {
4321 - keyix = skb->data[hdrlen + 3] >> 6;
4323 - if (test_bit(keyix, common->keymap))
4324 - rxs->flag |= RX_FLAG_DECRYPTED;
4326 - if (ah->sw_mgmt_crypto &&
4327 - (rxs->flag & RX_FLAG_DECRYPTED) &&
4328 - ieee80211_is_mgmt(fc))
4329 - /* Use software decrypt for management frames. */
4330 - rxs->flag &= ~RX_FLAG_DECRYPTED;
4331 + if (rs->rs_tstamp < tsf_lower &&
4332 + unlikely(tsf_lower - rs->rs_tstamp > 0x10000000))
4333 + rxs->mactime += 0x100000000ULL;
4336 #ifdef CPTCFG_ATH9K_DEBUGFS
4337 @@ -1133,6 +1056,234 @@ static int ath_process_fft(struct ath_so
4341 +static bool ath9k_is_mybeacon(struct ath_softc *sc, struct ieee80211_hdr *hdr)
4343 + struct ath_hw *ah = sc->sc_ah;
4344 + struct ath_common *common = ath9k_hw_common(ah);
4346 + if (ieee80211_is_beacon(hdr->frame_control)) {
4347 + RX_STAT_INC(rx_beacons);
4348 + if (!is_zero_ether_addr(common->curbssid) &&
4349 + ether_addr_equal(hdr->addr3, common->curbssid))
4357 + * For Decrypt or Demic errors, we only mark packet status here and always push
4358 + * up the frame up to let mac80211 handle the actual error case, be it no
4359 + * decryption key or real decryption error. This let us keep statistics there.
4361 +static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
4362 + struct sk_buff *skb,
4363 + struct ath_rx_status *rx_stats,
4364 + struct ieee80211_rx_status *rx_status,
4365 + bool *decrypt_error, u64 tsf)
4367 + struct ieee80211_hw *hw = sc->hw;
4368 + struct ath_hw *ah = sc->sc_ah;
4369 + struct ath_common *common = ath9k_hw_common(ah);
4370 + struct ieee80211_hdr *hdr;
4371 + bool discard_current = sc->rx.discard_next;
4375 + * Discard corrupt descriptors which are marked in
4376 + * ath_get_next_rx_buf().
4378 + sc->rx.discard_next = rx_stats->rs_more;
4379 + if (discard_current)
4383 + * Discard zero-length packets.
4385 + if (!rx_stats->rs_datalen) {
4386 + RX_STAT_INC(rx_len_err);
4391 + * rs_status follows rs_datalen so if rs_datalen is too large
4392 + * we can take a hint that hardware corrupted it, so ignore
4395 + if (rx_stats->rs_datalen > (common->rx_bufsize - ah->caps.rx_status_len)) {
4396 + RX_STAT_INC(rx_len_err);
4400 + /* Only use status info from the last fragment */
4401 + if (rx_stats->rs_more)
4405 + * Return immediately if the RX descriptor has been marked
4406 + * as corrupt based on the various error bits.
4408 + * This is different from the other corrupt descriptor
4409 + * condition handled above.
4411 + if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC) {
4416 + hdr = (struct ieee80211_hdr *) (skb->data + ah->caps.rx_status_len);
4418 + ath9k_process_tsf(rx_stats, rx_status, tsf);
4419 + ath_debug_stat_rx(sc, rx_stats);
4422 + * Process PHY errors and return so that the packet
4425 + if (rx_stats->rs_status & ATH9K_RXERR_PHY) {
4426 + ath9k_dfs_process_phyerr(sc, hdr, rx_stats, rx_status->mactime);
4427 + if (ath_process_fft(sc, hdr, rx_stats, rx_status->mactime))
4428 + RX_STAT_INC(rx_spectral);
4435 + * everything but the rate is checked here, the rate check is done
4436 + * separately to avoid doing two lookups for a rate for each frame.
4438 + if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error)) {
4443 + rx_stats->is_mybeacon = ath9k_is_mybeacon(sc, hdr);
4444 + if (rx_stats->is_mybeacon) {
4445 + sc->hw_busy_count = 0;
4446 + ath_start_rx_poll(sc, 3);
4449 + if (ath9k_process_rate(common, hw, rx_stats, rx_status)) {
4454 + ath9k_process_rssi(common, hw, rx_stats, rx_status);
4456 + rx_status->band = hw->conf.chandef.chan->band;
4457 + rx_status->freq = hw->conf.chandef.chan->center_freq;
4458 + rx_status->antenna = rx_stats->rs_antenna;
4459 + rx_status->flag |= RX_FLAG_MACTIME_END;
4461 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
4462 + if (ieee80211_is_data_present(hdr->frame_control) &&
4463 + !ieee80211_is_qos_nullfunc(hdr->frame_control))
4464 + sc->rx.num_pkts++;
4468 + sc->rx.discard_next = false;
4472 +static void ath9k_rx_skb_postprocess(struct ath_common *common,
4473 + struct sk_buff *skb,
4474 + struct ath_rx_status *rx_stats,
4475 + struct ieee80211_rx_status *rxs,
4476 + bool decrypt_error)
4478 + struct ath_hw *ah = common->ah;
4479 + struct ieee80211_hdr *hdr;
4480 + int hdrlen, padpos, padsize;
4484 + /* see if any padding is done by the hw and remove it */
4485 + hdr = (struct ieee80211_hdr *) skb->data;
4486 + hdrlen = ieee80211_get_hdrlen_from_skb(skb);
4487 + fc = hdr->frame_control;
4488 + padpos = ieee80211_hdrlen(fc);
4490 + /* The MAC header is padded to have 32-bit boundary if the
4491 + * packet payload is non-zero. The general calculation for
4492 + * padsize would take into account odd header lengths:
4493 + * padsize = (4 - padpos % 4) % 4; However, since only
4494 + * even-length headers are used, padding can only be 0 or 2
4495 + * bytes and we can optimize this a bit. In addition, we must
4496 + * not try to remove padding from short control frames that do
4497 + * not have payload. */
4498 + padsize = padpos & 3;
4499 + if (padsize && skb->len>=padpos+padsize+FCS_LEN) {
4500 + memmove(skb->data + padsize, skb->data, padpos);
4501 + skb_pull(skb, padsize);
4504 + keyix = rx_stats->rs_keyix;
4506 + if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error &&
4507 + ieee80211_has_protected(fc)) {
4508 + rxs->flag |= RX_FLAG_DECRYPTED;
4509 + } else if (ieee80211_has_protected(fc)
4510 + && !decrypt_error && skb->len >= hdrlen + 4) {
4511 + keyix = skb->data[hdrlen + 3] >> 6;
4513 + if (test_bit(keyix, common->keymap))
4514 + rxs->flag |= RX_FLAG_DECRYPTED;
4516 + if (ah->sw_mgmt_crypto &&
4517 + (rxs->flag & RX_FLAG_DECRYPTED) &&
4518 + ieee80211_is_mgmt(fc))
4519 + /* Use software decrypt for management frames. */
4520 + rxs->flag &= ~RX_FLAG_DECRYPTED;
4524 + * Run the LNA combining algorithm only in these cases:
4526 + * Standalone WLAN cards with both LNA/Antenna diversity
4527 + * enabled in the EEPROM.
4529 + * WLAN+BT cards which are in the supported card list
4530 + * in ath_pci_id_table and the user has loaded the
4531 + * driver with "bt_ant_diversity" set to true.
4533 +static void ath9k_antenna_check(struct ath_softc *sc,
4534 + struct ath_rx_status *rs)
4536 + struct ath_hw *ah = sc->sc_ah;
4537 + struct ath9k_hw_capabilities *pCap = &ah->caps;
4538 + struct ath_common *common = ath9k_hw_common(ah);
4540 + if (!(ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB))
4544 + * All MPDUs in an aggregate will use the same LNA
4545 + * as the first MPDU.
4547 + if (rs->rs_isaggr && !rs->rs_firstaggr)
4551 + * Change the default rx antenna if rx diversity
4552 + * chooses the other antenna 3 times in a row.
4554 + if (sc->rx.defant != rs->rs_antenna) {
4555 + if (++sc->rx.rxotherant >= 3)
4556 + ath_setdefantenna(sc, rs->rs_antenna);
4558 + sc->rx.rxotherant = 0;
4561 + if (pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV) {
4562 + if (common->bt_ant_diversity)
4563 + ath_ant_comb_scan(sc, rs);
4565 + ath_ant_comb_scan(sc, rs);
4569 static void ath9k_apply_ampdu_details(struct ath_softc *sc,
4570 struct ath_rx_status *rs, struct ieee80211_rx_status *rxs)
4572 @@ -1159,15 +1310,12 @@ int ath_rx_tasklet(struct ath_softc *sc,
4573 struct ath_hw *ah = sc->sc_ah;
4574 struct ath_common *common = ath9k_hw_common(ah);
4575 struct ieee80211_hw *hw = sc->hw;
4576 - struct ieee80211_hdr *hdr;
4578 struct ath_rx_status rs;
4579 enum ath9k_rx_qtype qtype;
4580 bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
4582 - u8 rx_status_len = ah->caps.rx_status_len;
4584 - u32 tsf_lower = 0;
4585 unsigned long flags;
4586 dma_addr_t new_buf_addr;
4588 @@ -1179,7 +1327,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
4589 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP;
4591 tsf = ath9k_hw_gettsf64(ah);
4592 - tsf_lower = tsf & 0xffffffff;
4595 bool decrypt_error = false;
4596 @@ -1206,55 +1353,14 @@ int ath_rx_tasklet(struct ath_softc *sc,
4600 - hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len);
4601 rxs = IEEE80211_SKB_RXCB(hdr_skb);
4602 - if (ieee80211_is_beacon(hdr->frame_control)) {
4603 - RX_STAT_INC(rx_beacons);
4604 - if (!is_zero_ether_addr(common->curbssid) &&
4605 - ether_addr_equal(hdr->addr3, common->curbssid))
4606 - rs.is_mybeacon = true;
4608 - rs.is_mybeacon = false;
4611 - rs.is_mybeacon = false;
4613 - if (ieee80211_is_data_present(hdr->frame_control) &&
4614 - !ieee80211_is_qos_nullfunc(hdr->frame_control))
4615 - sc->rx.num_pkts++;
4617 - ath_debug_stat_rx(sc, &rs);
4619 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
4621 - rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
4622 - if (rs.rs_tstamp > tsf_lower &&
4623 - unlikely(rs.rs_tstamp - tsf_lower > 0x10000000))
4624 - rxs->mactime -= 0x100000000ULL;
4626 - if (rs.rs_tstamp < tsf_lower &&
4627 - unlikely(tsf_lower - rs.rs_tstamp > 0x10000000))
4628 - rxs->mactime += 0x100000000ULL;
4630 - if (rs.rs_phyerr == ATH9K_PHYERR_RADAR)
4631 - ath9k_dfs_process_phyerr(sc, hdr, &rs, rxs->mactime);
4633 - if (rs.rs_status & ATH9K_RXERR_PHY) {
4634 - if (ath_process_fft(sc, hdr, &rs, rxs->mactime)) {
4635 - RX_STAT_INC(rx_spectral);
4636 - goto requeue_drop_frag;
4640 - retval = ath9k_rx_skb_preprocess(sc, hdr, &rs, rxs,
4642 + retval = ath9k_rx_skb_preprocess(sc, hdr_skb, &rs, rxs,
4643 + &decrypt_error, tsf);
4645 goto requeue_drop_frag;
4647 - if (rs.is_mybeacon) {
4648 - sc->hw_busy_count = 0;
4649 - ath_start_rx_poll(sc, 3);
4651 /* Ensure we always have an skb to requeue once we are done
4652 * processing the current buffer's skb */
4653 requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC);
4654 @@ -1308,8 +1414,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
4658 - if (rs.rs_status & ATH9K_RXERR_CORRUPT_DESC)
4659 - goto requeue_drop_frag;
4662 int space = skb->len - skb_tailroom(hdr_skb);
4663 @@ -1328,22 +1432,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
4668 - if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
4671 - * change the default rx antenna if rx diversity
4672 - * chooses the other antenna 3 times in a row.
4674 - if (sc->rx.defant != rs.rs_antenna) {
4675 - if (++sc->rx.rxotherant >= 3)
4676 - ath_setdefantenna(sc, rs.rs_antenna);
4678 - sc->rx.rxotherant = 0;
4683 if (rxs->flag & RX_FLAG_MMIC_STRIPPED)
4684 skb_trim(skb, skb->len - 8);
4686 @@ -1355,8 +1443,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
4687 ath_rx_ps(sc, skb, rs.is_mybeacon);
4688 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
4690 - if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx == 3)
4691 - ath_ant_comb_scan(sc, &rs);
4692 + ath9k_antenna_check(sc, &rs);
4694 ath9k_apply_ampdu_details(sc, &rs, rxs);
4696 @@ -1375,7 +1462,7 @@ requeue:
4698 ath_rx_edma_buf_link(sc, qtype);
4700 - ath_rx_buf_link(sc, bf);
4701 + ath_rx_buf_relink(sc, bf);
4705 --- a/drivers/net/wireless/ath/ath9k/init.c
4706 +++ b/drivers/net/wireless/ath/ath9k/init.c
4707 @@ -53,9 +53,9 @@ static int ath9k_btcoex_enable;
4708 module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444);
4709 MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence");
4711 -static int ath9k_enable_diversity;
4712 -module_param_named(enable_diversity, ath9k_enable_diversity, int, 0444);
4713 -MODULE_PARM_DESC(enable_diversity, "Enable Antenna diversity for AR9565");
4714 +static int ath9k_bt_ant_diversity;
4715 +module_param_named(bt_ant_diversity, ath9k_bt_ant_diversity, int, 0444);
4716 +MODULE_PARM_DESC(bt_ant_diversity, "Enable WLAN/BT RX antenna diversity");
4718 bool is_ath9k_unloaded;
4719 /* We use the hw_value as an index into our private channel structure */
4720 @@ -516,6 +516,7 @@ static void ath9k_init_misc(struct ath_s
4721 static void ath9k_init_platform(struct ath_softc *sc)
4723 struct ath_hw *ah = sc->sc_ah;
4724 + struct ath9k_hw_capabilities *pCap = &ah->caps;
4725 struct ath_common *common = ath9k_hw_common(ah);
4727 if (common->bus_ops->ath_bus_type != ATH_PCI)
4728 @@ -525,12 +526,27 @@ static void ath9k_init_platform(struct a
4729 ATH9K_PCI_CUS230)) {
4730 ah->config.xlna_gpio = 9;
4731 ah->config.xatten_margin_cfg = true;
4732 + ah->config.alt_mingainidx = true;
4733 + ah->config.ant_ctrl_comm2g_switch_enable = 0x000BBB88;
4734 + sc->ant_comb.low_rssi_thresh = 20;
4735 + sc->ant_comb.fast_div_bias = 3;
4737 ath_info(common, "Set parameters for %s\n",
4738 (sc->driver_data & ATH9K_PCI_CUS198) ?
4739 "CUS198" : "CUS230");
4740 - } else if (sc->driver_data & ATH9K_PCI_CUS217) {
4743 + if (sc->driver_data & ATH9K_PCI_CUS217)
4744 ath_info(common, "CUS217 card detected\n");
4746 + if (sc->driver_data & ATH9K_PCI_BT_ANT_DIV) {
4747 + pCap->hw_caps |= ATH9K_HW_CAP_BT_ANT_DIV;
4748 + ath_info(common, "Set BT/WLAN RX diversity capability\n");
4751 + if (sc->driver_data & ATH9K_PCI_D3_L1_WAR) {
4752 + ah->config.pcie_waen = 0x0040473b;
4753 + ath_info(common, "Enable WAR for ASPM D3/L1\n");
4757 @@ -584,6 +600,7 @@ static int ath9k_init_softc(u16 devid, s
4759 struct ath9k_platform_data *pdata = sc->dev->platform_data;
4760 struct ath_hw *ah = NULL;
4761 + struct ath9k_hw_capabilities *pCap;
4762 struct ath_common *common;
4765 @@ -600,6 +617,7 @@ static int ath9k_init_softc(u16 devid, s
4766 ah->reg_ops.rmw = ath9k_reg_rmw;
4767 atomic_set(&ah->intr_ref_cnt, -1);
4771 sc->dfs_detector = dfs_pattern_detector_init(ah, NL80211_DFS_UNSET);
4773 @@ -631,11 +649,15 @@ static int ath9k_init_softc(u16 devid, s
4774 ath9k_init_platform(sc);
4777 - * Enable Antenna diversity only when BTCOEX is disabled
4778 - * and the user manually requests the feature.
4779 + * Enable WLAN/BT RX Antenna diversity only when:
4781 + * - BTCOEX is disabled.
4782 + * - the user manually requests the feature.
4783 + * - the HW cap is set using the platform data.
4785 - if (!common->btcoex_enabled && ath9k_enable_diversity)
4786 - common->antenna_diversity = 1;
4787 + if (!common->btcoex_enabled && ath9k_bt_ant_diversity &&
4788 + (pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV))
4789 + common->bt_ant_diversity = 1;
4791 spin_lock_init(&common->cc_lock);
4793 @@ -710,13 +732,15 @@ static void ath9k_init_band_txpower(stru
4794 struct ieee80211_supported_band *sband;
4795 struct ieee80211_channel *chan;
4796 struct ath_hw *ah = sc->sc_ah;
4797 + struct cfg80211_chan_def chandef;
4800 sband = &sc->sbands[band];
4801 for (i = 0; i < sband->n_channels; i++) {
4802 chan = &sband->channels[i];
4803 ah->curchan = &ah->channels[chan->hw_value];
4804 - ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20);
4805 + cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_HT20);
4806 + ath9k_cmn_update_ichannel(ah->curchan, &chandef);
4807 ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true);
4810 @@ -802,7 +826,8 @@ void ath9k_set_hw_capab(struct ath_softc
4811 IEEE80211_HW_PS_NULLFUNC_STACK |
4812 IEEE80211_HW_SPECTRUM_MGMT |
4813 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
4814 - IEEE80211_HW_SUPPORTS_RC_TABLE;
4815 + IEEE80211_HW_SUPPORTS_RC_TABLE |
4816 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
4818 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
4819 hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION;
4820 --- a/drivers/net/wireless/ath/carl9170/main.c
4821 +++ b/drivers/net/wireless/ath/carl9170/main.c
4822 @@ -1878,7 +1878,8 @@ void *carl9170_alloc(size_t priv_size)
4823 IEEE80211_HW_PS_NULLFUNC_STACK |
4824 IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC |
4825 IEEE80211_HW_SUPPORTS_RC_TABLE |
4826 - IEEE80211_HW_SIGNAL_DBM;
4827 + IEEE80211_HW_SIGNAL_DBM |
4828 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
4830 if (!modparam_noht) {
4832 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
4833 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
4834 @@ -6133,7 +6133,8 @@ static int rt2800_probe_hw_mode(struct r
4835 IEEE80211_HW_SUPPORTS_PS |
4836 IEEE80211_HW_PS_NULLFUNC_STACK |
4837 IEEE80211_HW_AMPDU_AGGREGATION |
4838 - IEEE80211_HW_REPORTS_TX_ACK_STATUS;
4839 + IEEE80211_HW_REPORTS_TX_ACK_STATUS |
4840 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
4843 * Don't set IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING for USB devices
4844 --- a/include/net/mac80211.h
4845 +++ b/include/net/mac80211.h
4846 @@ -152,11 +152,14 @@ struct ieee80211_low_level_stats {
4847 * @IEEE80211_CHANCTX_CHANGE_WIDTH: The channel width changed
4848 * @IEEE80211_CHANCTX_CHANGE_RX_CHAINS: The number of RX chains changed
4849 * @IEEE80211_CHANCTX_CHANGE_RADAR: radar detection flag changed
4850 + * @IEEE80211_CHANCTX_CHANGE_CHANNEL: switched to another operating channel,
4851 + * this is used only with channel switching with CSA
4853 enum ieee80211_chanctx_change {
4854 IEEE80211_CHANCTX_CHANGE_WIDTH = BIT(0),
4855 IEEE80211_CHANCTX_CHANGE_RX_CHAINS = BIT(1),
4856 IEEE80211_CHANCTX_CHANGE_RADAR = BIT(2),
4857 + IEEE80211_CHANCTX_CHANGE_CHANNEL = BIT(3),
4861 @@ -1080,6 +1083,7 @@ enum ieee80211_vif_flags {
4862 * @addr: address of this interface
4863 * @p2p: indicates whether this AP or STA interface is a p2p
4864 * interface, i.e. a GO or p2p-sta respectively
4865 + * @csa_active: marks whether a channel switch is going on
4866 * @driver_flags: flags/capabilities the driver has for this interface,
4867 * these need to be set (or cleared) when the interface is added
4868 * or, if supported by the driver, the interface type is changed
4869 @@ -1102,6 +1106,7 @@ struct ieee80211_vif {
4870 struct ieee80211_bss_conf bss_conf;
4876 u8 hw_queue[IEEE80211_NUM_ACS];
4877 @@ -1499,6 +1504,7 @@ enum ieee80211_hw_flags {
4878 IEEE80211_HW_SUPPORTS_RC_TABLE = 1<<24,
4879 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25,
4880 IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26,
4881 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES = 1<<27,
4885 @@ -2633,6 +2639,16 @@ enum ieee80211_roc_type {
4886 * @ipv6_addr_change: IPv6 address assignment on the given interface changed.
4887 * Currently, this is only called for managed or P2P client interfaces.
4888 * This callback is optional; it must not sleep.
4890 + * @channel_switch_beacon: Starts a channel switch to a new channel.
4891 + * Beacons are modified to include CSA or ECSA IEs before calling this
4892 + * function. The corresponding count fields in these IEs must be
4893 + * decremented, and when they reach zero the driver must call
4894 + * ieee80211_csa_finish(). Drivers which use ieee80211_beacon_get()
4895 + * get the csa counter decremented by mac80211, but must check if it is
4896 + * zero using ieee80211_csa_is_complete() after the beacon has been
4897 + * transmitted and then call ieee80211_csa_finish().
4900 struct ieee80211_ops {
4901 void (*tx)(struct ieee80211_hw *hw,
4902 @@ -2830,6 +2846,9 @@ struct ieee80211_ops {
4903 struct ieee80211_vif *vif,
4904 struct inet6_dev *idev);
4906 + void (*channel_switch_beacon)(struct ieee80211_hw *hw,
4907 + struct ieee80211_vif *vif,
4908 + struct cfg80211_chan_def *chandef);
4912 @@ -3325,6 +3344,25 @@ static inline struct sk_buff *ieee80211_
4916 + * ieee80211_csa_finish - notify mac80211 about channel switch
4917 + * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4919 + * After a channel switch announcement was scheduled and the counter in this
4920 + * announcement hit zero, this function must be called by the driver to
4921 + * notify mac80211 that the channel can be changed.
4923 +void ieee80211_csa_finish(struct ieee80211_vif *vif);
4926 + * ieee80211_csa_is_complete - find out if counters reached zero
4927 + * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4929 + * This function returns whether the channel switch counters reached zero.
4931 +bool ieee80211_csa_is_complete(struct ieee80211_vif *vif);
4935 * ieee80211_proberesp_get - retrieve a Probe Response template
4936 * @hw: pointer obtained from ieee80211_alloc_hw().
4937 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4938 --- a/net/mac80211/cfg.c
4939 +++ b/net/mac80211/cfg.c
4940 @@ -854,8 +854,8 @@ static int ieee80211_set_probe_resp(stru
4944 -static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
4945 - struct cfg80211_beacon_data *params)
4946 +int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
4947 + struct cfg80211_beacon_data *params)
4949 struct beacon_data *new, *old;
4950 int new_head_len, new_tail_len;
4951 @@ -1018,6 +1018,12 @@ static int ieee80211_change_beacon(struc
4953 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4955 + /* don't allow changing the beacon while CSA is in place - offset
4956 + * of channel switch counter may change
4958 + if (sdata->vif.csa_active)
4961 old = rtnl_dereference(sdata->u.ap.beacon);
4964 @@ -1042,6 +1048,10 @@ static int ieee80211_stop_ap(struct wiph
4966 old_probe_resp = rtnl_dereference(sdata->u.ap.probe_resp);
4968 + /* abort any running channel switch */
4969 + sdata->vif.csa_active = false;
4970 + cancel_work_sync(&sdata->csa_finalize_work);
4972 /* turn off carrier for this interface and dependent VLANs */
4973 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
4974 netif_carrier_off(vlan->dev);
4975 @@ -2784,6 +2794,178 @@ static int ieee80211_start_radar_detecti
4979 +static struct cfg80211_beacon_data *
4980 +cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
4982 + struct cfg80211_beacon_data *new_beacon;
4986 + len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
4987 + beacon->proberesp_ies_len + beacon->assocresp_ies_len +
4988 + beacon->probe_resp_len;
4990 + new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
4994 + pos = (u8 *)(new_beacon + 1);
4995 + if (beacon->head_len) {
4996 + new_beacon->head_len = beacon->head_len;
4997 + new_beacon->head = pos;
4998 + memcpy(pos, beacon->head, beacon->head_len);
4999 + pos += beacon->head_len;
5001 + if (beacon->tail_len) {
5002 + new_beacon->tail_len = beacon->tail_len;
5003 + new_beacon->tail = pos;
5004 + memcpy(pos, beacon->tail, beacon->tail_len);
5005 + pos += beacon->tail_len;
5007 + if (beacon->beacon_ies_len) {
5008 + new_beacon->beacon_ies_len = beacon->beacon_ies_len;
5009 + new_beacon->beacon_ies = pos;
5010 + memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
5011 + pos += beacon->beacon_ies_len;
5013 + if (beacon->proberesp_ies_len) {
5014 + new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
5015 + new_beacon->proberesp_ies = pos;
5016 + memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
5017 + pos += beacon->proberesp_ies_len;
5019 + if (beacon->assocresp_ies_len) {
5020 + new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
5021 + new_beacon->assocresp_ies = pos;
5022 + memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
5023 + pos += beacon->assocresp_ies_len;
5025 + if (beacon->probe_resp_len) {
5026 + new_beacon->probe_resp_len = beacon->probe_resp_len;
5027 + beacon->probe_resp = pos;
5028 + memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
5029 + pos += beacon->probe_resp_len;
5032 + return new_beacon;
5035 +void ieee80211_csa_finalize_work(struct work_struct *work)
5037 + struct ieee80211_sub_if_data *sdata =
5038 + container_of(work, struct ieee80211_sub_if_data,
5039 + csa_finalize_work);
5040 + struct ieee80211_local *local = sdata->local;
5043 + if (!ieee80211_sdata_running(sdata))
5046 + if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP))
5049 + sdata->radar_required = sdata->csa_radar_required;
5050 + err = ieee80211_vif_change_channel(sdata, &local->csa_chandef,
5052 + if (WARN_ON(err < 0))
5055 + err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
5060 + kfree(sdata->u.ap.next_beacon);
5061 + sdata->u.ap.next_beacon = NULL;
5062 + sdata->vif.csa_active = false;
5064 + ieee80211_wake_queues_by_reason(&sdata->local->hw,
5065 + IEEE80211_MAX_QUEUE_MAP,
5066 + IEEE80211_QUEUE_STOP_REASON_CSA);
5068 + ieee80211_bss_info_change_notify(sdata, changed);
5070 + cfg80211_ch_switch_notify(sdata->dev, &local->csa_chandef);
5073 +static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
5074 + struct cfg80211_csa_settings *params)
5076 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
5077 + struct ieee80211_local *local = sdata->local;
5078 + struct ieee80211_chanctx_conf *chanctx_conf;
5079 + struct ieee80211_chanctx *chanctx;
5080 + int err, num_chanctx;
5082 + if (!list_empty(&local->roc_list) || local->scanning)
5085 + if (sdata->wdev.cac_started)
5088 + if (cfg80211_chandef_identical(¶ms->chandef,
5089 + &sdata->vif.bss_conf.chandef))
5093 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
5094 + if (!chanctx_conf) {
5095 + rcu_read_unlock();
5099 + /* don't handle for multi-VIF cases */
5100 + chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf);
5101 + if (chanctx->refcount > 1) {
5102 + rcu_read_unlock();
5106 + list_for_each_entry_rcu(chanctx, &local->chanctx_list, list)
5108 + rcu_read_unlock();
5110 + if (num_chanctx > 1)
5113 + /* don't allow another channel switch if one is already active. */
5114 + if (sdata->vif.csa_active)
5117 + /* only handle AP for now. */
5118 + switch (sdata->vif.type) {
5119 + case NL80211_IFTYPE_AP:
5122 + return -EOPNOTSUPP;
5125 + sdata->u.ap.next_beacon = cfg80211_beacon_dup(¶ms->beacon_after);
5126 + if (!sdata->u.ap.next_beacon)
5129 + sdata->csa_counter_offset_beacon = params->counter_offset_beacon;
5130 + sdata->csa_counter_offset_presp = params->counter_offset_presp;
5131 + sdata->csa_radar_required = params->radar_required;
5133 + if (params->block_tx)
5134 + ieee80211_stop_queues_by_reason(&local->hw,
5135 + IEEE80211_MAX_QUEUE_MAP,
5136 + IEEE80211_QUEUE_STOP_REASON_CSA);
5138 + err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa);
5142 + local->csa_chandef = params->chandef;
5143 + sdata->vif.csa_active = true;
5145 + ieee80211_bss_info_change_notify(sdata, err);
5146 + drv_channel_switch_beacon(sdata, ¶ms->chandef);
5151 static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
5152 struct ieee80211_channel *chan, bool offchan,
5153 unsigned int wait, const u8 *buf, size_t len,
5154 @@ -3332,7 +3514,7 @@ static int ieee80211_probe_client(struct
5157 band = chanctx_conf->def.chan->band;
5158 - sta = sta_info_get(sdata, peer);
5159 + sta = sta_info_get_bss(sdata, peer);
5161 qos = test_sta_flag(sta, WLAN_STA_WME);
5163 @@ -3501,4 +3683,5 @@ struct cfg80211_ops mac80211_config_ops
5164 .get_et_strings = ieee80211_get_et_strings,
5165 .get_channel = ieee80211_cfg_get_channel,
5166 .start_radar_detection = ieee80211_start_radar_detection,
5167 + .channel_switch = ieee80211_channel_switch,
5169 --- a/net/mac80211/chan.c
5170 +++ b/net/mac80211/chan.c
5171 @@ -410,6 +410,64 @@ int ieee80211_vif_use_channel(struct iee
5175 +int ieee80211_vif_change_channel(struct ieee80211_sub_if_data *sdata,
5176 + const struct cfg80211_chan_def *chandef,
5179 + struct ieee80211_local *local = sdata->local;
5180 + struct ieee80211_chanctx_conf *conf;
5181 + struct ieee80211_chanctx *ctx;
5183 + u32 chanctx_changed = 0;
5185 + /* should never be called if not performing a channel switch. */
5186 + if (WARN_ON(!sdata->vif.csa_active))
5189 + if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
5190 + IEEE80211_CHAN_DISABLED))
5193 + mutex_lock(&local->chanctx_mtx);
5194 + conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
5195 + lockdep_is_held(&local->chanctx_mtx));
5201 + ctx = container_of(conf, struct ieee80211_chanctx, conf);
5202 + if (ctx->refcount != 1) {
5207 + if (sdata->vif.bss_conf.chandef.width != chandef->width) {
5208 + chanctx_changed = IEEE80211_CHANCTX_CHANGE_WIDTH;
5209 + *changed |= BSS_CHANGED_BANDWIDTH;
5212 + sdata->vif.bss_conf.chandef = *chandef;
5213 + ctx->conf.def = *chandef;
5215 + chanctx_changed |= IEEE80211_CHANCTX_CHANGE_CHANNEL;
5216 + drv_change_chanctx(local, ctx, chanctx_changed);
5218 + if (!local->use_chanctx) {
5219 + local->_oper_chandef = *chandef;
5220 + ieee80211_hw_config(local, 0);
5223 + ieee80211_recalc_chanctx_chantype(local, ctx);
5224 + ieee80211_recalc_smps_chanctx(local, ctx);
5225 + ieee80211_recalc_radar_chanctx(local, ctx);
5229 + mutex_unlock(&local->chanctx_mtx);
5233 int ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
5234 const struct cfg80211_chan_def *chandef,
5236 --- a/net/mac80211/driver-ops.h
5237 +++ b/net/mac80211/driver-ops.h
5238 @@ -1104,4 +1104,17 @@ static inline void drv_ipv6_addr_change(
5243 +drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
5244 + struct cfg80211_chan_def *chandef)
5246 + struct ieee80211_local *local = sdata->local;
5248 + if (local->ops->channel_switch_beacon) {
5249 + trace_drv_channel_switch_beacon(local, sdata, chandef);
5250 + local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
5255 #endif /* __MAC80211_DRIVER_OPS */
5256 --- a/net/mac80211/ieee80211_i.h
5257 +++ b/net/mac80211/ieee80211_i.h
5258 @@ -53,9 +53,6 @@ struct ieee80211_local;
5259 * increased memory use (about 2 kB of RAM per entry). */
5260 #define IEEE80211_FRAGMENT_MAX 4
5262 -#define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
5263 -#define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
5265 /* power level hasn't been configured (or set to automatic) */
5266 #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
5268 @@ -259,6 +256,8 @@ struct ieee80211_if_ap {
5269 struct beacon_data __rcu *beacon;
5270 struct probe_resp __rcu *probe_resp;
5272 + /* to be used after channel switch. */
5273 + struct cfg80211_beacon_data *next_beacon;
5274 struct list_head vlans;
5277 @@ -713,6 +712,11 @@ struct ieee80211_sub_if_data {
5279 struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
5281 + struct work_struct csa_finalize_work;
5282 + int csa_counter_offset_beacon;
5283 + int csa_counter_offset_presp;
5284 + bool csa_radar_required;
5286 /* used to reconfigure hardware SM PS */
5287 struct work_struct recalc_smps;
5289 @@ -1346,6 +1350,9 @@ void ieee80211_roc_notify_destroy(struct
5290 void ieee80211_sw_roc_work(struct work_struct *work);
5291 void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
5293 +/* channel switch handling */
5294 +void ieee80211_csa_finalize_work(struct work_struct *work);
5296 /* interface handling */
5297 int ieee80211_iface_init(void);
5298 void ieee80211_iface_exit(void);
5299 @@ -1367,6 +1374,8 @@ void ieee80211_del_virtual_monitor(struc
5301 bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
5302 void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
5303 +int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
5304 + struct cfg80211_beacon_data *params);
5306 static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
5308 @@ -1627,6 +1636,11 @@ int __must_check
5309 ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
5310 const struct cfg80211_chan_def *chandef,
5312 +/* NOTE: only use ieee80211_vif_change_channel() for channel switch */
5314 +ieee80211_vif_change_channel(struct ieee80211_sub_if_data *sdata,
5315 + const struct cfg80211_chan_def *chandef,
5317 void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
5318 void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
5319 void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
5320 --- a/net/mac80211/trace.h
5321 +++ b/net/mac80211/trace.h
5322 @@ -1906,6 +1906,32 @@ TRACE_EVENT(api_radar_detected,
5326 +TRACE_EVENT(drv_channel_switch_beacon,
5327 + TP_PROTO(struct ieee80211_local *local,
5328 + struct ieee80211_sub_if_data *sdata,
5329 + struct cfg80211_chan_def *chandef),
5331 + TP_ARGS(local, sdata, chandef),
5342 + CHANDEF_ASSIGN(chandef);
5346 + LOCAL_PR_FMT VIF_PR_FMT " channel switch to " CHANDEF_PR_FMT,
5347 + LOCAL_PR_ARG, VIF_PR_ARG, CHANDEF_PR_ARG
5352 #ifdef CPTCFG_MAC80211_MESSAGE_TRACING
5354 #define TRACE_SYSTEM mac80211_msg
5355 --- a/net/mac80211/tx.c
5356 +++ b/net/mac80211/tx.c
5357 @@ -1101,7 +1101,8 @@ ieee80211_tx_prepare(struct ieee80211_su
5358 tx->sta = rcu_dereference(sdata->u.vlan.sta);
5359 if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr)
5361 - } else if (info->flags & IEEE80211_TX_CTL_INJECTED ||
5362 + } else if (info->flags & (IEEE80211_TX_CTL_INJECTED |
5363 + IEEE80211_TX_INTFL_NL80211_FRAME_TX) ||
5364 tx->sdata->control_port_protocol == tx->skb->protocol) {
5365 tx->sta = sta_info_get_bss(sdata, hdr->addr1);
5367 @@ -2326,6 +2327,81 @@ static int ieee80211_beacon_add_tim(stru
5371 +void ieee80211_csa_finish(struct ieee80211_vif *vif)
5373 + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
5375 + ieee80211_queue_work(&sdata->local->hw,
5376 + &sdata->csa_finalize_work);
5378 +EXPORT_SYMBOL(ieee80211_csa_finish);
5380 +static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata,
5381 + struct beacon_data *beacon)
5383 + struct probe_resp *resp;
5384 + int counter_offset_beacon = sdata->csa_counter_offset_beacon;
5385 + int counter_offset_presp = sdata->csa_counter_offset_presp;
5387 + /* warn if the driver did not check for/react to csa completeness */
5388 + if (WARN_ON(((u8 *)beacon->tail)[counter_offset_beacon] == 0))
5391 + ((u8 *)beacon->tail)[counter_offset_beacon]--;
5393 + if (sdata->vif.type == NL80211_IFTYPE_AP &&
5394 + counter_offset_presp) {
5396 + resp = rcu_dereference(sdata->u.ap.probe_resp);
5398 + /* if nl80211 accepted the offset, this should not happen. */
5399 + if (WARN_ON(!resp)) {
5400 + rcu_read_unlock();
5403 + resp->data[counter_offset_presp]--;
5404 + rcu_read_unlock();
5408 +bool ieee80211_csa_is_complete(struct ieee80211_vif *vif)
5410 + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
5411 + struct beacon_data *beacon = NULL;
5413 + size_t beacon_data_len;
5414 + int counter_beacon = sdata->csa_counter_offset_beacon;
5417 + if (!ieee80211_sdata_running(sdata))
5421 + if (vif->type == NL80211_IFTYPE_AP) {
5422 + struct ieee80211_if_ap *ap = &sdata->u.ap;
5424 + beacon = rcu_dereference(ap->beacon);
5425 + if (WARN_ON(!beacon || !beacon->tail))
5427 + beacon_data = beacon->tail;
5428 + beacon_data_len = beacon->tail_len;
5434 + if (WARN_ON(counter_beacon > beacon_data_len))
5437 + if (beacon_data[counter_beacon] == 0)
5440 + rcu_read_unlock();
5444 +EXPORT_SYMBOL(ieee80211_csa_is_complete);
5446 struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
5447 struct ieee80211_vif *vif,
5448 u16 *tim_offset, u16 *tim_length)
5449 @@ -2356,6 +2432,9 @@ struct sk_buff *ieee80211_beacon_get_tim
5450 struct beacon_data *beacon = rcu_dereference(ap->beacon);
5453 + if (sdata->vif.csa_active)
5454 + ieee80211_update_csa(sdata, beacon);
5457 * headroom, head length,
5458 * tail length and maximum TIM length
5459 --- a/net/wireless/rdev-ops.h
5460 +++ b/net/wireless/rdev-ops.h
5461 @@ -923,4 +923,16 @@ static inline void rdev_crit_proto_stop(
5462 trace_rdev_return_void(&rdev->wiphy);
5465 +static inline int rdev_channel_switch(struct cfg80211_registered_device *rdev,
5466 + struct net_device *dev,
5467 + struct cfg80211_csa_settings *params)
5471 + trace_rdev_channel_switch(&rdev->wiphy, dev, params);
5472 + ret = rdev->ops->channel_switch(&rdev->wiphy, dev, params);
5473 + trace_rdev_return_int(&rdev->wiphy, ret);
5477 #endif /* __CFG80211_RDEV_OPS */
5478 --- a/net/wireless/trace.h
5479 +++ b/net/wireless/trace.h
5480 @@ -1841,6 +1841,39 @@ TRACE_EVENT(rdev_crit_proto_stop,
5481 WIPHY_PR_ARG, WDEV_PR_ARG)
5484 +TRACE_EVENT(rdev_channel_switch,
5485 + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
5486 + struct cfg80211_csa_settings *params),
5487 + TP_ARGS(wiphy, netdev, params),
5492 + __field(u16, counter_offset_beacon)
5493 + __field(u16, counter_offset_presp)
5494 + __field(bool, radar_required)
5495 + __field(bool, block_tx)
5496 + __field(u8, count)
5501 + CHAN_DEF_ASSIGN(¶ms->chandef);
5502 + __entry->counter_offset_beacon = params->counter_offset_beacon;
5503 + __entry->counter_offset_presp = params->counter_offset_presp;
5504 + __entry->radar_required = params->radar_required;
5505 + __entry->block_tx = params->block_tx;
5506 + __entry->count = params->count;
5508 + TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT
5509 + ", block_tx: %d, count: %u, radar_required: %d"
5510 + ", counter offsets (beacon/presp): %u/%u",
5511 + WIPHY_PR_ARG, NETDEV_PR_ARG, CHAN_DEF_PR_ARG,
5512 + __entry->block_tx, __entry->count, __entry->radar_required,
5513 + __entry->counter_offset_beacon,
5514 + __entry->counter_offset_presp)
5517 /*************************************************************
5518 * cfg80211 exported functions traces *
5519 *************************************************************/
5520 --- a/drivers/net/wireless/ath/ath.h
5521 +++ b/drivers/net/wireless/ath/ath.h
5522 @@ -159,7 +159,7 @@ struct ath_common {
5524 bool btcoex_enabled;
5526 - bool antenna_diversity;
5527 + bool bt_ant_diversity;
5530 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
5531 --- a/drivers/net/wireless/ath/ath9k/antenna.c
5532 +++ b/drivers/net/wireless/ath/ath9k/antenna.c
5533 @@ -16,37 +16,119 @@
5537 -static inline bool ath_is_alt_ant_ratio_better(int alt_ratio, int maxdelta,
5542 + * EEPROM has 2 4-bit fields containing the card configuration.
5546 + * bb_enable_ant_div_lnadiv : 1
5547 + * bb_ant_div_alt_gaintb : 1
5548 + * bb_ant_div_main_gaintb : 1
5549 + * bb_enable_ant_fast_div : 1
5553 + * bb_ant_div_alt_lnaconf : 2
5554 + * bb_ant_div_main_lnaconf : 2
5556 + * The EEPROM bits are used as follows:
5557 + * ------------------------------------
5559 + * bb_enable_ant_div_lnadiv - Enable LNA path rx antenna diversity/combining.
5560 + * Set in AR_PHY_MULTICHAIN_GAIN_CTL.
5562 + * bb_ant_div_[alt/main]_gaintb - 0 -> Antenna config Alt/Main uses gaintable 0
5563 + * 1 -> Antenna config Alt/Main uses gaintable 1
5564 + * Set in AR_PHY_MULTICHAIN_GAIN_CTL.
5566 + * bb_enable_ant_fast_div - Enable fast antenna diversity.
5567 + * Set in AR_PHY_CCK_DETECT.
5569 + * bb_ant_div_[alt/main]_lnaconf - Alt/Main LNA diversity/combining input config.
5570 + * Set in AR_PHY_MULTICHAIN_GAIN_CTL.
5576 + * AR9485 / AR9565 / AR9331
5577 + * ========================
5579 + * The same bits are present in the EEPROM, but the location in the
5580 + * EEPROM is different (ant_div_control in ar9300_BaseExtension_1).
5582 + * ant_div_alt_lnaconf ==> bit 0~1
5583 + * ant_div_main_lnaconf ==> bit 2~3
5584 + * ant_div_alt_gaintb ==> bit 4
5585 + * ant_div_main_gaintb ==> bit 5
5586 + * enable_ant_div_lnadiv ==> bit 6
5587 + * enable_ant_fast_div ==> bit 7
5590 +static inline bool ath_is_alt_ant_ratio_better(struct ath_ant_comb *antcomb,
5591 + int alt_ratio, int maxdelta,
5592 int mindelta, int main_rssi_avg,
5593 int alt_rssi_avg, int pkt_count)
5595 - return (((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
5596 - (alt_rssi_avg > main_rssi_avg + maxdelta)) ||
5597 - (alt_rssi_avg > main_rssi_avg + mindelta)) && (pkt_count > 50);
5598 + if (pkt_count <= 50)
5601 + if (alt_rssi_avg > main_rssi_avg + mindelta)
5604 + if (alt_ratio >= antcomb->ant_ratio2 &&
5605 + alt_rssi_avg >= antcomb->low_rssi_thresh &&
5606 + (alt_rssi_avg > main_rssi_avg + maxdelta))
5612 -static inline bool ath_ant_div_comb_alt_check(u8 div_group, int alt_ratio,
5613 - int curr_main_set, int curr_alt_set,
5614 - int alt_rssi_avg, int main_rssi_avg)
5615 +static inline bool ath_ant_div_comb_alt_check(struct ath_hw_antcomb_conf *conf,
5616 + struct ath_ant_comb *antcomb,
5617 + int alt_ratio, int alt_rssi_avg,
5618 + int main_rssi_avg)
5620 - bool result = false;
5621 - switch (div_group) {
5622 + bool result, set1, set2;
5624 + result = set1 = set2 = false;
5626 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2 &&
5627 + conf->alt_lna_conf == ATH_ANT_DIV_COMB_LNA1)
5630 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA1 &&
5631 + conf->alt_lna_conf == ATH_ANT_DIV_COMB_LNA2)
5634 + switch (conf->div_group) {
5636 if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)
5641 - if ((((curr_main_set == ATH_ANT_DIV_COMB_LNA2) &&
5642 - (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) &&
5643 - (alt_rssi_avg >= (main_rssi_avg - 5))) ||
5644 - ((curr_main_set == ATH_ANT_DIV_COMB_LNA1) &&
5645 - (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) &&
5646 - (alt_rssi_avg >= (main_rssi_avg - 2)))) &&
5647 - (alt_rssi_avg >= 4))
5648 + if (alt_rssi_avg < 4 || alt_rssi_avg < antcomb->low_rssi_thresh)
5651 + if ((set1 && (alt_rssi_avg >= (main_rssi_avg - 5))) ||
5652 + (set2 && (alt_rssi_avg >= (main_rssi_avg - 2))) ||
5653 + (alt_ratio > antcomb->ant_ratio))
5660 + if (alt_rssi_avg < 4 || alt_rssi_avg < antcomb->low_rssi_thresh)
5663 + if ((set1 && (alt_rssi_avg >= (main_rssi_avg - 3))) ||
5664 + (set2 && (alt_rssi_avg >= (main_rssi_avg + 3))) ||
5665 + (alt_ratio > antcomb->ant_ratio))
5671 @@ -108,6 +190,74 @@ static void ath_lnaconf_alt_good_scan(st
5675 +static void ath_ant_set_alt_ratio(struct ath_ant_comb *antcomb,
5676 + struct ath_hw_antcomb_conf *conf)
5678 + /* set alt to the conf with maximun ratio */
5679 + if (antcomb->first_ratio && antcomb->second_ratio) {
5680 + if (antcomb->rssi_second > antcomb->rssi_third) {
5682 + if ((antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) ||
5683 + (antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2))
5684 + /* Set alt LNA1 or LNA2*/
5685 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
5686 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
5688 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
5690 + /* Set alt to A+B or A-B */
5691 + conf->alt_lna_conf =
5692 + antcomb->first_quick_scan_conf;
5693 + } else if ((antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) ||
5694 + (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) {
5695 + /* Set alt LNA1 or LNA2 */
5696 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
5697 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
5699 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
5701 + /* Set alt to A+B or A-B */
5702 + conf->alt_lna_conf = antcomb->second_quick_scan_conf;
5704 + } else if (antcomb->first_ratio) {
5706 + if ((antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) ||
5707 + (antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2))
5708 + /* Set alt LNA1 or LNA2 */
5709 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
5710 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
5712 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
5714 + /* Set alt to A+B or A-B */
5715 + conf->alt_lna_conf = antcomb->first_quick_scan_conf;
5716 + } else if (antcomb->second_ratio) {
5718 + if ((antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) ||
5719 + (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2))
5720 + /* Set alt LNA1 or LNA2 */
5721 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
5722 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
5724 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
5726 + /* Set alt to A+B or A-B */
5727 + conf->alt_lna_conf = antcomb->second_quick_scan_conf;
5729 + /* main is largest */
5730 + if ((antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) ||
5731 + (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2))
5732 + /* Set alt LNA1 or LNA2 */
5733 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
5734 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
5736 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
5738 + /* Set alt to A+B or A-B */
5739 + conf->alt_lna_conf = antcomb->main_conf;
5743 static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb,
5744 struct ath_hw_antcomb_conf *div_ant_conf,
5745 int main_rssi_avg, int alt_rssi_avg,
5746 @@ -129,7 +279,7 @@ static void ath_select_ant_div_from_quic
5748 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) {
5750 - if (ath_is_alt_ant_ratio_better(alt_ratio,
5751 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
5752 ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
5753 ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
5754 main_rssi_avg, alt_rssi_avg,
5755 @@ -138,7 +288,7 @@ static void ath_select_ant_div_from_quic
5757 antcomb->first_ratio = false;
5758 } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) {
5759 - if (ath_is_alt_ant_ratio_better(alt_ratio,
5760 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
5761 ATH_ANT_DIV_COMB_LNA1_DELTA_MID,
5762 ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
5763 main_rssi_avg, alt_rssi_avg,
5764 @@ -147,11 +297,11 @@ static void ath_select_ant_div_from_quic
5766 antcomb->first_ratio = false;
5768 - if ((((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
5769 - (alt_rssi_avg > main_rssi_avg +
5770 - ATH_ANT_DIV_COMB_LNA1_DELTA_HI)) ||
5771 - (alt_rssi_avg > main_rssi_avg)) &&
5772 - (antcomb->total_pkt_count > 50))
5773 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
5774 + ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
5776 + main_rssi_avg, alt_rssi_avg,
5777 + antcomb->total_pkt_count))
5778 antcomb->first_ratio = true;
5780 antcomb->first_ratio = false;
5781 @@ -164,17 +314,21 @@ static void ath_select_ant_div_from_quic
5782 antcomb->rssi_first = main_rssi_avg;
5783 antcomb->rssi_third = alt_rssi_avg;
5785 - if (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1)
5786 + switch(antcomb->second_quick_scan_conf) {
5787 + case ATH_ANT_DIV_COMB_LNA1:
5788 antcomb->rssi_lna1 = alt_rssi_avg;
5789 - else if (antcomb->second_quick_scan_conf ==
5790 - ATH_ANT_DIV_COMB_LNA2)
5792 + case ATH_ANT_DIV_COMB_LNA2:
5793 antcomb->rssi_lna2 = alt_rssi_avg;
5794 - else if (antcomb->second_quick_scan_conf ==
5795 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2) {
5797 + case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2:
5798 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2)
5799 antcomb->rssi_lna2 = main_rssi_avg;
5800 else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1)
5801 antcomb->rssi_lna1 = main_rssi_avg;
5807 if (antcomb->rssi_lna2 > antcomb->rssi_lna1 +
5808 @@ -184,7 +338,7 @@ static void ath_select_ant_div_from_quic
5809 div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
5811 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) {
5812 - if (ath_is_alt_ant_ratio_better(alt_ratio,
5813 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
5814 ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
5815 ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
5816 main_rssi_avg, alt_rssi_avg,
5817 @@ -193,7 +347,7 @@ static void ath_select_ant_div_from_quic
5819 antcomb->second_ratio = false;
5820 } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) {
5821 - if (ath_is_alt_ant_ratio_better(alt_ratio,
5822 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
5823 ATH_ANT_DIV_COMB_LNA1_DELTA_MID,
5824 ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
5825 main_rssi_avg, alt_rssi_avg,
5826 @@ -202,105 +356,18 @@ static void ath_select_ant_div_from_quic
5828 antcomb->second_ratio = false;
5830 - if ((((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
5831 - (alt_rssi_avg > main_rssi_avg +
5832 - ATH_ANT_DIV_COMB_LNA1_DELTA_HI)) ||
5833 - (alt_rssi_avg > main_rssi_avg)) &&
5834 - (antcomb->total_pkt_count > 50))
5835 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
5836 + ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
5838 + main_rssi_avg, alt_rssi_avg,
5839 + antcomb->total_pkt_count))
5840 antcomb->second_ratio = true;
5842 antcomb->second_ratio = false;
5845 - /* set alt to the conf with maximun ratio */
5846 - if (antcomb->first_ratio && antcomb->second_ratio) {
5847 - if (antcomb->rssi_second > antcomb->rssi_third) {
5849 - if ((antcomb->first_quick_scan_conf ==
5850 - ATH_ANT_DIV_COMB_LNA1) ||
5851 - (antcomb->first_quick_scan_conf ==
5852 - ATH_ANT_DIV_COMB_LNA2))
5853 - /* Set alt LNA1 or LNA2*/
5854 - if (div_ant_conf->main_lna_conf ==
5855 - ATH_ANT_DIV_COMB_LNA2)
5856 - div_ant_conf->alt_lna_conf =
5857 - ATH_ANT_DIV_COMB_LNA1;
5859 - div_ant_conf->alt_lna_conf =
5860 - ATH_ANT_DIV_COMB_LNA2;
5862 - /* Set alt to A+B or A-B */
5863 - div_ant_conf->alt_lna_conf =
5864 - antcomb->first_quick_scan_conf;
5865 - } else if ((antcomb->second_quick_scan_conf ==
5866 - ATH_ANT_DIV_COMB_LNA1) ||
5867 - (antcomb->second_quick_scan_conf ==
5868 - ATH_ANT_DIV_COMB_LNA2)) {
5869 - /* Set alt LNA1 or LNA2 */
5870 - if (div_ant_conf->main_lna_conf ==
5871 - ATH_ANT_DIV_COMB_LNA2)
5872 - div_ant_conf->alt_lna_conf =
5873 - ATH_ANT_DIV_COMB_LNA1;
5875 - div_ant_conf->alt_lna_conf =
5876 - ATH_ANT_DIV_COMB_LNA2;
5878 - /* Set alt to A+B or A-B */
5879 - div_ant_conf->alt_lna_conf =
5880 - antcomb->second_quick_scan_conf;
5882 - } else if (antcomb->first_ratio) {
5884 - if ((antcomb->first_quick_scan_conf ==
5885 - ATH_ANT_DIV_COMB_LNA1) ||
5886 - (antcomb->first_quick_scan_conf ==
5887 - ATH_ANT_DIV_COMB_LNA2))
5888 - /* Set alt LNA1 or LNA2 */
5889 - if (div_ant_conf->main_lna_conf ==
5890 - ATH_ANT_DIV_COMB_LNA2)
5891 - div_ant_conf->alt_lna_conf =
5892 - ATH_ANT_DIV_COMB_LNA1;
5894 - div_ant_conf->alt_lna_conf =
5895 - ATH_ANT_DIV_COMB_LNA2;
5897 - /* Set alt to A+B or A-B */
5898 - div_ant_conf->alt_lna_conf =
5899 - antcomb->first_quick_scan_conf;
5900 - } else if (antcomb->second_ratio) {
5902 - if ((antcomb->second_quick_scan_conf ==
5903 - ATH_ANT_DIV_COMB_LNA1) ||
5904 - (antcomb->second_quick_scan_conf ==
5905 - ATH_ANT_DIV_COMB_LNA2))
5906 - /* Set alt LNA1 or LNA2 */
5907 - if (div_ant_conf->main_lna_conf ==
5908 - ATH_ANT_DIV_COMB_LNA2)
5909 - div_ant_conf->alt_lna_conf =
5910 - ATH_ANT_DIV_COMB_LNA1;
5912 - div_ant_conf->alt_lna_conf =
5913 - ATH_ANT_DIV_COMB_LNA2;
5915 - /* Set alt to A+B or A-B */
5916 - div_ant_conf->alt_lna_conf =
5917 - antcomb->second_quick_scan_conf;
5919 - /* main is largest */
5920 - if ((antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) ||
5921 - (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2))
5922 - /* Set alt LNA1 or LNA2 */
5923 - if (div_ant_conf->main_lna_conf ==
5924 - ATH_ANT_DIV_COMB_LNA2)
5925 - div_ant_conf->alt_lna_conf =
5926 - ATH_ANT_DIV_COMB_LNA1;
5928 - div_ant_conf->alt_lna_conf =
5929 - ATH_ANT_DIV_COMB_LNA2;
5931 - /* Set alt to A+B or A-B */
5932 - div_ant_conf->alt_lna_conf = antcomb->main_conf;
5934 + ath_ant_set_alt_ratio(antcomb, div_ant_conf);
5939 @@ -430,8 +497,7 @@ static void ath_ant_div_conf_fast_divbia
5940 ant_conf->fast_div_bias = 0x1;
5942 case 0x10: /* LNA2 A-B */
5943 - if (!(antcomb->scan) &&
5944 - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
5945 + if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio))
5946 ant_conf->fast_div_bias = 0x1;
5948 ant_conf->fast_div_bias = 0x2;
5949 @@ -440,15 +506,13 @@ static void ath_ant_div_conf_fast_divbia
5950 ant_conf->fast_div_bias = 0x1;
5952 case 0x13: /* LNA2 A+B */
5953 - if (!(antcomb->scan) &&
5954 - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
5955 + if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio))
5956 ant_conf->fast_div_bias = 0x1;
5958 ant_conf->fast_div_bias = 0x2;
5960 case 0x20: /* LNA1 A-B */
5961 - if (!(antcomb->scan) &&
5962 - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
5963 + if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio))
5964 ant_conf->fast_div_bias = 0x1;
5966 ant_conf->fast_div_bias = 0x2;
5967 @@ -457,8 +521,7 @@ static void ath_ant_div_conf_fast_divbia
5968 ant_conf->fast_div_bias = 0x1;
5970 case 0x23: /* LNA1 A+B */
5971 - if (!(antcomb->scan) &&
5972 - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
5973 + if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio))
5974 ant_conf->fast_div_bias = 0x1;
5976 ant_conf->fast_div_bias = 0x2;
5977 @@ -475,6 +538,9 @@ static void ath_ant_div_conf_fast_divbia
5982 + if (antcomb->fast_div_bias)
5983 + ant_conf->fast_div_bias = antcomb->fast_div_bias;
5984 } else if (ant_conf->div_group == 3) {
5985 switch ((ant_conf->main_lna_conf << 4) |
5986 ant_conf->alt_lna_conf) {
5987 @@ -540,6 +606,138 @@ static void ath_ant_div_conf_fast_divbia
5991 +static void ath_ant_try_scan(struct ath_ant_comb *antcomb,
5992 + struct ath_hw_antcomb_conf *conf,
5993 + int curr_alt_set, int alt_rssi_avg,
5994 + int main_rssi_avg)
5996 + switch (curr_alt_set) {
5997 + case ATH_ANT_DIV_COMB_LNA2:
5998 + antcomb->rssi_lna2 = alt_rssi_avg;
5999 + antcomb->rssi_lna1 = main_rssi_avg;
6000 + antcomb->scan = true;
6002 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6003 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6005 + case ATH_ANT_DIV_COMB_LNA1:
6006 + antcomb->rssi_lna1 = alt_rssi_avg;
6007 + antcomb->rssi_lna2 = main_rssi_avg;
6008 + antcomb->scan = true;
6010 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6011 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6013 + case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2:
6014 + antcomb->rssi_add = alt_rssi_avg;
6015 + antcomb->scan = true;
6017 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6019 + case ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2:
6020 + antcomb->rssi_sub = alt_rssi_avg;
6021 + antcomb->scan = false;
6022 + if (antcomb->rssi_lna2 >
6023 + (antcomb->rssi_lna1 + ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)) {
6024 + /* use LNA2 as main LNA */
6025 + if ((antcomb->rssi_add > antcomb->rssi_lna1) &&
6026 + (antcomb->rssi_add > antcomb->rssi_sub)) {
6028 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6029 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6030 + } else if (antcomb->rssi_sub >
6031 + antcomb->rssi_lna1) {
6033 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6034 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6037 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6038 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6041 + /* use LNA1 as main LNA */
6042 + if ((antcomb->rssi_add > antcomb->rssi_lna2) &&
6043 + (antcomb->rssi_add > antcomb->rssi_sub)) {
6045 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6046 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6047 + } else if (antcomb->rssi_sub >
6048 + antcomb->rssi_lna1) {
6050 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6051 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6054 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6055 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6064 +static bool ath_ant_try_switch(struct ath_hw_antcomb_conf *div_ant_conf,
6065 + struct ath_ant_comb *antcomb,
6066 + int alt_ratio, int alt_rssi_avg,
6067 + int main_rssi_avg, int curr_main_set,
6072 + if (ath_ant_div_comb_alt_check(div_ant_conf, antcomb, alt_ratio,
6073 + alt_rssi_avg, main_rssi_avg)) {
6074 + if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) {
6076 + * Switch main and alt LNA.
6078 + div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6079 + div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6080 + } else if (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) {
6081 + div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6082 + div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6086 + } else if ((curr_alt_set != ATH_ANT_DIV_COMB_LNA1) &&
6087 + (curr_alt_set != ATH_ANT_DIV_COMB_LNA2)) {
6089 + Set alt to another LNA.
6091 + if (curr_main_set == ATH_ANT_DIV_COMB_LNA2)
6092 + div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6093 + else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1)
6094 + div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6102 +static bool ath_ant_short_scan_check(struct ath_ant_comb *antcomb)
6106 + if (!antcomb->scan || !antcomb->alt_good)
6109 + if (time_after(jiffies, antcomb->scan_start_time +
6110 + msecs_to_jiffies(ATH_ANT_DIV_COMB_SHORT_SCAN_INTR)))
6113 + if (antcomb->total_pkt_count == ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT) {
6114 + alt_ratio = ((antcomb->alt_recv_cnt * 100) /
6115 + antcomb->total_pkt_count);
6116 + if (alt_ratio < antcomb->ant_ratio)
6123 void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs)
6125 struct ath_hw_antcomb_conf div_ant_conf;
6126 @@ -549,41 +747,46 @@ void ath_ant_comb_scan(struct ath_softc
6127 int main_rssi = rs->rs_rssi_ctl0;
6128 int alt_rssi = rs->rs_rssi_ctl1;
6129 int rx_ant_conf, main_ant_conf;
6130 - bool short_scan = false;
6131 + bool short_scan = false, ret;
6133 rx_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_CURRENT_SHIFT) &
6135 main_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_MAIN_SHIFT) &
6138 + if (alt_rssi >= antcomb->low_rssi_thresh) {
6139 + antcomb->ant_ratio = ATH_ANT_DIV_COMB_ALT_ANT_RATIO;
6140 + antcomb->ant_ratio2 = ATH_ANT_DIV_COMB_ALT_ANT_RATIO2;
6142 + antcomb->ant_ratio = ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI;
6143 + antcomb->ant_ratio2 = ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI;
6146 /* Record packet only when both main_rssi and alt_rssi is positive */
6147 if (main_rssi > 0 && alt_rssi > 0) {
6148 antcomb->total_pkt_count++;
6149 antcomb->main_total_rssi += main_rssi;
6150 antcomb->alt_total_rssi += alt_rssi;
6152 if (main_ant_conf == rx_ant_conf)
6153 antcomb->main_recv_cnt++;
6155 antcomb->alt_recv_cnt++;
6158 - /* Short scan check */
6159 - if (antcomb->scan && antcomb->alt_good) {
6160 - if (time_after(jiffies, antcomb->scan_start_time +
6161 - msecs_to_jiffies(ATH_ANT_DIV_COMB_SHORT_SCAN_INTR)))
6162 - short_scan = true;
6164 - if (antcomb->total_pkt_count ==
6165 - ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT) {
6166 - alt_ratio = ((antcomb->alt_recv_cnt * 100) /
6167 - antcomb->total_pkt_count);
6168 - if (alt_ratio < ATH_ANT_DIV_COMB_ALT_ANT_RATIO)
6169 - short_scan = true;
6171 + if (main_ant_conf == rx_ant_conf) {
6172 + ANT_STAT_INC(ANT_MAIN, recv_cnt);
6173 + ANT_LNA_INC(ANT_MAIN, rx_ant_conf);
6175 + ANT_STAT_INC(ANT_ALT, recv_cnt);
6176 + ANT_LNA_INC(ANT_ALT, rx_ant_conf);
6179 + /* Short scan check */
6180 + short_scan = ath_ant_short_scan_check(antcomb);
6182 if (((antcomb->total_pkt_count < ATH_ANT_DIV_COMB_MAX_PKTCOUNT) ||
6183 - rs->rs_moreaggr) && !short_scan)
6184 + rs->rs_moreaggr) && !short_scan)
6187 if (antcomb->total_pkt_count) {
6188 @@ -595,15 +798,13 @@ void ath_ant_comb_scan(struct ath_softc
6189 antcomb->total_pkt_count);
6193 ath9k_hw_antdiv_comb_conf_get(sc->sc_ah, &div_ant_conf);
6194 curr_alt_set = div_ant_conf.alt_lna_conf;
6195 curr_main_set = div_ant_conf.main_lna_conf;
6199 if (antcomb->count == ATH_ANT_DIV_COMB_MAX_COUNT) {
6200 - if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) {
6201 + if (alt_ratio > antcomb->ant_ratio) {
6202 ath_lnaconf_alt_good_scan(antcomb, div_ant_conf,
6204 antcomb->alt_good = true;
6205 @@ -617,153 +818,47 @@ void ath_ant_comb_scan(struct ath_softc
6208 if (!antcomb->scan) {
6209 - if (ath_ant_div_comb_alt_check(div_ant_conf.div_group,
6210 - alt_ratio, curr_main_set, curr_alt_set,
6211 - alt_rssi_avg, main_rssi_avg)) {
6212 - if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) {
6213 - /* Switch main and alt LNA */
6214 - div_ant_conf.main_lna_conf =
6215 - ATH_ANT_DIV_COMB_LNA2;
6216 - div_ant_conf.alt_lna_conf =
6217 - ATH_ANT_DIV_COMB_LNA1;
6218 - } else if (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) {
6219 - div_ant_conf.main_lna_conf =
6220 - ATH_ANT_DIV_COMB_LNA1;
6221 - div_ant_conf.alt_lna_conf =
6222 - ATH_ANT_DIV_COMB_LNA2;
6225 - goto div_comb_done;
6226 - } else if ((curr_alt_set != ATH_ANT_DIV_COMB_LNA1) &&
6227 - (curr_alt_set != ATH_ANT_DIV_COMB_LNA2)) {
6228 - /* Set alt to another LNA */
6229 - if (curr_main_set == ATH_ANT_DIV_COMB_LNA2)
6230 - div_ant_conf.alt_lna_conf =
6231 - ATH_ANT_DIV_COMB_LNA1;
6232 - else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1)
6233 - div_ant_conf.alt_lna_conf =
6234 - ATH_ANT_DIV_COMB_LNA2;
6236 - goto div_comb_done;
6239 - if ((alt_rssi_avg < (main_rssi_avg +
6240 - div_ant_conf.lna1_lna2_delta)))
6241 + ret = ath_ant_try_switch(&div_ant_conf, antcomb, alt_ratio,
6242 + alt_rssi_avg, main_rssi_avg,
6243 + curr_main_set, curr_alt_set);
6248 + if (!antcomb->scan &&
6249 + (alt_rssi_avg < (main_rssi_avg + div_ant_conf.lna1_lna2_delta)))
6250 + goto div_comb_done;
6252 if (!antcomb->scan_not_start) {
6253 - switch (curr_alt_set) {
6254 - case ATH_ANT_DIV_COMB_LNA2:
6255 - antcomb->rssi_lna2 = alt_rssi_avg;
6256 - antcomb->rssi_lna1 = main_rssi_avg;
6257 - antcomb->scan = true;
6259 - div_ant_conf.main_lna_conf =
6260 - ATH_ANT_DIV_COMB_LNA1;
6261 - div_ant_conf.alt_lna_conf =
6262 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6264 - case ATH_ANT_DIV_COMB_LNA1:
6265 - antcomb->rssi_lna1 = alt_rssi_avg;
6266 - antcomb->rssi_lna2 = main_rssi_avg;
6267 - antcomb->scan = true;
6269 - div_ant_conf.main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6270 - div_ant_conf.alt_lna_conf =
6271 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6273 - case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2:
6274 - antcomb->rssi_add = alt_rssi_avg;
6275 - antcomb->scan = true;
6277 - div_ant_conf.alt_lna_conf =
6278 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6280 - case ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2:
6281 - antcomb->rssi_sub = alt_rssi_avg;
6282 - antcomb->scan = false;
6283 - if (antcomb->rssi_lna2 >
6284 - (antcomb->rssi_lna1 +
6285 - ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)) {
6286 - /* use LNA2 as main LNA */
6287 - if ((antcomb->rssi_add > antcomb->rssi_lna1) &&
6288 - (antcomb->rssi_add > antcomb->rssi_sub)) {
6290 - div_ant_conf.main_lna_conf =
6291 - ATH_ANT_DIV_COMB_LNA2;
6292 - div_ant_conf.alt_lna_conf =
6293 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6294 - } else if (antcomb->rssi_sub >
6295 - antcomb->rssi_lna1) {
6297 - div_ant_conf.main_lna_conf =
6298 - ATH_ANT_DIV_COMB_LNA2;
6299 - div_ant_conf.alt_lna_conf =
6300 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6303 - div_ant_conf.main_lna_conf =
6304 - ATH_ANT_DIV_COMB_LNA2;
6305 - div_ant_conf.alt_lna_conf =
6306 - ATH_ANT_DIV_COMB_LNA1;
6309 - /* use LNA1 as main LNA */
6310 - if ((antcomb->rssi_add > antcomb->rssi_lna2) &&
6311 - (antcomb->rssi_add > antcomb->rssi_sub)) {
6313 - div_ant_conf.main_lna_conf =
6314 - ATH_ANT_DIV_COMB_LNA1;
6315 - div_ant_conf.alt_lna_conf =
6316 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6317 - } else if (antcomb->rssi_sub >
6318 - antcomb->rssi_lna1) {
6320 - div_ant_conf.main_lna_conf =
6321 - ATH_ANT_DIV_COMB_LNA1;
6322 - div_ant_conf.alt_lna_conf =
6323 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6326 - div_ant_conf.main_lna_conf =
6327 - ATH_ANT_DIV_COMB_LNA1;
6328 - div_ant_conf.alt_lna_conf =
6329 - ATH_ANT_DIV_COMB_LNA2;
6336 + ath_ant_try_scan(antcomb, &div_ant_conf, curr_alt_set,
6337 + alt_rssi_avg, main_rssi_avg);
6339 if (!antcomb->alt_good) {
6340 antcomb->scan_not_start = false;
6341 /* Set alt to another LNA */
6342 if (curr_main_set == ATH_ANT_DIV_COMB_LNA2) {
6343 div_ant_conf.main_lna_conf =
6344 - ATH_ANT_DIV_COMB_LNA2;
6345 + ATH_ANT_DIV_COMB_LNA2;
6346 div_ant_conf.alt_lna_conf =
6347 - ATH_ANT_DIV_COMB_LNA1;
6348 + ATH_ANT_DIV_COMB_LNA1;
6349 } else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1) {
6350 div_ant_conf.main_lna_conf =
6351 - ATH_ANT_DIV_COMB_LNA1;
6352 + ATH_ANT_DIV_COMB_LNA1;
6353 div_ant_conf.alt_lna_conf =
6354 - ATH_ANT_DIV_COMB_LNA2;
6355 + ATH_ANT_DIV_COMB_LNA2;
6359 + ath_select_ant_div_from_quick_scan(antcomb, &div_ant_conf,
6360 + main_rssi_avg, alt_rssi_avg,
6362 + antcomb->quick_scan_cnt++;
6365 - ath_select_ant_div_from_quick_scan(antcomb, &div_ant_conf,
6366 - main_rssi_avg, alt_rssi_avg,
6369 - antcomb->quick_scan_cnt++;
6372 ath_ant_div_conf_fast_divbias(&div_ant_conf, antcomb, alt_ratio);
6373 ath9k_hw_antdiv_comb_conf_set(sc->sc_ah, &div_ant_conf);
6374 + ath9k_debug_stat_ant(sc, &div_ant_conf, main_rssi_avg, alt_rssi_avg);
6376 antcomb->scan_start_time = jiffies;
6377 antcomb->total_pkt_count = 0;
6378 @@ -772,26 +867,3 @@ div_comb_done:
6379 antcomb->main_recv_cnt = 0;
6380 antcomb->alt_recv_cnt = 0;
6383 -void ath_ant_comb_update(struct ath_softc *sc)
6385 - struct ath_hw *ah = sc->sc_ah;
6386 - struct ath_common *common = ath9k_hw_common(ah);
6387 - struct ath_hw_antcomb_conf div_ant_conf;
6390 - ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
6392 - if (sc->ant_rx == 1)
6393 - lna_conf = ATH_ANT_DIV_COMB_LNA1;
6395 - lna_conf = ATH_ANT_DIV_COMB_LNA2;
6397 - div_ant_conf.main_lna_conf = lna_conf;
6398 - div_ant_conf.alt_lna_conf = lna_conf;
6400 - ath9k_hw_antdiv_comb_conf_set(ah, &div_ant_conf);
6402 - if (common->antenna_diversity)
6403 - ath9k_hw_antctrl_shared_chain_lnadiv(ah, true);
6405 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
6406 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
6407 @@ -610,7 +610,15 @@ static void ar5008_hw_override_ini(struc
6408 REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
6410 if (AR_SREV_9280_20_OR_LATER(ah)) {
6411 - val = REG_READ(ah, AR_PCU_MISC_MODE2);
6413 + * For AR9280 and above, there is a new feature that allows
6414 + * Multicast search based on both MAC Address and Key ID.
6415 + * By default, this feature is enabled. But since the driver
6416 + * is not using this feature, we switch it off; otherwise
6417 + * multicast search based on MAC addr only will fail.
6419 + val = REG_READ(ah, AR_PCU_MISC_MODE2) &
6420 + (~AR_ADHOC_MCAST_KEYID_ENABLE);
6422 if (!AR_SREV_9271(ah))
6423 val &= ~AR_PCU_MISC_MODE2_HWWAR1;
6424 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
6425 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
6426 @@ -555,6 +555,69 @@ static void ar9002_hw_antdiv_comb_conf_s
6427 REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval);
6430 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
6432 +static void ar9002_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
6434 + struct ath_btcoex_hw *btcoex = &ah->btcoex_hw;
6435 + u8 antdiv_ctrl1, antdiv_ctrl2;
6439 + antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_ENABLE;
6440 + antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_ENABLE;
6443 + * Don't disable BT ant to allow BB to control SWCOM.
6445 + btcoex->bt_coex_mode2 &= (~(AR_BT_DISABLE_BT_ANT));
6446 + REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2);
6448 + REG_WRITE(ah, AR_PHY_SWITCH_COM, ATH_BT_COEX_ANT_DIV_SWITCH_COM);
6449 + REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000);
6452 + * Disable antenna diversity, use LNA1 only.
6454 + antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_FIXED_A;
6455 + antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_FIXED_A;
6458 + * Disable BT Ant. to allow concurrent BT and WLAN receive.
6460 + btcoex->bt_coex_mode2 |= AR_BT_DISABLE_BT_ANT;
6461 + REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2);
6464 + * Program SWCOM table to make sure RF switch always parks
6467 + REG_WRITE(ah, AR_PHY_SWITCH_COM, 0);
6468 + REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000);
6471 + regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
6472 + regval &= (~(AR_PHY_9285_ANT_DIV_CTL_ALL));
6474 + * Clear ant_fast_div_bias [14:9] since for WB195,
6475 + * the main LNA is always LNA1.
6477 + regval &= (~(AR_PHY_9285_FAST_DIV_BIAS));
6478 + regval |= SM(antdiv_ctrl1, AR_PHY_9285_ANT_DIV_CTL);
6479 + regval |= SM(antdiv_ctrl2, AR_PHY_9285_ANT_DIV_ALT_LNACONF);
6480 + regval |= SM((antdiv_ctrl2 >> 2), AR_PHY_9285_ANT_DIV_MAIN_LNACONF);
6481 + regval |= SM((antdiv_ctrl1 >> 1), AR_PHY_9285_ANT_DIV_ALT_GAINTB);
6482 + regval |= SM((antdiv_ctrl1 >> 2), AR_PHY_9285_ANT_DIV_MAIN_GAINTB);
6483 + REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval);
6485 + regval = REG_READ(ah, AR_PHY_CCK_DETECT);
6486 + regval &= (~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
6487 + regval |= SM((antdiv_ctrl1 >> 3), AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
6488 + REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
6493 static void ar9002_hw_spectral_scan_config(struct ath_hw *ah,
6494 struct ath_spec_scan *param)
6496 @@ -634,5 +697,9 @@ void ar9002_hw_attach_phy_ops(struct ath
6497 ops->spectral_scan_trigger = ar9002_hw_spectral_scan_trigger;
6498 ops->spectral_scan_wait = ar9002_hw_spectral_scan_wait;
6500 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
6501 + ops->set_bt_ant_diversity = ar9002_hw_set_bt_ant_diversity;
6504 ar9002_hw_set_nf_limits(ah);
6506 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.h
6507 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.h
6508 @@ -317,13 +317,15 @@
6509 #define AR_PHY_9285_ANT_DIV_ALT_GAINTB_S 29
6510 #define AR_PHY_9285_ANT_DIV_MAIN_GAINTB 0x40000000
6511 #define AR_PHY_9285_ANT_DIV_MAIN_GAINTB_S 30
6512 -#define AR_PHY_9285_ANT_DIV_LNA1 2
6513 -#define AR_PHY_9285_ANT_DIV_LNA2 1
6514 -#define AR_PHY_9285_ANT_DIV_LNA1_PLUS_LNA2 3
6515 -#define AR_PHY_9285_ANT_DIV_LNA1_MINUS_LNA2 0
6516 #define AR_PHY_9285_ANT_DIV_GAINTB_0 0
6517 #define AR_PHY_9285_ANT_DIV_GAINTB_1 1
6519 +#define ATH_BT_COEX_ANTDIV_CONTROL1_ENABLE 0x0b
6520 +#define ATH_BT_COEX_ANTDIV_CONTROL2_ENABLE 0x09
6521 +#define ATH_BT_COEX_ANTDIV_CONTROL1_FIXED_A 0x04
6522 +#define ATH_BT_COEX_ANTDIV_CONTROL2_FIXED_A 0x09
6523 +#define ATH_BT_COEX_ANT_DIV_SWITCH_COM 0x66666666
6525 #define AR_PHY_EXT_CCA0 0x99b8
6526 #define AR_PHY_EXT_CCA0_THRESH62 0x000000FF
6527 #define AR_PHY_EXT_CCA0_THRESH62_S 0
6528 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
6529 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
6530 @@ -3541,13 +3541,12 @@ static u16 ar9003_switch_com_spdt_get(st
6531 return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
6535 -static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
6536 +u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
6538 return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon);
6541 -static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
6542 +u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
6544 return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
6546 @@ -3561,6 +3560,7 @@ static u16 ar9003_hw_ant_ctrl_chain_get(
6548 static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
6550 + struct ath_common *common = ath9k_hw_common(ah);
6551 struct ath9k_hw_capabilities *pCap = &ah->caps;
6553 u32 regval, value, gpio;
6554 @@ -3614,6 +3614,11 @@ static void ar9003_hw_ant_ctrl_apply(str
6557 value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
6558 + if (AR_SREV_9485(ah) && common->bt_ant_diversity) {
6559 + regval &= ~AR_SWITCH_TABLE_COM2_ALL;
6560 + regval |= ah->config.ant_ctrl_comm2g_switch_enable;
6563 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
6565 if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
6566 @@ -3645,8 +3650,11 @@ static void ar9003_hw_ant_ctrl_apply(str
6567 regval &= (~AR_PHY_ANT_DIV_LNADIV);
6568 regval |= ((value >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
6570 + if (AR_SREV_9485(ah) && common->bt_ant_diversity)
6571 + regval |= AR_ANT_DIV_ENABLE;
6573 if (AR_SREV_9565(ah)) {
6574 - if (ah->shared_chain_lnadiv) {
6575 + if (common->bt_ant_diversity) {
6576 regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S);
6578 regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S);
6579 @@ -3656,10 +3664,14 @@ static void ar9003_hw_ant_ctrl_apply(str
6581 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
6583 - /*enable fast_div */
6584 + /* enable fast_div */
6585 regval = REG_READ(ah, AR_PHY_CCK_DETECT);
6586 regval &= (~AR_FAST_DIV_ENABLE);
6587 regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
6589 + if (AR_SREV_9485(ah) && common->bt_ant_diversity)
6590 + regval |= AR_FAST_DIV_ENABLE;
6592 REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
6594 if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
6595 @@ -3673,9 +3685,9 @@ static void ar9003_hw_ant_ctrl_apply(str
6596 AR_PHY_ANT_DIV_ALT_GAINTB |
6597 AR_PHY_ANT_DIV_MAIN_GAINTB));
6598 /* by default use LNA1 for the main antenna */
6599 - regval |= (AR_PHY_ANT_DIV_LNA1 <<
6600 + regval |= (ATH_ANT_DIV_COMB_LNA1 <<
6601 AR_PHY_ANT_DIV_MAIN_LNACONF_S);
6602 - regval |= (AR_PHY_ANT_DIV_LNA2 <<
6603 + regval |= (ATH_ANT_DIV_COMB_LNA2 <<
6604 AR_PHY_ANT_DIV_ALT_LNACONF_S);
6605 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
6607 @@ -3813,6 +3825,11 @@ static void ar9003_hw_atten_apply(struct
6609 value = ar9003_hw_atten_chain_get_margin(ah, i, chan);
6611 + if (ah->config.alt_mingainidx)
6612 + REG_RMW_FIELD(ah, AR_PHY_EXT_ATTEN_CTL_0,
6613 + AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
6616 REG_RMW_FIELD(ah, ext_atten_reg[i],
6617 AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
6619 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
6620 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
6621 @@ -334,6 +334,8 @@ struct ar9300_eeprom {
6623 s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah);
6624 s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah);
6625 +u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz);
6626 +u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz);
6628 u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz);
6630 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
6631 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
6633 #define AR_PHY_SFCORR_SPUR_SUBCHNL_SD_S 28
6634 #define AR_PHY_EXT_CCA_THRESH62 0x007F0000
6635 #define AR_PHY_EXT_CCA_THRESH62_S 16
6636 +#define AR_PHY_EXTCHN_PWRTHR1_ANT_DIV_ALT_ANT_MINGAINIDX 0x0000FF00
6637 +#define AR_PHY_EXTCHN_PWRTHR1_ANT_DIV_ALT_ANT_MINGAINIDX_S 8
6638 #define AR_PHY_EXT_MINCCA_PWR 0x01FF0000
6639 #define AR_PHY_EXT_MINCCA_PWR_S 16
6640 #define AR_PHY_EXT_CYCPWR_THR1 0x0000FE00L
6641 @@ -296,11 +298,6 @@
6642 #define AR_PHY_ANT_DIV_MAIN_GAINTB 0x40000000
6643 #define AR_PHY_ANT_DIV_MAIN_GAINTB_S 30
6645 -#define AR_PHY_ANT_DIV_LNA1_MINUS_LNA2 0x0
6646 -#define AR_PHY_ANT_DIV_LNA2 0x1
6647 -#define AR_PHY_ANT_DIV_LNA1 0x2
6648 -#define AR_PHY_ANT_DIV_LNA1_PLUS_LNA2 0x3
6650 #define AR_PHY_EXTCHN_PWRTHR1 (AR_AGC_BASE + 0x2c)
6651 #define AR_PHY_EXT_CHN_WIN (AR_AGC_BASE + 0x30)
6652 #define AR_PHY_20_40_DET_THR (AR_AGC_BASE + 0x34)
6653 --- a/drivers/net/wireless/ath/ath9k/debug.h
6654 +++ b/drivers/net/wireless/ath/ath9k/debug.h
6655 @@ -28,9 +28,13 @@ struct fft_sample_tlv;
6656 #ifdef CPTCFG_ATH9K_DEBUGFS
6657 #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
6658 #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++
6659 +#define ANT_STAT_INC(i, c) sc->debug.stats.ant_stats[i].c++
6660 +#define ANT_LNA_INC(i, c) sc->debug.stats.ant_stats[i].lna_recv_cnt[c]++;
6662 #define TX_STAT_INC(q, c) do { } while (0)
6663 #define RESET_STAT_INC(sc, type) do { } while (0)
6664 +#define ANT_STAT_INC(i, c) do { } while (0)
6665 +#define ANT_LNA_INC(i, c) do { } while (0)
6668 enum ath_reset_type {
6669 @@ -243,11 +247,22 @@ struct ath_rx_stats {
6676 +struct ath_antenna_stats {
6679 + u32 lna_recv_cnt[4];
6680 + u32 lna_attempt_cnt[4];
6684 struct ath_interrupt_stats istats;
6685 struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
6686 struct ath_rx_stats rxstats;
6687 struct ath_dfs_stats dfs_stats;
6688 + struct ath_antenna_stats ant_stats[2];
6689 u32 reset[__RESET_TYPE_MAX];
6692 @@ -281,10 +296,11 @@ void ath9k_sta_remove_debugfs(struct iee
6693 struct ieee80211_vif *vif,
6694 struct ieee80211_sta *sta,
6695 struct dentry *dir);
6697 void ath_debug_send_fft_sample(struct ath_softc *sc,
6698 struct fft_sample_tlv *fft_sample);
6700 +void ath9k_debug_stat_ant(struct ath_softc *sc,
6701 + struct ath_hw_antcomb_conf *div_ant_conf,
6702 + int main_rssi_avg, int alt_rssi_avg);
6705 #define RX_STAT_INC(c) /* NOP */
6706 @@ -297,12 +313,10 @@ static inline int ath9k_init_debug(struc
6707 static inline void ath9k_deinit_debug(struct ath_softc *sc)
6711 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
6712 enum ath9k_int status)
6716 static inline void ath_debug_stat_tx(struct ath_softc *sc,
6718 struct ath_tx_status *ts,
6719 @@ -310,11 +324,16 @@ static inline void ath_debug_stat_tx(str
6724 static inline void ath_debug_stat_rx(struct ath_softc *sc,
6725 struct ath_rx_status *rs)
6728 +static inline void ath9k_debug_stat_ant(struct ath_softc *sc,
6729 + struct ath_hw_antcomb_conf *div_ant_conf,
6730 + int main_rssi_avg, int alt_rssi_avg)
6735 #endif /* CPTCFG_ATH9K_DEBUGFS */
6737 --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
6738 +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
6739 @@ -812,6 +812,7 @@ static void ath9k_hw_4k_set_gain(struct
6740 static void ath9k_hw_4k_set_board_values(struct ath_hw *ah,
6741 struct ath9k_channel *chan)
6743 + struct ath9k_hw_capabilities *pCap = &ah->caps;
6744 struct modal_eep_4k_header *pModal;
6745 struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
6746 struct base_eep_header_4k *pBase = &eep->baseEepHeader;
6747 @@ -858,6 +859,24 @@ static void ath9k_hw_4k_set_board_values
6749 REG_WRITE(ah, AR_PHY_CCK_DETECT, regVal);
6750 regVal = REG_READ(ah, AR_PHY_CCK_DETECT);
6752 + if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
6754 + * If diversity combining is enabled,
6755 + * set MAIN to LNA1 and ALT to LNA2 initially.
6757 + regVal = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
6758 + regVal &= (~(AR_PHY_9285_ANT_DIV_MAIN_LNACONF |
6759 + AR_PHY_9285_ANT_DIV_ALT_LNACONF));
6761 + regVal |= (ATH_ANT_DIV_COMB_LNA1 <<
6762 + AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S);
6763 + regVal |= (ATH_ANT_DIV_COMB_LNA2 <<
6764 + AR_PHY_9285_ANT_DIV_ALT_LNACONF_S);
6765 + regVal &= (~(AR_PHY_9285_FAST_DIV_BIAS));
6766 + regVal |= (0 << AR_PHY_9285_FAST_DIV_BIAS_S);
6767 + REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regVal);
6771 if (pModal->version >= 2) {
6772 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h
6773 +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
6774 @@ -78,13 +78,16 @@ static inline void ath9k_hw_antdiv_comb_
6775 ath9k_hw_ops(ah)->antdiv_comb_conf_set(ah, antconf);
6778 -static inline void ath9k_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
6780 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
6782 +static inline void ath9k_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
6784 - if (ath9k_hw_ops(ah)->antctrl_shared_chain_lnadiv)
6785 - ath9k_hw_ops(ah)->antctrl_shared_chain_lnadiv(ah, enable);
6786 + if (ath9k_hw_ops(ah)->set_bt_ant_diversity)
6787 + ath9k_hw_ops(ah)->set_bt_ant_diversity(ah, enable);
6792 /* Private hardware call ops */
6795 --- a/drivers/net/wireless/ath/ath9k/hw.c
6796 +++ b/drivers/net/wireless/ath/ath9k/hw.c
6797 @@ -450,7 +450,6 @@ static void ath9k_hw_init_config(struct
6798 ah->config.ack_6mb = 0x0;
6799 ah->config.cwm_ignore_extcca = 0;
6800 ah->config.pcie_clock_req = 0;
6801 - ah->config.pcie_waen = 0;
6802 ah->config.analog_shiftreg = 1;
6804 for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
6805 @@ -1069,7 +1068,7 @@ void ath9k_hw_init_global_settings(struc
6806 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
6813 } else if (IS_CHAN_QUARTER_RATE(chan)) {
6814 @@ -1079,7 +1078,7 @@ void ath9k_hw_init_global_settings(struc
6815 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
6823 @@ -1116,7 +1115,6 @@ void ath9k_hw_init_global_settings(struc
6824 ctstimeout += 48 - sifstime - ah->slottime;
6828 ath9k_hw_set_sifs_time(ah, sifstime);
6829 ath9k_hw_setslottime(ah, slottime);
6830 ath9k_hw_set_ack_timeout(ah, acktimeout);
6831 @@ -1496,16 +1494,18 @@ static bool ath9k_hw_channel_change(stru
6832 struct ath9k_channel *chan)
6834 struct ath_common *common = ath9k_hw_common(ah);
6835 + struct ath9k_hw_capabilities *pCap = &ah->caps;
6836 + bool band_switch = false, mode_diff = false;
6837 + u8 ini_reloaded = 0;
6840 - bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
6841 - bool band_switch, mode_diff;
6844 - band_switch = (chan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ)) !=
6845 - (ah->curchan->channelFlags & (CHANNEL_2GHZ |
6847 - mode_diff = (chan->chanmode != ah->curchan->chanmode);
6849 + if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) {
6850 + u32 cur = ah->curchan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ);
6851 + u32 new = chan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ);
6852 + band_switch = (cur != new);
6853 + mode_diff = (chan->chanmode != ah->curchan->chanmode);
6856 for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
6857 if (ath9k_hw_numtxpending(ah, qnum)) {
6858 @@ -1520,11 +1520,12 @@ static bool ath9k_hw_channel_change(stru
6862 - if (edma && (band_switch || mode_diff)) {
6863 + if (band_switch || mode_diff) {
6864 ath9k_hw_mark_phy_inactive(ah);
6867 - ath9k_hw_init_pll(ah, NULL);
6869 + ath9k_hw_init_pll(ah, chan);
6871 if (ath9k_hw_fast_chan_change(ah, chan, &ini_reloaded)) {
6872 ath_err(common, "Failed to do fast channel change\n");
6873 @@ -1541,22 +1542,21 @@ static bool ath9k_hw_channel_change(stru
6875 ath9k_hw_set_clockrate(ah);
6876 ath9k_hw_apply_txpower(ah, chan, false);
6877 - ath9k_hw_rfbus_done(ah);
6879 if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
6880 ath9k_hw_set_delta_slope(ah, chan);
6882 ath9k_hw_spur_mitigate_freq(ah, chan);
6884 - if (edma && (band_switch || mode_diff)) {
6885 - ah->ah_flags |= AH_FASTCC;
6886 - if (band_switch || ini_reloaded)
6887 - ah->eep_ops->set_board_values(ah, chan);
6888 + if (band_switch || ini_reloaded)
6889 + ah->eep_ops->set_board_values(ah, chan);
6891 - ath9k_hw_init_bb(ah, chan);
6892 + ath9k_hw_init_bb(ah, chan);
6893 + ath9k_hw_rfbus_done(ah);
6895 - if (band_switch || ini_reloaded)
6896 - ath9k_hw_init_cal(ah, chan);
6897 + if (band_switch || ini_reloaded) {
6898 + ah->ah_flags |= AH_FASTCC;
6899 + ath9k_hw_init_cal(ah, chan);
6900 ah->ah_flags &= ~AH_FASTCC;
6903 @@ -1778,16 +1778,11 @@ static void ath9k_hw_init_desc(struct at
6905 * Fast channel change:
6906 * (Change synthesizer based on channel freq without resetting chip)
6908 - * Don't do FCC when
6909 - * - Flag is not set
6910 - * - Chip is just coming out of full sleep
6911 - * - Channel to be set is same as current channel
6912 - * - Channel flags are different, (eg.,moving from 2GHz to 5GHz channel)
6914 static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan)
6916 struct ath_common *common = ath9k_hw_common(ah);
6917 + struct ath9k_hw_capabilities *pCap = &ah->caps;
6920 if (AR_SREV_9280(ah) && common->bus_ops->ath_bus_type == ATH_PCI)
6921 @@ -1806,9 +1801,21 @@ static int ath9k_hw_do_fastcc(struct ath
6922 (CHANNEL_HALF | CHANNEL_QUARTER))
6925 - if ((chan->channelFlags & CHANNEL_ALL) !=
6926 - (ah->curchan->channelFlags & CHANNEL_ALL))
6929 + * If cross-band fcc is not supoprted, bail out if
6930 + * either channelFlags or chanmode differ.
6932 + * chanmode will be different if the HT operating mode
6933 + * changes because of CSA.
6935 + if (!(pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH)) {
6936 + if ((chan->channelFlags & CHANNEL_ALL) !=
6937 + (ah->curchan->channelFlags & CHANNEL_ALL))
6940 + if (chan->chanmode != ah->curchan->chanmode)
6944 if (!ath9k_hw_check_alive(ah))
6946 @@ -2047,7 +2054,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
6948 ath9k_hw_apply_gpio_override(ah);
6950 - if (AR_SREV_9565(ah) && ah->shared_chain_lnadiv)
6951 + if (AR_SREV_9565(ah) && common->bt_ant_diversity)
6952 REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON);
6955 @@ -2550,34 +2557,28 @@ int ath9k_hw_fill_cap_info(struct ath_hw
6956 if (AR_SREV_9287_11_OR_LATER(ah) || AR_SREV_9271(ah))
6957 pCap->hw_caps |= ATH9K_HW_CAP_SGI_20;
6959 - if (AR_SREV_9285(ah))
6960 + if (AR_SREV_9285(ah)) {
6961 if (ah->eep_ops->get_eeprom(ah, EEP_MODAL_VER) >= 3) {
6963 ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
6964 - if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1))
6965 + if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1)) {
6966 pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB;
6967 + ath_info(common, "Enable LNA combining\n");
6972 if (AR_SREV_9300_20_OR_LATER(ah)) {
6973 if (ah->eep_ops->get_eeprom(ah, EEP_CHAIN_MASK_REDUCE))
6974 pCap->hw_caps |= ATH9K_HW_CAP_APM;
6978 if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9565(ah)) {
6979 ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
6981 - * enable the diversity-combining algorithm only when
6982 - * both enable_lna_div and enable_fast_div are set
6983 - * Table for Diversity
6984 - * ant_div_alt_lnaconf bit 0-1
6985 - * ant_div_main_lnaconf bit 2-3
6986 - * ant_div_alt_gaintb bit 4
6987 - * ant_div_main_gaintb bit 5
6988 - * enable_ant_div_lnadiv bit 6
6989 - * enable_ant_fast_div bit 7
6991 - if ((ant_div_ctl1 >> 0x6) == 0x3)
6992 + if ((ant_div_ctl1 >> 0x6) == 0x3) {
6993 pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB;
6994 + ath_info(common, "Enable LNA combining\n");
6998 if (ath9k_hw_dfs_tested(ah))
6999 @@ -2610,6 +2611,13 @@ int ath9k_hw_fill_cap_info(struct ath_hw
7000 ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
7001 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
7004 + * Fast channel change across bands is available
7005 + * only for AR9462 and AR9565.
7007 + if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
7008 + pCap->hw_caps |= ATH9K_HW_CAP_FCC_BAND_SWITCH;
7013 --- a/drivers/net/wireless/ath/ath9k/hw.h
7014 +++ b/drivers/net/wireless/ath/ath9k/hw.h
7015 @@ -247,6 +247,8 @@ enum ath9k_hw_caps {
7016 ATH9K_HW_CAP_DFS = BIT(16),
7017 ATH9K_HW_WOW_DEVICE_CAPABLE = BIT(17),
7018 ATH9K_HW_CAP_PAPRD = BIT(18),
7019 + ATH9K_HW_CAP_FCC_BAND_SWITCH = BIT(19),
7020 + ATH9K_HW_CAP_BT_ANT_DIV = BIT(20),
7024 @@ -309,8 +311,11 @@ struct ath9k_ops_config {
7025 u16 ani_poll_interval; /* ANI poll interval in ms */
7027 /* Platform specific config */
7030 + u32 ant_ctrl_comm2g_switch_enable;
7031 bool xatten_margin_cfg;
7032 + bool alt_mingainidx;
7036 @@ -716,11 +721,14 @@ struct ath_hw_ops {
7037 struct ath_hw_antcomb_conf *antconf);
7038 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
7039 struct ath_hw_antcomb_conf *antconf);
7040 - void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
7041 void (*spectral_scan_config)(struct ath_hw *ah,
7042 struct ath_spec_scan *param);
7043 void (*spectral_scan_trigger)(struct ath_hw *ah);
7044 void (*spectral_scan_wait)(struct ath_hw *ah);
7046 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
7047 + void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
7051 struct ath_nf_limits {
7052 @@ -765,7 +773,6 @@ struct ath_hw {
7055 bool need_an_top2_fixup;
7056 - bool shared_chain_lnadiv;
7060 --- a/drivers/net/wireless/ath/ath9k/pci.c
7061 +++ b/drivers/net/wireless/ath/ath9k/pci.c
7062 @@ -29,6 +29,60 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
7063 { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */
7064 { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */
7065 { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */
7067 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7069 + PCI_VENDOR_ID_AZWAVE,
7071 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7072 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7074 + PCI_VENDOR_ID_FOXCONN,
7076 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7077 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7079 + 0x11AD, /* LITEON */
7081 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7082 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7084 + 0x11AD, /* LITEON */
7086 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7087 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7089 + PCI_VENDOR_ID_QMI,
7091 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7092 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7096 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7097 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7099 + 0x10CF, /* Fujitsu */
7101 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7102 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7104 + 0x10CF, /* Fujitsu */
7106 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7107 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7109 + 0x10CF, /* Fujitsu */
7111 + .driver_data = ATH9K_PCI_D3_L1_WAR },
7113 + /* AR9285 card for Asus */
7114 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7116 + PCI_VENDOR_ID_AZWAVE,
7118 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7120 { PCI_VDEVICE(ATHEROS, 0x002B) }, /* PCI-E */
7121 { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */
7122 { PCI_VDEVICE(ATHEROS, 0x002D) }, /* PCI */
7123 @@ -40,29 +94,106 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
7125 PCI_VENDOR_ID_AZWAVE,
7127 - .driver_data = ATH9K_PCI_CUS198 },
7128 + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
7129 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7131 PCI_VENDOR_ID_AZWAVE,
7133 - .driver_data = ATH9K_PCI_CUS198 },
7134 + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
7135 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7137 PCI_VENDOR_ID_AZWAVE,
7139 - .driver_data = ATH9K_PCI_CUS198 },
7140 + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
7141 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7143 + PCI_VENDOR_ID_AZWAVE,
7145 + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
7148 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7150 PCI_VENDOR_ID_AZWAVE,
7152 - .driver_data = ATH9K_PCI_CUS230 },
7153 + .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV },
7154 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7156 PCI_VENDOR_ID_FOXCONN,
7158 - .driver_data = ATH9K_PCI_CUS230 },
7159 + .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV },
7162 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7164 + PCI_VENDOR_ID_ATHEROS,
7166 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7167 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7169 + PCI_VENDOR_ID_ATHEROS,
7171 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7172 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7176 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7177 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7181 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7182 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7184 + PCI_VENDOR_ID_SAMSUNG,
7186 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7187 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7189 + PCI_VENDOR_ID_SAMSUNG,
7191 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7192 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7194 + PCI_VENDOR_ID_SAMSUNG,
7196 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7197 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7199 + PCI_VENDOR_ID_SAMSUNG,
7201 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7202 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7204 + PCI_VENDOR_ID_SAMSUNG,
7206 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7207 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7209 + PCI_VENDOR_ID_SAMSUNG,
7211 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7212 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7214 + PCI_VENDOR_ID_SAMSUNG,
7216 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7217 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7219 + PCI_VENDOR_ID_SAMSUNG,
7221 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7222 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7224 + PCI_VENDOR_ID_LENOVO,
7226 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7227 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
7229 + PCI_VENDOR_ID_LENOVO,
7231 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
7233 { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */
7234 { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */
7235 @@ -229,6 +360,22 @@ static void ath_pci_aspm_init(struct ath
7240 + * 0x70c - Ack Frequency Register.
7242 + * Bits 27:29 - DEFAULT_L1_ENTRANCE_LATENCY.
7252 + if (AR_SREV_9462(ah))
7253 + pci_read_config_dword(pdev, 0x70c, &ah->config.aspm_l1_fix);
7255 pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm);
7256 if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) {
7257 ah->aspm_enabled = true;
7258 --- a/drivers/net/wireless/ath/ath9k/phy.h
7259 +++ b/drivers/net/wireless/ath/ath9k/phy.h
7261 #define AR_PHY_PLL_CONTROL 0x16180
7262 #define AR_PHY_PLL_MODE 0x16184
7264 +enum ath9k_ant_div_comb_lna_conf {
7265 + ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2,
7266 + ATH_ANT_DIV_COMB_LNA2,
7267 + ATH_ANT_DIV_COMB_LNA1,
7268 + ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2,
7272 --- a/drivers/net/wireless/iwlwifi/mvm/time-event.c
7273 +++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c
7275 #include "iwl-prph.h"
7277 /* A TimeUnit is 1024 microsecond */
7278 -#define TU_TO_JIFFIES(_tu) (usecs_to_jiffies((_tu) * 1024))
7279 #define MSEC_TO_TU(_msec) (_msec*1000/1024)
7282 @@ -191,8 +190,7 @@ static void iwl_mvm_te_handle_notif(stru
7283 iwl_mvm_te_clear_data(mvm, te_data);
7284 } else if (le32_to_cpu(notif->action) & TE_NOTIF_HOST_EVENT_START) {
7285 te_data->running = true;
7286 - te_data->end_jiffies = jiffies +
7287 - TU_TO_JIFFIES(te_data->duration);
7288 + te_data->end_jiffies = TU_TO_EXP_TIME(te_data->duration);
7290 if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
7291 set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
7292 @@ -329,8 +327,7 @@ void iwl_mvm_protect_session(struct iwl_
7293 lockdep_assert_held(&mvm->mutex);
7295 if (te_data->running &&
7296 - time_after(te_data->end_jiffies,
7297 - jiffies + TU_TO_JIFFIES(min_duration))) {
7298 + time_after(te_data->end_jiffies, TU_TO_EXP_TIME(min_duration))) {
7299 IWL_DEBUG_TE(mvm, "We have enough time in the current TE: %u\n",
7300 jiffies_to_msecs(te_data->end_jiffies - jiffies));
7302 --- a/include/linux/ieee80211.h
7303 +++ b/include/linux/ieee80211.h
7304 @@ -2279,4 +2279,8 @@ static inline bool ieee80211_check_tim(c
7305 return !!(tim->virtual_map[index] & mask);
7308 +/* convert time units */
7309 +#define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
7310 +#define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
7312 #endif /* LINUX_IEEE80211_H */
7313 --- a/net/mac80211/rate.c
7314 +++ b/net/mac80211/rate.c
7315 @@ -210,7 +210,7 @@ static bool rc_no_data_or_no_ack_use_min
7316 !ieee80211_is_data(fc);
7319 -static void rc_send_low_broadcast(s8 *idx, u32 basic_rates,
7320 +static void rc_send_low_basicrate(s8 *idx, u32 basic_rates,
7321 struct ieee80211_supported_band *sband)
7324 @@ -272,28 +272,37 @@ static void __rate_control_send_low(stru
7328 -bool rate_control_send_low(struct ieee80211_sta *sta,
7329 +bool rate_control_send_low(struct ieee80211_sta *pubsta,
7331 struct ieee80211_tx_rate_control *txrc)
7333 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
7334 struct ieee80211_supported_band *sband = txrc->sband;
7335 + struct sta_info *sta;
7337 + bool use_basicrate = false;
7339 - if (!sta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
7340 - __rate_control_send_low(txrc->hw, sband, sta, info);
7341 + if (!pubsta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
7342 + __rate_control_send_low(txrc->hw, sband, pubsta, info);
7344 - if (!sta && txrc->bss) {
7345 + if (!pubsta && txrc->bss) {
7346 mcast_rate = txrc->bss_conf->mcast_rate[sband->band];
7347 if (mcast_rate > 0) {
7348 info->control.rates[0].idx = mcast_rate - 1;
7351 + use_basicrate = true;
7352 + } else if (pubsta) {
7353 + sta = container_of(pubsta, struct sta_info, sta);
7354 + if (ieee80211_vif_is_mesh(&sta->sdata->vif))
7355 + use_basicrate = true;
7358 - rc_send_low_broadcast(&info->control.rates[0].idx,
7359 + if (use_basicrate)
7360 + rc_send_low_basicrate(&info->control.rates[0].idx,
7361 txrc->bss_conf->basic_rates,
7368 --- a/drivers/net/wireless/ath/ath9k/Kconfig
7369 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
7370 @@ -60,7 +60,7 @@ config ATH9K_AHB
7372 config ATH9K_DEBUGFS
7373 bool "Atheros ath9k debugging"
7375 + depends on ATH9K && DEBUG_FS
7376 select MAC80211_DEBUGFS
7379 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
7380 +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
7381 @@ -269,13 +269,12 @@ static void ar9002_hw_configpcipowersave
7382 if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE)
7383 val |= AR_WA_D3_L1_DISABLE;
7385 - if (((AR_SREV_9285(ah) ||
7386 - AR_SREV_9271(ah) ||
7387 - AR_SREV_9287(ah)) &&
7388 - (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) ||
7389 - (AR_SREV_9280(ah) &&
7390 - (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) {
7391 - val |= AR_WA_D3_L1_DISABLE;
7392 + if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || AR_SREV_9287(ah)) {
7393 + if (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)
7394 + val |= AR_WA_D3_L1_DISABLE;
7395 + } else if (AR_SREV_9280(ah)) {
7396 + if (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE)
7397 + val |= AR_WA_D3_L1_DISABLE;
7401 @@ -297,24 +296,18 @@ static void ar9002_hw_configpcipowersave
7403 if (ah->config.pcie_waen) {
7404 val = ah->config.pcie_waen;
7406 - val &= (~AR_WA_D3_L1_DISABLE);
7407 + val &= (~AR_WA_D3_L1_DISABLE);
7409 - if (AR_SREV_9285(ah) ||
7410 - AR_SREV_9271(ah) ||
7411 - AR_SREV_9287(ah)) {
7412 + if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || AR_SREV_9287(ah)) {
7413 val = AR9285_WA_DEFAULT;
7415 - val &= (~AR_WA_D3_L1_DISABLE);
7417 - else if (AR_SREV_9280(ah)) {
7418 + val &= (~AR_WA_D3_L1_DISABLE);
7419 + } else if (AR_SREV_9280(ah)) {
7421 * For AR9280 chips, bit 22 of 0x4004
7424 val = AR9280_WA_DEFAULT;
7426 - val &= (~AR_WA_D3_L1_DISABLE);
7427 + val &= (~AR_WA_D3_L1_DISABLE);
7429 val = AR_WA_DEFAULT;
7431 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
7432 +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
7433 @@ -153,7 +153,7 @@ static void ar9003_hw_init_mode_regs(str
7434 if (!ah->is_clk_25mhz)
7435 INIT_INI_ARRAY(&ah->iniAdditional,
7436 ar9340_1p0_radio_core_40M);
7437 - } else if (AR_SREV_9485_11(ah)) {
7438 + } else if (AR_SREV_9485_11_OR_LATER(ah)) {
7440 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
7441 ar9485_1_1_mac_core);
7442 @@ -424,7 +424,7 @@ static void ar9003_tx_gain_table_mode0(s
7443 else if (AR_SREV_9340(ah))
7444 INIT_INI_ARRAY(&ah->iniModesTxGain,
7445 ar9340Modes_lowest_ob_db_tx_gain_table_1p0);
7446 - else if (AR_SREV_9485_11(ah))
7447 + else if (AR_SREV_9485_11_OR_LATER(ah))
7448 INIT_INI_ARRAY(&ah->iniModesTxGain,
7449 ar9485_modes_lowest_ob_db_tx_gain_1_1);
7450 else if (AR_SREV_9550(ah))
7451 @@ -458,7 +458,7 @@ static void ar9003_tx_gain_table_mode1(s
7452 else if (AR_SREV_9340(ah))
7453 INIT_INI_ARRAY(&ah->iniModesTxGain,
7454 ar9340Modes_high_ob_db_tx_gain_table_1p0);
7455 - else if (AR_SREV_9485_11(ah))
7456 + else if (AR_SREV_9485_11_OR_LATER(ah))
7457 INIT_INI_ARRAY(&ah->iniModesTxGain,
7458 ar9485Modes_high_ob_db_tx_gain_1_1);
7459 else if (AR_SREV_9580(ah))
7460 @@ -492,7 +492,7 @@ static void ar9003_tx_gain_table_mode2(s
7461 else if (AR_SREV_9340(ah))
7462 INIT_INI_ARRAY(&ah->iniModesTxGain,
7463 ar9340Modes_low_ob_db_tx_gain_table_1p0);
7464 - else if (AR_SREV_9485_11(ah))
7465 + else if (AR_SREV_9485_11_OR_LATER(ah))
7466 INIT_INI_ARRAY(&ah->iniModesTxGain,
7467 ar9485Modes_low_ob_db_tx_gain_1_1);
7468 else if (AR_SREV_9580(ah))
7469 @@ -517,7 +517,7 @@ static void ar9003_tx_gain_table_mode3(s
7470 else if (AR_SREV_9340(ah))
7471 INIT_INI_ARRAY(&ah->iniModesTxGain,
7472 ar9340Modes_high_power_tx_gain_table_1p0);
7473 - else if (AR_SREV_9485_11(ah))
7474 + else if (AR_SREV_9485_11_OR_LATER(ah))
7475 INIT_INI_ARRAY(&ah->iniModesTxGain,
7476 ar9485Modes_high_power_tx_gain_1_1);
7477 else if (AR_SREV_9580(ah))
7478 @@ -552,7 +552,7 @@ static void ar9003_tx_gain_table_mode4(s
7480 static void ar9003_tx_gain_table_mode5(struct ath_hw *ah)
7482 - if (AR_SREV_9485_11(ah))
7483 + if (AR_SREV_9485_11_OR_LATER(ah))
7484 INIT_INI_ARRAY(&ah->iniModesTxGain,
7485 ar9485Modes_green_ob_db_tx_gain_1_1);
7486 else if (AR_SREV_9340(ah))
7487 @@ -571,7 +571,7 @@ static void ar9003_tx_gain_table_mode6(s
7488 if (AR_SREV_9340(ah))
7489 INIT_INI_ARRAY(&ah->iniModesTxGain,
7490 ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0);
7491 - else if (AR_SREV_9485_11(ah))
7492 + else if (AR_SREV_9485_11_OR_LATER(ah))
7493 INIT_INI_ARRAY(&ah->iniModesTxGain,
7494 ar9485Modes_green_spur_ob_db_tx_gain_1_1);
7495 else if (AR_SREV_9580(ah))
7496 @@ -611,7 +611,7 @@ static void ar9003_rx_gain_table_mode0(s
7497 else if (AR_SREV_9340(ah))
7498 INIT_INI_ARRAY(&ah->iniModesRxGain,
7499 ar9340Common_rx_gain_table_1p0);
7500 - else if (AR_SREV_9485_11(ah))
7501 + else if (AR_SREV_9485_11_OR_LATER(ah))
7502 INIT_INI_ARRAY(&ah->iniModesRxGain,
7503 ar9485_common_rx_gain_1_1);
7504 else if (AR_SREV_9550(ah)) {
7505 @@ -644,7 +644,7 @@ static void ar9003_rx_gain_table_mode1(s
7506 else if (AR_SREV_9340(ah))
7507 INIT_INI_ARRAY(&ah->iniModesRxGain,
7508 ar9340Common_wo_xlna_rx_gain_table_1p0);
7509 - else if (AR_SREV_9485_11(ah))
7510 + else if (AR_SREV_9485_11_OR_LATER(ah))
7511 INIT_INI_ARRAY(&ah->iniModesRxGain,
7512 ar9485Common_wo_xlna_rx_gain_1_1);
7513 else if (AR_SREV_9462_21(ah))
7514 @@ -745,16 +745,25 @@ static void ar9003_hw_init_mode_gain_reg
7515 static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
7519 + * Increase L1 Entry Latency. Some WB222 boards don't have
7520 + * this change in eeprom/OTP.
7523 + if (AR_SREV_9462(ah)) {
7524 + u32 val = ah->config.aspm_l1_fix;
7525 + if ((val & 0xff000000) == 0x17000000) {
7526 + val &= 0x00ffffff;
7527 + val |= 0x27000000;
7528 + REG_WRITE(ah, 0x570c, val);
7532 /* Nothing to do on restore for 11N */
7533 if (!power_off /* !restore */) {
7534 /* set bit 19 to allow forcing of pcie core into L1 state */
7535 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
7537 - /* Several PCIe massages to ensure proper behaviour */
7538 - if (ah->config.pcie_waen)
7539 - REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
7541 - REG_WRITE(ah, AR_WA, ah->WARegVal);
7542 + REG_WRITE(ah, AR_WA, ah->WARegVal);
7546 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
7547 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
7548 @@ -491,6 +491,7 @@ int ath9k_hw_process_rxdesc_edma(struct
7549 rxs->rs_rate = MS(rxsp->status1, AR_RxRate);
7550 rxs->rs_more = (rxsp->status2 & AR_RxMore) ? 1 : 0;
7552 + rxs->rs_firstaggr = (rxsp->status11 & AR_RxFirstAggr) ? 1 : 0;
7553 rxs->rs_isaggr = (rxsp->status11 & AR_RxAggr) ? 1 : 0;
7554 rxs->rs_moreaggr = (rxsp->status11 & AR_RxMoreAggr) ? 1 : 0;
7555 rxs->rs_antenna = (MS(rxsp->status4, AR_RxAntenna) & 0x7);
7556 --- a/drivers/net/wireless/ath/ath9k/common.c
7557 +++ b/drivers/net/wireless/ath/ath9k/common.c
7558 @@ -49,37 +49,40 @@ int ath9k_cmn_get_hw_crypto_keytype(stru
7560 EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype);
7562 -static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan,
7563 - enum nl80211_channel_type channel_type)
7564 +static u32 ath9k_get_extchanmode(struct cfg80211_chan_def *chandef)
7568 - switch (chan->band) {
7569 + switch (chandef->chan->band) {
7570 case IEEE80211_BAND_2GHZ:
7571 - switch (channel_type) {
7572 - case NL80211_CHAN_NO_HT:
7573 - case NL80211_CHAN_HT20:
7574 + switch (chandef->width) {
7575 + case NL80211_CHAN_WIDTH_20_NOHT:
7576 + case NL80211_CHAN_WIDTH_20:
7577 chanmode = CHANNEL_G_HT20;
7579 - case NL80211_CHAN_HT40PLUS:
7580 - chanmode = CHANNEL_G_HT40PLUS;
7581 + case NL80211_CHAN_WIDTH_40:
7582 + if (chandef->center_freq1 > chandef->chan->center_freq)
7583 + chanmode = CHANNEL_G_HT40PLUS;
7585 + chanmode = CHANNEL_G_HT40MINUS;
7587 - case NL80211_CHAN_HT40MINUS:
7588 - chanmode = CHANNEL_G_HT40MINUS;
7593 case IEEE80211_BAND_5GHZ:
7594 - switch (channel_type) {
7595 - case NL80211_CHAN_NO_HT:
7596 - case NL80211_CHAN_HT20:
7597 + switch (chandef->width) {
7598 + case NL80211_CHAN_WIDTH_20_NOHT:
7599 + case NL80211_CHAN_WIDTH_20:
7600 chanmode = CHANNEL_A_HT20;
7602 - case NL80211_CHAN_HT40PLUS:
7603 - chanmode = CHANNEL_A_HT40PLUS;
7604 + case NL80211_CHAN_WIDTH_40:
7605 + if (chandef->center_freq1 > chandef->chan->center_freq)
7606 + chanmode = CHANNEL_A_HT40PLUS;
7608 + chanmode = CHANNEL_A_HT40MINUS;
7610 - case NL80211_CHAN_HT40MINUS:
7611 - chanmode = CHANNEL_A_HT40MINUS;
7616 @@ -94,13 +97,12 @@ static u32 ath9k_get_extchanmode(struct
7617 * Update internal channel flags.
7619 void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
7620 - struct ieee80211_channel *chan,
7621 - enum nl80211_channel_type channel_type)
7622 + struct cfg80211_chan_def *chandef)
7624 - ichan->channel = chan->center_freq;
7625 - ichan->chan = chan;
7626 + ichan->channel = chandef->chan->center_freq;
7627 + ichan->chan = chandef->chan;
7629 - if (chan->band == IEEE80211_BAND_2GHZ) {
7630 + if (chandef->chan->band == IEEE80211_BAND_2GHZ) {
7631 ichan->chanmode = CHANNEL_G;
7632 ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM;
7634 @@ -108,8 +110,22 @@ void ath9k_cmn_update_ichannel(struct at
7635 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
7638 - if (channel_type != NL80211_CHAN_NO_HT)
7639 - ichan->chanmode = ath9k_get_extchanmode(chan, channel_type);
7640 + switch (chandef->width) {
7641 + case NL80211_CHAN_WIDTH_5:
7642 + ichan->channelFlags |= CHANNEL_QUARTER;
7644 + case NL80211_CHAN_WIDTH_10:
7645 + ichan->channelFlags |= CHANNEL_HALF;
7647 + case NL80211_CHAN_WIDTH_20_NOHT:
7649 + case NL80211_CHAN_WIDTH_20:
7650 + case NL80211_CHAN_WIDTH_40:
7651 + ichan->chanmode = ath9k_get_extchanmode(chandef);
7657 EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
7659 @@ -125,8 +141,7 @@ struct ath9k_channel *ath9k_cmn_get_curc
7661 chan_idx = curchan->hw_value;
7662 channel = &ah->channels[chan_idx];
7663 - ath9k_cmn_update_ichannel(channel, curchan,
7664 - cfg80211_get_chandef_type(&hw->conf.chandef));
7665 + ath9k_cmn_update_ichannel(channel, &hw->conf.chandef);
7669 --- a/drivers/net/wireless/ath/ath9k/common.h
7670 +++ b/drivers/net/wireless/ath/ath9k/common.h
7673 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
7674 void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
7675 - struct ieee80211_channel *chan,
7676 - enum nl80211_channel_type channel_type);
7677 + struct cfg80211_chan_def *chandef);
7678 struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
7680 int ath9k_cmn_count_streams(unsigned int chainmask, int max);
7681 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
7682 +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
7683 @@ -115,10 +115,10 @@ static int hif_usb_send_regout(struct hi
7685 cmd->hif_dev = hif_dev;
7687 - usb_fill_bulk_urb(urb, hif_dev->udev,
7688 - usb_sndbulkpipe(hif_dev->udev, USB_REG_OUT_PIPE),
7689 + usb_fill_int_urb(urb, hif_dev->udev,
7690 + usb_sndintpipe(hif_dev->udev, USB_REG_OUT_PIPE),
7691 skb->data, skb->len,
7692 - hif_usb_regout_cb, cmd);
7693 + hif_usb_regout_cb, cmd, 1);
7695 usb_anchor_urb(urb, &hif_dev->regout_submitted);
7696 ret = usb_submit_urb(urb, GFP_KERNEL);
7697 @@ -723,11 +723,11 @@ static void ath9k_hif_usb_reg_in_cb(stru
7701 - usb_fill_bulk_urb(urb, hif_dev->udev,
7702 - usb_rcvbulkpipe(hif_dev->udev,
7703 + usb_fill_int_urb(urb, hif_dev->udev,
7704 + usb_rcvintpipe(hif_dev->udev,
7706 nskb->data, MAX_REG_IN_BUF_SIZE,
7707 - ath9k_hif_usb_reg_in_cb, nskb);
7708 + ath9k_hif_usb_reg_in_cb, nskb, 1);
7712 @@ -909,11 +909,11 @@ static int ath9k_hif_usb_alloc_reg_in_ur
7716 - usb_fill_bulk_urb(urb, hif_dev->udev,
7717 - usb_rcvbulkpipe(hif_dev->udev,
7718 + usb_fill_int_urb(urb, hif_dev->udev,
7719 + usb_rcvintpipe(hif_dev->udev,
7721 skb->data, MAX_REG_IN_BUF_SIZE,
7722 - ath9k_hif_usb_reg_in_cb, skb);
7723 + ath9k_hif_usb_reg_in_cb, skb, 1);
7726 usb_anchor_urb(urb, &hif_dev->reg_in_submitted);
7727 @@ -1031,9 +1031,7 @@ static int ath9k_hif_usb_download_fw(str
7729 static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev)
7731 - struct usb_host_interface *alt = &hif_dev->interface->altsetting[0];
7732 - struct usb_endpoint_descriptor *endp;
7736 ret = ath9k_hif_usb_download_fw(hif_dev);
7738 @@ -1043,20 +1041,6 @@ static int ath9k_hif_usb_dev_init(struct
7742 - /* On downloading the firmware to the target, the USB descriptor of EP4
7743 - * is 'patched' to change the type of the endpoint to Bulk. This will
7744 - * bring down CPU usage during the scan period.
7746 - for (idx = 0; idx < alt->desc.bNumEndpoints; idx++) {
7747 - endp = &alt->endpoint[idx].desc;
7748 - if ((endp->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
7749 - == USB_ENDPOINT_XFER_INT) {
7750 - endp->bmAttributes &= ~USB_ENDPOINT_XFERTYPE_MASK;
7751 - endp->bmAttributes |= USB_ENDPOINT_XFER_BULK;
7752 - endp->bInterval = 0;
7757 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
7759 @@ -1268,7 +1252,7 @@ static void ath9k_hif_usb_reboot(struct
7763 - ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, USB_REG_OUT_PIPE),
7764 + ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE),
7767 dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n");
7768 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
7769 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
7770 @@ -1203,16 +1203,13 @@ static int ath9k_htc_config(struct ieee8
7772 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) {
7773 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
7774 - enum nl80211_channel_type channel_type =
7775 - cfg80211_get_chandef_type(&hw->conf.chandef);
7776 int pos = curchan->hw_value;
7778 ath_dbg(common, CONFIG, "Set channel: %d MHz\n",
7779 curchan->center_freq);
7781 ath9k_cmn_update_ichannel(&priv->ah->channels[pos],
7782 - hw->conf.chandef.chan,
7784 + &hw->conf.chandef);
7786 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
7787 ath_err(common, "Unable to set channel\n");
7788 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
7789 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
7790 @@ -448,6 +448,7 @@ static void ath9k_htc_tx_process(struct
7791 struct ieee80211_conf *cur_conf = &priv->hw->conf;
7794 + int hdrlen, padsize;
7796 slot = strip_drv_header(priv, skb);
7798 @@ -504,6 +505,15 @@ send_mac80211:
7800 ath9k_htc_tx_clear_slot(priv, slot);
7802 + /* Remove padding before handing frame back to mac80211 */
7803 + hdrlen = ieee80211_get_hdrlen_from_skb(skb);
7805 + padsize = hdrlen & 3;
7806 + if (padsize && skb->len > hdrlen + padsize) {
7807 + memmove(skb->data + padsize, skb->data, hdrlen);
7808 + skb_pull(skb, padsize);
7811 /* Send status to mac80211 */
7812 ieee80211_tx_status(priv->hw, skb);
7814 --- a/drivers/net/wireless/ath/ath9k/link.c
7815 +++ b/drivers/net/wireless/ath/ath9k/link.c
7816 @@ -41,7 +41,7 @@ void ath_tx_complete_poll_work(struct wo
7817 txq->axq_tx_inprogress = true;
7820 - ath_txq_unlock_complete(sc, txq);
7821 + ath_txq_unlock(sc, txq);
7825 --- a/drivers/net/wireless/ath/ath9k/mac.c
7826 +++ b/drivers/net/wireless/ath/ath9k/mac.c
7827 @@ -583,9 +583,9 @@ int ath9k_hw_rxprocdesc(struct ath_hw *a
7828 rs->rs_rate = MS(ads.ds_rxstatus0, AR_RxRate);
7829 rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
7831 + rs->rs_firstaggr = (ads.ds_rxstatus8 & AR_RxFirstAggr) ? 1 : 0;
7832 rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
7834 - (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
7835 + rs->rs_moreaggr = (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
7836 rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
7838 /* directly mapped flags for ieee80211_rx_status */
7839 --- a/drivers/net/wireless/ath/ath9k/mac.h
7840 +++ b/drivers/net/wireless/ath/ath9k/mac.h
7841 @@ -140,6 +140,7 @@ struct ath_rx_status {
7842 int8_t rs_rssi_ext1;
7843 int8_t rs_rssi_ext2;
7849 @@ -569,6 +570,7 @@ struct ar5416_desc {
7850 #define AR_RxAggr 0x00020000
7851 #define AR_PostDelimCRCErr 0x00040000
7852 #define AR_RxStatusRsvd71 0x3ff80000
7853 +#define AR_RxFirstAggr 0x20000000
7854 #define AR_DecryptBusyErr 0x40000000
7855 #define AR_KeyMiss 0x80000000
7857 --- a/drivers/net/wireless/ath/ath9k/rc.c
7858 +++ b/drivers/net/wireless/ath/ath9k/rc.c
7859 @@ -1324,8 +1324,8 @@ static void ath_rate_update(void *priv,
7860 ath_rc_init(sc, priv_sta);
7862 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG,
7863 - "Operating HT Bandwidth changed to: %d\n",
7864 - cfg80211_get_chandef_type(&sc->hw->conf.chandef));
7865 + "Operating Bandwidth changed to: %d\n",
7866 + sc->hw->conf.chandef.width);
7870 --- a/drivers/net/wireless/ath/ath9k/reg.h
7871 +++ b/drivers/net/wireless/ath/ath9k/reg.h
7874 #define AR_SREV_9485(_ah) \
7875 (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485))
7876 -#define AR_SREV_9485_11(_ah) \
7877 - (AR_SREV_9485(_ah) && \
7878 - ((_ah)->hw_version.macRev == AR_SREV_REVISION_9485_11))
7879 +#define AR_SREV_9485_11_OR_LATER(_ah) \
7880 + (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485) && \
7881 + ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9485_11))
7882 #define AR_SREV_9485_OR_LATER(_ah) \
7883 (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9485))
7885 --- a/net/mac80211/main.c
7886 +++ b/net/mac80211/main.c
7887 @@ -101,7 +101,7 @@ static u32 ieee80211_hw_conf_chan(struct
7888 struct ieee80211_sub_if_data *sdata;
7889 struct cfg80211_chan_def chandef = {};
7893 u32 offchannel_flag;
7895 offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;
7896 @@ -155,16 +155,16 @@ static u32 ieee80211_hw_conf_chan(struct
7897 changed |= IEEE80211_CONF_CHANGE_SMPS;
7900 - power = chandef.chan->max_power;
7903 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
7904 if (!rcu_access_pointer(sdata->vif.chanctx_conf))
7906 - power = min(power, sdata->vif.bss_conf.txpower);
7907 + power = max(power, sdata->vif.bss_conf.txpower);
7911 + power = min(power, chandef.chan->max_power);
7913 if (local->hw.conf.power_level != power) {
7914 changed |= IEEE80211_CONF_CHANGE_POWER;
7915 local->hw.conf.power_level = power;
7916 --- a/net/mac80211/status.c
7917 +++ b/net/mac80211/status.c
7918 @@ -180,6 +180,9 @@ static void ieee80211_frame_acked(struct
7919 struct ieee80211_local *local = sta->local;
7920 struct ieee80211_sub_if_data *sdata = sta->sdata;
7922 + if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
7923 + sta->last_rx = jiffies;
7925 if (ieee80211_is_data_qos(mgmt->frame_control)) {
7926 struct ieee80211_hdr *hdr = (void *) skb->data;
7927 u8 *qc = ieee80211_get_qos_ctl(hdr);