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 - ath_tx_fill_desc(sc, bf, txq, aggr_len);
1020 - ath_tx_txqaddbuf(sc, txq, &bf_q, false);
1021 - } while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH &&
1022 - status != ATH_AGGR_BAW_CLOSED);
1023 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
1027 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
1028 + aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
1029 + if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
1030 + (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
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 @@ -1542,16 +1704,9 @@ int ath_cabq_update(struct ath_softc *sc
1170 int qnum = sc->beacon.cabq->axq_qnum;
1172 ath9k_hw_get_txq_props(sc->sc_ah, qnum, &qi);
1174 - * Ensure the readytime % is within the bounds.
1176 - if (sc->config.cabqReadytime < ATH9K_READY_TIME_LO_BOUND)
1177 - sc->config.cabqReadytime = ATH9K_READY_TIME_LO_BOUND;
1178 - else if (sc->config.cabqReadytime > ATH9K_READY_TIME_HI_BOUND)
1179 - sc->config.cabqReadytime = ATH9K_READY_TIME_HI_BOUND;
1181 qi.tqi_readyTime = (cur_conf->beacon_interval *
1182 - sc->config.cabqReadytime) / 100;
1183 + ATH_CABQ_READY_TIME) / 100;
1184 ath_txq_update(sc, qnum, &qi);
1187 @@ -1571,7 +1726,7 @@ static void ath_drain_txq_list(struct at
1188 while (!list_empty(list)) {
1189 bf = list_first_entry(list, struct ath_buf, list);
1191 - if (bf->bf_stale) {
1192 + if (bf->bf_state.stale) {
1193 list_del(&bf->list);
1195 ath_tx_return_buffer(sc, bf);
1196 @@ -1665,25 +1820,27 @@ void ath_tx_cleanupq(struct ath_softc *s
1198 void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
1200 - struct ath_atx_ac *ac, *ac_tmp, *last_ac;
1201 + struct ath_atx_ac *ac, *last_ac;
1202 struct ath_atx_tid *tid, *last_tid;
1203 + bool sent = false;
1205 if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) ||
1206 - list_empty(&txq->axq_acq) ||
1207 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1208 + list_empty(&txq->axq_acq))
1213 - ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
1214 last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list);
1215 + while (!list_empty(&txq->axq_acq)) {
1216 + bool stop = false;
1218 - list_for_each_entry_safe(ac, ac_tmp, &txq->axq_acq, list) {
1219 + ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
1220 last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
1221 list_del(&ac->list);
1224 while (!list_empty(&ac->tid_q)) {
1226 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
1228 list_del(&tid->list);
1229 @@ -1692,17 +1849,17 @@ void ath_txq_schedule(struct ath_softc *
1233 - ath_tx_sched_aggr(sc, txq, tid);
1234 + if (ath_tx_sched_aggr(sc, txq, tid, &stop))
1238 * add tid to round-robin queue if more frames
1239 * are pending for the tid
1241 - if (!skb_queue_empty(&tid->buf_q))
1242 + if (ath_tid_has_buffered(tid))
1243 ath_tx_queue_tid(txq, tid);
1245 - if (tid == last_tid ||
1246 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1247 + if (stop || tid == last_tid)
1251 @@ -1711,9 +1868,17 @@ void ath_txq_schedule(struct ath_softc *
1252 list_add_tail(&ac->list, &txq->axq_acq);
1255 - if (ac == last_ac ||
1256 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1260 + if (ac == last_ac) {
1265 + last_ac = list_entry(txq->axq_acq.prev,
1266 + struct ath_atx_ac, list);
1271 @@ -1787,74 +1952,28 @@ static void ath_tx_txqaddbuf(struct ath_
1272 if (bf_is_ampdu_not_probing(bf))
1273 txq->axq_ampdu_depth++;
1275 - bf = bf->bf_lastbf->bf_next;
1276 + bf_last = bf->bf_lastbf;
1277 + bf = bf_last->bf_next;
1278 + bf_last->bf_next = NULL;
1283 -static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_txq *txq,
1284 - struct ath_atx_tid *tid, struct sk_buff *skb,
1285 - struct ath_tx_control *txctl)
1287 - struct ath_frame_info *fi = get_frame_info(skb);
1288 - struct list_head bf_head;
1289 - struct ath_buf *bf;
1292 - * Do not queue to h/w when any of the following conditions is true:
1293 - * - there are pending frames in software queue
1294 - * - the TID is currently paused for ADDBA/BAR request
1295 - * - seqno is not within block-ack window
1296 - * - h/w queue depth exceeds low water mark
1298 - if ((!skb_queue_empty(&tid->buf_q) || tid->paused ||
1299 - !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) ||
1300 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) &&
1301 - txq != sc->tx.uapsdq) {
1303 - * Add this frame to software queue for scheduling later
1304 - * for aggregation.
1306 - TX_STAT_INC(txq->axq_qnum, a_queued_sw);
1307 - __skb_queue_tail(&tid->buf_q, skb);
1308 - if (!txctl->an || !txctl->an->sleeping)
1309 - ath_tx_queue_tid(txq, tid);
1313 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1315 - ieee80211_free_txskb(sc->hw, skb);
1319 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
1320 - bf->bf_state.bf_type = BUF_AMPDU;
1321 - INIT_LIST_HEAD(&bf_head);
1322 - list_add(&bf->list, &bf_head);
1324 - /* Add sub-frame to BAW */
1325 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
1327 - /* Queue to h/w without aggregation */
1328 - TX_STAT_INC(txq->axq_qnum, a_queued_hw);
1329 - bf->bf_lastbf = bf;
1330 - ath_tx_fill_desc(sc, bf, txq, fi->framelen);
1331 - ath_tx_txqaddbuf(sc, txq, &bf_head, false);
1334 static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
1335 struct ath_atx_tid *tid, struct sk_buff *skb)
1337 + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1338 struct ath_frame_info *fi = get_frame_info(skb);
1339 struct list_head bf_head;
1340 - struct ath_buf *bf;
1343 + struct ath_buf *bf = fi->bf;
1345 INIT_LIST_HEAD(&bf_head);
1346 list_add_tail(&bf->list, &bf_head);
1347 bf->bf_state.bf_type = 0;
1348 + if (tid && (tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
1349 + bf->bf_state.bf_type = BUF_AMPDU;
1350 + ath_tx_addto_baw(sc, tid, bf);
1355 @@ -1911,8 +2030,7 @@ u8 ath_txchainmask_reduction(struct ath_
1356 struct ath_hw *ah = sc->sc_ah;
1357 struct ath9k_channel *curchan = ah->curchan;
1359 - if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) &&
1360 - (curchan->channelFlags & CHANNEL_5GHZ) &&
1361 + if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && IS_CHAN_5GHZ(curchan) &&
1362 (chainmask == 0x7) && (rate < 0x90))
1364 else if (AR_SREV_9462(ah) && ath9k_hw_btcoex_is_enabled(ah) &&
1365 @@ -1985,6 +2103,7 @@ static int ath_tx_prepare(struct ieee802
1366 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1367 struct ieee80211_sta *sta = txctl->sta;
1368 struct ieee80211_vif *vif = info->control.vif;
1369 + struct ath_vif *avp;
1370 struct ath_softc *sc = hw->priv;
1371 int frmlen = skb->len + FCS_LEN;
1372 int padpos, padsize;
1373 @@ -1992,6 +2111,10 @@ static int ath_tx_prepare(struct ieee802
1374 /* NOTE: sta can be NULL according to net/mac80211.h */
1376 txctl->an = (struct ath_node *)sta->drv_priv;
1377 + else if (vif && ieee80211_is_data(hdr->frame_control)) {
1378 + avp = (void *)vif->drv_priv;
1379 + txctl->an = &avp->mcast_node;
1382 if (info->control.hw_key)
1383 frmlen += info->control.hw_key->icv_len;
1384 @@ -2041,7 +2164,6 @@ int ath_tx_start(struct ieee80211_hw *hw
1385 struct ath_txq *txq = txctl->txq;
1386 struct ath_atx_tid *tid = NULL;
1392 @@ -2069,27 +2191,31 @@ int ath_tx_start(struct ieee80211_hw *hw
1393 ath_txq_unlock(sc, txq);
1394 txq = sc->tx.uapsdq;
1395 ath_txq_lock(sc, txq);
1398 - if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
1399 - tidno = ieee80211_get_qos_ctl(hdr)[0] &
1400 - IEEE80211_QOS_CTL_TID_MASK;
1401 - tid = ATH_AN_2_TID(txctl->an, tidno);
1402 + } else if (txctl->an &&
1403 + ieee80211_is_data_present(hdr->frame_control)) {
1404 + tid = ath_get_skb_tid(sc, txctl->an, skb);
1406 WARN_ON(tid->ac->txq != txctl->txq);
1409 - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
1410 + if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
1411 + tid->ac->clear_ps_filter = true;
1414 - * Try aggregation if it's a unicast data frame
1415 - * and the destination is HT capable.
1416 + * Add this frame to software queue for scheduling later
1417 + * for aggregation.
1419 - ath_tx_send_ampdu(sc, txq, tid, skb, txctl);
1420 + TX_STAT_INC(txq->axq_qnum, a_queued_sw);
1421 + __skb_queue_tail(&tid->buf_q, skb);
1422 + if (!txctl->an->sleeping)
1423 + ath_tx_queue_tid(txq, tid);
1425 + ath_txq_schedule(sc, txq);
1429 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
1431 + ath_txq_skb_done(sc, txq, skb);
1433 dev_kfree_skb_any(skb);
1435 @@ -2142,7 +2268,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
1438 ath_set_rates(vif, NULL, bf);
1439 - ath_buf_set_rate(sc, bf, &info, fi->framelen);
1440 + ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
1441 duration += info.rates[0].PktDuration;
1443 bf_tail->bf_next = bf;
1444 @@ -2189,7 +2315,7 @@ static void ath_tx_complete(struct ath_s
1445 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1446 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1447 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
1448 - int q, padpos, padsize;
1449 + int padpos, padsize;
1450 unsigned long flags;
1452 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
1453 @@ -2225,21 +2351,7 @@ static void ath_tx_complete(struct ath_s
1454 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1456 __skb_queue_tail(&txq->complete_q, skb);
1458 - q = skb_get_queue_mapping(skb);
1459 - if (txq == sc->tx.uapsdq)
1460 - txq = sc->tx.txq_map[q];
1462 - if (txq == sc->tx.txq_map[q]) {
1463 - if (WARN_ON(--txq->pending_frames < 0))
1464 - txq->pending_frames = 0;
1466 - if (txq->stopped &&
1467 - txq->pending_frames < sc->tx.txq_max_pending[q]) {
1468 - ieee80211_wake_queue(sc->hw, q);
1469 - txq->stopped = false;
1472 + ath_txq_skb_done(sc, txq, skb);
1475 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
1476 @@ -2360,8 +2472,7 @@ static void ath_tx_processq(struct ath_s
1478 if (list_empty(&txq->axq_q)) {
1479 txq->axq_link = NULL;
1480 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
1481 - ath_txq_schedule(sc, txq);
1482 + ath_txq_schedule(sc, txq);
1485 bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
1486 @@ -2375,7 +2486,7 @@ static void ath_tx_processq(struct ath_s
1487 * it with the STALE flag.
1490 - if (bf->bf_stale) {
1491 + if (bf->bf_state.stale) {
1493 if (list_is_last(&bf_held->list, &txq->axq_q))
1495 @@ -2399,7 +2510,7 @@ static void ath_tx_processq(struct ath_s
1496 * however leave the last descriptor back as the holding
1497 * descriptor for hw.
1499 - lastbf->bf_stale = true;
1500 + lastbf->bf_state.stale = true;
1501 INIT_LIST_HEAD(&bf_head);
1502 if (!list_is_singular(&lastbf->list))
1503 list_cut_position(&bf_head,
1504 @@ -2470,7 +2581,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1507 bf = list_first_entry(fifo_list, struct ath_buf, list);
1508 - if (bf->bf_stale) {
1509 + if (bf->bf_state.stale) {
1510 list_del(&bf->list);
1511 ath_tx_return_buffer(sc, bf);
1512 bf = list_first_entry(fifo_list, struct ath_buf, list);
1513 @@ -2492,7 +2603,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1514 ath_tx_txqaddbuf(sc, txq, &bf_q, true);
1517 - lastbf->bf_stale = true;
1518 + lastbf->bf_state.stale = true;
1520 list_cut_position(&bf_head, fifo_list,
1522 @@ -2583,6 +2694,7 @@ void ath_tx_node_init(struct ath_softc *
1523 tid->paused = false;
1524 tid->active = false;
1525 __skb_queue_head_init(&tid->buf_q);
1526 + __skb_queue_head_init(&tid->retry_q);
1527 acno = TID_TO_WME_AC(tidno);
1528 tid->ac = &an->ac[acno];
1530 @@ -2590,6 +2702,7 @@ void ath_tx_node_init(struct ath_softc *
1531 for (acno = 0, ac = &an->ac[acno];
1532 acno < IEEE80211_NUM_ACS; acno++, ac++) {
1534 + ac->clear_ps_filter = true;
1535 ac->txq = sc->tx.txq_map[acno];
1536 INIT_LIST_HEAD(&ac->tid_q);
1538 --- a/drivers/net/wireless/ath/ath9k/main.c
1539 +++ b/drivers/net/wireless/ath/ath9k/main.c
1540 @@ -173,8 +173,7 @@ static void ath_restart_work(struct ath_
1542 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
1544 - if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9485(sc->sc_ah) ||
1545 - AR_SREV_9550(sc->sc_ah))
1546 + if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah))
1547 ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
1548 msecs_to_jiffies(ATH_PLL_WORK_INTERVAL));
1550 @@ -209,6 +208,7 @@ static bool ath_complete_reset(struct at
1551 struct ath_hw *ah = sc->sc_ah;
1552 struct ath_common *common = ath9k_hw_common(ah);
1553 unsigned long flags;
1556 if (ath_startrecv(sc) != 0) {
1557 ath_err(common, "Unable to restart recv logic\n");
1558 @@ -236,10 +236,16 @@ static bool ath_complete_reset(struct at
1561 ath_restart_work(sc);
1564 - if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3)
1565 - ath_ant_comb_update(sc);
1566 + for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1567 + if (!ATH_TXQ_SETUP(sc, i))
1570 + spin_lock_bh(&sc->tx.txq[i].axq_lock);
1571 + ath_txq_schedule(sc, &sc->tx.txq[i]);
1572 + spin_unlock_bh(&sc->tx.txq[i].axq_lock);
1576 ieee80211_wake_queues(sc->hw);
1578 @@ -306,17 +312,91 @@ out:
1579 * by reseting the chip. To accomplish this we must first cleanup any pending
1580 * DMA, then restart stuff.
1582 -static int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
1583 - struct ath9k_channel *hchan)
1584 +static int ath_set_channel(struct ath_softc *sc, struct cfg80211_chan_def *chandef)
1586 + struct ath_hw *ah = sc->sc_ah;
1587 + struct ath_common *common = ath9k_hw_common(ah);
1588 + struct ieee80211_hw *hw = sc->hw;
1589 + struct ath9k_channel *hchan;
1590 + struct ieee80211_channel *chan = chandef->chan;
1591 + unsigned long flags;
1593 + int pos = chan->hw_value;
1597 if (test_bit(SC_OP_INVALID, &sc->sc_flags))
1600 + offchannel = !!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL);
1603 + old_pos = ah->curchan - &ah->channels[0];
1605 + ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
1606 + chan->center_freq, chandef->width);
1608 + /* update survey stats for the old channel before switching */
1609 + spin_lock_irqsave(&common->cc_lock, flags);
1610 + ath_update_survey_stats(sc);
1611 + spin_unlock_irqrestore(&common->cc_lock, flags);
1613 + ath9k_cmn_get_channel(hw, ah, chandef);
1616 + * If the operating channel changes, change the survey in-use flags
1618 + * Reset the survey data for the new channel, unless we're switching
1619 + * back to the operating channel from an off-channel operation.
1621 + if (!offchannel && sc->cur_survey != &sc->survey[pos]) {
1622 + if (sc->cur_survey)
1623 + sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
1625 + sc->cur_survey = &sc->survey[pos];
1627 + memset(sc->cur_survey, 0, sizeof(struct survey_info));
1628 + sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
1629 + } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
1630 + memset(&sc->survey[pos], 0, sizeof(struct survey_info));
1633 + hchan = &sc->sc_ah->channels[pos];
1634 r = ath_reset_internal(sc, hchan);
1640 + * The most recent snapshot of channel->noisefloor for the old
1641 + * channel is only available after the hardware reset. Copy it to
1642 + * the survey stats now.
1645 + ath_update_survey_nf(sc, old_pos);
1648 + * Enable radar pulse detection if on a DFS channel. Spectral
1649 + * scanning and radar detection can not be used concurrently.
1651 + if (hw->conf.radar_enabled) {
1654 + /* set HW specific DFS configuration */
1655 + ath9k_hw_set_radar_params(ah);
1656 + rxfilter = ath9k_hw_getrxfilter(ah);
1657 + rxfilter |= ATH9K_RX_FILTER_PHYRADAR |
1658 + ATH9K_RX_FILTER_PHYERR;
1659 + ath9k_hw_setrxfilter(ah, rxfilter);
1660 + ath_dbg(common, DFS, "DFS enabled at freq %d\n",
1661 + chan->center_freq);
1663 + /* perform spectral scan if requested. */
1664 + if (test_bit(SC_OP_SCANNING, &sc->sc_flags) &&
1665 + sc->spectral_mode == SPECTRAL_CHANSCAN)
1666 + ath9k_spectral_scan_trigger(hw);
1672 static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
1673 @@ -543,21 +623,10 @@ chip_reset:
1675 static int ath_reset(struct ath_softc *sc)
1680 ath9k_ps_wakeup(sc);
1682 r = ath_reset_internal(sc, NULL);
1684 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1685 - if (!ATH_TXQ_SETUP(sc, i))
1688 - spin_lock_bh(&sc->tx.txq[i].axq_lock);
1689 - ath_txq_schedule(sc, &sc->tx.txq[i]);
1690 - spin_unlock_bh(&sc->tx.txq[i].axq_lock);
1693 ath9k_ps_restore(sc);
1696 @@ -599,7 +668,7 @@ static int ath9k_start(struct ieee80211_
1697 ath9k_ps_wakeup(sc);
1698 mutex_lock(&sc->mutex);
1700 - init_channel = ath9k_cmn_get_curchannel(hw, ah);
1701 + init_channel = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
1703 /* Reset SERDES registers */
1704 ath9k_hw_configpcipowersave(ah, false);
1705 @@ -802,7 +871,7 @@ static void ath9k_stop(struct ieee80211_
1709 - ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
1710 + ah->curchan = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
1712 ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
1713 ath9k_hw_phy_disable(ah);
1714 @@ -821,7 +890,7 @@ static void ath9k_stop(struct ieee80211_
1715 ath_dbg(common, CONFIG, "Driver halt\n");
1718 -bool ath9k_uses_beacons(int type)
1719 +static bool ath9k_uses_beacons(int type)
1722 case NL80211_IFTYPE_AP:
1723 @@ -966,6 +1035,8 @@ static int ath9k_add_interface(struct ie
1724 struct ath_softc *sc = hw->priv;
1725 struct ath_hw *ah = sc->sc_ah;
1726 struct ath_common *common = ath9k_hw_common(ah);
1727 + struct ath_vif *avp = (void *)vif->drv_priv;
1728 + struct ath_node *an = &avp->mcast_node;
1730 mutex_lock(&sc->mutex);
1732 @@ -979,6 +1050,12 @@ static int ath9k_add_interface(struct ie
1733 if (ath9k_uses_beacons(vif->type))
1734 ath9k_beacon_assign_slot(sc, vif);
1739 + an->no_ps_filter = true;
1740 + ath_tx_node_init(sc, an);
1742 mutex_unlock(&sc->mutex);
1745 @@ -1016,6 +1093,7 @@ static void ath9k_remove_interface(struc
1747 struct ath_softc *sc = hw->priv;
1748 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1749 + struct ath_vif *avp = (void *)vif->drv_priv;
1751 ath_dbg(common, CONFIG, "Detach Interface\n");
1753 @@ -1030,6 +1108,8 @@ static void ath9k_remove_interface(struc
1754 ath9k_calculate_summary_state(hw, NULL);
1755 ath9k_ps_restore(sc);
1757 + ath_tx_node_cleanup(sc, &avp->mcast_node);
1759 mutex_unlock(&sc->mutex);
1762 @@ -1192,83 +1272,12 @@ static int ath9k_config(struct ieee80211
1765 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
1766 - struct ieee80211_channel *curchan = hw->conf.chandef.chan;
1767 - enum nl80211_channel_type channel_type =
1768 - cfg80211_get_chandef_type(&conf->chandef);
1769 - int pos = curchan->hw_value;
1771 - unsigned long flags;
1774 - old_pos = ah->curchan - &ah->channels[0];
1776 - ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n",
1777 - curchan->center_freq, channel_type);
1779 - /* update survey stats for the old channel before switching */
1780 - spin_lock_irqsave(&common->cc_lock, flags);
1781 - ath_update_survey_stats(sc);
1782 - spin_unlock_irqrestore(&common->cc_lock, flags);
1784 - ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
1785 - curchan, channel_type);
1788 - * If the operating channel changes, change the survey in-use flags
1790 - * Reset the survey data for the new channel, unless we're switching
1791 - * back to the operating channel from an off-channel operation.
1793 - if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) &&
1794 - sc->cur_survey != &sc->survey[pos]) {
1796 - if (sc->cur_survey)
1797 - sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
1799 - sc->cur_survey = &sc->survey[pos];
1801 - memset(sc->cur_survey, 0, sizeof(struct survey_info));
1802 - sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
1803 - } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
1804 - memset(&sc->survey[pos], 0, sizeof(struct survey_info));
1807 - if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
1808 + if (ath_set_channel(sc, &hw->conf.chandef) < 0) {
1809 ath_err(common, "Unable to set channel\n");
1810 mutex_unlock(&sc->mutex);
1811 ath9k_ps_restore(sc);
1816 - * The most recent snapshot of channel->noisefloor for the old
1817 - * channel is only available after the hardware reset. Copy it to
1818 - * the survey stats now.
1821 - ath_update_survey_nf(sc, old_pos);
1824 - * Enable radar pulse detection if on a DFS channel. Spectral
1825 - * scanning and radar detection can not be used concurrently.
1827 - if (hw->conf.radar_enabled) {
1830 - /* set HW specific DFS configuration */
1831 - ath9k_hw_set_radar_params(ah);
1832 - rxfilter = ath9k_hw_getrxfilter(ah);
1833 - rxfilter |= ATH9K_RX_FILTER_PHYRADAR |
1834 - ATH9K_RX_FILTER_PHYERR;
1835 - ath9k_hw_setrxfilter(ah, rxfilter);
1836 - ath_dbg(common, DFS, "DFS enabled at freq %d\n",
1837 - curchan->center_freq);
1839 - /* perform spectral scan if requested. */
1840 - if (test_bit(SC_OP_SCANNING, &sc->sc_flags) &&
1841 - sc->spectral_mode == SPECTRAL_CHANSCAN)
1842 - ath9k_spectral_scan_trigger(hw);
1846 if (changed & IEEE80211_CONF_CHANGE_POWER) {
1847 @@ -1374,9 +1383,6 @@ static void ath9k_sta_notify(struct ieee
1848 struct ath_softc *sc = hw->priv;
1849 struct ath_node *an = (struct ath_node *) sta->drv_priv;
1851 - if (!sta->ht_cap.ht_supported)
1855 case STA_NOTIFY_SLEEP:
1856 an->sleeping = true;
1857 @@ -2094,7 +2100,7 @@ static void ath9k_wow_add_pattern(struct
1859 struct ath_hw *ah = sc->sc_ah;
1860 struct ath9k_wow_pattern *wow_pattern = NULL;
1861 - struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
1862 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
1866 --- a/drivers/net/wireless/mwifiex/cfg80211.c
1867 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
1868 @@ -2298,8 +2298,7 @@ EXPORT_SYMBOL_GPL(mwifiex_del_virtual_in
1872 -mwifiex_is_pattern_supported(struct cfg80211_wowlan_trig_pkt_pattern *pat,
1874 +mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern *pat, s8 *byte_seq)
1876 int j, k, valid_byte_cnt = 0;
1877 bool dont_care_byte = false;
1878 --- a/drivers/net/wireless/ti/wlcore/main.c
1879 +++ b/drivers/net/wireless/ti/wlcore/main.c
1880 @@ -1315,7 +1315,7 @@ static struct sk_buff *wl12xx_alloc_dumm
1884 -wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
1885 +wl1271_validate_wowlan_pattern(struct cfg80211_pkt_pattern *p)
1887 int num_fields = 0, in_field = 0, fields_size = 0;
1888 int i, pattern_len = 0;
1889 @@ -1458,9 +1458,9 @@ void wl1271_rx_filter_flatten_fields(str
1890 * Allocates an RX filter returned through f
1891 * which needs to be freed using rx_filter_free()
1893 -static int wl1271_convert_wowlan_pattern_to_rx_filter(
1894 - struct cfg80211_wowlan_trig_pkt_pattern *p,
1895 - struct wl12xx_rx_filter **f)
1897 +wl1271_convert_wowlan_pattern_to_rx_filter(struct cfg80211_pkt_pattern *p,
1898 + struct wl12xx_rx_filter **f)
1901 struct wl12xx_rx_filter *filter;
1902 @@ -1562,7 +1562,7 @@ static int wl1271_configure_wowlan(struc
1904 /* Translate WoWLAN patterns into filters */
1905 for (i = 0; i < wow->n_patterns; i++) {
1906 - struct cfg80211_wowlan_trig_pkt_pattern *p;
1907 + struct cfg80211_pkt_pattern *p;
1908 struct wl12xx_rx_filter *filter = NULL;
1910 p = &wow->patterns[i];
1911 --- a/include/net/cfg80211.h
1912 +++ b/include/net/cfg80211.h
1913 @@ -639,6 +639,30 @@ struct cfg80211_ap_settings {
1917 + * struct cfg80211_csa_settings - channel switch settings
1919 + * Used for channel switch
1921 + * @chandef: defines the channel to use after the switch
1922 + * @beacon_csa: beacon data while performing the switch
1923 + * @counter_offset_beacon: offset for the counter within the beacon (tail)
1924 + * @counter_offset_presp: offset for the counter within the probe response
1925 + * @beacon_after: beacon data to be used on the new channel
1926 + * @radar_required: whether radar detection is required on the new channel
1927 + * @block_tx: whether transmissions should be blocked while changing
1928 + * @count: number of beacons until switch
1930 +struct cfg80211_csa_settings {
1931 + struct cfg80211_chan_def chandef;
1932 + struct cfg80211_beacon_data beacon_csa;
1933 + u16 counter_offset_beacon, counter_offset_presp;
1934 + struct cfg80211_beacon_data beacon_after;
1935 + bool radar_required;
1941 * enum station_parameters_apply_mask - station parameter values to apply
1942 * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
1943 * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
1944 @@ -1698,7 +1722,7 @@ struct cfg80211_pmksa {
1948 - * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
1949 + * struct cfg80211_pkt_pattern - packet pattern
1950 * @mask: bitmask where to match pattern and where to ignore bytes,
1951 * one bit per byte, in same format as nl80211
1952 * @pattern: bytes to match where bitmask is 1
1953 @@ -1708,7 +1732,7 @@ struct cfg80211_pmksa {
1954 * Internal note: @mask and @pattern are allocated in one chunk of
1955 * memory, free @mask only!
1957 -struct cfg80211_wowlan_trig_pkt_pattern {
1958 +struct cfg80211_pkt_pattern {
1962 @@ -1770,7 +1794,7 @@ struct cfg80211_wowlan {
1963 bool any, disconnect, magic_pkt, gtk_rekey_failure,
1964 eap_identity_req, four_way_handshake,
1966 - struct cfg80211_wowlan_trig_pkt_pattern *patterns;
1967 + struct cfg80211_pkt_pattern *patterns;
1968 struct cfg80211_wowlan_tcp *tcp;
1971 @@ -2071,6 +2095,8 @@ struct cfg80211_update_ft_ies_params {
1972 * driver can take the most appropriate actions.
1973 * @crit_proto_stop: Indicates critical protocol no longer needs increased link
1974 * reliability. This operation can not fail.
1976 + * @channel_switch: initiate channel-switch procedure (with CSA)
1978 struct cfg80211_ops {
1979 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
1980 @@ -2306,6 +2332,10 @@ struct cfg80211_ops {
1982 void (*crit_proto_stop)(struct wiphy *wiphy,
1983 struct wireless_dev *wdev);
1985 + int (*channel_switch)(struct wiphy *wiphy,
1986 + struct net_device *dev,
1987 + struct cfg80211_csa_settings *params);
1991 @@ -2371,6 +2401,8 @@ struct cfg80211_ops {
1992 * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
1993 * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
1994 * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
1995 + * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
1996 + * beaconing mode (AP, IBSS, Mesh, ...).
1999 WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0),
2000 @@ -2395,6 +2427,7 @@ enum wiphy_flags {
2001 WIPHY_FLAG_OFFCHAN_TX = BIT(20),
2002 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
2003 WIPHY_FLAG_SUPPORTS_5_10_MHZ = BIT(22),
2004 + WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
2008 --- a/include/uapi/linux/nl80211.h
2009 +++ b/include/uapi/linux/nl80211.h
2010 @@ -648,6 +648,16 @@
2011 * @NL80211_CMD_CRIT_PROTOCOL_STOP: Indicates the connection reliability can
2012 * return back to normal.
2014 + * @NL80211_CMD_CHANNEL_SWITCH: Perform a channel switch by announcing the
2015 + * the new channel information (Channel Switch Announcement - CSA)
2016 + * in the beacon for some time (as defined in the
2017 + * %NL80211_ATTR_CH_SWITCH_COUNT parameter) and then change to the
2018 + * new channel. Userspace provides the new channel information (using
2019 + * %NL80211_ATTR_WIPHY_FREQ and the attributes determining channel
2020 + * width). %NL80211_ATTR_CH_SWITCH_BLOCK_TX may be supplied to inform
2021 + * other station that transmission must be blocked until the channel
2022 + * switch is complete.
2024 * @NL80211_CMD_MAX: highest used command number
2025 * @__NL80211_CMD_AFTER_LAST: internal use
2027 @@ -810,6 +820,8 @@ enum nl80211_commands {
2028 NL80211_CMD_CRIT_PROTOCOL_START,
2029 NL80211_CMD_CRIT_PROTOCOL_STOP,
2031 + NL80211_CMD_CHANNEL_SWITCH,
2033 /* add new commands above here */
2035 /* used to define NL80211_CMD_MAX below */
2036 @@ -1436,6 +1448,18 @@ enum nl80211_commands {
2037 * allowed to be used with the first @NL80211_CMD_SET_STATION command to
2038 * update a TDLS peer STA entry.
2040 + * @NL80211_ATTR_CH_SWITCH_COUNT: u32 attribute specifying the number of TBTT's
2041 + * until the channel switch event.
2042 + * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission
2043 + * must be blocked on the current channel (before the channel switch
2045 + * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
2046 + * for the time while performing a channel switch.
2047 + * @NL80211_ATTR_CSA_C_OFF_BEACON: Offset of the channel switch counter
2048 + * field in the beacons tail (%NL80211_ATTR_BEACON_TAIL).
2049 + * @NL80211_ATTR_CSA_C_OFF_PRESP: Offset of the channel switch counter
2050 + * field in the probe response (%NL80211_ATTR_PROBE_RESP).
2052 * @NL80211_ATTR_MAX: highest attribute number currently defined
2053 * @__NL80211_ATTR_AFTER_LAST: internal use
2055 @@ -1736,6 +1760,12 @@ enum nl80211_attrs {
2057 NL80211_ATTR_PEER_AID,
2059 + NL80211_ATTR_CH_SWITCH_COUNT,
2060 + NL80211_ATTR_CH_SWITCH_BLOCK_TX,
2061 + NL80211_ATTR_CSA_IES,
2062 + NL80211_ATTR_CSA_C_OFF_BEACON,
2063 + NL80211_ATTR_CSA_C_OFF_PRESP,
2065 /* add attributes here, update the policy in nl80211.c */
2067 __NL80211_ATTR_AFTER_LAST,
2068 @@ -3060,11 +3090,11 @@ enum nl80211_tx_power_setting {
2072 - * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
2073 - * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
2074 - * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
2075 + * enum nl80211_packet_pattern_attr - packet pattern attribute
2076 + * @__NL80211_PKTPAT_INVALID: invalid number for nested attribute
2077 + * @NL80211_PKTPAT_PATTERN: the pattern, values where the mask has
2078 * a zero bit are ignored
2079 - * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
2080 + * @NL80211_PKTPAT_MASK: pattern mask, must be long enough to have
2081 * a bit for each byte in the pattern. The lowest-order bit corresponds
2082 * to the first byte of the pattern, but the bytes of the pattern are
2083 * in a little-endian-like format, i.e. the 9th byte of the pattern
2084 @@ -3075,23 +3105,23 @@ enum nl80211_tx_power_setting {
2085 * Note that the pattern matching is done as though frames were not
2086 * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
2087 * first (including SNAP header unpacking) and then matched.
2088 - * @NL80211_WOWLAN_PKTPAT_OFFSET: packet offset, pattern is matched after
2089 + * @NL80211_PKTPAT_OFFSET: packet offset, pattern is matched after
2090 * these fixed number of bytes of received packet
2091 - * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
2092 - * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
2093 + * @NUM_NL80211_PKTPAT: number of attributes
2094 + * @MAX_NL80211_PKTPAT: max attribute number
2096 -enum nl80211_wowlan_packet_pattern_attr {
2097 - __NL80211_WOWLAN_PKTPAT_INVALID,
2098 - NL80211_WOWLAN_PKTPAT_MASK,
2099 - NL80211_WOWLAN_PKTPAT_PATTERN,
2100 - NL80211_WOWLAN_PKTPAT_OFFSET,
2101 +enum nl80211_packet_pattern_attr {
2102 + __NL80211_PKTPAT_INVALID,
2103 + NL80211_PKTPAT_MASK,
2104 + NL80211_PKTPAT_PATTERN,
2105 + NL80211_PKTPAT_OFFSET,
2107 - NUM_NL80211_WOWLAN_PKTPAT,
2108 - MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
2109 + NUM_NL80211_PKTPAT,
2110 + MAX_NL80211_PKTPAT = NUM_NL80211_PKTPAT - 1,
2114 - * struct nl80211_wowlan_pattern_support - pattern support information
2115 + * struct nl80211_pattern_support - packet pattern support information
2116 * @max_patterns: maximum number of patterns supported
2117 * @min_pattern_len: minimum length of each pattern
2118 * @max_pattern_len: maximum length of each pattern
2119 @@ -3101,13 +3131,22 @@ enum nl80211_wowlan_packet_pattern_attr
2120 * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
2121 * capability information given by the kernel to userspace.
2123 -struct nl80211_wowlan_pattern_support {
2124 +struct nl80211_pattern_support {
2126 __u32 min_pattern_len;
2127 __u32 max_pattern_len;
2128 __u32 max_pkt_offset;
2129 } __attribute__((packed));
2131 +/* only for backward compatibility */
2132 +#define __NL80211_WOWLAN_PKTPAT_INVALID __NL80211_PKTPAT_INVALID
2133 +#define NL80211_WOWLAN_PKTPAT_MASK NL80211_PKTPAT_MASK
2134 +#define NL80211_WOWLAN_PKTPAT_PATTERN NL80211_PKTPAT_PATTERN
2135 +#define NL80211_WOWLAN_PKTPAT_OFFSET NL80211_PKTPAT_OFFSET
2136 +#define NUM_NL80211_WOWLAN_PKTPAT NUM_NL80211_PKTPAT
2137 +#define MAX_NL80211_WOWLAN_PKTPAT MAX_NL80211_PKTPAT
2138 +#define nl80211_wowlan_pattern_support nl80211_pattern_support
2141 * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
2142 * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
2143 @@ -3127,7 +3166,7 @@ struct nl80211_wowlan_pattern_support {
2144 * pattern matching is done after the packet is converted to the MSDU.
2146 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
2147 - * carrying a &struct nl80211_wowlan_pattern_support.
2148 + * carrying a &struct nl80211_pattern_support.
2150 * When reporting wakeup. it is a u32 attribute containing the 0-based
2151 * index of the pattern that caused the wakeup, in the patterns passed
2152 @@ -3284,7 +3323,7 @@ struct nl80211_wowlan_tcp_data_token_fea
2153 * @NL80211_WOWLAN_TCP_WAKE_PAYLOAD: wake packet payload, for advertising a
2154 * u32 attribute holding the maximum length
2155 * @NL80211_WOWLAN_TCP_WAKE_MASK: Wake packet payload mask, not used for
2156 - * feature advertising. The mask works like @NL80211_WOWLAN_PKTPAT_MASK
2157 + * feature advertising. The mask works like @NL80211_PKTPAT_MASK
2158 * but on the TCP payload only.
2159 * @NUM_NL80211_WOWLAN_TCP: number of TCP attributes
2160 * @MAX_NL80211_WOWLAN_TCP: highest attribute number
2161 --- a/net/mac80211/mesh_ps.c
2162 +++ b/net/mac80211/mesh_ps.c
2163 @@ -229,6 +229,10 @@ void ieee80211_mps_sta_status_update(str
2164 enum nl80211_mesh_power_mode pm;
2167 + /* For non-assoc STA, prevent buffering or frame transmission */
2168 + if (sta->sta_state < IEEE80211_STA_ASSOC)
2172 * use peer-specific power mode if peering is established and the
2173 * peer's power mode is known
2174 --- a/net/wireless/nl80211.c
2175 +++ b/net/wireless/nl80211.c
2176 @@ -349,6 +349,11 @@ static const struct nla_policy nl80211_p
2177 [NL80211_ATTR_IE_RIC] = { .type = NLA_BINARY,
2178 .len = IEEE80211_MAX_DATA_LEN },
2179 [NL80211_ATTR_PEER_AID] = { .type = NLA_U16 },
2180 + [NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 },
2181 + [NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG },
2182 + [NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED },
2183 + [NL80211_ATTR_CSA_C_OFF_BEACON] = { .type = NLA_U16 },
2184 + [NL80211_ATTR_CSA_C_OFF_PRESP] = { .type = NLA_U16 },
2187 /* policy for the key attributes */
2188 @@ -441,10 +446,12 @@ static int nl80211_prepare_wdev_dump(str
2191 *rdev = wiphy_to_dev((*wdev)->wiphy);
2192 - cb->args[0] = (*rdev)->wiphy_idx;
2193 + /* 0 is the first index - add 1 to parse only once */
2194 + cb->args[0] = (*rdev)->wiphy_idx + 1;
2195 cb->args[1] = (*wdev)->identifier;
2197 - struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]);
2198 + /* subtract the 1 again here */
2199 + struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
2200 struct wireless_dev *tmp;
2203 @@ -974,7 +981,7 @@ static int nl80211_send_wowlan(struct sk
2206 if (dev->wiphy.wowlan->n_patterns) {
2207 - struct nl80211_wowlan_pattern_support pat = {
2208 + struct nl80211_pattern_support pat = {
2209 .max_patterns = dev->wiphy.wowlan->n_patterns,
2210 .min_pattern_len = dev->wiphy.wowlan->pattern_min_len,
2211 .max_pattern_len = dev->wiphy.wowlan->pattern_max_len,
2212 @@ -1393,6 +1400,8 @@ static int nl80211_send_wiphy(struct cfg
2214 CMD(crit_proto_start, CRIT_PROTOCOL_START);
2215 CMD(crit_proto_stop, CRIT_PROTOCOL_STOP);
2216 + if (dev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)
2217 + CMD(channel_switch, CHANNEL_SWITCH);
2220 #ifdef CPTCFG_NL80211_TESTMODE
2221 @@ -1568,8 +1577,10 @@ static int nl80211_dump_wiphy(struct sk_
2224 state = kzalloc(sizeof(*state), GFP_KERNEL);
2230 state->filter_wiphy = -1;
2231 ret = nl80211_dump_wiphy_parse(skb, cb, state);
2233 @@ -2620,8 +2631,8 @@ static int nl80211_get_key(struct sk_buf
2235 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2236 NL80211_CMD_NEW_KEY);
2238 - return PTR_ERR(hdr);
2243 cookie.idx = key_idx;
2244 @@ -4770,9 +4781,9 @@ do { \
2245 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, 0, 1,
2246 mask, NL80211_MESHCONF_FORWARDING,
2248 - FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, 1, 255,
2249 + FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0,
2250 mask, NL80211_MESHCONF_RSSI_THRESHOLD,
2253 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16,
2254 mask, NL80211_MESHCONF_HT_OPMODE,
2256 @@ -5578,6 +5589,111 @@ static int nl80211_start_radar_detection
2260 +static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
2262 + struct cfg80211_registered_device *rdev = info->user_ptr[0];
2263 + struct net_device *dev = info->user_ptr[1];
2264 + struct wireless_dev *wdev = dev->ieee80211_ptr;
2265 + struct cfg80211_csa_settings params;
2266 + /* csa_attrs is defined static to avoid waste of stack size - this
2267 + * function is called under RTNL lock, so this should not be a problem.
2269 + static struct nlattr *csa_attrs[NL80211_ATTR_MAX+1];
2270 + u8 radar_detect_width = 0;
2273 + if (!rdev->ops->channel_switch ||
2274 + !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
2275 + return -EOPNOTSUPP;
2277 + /* may add IBSS support later */
2278 + if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
2279 + dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
2280 + return -EOPNOTSUPP;
2282 + memset(¶ms, 0, sizeof(params));
2284 + if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] ||
2285 + !info->attrs[NL80211_ATTR_CH_SWITCH_COUNT])
2288 + /* only important for AP, IBSS and mesh create IEs internally */
2289 + if (!info->attrs[NL80211_ATTR_CSA_IES])
2292 + /* useless if AP is not running */
2293 + if (!wdev->beacon_interval)
2296 + params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
2298 + err = nl80211_parse_beacon(info->attrs, ¶ms.beacon_after);
2302 + err = nla_parse_nested(csa_attrs, NL80211_ATTR_MAX,
2303 + info->attrs[NL80211_ATTR_CSA_IES],
2308 + err = nl80211_parse_beacon(csa_attrs, ¶ms.beacon_csa);
2312 + if (!csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON])
2315 + params.counter_offset_beacon =
2316 + nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]);
2317 + if (params.counter_offset_beacon >= params.beacon_csa.tail_len)
2320 + /* sanity check - counters should be the same */
2321 + if (params.beacon_csa.tail[params.counter_offset_beacon] !=
2325 + if (csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]) {
2326 + params.counter_offset_presp =
2327 + nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]);
2328 + if (params.counter_offset_presp >=
2329 + params.beacon_csa.probe_resp_len)
2332 + if (params.beacon_csa.probe_resp[params.counter_offset_presp] !=
2337 + err = nl80211_parse_chandef(rdev, info, ¶ms.chandef);
2341 + if (!cfg80211_reg_can_beacon(&rdev->wiphy, ¶ms.chandef))
2344 + err = cfg80211_chandef_dfs_required(wdev->wiphy, ¶ms.chandef);
2348 + radar_detect_width = BIT(params.chandef.width);
2349 + params.radar_required = true;
2352 + err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype,
2353 + params.chandef.chan,
2355 + radar_detect_width);
2359 + if (info->attrs[NL80211_ATTR_CH_SWITCH_BLOCK_TX])
2360 + params.block_tx = true;
2362 + return rdev_channel_switch(rdev, dev, ¶ms);
2365 static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
2367 struct cfg80211_registered_device *rdev,
2368 @@ -6507,6 +6623,9 @@ static int nl80211_testmode_dump(struct
2369 NL80211_CMD_TESTMODE);
2370 struct nlattr *tmdata;
2375 if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
2376 genlmsg_cancel(skb, hdr);
2378 @@ -6615,12 +6734,14 @@ EXPORT_SYMBOL(cfg80211_testmode_alloc_ev
2380 void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
2382 + struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
2383 void *hdr = ((void **)skb->cb)[1];
2384 struct nlattr *data = ((void **)skb->cb)[2];
2386 nla_nest_end(skb, data);
2387 genlmsg_end(skb, hdr);
2388 - genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
2389 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), skb, 0,
2390 + nl80211_testmode_mcgrp.id, gfp);
2392 EXPORT_SYMBOL(cfg80211_testmode_event);
2394 @@ -6949,9 +7070,8 @@ static int nl80211_remain_on_channel(str
2396 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2397 NL80211_CMD_REMAIN_ON_CHANNEL);
2399 - if (IS_ERR(hdr)) {
2400 - err = PTR_ERR(hdr);
2406 @@ -7249,9 +7369,8 @@ static int nl80211_tx_mgmt(struct sk_buf
2408 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2411 - if (IS_ERR(hdr)) {
2412 - err = PTR_ERR(hdr);
2418 @@ -7593,12 +7712,11 @@ static int nl80211_send_wowlan_patterns(
2421 pat_len = wowlan->patterns[i].pattern_len;
2422 - if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
2423 - DIV_ROUND_UP(pat_len, 8),
2424 + if (nla_put(msg, NL80211_PKTPAT_MASK, DIV_ROUND_UP(pat_len, 8),
2425 wowlan->patterns[i].mask) ||
2426 - nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
2427 - pat_len, wowlan->patterns[i].pattern) ||
2428 - nla_put_u32(msg, NL80211_WOWLAN_PKTPAT_OFFSET,
2429 + nla_put(msg, NL80211_PKTPAT_PATTERN, pat_len,
2430 + wowlan->patterns[i].pattern) ||
2431 + nla_put_u32(msg, NL80211_PKTPAT_OFFSET,
2432 wowlan->patterns[i].pkt_offset))
2434 nla_nest_end(msg, nl_pat);
2435 @@ -7939,7 +8057,7 @@ static int nl80211_set_wowlan(struct sk_
2438 int rem, pat_len, mask_len, pkt_offset;
2439 - struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
2440 + struct nlattr *pat_tb[NUM_NL80211_PKTPAT];
2442 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
2444 @@ -7958,26 +8076,25 @@ static int nl80211_set_wowlan(struct sk_
2446 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
2448 - nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
2449 - nla_data(pat), nla_len(pat), NULL);
2450 + nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
2451 + nla_len(pat), NULL);
2453 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
2454 - !pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
2455 + if (!pat_tb[NL80211_PKTPAT_MASK] ||
2456 + !pat_tb[NL80211_PKTPAT_PATTERN])
2458 - pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
2459 + pat_len = nla_len(pat_tb[NL80211_PKTPAT_PATTERN]);
2460 mask_len = DIV_ROUND_UP(pat_len, 8);
2461 - if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
2463 + if (nla_len(pat_tb[NL80211_PKTPAT_MASK]) != mask_len)
2465 if (pat_len > wowlan->pattern_max_len ||
2466 pat_len < wowlan->pattern_min_len)
2469 - if (!pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET])
2470 + if (!pat_tb[NL80211_PKTPAT_OFFSET])
2473 pkt_offset = nla_get_u32(
2474 - pat_tb[NL80211_WOWLAN_PKTPAT_OFFSET]);
2475 + pat_tb[NL80211_PKTPAT_OFFSET]);
2476 if (pkt_offset > wowlan->max_pkt_offset)
2478 new_triggers.patterns[i].pkt_offset = pkt_offset;
2479 @@ -7991,11 +8108,11 @@ static int nl80211_set_wowlan(struct sk_
2480 new_triggers.patterns[i].pattern =
2481 new_triggers.patterns[i].mask + mask_len;
2482 memcpy(new_triggers.patterns[i].mask,
2483 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
2484 + nla_data(pat_tb[NL80211_PKTPAT_MASK]),
2486 new_triggers.patterns[i].pattern_len = pat_len;
2487 memcpy(new_triggers.patterns[i].pattern,
2488 - nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
2489 + nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
2493 @@ -8130,9 +8247,8 @@ static int nl80211_probe_client(struct s
2495 hdr = nl80211hdr_put(msg, genl_info_snd_portid(info), info->snd_seq, 0,
2496 NL80211_CMD_PROBE_CLIENT);
2498 - if (IS_ERR(hdr)) {
2499 - err = PTR_ERR(hdr);
2505 @@ -9041,7 +9157,15 @@ static struct genl_ops nl80211_ops[] = {
2506 .flags = GENL_ADMIN_PERM,
2507 .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
2508 NL80211_FLAG_NEED_RTNL,
2512 + .cmd = NL80211_CMD_CHANNEL_SWITCH,
2513 + .doit = nl80211_channel_switch,
2514 + .policy = nl80211_policy,
2515 + .flags = GENL_ADMIN_PERM,
2516 + .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
2517 + NL80211_FLAG_NEED_RTNL,
2521 static struct genl_multicast_group nl80211_mlme_mcgrp = {
2522 @@ -10066,7 +10190,8 @@ void cfg80211_mgmt_tx_status(struct wire
2524 genlmsg_end(msg, hdr);
2526 - genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
2527 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
2528 + nl80211_mlme_mcgrp.id, gfp);
2532 --- a/net/wireless/reg.c
2533 +++ b/net/wireless/reg.c
2534 @@ -2247,10 +2247,13 @@ int reg_device_uevent(struct device *dev
2536 void wiphy_regulatory_register(struct wiphy *wiphy)
2538 + struct regulatory_request *lr;
2540 if (!reg_dev_ignore_cell_hint(wiphy))
2541 reg_num_devs_support_basehint++;
2543 - wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
2544 + lr = get_last_request();
2545 + wiphy_update_regulatory(wiphy, lr->initiator);
2548 void wiphy_regulatory_deregister(struct wiphy *wiphy)
2549 @@ -2279,7 +2282,9 @@ void wiphy_regulatory_deregister(struct
2550 static void reg_timeout_work(struct work_struct *work)
2552 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
2554 restore_regulatory_settings(true);
2558 int __init regulatory_init(void)
2559 --- a/net/wireless/sme.c
2560 +++ b/net/wireless/sme.c
2561 @@ -34,8 +34,10 @@ struct cfg80211_conn {
2562 CFG80211_CONN_SCAN_AGAIN,
2563 CFG80211_CONN_AUTHENTICATE_NEXT,
2564 CFG80211_CONN_AUTHENTICATING,
2565 + CFG80211_CONN_AUTH_FAILED,
2566 CFG80211_CONN_ASSOCIATE_NEXT,
2567 CFG80211_CONN_ASSOCIATING,
2568 + CFG80211_CONN_ASSOC_FAILED,
2569 CFG80211_CONN_DEAUTH,
2570 CFG80211_CONN_CONNECTED,
2572 @@ -164,6 +166,8 @@ static int cfg80211_conn_do_work(struct
2574 params->key, params->key_len,
2575 params->key_idx, NULL, 0);
2576 + case CFG80211_CONN_AUTH_FAILED:
2578 case CFG80211_CONN_ASSOCIATE_NEXT:
2579 BUG_ON(!rdev->ops->assoc);
2580 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
2581 @@ -188,10 +192,17 @@ static int cfg80211_conn_do_work(struct
2582 WLAN_REASON_DEAUTH_LEAVING,
2585 + case CFG80211_CONN_ASSOC_FAILED:
2586 + cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
2588 + WLAN_REASON_DEAUTH_LEAVING, false);
2590 case CFG80211_CONN_DEAUTH:
2591 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
2593 WLAN_REASON_DEAUTH_LEAVING, false);
2594 + /* free directly, disconnected event already sent */
2595 + cfg80211_sme_free(wdev);
2599 @@ -371,7 +382,7 @@ bool cfg80211_sme_rx_assoc_resp(struct w
2603 - wdev->conn->state = CFG80211_CONN_DEAUTH;
2604 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
2605 schedule_work(&rdev->conn_work);
2608 @@ -383,7 +394,13 @@ void cfg80211_sme_deauth(struct wireless
2610 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
2612 - cfg80211_sme_free(wdev);
2613 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
2618 + wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
2619 + schedule_work(&rdev->conn_work);
2622 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
2623 @@ -399,7 +416,13 @@ void cfg80211_sme_disassoc(struct wirele
2625 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
2627 - cfg80211_sme_disassoc(wdev);
2628 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
2633 + wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
2634 + schedule_work(&rdev->conn_work);
2637 static int cfg80211_sme_connect(struct wireless_dev *wdev,
2638 @@ -953,21 +976,19 @@ int cfg80211_disconnect(struct cfg80211_
2639 struct net_device *dev, u16 reason, bool wextev)
2641 struct wireless_dev *wdev = dev->ieee80211_ptr;
2645 ASSERT_WDEV_LOCK(wdev);
2647 kfree(wdev->connect_keys);
2648 wdev->connect_keys = NULL;
2652 err = cfg80211_sme_disconnect(wdev, reason);
2653 - } else if (!rdev->ops->disconnect) {
2654 + else if (!rdev->ops->disconnect)
2655 cfg80211_mlme_down(rdev, dev);
2658 + else if (wdev->current_bss)
2659 err = rdev_disconnect(rdev, dev, reason);
2664 --- a/net/mac80211/rc80211_minstrel.c
2665 +++ b/net/mac80211/rc80211_minstrel.c
2666 @@ -203,6 +203,15 @@ minstrel_update_stats(struct minstrel_pr
2667 memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate));
2668 mi->max_prob_rate = tmp_prob_rate;
2670 +#ifdef CPTCFG_MAC80211_DEBUGFS
2671 + /* use fixed index if set */
2672 + if (mp->fixed_rate_idx != -1) {
2673 + mi->max_tp_rate[0] = mp->fixed_rate_idx;
2674 + mi->max_tp_rate[1] = mp->fixed_rate_idx;
2675 + mi->max_prob_rate = mp->fixed_rate_idx;
2679 /* Reset update timer */
2680 mi->stats_update = jiffies;
2682 @@ -290,7 +299,7 @@ minstrel_get_rate(void *priv, struct iee
2683 struct minstrel_rate *msr, *mr;
2686 - bool prev_sample = mi->prev_sample;
2691 @@ -310,10 +319,16 @@ minstrel_get_rate(void *priv, struct iee
2692 /* increase sum packet counter */
2695 +#ifdef CPTCFG_MAC80211_DEBUGFS
2696 + if (mp->fixed_rate_idx != -1)
2700 delta = (mi->packet_count * sampling_ratio / 100) -
2701 (mi->sample_count + mi->sample_deferred / 2);
2703 /* delta < 0: no sampling required */
2704 + prev_sample = mi->prev_sample;
2705 mi->prev_sample = false;
2706 if (delta < 0 || (!mrr_capable && prev_sample))
2708 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
2709 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
2710 @@ -936,13 +936,8 @@ void rt2x00queue_index_inc(struct queue_
2711 spin_unlock_irqrestore(&queue->index_lock, irqflags);
2714 -void rt2x00queue_pause_queue(struct data_queue *queue)
2715 +void rt2x00queue_pause_queue_nocheck(struct data_queue *queue)
2717 - if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
2718 - !test_bit(QUEUE_STARTED, &queue->flags) ||
2719 - test_and_set_bit(QUEUE_PAUSED, &queue->flags))
2722 switch (queue->qid) {
2725 @@ -958,6 +953,15 @@ void rt2x00queue_pause_queue(struct data
2729 +void rt2x00queue_pause_queue(struct data_queue *queue)
2731 + if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
2732 + !test_bit(QUEUE_STARTED, &queue->flags) ||
2733 + test_and_set_bit(QUEUE_PAUSED, &queue->flags))
2736 + rt2x00queue_pause_queue_nocheck(queue);
2738 EXPORT_SYMBOL_GPL(rt2x00queue_pause_queue);
2740 void rt2x00queue_unpause_queue(struct data_queue *queue)
2741 @@ -1019,7 +1023,7 @@ void rt2x00queue_stop_queue(struct data_
2745 - rt2x00queue_pause_queue(queue);
2746 + rt2x00queue_pause_queue_nocheck(queue);
2748 queue->rt2x00dev->ops->lib->stop_queue(queue);
2750 --- a/net/mac80211/mlme.c
2751 +++ b/net/mac80211/mlme.c
2755 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
2756 +#define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2)
2757 #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
2758 #define IEEE80211_AUTH_MAX_TRIES 3
2759 #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
2760 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
2761 +#define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)
2762 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
2763 #define IEEE80211_ASSOC_MAX_TRIES 3
2765 @@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee
2766 struct ieee80211_channel *channel,
2767 const struct ieee80211_ht_operation *ht_oper,
2768 const struct ieee80211_vht_operation *vht_oper,
2769 - struct cfg80211_chan_def *chandef, bool verbose)
2770 + struct cfg80211_chan_def *chandef, bool tracking)
2772 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2773 struct cfg80211_chan_def vht_chandef;
2776 @@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee
2777 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
2779 /* check that channel matches the right operating channel */
2780 - if (channel->center_freq != ht_cfreq) {
2781 + if (!tracking && channel->center_freq != ht_cfreq) {
2783 * It's possible that some APs are confused here;
2784 * Netgear WNDR3700 sometimes reports 4 higher than
2785 @@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee
2786 * since we look at probe response/beacon data here
2791 - "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
2792 - channel->center_freq, ht_cfreq,
2793 - ht_oper->primary_chan, channel->band);
2795 + "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
2796 + channel->center_freq, ht_cfreq,
2797 + ht_oper->primary_chan, channel->band);
2798 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
2801 @@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee
2806 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2808 "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
2809 vht_oper->chan_width);
2810 @@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee
2813 if (!cfg80211_chandef_valid(&vht_chandef)) {
2815 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2817 "AP VHT information is invalid, disable VHT\n");
2818 ret = IEEE80211_STA_DISABLE_VHT;
2819 @@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee
2822 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
2824 + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2826 "AP VHT information doesn't match HT, disable VHT\n");
2827 ret = IEEE80211_STA_DISABLE_VHT;
2828 @@ -333,18 +335,27 @@ out:
2829 if (ret & IEEE80211_STA_DISABLE_VHT)
2830 vht_chandef = *chandef;
2833 + * Ignore the DISABLED flag when we're already connected and only
2834 + * tracking the APs beacon for bandwidth changes - otherwise we
2835 + * might get disconnected here if we connect to an AP, update our
2836 + * regulatory information based on the AP's country IE and the
2837 + * information we have is wrong/outdated and disables the channel
2838 + * that we're actually using for the connection to the AP.
2840 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
2841 - IEEE80211_CHAN_DISABLED)) {
2843 + IEEE80211_CHAN_DISABLED)) {
2844 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
2845 ret = IEEE80211_STA_DISABLE_HT |
2846 IEEE80211_STA_DISABLE_VHT;
2851 ret |= chandef_downgrade(chandef);
2854 - if (chandef->width != vht_chandef.width && verbose)
2855 + if (chandef->width != vht_chandef.width && !tracking)
2857 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
2859 @@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ie
2861 /* calculate new channel (type) based on HT/VHT operation IEs */
2862 flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper,
2863 - vht_oper, &chandef, false);
2864 + vht_oper, &chandef, true);
2867 * Downgrade the new channel if we associated with restricted
2868 @@ -1043,6 +1054,13 @@ ieee80211_sta_process_chanswitch(struct
2869 if (!ieee80211_operating_class_to_band(
2870 elems->ext_chansw_ie->new_operating_class,
2873 + * Some APs send invalid ECSA IEs in probe response
2874 + * frames, so check for these and ignore them.
2876 + if (beacon && elems->ext_chansw_ie->new_ch_num == 0 &&
2877 + elems->ext_chansw_ie->new_operating_class == 0)
2880 "cannot understand ECSA IE operating class %d, disconnecting\n",
2881 elems->ext_chansw_ie->new_operating_class);
2882 @@ -1110,6 +1128,15 @@ ieee80211_sta_process_chanswitch(struct
2884 cfg80211_chandef_create(&new_chandef, new_chan,
2885 NL80211_CHAN_NO_HT);
2886 + /* keep width for 5/10 MHz channels */
2887 + switch (sdata->vif.bss_conf.chandef.width) {
2888 + case NL80211_CHAN_WIDTH_5:
2889 + case NL80211_CHAN_WIDTH_10:
2890 + new_chandef.width = sdata->vif.bss_conf.chandef.width;
2898 @@ -3394,10 +3421,13 @@ static int ieee80211_probe_auth(struct i
2900 if (tx_flags == 0) {
2901 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
2902 - ifmgd->auth_data->timeout_started = true;
2903 + auth_data->timeout_started = true;
2904 run_again(sdata, auth_data->timeout);
2906 - auth_data->timeout_started = false;
2907 + auth_data->timeout =
2908 + round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
2909 + auth_data->timeout_started = true;
2910 + run_again(sdata, auth_data->timeout);
2914 @@ -3434,7 +3464,11 @@ static int ieee80211_do_assoc(struct iee
2915 assoc_data->timeout_started = true;
2916 run_again(sdata, assoc_data->timeout);
2918 - assoc_data->timeout_started = false;
2919 + assoc_data->timeout =
2920 + round_jiffies_up(jiffies +
2921 + IEEE80211_ASSOC_TIMEOUT_LONG);
2922 + assoc_data->timeout_started = true;
2923 + run_again(sdata, assoc_data->timeout);
2927 @@ -3829,7 +3863,7 @@ static int ieee80211_prep_channel(struct
2928 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
2934 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
2936 --- a/net/wireless/core.c
2937 +++ b/net/wireless/core.c
2938 @@ -772,6 +772,7 @@ void cfg80211_leave(struct cfg80211_regi
2939 cfg80211_leave_mesh(rdev, dev);
2941 case NL80211_IFTYPE_AP:
2942 + case NL80211_IFTYPE_P2P_GO:
2943 cfg80211_stop_ap(rdev, dev);
2946 --- a/drivers/net/wireless/rtlwifi/Kconfig
2947 +++ b/drivers/net/wireless/rtlwifi/Kconfig
2950 - tristate "Realtek wireless card support"
2951 +menuconfig RTL_CARDS
2952 + tristate "Realtek rtlwifi family of devices"
2954 - depends on MAC80211
2955 - select BACKPORT_FW_LOADER
2957 - This is common code for RTL8192CE/RTL8192CU/RTL8192SE/RTL8723AE
2958 - drivers. This module does nothing by itself - the various front-end
2959 - drivers need to be enabled to support any desired devices.
2961 - If you choose to build as a module, it'll be called rtlwifi.
2963 -config RTLWIFI_DEBUG
2964 - bool "Debugging output for rtlwifi driver family"
2965 - depends on RTLWIFI
2966 + depends on MAC80211 && (PCI || USB)
2969 - To use the module option that sets the dynamic-debugging level for,
2970 - the front-end driver, this parameter must be "Y". For memory-limited
2971 - systems, choose "N". If in doubt, choose "Y".
2972 + This option will enable support for the Realtek mac80211-based
2973 + wireless drivers. Drivers rtl8192ce, rtl8192cu, rtl8192se, rtl8192de,
2974 + rtl8723eu, and rtl8188eu share some common code.
2979 tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter"
2981 - depends on RTLWIFI && PCI
2983 select RTL8192C_COMMON
2985 + select RTLWIFI_PCI
2987 This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe
2988 wireless network adapters.
2989 @@ -33,7 +26,9 @@ config RTL8192CE
2991 tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter"
2993 - depends on RTLWIFI && PCI
2996 + select RTLWIFI_PCI
2998 This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe
2999 wireless network adapters.
3000 @@ -43,7 +38,9 @@ config RTL8192SE
3002 tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter"
3004 - depends on RTLWIFI && PCI
3007 + select RTLWIFI_PCI
3009 This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe
3010 wireless network adapters.
3011 @@ -53,7 +50,9 @@ config RTL8192DE
3013 tristate "Realtek RTL8723AE PCIe Wireless Network Adapter"
3015 - depends on RTLWIFI && PCI
3018 + select RTLWIFI_PCI
3020 This is the driver for Realtek RTL8723AE 802.11n PCIe
3021 wireless network adapters.
3022 @@ -63,7 +62,9 @@ config RTL8723AE
3024 tristate "Realtek RTL8188EE Wireless Network Adapter"
3026 - depends on RTLWIFI && PCI
3029 + select RTLWIFI_PCI
3031 This is the driver for Realtek RTL8188EE 802.11n PCIe
3032 wireless network adapters.
3033 @@ -73,7 +74,9 @@ config RTL8188EE
3035 tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter"
3037 - depends on RTLWIFI && USB
3040 + select RTLWIFI_USB
3041 select RTL8192C_COMMON
3043 This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB
3044 @@ -81,8 +84,32 @@ config RTL8192CU
3046 If you choose to build it as a module, it will be called rtl8192cu
3051 + select BACKPORT_FW_LOADER
3061 +config RTLWIFI_DEBUG
3062 + bool "Debugging output for rtlwifi driver family"
3063 + depends on RTLWIFI
3066 + To use the module option that sets the dynamic-debugging level for,
3067 + the front-end driver, this parameter must be "Y". For memory-limited
3068 + systems, choose "N". If in doubt, choose "Y".
3070 config RTL8192C_COMMON
3073 depends on RTL8192CE || RTL8192CU
3078 --- a/drivers/net/wireless/rtlwifi/Makefile
3079 +++ b/drivers/net/wireless/rtlwifi/Makefile
3080 @@ -12,13 +12,11 @@ rtlwifi-objs := \
3082 rtl8192c_common-objs += \
3084 -ifneq ($(CONFIG_PCI),)
3085 -rtlwifi-objs += pci.o
3087 +obj-$(CPTCFG_RTLWIFI_PCI) += rtl_pci.o
3088 +rtl_pci-objs := pci.o
3090 -ifneq ($(CONFIG_USB),)
3091 -rtlwifi-objs += usb.o
3093 +obj-$(CPTCFG_RTLWIFI_USB) += rtl_usb.o
3094 +rtl_usb-objs := usb.o
3096 obj-$(CPTCFG_RTL8192C_COMMON) += rtl8192c/
3097 obj-$(CPTCFG_RTL8192CE) += rtl8192ce/
3098 --- a/drivers/net/wireless/rtlwifi/ps.h
3099 +++ b/drivers/net/wireless/rtlwifi/ps.h
3100 @@ -49,5 +49,6 @@ void rtl_swlps_rf_awake(struct ieee80211
3101 void rtl_swlps_rf_sleep(struct ieee80211_hw *hw);
3102 void rtl_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
3103 void rtl_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len);
3104 +void rtl_lps_change_work_callback(struct work_struct *work);
3107 --- a/drivers/net/wireless/rtlwifi/base.c
3108 +++ b/drivers/net/wireless/rtlwifi/base.c
3109 @@ -173,6 +173,7 @@ u8 rtl_tid_to_ac(u8 tid)
3111 return tid_to_ac[tid];
3113 +EXPORT_SYMBOL_GPL(rtl_tid_to_ac);
3115 static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
3116 struct ieee80211_sta_ht_cap *ht_cap)
3117 @@ -407,6 +408,7 @@ void rtl_deinit_deferred_work(struct iee
3118 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
3119 cancel_delayed_work(&rtlpriv->works.fwevt_wq);
3121 +EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
3123 void rtl_init_rfkill(struct ieee80211_hw *hw)
3125 @@ -440,6 +442,7 @@ void rtl_deinit_rfkill(struct ieee80211_
3127 wiphy_rfkill_stop_polling(hw->wiphy);
3129 +EXPORT_SYMBOL_GPL(rtl_deinit_rfkill);
3131 int rtl_init_core(struct ieee80211_hw *hw)
3133 @@ -490,10 +493,12 @@ int rtl_init_core(struct ieee80211_hw *h
3137 +EXPORT_SYMBOL_GPL(rtl_init_core);
3139 void rtl_deinit_core(struct ieee80211_hw *hw)
3142 +EXPORT_SYMBOL_GPL(rtl_deinit_core);
3144 void rtl_init_rx_config(struct ieee80211_hw *hw)
3146 @@ -502,6 +507,7 @@ void rtl_init_rx_config(struct ieee80211
3148 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf));
3150 +EXPORT_SYMBOL_GPL(rtl_init_rx_config);
3152 /*********************************************************
3154 @@ -880,6 +886,7 @@ bool rtl_tx_mgmt_proc(struct ieee80211_h
3158 +EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc);
3160 void rtl_get_tcb_desc(struct ieee80211_hw *hw,
3161 struct ieee80211_tx_info *info,
3162 @@ -1053,6 +1060,7 @@ bool rtl_action_proc(struct ieee80211_hw
3166 +EXPORT_SYMBOL_GPL(rtl_action_proc);
3168 /*should call before software enc*/
3169 u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
3170 @@ -1126,6 +1134,7 @@ u8 rtl_is_special_data(struct ieee80211_
3174 +EXPORT_SYMBOL_GPL(rtl_is_special_data);
3176 /*********************************************************
3178 @@ -1301,6 +1310,7 @@ void rtl_beacon_statistic(struct ieee802
3180 rtlpriv->link_info.bcn_rx_inperiod++;
3182 +EXPORT_SYMBOL_GPL(rtl_beacon_statistic);
3184 void rtl_watchdog_wq_callback(void *data)
3186 @@ -1794,6 +1804,7 @@ void rtl_recognize_peer(struct ieee80211
3188 mac->vendor = vendor;
3190 +EXPORT_SYMBOL_GPL(rtl_recognize_peer);
3192 /*********************************************************
3194 @@ -1850,6 +1861,7 @@ struct attribute_group rtl_attribute_gro
3196 .attrs = rtl_sysfs_entries,
3198 +EXPORT_SYMBOL_GPL(rtl_attribute_group);
3200 MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
3201 MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
3202 @@ -1857,7 +1869,8 @@ MODULE_AUTHOR("Larry Finger <Larry.FInge
3203 MODULE_LICENSE("GPL");
3204 MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
3206 -struct rtl_global_var global_var = {};
3207 +struct rtl_global_var rtl_global_var = {};
3208 +EXPORT_SYMBOL_GPL(rtl_global_var);
3210 static int __init rtl_core_module_init(void)
3212 @@ -1865,8 +1878,8 @@ static int __init rtl_core_module_init(v
3213 pr_err("Unable to register rtl_rc, use default RC !!\n");
3215 /* init some global vars */
3216 - INIT_LIST_HEAD(&global_var.glb_priv_list);
3217 - spin_lock_init(&global_var.glb_list_lock);
3218 + INIT_LIST_HEAD(&rtl_global_var.glb_priv_list);
3219 + spin_lock_init(&rtl_global_var.glb_list_lock);
3223 --- a/drivers/net/wireless/rtlwifi/base.h
3224 +++ b/drivers/net/wireless/rtlwifi/base.h
3225 @@ -147,7 +147,7 @@ void rtl_recognize_peer(struct ieee80211
3226 u8 rtl_tid_to_ac(u8 tid);
3227 extern struct attribute_group rtl_attribute_group;
3228 void rtl_easy_concurrent_retrytimer_callback(unsigned long data);
3229 -extern struct rtl_global_var global_var;
3230 +extern struct rtl_global_var rtl_global_var;
3231 int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
3232 bool isht, u8 desc_rate, bool first_ampdu);
3233 bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
3234 --- a/drivers/net/wireless/rtlwifi/core.c
3235 +++ b/drivers/net/wireless/rtlwifi/core.c
3236 @@ -1330,3 +1330,4 @@ const struct ieee80211_ops rtl_ops = {
3237 .rfkill_poll = rtl_op_rfkill_poll,
3238 .flush = rtl_op_flush,
3240 +EXPORT_SYMBOL_GPL(rtl_ops);
3241 --- a/drivers/net/wireless/rtlwifi/debug.c
3242 +++ b/drivers/net/wireless/rtlwifi/debug.c
3243 @@ -51,3 +51,4 @@ void rtl_dbgp_flag_init(struct ieee80211
3245 /*Init Debug flag enable condition */
3247 +EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
3248 --- a/drivers/net/wireless/rtlwifi/efuse.c
3249 +++ b/drivers/net/wireless/rtlwifi/efuse.c
3250 @@ -229,6 +229,7 @@ void read_efuse_byte(struct ieee80211_hw
3252 *pbuf = (u8) (value32 & 0xff);
3254 +EXPORT_SYMBOL_GPL(read_efuse_byte);
3256 void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
3258 --- a/drivers/net/wireless/rtlwifi/pci.c
3259 +++ b/drivers/net/wireless/rtlwifi/pci.c
3262 #include <linux/export.h>
3263 #include <linux/kmemleak.h>
3264 +#include <linux/module.h>
3266 +MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
3267 +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
3268 +MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
3269 +MODULE_LICENSE("GPL");
3270 +MODULE_DESCRIPTION("PCI basic driver for rtlwifi");
3272 static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = {
3273 PCI_VENDOR_ID_INTEL,
3274 @@ -1008,19 +1015,6 @@ static void _rtl_pci_prepare_bcn_tasklet
3278 -static void rtl_lps_change_work_callback(struct work_struct *work)
3280 - struct rtl_works *rtlworks =
3281 - container_of(work, struct rtl_works, lps_change_work);
3282 - struct ieee80211_hw *hw = rtlworks->hw;
3283 - struct rtl_priv *rtlpriv = rtl_priv(hw);
3285 - if (rtlpriv->enter_ps)
3286 - rtl_lps_enter(hw);
3288 - rtl_lps_leave(hw);
3291 static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
3293 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
3294 @@ -1899,7 +1893,7 @@ int rtl_pci_probe(struct pci_dev *pdev,
3295 rtlpriv->rtlhal.interface = INTF_PCI;
3296 rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data);
3297 rtlpriv->intf_ops = &rtl_pci_ops;
3298 - rtlpriv->glb_var = &global_var;
3299 + rtlpriv->glb_var = &rtl_global_var;
3302 *init dbgp flags before all
3303 --- a/drivers/net/wireless/rtlwifi/ps.c
3304 +++ b/drivers/net/wireless/rtlwifi/ps.c
3305 @@ -269,6 +269,7 @@ void rtl_ips_nic_on(struct ieee80211_hw
3307 spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags);
3309 +EXPORT_SYMBOL_GPL(rtl_ips_nic_on);
3313 @@ -518,6 +519,7 @@ void rtl_swlps_beacon(struct ieee80211_h
3314 "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed);
3317 +EXPORT_SYMBOL_GPL(rtl_swlps_beacon);
3319 void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
3321 @@ -611,6 +613,19 @@ void rtl_swlps_rf_sleep(struct ieee80211
3322 MSECS(sleep_intv * mac->vif->bss_conf.beacon_int - 40));
3325 +void rtl_lps_change_work_callback(struct work_struct *work)
3327 + struct rtl_works *rtlworks =
3328 + container_of(work, struct rtl_works, lps_change_work);
3329 + struct ieee80211_hw *hw = rtlworks->hw;
3330 + struct rtl_priv *rtlpriv = rtl_priv(hw);
3332 + if (rtlpriv->enter_ps)
3333 + rtl_lps_enter(hw);
3335 + rtl_lps_leave(hw);
3337 +EXPORT_SYMBOL_GPL(rtl_lps_change_work_callback);
3339 void rtl_swlps_wq_callback(void *data)
3341 @@ -922,3 +937,4 @@ void rtl_p2p_info(struct ieee80211_hw *h
3343 rtl_p2p_noa_ie(hw, data, len - FCS_LEN);
3345 +EXPORT_SYMBOL_GPL(rtl_p2p_info);
3346 --- a/drivers/net/wireless/rtlwifi/usb.c
3347 +++ b/drivers/net/wireless/rtlwifi/usb.c
3350 #include "rtl8192c/fw_common.h"
3351 #include <linux/export.h>
3352 +#include <linux/module.h>
3354 +MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
3355 +MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
3356 +MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
3357 +MODULE_LICENSE("GPL");
3358 +MODULE_DESCRIPTION("USB basic driver for rtlwifi");
3360 #define REALTEK_USB_VENQT_READ 0xC0
3361 #define REALTEK_USB_VENQT_WRITE 0x40
3362 @@ -1070,6 +1077,8 @@ int rtl_usb_probe(struct usb_interface *
3363 spin_lock_init(&rtlpriv->locks.usb_lock);
3364 INIT_WORK(&rtlpriv->works.fill_h2c_cmd,
3365 rtl_fill_h2c_cmd_work_callback);
3366 + INIT_WORK(&rtlpriv->works.lps_change_work,
3367 + rtl_lps_change_work_callback);
3369 rtlpriv->usb_data_index = 0;
3370 init_completion(&rtlpriv->firmware_loading_complete);
3371 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
3372 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3373 @@ -64,7 +64,6 @@ struct ath_node;
3380 /*************************/
3381 @@ -72,17 +71,12 @@ struct ath_config {
3382 /*************************/
3384 #define ATH_TXBUF_RESET(_bf) do { \
3385 - (_bf)->bf_stale = false; \
3386 (_bf)->bf_lastbf = NULL; \
3387 (_bf)->bf_next = NULL; \
3388 memset(&((_bf)->bf_state), 0, \
3389 sizeof(struct ath_buf_state)); \
3392 -#define ATH_RXBUF_RESET(_bf) do { \
3393 - (_bf)->bf_stale = false; \
3397 * enum buffer_type - Buffer type flags
3399 @@ -137,7 +131,8 @@ int ath_descdma_setup(struct ath_softc *
3400 #define ATH_AGGR_ENCRYPTDELIM 10
3401 /* minimum h/w qdepth to be sustained to maximize aggregation */
3402 #define ATH_AGGR_MIN_QDEPTH 2
3403 -#define ATH_AMPDU_SUBFRAME_DEFAULT 32
3404 +/* minimum h/w qdepth for non-aggregated traffic */
3405 +#define ATH_NON_AGGR_MIN_QDEPTH 8
3407 #define IEEE80211_SEQ_SEQ_SHIFT 4
3408 #define IEEE80211_SEQ_MAX 4096
3409 @@ -174,12 +169,6 @@ int ath_descdma_setup(struct ath_softc *
3411 #define ATH_TX_COMPLETE_POLL_INT 1000
3413 -enum ATH_AGGR_STATUS {
3415 - ATH_AGGR_BAW_CLOSED,
3419 #define ATH_TXFIFO_DEPTH 8
3421 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */
3422 @@ -201,10 +190,10 @@ struct ath_txq {
3425 struct ath_txq *txq;
3427 struct list_head list;
3428 struct list_head tid_q;
3429 bool clear_ps_filter;
3433 struct ath_frame_info {
3434 @@ -212,14 +201,24 @@ struct ath_frame_info {
3436 enum ath9k_key_type keytype;
3441 + u8 baw_tracked : 1;
3445 + struct list_head list;
3446 + struct sk_buff *bf_mpdu;
3448 + dma_addr_t bf_daddr;
3449 + dma_addr_t bf_buf_addr;
3452 struct ath_buf_state {
3458 unsigned long bfs_paprd_timestamp;
3460 @@ -233,7 +232,6 @@ struct ath_buf {
3461 void *bf_desc; /* virtual addr of desc */
3462 dma_addr_t bf_daddr; /* physical addr of desc */
3463 dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */
3465 struct ieee80211_tx_rate rates[4];
3466 struct ath_buf_state bf_state;
3468 @@ -241,16 +239,18 @@ struct ath_buf {
3469 struct ath_atx_tid {
3470 struct list_head list;
3471 struct sk_buff_head buf_q;
3472 + struct sk_buff_head retry_q;
3473 struct ath_node *an;
3474 struct ath_atx_ac *ac;
3475 unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
3482 int baw_head; /* first un-acked tx buffer */
3483 int baw_tail; /* next unused tx buffer slot */
3489 @@ -262,12 +262,13 @@ struct ath_node {
3490 struct ieee80211_vif *vif; /* interface with which we're associated */
3491 struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
3492 struct ath_atx_ac ac[IEEE80211_NUM_ACS];
3500 + bool no_ps_filter;
3502 #if defined(CPTCFG_MAC80211_DEBUGFS) && defined(CPTCFG_ATH9K_DEBUGFS)
3503 struct dentry *node_stat;
3504 @@ -317,6 +318,7 @@ struct ath_rx {
3505 struct ath_descdma rxdma;
3506 struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX];
3508 + struct ath_rxbuf *buf_hold;
3509 struct sk_buff *frag;
3512 @@ -367,6 +369,7 @@ void ath9k_release_buffered_frames(struc
3516 + struct ath_node mcast_node;
3518 bool primary_sta_vif;
3519 __le64 tsf_adjust; /* TSF adjustment for staggered beacons */
3520 @@ -585,19 +588,14 @@ static inline void ath_fill_led_pin(stru
3521 #define ATH_ANT_DIV_COMB_MAX_COUNT 100
3522 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30
3523 #define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20
3524 +#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50
3525 +#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50
3527 #define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1
3528 #define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4
3529 #define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2
3530 #define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2
3532 -enum ath9k_ant_div_comb_lna_conf {
3533 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2,
3534 - ATH_ANT_DIV_COMB_LNA2,
3535 - ATH_ANT_DIV_COMB_LNA1,
3536 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2,
3539 struct ath_ant_comb {
3541 u16 total_pkt_count;
3542 @@ -614,27 +612,36 @@ struct ath_ant_comb {
3551 + enum ath9k_ant_div_comb_lna_conf main_conf;
3552 enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf;
3553 enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf;
3556 unsigned long scan_start_time;
3559 + * Card-specific config values.
3561 + int low_rssi_thresh;
3562 + int fast_div_bias;
3565 void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
3566 -void ath_ant_comb_update(struct ath_softc *sc);
3568 /********************/
3569 /* Main driver core */
3570 /********************/
3572 -#define ATH9K_PCI_CUS198 0x0001
3573 -#define ATH9K_PCI_CUS230 0x0002
3574 -#define ATH9K_PCI_CUS217 0x0004
3575 -#define ATH9K_PCI_WOW 0x0008
3576 +#define ATH9K_PCI_CUS198 0x0001
3577 +#define ATH9K_PCI_CUS230 0x0002
3578 +#define ATH9K_PCI_CUS217 0x0004
3579 +#define ATH9K_PCI_WOW 0x0008
3580 +#define ATH9K_PCI_BT_ANT_DIV 0x0010
3581 +#define ATH9K_PCI_D3_L1_WAR 0x0020
3584 * Default cache line size, in bytes.
3585 @@ -926,7 +933,6 @@ void ath9k_deinit_device(struct ath_soft
3586 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw);
3587 void ath9k_reload_chainmask_settings(struct ath_softc *sc);
3589 -bool ath9k_uses_beacons(int type);
3590 void ath9k_spectral_scan_trigger(struct ieee80211_hw *hw);
3591 int ath9k_spectral_scan_config(struct ieee80211_hw *hw,
3592 enum spectral_mode spectral_mode);
3593 --- a/drivers/net/wireless/ath/ath9k/debug.c
3594 +++ b/drivers/net/wireless/ath/ath9k/debug.c
3595 @@ -270,25 +270,29 @@ static const struct file_operations fops
3596 .llseek = default_llseek,
3599 -static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
3600 - size_t count, loff_t *ppos)
3601 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
3603 +static ssize_t read_file_bt_ant_diversity(struct file *file,
3604 + char __user *user_buf,
3605 + size_t count, loff_t *ppos)
3607 struct ath_softc *sc = file->private_data;
3608 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
3612 - len = sprintf(buf, "%d\n", common->antenna_diversity);
3613 + len = sprintf(buf, "%d\n", common->bt_ant_diversity);
3614 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
3617 -static ssize_t write_file_ant_diversity(struct file *file,
3618 - const char __user *user_buf,
3619 - size_t count, loff_t *ppos)
3620 +static ssize_t write_file_bt_ant_diversity(struct file *file,
3621 + const char __user *user_buf,
3622 + size_t count, loff_t *ppos)
3624 struct ath_softc *sc = file->private_data;
3625 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
3626 - unsigned long antenna_diversity;
3627 + struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps;
3628 + unsigned long bt_ant_diversity;
3632 @@ -296,26 +300,147 @@ static ssize_t write_file_ant_diversity(
3633 if (copy_from_user(buf, user_buf, len))
3636 - if (!AR_SREV_9565(sc->sc_ah))
3637 + if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV))
3641 - if (strict_strtoul(buf, 0, &antenna_diversity))
3642 + if (kstrtoul(buf, 0, &bt_ant_diversity))
3645 - common->antenna_diversity = !!antenna_diversity;
3646 + common->bt_ant_diversity = !!bt_ant_diversity;
3647 ath9k_ps_wakeup(sc);
3648 - ath_ant_comb_update(sc);
3649 - ath_dbg(common, CONFIG, "Antenna diversity: %d\n",
3650 - common->antenna_diversity);
3651 + ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity);
3652 + ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n",
3653 + common->bt_ant_diversity);
3654 ath9k_ps_restore(sc);
3659 -static const struct file_operations fops_ant_diversity = {
3660 - .read = read_file_ant_diversity,
3661 - .write = write_file_ant_diversity,
3662 +static const struct file_operations fops_bt_ant_diversity = {
3663 + .read = read_file_bt_ant_diversity,
3664 + .write = write_file_bt_ant_diversity,
3665 + .open = simple_open,
3666 + .owner = THIS_MODULE,
3667 + .llseek = default_llseek,
3672 +void ath9k_debug_stat_ant(struct ath_softc *sc,
3673 + struct ath_hw_antcomb_conf *div_ant_conf,
3674 + int main_rssi_avg, int alt_rssi_avg)
3676 + struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
3677 + struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
3679 + as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++;
3680 + as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++;
3682 + as_main->rssi_avg = main_rssi_avg;
3683 + as_alt->rssi_avg = alt_rssi_avg;
3686 +static ssize_t read_file_antenna_diversity(struct file *file,
3687 + char __user *user_buf,
3688 + size_t count, loff_t *ppos)
3690 + struct ath_softc *sc = file->private_data;
3691 + struct ath_hw *ah = sc->sc_ah;
3692 + struct ath9k_hw_capabilities *pCap = &ah->caps;
3693 + struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
3694 + struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
3695 + struct ath_hw_antcomb_conf div_ant_conf;
3696 + unsigned int len = 0, size = 1024;
3697 + ssize_t retval = 0;
3699 + char *lna_conf_str[4] = {"LNA1_MINUS_LNA2",
3702 + "LNA1_PLUS_LNA2"};
3704 + buf = kzalloc(size, GFP_KERNEL);
3708 + if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) {
3709 + len += snprintf(buf + len, size - len, "%s\n",
3710 + "Antenna Diversity Combining is disabled");
3714 + ath9k_ps_wakeup(sc);
3715 + ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
3716 + len += snprintf(buf + len, size - len, "Current MAIN config : %s\n",
3717 + lna_conf_str[div_ant_conf.main_lna_conf]);
3718 + len += snprintf(buf + len, size - len, "Current ALT config : %s\n",
3719 + lna_conf_str[div_ant_conf.alt_lna_conf]);
3720 + len += snprintf(buf + len, size - len, "Average MAIN RSSI : %d\n",
3721 + as_main->rssi_avg);
3722 + len += snprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n",
3723 + as_alt->rssi_avg);
3724 + ath9k_ps_restore(sc);
3726 + len += snprintf(buf + len, size - len, "Packet Receive Cnt:\n");
3727 + len += snprintf(buf + len, size - len, "-------------------\n");
3729 + len += snprintf(buf + len, size - len, "%30s%15s\n",
3731 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3733 + as_main->recv_cnt,
3734 + as_alt->recv_cnt);
3735 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3737 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1],
3738 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]);
3739 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3741 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2],
3742 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]);
3743 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3745 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
3746 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
3747 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3749 + as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
3750 + as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
3752 + len += snprintf(buf + len, size - len, "\nLNA Config Attempts:\n");
3753 + len += snprintf(buf + len, size - len, "--------------------\n");
3755 + len += snprintf(buf + len, size - len, "%30s%15s\n",
3757 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3759 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1],
3760 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]);
3761 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3763 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2],
3764 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]);
3765 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3767 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
3768 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
3769 + len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n",
3771 + as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
3772 + as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
3778 + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
3784 +static const struct file_operations fops_antenna_diversity = {
3785 + .read = read_file_antenna_diversity,
3786 .open = simple_open,
3787 .owner = THIS_MODULE,
3788 .llseek = default_llseek,
3789 @@ -607,6 +732,28 @@ static ssize_t read_file_xmit(struct fil
3793 +static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq,
3794 + char *buf, ssize_t size)
3798 + ath_txq_lock(sc, txq);
3800 + len += snprintf(buf + len, size - len, "%s: %d ",
3801 + "qnum", txq->axq_qnum);
3802 + len += snprintf(buf + len, size - len, "%s: %2d ",
3803 + "qdepth", txq->axq_depth);
3804 + len += snprintf(buf + len, size - len, "%s: %2d ",
3805 + "ampdu-depth", txq->axq_ampdu_depth);
3806 + len += snprintf(buf + len, size - len, "%s: %3d ",
3807 + "pending", txq->pending_frames);
3808 + len += snprintf(buf + len, size - len, "%s: %d\n",
3809 + "stopped", txq->stopped);
3811 + ath_txq_unlock(sc, txq);
3815 static ssize_t read_file_queues(struct file *file, char __user *user_buf,
3816 size_t count, loff_t *ppos)
3818 @@ -624,24 +771,13 @@ static ssize_t read_file_queues(struct f
3820 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
3821 txq = sc->tx.txq_map[i];
3822 - len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
3824 - ath_txq_lock(sc, txq);
3826 - len += snprintf(buf + len, size - len, "%s: %d ",
3827 - "qnum", txq->axq_qnum);
3828 - len += snprintf(buf + len, size - len, "%s: %2d ",
3829 - "qdepth", txq->axq_depth);
3830 - len += snprintf(buf + len, size - len, "%s: %2d ",
3831 - "ampdu-depth", txq->axq_ampdu_depth);
3832 - len += snprintf(buf + len, size - len, "%s: %3d ",
3833 - "pending", txq->pending_frames);
3834 - len += snprintf(buf + len, size - len, "%s: %d\n",
3835 - "stopped", txq->stopped);
3837 - ath_txq_unlock(sc, txq);
3838 + len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
3839 + len += print_queue(sc, txq, buf + len, size - len);
3842 + len += snprintf(buf + len, size - len, "(CAB): ");
3843 + len += print_queue(sc, sc->beacon.cabq, buf + len, size - len);
3848 @@ -1818,9 +1954,11 @@ int ath9k_init_debug(struct ath_hw *ah)
3849 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
3850 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
3851 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
3852 - debugfs_create_file("diversity", S_IRUSR | S_IWUSR,
3853 - sc->debug.debugfs_phy, sc, &fops_ant_diversity);
3854 + debugfs_create_file("antenna_diversity", S_IRUSR,
3855 + sc->debug.debugfs_phy, sc, &fops_antenna_diversity);
3856 #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
3857 + debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR,
3858 + sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity);
3859 debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc,
3862 --- a/net/mac80211/ibss.c
3863 +++ b/net/mac80211/ibss.c
3866 #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ)
3867 #define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ)
3868 +#define IEEE80211_IBSS_RSN_INACTIVITY_LIMIT (10 * HZ)
3870 #define IEEE80211_IBSS_MAX_STA_ENTRIES 128
3873 static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
3874 const u8 *bssid, const int beacon_int,
3875 - struct ieee80211_channel *chan,
3876 + struct cfg80211_chan_def *req_chandef,
3877 const u32 basic_rates,
3878 const u16 capability, u64 tsf,
3880 @@ -51,6 +52,7 @@ static void __ieee80211_sta_join_ibss(st
3882 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
3883 struct cfg80211_chan_def chandef;
3884 + struct ieee80211_channel *chan;
3885 struct beacon_data *presp;
3888 @@ -81,7 +83,9 @@ static void __ieee80211_sta_join_ibss(st
3890 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
3892 - chandef = ifibss->chandef;
3893 + /* make a copy of the chandef, it could be modified below. */
3894 + chandef = *req_chandef;
3895 + chan = chandef.chan;
3896 if (!cfg80211_reg_can_beacon(local->hw.wiphy, &chandef)) {
3897 chandef.width = NL80211_CHAN_WIDTH_20;
3898 chandef.center_freq1 = chan->center_freq;
3899 @@ -259,10 +263,12 @@ static void ieee80211_sta_join_ibss(stru
3900 struct cfg80211_bss *cbss =
3901 container_of((void *)bss, struct cfg80211_bss, priv);
3902 struct ieee80211_supported_band *sband;
3903 + struct cfg80211_chan_def chandef;
3906 u16 beacon_int = cbss->beacon_interval;
3907 const struct cfg80211_bss_ies *ies;
3908 + enum nl80211_channel_type chan_type;
3911 sdata_assert_lock(sdata);
3912 @@ -270,6 +276,26 @@ static void ieee80211_sta_join_ibss(stru
3913 if (beacon_int < 10)
3916 + switch (sdata->u.ibss.chandef.width) {
3917 + case NL80211_CHAN_WIDTH_20_NOHT:
3918 + case NL80211_CHAN_WIDTH_20:
3919 + case NL80211_CHAN_WIDTH_40:
3920 + chan_type = cfg80211_get_chandef_type(&sdata->u.ibss.chandef);
3921 + cfg80211_chandef_create(&chandef, cbss->channel, chan_type);
3923 + case NL80211_CHAN_WIDTH_5:
3924 + case NL80211_CHAN_WIDTH_10:
3925 + cfg80211_chandef_create(&chandef, cbss->channel,
3926 + NL80211_CHAN_WIDTH_20_NOHT);
3927 + chandef.width = sdata->u.ibss.chandef.width;
3930 + /* fall back to 20 MHz for unsupported modes */
3931 + cfg80211_chandef_create(&chandef, cbss->channel,
3932 + NL80211_CHAN_WIDTH_20_NOHT);
3936 sband = sdata->local->hw.wiphy->bands[cbss->channel->band];
3939 @@ -294,7 +320,7 @@ static void ieee80211_sta_join_ibss(stru
3941 __ieee80211_sta_join_ibss(sdata, cbss->bssid,
3948 @@ -672,6 +698,33 @@ static int ieee80211_sta_active_ibss(str
3952 +static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
3954 + struct ieee80211_local *local = sdata->local;
3955 + struct sta_info *sta, *tmp;
3956 + unsigned long exp_time = IEEE80211_IBSS_INACTIVITY_LIMIT;
3957 + unsigned long exp_rsn_time = IEEE80211_IBSS_RSN_INACTIVITY_LIMIT;
3959 + mutex_lock(&local->sta_mtx);
3961 + list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
3962 + if (sdata != sta->sdata)
3965 + if (time_after(jiffies, sta->last_rx + exp_time) ||
3966 + (time_after(jiffies, sta->last_rx + exp_rsn_time) &&
3967 + sta->sta_state != IEEE80211_STA_AUTHORIZED)) {
3968 + sta_dbg(sta->sdata, "expiring inactive %sSTA %pM\n",
3969 + sta->sta_state != IEEE80211_STA_AUTHORIZED ?
3970 + "not authorized " : "", sta->sta.addr);
3972 + WARN_ON(__sta_info_destroy(sta));
3976 + mutex_unlock(&local->sta_mtx);
3980 * This function is called with state == IEEE80211_IBSS_MLME_JOINED
3982 @@ -685,7 +738,7 @@ static void ieee80211_sta_merge_ibss(str
3983 mod_timer(&ifibss->timer,
3984 round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL));
3986 - ieee80211_sta_expire(sdata, IEEE80211_IBSS_INACTIVITY_LIMIT);
3987 + ieee80211_ibss_sta_expire(sdata);
3989 if (time_before(jiffies, ifibss->last_scan_completed +
3990 IEEE80211_IBSS_MERGE_INTERVAL))
3991 @@ -736,7 +789,7 @@ static void ieee80211_sta_create_ibss(st
3992 sdata->drop_unencrypted = 0;
3994 __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int,
3995 - ifibss->chandef.chan, ifibss->basic_rates,
3996 + &ifibss->chandef, ifibss->basic_rates,
3997 capability, 0, true);
4000 @@ -792,6 +845,17 @@ static void ieee80211_sta_find_ibss(stru
4004 + /* if a fixed bssid and a fixed freq have been provided create the IBSS
4005 + * directly and do not waste time scanning
4007 + if (ifibss->fixed_bssid && ifibss->fixed_channel) {
4008 + sdata_info(sdata, "Created IBSS using preconfigured BSSID %pM\n",
4010 + ieee80211_sta_create_ibss(sdata);
4015 ibss_dbg(sdata, "sta_find_ibss: did not try to join ibss\n");
4017 /* Selected IBSS not found in current scan results - try to scan */
4018 @@ -1138,6 +1202,7 @@ int ieee80211_ibss_leave(struct ieee8021
4019 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
4020 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
4022 + ieee80211_vif_release_channel(sdata);
4026 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
4027 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
4028 @@ -551,8 +551,7 @@ static void ar9003_hw_set_channel_regs(s
4029 if (IS_CHAN_HT40(chan)) {
4030 phymode |= AR_PHY_GC_DYN2040_EN;
4031 /* Configure control (primary) channel at +-10MHz */
4032 - if ((chan->chanmode == CHANNEL_A_HT40PLUS) ||
4033 - (chan->chanmode == CHANNEL_G_HT40PLUS))
4034 + if (IS_CHAN_HT40PLUS(chan))
4035 phymode |= AR_PHY_GC_DYN2040_PRI_CH;
4038 @@ -565,7 +564,7 @@ static void ar9003_hw_set_channel_regs(s
4039 REG_WRITE(ah, AR_PHY_GEN_CTRL, phymode);
4041 /* Configure MAC for 20/40 operation */
4042 - ath9k_hw_set11nmac2040(ah);
4043 + ath9k_hw_set11nmac2040(ah, chan);
4045 /* global transmit timeout (25 TUs default)*/
4046 REG_WRITE(ah, AR_GTXTO, 25 << AR_GTXTO_TIMEOUT_LIMIT_S);
4047 @@ -632,6 +631,22 @@ static void ar9003_hw_override_ini(struc
4049 REG_SET_BIT(ah, AR_PHY_CCK_DETECT,
4050 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
4052 + if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
4053 + REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE,
4054 + AR_GLB_SWREG_DISCONT_EN_BT_WLAN);
4056 + if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
4057 + AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL))
4058 + ah->enabled_cals |= TX_IQ_CAL;
4060 + ah->enabled_cals &= ~TX_IQ_CAL;
4062 + if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE)
4063 + ah->enabled_cals |= TX_CL_CAL;
4065 + ah->enabled_cals &= ~TX_CL_CAL;
4069 static void ar9003_hw_prog_ini(struct ath_hw *ah,
4070 @@ -667,41 +682,22 @@ static int ar9550_hw_get_modes_txgain_in
4074 - switch (chan->chanmode) {
4076 - case CHANNEL_A_HT20:
4077 - if (chan->channel <= 5350)
4079 - else if ((chan->channel > 5350) && (chan->channel <= 5600))
4081 + if (IS_CHAN_2GHZ(chan)) {
4082 + if (IS_CHAN_HT40(chan))
4088 - case CHANNEL_A_HT40PLUS:
4089 - case CHANNEL_A_HT40MINUS:
4090 - if (chan->channel <= 5350)
4092 - else if ((chan->channel > 5350) && (chan->channel <= 5600))
4101 - case CHANNEL_G_HT20:
4105 + if (chan->channel <= 5350)
4107 + else if ((chan->channel > 5350) && (chan->channel <= 5600))
4112 - case CHANNEL_G_HT40PLUS:
4113 - case CHANNEL_G_HT40MINUS:
4120 + if (IS_CHAN_HT40(chan))
4125 @@ -712,28 +708,10 @@ static int ar9003_hw_process_ini(struct
4126 unsigned int regWrites = 0, i;
4129 - switch (chan->chanmode) {
4131 - case CHANNEL_A_HT20:
4134 - case CHANNEL_A_HT40PLUS:
4135 - case CHANNEL_A_HT40MINUS:
4139 - case CHANNEL_G_HT20:
4143 - case CHANNEL_G_HT40PLUS:
4144 - case CHANNEL_G_HT40MINUS:
4151 + if (IS_CHAN_5GHZ(chan))
4152 + modesIndex = IS_CHAN_HT40(chan) ? 2 : 1;
4154 + modesIndex = IS_CHAN_HT40(chan) ? 3 : 4;
4157 * SOC, MAC, BB, RADIO initvals.
4158 @@ -814,29 +792,12 @@ static int ar9003_hw_process_ini(struct
4159 if (chan->channel == 2484)
4160 ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1);
4162 - if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
4163 - REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE,
4164 - AR_GLB_SWREG_DISCONT_EN_BT_WLAN);
4166 ah->modes_index = modesIndex;
4167 ar9003_hw_override_ini(ah);
4168 ar9003_hw_set_channel_regs(ah, chan);
4169 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
4170 ath9k_hw_apply_txpower(ah, chan, false);
4172 - if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
4173 - if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
4174 - AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL))
4175 - ah->enabled_cals |= TX_IQ_CAL;
4177 - ah->enabled_cals &= ~TX_IQ_CAL;
4179 - if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE)
4180 - ah->enabled_cals |= TX_CL_CAL;
4182 - ah->enabled_cals &= ~TX_CL_CAL;
4188 @@ -848,8 +809,10 @@ static void ar9003_hw_set_rfmode(struct
4192 - rfMode |= (IS_CHAN_B(chan) || IS_CHAN_G(chan))
4193 - ? AR_PHY_MODE_DYNAMIC : AR_PHY_MODE_OFDM;
4194 + if (IS_CHAN_2GHZ(chan))
4195 + rfMode |= AR_PHY_MODE_DYNAMIC;
4197 + rfMode |= AR_PHY_MODE_OFDM;
4199 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
4200 rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE);
4201 @@ -1173,6 +1136,10 @@ skip_ws_det:
4202 * is_on == 0 means MRC CCK is OFF (more noise imm)
4204 bool is_on = param ? 1 : 0;
4206 + if (ah->caps.rx_chainmask == 1)
4209 REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
4210 AR_PHY_MRC_CCK_ENABLE, is_on);
4211 REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
4212 @@ -1273,12 +1240,11 @@ static void ar9003_hw_ani_cache_ini_regs
4213 aniState = &ah->ani;
4214 iniDef = &aniState->iniDef;
4216 - ath_dbg(common, ANI, "ver %d.%d opmode %u chan %d Mhz/0x%x\n",
4217 + ath_dbg(common, ANI, "ver %d.%d opmode %u chan %d Mhz\n",
4218 ah->hw_version.macVersion,
4219 ah->hw_version.macRev,
4222 - chan->channelFlags);
4225 val = REG_READ(ah, AR_PHY_SFCORR);
4226 iniDef->m1Thresh = MS(val, AR_PHY_SFCORR_M1_THRESH);
4227 @@ -1413,65 +1379,111 @@ static void ar9003_hw_antdiv_comb_conf_s
4228 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
4231 -static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
4233 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
4235 +static void ar9003_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
4237 + struct ath9k_hw_capabilities *pCap = &ah->caps;
4241 - if (!AR_SREV_9565(ah))
4242 + if (!AR_SREV_9485(ah) && !AR_SREV_9565(ah))
4245 - ah->shared_chain_lnadiv = enable;
4246 + if (AR_SREV_9485(ah)) {
4247 + regval = ar9003_hw_ant_ctrl_common_2_get(ah,
4248 + IS_CHAN_2GHZ(ah->curchan));
4250 + regval &= ~AR_SWITCH_TABLE_COM2_ALL;
4251 + regval |= ah->config.ant_ctrl_comm2g_switch_enable;
4253 + REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2,
4254 + AR_SWITCH_TABLE_COM2_ALL, regval);
4257 ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
4260 + * Set MAIN/ALT LNA conf.
4261 + * Set MAIN/ALT gain_tb.
4263 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
4264 regval &= (~AR_ANT_DIV_CTRL_ALL);
4265 regval |= (ant_div_ctl1 & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
4266 - regval &= ~AR_PHY_ANT_DIV_LNADIV;
4267 - regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
4270 - regval |= AR_ANT_DIV_ENABLE;
4272 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
4274 - regval = REG_READ(ah, AR_PHY_CCK_DETECT);
4275 - regval &= ~AR_FAST_DIV_ENABLE;
4276 - regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
4279 - regval |= AR_FAST_DIV_ENABLE;
4281 - REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
4284 - REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
4285 - (1 << AR_PHY_ANT_SW_RX_PROT_S));
4286 - if (ah->curchan && IS_CHAN_2GHZ(ah->curchan))
4287 - REG_SET_BIT(ah, AR_PHY_RESTART,
4288 - AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
4289 - REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
4290 - AR_BTCOEX_WL_LNADIV_FORCE_ON);
4292 - REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE);
4293 - REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
4294 - (1 << AR_PHY_ANT_SW_RX_PROT_S));
4295 - REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE);
4296 - REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
4297 - AR_BTCOEX_WL_LNADIV_FORCE_ON);
4299 + if (AR_SREV_9485_11_OR_LATER(ah)) {
4301 + * Enable LNA diversity.
4303 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
4304 - regval &= ~(AR_PHY_ANT_DIV_MAIN_LNACONF |
4305 - AR_PHY_ANT_DIV_ALT_LNACONF |
4306 - AR_PHY_ANT_DIV_MAIN_GAINTB |
4307 - AR_PHY_ANT_DIV_ALT_GAINTB);
4308 - regval |= (AR_PHY_ANT_DIV_LNA1 << AR_PHY_ANT_DIV_MAIN_LNACONF_S);
4309 - regval |= (AR_PHY_ANT_DIV_LNA2 << AR_PHY_ANT_DIV_ALT_LNACONF_S);
4310 + regval &= ~AR_PHY_ANT_DIV_LNADIV;
4311 + regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
4313 + regval |= AR_ANT_DIV_ENABLE;
4315 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
4318 + * Enable fast antenna diversity.
4320 + regval = REG_READ(ah, AR_PHY_CCK_DETECT);
4321 + regval &= ~AR_FAST_DIV_ENABLE;
4322 + regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
4324 + regval |= AR_FAST_DIV_ENABLE;
4326 + REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
4328 + if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
4329 + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
4330 + regval &= (~(AR_PHY_ANT_DIV_MAIN_LNACONF |
4331 + AR_PHY_ANT_DIV_ALT_LNACONF |
4332 + AR_PHY_ANT_DIV_ALT_GAINTB |
4333 + AR_PHY_ANT_DIV_MAIN_GAINTB));
4335 + * Set MAIN to LNA1 and ALT to LNA2 at the
4338 + regval |= (ATH_ANT_DIV_COMB_LNA1 <<
4339 + AR_PHY_ANT_DIV_MAIN_LNACONF_S);
4340 + regval |= (ATH_ANT_DIV_COMB_LNA2 <<
4341 + AR_PHY_ANT_DIV_ALT_LNACONF_S);
4342 + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
4344 + } else if (AR_SREV_9565(ah)) {
4346 + REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
4347 + (1 << AR_PHY_ANT_SW_RX_PROT_S));
4348 + if (ah->curchan && IS_CHAN_2GHZ(ah->curchan))
4349 + REG_SET_BIT(ah, AR_PHY_RESTART,
4350 + AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
4351 + REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
4352 + AR_BTCOEX_WL_LNADIV_FORCE_ON);
4354 + REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE);
4355 + REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
4356 + (1 << AR_PHY_ANT_SW_RX_PROT_S));
4357 + REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE);
4358 + REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
4359 + AR_BTCOEX_WL_LNADIV_FORCE_ON);
4361 + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
4362 + regval &= ~(AR_PHY_ANT_DIV_MAIN_LNACONF |
4363 + AR_PHY_ANT_DIV_ALT_LNACONF |
4364 + AR_PHY_ANT_DIV_MAIN_GAINTB |
4365 + AR_PHY_ANT_DIV_ALT_GAINTB);
4366 + regval |= (ATH_ANT_DIV_COMB_LNA1 <<
4367 + AR_PHY_ANT_DIV_MAIN_LNACONF_S);
4368 + regval |= (ATH_ANT_DIV_COMB_LNA2 <<
4369 + AR_PHY_ANT_DIV_ALT_LNACONF_S);
4370 + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
4377 static int ar9003_hw_fast_chan_change(struct ath_hw *ah,
4378 struct ath9k_channel *chan,
4380 @@ -1479,28 +1491,10 @@ static int ar9003_hw_fast_chan_change(st
4381 unsigned int regWrites = 0;
4384 - switch (chan->chanmode) {
4386 - case CHANNEL_A_HT20:
4389 - case CHANNEL_A_HT40PLUS:
4390 - case CHANNEL_A_HT40MINUS:
4394 - case CHANNEL_G_HT20:
4398 - case CHANNEL_G_HT40PLUS:
4399 - case CHANNEL_G_HT40MINUS:
4406 + if (IS_CHAN_5GHZ(chan))
4407 + modesIndex = IS_CHAN_HT40(chan) ? 2 : 1;
4409 + modesIndex = IS_CHAN_HT40(chan) ? 3 : 4;
4411 if (modesIndex == ah->modes_index) {
4412 *ini_reloaded = false;
4413 @@ -1518,6 +1512,18 @@ static int ar9003_hw_fast_chan_change(st
4415 REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites);
4417 + if (AR_SREV_9462_20_OR_LATER(ah)) {
4419 + * CUS217 mix LNA mode.
4421 + if (ar9003_hw_get_rx_gain_idx(ah) == 2) {
4422 + REG_WRITE_ARRAY(&ah->ini_modes_rxgain_bb_core,
4424 + REG_WRITE_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
4425 + modesIndex, regWrites);
4430 * For 5GHz channels requiring Fast Clock, apply
4431 * different modal values.
4432 @@ -1528,7 +1534,11 @@ static int ar9003_hw_fast_chan_change(st
4433 if (AR_SREV_9565(ah))
4434 REG_WRITE_ARRAY(&ah->iniModesFastClock, 1, regWrites);
4436 - REG_WRITE_ARRAY(&ah->iniAdditional, 1, regWrites);
4438 + * JAPAN regulatory.
4440 + if (chan->channel == 2484)
4441 + ar9003_hw_prog_ini(ah, &ah->iniCckfirJapan2484, 1);
4443 ah->modes_index = modesIndex;
4444 *ini_reloaded = true;
4445 @@ -1631,11 +1641,14 @@ void ar9003_hw_attach_phy_ops(struct ath
4447 ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get;
4448 ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set;
4449 - ops->antctrl_shared_chain_lnadiv = ar9003_hw_antctrl_shared_chain_lnadiv;
4450 ops->spectral_scan_config = ar9003_hw_spectral_scan_config;
4451 ops->spectral_scan_trigger = ar9003_hw_spectral_scan_trigger;
4452 ops->spectral_scan_wait = ar9003_hw_spectral_scan_wait;
4454 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
4455 + ops->set_bt_ant_diversity = ar9003_hw_set_bt_ant_diversity;
4458 ar9003_hw_set_nf_limits(ah);
4459 ar9003_hw_set_radar_conf(ah);
4460 memcpy(ah->nf_regs, ar9300_cca_regs, sizeof(ah->nf_regs));
4461 --- a/drivers/net/wireless/ath/ath9k/recv.c
4462 +++ b/drivers/net/wireless/ath/ath9k/recv.c
4465 #include "ar9003_mac.h"
4467 -#define SKB_CB_ATHBUF(__skb) (*((struct ath_buf **)__skb->cb))
4468 +#define SKB_CB_ATHBUF(__skb) (*((struct ath_rxbuf **)__skb->cb))
4470 static inline bool ath9k_check_auto_sleep(struct ath_softc *sc)
4472 @@ -35,15 +35,13 @@ static inline bool ath9k_check_auto_slee
4473 * buffer (or rx fifo). This can incorrectly acknowledge packets
4474 * to a sender if last desc is self-linked.
4476 -static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
4477 +static void ath_rx_buf_link(struct ath_softc *sc, struct ath_rxbuf *bf)
4479 struct ath_hw *ah = sc->sc_ah;
4480 struct ath_common *common = ath9k_hw_common(ah);
4481 struct ath_desc *ds;
4482 struct sk_buff *skb;
4484 - ATH_RXBUF_RESET(bf);
4487 ds->ds_link = 0; /* link to null */
4488 ds->ds_data = bf->bf_buf_addr;
4489 @@ -70,6 +68,14 @@ static void ath_rx_buf_link(struct ath_s
4490 sc->rx.rxlink = &ds->ds_link;
4493 +static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_rxbuf *bf)
4495 + if (sc->rx.buf_hold)
4496 + ath_rx_buf_link(sc, sc->rx.buf_hold);
4498 + sc->rx.buf_hold = bf;
4501 static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
4503 /* XXX block beacon interrupts */
4504 @@ -106,18 +112,17 @@ static bool ath_rx_edma_buf_link(struct
4505 struct ath_hw *ah = sc->sc_ah;
4506 struct ath_rx_edma *rx_edma;
4507 struct sk_buff *skb;
4508 - struct ath_buf *bf;
4509 + struct ath_rxbuf *bf;
4511 rx_edma = &sc->rx.rx_edma[qtype];
4512 if (skb_queue_len(&rx_edma->rx_fifo) >= rx_edma->rx_fifo_hwsize)
4515 - bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list);
4516 + bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list);
4517 list_del_init(&bf->list);
4521 - ATH_RXBUF_RESET(bf);
4522 memset(skb->data, 0, ah->caps.rx_status_len);
4523 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
4524 ah->caps.rx_status_len, DMA_TO_DEVICE);
4525 @@ -133,7 +138,7 @@ static void ath_rx_addbuffer_edma(struct
4526 enum ath9k_rx_qtype qtype)
4528 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
4529 - struct ath_buf *bf, *tbf;
4530 + struct ath_rxbuf *bf, *tbf;
4532 if (list_empty(&sc->rx.rxbuf)) {
4533 ath_dbg(common, QUEUE, "No free rx buf available\n");
4534 @@ -149,7 +154,7 @@ static void ath_rx_addbuffer_edma(struct
4535 static void ath_rx_remove_buffer(struct ath_softc *sc,
4536 enum ath9k_rx_qtype qtype)
4538 - struct ath_buf *bf;
4539 + struct ath_rxbuf *bf;
4540 struct ath_rx_edma *rx_edma;
4541 struct sk_buff *skb;
4543 @@ -166,7 +171,7 @@ static void ath_rx_edma_cleanup(struct a
4545 struct ath_hw *ah = sc->sc_ah;
4546 struct ath_common *common = ath9k_hw_common(ah);
4547 - struct ath_buf *bf;
4548 + struct ath_rxbuf *bf;
4550 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_LP);
4551 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_HP);
4552 @@ -185,7 +190,7 @@ static void ath_rx_edma_cleanup(struct a
4554 static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size)
4556 - skb_queue_head_init(&rx_edma->rx_fifo);
4557 + __skb_queue_head_init(&rx_edma->rx_fifo);
4558 rx_edma->rx_fifo_hwsize = size;
4561 @@ -194,7 +199,7 @@ static int ath_rx_edma_init(struct ath_s
4562 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
4563 struct ath_hw *ah = sc->sc_ah;
4564 struct sk_buff *skb;
4565 - struct ath_buf *bf;
4566 + struct ath_rxbuf *bf;
4570 @@ -206,7 +211,7 @@ static int ath_rx_edma_init(struct ath_s
4571 ath_rx_edma_init_queue(&sc->rx.rx_edma[ATH9K_RX_QUEUE_HP],
4572 ah->caps.rx_hp_qdepth);
4574 - size = sizeof(struct ath_buf) * nbufs;
4575 + size = sizeof(struct ath_rxbuf) * nbufs;
4576 bf = devm_kzalloc(sc->dev, size, GFP_KERNEL);
4579 @@ -266,7 +271,7 @@ int ath_rx_init(struct ath_softc *sc, in
4581 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
4582 struct sk_buff *skb;
4583 - struct ath_buf *bf;
4584 + struct ath_rxbuf *bf;
4587 spin_lock_init(&sc->sc_pcu_lock);
4588 @@ -327,7 +332,7 @@ void ath_rx_cleanup(struct ath_softc *sc
4589 struct ath_hw *ah = sc->sc_ah;
4590 struct ath_common *common = ath9k_hw_common(ah);
4591 struct sk_buff *skb;
4592 - struct ath_buf *bf;
4593 + struct ath_rxbuf *bf;
4595 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
4596 ath_rx_edma_cleanup(sc);
4597 @@ -422,7 +427,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
4598 int ath_startrecv(struct ath_softc *sc)
4600 struct ath_hw *ah = sc->sc_ah;
4601 - struct ath_buf *bf, *tbf;
4602 + struct ath_rxbuf *bf, *tbf;
4604 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
4605 ath_edma_start_recv(sc);
4606 @@ -432,6 +437,7 @@ int ath_startrecv(struct ath_softc *sc)
4607 if (list_empty(&sc->rx.rxbuf))
4610 + sc->rx.buf_hold = NULL;
4611 sc->rx.rxlink = NULL;
4612 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) {
4613 ath_rx_buf_link(sc, bf);
4614 @@ -441,7 +447,7 @@ int ath_startrecv(struct ath_softc *sc)
4615 if (list_empty(&sc->rx.rxbuf))
4618 - bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list);
4619 + bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list);
4620 ath9k_hw_putrxbuf(ah, bf->bf_daddr);
4623 @@ -597,13 +603,13 @@ static void ath_rx_ps(struct ath_softc *
4624 static bool ath_edma_get_buffers(struct ath_softc *sc,
4625 enum ath9k_rx_qtype qtype,
4626 struct ath_rx_status *rs,
4627 - struct ath_buf **dest)
4628 + struct ath_rxbuf **dest)
4630 struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype];
4631 struct ath_hw *ah = sc->sc_ah;
4632 struct ath_common *common = ath9k_hw_common(ah);
4633 struct sk_buff *skb;
4634 - struct ath_buf *bf;
4635 + struct ath_rxbuf *bf;
4638 skb = skb_peek(&rx_edma->rx_fifo);
4639 @@ -647,11 +653,11 @@ static bool ath_edma_get_buffers(struct
4643 -static struct ath_buf *ath_edma_get_next_rx_buf(struct ath_softc *sc,
4644 +static struct ath_rxbuf *ath_edma_get_next_rx_buf(struct ath_softc *sc,
4645 struct ath_rx_status *rs,
4646 enum ath9k_rx_qtype qtype)
4648 - struct ath_buf *bf = NULL;
4649 + struct ath_rxbuf *bf = NULL;
4651 while (ath_edma_get_buffers(sc, qtype, rs, &bf)) {
4653 @@ -662,13 +668,13 @@ static struct ath_buf *ath_edma_get_next
4657 -static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
4658 +static struct ath_rxbuf *ath_get_next_rx_buf(struct ath_softc *sc,
4659 struct ath_rx_status *rs)
4661 struct ath_hw *ah = sc->sc_ah;
4662 struct ath_common *common = ath9k_hw_common(ah);
4663 struct ath_desc *ds;
4664 - struct ath_buf *bf;
4665 + struct ath_rxbuf *bf;
4668 if (list_empty(&sc->rx.rxbuf)) {
4669 @@ -676,7 +682,10 @@ static struct ath_buf *ath_get_next_rx_b
4673 - bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list);
4674 + bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list);
4675 + if (bf == sc->rx.buf_hold)
4681 @@ -693,7 +702,7 @@ static struct ath_buf *ath_get_next_rx_b
4682 ret = ath9k_hw_rxprocdesc(ah, ds, rs);
4683 if (ret == -EINPROGRESS) {
4684 struct ath_rx_status trs;
4685 - struct ath_buf *tbf;
4686 + struct ath_rxbuf *tbf;
4687 struct ath_desc *tds;
4689 memset(&trs, 0, sizeof(trs));
4690 @@ -702,7 +711,7 @@ static struct ath_buf *ath_get_next_rx_b
4694 - tbf = list_entry(bf->list.next, struct ath_buf, list);
4695 + tbf = list_entry(bf->list.next, struct ath_rxbuf, list);
4698 * On some hardware the descriptor status words could
4699 @@ -755,7 +764,6 @@ static bool ath9k_rx_accept(struct ath_c
4700 bool is_mc, is_valid_tkip, strip_mic, mic_error;
4701 struct ath_hw *ah = common->ah;
4703 - u8 rx_status_len = ah->caps.rx_status_len;
4705 fc = hdr->frame_control;
4707 @@ -777,25 +785,6 @@ static bool ath9k_rx_accept(struct ath_c
4708 !test_bit(rx_stats->rs_keyix, common->ccmp_keymap))
4709 rx_stats->rs_status &= ~ATH9K_RXERR_KEYMISS;
4711 - if (!rx_stats->rs_datalen) {
4712 - RX_STAT_INC(rx_len_err);
4717 - * rs_status follows rs_datalen so if rs_datalen is too large
4718 - * we can take a hint that hardware corrupted it, so ignore
4721 - if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len)) {
4722 - RX_STAT_INC(rx_len_err);
4726 - /* Only use error bits from the last fragment */
4727 - if (rx_stats->rs_more)
4730 mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
4731 !ieee80211_has_morefrags(fc) &&
4732 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
4733 @@ -814,8 +803,6 @@ static bool ath9k_rx_accept(struct ath_c
4734 rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
4737 - if (rx_stats->rs_status & ATH9K_RXERR_PHY)
4740 if ((rx_stats->rs_status & ATH9K_RXERR_DECRYPT) ||
4741 (!is_mc && (rx_stats->rs_status & ATH9K_RXERR_KEYMISS))) {
4742 @@ -898,129 +885,65 @@ static int ath9k_process_rate(struct ath
4744 static void ath9k_process_rssi(struct ath_common *common,
4745 struct ieee80211_hw *hw,
4746 - struct ieee80211_hdr *hdr,
4747 - struct ath_rx_status *rx_stats)
4748 + struct ath_rx_status *rx_stats,
4749 + struct ieee80211_rx_status *rxs)
4751 struct ath_softc *sc = hw->priv;
4752 struct ath_hw *ah = common->ah;
4754 int rssi = rx_stats->rs_rssi;
4756 - if (!rx_stats->is_mybeacon ||
4757 - ((ah->opmode != NL80211_IFTYPE_STATION) &&
4758 - (ah->opmode != NL80211_IFTYPE_ADHOC)))
4760 + * RSSI is not available for subframes in an A-MPDU.
4762 + if (rx_stats->rs_moreaggr) {
4763 + rxs->flag |= RX_FLAG_NO_SIGNAL_VAL;
4766 - if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr)
4767 - ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
4769 - last_rssi = sc->last_rssi;
4770 - if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
4771 - rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
4775 - /* Update Beacon RSSI, this is used by ANI. */
4776 - ah->stats.avgbrssi = rssi;
4780 - * For Decrypt or Demic errors, we only mark packet status here and always push
4781 - * up the frame up to let mac80211 handle the actual error case, be it no
4782 - * decryption key or real decryption error. This let us keep statistics there.
4784 -static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
4785 - struct ieee80211_hdr *hdr,
4786 - struct ath_rx_status *rx_stats,
4787 - struct ieee80211_rx_status *rx_status,
4788 - bool *decrypt_error)
4790 - struct ieee80211_hw *hw = sc->hw;
4791 - struct ath_hw *ah = sc->sc_ah;
4792 - struct ath_common *common = ath9k_hw_common(ah);
4793 - bool discard_current = sc->rx.discard_next;
4795 - sc->rx.discard_next = rx_stats->rs_more;
4796 - if (discard_current)
4801 - * everything but the rate is checked here, the rate check is done
4802 - * separately to avoid doing two lookups for a rate for each frame.
4803 + * Check if the RSSI for the last subframe in an A-MPDU
4804 + * or an unaggregated frame is valid.
4806 - if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error))
4809 - /* Only use status info from the last fragment */
4810 - if (rx_stats->rs_more)
4812 + if (rx_stats->rs_rssi == ATH9K_RSSI_BAD) {
4813 + rxs->flag |= RX_FLAG_NO_SIGNAL_VAL;
4817 - if (ath9k_process_rate(common, hw, rx_stats, rx_status))
4820 + * Update Beacon RSSI, this is used by ANI.
4822 + if (rx_stats->is_mybeacon &&
4823 + ((ah->opmode == NL80211_IFTYPE_STATION) ||
4824 + (ah->opmode == NL80211_IFTYPE_ADHOC))) {
4825 + ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
4826 + last_rssi = sc->last_rssi;
4828 - ath9k_process_rssi(common, hw, hdr, rx_stats);
4829 + if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
4830 + rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
4834 - rx_status->band = hw->conf.chandef.chan->band;
4835 - rx_status->freq = hw->conf.chandef.chan->center_freq;
4836 - rx_status->signal = ah->noise + rx_stats->rs_rssi;
4837 - rx_status->antenna = rx_stats->rs_antenna;
4838 - rx_status->flag |= RX_FLAG_MACTIME_END;
4839 - if (rx_stats->rs_moreaggr)
4840 - rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
4841 + ah->stats.avgbrssi = rssi;
4844 - sc->rx.discard_next = false;
4846 + rxs->signal = ah->noise + rx_stats->rs_rssi;
4849 -static void ath9k_rx_skb_postprocess(struct ath_common *common,
4850 - struct sk_buff *skb,
4851 - struct ath_rx_status *rx_stats,
4852 - struct ieee80211_rx_status *rxs,
4853 - bool decrypt_error)
4854 +static void ath9k_process_tsf(struct ath_rx_status *rs,
4855 + struct ieee80211_rx_status *rxs,
4858 - struct ath_hw *ah = common->ah;
4859 - struct ieee80211_hdr *hdr;
4860 - int hdrlen, padpos, padsize;
4863 + u32 tsf_lower = tsf & 0xffffffff;
4865 - /* see if any padding is done by the hw and remove it */
4866 - hdr = (struct ieee80211_hdr *) skb->data;
4867 - hdrlen = ieee80211_get_hdrlen_from_skb(skb);
4868 - fc = hdr->frame_control;
4869 - padpos = ieee80211_hdrlen(fc);
4870 + rxs->mactime = (tsf & ~0xffffffffULL) | rs->rs_tstamp;
4871 + if (rs->rs_tstamp > tsf_lower &&
4872 + unlikely(rs->rs_tstamp - tsf_lower > 0x10000000))
4873 + rxs->mactime -= 0x100000000ULL;
4875 - /* The MAC header is padded to have 32-bit boundary if the
4876 - * packet payload is non-zero. The general calculation for
4877 - * padsize would take into account odd header lengths:
4878 - * padsize = (4 - padpos % 4) % 4; However, since only
4879 - * even-length headers are used, padding can only be 0 or 2
4880 - * bytes and we can optimize this a bit. In addition, we must
4881 - * not try to remove padding from short control frames that do
4882 - * not have payload. */
4883 - padsize = padpos & 3;
4884 - if (padsize && skb->len>=padpos+padsize+FCS_LEN) {
4885 - memmove(skb->data + padsize, skb->data, padpos);
4886 - skb_pull(skb, padsize);
4889 - keyix = rx_stats->rs_keyix;
4891 - if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error &&
4892 - ieee80211_has_protected(fc)) {
4893 - rxs->flag |= RX_FLAG_DECRYPTED;
4894 - } else if (ieee80211_has_protected(fc)
4895 - && !decrypt_error && skb->len >= hdrlen + 4) {
4896 - keyix = skb->data[hdrlen + 3] >> 6;
4898 - if (test_bit(keyix, common->keymap))
4899 - rxs->flag |= RX_FLAG_DECRYPTED;
4901 - if (ah->sw_mgmt_crypto &&
4902 - (rxs->flag & RX_FLAG_DECRYPTED) &&
4903 - ieee80211_is_mgmt(fc))
4904 - /* Use software decrypt for management frames. */
4905 - rxs->flag &= ~RX_FLAG_DECRYPTED;
4906 + if (rs->rs_tstamp < tsf_lower &&
4907 + unlikely(tsf_lower - rs->rs_tstamp > 0x10000000))
4908 + rxs->mactime += 0x100000000ULL;
4911 #ifdef CPTCFG_ATH9K_DEBUGFS
4912 @@ -1133,6 +1056,234 @@ static int ath_process_fft(struct ath_so
4916 +static bool ath9k_is_mybeacon(struct ath_softc *sc, struct ieee80211_hdr *hdr)
4918 + struct ath_hw *ah = sc->sc_ah;
4919 + struct ath_common *common = ath9k_hw_common(ah);
4921 + if (ieee80211_is_beacon(hdr->frame_control)) {
4922 + RX_STAT_INC(rx_beacons);
4923 + if (!is_zero_ether_addr(common->curbssid) &&
4924 + ether_addr_equal(hdr->addr3, common->curbssid))
4932 + * For Decrypt or Demic errors, we only mark packet status here and always push
4933 + * up the frame up to let mac80211 handle the actual error case, be it no
4934 + * decryption key or real decryption error. This let us keep statistics there.
4936 +static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
4937 + struct sk_buff *skb,
4938 + struct ath_rx_status *rx_stats,
4939 + struct ieee80211_rx_status *rx_status,
4940 + bool *decrypt_error, u64 tsf)
4942 + struct ieee80211_hw *hw = sc->hw;
4943 + struct ath_hw *ah = sc->sc_ah;
4944 + struct ath_common *common = ath9k_hw_common(ah);
4945 + struct ieee80211_hdr *hdr;
4946 + bool discard_current = sc->rx.discard_next;
4950 + * Discard corrupt descriptors which are marked in
4951 + * ath_get_next_rx_buf().
4953 + sc->rx.discard_next = rx_stats->rs_more;
4954 + if (discard_current)
4958 + * Discard zero-length packets.
4960 + if (!rx_stats->rs_datalen) {
4961 + RX_STAT_INC(rx_len_err);
4966 + * rs_status follows rs_datalen so if rs_datalen is too large
4967 + * we can take a hint that hardware corrupted it, so ignore
4970 + if (rx_stats->rs_datalen > (common->rx_bufsize - ah->caps.rx_status_len)) {
4971 + RX_STAT_INC(rx_len_err);
4975 + /* Only use status info from the last fragment */
4976 + if (rx_stats->rs_more)
4980 + * Return immediately if the RX descriptor has been marked
4981 + * as corrupt based on the various error bits.
4983 + * This is different from the other corrupt descriptor
4984 + * condition handled above.
4986 + if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC) {
4991 + hdr = (struct ieee80211_hdr *) (skb->data + ah->caps.rx_status_len);
4993 + ath9k_process_tsf(rx_stats, rx_status, tsf);
4994 + ath_debug_stat_rx(sc, rx_stats);
4997 + * Process PHY errors and return so that the packet
5000 + if (rx_stats->rs_status & ATH9K_RXERR_PHY) {
5001 + ath9k_dfs_process_phyerr(sc, hdr, rx_stats, rx_status->mactime);
5002 + if (ath_process_fft(sc, hdr, rx_stats, rx_status->mactime))
5003 + RX_STAT_INC(rx_spectral);
5010 + * everything but the rate is checked here, the rate check is done
5011 + * separately to avoid doing two lookups for a rate for each frame.
5013 + if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error)) {
5018 + rx_stats->is_mybeacon = ath9k_is_mybeacon(sc, hdr);
5019 + if (rx_stats->is_mybeacon) {
5020 + sc->hw_busy_count = 0;
5021 + ath_start_rx_poll(sc, 3);
5024 + if (ath9k_process_rate(common, hw, rx_stats, rx_status)) {
5029 + ath9k_process_rssi(common, hw, rx_stats, rx_status);
5031 + rx_status->band = hw->conf.chandef.chan->band;
5032 + rx_status->freq = hw->conf.chandef.chan->center_freq;
5033 + rx_status->antenna = rx_stats->rs_antenna;
5034 + rx_status->flag |= RX_FLAG_MACTIME_END;
5036 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
5037 + if (ieee80211_is_data_present(hdr->frame_control) &&
5038 + !ieee80211_is_qos_nullfunc(hdr->frame_control))
5039 + sc->rx.num_pkts++;
5043 + sc->rx.discard_next = false;
5047 +static void ath9k_rx_skb_postprocess(struct ath_common *common,
5048 + struct sk_buff *skb,
5049 + struct ath_rx_status *rx_stats,
5050 + struct ieee80211_rx_status *rxs,
5051 + bool decrypt_error)
5053 + struct ath_hw *ah = common->ah;
5054 + struct ieee80211_hdr *hdr;
5055 + int hdrlen, padpos, padsize;
5059 + /* see if any padding is done by the hw and remove it */
5060 + hdr = (struct ieee80211_hdr *) skb->data;
5061 + hdrlen = ieee80211_get_hdrlen_from_skb(skb);
5062 + fc = hdr->frame_control;
5063 + padpos = ieee80211_hdrlen(fc);
5065 + /* The MAC header is padded to have 32-bit boundary if the
5066 + * packet payload is non-zero. The general calculation for
5067 + * padsize would take into account odd header lengths:
5068 + * padsize = (4 - padpos % 4) % 4; However, since only
5069 + * even-length headers are used, padding can only be 0 or 2
5070 + * bytes and we can optimize this a bit. In addition, we must
5071 + * not try to remove padding from short control frames that do
5072 + * not have payload. */
5073 + padsize = padpos & 3;
5074 + if (padsize && skb->len>=padpos+padsize+FCS_LEN) {
5075 + memmove(skb->data + padsize, skb->data, padpos);
5076 + skb_pull(skb, padsize);
5079 + keyix = rx_stats->rs_keyix;
5081 + if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error &&
5082 + ieee80211_has_protected(fc)) {
5083 + rxs->flag |= RX_FLAG_DECRYPTED;
5084 + } else if (ieee80211_has_protected(fc)
5085 + && !decrypt_error && skb->len >= hdrlen + 4) {
5086 + keyix = skb->data[hdrlen + 3] >> 6;
5088 + if (test_bit(keyix, common->keymap))
5089 + rxs->flag |= RX_FLAG_DECRYPTED;
5091 + if (ah->sw_mgmt_crypto &&
5092 + (rxs->flag & RX_FLAG_DECRYPTED) &&
5093 + ieee80211_is_mgmt(fc))
5094 + /* Use software decrypt for management frames. */
5095 + rxs->flag &= ~RX_FLAG_DECRYPTED;
5099 + * Run the LNA combining algorithm only in these cases:
5101 + * Standalone WLAN cards with both LNA/Antenna diversity
5102 + * enabled in the EEPROM.
5104 + * WLAN+BT cards which are in the supported card list
5105 + * in ath_pci_id_table and the user has loaded the
5106 + * driver with "bt_ant_diversity" set to true.
5108 +static void ath9k_antenna_check(struct ath_softc *sc,
5109 + struct ath_rx_status *rs)
5111 + struct ath_hw *ah = sc->sc_ah;
5112 + struct ath9k_hw_capabilities *pCap = &ah->caps;
5113 + struct ath_common *common = ath9k_hw_common(ah);
5115 + if (!(ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB))
5119 + * All MPDUs in an aggregate will use the same LNA
5120 + * as the first MPDU.
5122 + if (rs->rs_isaggr && !rs->rs_firstaggr)
5126 + * Change the default rx antenna if rx diversity
5127 + * chooses the other antenna 3 times in a row.
5129 + if (sc->rx.defant != rs->rs_antenna) {
5130 + if (++sc->rx.rxotherant >= 3)
5131 + ath_setdefantenna(sc, rs->rs_antenna);
5133 + sc->rx.rxotherant = 0;
5136 + if (pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV) {
5137 + if (common->bt_ant_diversity)
5138 + ath_ant_comb_scan(sc, rs);
5140 + ath_ant_comb_scan(sc, rs);
5144 static void ath9k_apply_ampdu_details(struct ath_softc *sc,
5145 struct ath_rx_status *rs, struct ieee80211_rx_status *rxs)
5147 @@ -1153,21 +1304,18 @@ static void ath9k_apply_ampdu_details(st
5149 int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
5151 - struct ath_buf *bf;
5152 + struct ath_rxbuf *bf;
5153 struct sk_buff *skb = NULL, *requeue_skb, *hdr_skb;
5154 struct ieee80211_rx_status *rxs;
5155 struct ath_hw *ah = sc->sc_ah;
5156 struct ath_common *common = ath9k_hw_common(ah);
5157 struct ieee80211_hw *hw = sc->hw;
5158 - struct ieee80211_hdr *hdr;
5160 struct ath_rx_status rs;
5161 enum ath9k_rx_qtype qtype;
5162 bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
5164 - u8 rx_status_len = ah->caps.rx_status_len;
5166 - u32 tsf_lower = 0;
5167 unsigned long flags;
5168 dma_addr_t new_buf_addr;
5170 @@ -1179,7 +1327,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
5171 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP;
5173 tsf = ath9k_hw_gettsf64(ah);
5174 - tsf_lower = tsf & 0xffffffff;
5177 bool decrypt_error = false;
5178 @@ -1206,55 +1353,14 @@ int ath_rx_tasklet(struct ath_softc *sc,
5182 - hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len);
5183 rxs = IEEE80211_SKB_RXCB(hdr_skb);
5184 - if (ieee80211_is_beacon(hdr->frame_control)) {
5185 - RX_STAT_INC(rx_beacons);
5186 - if (!is_zero_ether_addr(common->curbssid) &&
5187 - ether_addr_equal(hdr->addr3, common->curbssid))
5188 - rs.is_mybeacon = true;
5190 - rs.is_mybeacon = false;
5193 - rs.is_mybeacon = false;
5195 - if (ieee80211_is_data_present(hdr->frame_control) &&
5196 - !ieee80211_is_qos_nullfunc(hdr->frame_control))
5197 - sc->rx.num_pkts++;
5199 - ath_debug_stat_rx(sc, &rs);
5201 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
5203 - rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
5204 - if (rs.rs_tstamp > tsf_lower &&
5205 - unlikely(rs.rs_tstamp - tsf_lower > 0x10000000))
5206 - rxs->mactime -= 0x100000000ULL;
5208 - if (rs.rs_tstamp < tsf_lower &&
5209 - unlikely(tsf_lower - rs.rs_tstamp > 0x10000000))
5210 - rxs->mactime += 0x100000000ULL;
5212 - if (rs.rs_phyerr == ATH9K_PHYERR_RADAR)
5213 - ath9k_dfs_process_phyerr(sc, hdr, &rs, rxs->mactime);
5215 - if (rs.rs_status & ATH9K_RXERR_PHY) {
5216 - if (ath_process_fft(sc, hdr, &rs, rxs->mactime)) {
5217 - RX_STAT_INC(rx_spectral);
5218 - goto requeue_drop_frag;
5222 - retval = ath9k_rx_skb_preprocess(sc, hdr, &rs, rxs,
5224 + retval = ath9k_rx_skb_preprocess(sc, hdr_skb, &rs, rxs,
5225 + &decrypt_error, tsf);
5227 goto requeue_drop_frag;
5229 - if (rs.is_mybeacon) {
5230 - sc->hw_busy_count = 0;
5231 - ath_start_rx_poll(sc, 3);
5233 /* Ensure we always have an skb to requeue once we are done
5234 * processing the current buffer's skb */
5235 requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC);
5236 @@ -1308,8 +1414,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
5240 - if (rs.rs_status & ATH9K_RXERR_CORRUPT_DESC)
5241 - goto requeue_drop_frag;
5244 int space = skb->len - skb_tailroom(hdr_skb);
5245 @@ -1328,22 +1432,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
5250 - if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
5253 - * change the default rx antenna if rx diversity
5254 - * chooses the other antenna 3 times in a row.
5256 - if (sc->rx.defant != rs.rs_antenna) {
5257 - if (++sc->rx.rxotherant >= 3)
5258 - ath_setdefantenna(sc, rs.rs_antenna);
5260 - sc->rx.rxotherant = 0;
5265 if (rxs->flag & RX_FLAG_MMIC_STRIPPED)
5266 skb_trim(skb, skb->len - 8);
5268 @@ -1355,8 +1443,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
5269 ath_rx_ps(sc, skb, rs.is_mybeacon);
5270 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
5272 - if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx == 3)
5273 - ath_ant_comb_scan(sc, &rs);
5274 + ath9k_antenna_check(sc, &rs);
5276 ath9k_apply_ampdu_details(sc, &rs, rxs);
5278 @@ -1375,7 +1462,7 @@ requeue:
5280 ath_rx_edma_buf_link(sc, qtype);
5282 - ath_rx_buf_link(sc, bf);
5283 + ath_rx_buf_relink(sc, bf);
5287 --- a/drivers/net/wireless/ath/ath9k/init.c
5288 +++ b/drivers/net/wireless/ath/ath9k/init.c
5289 @@ -53,9 +53,9 @@ static int ath9k_btcoex_enable;
5290 module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444);
5291 MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence");
5293 -static int ath9k_enable_diversity;
5294 -module_param_named(enable_diversity, ath9k_enable_diversity, int, 0444);
5295 -MODULE_PARM_DESC(enable_diversity, "Enable Antenna diversity for AR9565");
5296 +static int ath9k_bt_ant_diversity;
5297 +module_param_named(bt_ant_diversity, ath9k_bt_ant_diversity, int, 0444);
5298 +MODULE_PARM_DESC(bt_ant_diversity, "Enable WLAN/BT RX antenna diversity");
5300 bool is_ath9k_unloaded;
5301 /* We use the hw_value as an index into our private channel structure */
5302 @@ -339,7 +339,6 @@ int ath_descdma_setup(struct ath_softc *
5304 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
5306 - struct ath_buf *bf;
5307 int i, bsize, desc_len;
5309 ath_dbg(common, CONFIG, "%s DMA: %u buffers %u desc/buf\n",
5310 @@ -391,33 +390,68 @@ int ath_descdma_setup(struct ath_softc *
5311 ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len);
5313 /* allocate buffers */
5314 - bsize = sizeof(struct ath_buf) * nbuf;
5315 - bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL);
5319 + struct ath_buf *bf;
5321 + bsize = sizeof(struct ath_buf) * nbuf;
5322 + bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL);
5326 + for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) {
5328 + bf->bf_daddr = DS2PHYS(dd, ds);
5330 + if (!(sc->sc_ah->caps.hw_caps &
5331 + ATH9K_HW_CAP_4KB_SPLITTRANS)) {
5333 + * Skip descriptor addresses which can cause 4KB
5334 + * boundary crossing (addr + length) with a 32 dword
5335 + * descriptor fetch.
5337 + while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) {
5338 + BUG_ON((caddr_t) bf->bf_desc >=
5339 + ((caddr_t) dd->dd_desc +
5340 + dd->dd_desc_len));
5342 + ds += (desc_len * ndesc);
5344 + bf->bf_daddr = DS2PHYS(dd, ds);
5347 + list_add_tail(&bf->list, head);
5350 + struct ath_rxbuf *bf;
5352 - for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) {
5354 - bf->bf_daddr = DS2PHYS(dd, ds);
5356 - if (!(sc->sc_ah->caps.hw_caps &
5357 - ATH9K_HW_CAP_4KB_SPLITTRANS)) {
5359 - * Skip descriptor addresses which can cause 4KB
5360 - * boundary crossing (addr + length) with a 32 dword
5361 - * descriptor fetch.
5363 - while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) {
5364 - BUG_ON((caddr_t) bf->bf_desc >=
5365 - ((caddr_t) dd->dd_desc +
5366 - dd->dd_desc_len));
5368 - ds += (desc_len * ndesc);
5370 - bf->bf_daddr = DS2PHYS(dd, ds);
5371 + bsize = sizeof(struct ath_buf) * nbuf;
5372 + bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL);
5376 + for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) {
5378 + bf->bf_daddr = DS2PHYS(dd, ds);
5380 + if (!(sc->sc_ah->caps.hw_caps &
5381 + ATH9K_HW_CAP_4KB_SPLITTRANS)) {
5383 + * Skip descriptor addresses which can cause 4KB
5384 + * boundary crossing (addr + length) with a 32 dword
5385 + * descriptor fetch.
5387 + while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) {
5388 + BUG_ON((caddr_t) bf->bf_desc >=
5389 + ((caddr_t) dd->dd_desc +
5390 + dd->dd_desc_len));
5392 + ds += (desc_len * ndesc);
5394 + bf->bf_daddr = DS2PHYS(dd, ds);
5397 + list_add_tail(&bf->list, head);
5399 - list_add_tail(&bf->list, head);
5403 @@ -429,7 +463,6 @@ static int ath9k_init_queues(struct ath_
5404 sc->beacon.beaconq = ath9k_hw_beaconq_setup(sc->sc_ah);
5405 sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0);
5407 - sc->config.cabqReadytime = ATH_CABQ_READY_TIME;
5408 ath_cabq_update(sc);
5410 sc->tx.uapsdq = ath_txq_setup(sc, ATH9K_TX_QUEUE_UAPSD, 0);
5411 @@ -516,6 +549,7 @@ static void ath9k_init_misc(struct ath_s
5412 static void ath9k_init_platform(struct ath_softc *sc)
5414 struct ath_hw *ah = sc->sc_ah;
5415 + struct ath9k_hw_capabilities *pCap = &ah->caps;
5416 struct ath_common *common = ath9k_hw_common(ah);
5418 if (common->bus_ops->ath_bus_type != ATH_PCI)
5419 @@ -525,12 +559,27 @@ static void ath9k_init_platform(struct a
5420 ATH9K_PCI_CUS230)) {
5421 ah->config.xlna_gpio = 9;
5422 ah->config.xatten_margin_cfg = true;
5423 + ah->config.alt_mingainidx = true;
5424 + ah->config.ant_ctrl_comm2g_switch_enable = 0x000BBB88;
5425 + sc->ant_comb.low_rssi_thresh = 20;
5426 + sc->ant_comb.fast_div_bias = 3;
5428 ath_info(common, "Set parameters for %s\n",
5429 (sc->driver_data & ATH9K_PCI_CUS198) ?
5430 "CUS198" : "CUS230");
5431 - } else if (sc->driver_data & ATH9K_PCI_CUS217) {
5434 + if (sc->driver_data & ATH9K_PCI_CUS217)
5435 ath_info(common, "CUS217 card detected\n");
5437 + if (sc->driver_data & ATH9K_PCI_BT_ANT_DIV) {
5438 + pCap->hw_caps |= ATH9K_HW_CAP_BT_ANT_DIV;
5439 + ath_info(common, "Set BT/WLAN RX diversity capability\n");
5442 + if (sc->driver_data & ATH9K_PCI_D3_L1_WAR) {
5443 + ah->config.pcie_waen = 0x0040473b;
5444 + ath_info(common, "Enable WAR for ASPM D3/L1\n");
5448 @@ -584,6 +633,7 @@ static int ath9k_init_softc(u16 devid, s
5450 struct ath9k_platform_data *pdata = sc->dev->platform_data;
5451 struct ath_hw *ah = NULL;
5452 + struct ath9k_hw_capabilities *pCap;
5453 struct ath_common *common;
5456 @@ -600,6 +650,7 @@ static int ath9k_init_softc(u16 devid, s
5457 ah->reg_ops.rmw = ath9k_reg_rmw;
5458 atomic_set(&ah->intr_ref_cnt, -1);
5462 sc->dfs_detector = dfs_pattern_detector_init(ah, NL80211_DFS_UNSET);
5464 @@ -631,11 +682,15 @@ static int ath9k_init_softc(u16 devid, s
5465 ath9k_init_platform(sc);
5468 - * Enable Antenna diversity only when BTCOEX is disabled
5469 - * and the user manually requests the feature.
5470 + * Enable WLAN/BT RX Antenna diversity only when:
5472 + * - BTCOEX is disabled.
5473 + * - the user manually requests the feature.
5474 + * - the HW cap is set using the platform data.
5476 - if (!common->btcoex_enabled && ath9k_enable_diversity)
5477 - common->antenna_diversity = 1;
5478 + if (!common->btcoex_enabled && ath9k_bt_ant_diversity &&
5479 + (pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV))
5480 + common->bt_ant_diversity = 1;
5482 spin_lock_init(&common->cc_lock);
5484 @@ -710,13 +765,15 @@ static void ath9k_init_band_txpower(stru
5485 struct ieee80211_supported_band *sband;
5486 struct ieee80211_channel *chan;
5487 struct ath_hw *ah = sc->sc_ah;
5488 + struct cfg80211_chan_def chandef;
5491 sband = &sc->sbands[band];
5492 for (i = 0; i < sband->n_channels; i++) {
5493 chan = &sband->channels[i];
5494 ah->curchan = &ah->channels[chan->hw_value];
5495 - ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20);
5496 + cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_HT20);
5497 + ath9k_cmn_get_channel(sc->hw, ah, &chandef);
5498 ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true);
5501 @@ -802,7 +859,8 @@ void ath9k_set_hw_capab(struct ath_softc
5502 IEEE80211_HW_PS_NULLFUNC_STACK |
5503 IEEE80211_HW_SPECTRUM_MGMT |
5504 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
5505 - IEEE80211_HW_SUPPORTS_RC_TABLE;
5506 + IEEE80211_HW_SUPPORTS_RC_TABLE |
5507 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
5509 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
5510 hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION;
5511 --- a/drivers/net/wireless/ath/carl9170/main.c
5512 +++ b/drivers/net/wireless/ath/carl9170/main.c
5513 @@ -1878,7 +1878,8 @@ void *carl9170_alloc(size_t priv_size)
5514 IEEE80211_HW_PS_NULLFUNC_STACK |
5515 IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC |
5516 IEEE80211_HW_SUPPORTS_RC_TABLE |
5517 - IEEE80211_HW_SIGNAL_DBM;
5518 + IEEE80211_HW_SIGNAL_DBM |
5519 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
5521 if (!modparam_noht) {
5523 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
5524 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
5525 @@ -6133,7 +6133,8 @@ static int rt2800_probe_hw_mode(struct r
5526 IEEE80211_HW_SUPPORTS_PS |
5527 IEEE80211_HW_PS_NULLFUNC_STACK |
5528 IEEE80211_HW_AMPDU_AGGREGATION |
5529 - IEEE80211_HW_REPORTS_TX_ACK_STATUS;
5530 + IEEE80211_HW_REPORTS_TX_ACK_STATUS |
5531 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
5534 * Don't set IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING for USB devices
5535 --- a/include/net/mac80211.h
5536 +++ b/include/net/mac80211.h
5537 @@ -152,11 +152,14 @@ struct ieee80211_low_level_stats {
5538 * @IEEE80211_CHANCTX_CHANGE_WIDTH: The channel width changed
5539 * @IEEE80211_CHANCTX_CHANGE_RX_CHAINS: The number of RX chains changed
5540 * @IEEE80211_CHANCTX_CHANGE_RADAR: radar detection flag changed
5541 + * @IEEE80211_CHANCTX_CHANGE_CHANNEL: switched to another operating channel,
5542 + * this is used only with channel switching with CSA
5544 enum ieee80211_chanctx_change {
5545 IEEE80211_CHANCTX_CHANGE_WIDTH = BIT(0),
5546 IEEE80211_CHANCTX_CHANGE_RX_CHAINS = BIT(1),
5547 IEEE80211_CHANCTX_CHANGE_RADAR = BIT(2),
5548 + IEEE80211_CHANCTX_CHANGE_CHANNEL = BIT(3),
5552 @@ -1080,6 +1083,7 @@ enum ieee80211_vif_flags {
5553 * @addr: address of this interface
5554 * @p2p: indicates whether this AP or STA interface is a p2p
5555 * interface, i.e. a GO or p2p-sta respectively
5556 + * @csa_active: marks whether a channel switch is going on
5557 * @driver_flags: flags/capabilities the driver has for this interface,
5558 * these need to be set (or cleared) when the interface is added
5559 * or, if supported by the driver, the interface type is changed
5560 @@ -1102,6 +1106,7 @@ struct ieee80211_vif {
5561 struct ieee80211_bss_conf bss_conf;
5567 u8 hw_queue[IEEE80211_NUM_ACS];
5568 @@ -1499,6 +1504,7 @@ enum ieee80211_hw_flags {
5569 IEEE80211_HW_SUPPORTS_RC_TABLE = 1<<24,
5570 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25,
5571 IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26,
5572 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES = 1<<27,
5576 @@ -2633,6 +2639,16 @@ enum ieee80211_roc_type {
5577 * @ipv6_addr_change: IPv6 address assignment on the given interface changed.
5578 * Currently, this is only called for managed or P2P client interfaces.
5579 * This callback is optional; it must not sleep.
5581 + * @channel_switch_beacon: Starts a channel switch to a new channel.
5582 + * Beacons are modified to include CSA or ECSA IEs before calling this
5583 + * function. The corresponding count fields in these IEs must be
5584 + * decremented, and when they reach zero the driver must call
5585 + * ieee80211_csa_finish(). Drivers which use ieee80211_beacon_get()
5586 + * get the csa counter decremented by mac80211, but must check if it is
5587 + * zero using ieee80211_csa_is_complete() after the beacon has been
5588 + * transmitted and then call ieee80211_csa_finish().
5591 struct ieee80211_ops {
5592 void (*tx)(struct ieee80211_hw *hw,
5593 @@ -2830,6 +2846,9 @@ struct ieee80211_ops {
5594 struct ieee80211_vif *vif,
5595 struct inet6_dev *idev);
5597 + void (*channel_switch_beacon)(struct ieee80211_hw *hw,
5598 + struct ieee80211_vif *vif,
5599 + struct cfg80211_chan_def *chandef);
5603 @@ -3325,6 +3344,25 @@ static inline struct sk_buff *ieee80211_
5607 + * ieee80211_csa_finish - notify mac80211 about channel switch
5608 + * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5610 + * After a channel switch announcement was scheduled and the counter in this
5611 + * announcement hit zero, this function must be called by the driver to
5612 + * notify mac80211 that the channel can be changed.
5614 +void ieee80211_csa_finish(struct ieee80211_vif *vif);
5617 + * ieee80211_csa_is_complete - find out if counters reached zero
5618 + * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5620 + * This function returns whether the channel switch counters reached zero.
5622 +bool ieee80211_csa_is_complete(struct ieee80211_vif *vif);
5626 * ieee80211_proberesp_get - retrieve a Probe Response template
5627 * @hw: pointer obtained from ieee80211_alloc_hw().
5628 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5629 --- a/net/mac80211/cfg.c
5630 +++ b/net/mac80211/cfg.c
5631 @@ -854,8 +854,8 @@ static int ieee80211_set_probe_resp(stru
5635 -static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
5636 - struct cfg80211_beacon_data *params)
5637 +int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
5638 + struct cfg80211_beacon_data *params)
5640 struct beacon_data *new, *old;
5641 int new_head_len, new_tail_len;
5642 @@ -1018,6 +1018,12 @@ static int ieee80211_change_beacon(struc
5644 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
5646 + /* don't allow changing the beacon while CSA is in place - offset
5647 + * of channel switch counter may change
5649 + if (sdata->vif.csa_active)
5652 old = rtnl_dereference(sdata->u.ap.beacon);
5655 @@ -1042,6 +1048,10 @@ static int ieee80211_stop_ap(struct wiph
5657 old_probe_resp = rtnl_dereference(sdata->u.ap.probe_resp);
5659 + /* abort any running channel switch */
5660 + sdata->vif.csa_active = false;
5661 + cancel_work_sync(&sdata->csa_finalize_work);
5663 /* turn off carrier for this interface and dependent VLANs */
5664 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
5665 netif_carrier_off(vlan->dev);
5666 @@ -2784,6 +2794,178 @@ static int ieee80211_start_radar_detecti
5670 +static struct cfg80211_beacon_data *
5671 +cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
5673 + struct cfg80211_beacon_data *new_beacon;
5677 + len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
5678 + beacon->proberesp_ies_len + beacon->assocresp_ies_len +
5679 + beacon->probe_resp_len;
5681 + new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
5685 + pos = (u8 *)(new_beacon + 1);
5686 + if (beacon->head_len) {
5687 + new_beacon->head_len = beacon->head_len;
5688 + new_beacon->head = pos;
5689 + memcpy(pos, beacon->head, beacon->head_len);
5690 + pos += beacon->head_len;
5692 + if (beacon->tail_len) {
5693 + new_beacon->tail_len = beacon->tail_len;
5694 + new_beacon->tail = pos;
5695 + memcpy(pos, beacon->tail, beacon->tail_len);
5696 + pos += beacon->tail_len;
5698 + if (beacon->beacon_ies_len) {
5699 + new_beacon->beacon_ies_len = beacon->beacon_ies_len;
5700 + new_beacon->beacon_ies = pos;
5701 + memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
5702 + pos += beacon->beacon_ies_len;
5704 + if (beacon->proberesp_ies_len) {
5705 + new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
5706 + new_beacon->proberesp_ies = pos;
5707 + memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
5708 + pos += beacon->proberesp_ies_len;
5710 + if (beacon->assocresp_ies_len) {
5711 + new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
5712 + new_beacon->assocresp_ies = pos;
5713 + memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
5714 + pos += beacon->assocresp_ies_len;
5716 + if (beacon->probe_resp_len) {
5717 + new_beacon->probe_resp_len = beacon->probe_resp_len;
5718 + beacon->probe_resp = pos;
5719 + memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
5720 + pos += beacon->probe_resp_len;
5723 + return new_beacon;
5726 +void ieee80211_csa_finalize_work(struct work_struct *work)
5728 + struct ieee80211_sub_if_data *sdata =
5729 + container_of(work, struct ieee80211_sub_if_data,
5730 + csa_finalize_work);
5731 + struct ieee80211_local *local = sdata->local;
5734 + if (!ieee80211_sdata_running(sdata))
5737 + if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP))
5740 + sdata->radar_required = sdata->csa_radar_required;
5741 + err = ieee80211_vif_change_channel(sdata, &local->csa_chandef,
5743 + if (WARN_ON(err < 0))
5746 + err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
5751 + kfree(sdata->u.ap.next_beacon);
5752 + sdata->u.ap.next_beacon = NULL;
5753 + sdata->vif.csa_active = false;
5755 + ieee80211_wake_queues_by_reason(&sdata->local->hw,
5756 + IEEE80211_MAX_QUEUE_MAP,
5757 + IEEE80211_QUEUE_STOP_REASON_CSA);
5759 + ieee80211_bss_info_change_notify(sdata, changed);
5761 + cfg80211_ch_switch_notify(sdata->dev, &local->csa_chandef);
5764 +static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
5765 + struct cfg80211_csa_settings *params)
5767 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
5768 + struct ieee80211_local *local = sdata->local;
5769 + struct ieee80211_chanctx_conf *chanctx_conf;
5770 + struct ieee80211_chanctx *chanctx;
5771 + int err, num_chanctx;
5773 + if (!list_empty(&local->roc_list) || local->scanning)
5776 + if (sdata->wdev.cac_started)
5779 + if (cfg80211_chandef_identical(¶ms->chandef,
5780 + &sdata->vif.bss_conf.chandef))
5784 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
5785 + if (!chanctx_conf) {
5786 + rcu_read_unlock();
5790 + /* don't handle for multi-VIF cases */
5791 + chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf);
5792 + if (chanctx->refcount > 1) {
5793 + rcu_read_unlock();
5797 + list_for_each_entry_rcu(chanctx, &local->chanctx_list, list)
5799 + rcu_read_unlock();
5801 + if (num_chanctx > 1)
5804 + /* don't allow another channel switch if one is already active. */
5805 + if (sdata->vif.csa_active)
5808 + /* only handle AP for now. */
5809 + switch (sdata->vif.type) {
5810 + case NL80211_IFTYPE_AP:
5813 + return -EOPNOTSUPP;
5816 + sdata->u.ap.next_beacon = cfg80211_beacon_dup(¶ms->beacon_after);
5817 + if (!sdata->u.ap.next_beacon)
5820 + sdata->csa_counter_offset_beacon = params->counter_offset_beacon;
5821 + sdata->csa_counter_offset_presp = params->counter_offset_presp;
5822 + sdata->csa_radar_required = params->radar_required;
5824 + if (params->block_tx)
5825 + ieee80211_stop_queues_by_reason(&local->hw,
5826 + IEEE80211_MAX_QUEUE_MAP,
5827 + IEEE80211_QUEUE_STOP_REASON_CSA);
5829 + err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa);
5833 + local->csa_chandef = params->chandef;
5834 + sdata->vif.csa_active = true;
5836 + ieee80211_bss_info_change_notify(sdata, err);
5837 + drv_channel_switch_beacon(sdata, ¶ms->chandef);
5842 static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
5843 struct ieee80211_channel *chan, bool offchan,
5844 unsigned int wait, const u8 *buf, size_t len,
5845 @@ -3332,7 +3514,7 @@ static int ieee80211_probe_client(struct
5848 band = chanctx_conf->def.chan->band;
5849 - sta = sta_info_get(sdata, peer);
5850 + sta = sta_info_get_bss(sdata, peer);
5852 qos = test_sta_flag(sta, WLAN_STA_WME);
5854 @@ -3501,4 +3683,5 @@ struct cfg80211_ops mac80211_config_ops
5855 .get_et_strings = ieee80211_get_et_strings,
5856 .get_channel = ieee80211_cfg_get_channel,
5857 .start_radar_detection = ieee80211_start_radar_detection,
5858 + .channel_switch = ieee80211_channel_switch,
5860 --- a/net/mac80211/chan.c
5861 +++ b/net/mac80211/chan.c
5862 @@ -410,6 +410,64 @@ int ieee80211_vif_use_channel(struct iee
5866 +int ieee80211_vif_change_channel(struct ieee80211_sub_if_data *sdata,
5867 + const struct cfg80211_chan_def *chandef,
5870 + struct ieee80211_local *local = sdata->local;
5871 + struct ieee80211_chanctx_conf *conf;
5872 + struct ieee80211_chanctx *ctx;
5874 + u32 chanctx_changed = 0;
5876 + /* should never be called if not performing a channel switch. */
5877 + if (WARN_ON(!sdata->vif.csa_active))
5880 + if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
5881 + IEEE80211_CHAN_DISABLED))
5884 + mutex_lock(&local->chanctx_mtx);
5885 + conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
5886 + lockdep_is_held(&local->chanctx_mtx));
5892 + ctx = container_of(conf, struct ieee80211_chanctx, conf);
5893 + if (ctx->refcount != 1) {
5898 + if (sdata->vif.bss_conf.chandef.width != chandef->width) {
5899 + chanctx_changed = IEEE80211_CHANCTX_CHANGE_WIDTH;
5900 + *changed |= BSS_CHANGED_BANDWIDTH;
5903 + sdata->vif.bss_conf.chandef = *chandef;
5904 + ctx->conf.def = *chandef;
5906 + chanctx_changed |= IEEE80211_CHANCTX_CHANGE_CHANNEL;
5907 + drv_change_chanctx(local, ctx, chanctx_changed);
5909 + if (!local->use_chanctx) {
5910 + local->_oper_chandef = *chandef;
5911 + ieee80211_hw_config(local, 0);
5914 + ieee80211_recalc_chanctx_chantype(local, ctx);
5915 + ieee80211_recalc_smps_chanctx(local, ctx);
5916 + ieee80211_recalc_radar_chanctx(local, ctx);
5920 + mutex_unlock(&local->chanctx_mtx);
5924 int ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
5925 const struct cfg80211_chan_def *chandef,
5927 --- a/net/mac80211/driver-ops.h
5928 +++ b/net/mac80211/driver-ops.h
5929 @@ -1104,4 +1104,17 @@ static inline void drv_ipv6_addr_change(
5934 +drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
5935 + struct cfg80211_chan_def *chandef)
5937 + struct ieee80211_local *local = sdata->local;
5939 + if (local->ops->channel_switch_beacon) {
5940 + trace_drv_channel_switch_beacon(local, sdata, chandef);
5941 + local->ops->channel_switch_beacon(&local->hw, &sdata->vif,
5946 #endif /* __MAC80211_DRIVER_OPS */
5947 --- a/net/mac80211/ieee80211_i.h
5948 +++ b/net/mac80211/ieee80211_i.h
5949 @@ -53,9 +53,6 @@ struct ieee80211_local;
5950 * increased memory use (about 2 kB of RAM per entry). */
5951 #define IEEE80211_FRAGMENT_MAX 4
5953 -#define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
5954 -#define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
5956 /* power level hasn't been configured (or set to automatic) */
5957 #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
5959 @@ -259,6 +256,8 @@ struct ieee80211_if_ap {
5960 struct beacon_data __rcu *beacon;
5961 struct probe_resp __rcu *probe_resp;
5963 + /* to be used after channel switch. */
5964 + struct cfg80211_beacon_data *next_beacon;
5965 struct list_head vlans;
5968 @@ -713,6 +712,11 @@ struct ieee80211_sub_if_data {
5970 struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
5972 + struct work_struct csa_finalize_work;
5973 + int csa_counter_offset_beacon;
5974 + int csa_counter_offset_presp;
5975 + bool csa_radar_required;
5977 /* used to reconfigure hardware SM PS */
5978 struct work_struct recalc_smps;
5980 @@ -1346,6 +1350,9 @@ void ieee80211_roc_notify_destroy(struct
5981 void ieee80211_sw_roc_work(struct work_struct *work);
5982 void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
5984 +/* channel switch handling */
5985 +void ieee80211_csa_finalize_work(struct work_struct *work);
5987 /* interface handling */
5988 int ieee80211_iface_init(void);
5989 void ieee80211_iface_exit(void);
5990 @@ -1367,6 +1374,8 @@ void ieee80211_del_virtual_monitor(struc
5992 bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
5993 void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
5994 +int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
5995 + struct cfg80211_beacon_data *params);
5997 static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
5999 @@ -1627,6 +1636,11 @@ int __must_check
6000 ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
6001 const struct cfg80211_chan_def *chandef,
6003 +/* NOTE: only use ieee80211_vif_change_channel() for channel switch */
6005 +ieee80211_vif_change_channel(struct ieee80211_sub_if_data *sdata,
6006 + const struct cfg80211_chan_def *chandef,
6008 void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
6009 void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
6010 void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
6011 --- a/net/mac80211/trace.h
6012 +++ b/net/mac80211/trace.h
6013 @@ -1906,6 +1906,32 @@ TRACE_EVENT(api_radar_detected,
6017 +TRACE_EVENT(drv_channel_switch_beacon,
6018 + TP_PROTO(struct ieee80211_local *local,
6019 + struct ieee80211_sub_if_data *sdata,
6020 + struct cfg80211_chan_def *chandef),
6022 + TP_ARGS(local, sdata, chandef),
6033 + CHANDEF_ASSIGN(chandef);
6037 + LOCAL_PR_FMT VIF_PR_FMT " channel switch to " CHANDEF_PR_FMT,
6038 + LOCAL_PR_ARG, VIF_PR_ARG, CHANDEF_PR_ARG
6043 #ifdef CPTCFG_MAC80211_MESSAGE_TRACING
6045 #define TRACE_SYSTEM mac80211_msg
6046 --- a/net/mac80211/tx.c
6047 +++ b/net/mac80211/tx.c
6048 @@ -1101,7 +1101,8 @@ ieee80211_tx_prepare(struct ieee80211_su
6049 tx->sta = rcu_dereference(sdata->u.vlan.sta);
6050 if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr)
6052 - } else if (info->flags & IEEE80211_TX_CTL_INJECTED ||
6053 + } else if (info->flags & (IEEE80211_TX_CTL_INJECTED |
6054 + IEEE80211_TX_INTFL_NL80211_FRAME_TX) ||
6055 tx->sdata->control_port_protocol == tx->skb->protocol) {
6056 tx->sta = sta_info_get_bss(sdata, hdr->addr1);
6058 @@ -2326,6 +2327,81 @@ static int ieee80211_beacon_add_tim(stru
6062 +void ieee80211_csa_finish(struct ieee80211_vif *vif)
6064 + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
6066 + ieee80211_queue_work(&sdata->local->hw,
6067 + &sdata->csa_finalize_work);
6069 +EXPORT_SYMBOL(ieee80211_csa_finish);
6071 +static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata,
6072 + struct beacon_data *beacon)
6074 + struct probe_resp *resp;
6075 + int counter_offset_beacon = sdata->csa_counter_offset_beacon;
6076 + int counter_offset_presp = sdata->csa_counter_offset_presp;
6078 + /* warn if the driver did not check for/react to csa completeness */
6079 + if (WARN_ON(((u8 *)beacon->tail)[counter_offset_beacon] == 0))
6082 + ((u8 *)beacon->tail)[counter_offset_beacon]--;
6084 + if (sdata->vif.type == NL80211_IFTYPE_AP &&
6085 + counter_offset_presp) {
6087 + resp = rcu_dereference(sdata->u.ap.probe_resp);
6089 + /* if nl80211 accepted the offset, this should not happen. */
6090 + if (WARN_ON(!resp)) {
6091 + rcu_read_unlock();
6094 + resp->data[counter_offset_presp]--;
6095 + rcu_read_unlock();
6099 +bool ieee80211_csa_is_complete(struct ieee80211_vif *vif)
6101 + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
6102 + struct beacon_data *beacon = NULL;
6104 + size_t beacon_data_len;
6105 + int counter_beacon = sdata->csa_counter_offset_beacon;
6108 + if (!ieee80211_sdata_running(sdata))
6112 + if (vif->type == NL80211_IFTYPE_AP) {
6113 + struct ieee80211_if_ap *ap = &sdata->u.ap;
6115 + beacon = rcu_dereference(ap->beacon);
6116 + if (WARN_ON(!beacon || !beacon->tail))
6118 + beacon_data = beacon->tail;
6119 + beacon_data_len = beacon->tail_len;
6125 + if (WARN_ON(counter_beacon > beacon_data_len))
6128 + if (beacon_data[counter_beacon] == 0)
6131 + rcu_read_unlock();
6135 +EXPORT_SYMBOL(ieee80211_csa_is_complete);
6137 struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
6138 struct ieee80211_vif *vif,
6139 u16 *tim_offset, u16 *tim_length)
6140 @@ -2356,6 +2432,9 @@ struct sk_buff *ieee80211_beacon_get_tim
6141 struct beacon_data *beacon = rcu_dereference(ap->beacon);
6144 + if (sdata->vif.csa_active)
6145 + ieee80211_update_csa(sdata, beacon);
6148 * headroom, head length,
6149 * tail length and maximum TIM length
6150 --- a/net/wireless/rdev-ops.h
6151 +++ b/net/wireless/rdev-ops.h
6152 @@ -923,4 +923,16 @@ static inline void rdev_crit_proto_stop(
6153 trace_rdev_return_void(&rdev->wiphy);
6156 +static inline int rdev_channel_switch(struct cfg80211_registered_device *rdev,
6157 + struct net_device *dev,
6158 + struct cfg80211_csa_settings *params)
6162 + trace_rdev_channel_switch(&rdev->wiphy, dev, params);
6163 + ret = rdev->ops->channel_switch(&rdev->wiphy, dev, params);
6164 + trace_rdev_return_int(&rdev->wiphy, ret);
6168 #endif /* __CFG80211_RDEV_OPS */
6169 --- a/net/wireless/trace.h
6170 +++ b/net/wireless/trace.h
6171 @@ -1841,6 +1841,39 @@ TRACE_EVENT(rdev_crit_proto_stop,
6172 WIPHY_PR_ARG, WDEV_PR_ARG)
6175 +TRACE_EVENT(rdev_channel_switch,
6176 + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
6177 + struct cfg80211_csa_settings *params),
6178 + TP_ARGS(wiphy, netdev, params),
6183 + __field(u16, counter_offset_beacon)
6184 + __field(u16, counter_offset_presp)
6185 + __field(bool, radar_required)
6186 + __field(bool, block_tx)
6187 + __field(u8, count)
6192 + CHAN_DEF_ASSIGN(¶ms->chandef);
6193 + __entry->counter_offset_beacon = params->counter_offset_beacon;
6194 + __entry->counter_offset_presp = params->counter_offset_presp;
6195 + __entry->radar_required = params->radar_required;
6196 + __entry->block_tx = params->block_tx;
6197 + __entry->count = params->count;
6199 + TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT
6200 + ", block_tx: %d, count: %u, radar_required: %d"
6201 + ", counter offsets (beacon/presp): %u/%u",
6202 + WIPHY_PR_ARG, NETDEV_PR_ARG, CHAN_DEF_PR_ARG,
6203 + __entry->block_tx, __entry->count, __entry->radar_required,
6204 + __entry->counter_offset_beacon,
6205 + __entry->counter_offset_presp)
6208 /*************************************************************
6209 * cfg80211 exported functions traces *
6210 *************************************************************/
6211 --- a/drivers/net/wireless/ath/ath.h
6212 +++ b/drivers/net/wireless/ath/ath.h
6213 @@ -159,7 +159,7 @@ struct ath_common {
6215 bool btcoex_enabled;
6217 - bool antenna_diversity;
6218 + bool bt_ant_diversity;
6221 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
6222 --- a/drivers/net/wireless/ath/ath9k/antenna.c
6223 +++ b/drivers/net/wireless/ath/ath9k/antenna.c
6224 @@ -16,37 +16,119 @@
6228 -static inline bool ath_is_alt_ant_ratio_better(int alt_ratio, int maxdelta,
6233 + * EEPROM has 2 4-bit fields containing the card configuration.
6237 + * bb_enable_ant_div_lnadiv : 1
6238 + * bb_ant_div_alt_gaintb : 1
6239 + * bb_ant_div_main_gaintb : 1
6240 + * bb_enable_ant_fast_div : 1
6244 + * bb_ant_div_alt_lnaconf : 2
6245 + * bb_ant_div_main_lnaconf : 2
6247 + * The EEPROM bits are used as follows:
6248 + * ------------------------------------
6250 + * bb_enable_ant_div_lnadiv - Enable LNA path rx antenna diversity/combining.
6251 + * Set in AR_PHY_MULTICHAIN_GAIN_CTL.
6253 + * bb_ant_div_[alt/main]_gaintb - 0 -> Antenna config Alt/Main uses gaintable 0
6254 + * 1 -> Antenna config Alt/Main uses gaintable 1
6255 + * Set in AR_PHY_MULTICHAIN_GAIN_CTL.
6257 + * bb_enable_ant_fast_div - Enable fast antenna diversity.
6258 + * Set in AR_PHY_CCK_DETECT.
6260 + * bb_ant_div_[alt/main]_lnaconf - Alt/Main LNA diversity/combining input config.
6261 + * Set in AR_PHY_MULTICHAIN_GAIN_CTL.
6267 + * AR9485 / AR9565 / AR9331
6268 + * ========================
6270 + * The same bits are present in the EEPROM, but the location in the
6271 + * EEPROM is different (ant_div_control in ar9300_BaseExtension_1).
6273 + * ant_div_alt_lnaconf ==> bit 0~1
6274 + * ant_div_main_lnaconf ==> bit 2~3
6275 + * ant_div_alt_gaintb ==> bit 4
6276 + * ant_div_main_gaintb ==> bit 5
6277 + * enable_ant_div_lnadiv ==> bit 6
6278 + * enable_ant_fast_div ==> bit 7
6281 +static inline bool ath_is_alt_ant_ratio_better(struct ath_ant_comb *antcomb,
6282 + int alt_ratio, int maxdelta,
6283 int mindelta, int main_rssi_avg,
6284 int alt_rssi_avg, int pkt_count)
6286 - return (((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
6287 - (alt_rssi_avg > main_rssi_avg + maxdelta)) ||
6288 - (alt_rssi_avg > main_rssi_avg + mindelta)) && (pkt_count > 50);
6289 + if (pkt_count <= 50)
6292 + if (alt_rssi_avg > main_rssi_avg + mindelta)
6295 + if (alt_ratio >= antcomb->ant_ratio2 &&
6296 + alt_rssi_avg >= antcomb->low_rssi_thresh &&
6297 + (alt_rssi_avg > main_rssi_avg + maxdelta))
6303 -static inline bool ath_ant_div_comb_alt_check(u8 div_group, int alt_ratio,
6304 - int curr_main_set, int curr_alt_set,
6305 - int alt_rssi_avg, int main_rssi_avg)
6306 +static inline bool ath_ant_div_comb_alt_check(struct ath_hw_antcomb_conf *conf,
6307 + struct ath_ant_comb *antcomb,
6308 + int alt_ratio, int alt_rssi_avg,
6309 + int main_rssi_avg)
6311 - bool result = false;
6312 - switch (div_group) {
6313 + bool result, set1, set2;
6315 + result = set1 = set2 = false;
6317 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2 &&
6318 + conf->alt_lna_conf == ATH_ANT_DIV_COMB_LNA1)
6321 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA1 &&
6322 + conf->alt_lna_conf == ATH_ANT_DIV_COMB_LNA2)
6325 + switch (conf->div_group) {
6327 if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)
6332 - if ((((curr_main_set == ATH_ANT_DIV_COMB_LNA2) &&
6333 - (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) &&
6334 - (alt_rssi_avg >= (main_rssi_avg - 5))) ||
6335 - ((curr_main_set == ATH_ANT_DIV_COMB_LNA1) &&
6336 - (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) &&
6337 - (alt_rssi_avg >= (main_rssi_avg - 2)))) &&
6338 - (alt_rssi_avg >= 4))
6339 + if (alt_rssi_avg < 4 || alt_rssi_avg < antcomb->low_rssi_thresh)
6342 + if ((set1 && (alt_rssi_avg >= (main_rssi_avg - 5))) ||
6343 + (set2 && (alt_rssi_avg >= (main_rssi_avg - 2))) ||
6344 + (alt_ratio > antcomb->ant_ratio))
6351 + if (alt_rssi_avg < 4 || alt_rssi_avg < antcomb->low_rssi_thresh)
6354 + if ((set1 && (alt_rssi_avg >= (main_rssi_avg - 3))) ||
6355 + (set2 && (alt_rssi_avg >= (main_rssi_avg + 3))) ||
6356 + (alt_ratio > antcomb->ant_ratio))
6362 @@ -108,6 +190,74 @@ static void ath_lnaconf_alt_good_scan(st
6366 +static void ath_ant_set_alt_ratio(struct ath_ant_comb *antcomb,
6367 + struct ath_hw_antcomb_conf *conf)
6369 + /* set alt to the conf with maximun ratio */
6370 + if (antcomb->first_ratio && antcomb->second_ratio) {
6371 + if (antcomb->rssi_second > antcomb->rssi_third) {
6373 + if ((antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) ||
6374 + (antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2))
6375 + /* Set alt LNA1 or LNA2*/
6376 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
6377 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6379 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6381 + /* Set alt to A+B or A-B */
6382 + conf->alt_lna_conf =
6383 + antcomb->first_quick_scan_conf;
6384 + } else if ((antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) ||
6385 + (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2)) {
6386 + /* Set alt LNA1 or LNA2 */
6387 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
6388 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6390 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6392 + /* Set alt to A+B or A-B */
6393 + conf->alt_lna_conf = antcomb->second_quick_scan_conf;
6395 + } else if (antcomb->first_ratio) {
6397 + if ((antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) ||
6398 + (antcomb->first_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2))
6399 + /* Set alt LNA1 or LNA2 */
6400 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
6401 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6403 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6405 + /* Set alt to A+B or A-B */
6406 + conf->alt_lna_conf = antcomb->first_quick_scan_conf;
6407 + } else if (antcomb->second_ratio) {
6409 + if ((antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1) ||
6410 + (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA2))
6411 + /* Set alt LNA1 or LNA2 */
6412 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
6413 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6415 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6417 + /* Set alt to A+B or A-B */
6418 + conf->alt_lna_conf = antcomb->second_quick_scan_conf;
6420 + /* main is largest */
6421 + if ((antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) ||
6422 + (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2))
6423 + /* Set alt LNA1 or LNA2 */
6424 + if (conf->main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
6425 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6427 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6429 + /* Set alt to A+B or A-B */
6430 + conf->alt_lna_conf = antcomb->main_conf;
6434 static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb,
6435 struct ath_hw_antcomb_conf *div_ant_conf,
6436 int main_rssi_avg, int alt_rssi_avg,
6437 @@ -129,7 +279,7 @@ static void ath_select_ant_div_from_quic
6439 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) {
6441 - if (ath_is_alt_ant_ratio_better(alt_ratio,
6442 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
6443 ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
6444 ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
6445 main_rssi_avg, alt_rssi_avg,
6446 @@ -138,7 +288,7 @@ static void ath_select_ant_div_from_quic
6448 antcomb->first_ratio = false;
6449 } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) {
6450 - if (ath_is_alt_ant_ratio_better(alt_ratio,
6451 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
6452 ATH_ANT_DIV_COMB_LNA1_DELTA_MID,
6453 ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
6454 main_rssi_avg, alt_rssi_avg,
6455 @@ -147,11 +297,11 @@ static void ath_select_ant_div_from_quic
6457 antcomb->first_ratio = false;
6459 - if ((((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
6460 - (alt_rssi_avg > main_rssi_avg +
6461 - ATH_ANT_DIV_COMB_LNA1_DELTA_HI)) ||
6462 - (alt_rssi_avg > main_rssi_avg)) &&
6463 - (antcomb->total_pkt_count > 50))
6464 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
6465 + ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
6467 + main_rssi_avg, alt_rssi_avg,
6468 + antcomb->total_pkt_count))
6469 antcomb->first_ratio = true;
6471 antcomb->first_ratio = false;
6472 @@ -164,17 +314,21 @@ static void ath_select_ant_div_from_quic
6473 antcomb->rssi_first = main_rssi_avg;
6474 antcomb->rssi_third = alt_rssi_avg;
6476 - if (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1)
6477 + switch(antcomb->second_quick_scan_conf) {
6478 + case ATH_ANT_DIV_COMB_LNA1:
6479 antcomb->rssi_lna1 = alt_rssi_avg;
6480 - else if (antcomb->second_quick_scan_conf ==
6481 - ATH_ANT_DIV_COMB_LNA2)
6483 + case ATH_ANT_DIV_COMB_LNA2:
6484 antcomb->rssi_lna2 = alt_rssi_avg;
6485 - else if (antcomb->second_quick_scan_conf ==
6486 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2) {
6488 + case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2:
6489 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2)
6490 antcomb->rssi_lna2 = main_rssi_avg;
6491 else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1)
6492 antcomb->rssi_lna1 = main_rssi_avg;
6498 if (antcomb->rssi_lna2 > antcomb->rssi_lna1 +
6499 @@ -184,7 +338,7 @@ static void ath_select_ant_div_from_quic
6500 div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6502 if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) {
6503 - if (ath_is_alt_ant_ratio_better(alt_ratio,
6504 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
6505 ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
6506 ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
6507 main_rssi_avg, alt_rssi_avg,
6508 @@ -193,7 +347,7 @@ static void ath_select_ant_div_from_quic
6510 antcomb->second_ratio = false;
6511 } else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) {
6512 - if (ath_is_alt_ant_ratio_better(alt_ratio,
6513 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
6514 ATH_ANT_DIV_COMB_LNA1_DELTA_MID,
6515 ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
6516 main_rssi_avg, alt_rssi_avg,
6517 @@ -202,105 +356,18 @@ static void ath_select_ant_div_from_quic
6519 antcomb->second_ratio = false;
6521 - if ((((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
6522 - (alt_rssi_avg > main_rssi_avg +
6523 - ATH_ANT_DIV_COMB_LNA1_DELTA_HI)) ||
6524 - (alt_rssi_avg > main_rssi_avg)) &&
6525 - (antcomb->total_pkt_count > 50))
6526 + if (ath_is_alt_ant_ratio_better(antcomb, alt_ratio,
6527 + ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
6529 + main_rssi_avg, alt_rssi_avg,
6530 + antcomb->total_pkt_count))
6531 antcomb->second_ratio = true;
6533 antcomb->second_ratio = false;
6536 - /* set alt to the conf with maximun ratio */
6537 - if (antcomb->first_ratio && antcomb->second_ratio) {
6538 - if (antcomb->rssi_second > antcomb->rssi_third) {
6540 - if ((antcomb->first_quick_scan_conf ==
6541 - ATH_ANT_DIV_COMB_LNA1) ||
6542 - (antcomb->first_quick_scan_conf ==
6543 - ATH_ANT_DIV_COMB_LNA2))
6544 - /* Set alt LNA1 or LNA2*/
6545 - if (div_ant_conf->main_lna_conf ==
6546 - ATH_ANT_DIV_COMB_LNA2)
6547 - div_ant_conf->alt_lna_conf =
6548 - ATH_ANT_DIV_COMB_LNA1;
6550 - div_ant_conf->alt_lna_conf =
6551 - ATH_ANT_DIV_COMB_LNA2;
6553 - /* Set alt to A+B or A-B */
6554 - div_ant_conf->alt_lna_conf =
6555 - antcomb->first_quick_scan_conf;
6556 - } else if ((antcomb->second_quick_scan_conf ==
6557 - ATH_ANT_DIV_COMB_LNA1) ||
6558 - (antcomb->second_quick_scan_conf ==
6559 - ATH_ANT_DIV_COMB_LNA2)) {
6560 - /* Set alt LNA1 or LNA2 */
6561 - if (div_ant_conf->main_lna_conf ==
6562 - ATH_ANT_DIV_COMB_LNA2)
6563 - div_ant_conf->alt_lna_conf =
6564 - ATH_ANT_DIV_COMB_LNA1;
6566 - div_ant_conf->alt_lna_conf =
6567 - ATH_ANT_DIV_COMB_LNA2;
6569 - /* Set alt to A+B or A-B */
6570 - div_ant_conf->alt_lna_conf =
6571 - antcomb->second_quick_scan_conf;
6573 - } else if (antcomb->first_ratio) {
6575 - if ((antcomb->first_quick_scan_conf ==
6576 - ATH_ANT_DIV_COMB_LNA1) ||
6577 - (antcomb->first_quick_scan_conf ==
6578 - ATH_ANT_DIV_COMB_LNA2))
6579 - /* Set alt LNA1 or LNA2 */
6580 - if (div_ant_conf->main_lna_conf ==
6581 - ATH_ANT_DIV_COMB_LNA2)
6582 - div_ant_conf->alt_lna_conf =
6583 - ATH_ANT_DIV_COMB_LNA1;
6585 - div_ant_conf->alt_lna_conf =
6586 - ATH_ANT_DIV_COMB_LNA2;
6588 - /* Set alt to A+B or A-B */
6589 - div_ant_conf->alt_lna_conf =
6590 - antcomb->first_quick_scan_conf;
6591 - } else if (antcomb->second_ratio) {
6593 - if ((antcomb->second_quick_scan_conf ==
6594 - ATH_ANT_DIV_COMB_LNA1) ||
6595 - (antcomb->second_quick_scan_conf ==
6596 - ATH_ANT_DIV_COMB_LNA2))
6597 - /* Set alt LNA1 or LNA2 */
6598 - if (div_ant_conf->main_lna_conf ==
6599 - ATH_ANT_DIV_COMB_LNA2)
6600 - div_ant_conf->alt_lna_conf =
6601 - ATH_ANT_DIV_COMB_LNA1;
6603 - div_ant_conf->alt_lna_conf =
6604 - ATH_ANT_DIV_COMB_LNA2;
6606 - /* Set alt to A+B or A-B */
6607 - div_ant_conf->alt_lna_conf =
6608 - antcomb->second_quick_scan_conf;
6610 - /* main is largest */
6611 - if ((antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) ||
6612 - (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2))
6613 - /* Set alt LNA1 or LNA2 */
6614 - if (div_ant_conf->main_lna_conf ==
6615 - ATH_ANT_DIV_COMB_LNA2)
6616 - div_ant_conf->alt_lna_conf =
6617 - ATH_ANT_DIV_COMB_LNA1;
6619 - div_ant_conf->alt_lna_conf =
6620 - ATH_ANT_DIV_COMB_LNA2;
6622 - /* Set alt to A+B or A-B */
6623 - div_ant_conf->alt_lna_conf = antcomb->main_conf;
6625 + ath_ant_set_alt_ratio(antcomb, div_ant_conf);
6630 @@ -430,8 +497,7 @@ static void ath_ant_div_conf_fast_divbia
6631 ant_conf->fast_div_bias = 0x1;
6633 case 0x10: /* LNA2 A-B */
6634 - if (!(antcomb->scan) &&
6635 - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
6636 + if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio))
6637 ant_conf->fast_div_bias = 0x1;
6639 ant_conf->fast_div_bias = 0x2;
6640 @@ -440,15 +506,13 @@ static void ath_ant_div_conf_fast_divbia
6641 ant_conf->fast_div_bias = 0x1;
6643 case 0x13: /* LNA2 A+B */
6644 - if (!(antcomb->scan) &&
6645 - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
6646 + if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio))
6647 ant_conf->fast_div_bias = 0x1;
6649 ant_conf->fast_div_bias = 0x2;
6651 case 0x20: /* LNA1 A-B */
6652 - if (!(antcomb->scan) &&
6653 - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
6654 + if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio))
6655 ant_conf->fast_div_bias = 0x1;
6657 ant_conf->fast_div_bias = 0x2;
6658 @@ -457,8 +521,7 @@ static void ath_ant_div_conf_fast_divbia
6659 ant_conf->fast_div_bias = 0x1;
6661 case 0x23: /* LNA1 A+B */
6662 - if (!(antcomb->scan) &&
6663 - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
6664 + if (!antcomb->scan && (alt_ratio > antcomb->ant_ratio))
6665 ant_conf->fast_div_bias = 0x1;
6667 ant_conf->fast_div_bias = 0x2;
6668 @@ -475,6 +538,9 @@ static void ath_ant_div_conf_fast_divbia
6673 + if (antcomb->fast_div_bias)
6674 + ant_conf->fast_div_bias = antcomb->fast_div_bias;
6675 } else if (ant_conf->div_group == 3) {
6676 switch ((ant_conf->main_lna_conf << 4) |
6677 ant_conf->alt_lna_conf) {
6678 @@ -540,6 +606,138 @@ static void ath_ant_div_conf_fast_divbia
6682 +static void ath_ant_try_scan(struct ath_ant_comb *antcomb,
6683 + struct ath_hw_antcomb_conf *conf,
6684 + int curr_alt_set, int alt_rssi_avg,
6685 + int main_rssi_avg)
6687 + switch (curr_alt_set) {
6688 + case ATH_ANT_DIV_COMB_LNA2:
6689 + antcomb->rssi_lna2 = alt_rssi_avg;
6690 + antcomb->rssi_lna1 = main_rssi_avg;
6691 + antcomb->scan = true;
6693 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6694 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6696 + case ATH_ANT_DIV_COMB_LNA1:
6697 + antcomb->rssi_lna1 = alt_rssi_avg;
6698 + antcomb->rssi_lna2 = main_rssi_avg;
6699 + antcomb->scan = true;
6701 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6702 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6704 + case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2:
6705 + antcomb->rssi_add = alt_rssi_avg;
6706 + antcomb->scan = true;
6708 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6710 + case ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2:
6711 + antcomb->rssi_sub = alt_rssi_avg;
6712 + antcomb->scan = false;
6713 + if (antcomb->rssi_lna2 >
6714 + (antcomb->rssi_lna1 + ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)) {
6715 + /* use LNA2 as main LNA */
6716 + if ((antcomb->rssi_add > antcomb->rssi_lna1) &&
6717 + (antcomb->rssi_add > antcomb->rssi_sub)) {
6719 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6720 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6721 + } else if (antcomb->rssi_sub >
6722 + antcomb->rssi_lna1) {
6724 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6725 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6728 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6729 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6732 + /* use LNA1 as main LNA */
6733 + if ((antcomb->rssi_add > antcomb->rssi_lna2) &&
6734 + (antcomb->rssi_add > antcomb->rssi_sub)) {
6736 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6737 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6738 + } else if (antcomb->rssi_sub >
6739 + antcomb->rssi_lna1) {
6741 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6742 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6745 + conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6746 + conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6755 +static bool ath_ant_try_switch(struct ath_hw_antcomb_conf *div_ant_conf,
6756 + struct ath_ant_comb *antcomb,
6757 + int alt_ratio, int alt_rssi_avg,
6758 + int main_rssi_avg, int curr_main_set,
6763 + if (ath_ant_div_comb_alt_check(div_ant_conf, antcomb, alt_ratio,
6764 + alt_rssi_avg, main_rssi_avg)) {
6765 + if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) {
6767 + * Switch main and alt LNA.
6769 + div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6770 + div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6771 + } else if (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) {
6772 + div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6773 + div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6777 + } else if ((curr_alt_set != ATH_ANT_DIV_COMB_LNA1) &&
6778 + (curr_alt_set != ATH_ANT_DIV_COMB_LNA2)) {
6780 + Set alt to another LNA.
6782 + if (curr_main_set == ATH_ANT_DIV_COMB_LNA2)
6783 + div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA1;
6784 + else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1)
6785 + div_ant_conf->alt_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6793 +static bool ath_ant_short_scan_check(struct ath_ant_comb *antcomb)
6797 + if (!antcomb->scan || !antcomb->alt_good)
6800 + if (time_after(jiffies, antcomb->scan_start_time +
6801 + msecs_to_jiffies(ATH_ANT_DIV_COMB_SHORT_SCAN_INTR)))
6804 + if (antcomb->total_pkt_count == ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT) {
6805 + alt_ratio = ((antcomb->alt_recv_cnt * 100) /
6806 + antcomb->total_pkt_count);
6807 + if (alt_ratio < antcomb->ant_ratio)
6814 void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs)
6816 struct ath_hw_antcomb_conf div_ant_conf;
6817 @@ -549,41 +747,46 @@ void ath_ant_comb_scan(struct ath_softc
6818 int main_rssi = rs->rs_rssi_ctl0;
6819 int alt_rssi = rs->rs_rssi_ctl1;
6820 int rx_ant_conf, main_ant_conf;
6821 - bool short_scan = false;
6822 + bool short_scan = false, ret;
6824 rx_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_CURRENT_SHIFT) &
6826 main_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_MAIN_SHIFT) &
6829 + if (alt_rssi >= antcomb->low_rssi_thresh) {
6830 + antcomb->ant_ratio = ATH_ANT_DIV_COMB_ALT_ANT_RATIO;
6831 + antcomb->ant_ratio2 = ATH_ANT_DIV_COMB_ALT_ANT_RATIO2;
6833 + antcomb->ant_ratio = ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI;
6834 + antcomb->ant_ratio2 = ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI;
6837 /* Record packet only when both main_rssi and alt_rssi is positive */
6838 if (main_rssi > 0 && alt_rssi > 0) {
6839 antcomb->total_pkt_count++;
6840 antcomb->main_total_rssi += main_rssi;
6841 antcomb->alt_total_rssi += alt_rssi;
6843 if (main_ant_conf == rx_ant_conf)
6844 antcomb->main_recv_cnt++;
6846 antcomb->alt_recv_cnt++;
6849 - /* Short scan check */
6850 - if (antcomb->scan && antcomb->alt_good) {
6851 - if (time_after(jiffies, antcomb->scan_start_time +
6852 - msecs_to_jiffies(ATH_ANT_DIV_COMB_SHORT_SCAN_INTR)))
6853 - short_scan = true;
6855 - if (antcomb->total_pkt_count ==
6856 - ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT) {
6857 - alt_ratio = ((antcomb->alt_recv_cnt * 100) /
6858 - antcomb->total_pkt_count);
6859 - if (alt_ratio < ATH_ANT_DIV_COMB_ALT_ANT_RATIO)
6860 - short_scan = true;
6862 + if (main_ant_conf == rx_ant_conf) {
6863 + ANT_STAT_INC(ANT_MAIN, recv_cnt);
6864 + ANT_LNA_INC(ANT_MAIN, rx_ant_conf);
6866 + ANT_STAT_INC(ANT_ALT, recv_cnt);
6867 + ANT_LNA_INC(ANT_ALT, rx_ant_conf);
6870 + /* Short scan check */
6871 + short_scan = ath_ant_short_scan_check(antcomb);
6873 if (((antcomb->total_pkt_count < ATH_ANT_DIV_COMB_MAX_PKTCOUNT) ||
6874 - rs->rs_moreaggr) && !short_scan)
6875 + rs->rs_moreaggr) && !short_scan)
6878 if (antcomb->total_pkt_count) {
6879 @@ -595,15 +798,13 @@ void ath_ant_comb_scan(struct ath_softc
6880 antcomb->total_pkt_count);
6884 ath9k_hw_antdiv_comb_conf_get(sc->sc_ah, &div_ant_conf);
6885 curr_alt_set = div_ant_conf.alt_lna_conf;
6886 curr_main_set = div_ant_conf.main_lna_conf;
6890 if (antcomb->count == ATH_ANT_DIV_COMB_MAX_COUNT) {
6891 - if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) {
6892 + if (alt_ratio > antcomb->ant_ratio) {
6893 ath_lnaconf_alt_good_scan(antcomb, div_ant_conf,
6895 antcomb->alt_good = true;
6896 @@ -617,153 +818,47 @@ void ath_ant_comb_scan(struct ath_softc
6899 if (!antcomb->scan) {
6900 - if (ath_ant_div_comb_alt_check(div_ant_conf.div_group,
6901 - alt_ratio, curr_main_set, curr_alt_set,
6902 - alt_rssi_avg, main_rssi_avg)) {
6903 - if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) {
6904 - /* Switch main and alt LNA */
6905 - div_ant_conf.main_lna_conf =
6906 - ATH_ANT_DIV_COMB_LNA2;
6907 - div_ant_conf.alt_lna_conf =
6908 - ATH_ANT_DIV_COMB_LNA1;
6909 - } else if (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) {
6910 - div_ant_conf.main_lna_conf =
6911 - ATH_ANT_DIV_COMB_LNA1;
6912 - div_ant_conf.alt_lna_conf =
6913 - ATH_ANT_DIV_COMB_LNA2;
6916 - goto div_comb_done;
6917 - } else if ((curr_alt_set != ATH_ANT_DIV_COMB_LNA1) &&
6918 - (curr_alt_set != ATH_ANT_DIV_COMB_LNA2)) {
6919 - /* Set alt to another LNA */
6920 - if (curr_main_set == ATH_ANT_DIV_COMB_LNA2)
6921 - div_ant_conf.alt_lna_conf =
6922 - ATH_ANT_DIV_COMB_LNA1;
6923 - else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1)
6924 - div_ant_conf.alt_lna_conf =
6925 - ATH_ANT_DIV_COMB_LNA2;
6927 - goto div_comb_done;
6930 - if ((alt_rssi_avg < (main_rssi_avg +
6931 - div_ant_conf.lna1_lna2_delta)))
6932 + ret = ath_ant_try_switch(&div_ant_conf, antcomb, alt_ratio,
6933 + alt_rssi_avg, main_rssi_avg,
6934 + curr_main_set, curr_alt_set);
6939 + if (!antcomb->scan &&
6940 + (alt_rssi_avg < (main_rssi_avg + div_ant_conf.lna1_lna2_delta)))
6941 + goto div_comb_done;
6943 if (!antcomb->scan_not_start) {
6944 - switch (curr_alt_set) {
6945 - case ATH_ANT_DIV_COMB_LNA2:
6946 - antcomb->rssi_lna2 = alt_rssi_avg;
6947 - antcomb->rssi_lna1 = main_rssi_avg;
6948 - antcomb->scan = true;
6950 - div_ant_conf.main_lna_conf =
6951 - ATH_ANT_DIV_COMB_LNA1;
6952 - div_ant_conf.alt_lna_conf =
6953 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6955 - case ATH_ANT_DIV_COMB_LNA1:
6956 - antcomb->rssi_lna1 = alt_rssi_avg;
6957 - antcomb->rssi_lna2 = main_rssi_avg;
6958 - antcomb->scan = true;
6960 - div_ant_conf.main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
6961 - div_ant_conf.alt_lna_conf =
6962 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6964 - case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2:
6965 - antcomb->rssi_add = alt_rssi_avg;
6966 - antcomb->scan = true;
6968 - div_ant_conf.alt_lna_conf =
6969 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6971 - case ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2:
6972 - antcomb->rssi_sub = alt_rssi_avg;
6973 - antcomb->scan = false;
6974 - if (antcomb->rssi_lna2 >
6975 - (antcomb->rssi_lna1 +
6976 - ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)) {
6977 - /* use LNA2 as main LNA */
6978 - if ((antcomb->rssi_add > antcomb->rssi_lna1) &&
6979 - (antcomb->rssi_add > antcomb->rssi_sub)) {
6981 - div_ant_conf.main_lna_conf =
6982 - ATH_ANT_DIV_COMB_LNA2;
6983 - div_ant_conf.alt_lna_conf =
6984 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
6985 - } else if (antcomb->rssi_sub >
6986 - antcomb->rssi_lna1) {
6988 - div_ant_conf.main_lna_conf =
6989 - ATH_ANT_DIV_COMB_LNA2;
6990 - div_ant_conf.alt_lna_conf =
6991 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
6994 - div_ant_conf.main_lna_conf =
6995 - ATH_ANT_DIV_COMB_LNA2;
6996 - div_ant_conf.alt_lna_conf =
6997 - ATH_ANT_DIV_COMB_LNA1;
7000 - /* use LNA1 as main LNA */
7001 - if ((antcomb->rssi_add > antcomb->rssi_lna2) &&
7002 - (antcomb->rssi_add > antcomb->rssi_sub)) {
7004 - div_ant_conf.main_lna_conf =
7005 - ATH_ANT_DIV_COMB_LNA1;
7006 - div_ant_conf.alt_lna_conf =
7007 - ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
7008 - } else if (antcomb->rssi_sub >
7009 - antcomb->rssi_lna1) {
7011 - div_ant_conf.main_lna_conf =
7012 - ATH_ANT_DIV_COMB_LNA1;
7013 - div_ant_conf.alt_lna_conf =
7014 - ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
7017 - div_ant_conf.main_lna_conf =
7018 - ATH_ANT_DIV_COMB_LNA1;
7019 - div_ant_conf.alt_lna_conf =
7020 - ATH_ANT_DIV_COMB_LNA2;
7027 + ath_ant_try_scan(antcomb, &div_ant_conf, curr_alt_set,
7028 + alt_rssi_avg, main_rssi_avg);
7030 if (!antcomb->alt_good) {
7031 antcomb->scan_not_start = false;
7032 /* Set alt to another LNA */
7033 if (curr_main_set == ATH_ANT_DIV_COMB_LNA2) {
7034 div_ant_conf.main_lna_conf =
7035 - ATH_ANT_DIV_COMB_LNA2;
7036 + ATH_ANT_DIV_COMB_LNA2;
7037 div_ant_conf.alt_lna_conf =
7038 - ATH_ANT_DIV_COMB_LNA1;
7039 + ATH_ANT_DIV_COMB_LNA1;
7040 } else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1) {
7041 div_ant_conf.main_lna_conf =
7042 - ATH_ANT_DIV_COMB_LNA1;
7043 + ATH_ANT_DIV_COMB_LNA1;
7044 div_ant_conf.alt_lna_conf =
7045 - ATH_ANT_DIV_COMB_LNA2;
7046 + ATH_ANT_DIV_COMB_LNA2;
7050 + ath_select_ant_div_from_quick_scan(antcomb, &div_ant_conf,
7051 + main_rssi_avg, alt_rssi_avg,
7053 + antcomb->quick_scan_cnt++;
7056 - ath_select_ant_div_from_quick_scan(antcomb, &div_ant_conf,
7057 - main_rssi_avg, alt_rssi_avg,
7060 - antcomb->quick_scan_cnt++;
7063 ath_ant_div_conf_fast_divbias(&div_ant_conf, antcomb, alt_ratio);
7064 ath9k_hw_antdiv_comb_conf_set(sc->sc_ah, &div_ant_conf);
7065 + ath9k_debug_stat_ant(sc, &div_ant_conf, main_rssi_avg, alt_rssi_avg);
7067 antcomb->scan_start_time = jiffies;
7068 antcomb->total_pkt_count = 0;
7069 @@ -772,26 +867,3 @@ div_comb_done:
7070 antcomb->main_recv_cnt = 0;
7071 antcomb->alt_recv_cnt = 0;
7074 -void ath_ant_comb_update(struct ath_softc *sc)
7076 - struct ath_hw *ah = sc->sc_ah;
7077 - struct ath_common *common = ath9k_hw_common(ah);
7078 - struct ath_hw_antcomb_conf div_ant_conf;
7081 - ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
7083 - if (sc->ant_rx == 1)
7084 - lna_conf = ATH_ANT_DIV_COMB_LNA1;
7086 - lna_conf = ATH_ANT_DIV_COMB_LNA2;
7088 - div_ant_conf.main_lna_conf = lna_conf;
7089 - div_ant_conf.alt_lna_conf = lna_conf;
7091 - ath9k_hw_antdiv_comb_conf_set(ah, &div_ant_conf);
7093 - if (common->antenna_diversity)
7094 - ath9k_hw_antctrl_shared_chain_lnadiv(ah, true);
7096 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
7097 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
7098 @@ -610,7 +610,15 @@ static void ar5008_hw_override_ini(struc
7099 REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
7101 if (AR_SREV_9280_20_OR_LATER(ah)) {
7102 - val = REG_READ(ah, AR_PCU_MISC_MODE2);
7104 + * For AR9280 and above, there is a new feature that allows
7105 + * Multicast search based on both MAC Address and Key ID.
7106 + * By default, this feature is enabled. But since the driver
7107 + * is not using this feature, we switch it off; otherwise
7108 + * multicast search based on MAC addr only will fail.
7110 + val = REG_READ(ah, AR_PCU_MISC_MODE2) &
7111 + (~AR_ADHOC_MCAST_KEYID_ENABLE);
7113 if (!AR_SREV_9271(ah))
7114 val &= ~AR_PCU_MISC_MODE2_HWWAR1;
7115 @@ -659,14 +667,13 @@ static void ar5008_hw_set_channel_regs(s
7116 if (IS_CHAN_HT40(chan)) {
7117 phymode |= AR_PHY_FC_DYN2040_EN;
7119 - if ((chan->chanmode == CHANNEL_A_HT40PLUS) ||
7120 - (chan->chanmode == CHANNEL_G_HT40PLUS))
7121 + if (IS_CHAN_HT40PLUS(chan))
7122 phymode |= AR_PHY_FC_DYN2040_PRI_CH;
7125 REG_WRITE(ah, AR_PHY_TURBO, phymode);
7127 - ath9k_hw_set11nmac2040(ah);
7128 + ath9k_hw_set11nmac2040(ah, chan);
7130 ENABLE_REGWRITE_BUFFER(ah);
7132 @@ -684,31 +691,12 @@ static int ar5008_hw_process_ini(struct
7133 int i, regWrites = 0;
7134 u32 modesIndex, freqIndex;
7136 - switch (chan->chanmode) {
7138 - case CHANNEL_A_HT20:
7142 - case CHANNEL_A_HT40PLUS:
7143 - case CHANNEL_A_HT40MINUS:
7145 + if (IS_CHAN_5GHZ(chan)) {
7149 - case CHANNEL_G_HT20:
7152 + modesIndex = IS_CHAN_HT40(chan) ? 2 : 1;
7156 - case CHANNEL_G_HT40PLUS:
7157 - case CHANNEL_G_HT40MINUS:
7164 + modesIndex = IS_CHAN_HT40(chan) ? 3 : 4;
7168 @@ -807,8 +795,10 @@ static void ar5008_hw_set_rfmode(struct
7172 - rfMode |= (IS_CHAN_B(chan) || IS_CHAN_G(chan))
7173 - ? AR_PHY_MODE_DYNAMIC : AR_PHY_MODE_OFDM;
7174 + if (IS_CHAN_2GHZ(chan))
7175 + rfMode |= AR_PHY_MODE_DYNAMIC;
7177 + rfMode |= AR_PHY_MODE_OFDM;
7179 if (!AR_SREV_9280_20_OR_LATER(ah))
7180 rfMode |= (IS_CHAN_5GHZ(chan)) ?
7181 @@ -1213,12 +1203,11 @@ static void ar5008_hw_ani_cache_ini_regs
7183 iniDef = &aniState->iniDef;
7185 - ath_dbg(common, ANI, "ver %d.%d opmode %u chan %d Mhz/0x%x\n",
7186 + ath_dbg(common, ANI, "ver %d.%d opmode %u chan %d Mhz\n",
7187 ah->hw_version.macVersion,
7188 ah->hw_version.macRev,
7191 - chan->channelFlags);
7194 val = REG_READ(ah, AR_PHY_SFCORR);
7195 iniDef->m1Thresh = MS(val, AR_PHY_SFCORR_M1_THRESH);
7196 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
7197 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
7198 @@ -555,6 +555,69 @@ static void ar9002_hw_antdiv_comb_conf_s
7199 REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval);
7202 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
7204 +static void ar9002_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
7206 + struct ath_btcoex_hw *btcoex = &ah->btcoex_hw;
7207 + u8 antdiv_ctrl1, antdiv_ctrl2;
7211 + antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_ENABLE;
7212 + antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_ENABLE;
7215 + * Don't disable BT ant to allow BB to control SWCOM.
7217 + btcoex->bt_coex_mode2 &= (~(AR_BT_DISABLE_BT_ANT));
7218 + REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2);
7220 + REG_WRITE(ah, AR_PHY_SWITCH_COM, ATH_BT_COEX_ANT_DIV_SWITCH_COM);
7221 + REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000);
7224 + * Disable antenna diversity, use LNA1 only.
7226 + antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_FIXED_A;
7227 + antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_FIXED_A;
7230 + * Disable BT Ant. to allow concurrent BT and WLAN receive.
7232 + btcoex->bt_coex_mode2 |= AR_BT_DISABLE_BT_ANT;
7233 + REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2);
7236 + * Program SWCOM table to make sure RF switch always parks
7239 + REG_WRITE(ah, AR_PHY_SWITCH_COM, 0);
7240 + REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000);
7243 + regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
7244 + regval &= (~(AR_PHY_9285_ANT_DIV_CTL_ALL));
7246 + * Clear ant_fast_div_bias [14:9] since for WB195,
7247 + * the main LNA is always LNA1.
7249 + regval &= (~(AR_PHY_9285_FAST_DIV_BIAS));
7250 + regval |= SM(antdiv_ctrl1, AR_PHY_9285_ANT_DIV_CTL);
7251 + regval |= SM(antdiv_ctrl2, AR_PHY_9285_ANT_DIV_ALT_LNACONF);
7252 + regval |= SM((antdiv_ctrl2 >> 2), AR_PHY_9285_ANT_DIV_MAIN_LNACONF);
7253 + regval |= SM((antdiv_ctrl1 >> 1), AR_PHY_9285_ANT_DIV_ALT_GAINTB);
7254 + regval |= SM((antdiv_ctrl1 >> 2), AR_PHY_9285_ANT_DIV_MAIN_GAINTB);
7255 + REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval);
7257 + regval = REG_READ(ah, AR_PHY_CCK_DETECT);
7258 + regval &= (~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
7259 + regval |= SM((antdiv_ctrl1 >> 3), AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
7260 + REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
7265 static void ar9002_hw_spectral_scan_config(struct ath_hw *ah,
7266 struct ath_spec_scan *param)
7268 @@ -634,5 +697,9 @@ void ar9002_hw_attach_phy_ops(struct ath
7269 ops->spectral_scan_trigger = ar9002_hw_spectral_scan_trigger;
7270 ops->spectral_scan_wait = ar9002_hw_spectral_scan_wait;
7272 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
7273 + ops->set_bt_ant_diversity = ar9002_hw_set_bt_ant_diversity;
7276 ar9002_hw_set_nf_limits(ah);
7278 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.h
7279 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.h
7280 @@ -317,13 +317,15 @@
7281 #define AR_PHY_9285_ANT_DIV_ALT_GAINTB_S 29
7282 #define AR_PHY_9285_ANT_DIV_MAIN_GAINTB 0x40000000
7283 #define AR_PHY_9285_ANT_DIV_MAIN_GAINTB_S 30
7284 -#define AR_PHY_9285_ANT_DIV_LNA1 2
7285 -#define AR_PHY_9285_ANT_DIV_LNA2 1
7286 -#define AR_PHY_9285_ANT_DIV_LNA1_PLUS_LNA2 3
7287 -#define AR_PHY_9285_ANT_DIV_LNA1_MINUS_LNA2 0
7288 #define AR_PHY_9285_ANT_DIV_GAINTB_0 0
7289 #define AR_PHY_9285_ANT_DIV_GAINTB_1 1
7291 +#define ATH_BT_COEX_ANTDIV_CONTROL1_ENABLE 0x0b
7292 +#define ATH_BT_COEX_ANTDIV_CONTROL2_ENABLE 0x09
7293 +#define ATH_BT_COEX_ANTDIV_CONTROL1_FIXED_A 0x04
7294 +#define ATH_BT_COEX_ANTDIV_CONTROL2_FIXED_A 0x09
7295 +#define ATH_BT_COEX_ANT_DIV_SWITCH_COM 0x66666666
7297 #define AR_PHY_EXT_CCA0 0x99b8
7298 #define AR_PHY_EXT_CCA0_THRESH62 0x000000FF
7299 #define AR_PHY_EXT_CCA0_THRESH62_S 0
7300 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
7301 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
7302 @@ -3541,13 +3541,12 @@ static u16 ar9003_switch_com_spdt_get(st
7303 return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
7307 -static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
7308 +u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
7310 return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon);
7313 -static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
7314 +u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
7316 return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
7318 @@ -3561,6 +3560,7 @@ static u16 ar9003_hw_ant_ctrl_chain_get(
7320 static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
7322 + struct ath_common *common = ath9k_hw_common(ah);
7323 struct ath9k_hw_capabilities *pCap = &ah->caps;
7325 u32 regval, value, gpio;
7326 @@ -3614,6 +3614,11 @@ static void ar9003_hw_ant_ctrl_apply(str
7329 value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
7330 + if (AR_SREV_9485(ah) && common->bt_ant_diversity) {
7331 + regval &= ~AR_SWITCH_TABLE_COM2_ALL;
7332 + regval |= ah->config.ant_ctrl_comm2g_switch_enable;
7335 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
7337 if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
7338 @@ -3645,8 +3650,11 @@ static void ar9003_hw_ant_ctrl_apply(str
7339 regval &= (~AR_PHY_ANT_DIV_LNADIV);
7340 regval |= ((value >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
7342 + if (AR_SREV_9485(ah) && common->bt_ant_diversity)
7343 + regval |= AR_ANT_DIV_ENABLE;
7345 if (AR_SREV_9565(ah)) {
7346 - if (ah->shared_chain_lnadiv) {
7347 + if (common->bt_ant_diversity) {
7348 regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S);
7350 regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S);
7351 @@ -3656,10 +3664,14 @@ static void ar9003_hw_ant_ctrl_apply(str
7353 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
7355 - /*enable fast_div */
7356 + /* enable fast_div */
7357 regval = REG_READ(ah, AR_PHY_CCK_DETECT);
7358 regval &= (~AR_FAST_DIV_ENABLE);
7359 regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
7361 + if (AR_SREV_9485(ah) && common->bt_ant_diversity)
7362 + regval |= AR_FAST_DIV_ENABLE;
7364 REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
7366 if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
7367 @@ -3673,9 +3685,9 @@ static void ar9003_hw_ant_ctrl_apply(str
7368 AR_PHY_ANT_DIV_ALT_GAINTB |
7369 AR_PHY_ANT_DIV_MAIN_GAINTB));
7370 /* by default use LNA1 for the main antenna */
7371 - regval |= (AR_PHY_ANT_DIV_LNA1 <<
7372 + regval |= (ATH_ANT_DIV_COMB_LNA1 <<
7373 AR_PHY_ANT_DIV_MAIN_LNACONF_S);
7374 - regval |= (AR_PHY_ANT_DIV_LNA2 <<
7375 + regval |= (ATH_ANT_DIV_COMB_LNA2 <<
7376 AR_PHY_ANT_DIV_ALT_LNACONF_S);
7377 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
7379 @@ -3813,6 +3825,11 @@ static void ar9003_hw_atten_apply(struct
7381 value = ar9003_hw_atten_chain_get_margin(ah, i, chan);
7383 + if (ah->config.alt_mingainidx)
7384 + REG_RMW_FIELD(ah, AR_PHY_EXT_ATTEN_CTL_0,
7385 + AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
7388 REG_RMW_FIELD(ah, ext_atten_reg[i],
7389 AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
7391 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
7392 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
7393 @@ -334,6 +334,8 @@ struct ar9300_eeprom {
7395 s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah);
7396 s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah);
7397 +u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz);
7398 +u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz);
7400 u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz);
7402 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
7403 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
7405 #define AR_PHY_SFCORR_SPUR_SUBCHNL_SD_S 28
7406 #define AR_PHY_EXT_CCA_THRESH62 0x007F0000
7407 #define AR_PHY_EXT_CCA_THRESH62_S 16
7408 +#define AR_PHY_EXTCHN_PWRTHR1_ANT_DIV_ALT_ANT_MINGAINIDX 0x0000FF00
7409 +#define AR_PHY_EXTCHN_PWRTHR1_ANT_DIV_ALT_ANT_MINGAINIDX_S 8
7410 #define AR_PHY_EXT_MINCCA_PWR 0x01FF0000
7411 #define AR_PHY_EXT_MINCCA_PWR_S 16
7412 #define AR_PHY_EXT_CYCPWR_THR1 0x0000FE00L
7413 @@ -296,11 +298,6 @@
7414 #define AR_PHY_ANT_DIV_MAIN_GAINTB 0x40000000
7415 #define AR_PHY_ANT_DIV_MAIN_GAINTB_S 30
7417 -#define AR_PHY_ANT_DIV_LNA1_MINUS_LNA2 0x0
7418 -#define AR_PHY_ANT_DIV_LNA2 0x1
7419 -#define AR_PHY_ANT_DIV_LNA1 0x2
7420 -#define AR_PHY_ANT_DIV_LNA1_PLUS_LNA2 0x3
7422 #define AR_PHY_EXTCHN_PWRTHR1 (AR_AGC_BASE + 0x2c)
7423 #define AR_PHY_EXT_CHN_WIN (AR_AGC_BASE + 0x30)
7424 #define AR_PHY_20_40_DET_THR (AR_AGC_BASE + 0x34)
7425 --- a/drivers/net/wireless/ath/ath9k/debug.h
7426 +++ b/drivers/net/wireless/ath/ath9k/debug.h
7427 @@ -28,9 +28,13 @@ struct fft_sample_tlv;
7428 #ifdef CPTCFG_ATH9K_DEBUGFS
7429 #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
7430 #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++
7431 +#define ANT_STAT_INC(i, c) sc->debug.stats.ant_stats[i].c++
7432 +#define ANT_LNA_INC(i, c) sc->debug.stats.ant_stats[i].lna_recv_cnt[c]++;
7434 #define TX_STAT_INC(q, c) do { } while (0)
7435 #define RESET_STAT_INC(sc, type) do { } while (0)
7436 +#define ANT_STAT_INC(i, c) do { } while (0)
7437 +#define ANT_LNA_INC(i, c) do { } while (0)
7440 enum ath_reset_type {
7441 @@ -243,11 +247,22 @@ struct ath_rx_stats {
7448 +struct ath_antenna_stats {
7451 + u32 lna_recv_cnt[4];
7452 + u32 lna_attempt_cnt[4];
7456 struct ath_interrupt_stats istats;
7457 struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
7458 struct ath_rx_stats rxstats;
7459 struct ath_dfs_stats dfs_stats;
7460 + struct ath_antenna_stats ant_stats[2];
7461 u32 reset[__RESET_TYPE_MAX];
7464 @@ -281,10 +296,11 @@ void ath9k_sta_remove_debugfs(struct iee
7465 struct ieee80211_vif *vif,
7466 struct ieee80211_sta *sta,
7467 struct dentry *dir);
7469 void ath_debug_send_fft_sample(struct ath_softc *sc,
7470 struct fft_sample_tlv *fft_sample);
7472 +void ath9k_debug_stat_ant(struct ath_softc *sc,
7473 + struct ath_hw_antcomb_conf *div_ant_conf,
7474 + int main_rssi_avg, int alt_rssi_avg);
7477 #define RX_STAT_INC(c) /* NOP */
7478 @@ -297,12 +313,10 @@ static inline int ath9k_init_debug(struc
7479 static inline void ath9k_deinit_debug(struct ath_softc *sc)
7483 static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
7484 enum ath9k_int status)
7488 static inline void ath_debug_stat_tx(struct ath_softc *sc,
7490 struct ath_tx_status *ts,
7491 @@ -310,11 +324,16 @@ static inline void ath_debug_stat_tx(str
7496 static inline void ath_debug_stat_rx(struct ath_softc *sc,
7497 struct ath_rx_status *rs)
7500 +static inline void ath9k_debug_stat_ant(struct ath_softc *sc,
7501 + struct ath_hw_antcomb_conf *div_ant_conf,
7502 + int main_rssi_avg, int alt_rssi_avg)
7507 #endif /* CPTCFG_ATH9K_DEBUGFS */
7509 --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
7510 +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
7511 @@ -812,6 +812,7 @@ static void ath9k_hw_4k_set_gain(struct
7512 static void ath9k_hw_4k_set_board_values(struct ath_hw *ah,
7513 struct ath9k_channel *chan)
7515 + struct ath9k_hw_capabilities *pCap = &ah->caps;
7516 struct modal_eep_4k_header *pModal;
7517 struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
7518 struct base_eep_header_4k *pBase = &eep->baseEepHeader;
7519 @@ -858,6 +859,24 @@ static void ath9k_hw_4k_set_board_values
7521 REG_WRITE(ah, AR_PHY_CCK_DETECT, regVal);
7522 regVal = REG_READ(ah, AR_PHY_CCK_DETECT);
7524 + if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
7526 + * If diversity combining is enabled,
7527 + * set MAIN to LNA1 and ALT to LNA2 initially.
7529 + regVal = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
7530 + regVal &= (~(AR_PHY_9285_ANT_DIV_MAIN_LNACONF |
7531 + AR_PHY_9285_ANT_DIV_ALT_LNACONF));
7533 + regVal |= (ATH_ANT_DIV_COMB_LNA1 <<
7534 + AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S);
7535 + regVal |= (ATH_ANT_DIV_COMB_LNA2 <<
7536 + AR_PHY_9285_ANT_DIV_ALT_LNACONF_S);
7537 + regVal &= (~(AR_PHY_9285_FAST_DIV_BIAS));
7538 + regVal |= (0 << AR_PHY_9285_FAST_DIV_BIAS_S);
7539 + REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regVal);
7543 if (pModal->version >= 2) {
7544 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h
7545 +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
7546 @@ -78,13 +78,16 @@ static inline void ath9k_hw_antdiv_comb_
7547 ath9k_hw_ops(ah)->antdiv_comb_conf_set(ah, antconf);
7550 -static inline void ath9k_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
7552 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
7554 +static inline void ath9k_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
7556 - if (ath9k_hw_ops(ah)->antctrl_shared_chain_lnadiv)
7557 - ath9k_hw_ops(ah)->antctrl_shared_chain_lnadiv(ah, enable);
7558 + if (ath9k_hw_ops(ah)->set_bt_ant_diversity)
7559 + ath9k_hw_ops(ah)->set_bt_ant_diversity(ah, enable);
7564 /* Private hardware call ops */
7567 --- a/drivers/net/wireless/ath/ath9k/hw.c
7568 +++ b/drivers/net/wireless/ath/ath9k/hw.c
7569 @@ -130,29 +130,29 @@ void ath9k_debug_sync_cause(struct ath_c
7571 static void ath9k_hw_set_clockrate(struct ath_hw *ah)
7573 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
7574 struct ath_common *common = ath9k_hw_common(ah);
7575 + struct ath9k_channel *chan = ah->curchan;
7576 unsigned int clockrate;
7578 /* AR9287 v1.3+ uses async FIFO and runs the MAC at 117 MHz */
7579 if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah))
7581 - else if (!ah->curchan) /* should really check for CCK instead */
7582 + else if (!chan) /* should really check for CCK instead */
7583 clockrate = ATH9K_CLOCK_RATE_CCK;
7584 - else if (conf->chandef.chan->band == IEEE80211_BAND_2GHZ)
7585 + else if (IS_CHAN_2GHZ(chan))
7586 clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
7587 else if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)
7588 clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
7590 clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM;
7592 - if (conf_is_ht40(conf))
7593 + if (IS_CHAN_HT40(chan))
7597 - if (IS_CHAN_HALF_RATE(ah->curchan))
7598 + if (IS_CHAN_HALF_RATE(chan))
7600 - if (IS_CHAN_QUARTER_RATE(ah->curchan))
7601 + if (IS_CHAN_QUARTER_RATE(chan))
7605 @@ -190,10 +190,7 @@ EXPORT_SYMBOL(ath9k_hw_wait);
7606 void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
7609 - if (IS_CHAN_B(chan))
7610 - hw_delay = (4 * hw_delay) / 22;
7615 if (IS_CHAN_HALF_RATE(chan))
7617 @@ -294,8 +291,7 @@ void ath9k_hw_get_channel_centers(struct
7621 - if ((chan->chanmode == CHANNEL_A_HT40PLUS) ||
7622 - (chan->chanmode == CHANNEL_G_HT40PLUS)) {
7623 + if (IS_CHAN_HT40PLUS(chan)) {
7624 centers->synth_center =
7625 chan->channel + HT40_CHANNEL_CENTER_SHIFT;
7627 @@ -450,7 +446,6 @@ static void ath9k_hw_init_config(struct
7628 ah->config.ack_6mb = 0x0;
7629 ah->config.cwm_ignore_extcca = 0;
7630 ah->config.pcie_clock_req = 0;
7631 - ah->config.pcie_waen = 0;
7632 ah->config.analog_shiftreg = 1;
7634 for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
7635 @@ -1034,7 +1029,6 @@ static bool ath9k_hw_set_global_txtimeou
7636 void ath9k_hw_init_global_settings(struct ath_hw *ah)
7638 struct ath_common *common = ath9k_hw_common(ah);
7639 - struct ieee80211_conf *conf = &common->hw->conf;
7640 const struct ath9k_channel *chan = ah->curchan;
7641 int acktimeout, ctstimeout, ack_offset = 0;
7643 @@ -1069,7 +1063,7 @@ void ath9k_hw_init_global_settings(struc
7644 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
7651 } else if (IS_CHAN_QUARTER_RATE(chan)) {
7652 @@ -1079,7 +1073,7 @@ void ath9k_hw_init_global_settings(struc
7653 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
7661 @@ -1109,14 +1103,12 @@ void ath9k_hw_init_global_settings(struc
7662 * BA frames in some implementations, but it has been found to fix ACK
7663 * timeout issues in other cases as well.
7665 - if (conf->chandef.chan &&
7666 - conf->chandef.chan->band == IEEE80211_BAND_2GHZ &&
7667 + if (IS_CHAN_2GHZ(chan) &&
7668 !IS_CHAN_HALF_RATE(chan) && !IS_CHAN_QUARTER_RATE(chan)) {
7669 acktimeout += 64 - sifstime - ah->slottime;
7670 ctstimeout += 48 - sifstime - ah->slottime;
7674 ath9k_hw_set_sifs_time(ah, sifstime);
7675 ath9k_hw_setslottime(ah, slottime);
7676 ath9k_hw_set_ack_timeout(ah, acktimeout);
7677 @@ -1153,9 +1145,7 @@ u32 ath9k_regd_get_ctl(struct ath_regula
7679 u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band);
7681 - if (IS_CHAN_B(chan))
7683 - else if (IS_CHAN_G(chan))
7684 + if (IS_CHAN_2GHZ(chan))
7688 @@ -1496,16 +1486,16 @@ static bool ath9k_hw_channel_change(stru
7689 struct ath9k_channel *chan)
7691 struct ath_common *common = ath9k_hw_common(ah);
7692 + struct ath9k_hw_capabilities *pCap = &ah->caps;
7693 + bool band_switch = false, mode_diff = false;
7694 + u8 ini_reloaded = 0;
7697 - bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
7698 - bool band_switch, mode_diff;
7701 - band_switch = (chan->channelFlags & (CHANNEL_2GHZ | CHANNEL_5GHZ)) !=
7702 - (ah->curchan->channelFlags & (CHANNEL_2GHZ |
7704 - mode_diff = (chan->chanmode != ah->curchan->chanmode);
7706 + if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) {
7707 + band_switch = IS_CHAN_5GHZ(ah->curchan) != IS_CHAN_5GHZ(chan);
7708 + mode_diff = (chan->channelFlags != ah->curchan->channelFlags);
7711 for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
7712 if (ath9k_hw_numtxpending(ah, qnum)) {
7713 @@ -1520,11 +1510,12 @@ static bool ath9k_hw_channel_change(stru
7717 - if (edma && (band_switch || mode_diff)) {
7718 + if (band_switch || mode_diff) {
7719 ath9k_hw_mark_phy_inactive(ah);
7722 - ath9k_hw_init_pll(ah, NULL);
7724 + ath9k_hw_init_pll(ah, chan);
7726 if (ath9k_hw_fast_chan_change(ah, chan, &ini_reloaded)) {
7727 ath_err(common, "Failed to do fast channel change\n");
7728 @@ -1541,22 +1532,19 @@ static bool ath9k_hw_channel_change(stru
7730 ath9k_hw_set_clockrate(ah);
7731 ath9k_hw_apply_txpower(ah, chan, false);
7732 - ath9k_hw_rfbus_done(ah);
7734 - if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
7735 - ath9k_hw_set_delta_slope(ah, chan);
7737 + ath9k_hw_set_delta_slope(ah, chan);
7738 ath9k_hw_spur_mitigate_freq(ah, chan);
7740 - if (edma && (band_switch || mode_diff)) {
7741 - ah->ah_flags |= AH_FASTCC;
7742 - if (band_switch || ini_reloaded)
7743 - ah->eep_ops->set_board_values(ah, chan);
7744 + if (band_switch || ini_reloaded)
7745 + ah->eep_ops->set_board_values(ah, chan);
7747 - ath9k_hw_init_bb(ah, chan);
7748 + ath9k_hw_init_bb(ah, chan);
7749 + ath9k_hw_rfbus_done(ah);
7751 - if (band_switch || ini_reloaded)
7752 - ath9k_hw_init_cal(ah, chan);
7753 + if (band_switch || ini_reloaded) {
7754 + ah->ah_flags |= AH_FASTCC;
7755 + ath9k_hw_init_cal(ah, chan);
7756 ah->ah_flags &= ~AH_FASTCC;
7759 @@ -1778,16 +1766,11 @@ static void ath9k_hw_init_desc(struct at
7761 * Fast channel change:
7762 * (Change synthesizer based on channel freq without resetting chip)
7764 - * Don't do FCC when
7765 - * - Flag is not set
7766 - * - Chip is just coming out of full sleep
7767 - * - Channel to be set is same as current channel
7768 - * - Channel flags are different, (eg.,moving from 2GHz to 5GHz channel)
7770 static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan)
7772 struct ath_common *common = ath9k_hw_common(ah);
7773 + struct ath9k_hw_capabilities *pCap = &ah->caps;
7776 if (AR_SREV_9280(ah) && common->bus_ops->ath_bus_type == ATH_PCI)
7777 @@ -1806,8 +1789,11 @@ static int ath9k_hw_do_fastcc(struct ath
7778 (CHANNEL_HALF | CHANNEL_QUARTER))
7781 - if ((chan->channelFlags & CHANNEL_ALL) !=
7782 - (ah->curchan->channelFlags & CHANNEL_ALL))
7784 + * If cross-band fcc is not supoprted, bail out if channelFlags differ.
7786 + if (!(pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) &&
7787 + chan->channelFlags != ah->curchan->channelFlags)
7790 if (!ath9k_hw_check_alive(ah))
7791 @@ -1870,8 +1856,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
7793 ah->caldata = caldata;
7794 if (caldata && (chan->channel != caldata->channel ||
7795 - chan->channelFlags != caldata->channelFlags ||
7796 - chan->chanmode != caldata->chanmode)) {
7797 + chan->channelFlags != caldata->channelFlags)) {
7798 /* Operating channel changed, reset channel calibration data */
7799 memset(caldata, 0, sizeof(*caldata));
7800 ath9k_init_nfcal_hist_buffer(ah, chan);
7801 @@ -1960,9 +1945,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
7803 ath9k_hw_init_mfp(ah);
7805 - if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
7806 - ath9k_hw_set_delta_slope(ah, chan);
7808 + ath9k_hw_set_delta_slope(ah, chan);
7809 ath9k_hw_spur_mitigate_freq(ah, chan);
7810 ah->eep_ops->set_board_values(ah, chan);
7812 @@ -2047,7 +2030,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
7814 ath9k_hw_apply_gpio_override(ah);
7816 - if (AR_SREV_9565(ah) && ah->shared_chain_lnadiv)
7817 + if (AR_SREV_9565(ah) && common->bt_ant_diversity)
7818 REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON);
7821 @@ -2550,34 +2533,28 @@ int ath9k_hw_fill_cap_info(struct ath_hw
7822 if (AR_SREV_9287_11_OR_LATER(ah) || AR_SREV_9271(ah))
7823 pCap->hw_caps |= ATH9K_HW_CAP_SGI_20;
7825 - if (AR_SREV_9285(ah))
7826 + if (AR_SREV_9285(ah)) {
7827 if (ah->eep_ops->get_eeprom(ah, EEP_MODAL_VER) >= 3) {
7829 ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
7830 - if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1))
7831 + if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1)) {
7832 pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB;
7833 + ath_info(common, "Enable LNA combining\n");
7838 if (AR_SREV_9300_20_OR_LATER(ah)) {
7839 if (ah->eep_ops->get_eeprom(ah, EEP_CHAIN_MASK_REDUCE))
7840 pCap->hw_caps |= ATH9K_HW_CAP_APM;
7844 if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9565(ah)) {
7845 ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
7847 - * enable the diversity-combining algorithm only when
7848 - * both enable_lna_div and enable_fast_div are set
7849 - * Table for Diversity
7850 - * ant_div_alt_lnaconf bit 0-1
7851 - * ant_div_main_lnaconf bit 2-3
7852 - * ant_div_alt_gaintb bit 4
7853 - * ant_div_main_gaintb bit 5
7854 - * enable_ant_div_lnadiv bit 6
7855 - * enable_ant_fast_div bit 7
7857 - if ((ant_div_ctl1 >> 0x6) == 0x3)
7858 + if ((ant_div_ctl1 >> 0x6) == 0x3) {
7859 pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB;
7860 + ath_info(common, "Enable LNA combining\n");
7864 if (ath9k_hw_dfs_tested(ah))
7865 @@ -2610,6 +2587,13 @@ int ath9k_hw_fill_cap_info(struct ath_hw
7866 ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
7867 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
7870 + * Fast channel change across bands is available
7871 + * only for AR9462 and AR9565.
7873 + if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
7874 + pCap->hw_caps |= ATH9K_HW_CAP_FCC_BAND_SWITCH;
7879 @@ -2938,12 +2922,11 @@ void ath9k_hw_set_tsfadjust(struct ath_h
7881 EXPORT_SYMBOL(ath9k_hw_set_tsfadjust);
7883 -void ath9k_hw_set11nmac2040(struct ath_hw *ah)
7884 +void ath9k_hw_set11nmac2040(struct ath_hw *ah, struct ath9k_channel *chan)
7886 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
7889 - if (conf_is_ht40(conf) && !ah->config.cwm_ignore_extcca)
7890 + if (IS_CHAN_HT40(chan) && !ah->config.cwm_ignore_extcca)
7891 macmode = AR_2040_JOINED_RX_CLEAR;
7894 --- a/drivers/net/wireless/ath/ath9k/hw.h
7895 +++ b/drivers/net/wireless/ath/ath9k/hw.h
7896 @@ -247,6 +247,8 @@ enum ath9k_hw_caps {
7897 ATH9K_HW_CAP_DFS = BIT(16),
7898 ATH9K_HW_WOW_DEVICE_CAPABLE = BIT(17),
7899 ATH9K_HW_CAP_PAPRD = BIT(18),
7900 + ATH9K_HW_CAP_FCC_BAND_SWITCH = BIT(19),
7901 + ATH9K_HW_CAP_BT_ANT_DIV = BIT(20),
7905 @@ -309,8 +311,11 @@ struct ath9k_ops_config {
7906 u16 ani_poll_interval; /* ANI poll interval in ms */
7908 /* Platform specific config */
7911 + u32 ant_ctrl_comm2g_switch_enable;
7912 bool xatten_margin_cfg;
7913 + bool alt_mingainidx;
7917 @@ -364,36 +369,6 @@ enum ath9k_int {
7918 ATH9K_INT_NOCARD = 0xffffffff
7921 -#define CHANNEL_CCK 0x00020
7922 -#define CHANNEL_OFDM 0x00040
7923 -#define CHANNEL_2GHZ 0x00080
7924 -#define CHANNEL_5GHZ 0x00100
7925 -#define CHANNEL_PASSIVE 0x00200
7926 -#define CHANNEL_DYN 0x00400
7927 -#define CHANNEL_HALF 0x04000
7928 -#define CHANNEL_QUARTER 0x08000
7929 -#define CHANNEL_HT20 0x10000
7930 -#define CHANNEL_HT40PLUS 0x20000
7931 -#define CHANNEL_HT40MINUS 0x40000
7933 -#define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM)
7934 -#define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK)
7935 -#define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM)
7936 -#define CHANNEL_G_HT20 (CHANNEL_2GHZ|CHANNEL_HT20)
7937 -#define CHANNEL_A_HT20 (CHANNEL_5GHZ|CHANNEL_HT20)
7938 -#define CHANNEL_G_HT40PLUS (CHANNEL_2GHZ|CHANNEL_HT40PLUS)
7939 -#define CHANNEL_G_HT40MINUS (CHANNEL_2GHZ|CHANNEL_HT40MINUS)
7940 -#define CHANNEL_A_HT40PLUS (CHANNEL_5GHZ|CHANNEL_HT40PLUS)
7941 -#define CHANNEL_A_HT40MINUS (CHANNEL_5GHZ|CHANNEL_HT40MINUS)
7942 -#define CHANNEL_ALL \
7948 - CHANNEL_HT40PLUS | \
7949 - CHANNEL_HT40MINUS)
7951 #define MAX_RTT_TABLE_ENTRY 6
7952 #define MAX_IQCAL_MEASUREMENT 8
7953 #define MAX_CL_TAB_ENTRY 16
7954 @@ -401,8 +376,7 @@ enum ath9k_int {
7956 struct ath9k_hw_cal_data {
7964 @@ -425,33 +399,34 @@ struct ath9k_hw_cal_data {
7965 struct ath9k_channel {
7966 struct ieee80211_channel *chan;
7974 -#define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \
7975 - (((_c)->channelFlags & CHANNEL_G_HT20) == CHANNEL_G_HT20) || \
7976 - (((_c)->channelFlags & CHANNEL_G_HT40PLUS) == CHANNEL_G_HT40PLUS) || \
7977 - (((_c)->channelFlags & CHANNEL_G_HT40MINUS) == CHANNEL_G_HT40MINUS))
7978 -#define IS_CHAN_OFDM(_c) (((_c)->channelFlags & CHANNEL_OFDM) != 0)
7979 -#define IS_CHAN_5GHZ(_c) (((_c)->channelFlags & CHANNEL_5GHZ) != 0)
7980 -#define IS_CHAN_2GHZ(_c) (((_c)->channelFlags & CHANNEL_2GHZ) != 0)
7981 -#define IS_CHAN_HALF_RATE(_c) (((_c)->channelFlags & CHANNEL_HALF) != 0)
7982 -#define IS_CHAN_QUARTER_RATE(_c) (((_c)->channelFlags & CHANNEL_QUARTER) != 0)
7983 +#define CHANNEL_5GHZ BIT(0)
7984 +#define CHANNEL_HALF BIT(1)
7985 +#define CHANNEL_QUARTER BIT(2)
7986 +#define CHANNEL_HT BIT(3)
7987 +#define CHANNEL_HT40PLUS BIT(4)
7988 +#define CHANNEL_HT40MINUS BIT(5)
7990 +#define IS_CHAN_5GHZ(_c) (!!((_c)->channelFlags & CHANNEL_5GHZ))
7991 +#define IS_CHAN_2GHZ(_c) (!IS_CHAN_5GHZ(_c))
7993 +#define IS_CHAN_HALF_RATE(_c) (!!((_c)->channelFlags & CHANNEL_HALF))
7994 +#define IS_CHAN_QUARTER_RATE(_c) (!!((_c)->channelFlags & CHANNEL_QUARTER))
7995 #define IS_CHAN_A_FAST_CLOCK(_ah, _c) \
7996 - ((((_c)->channelFlags & CHANNEL_5GHZ) != 0) && \
7997 - ((_ah)->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK))
7998 + (IS_CHAN_5GHZ(_c) && ((_ah)->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK))
8000 +#define IS_CHAN_HT(_c) ((_c)->channelFlags & CHANNEL_HT)
8002 +#define IS_CHAN_HT20(_c) (IS_CHAN_HT(_c) && !IS_CHAN_HT40(_c))
8004 -/* These macros check chanmode and not channelFlags */
8005 -#define IS_CHAN_B(_c) ((_c)->chanmode == CHANNEL_B)
8006 -#define IS_CHAN_HT20(_c) (((_c)->chanmode == CHANNEL_A_HT20) || \
8007 - ((_c)->chanmode == CHANNEL_G_HT20))
8008 -#define IS_CHAN_HT40(_c) (((_c)->chanmode == CHANNEL_A_HT40PLUS) || \
8009 - ((_c)->chanmode == CHANNEL_A_HT40MINUS) || \
8010 - ((_c)->chanmode == CHANNEL_G_HT40PLUS) || \
8011 - ((_c)->chanmode == CHANNEL_G_HT40MINUS))
8012 -#define IS_CHAN_HT(_c) (IS_CHAN_HT20((_c)) || IS_CHAN_HT40((_c)))
8013 +#define IS_CHAN_HT40(_c) \
8014 + (!!((_c)->channelFlags & (CHANNEL_HT40PLUS | CHANNEL_HT40MINUS)))
8016 +#define IS_CHAN_HT40PLUS(_c) ((_c)->channelFlags & CHANNEL_HT40PLUS)
8017 +#define IS_CHAN_HT40MINUS(_c) ((_c)->channelFlags & CHANNEL_HT40MINUS)
8019 enum ath9k_power_mode {
8021 @@ -716,11 +691,14 @@ struct ath_hw_ops {
8022 struct ath_hw_antcomb_conf *antconf);
8023 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
8024 struct ath_hw_antcomb_conf *antconf);
8025 - void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
8026 void (*spectral_scan_config)(struct ath_hw *ah,
8027 struct ath_spec_scan *param);
8028 void (*spectral_scan_trigger)(struct ath_hw *ah);
8029 void (*spectral_scan_wait)(struct ath_hw *ah);
8031 +#ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
8032 + void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
8036 struct ath_nf_limits {
8037 @@ -765,7 +743,6 @@ struct ath_hw {
8040 bool need_an_top2_fixup;
8041 - bool shared_chain_lnadiv;
8045 @@ -1019,7 +996,7 @@ void ath9k_hw_reset_tsf(struct ath_hw *a
8046 void ath9k_hw_set_tsfadjust(struct ath_hw *ah, bool set);
8047 void ath9k_hw_init_global_settings(struct ath_hw *ah);
8048 u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah);
8049 -void ath9k_hw_set11nmac2040(struct ath_hw *ah);
8050 +void ath9k_hw_set11nmac2040(struct ath_hw *ah, struct ath9k_channel *chan);
8051 void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period);
8052 void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
8053 const struct ath9k_beacon_state *bs);
8054 --- a/drivers/net/wireless/ath/ath9k/pci.c
8055 +++ b/drivers/net/wireless/ath/ath9k/pci.c
8056 @@ -29,6 +29,60 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
8057 { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */
8058 { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */
8059 { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */
8061 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8063 + PCI_VENDOR_ID_AZWAVE,
8065 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8066 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8068 + PCI_VENDOR_ID_FOXCONN,
8070 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8071 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8073 + 0x11AD, /* LITEON */
8075 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8076 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8078 + 0x11AD, /* LITEON */
8080 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8081 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8083 + PCI_VENDOR_ID_QMI,
8085 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8086 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8090 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8091 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8093 + 0x10CF, /* Fujitsu */
8095 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8096 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8098 + 0x10CF, /* Fujitsu */
8100 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8101 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8103 + 0x10CF, /* Fujitsu */
8105 + .driver_data = ATH9K_PCI_D3_L1_WAR },
8107 + /* AR9285 card for Asus */
8108 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8110 + PCI_VENDOR_ID_AZWAVE,
8112 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8114 { PCI_VDEVICE(ATHEROS, 0x002B) }, /* PCI-E */
8115 { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */
8116 { PCI_VDEVICE(ATHEROS, 0x002D) }, /* PCI */
8117 @@ -40,29 +94,106 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
8119 PCI_VENDOR_ID_AZWAVE,
8121 - .driver_data = ATH9K_PCI_CUS198 },
8122 + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
8123 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8125 PCI_VENDOR_ID_AZWAVE,
8127 - .driver_data = ATH9K_PCI_CUS198 },
8128 + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
8129 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8131 PCI_VENDOR_ID_AZWAVE,
8133 - .driver_data = ATH9K_PCI_CUS198 },
8134 + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
8135 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8137 + PCI_VENDOR_ID_AZWAVE,
8139 + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV },
8142 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8144 PCI_VENDOR_ID_AZWAVE,
8146 - .driver_data = ATH9K_PCI_CUS230 },
8147 + .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV },
8148 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8150 PCI_VENDOR_ID_FOXCONN,
8152 - .driver_data = ATH9K_PCI_CUS230 },
8153 + .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV },
8156 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8158 + PCI_VENDOR_ID_ATHEROS,
8160 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8161 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8163 + PCI_VENDOR_ID_ATHEROS,
8165 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8166 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8170 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8171 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8175 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8176 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8178 + PCI_VENDOR_ID_SAMSUNG,
8180 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8181 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8183 + PCI_VENDOR_ID_SAMSUNG,
8185 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8186 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8188 + PCI_VENDOR_ID_SAMSUNG,
8190 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8191 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8193 + PCI_VENDOR_ID_SAMSUNG,
8195 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8196 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8198 + PCI_VENDOR_ID_SAMSUNG,
8200 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8201 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8203 + PCI_VENDOR_ID_SAMSUNG,
8205 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8206 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8208 + PCI_VENDOR_ID_SAMSUNG,
8210 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8211 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8213 + PCI_VENDOR_ID_SAMSUNG,
8215 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8216 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8218 + PCI_VENDOR_ID_LENOVO,
8220 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8221 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
8223 + PCI_VENDOR_ID_LENOVO,
8225 + .driver_data = ATH9K_PCI_BT_ANT_DIV },
8227 { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */
8228 { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */
8229 @@ -229,6 +360,22 @@ static void ath_pci_aspm_init(struct ath
8234 + * 0x70c - Ack Frequency Register.
8236 + * Bits 27:29 - DEFAULT_L1_ENTRANCE_LATENCY.
8246 + if (AR_SREV_9462(ah))
8247 + pci_read_config_dword(pdev, 0x70c, &ah->config.aspm_l1_fix);
8249 pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm);
8250 if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) {
8251 ah->aspm_enabled = true;
8252 --- a/drivers/net/wireless/ath/ath9k/phy.h
8253 +++ b/drivers/net/wireless/ath/ath9k/phy.h
8255 #define AR_PHY_PLL_CONTROL 0x16180
8256 #define AR_PHY_PLL_MODE 0x16184
8258 +enum ath9k_ant_div_comb_lna_conf {
8259 + ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2,
8260 + ATH_ANT_DIV_COMB_LNA2,
8261 + ATH_ANT_DIV_COMB_LNA1,
8262 + ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2,
8266 --- a/drivers/net/wireless/iwlwifi/mvm/time-event.c
8267 +++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c
8269 #include "iwl-prph.h"
8271 /* A TimeUnit is 1024 microsecond */
8272 -#define TU_TO_JIFFIES(_tu) (usecs_to_jiffies((_tu) * 1024))
8273 #define MSEC_TO_TU(_msec) (_msec*1000/1024)
8276 @@ -191,8 +190,7 @@ static void iwl_mvm_te_handle_notif(stru
8277 iwl_mvm_te_clear_data(mvm, te_data);
8278 } else if (le32_to_cpu(notif->action) & TE_NOTIF_HOST_EVENT_START) {
8279 te_data->running = true;
8280 - te_data->end_jiffies = jiffies +
8281 - TU_TO_JIFFIES(te_data->duration);
8282 + te_data->end_jiffies = TU_TO_EXP_TIME(te_data->duration);
8284 if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
8285 set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
8286 @@ -329,8 +327,7 @@ void iwl_mvm_protect_session(struct iwl_
8287 lockdep_assert_held(&mvm->mutex);
8289 if (te_data->running &&
8290 - time_after(te_data->end_jiffies,
8291 - jiffies + TU_TO_JIFFIES(min_duration))) {
8292 + time_after(te_data->end_jiffies, TU_TO_EXP_TIME(min_duration))) {
8293 IWL_DEBUG_TE(mvm, "We have enough time in the current TE: %u\n",
8294 jiffies_to_msecs(te_data->end_jiffies - jiffies));
8296 --- a/include/linux/ieee80211.h
8297 +++ b/include/linux/ieee80211.h
8298 @@ -2279,4 +2279,8 @@ static inline bool ieee80211_check_tim(c
8299 return !!(tim->virtual_map[index] & mask);
8302 +/* convert time units */
8303 +#define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024))
8304 +#define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x))
8306 #endif /* LINUX_IEEE80211_H */
8307 --- a/net/mac80211/rate.c
8308 +++ b/net/mac80211/rate.c
8309 @@ -210,7 +210,7 @@ static bool rc_no_data_or_no_ack_use_min
8310 !ieee80211_is_data(fc);
8313 -static void rc_send_low_broadcast(s8 *idx, u32 basic_rates,
8314 +static void rc_send_low_basicrate(s8 *idx, u32 basic_rates,
8315 struct ieee80211_supported_band *sband)
8318 @@ -272,28 +272,37 @@ static void __rate_control_send_low(stru
8322 -bool rate_control_send_low(struct ieee80211_sta *sta,
8323 +bool rate_control_send_low(struct ieee80211_sta *pubsta,
8325 struct ieee80211_tx_rate_control *txrc)
8327 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
8328 struct ieee80211_supported_band *sband = txrc->sband;
8329 + struct sta_info *sta;
8331 + bool use_basicrate = false;
8333 - if (!sta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
8334 - __rate_control_send_low(txrc->hw, sband, sta, info);
8335 + if (!pubsta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) {
8336 + __rate_control_send_low(txrc->hw, sband, pubsta, info);
8338 - if (!sta && txrc->bss) {
8339 + if (!pubsta && txrc->bss) {
8340 mcast_rate = txrc->bss_conf->mcast_rate[sband->band];
8341 if (mcast_rate > 0) {
8342 info->control.rates[0].idx = mcast_rate - 1;
8345 + use_basicrate = true;
8346 + } else if (pubsta) {
8347 + sta = container_of(pubsta, struct sta_info, sta);
8348 + if (ieee80211_vif_is_mesh(&sta->sdata->vif))
8349 + use_basicrate = true;
8352 - rc_send_low_broadcast(&info->control.rates[0].idx,
8353 + if (use_basicrate)
8354 + rc_send_low_basicrate(&info->control.rates[0].idx,
8355 txrc->bss_conf->basic_rates,
8362 --- a/drivers/net/wireless/ath/ath9k/Kconfig
8363 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
8364 @@ -60,7 +60,7 @@ config ATH9K_AHB
8366 config ATH9K_DEBUGFS
8367 bool "Atheros ath9k debugging"
8369 + depends on ATH9K && DEBUG_FS
8370 select MAC80211_DEBUGFS
8373 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
8374 +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
8375 @@ -269,13 +269,12 @@ static void ar9002_hw_configpcipowersave
8376 if (ah->config.pcie_waen & AR_WA_D3_L1_DISABLE)
8377 val |= AR_WA_D3_L1_DISABLE;
8379 - if (((AR_SREV_9285(ah) ||
8380 - AR_SREV_9271(ah) ||
8381 - AR_SREV_9287(ah)) &&
8382 - (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)) ||
8383 - (AR_SREV_9280(ah) &&
8384 - (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE))) {
8385 - val |= AR_WA_D3_L1_DISABLE;
8386 + if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || AR_SREV_9287(ah)) {
8387 + if (AR9285_WA_DEFAULT & AR_WA_D3_L1_DISABLE)
8388 + val |= AR_WA_D3_L1_DISABLE;
8389 + } else if (AR_SREV_9280(ah)) {
8390 + if (AR9280_WA_DEFAULT & AR_WA_D3_L1_DISABLE)
8391 + val |= AR_WA_D3_L1_DISABLE;
8395 @@ -297,24 +296,18 @@ static void ar9002_hw_configpcipowersave
8397 if (ah->config.pcie_waen) {
8398 val = ah->config.pcie_waen;
8400 - val &= (~AR_WA_D3_L1_DISABLE);
8401 + val &= (~AR_WA_D3_L1_DISABLE);
8403 - if (AR_SREV_9285(ah) ||
8404 - AR_SREV_9271(ah) ||
8405 - AR_SREV_9287(ah)) {
8406 + if (AR_SREV_9285(ah) || AR_SREV_9271(ah) || AR_SREV_9287(ah)) {
8407 val = AR9285_WA_DEFAULT;
8409 - val &= (~AR_WA_D3_L1_DISABLE);
8411 - else if (AR_SREV_9280(ah)) {
8412 + val &= (~AR_WA_D3_L1_DISABLE);
8413 + } else if (AR_SREV_9280(ah)) {
8415 * For AR9280 chips, bit 22 of 0x4004
8418 val = AR9280_WA_DEFAULT;
8420 - val &= (~AR_WA_D3_L1_DISABLE);
8421 + val &= (~AR_WA_D3_L1_DISABLE);
8423 val = AR_WA_DEFAULT;
8425 @@ -426,28 +419,10 @@ void ar9002_hw_load_ani_reg(struct ath_h
8429 - switch (chan->chanmode) {
8431 - case CHANNEL_A_HT20:
8434 - case CHANNEL_A_HT40PLUS:
8435 - case CHANNEL_A_HT40MINUS:
8439 - case CHANNEL_G_HT20:
8443 - case CHANNEL_G_HT40PLUS:
8444 - case CHANNEL_G_HT40MINUS:
8451 + if (IS_CHAN_5GHZ(chan))
8452 + modesIndex = IS_CHAN_HT40(chan) ? 2 : 1;
8454 + modesIndex = IS_CHAN_HT40(chan) ? 3 : 4;
8456 ENABLE_REGWRITE_BUFFER(ah);
8458 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
8459 +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
8460 @@ -153,7 +153,7 @@ static void ar9003_hw_init_mode_regs(str
8461 if (!ah->is_clk_25mhz)
8462 INIT_INI_ARRAY(&ah->iniAdditional,
8463 ar9340_1p0_radio_core_40M);
8464 - } else if (AR_SREV_9485_11(ah)) {
8465 + } else if (AR_SREV_9485_11_OR_LATER(ah)) {
8467 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
8468 ar9485_1_1_mac_core);
8469 @@ -424,7 +424,7 @@ static void ar9003_tx_gain_table_mode0(s
8470 else if (AR_SREV_9340(ah))
8471 INIT_INI_ARRAY(&ah->iniModesTxGain,
8472 ar9340Modes_lowest_ob_db_tx_gain_table_1p0);
8473 - else if (AR_SREV_9485_11(ah))
8474 + else if (AR_SREV_9485_11_OR_LATER(ah))
8475 INIT_INI_ARRAY(&ah->iniModesTxGain,
8476 ar9485_modes_lowest_ob_db_tx_gain_1_1);
8477 else if (AR_SREV_9550(ah))
8478 @@ -458,7 +458,7 @@ static void ar9003_tx_gain_table_mode1(s
8479 else if (AR_SREV_9340(ah))
8480 INIT_INI_ARRAY(&ah->iniModesTxGain,
8481 ar9340Modes_high_ob_db_tx_gain_table_1p0);
8482 - else if (AR_SREV_9485_11(ah))
8483 + else if (AR_SREV_9485_11_OR_LATER(ah))
8484 INIT_INI_ARRAY(&ah->iniModesTxGain,
8485 ar9485Modes_high_ob_db_tx_gain_1_1);
8486 else if (AR_SREV_9580(ah))
8487 @@ -492,7 +492,7 @@ static void ar9003_tx_gain_table_mode2(s
8488 else if (AR_SREV_9340(ah))
8489 INIT_INI_ARRAY(&ah->iniModesTxGain,
8490 ar9340Modes_low_ob_db_tx_gain_table_1p0);
8491 - else if (AR_SREV_9485_11(ah))
8492 + else if (AR_SREV_9485_11_OR_LATER(ah))
8493 INIT_INI_ARRAY(&ah->iniModesTxGain,
8494 ar9485Modes_low_ob_db_tx_gain_1_1);
8495 else if (AR_SREV_9580(ah))
8496 @@ -517,7 +517,7 @@ static void ar9003_tx_gain_table_mode3(s
8497 else if (AR_SREV_9340(ah))
8498 INIT_INI_ARRAY(&ah->iniModesTxGain,
8499 ar9340Modes_high_power_tx_gain_table_1p0);
8500 - else if (AR_SREV_9485_11(ah))
8501 + else if (AR_SREV_9485_11_OR_LATER(ah))
8502 INIT_INI_ARRAY(&ah->iniModesTxGain,
8503 ar9485Modes_high_power_tx_gain_1_1);
8504 else if (AR_SREV_9580(ah))
8505 @@ -552,7 +552,7 @@ static void ar9003_tx_gain_table_mode4(s
8507 static void ar9003_tx_gain_table_mode5(struct ath_hw *ah)
8509 - if (AR_SREV_9485_11(ah))
8510 + if (AR_SREV_9485_11_OR_LATER(ah))
8511 INIT_INI_ARRAY(&ah->iniModesTxGain,
8512 ar9485Modes_green_ob_db_tx_gain_1_1);
8513 else if (AR_SREV_9340(ah))
8514 @@ -571,7 +571,7 @@ static void ar9003_tx_gain_table_mode6(s
8515 if (AR_SREV_9340(ah))
8516 INIT_INI_ARRAY(&ah->iniModesTxGain,
8517 ar9340Modes_low_ob_db_and_spur_tx_gain_table_1p0);
8518 - else if (AR_SREV_9485_11(ah))
8519 + else if (AR_SREV_9485_11_OR_LATER(ah))
8520 INIT_INI_ARRAY(&ah->iniModesTxGain,
8521 ar9485Modes_green_spur_ob_db_tx_gain_1_1);
8522 else if (AR_SREV_9580(ah))
8523 @@ -611,7 +611,7 @@ static void ar9003_rx_gain_table_mode0(s
8524 else if (AR_SREV_9340(ah))
8525 INIT_INI_ARRAY(&ah->iniModesRxGain,
8526 ar9340Common_rx_gain_table_1p0);
8527 - else if (AR_SREV_9485_11(ah))
8528 + else if (AR_SREV_9485_11_OR_LATER(ah))
8529 INIT_INI_ARRAY(&ah->iniModesRxGain,
8530 ar9485_common_rx_gain_1_1);
8531 else if (AR_SREV_9550(ah)) {
8532 @@ -644,7 +644,7 @@ static void ar9003_rx_gain_table_mode1(s
8533 else if (AR_SREV_9340(ah))
8534 INIT_INI_ARRAY(&ah->iniModesRxGain,
8535 ar9340Common_wo_xlna_rx_gain_table_1p0);
8536 - else if (AR_SREV_9485_11(ah))
8537 + else if (AR_SREV_9485_11_OR_LATER(ah))
8538 INIT_INI_ARRAY(&ah->iniModesRxGain,
8539 ar9485Common_wo_xlna_rx_gain_1_1);
8540 else if (AR_SREV_9462_21(ah))
8541 @@ -745,16 +745,25 @@ static void ar9003_hw_init_mode_gain_reg
8542 static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
8546 + * Increase L1 Entry Latency. Some WB222 boards don't have
8547 + * this change in eeprom/OTP.
8550 + if (AR_SREV_9462(ah)) {
8551 + u32 val = ah->config.aspm_l1_fix;
8552 + if ((val & 0xff000000) == 0x17000000) {
8553 + val &= 0x00ffffff;
8554 + val |= 0x27000000;
8555 + REG_WRITE(ah, 0x570c, val);
8559 /* Nothing to do on restore for 11N */
8560 if (!power_off /* !restore */) {
8561 /* set bit 19 to allow forcing of pcie core into L1 state */
8562 REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA);
8564 - /* Several PCIe massages to ensure proper behaviour */
8565 - if (ah->config.pcie_waen)
8566 - REG_WRITE(ah, AR_WA, ah->config.pcie_waen);
8568 - REG_WRITE(ah, AR_WA, ah->WARegVal);
8569 + REG_WRITE(ah, AR_WA, ah->WARegVal);
8573 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
8574 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
8575 @@ -491,6 +491,7 @@ int ath9k_hw_process_rxdesc_edma(struct
8576 rxs->rs_rate = MS(rxsp->status1, AR_RxRate);
8577 rxs->rs_more = (rxsp->status2 & AR_RxMore) ? 1 : 0;
8579 + rxs->rs_firstaggr = (rxsp->status11 & AR_RxFirstAggr) ? 1 : 0;
8580 rxs->rs_isaggr = (rxsp->status11 & AR_RxAggr) ? 1 : 0;
8581 rxs->rs_moreaggr = (rxsp->status11 & AR_RxMoreAggr) ? 1 : 0;
8582 rxs->rs_antenna = (MS(rxsp->status4, AR_RxAntenna) & 0x7);
8583 --- a/drivers/net/wireless/ath/ath9k/common.c
8584 +++ b/drivers/net/wireless/ath/ath9k/common.c
8585 @@ -49,88 +49,64 @@ int ath9k_cmn_get_hw_crypto_keytype(stru
8587 EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype);
8589 -static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan,
8590 - enum nl80211_channel_type channel_type)
8594 - switch (chan->band) {
8595 - case IEEE80211_BAND_2GHZ:
8596 - switch (channel_type) {
8597 - case NL80211_CHAN_NO_HT:
8598 - case NL80211_CHAN_HT20:
8599 - chanmode = CHANNEL_G_HT20;
8601 - case NL80211_CHAN_HT40PLUS:
8602 - chanmode = CHANNEL_G_HT40PLUS;
8604 - case NL80211_CHAN_HT40MINUS:
8605 - chanmode = CHANNEL_G_HT40MINUS;
8609 - case IEEE80211_BAND_5GHZ:
8610 - switch (channel_type) {
8611 - case NL80211_CHAN_NO_HT:
8612 - case NL80211_CHAN_HT20:
8613 - chanmode = CHANNEL_A_HT20;
8615 - case NL80211_CHAN_HT40PLUS:
8616 - chanmode = CHANNEL_A_HT40PLUS;
8618 - case NL80211_CHAN_HT40MINUS:
8619 - chanmode = CHANNEL_A_HT40MINUS;
8631 * Update internal channel flags.
8633 -void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
8634 - struct ieee80211_channel *chan,
8635 - enum nl80211_channel_type channel_type)
8636 +static void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
8637 + struct cfg80211_chan_def *chandef)
8639 + struct ieee80211_channel *chan = chandef->chan;
8642 ichan->channel = chan->center_freq;
8645 - if (chan->band == IEEE80211_BAND_2GHZ) {
8646 - ichan->chanmode = CHANNEL_G;
8647 - ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM;
8649 - ichan->chanmode = CHANNEL_A;
8650 - ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
8651 + if (chan->band == IEEE80211_BAND_5GHZ)
8652 + flags |= CHANNEL_5GHZ;
8654 + switch (chandef->width) {
8655 + case NL80211_CHAN_WIDTH_5:
8656 + flags |= CHANNEL_QUARTER;
8658 + case NL80211_CHAN_WIDTH_10:
8659 + flags |= CHANNEL_HALF;
8661 + case NL80211_CHAN_WIDTH_20_NOHT:
8663 + case NL80211_CHAN_WIDTH_20:
8664 + flags |= CHANNEL_HT;
8666 + case NL80211_CHAN_WIDTH_40:
8667 + if (chandef->center_freq1 > chandef->chan->center_freq)
8668 + flags |= CHANNEL_HT40PLUS | CHANNEL_HT;
8670 + flags |= CHANNEL_HT40MINUS | CHANNEL_HT;
8676 - if (channel_type != NL80211_CHAN_NO_HT)
8677 - ichan->chanmode = ath9k_get_extchanmode(chan, channel_type);
8678 + ichan->channelFlags = flags;
8680 -EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
8683 * Get the internal channel reference.
8685 -struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
8686 - struct ath_hw *ah)
8687 +struct ath9k_channel *ath9k_cmn_get_channel(struct ieee80211_hw *hw,
8688 + struct ath_hw *ah,
8689 + struct cfg80211_chan_def *chandef)
8691 - struct ieee80211_channel *curchan = hw->conf.chandef.chan;
8692 + struct ieee80211_channel *curchan = chandef->chan;
8693 struct ath9k_channel *channel;
8696 chan_idx = curchan->hw_value;
8697 channel = &ah->channels[chan_idx];
8698 - ath9k_cmn_update_ichannel(channel, curchan,
8699 - cfg80211_get_chandef_type(&hw->conf.chandef));
8700 + ath9k_cmn_update_ichannel(channel, chandef);
8704 -EXPORT_SYMBOL(ath9k_cmn_get_curchannel);
8705 +EXPORT_SYMBOL(ath9k_cmn_get_channel);
8707 int ath9k_cmn_count_streams(unsigned int chainmask, int max)
8709 --- a/drivers/net/wireless/ath/ath9k/common.h
8710 +++ b/drivers/net/wireless/ath/ath9k/common.h
8712 (((x) + ((mul)/2)) / (mul))
8714 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
8715 -void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
8716 - struct ieee80211_channel *chan,
8717 - enum nl80211_channel_type channel_type);
8718 -struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
8719 - struct ath_hw *ah);
8720 +struct ath9k_channel *ath9k_cmn_get_channel(struct ieee80211_hw *hw,
8721 + struct ath_hw *ah,
8722 + struct cfg80211_chan_def *chandef);
8723 int ath9k_cmn_count_streams(unsigned int chainmask, int max);
8724 void ath9k_cmn_btcoex_bt_stomp(struct ath_common *common,
8725 enum ath_stomp_type stomp_type);
8726 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
8727 +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
8728 @@ -115,10 +115,10 @@ static int hif_usb_send_regout(struct hi
8730 cmd->hif_dev = hif_dev;
8732 - usb_fill_bulk_urb(urb, hif_dev->udev,
8733 - usb_sndbulkpipe(hif_dev->udev, USB_REG_OUT_PIPE),
8734 + usb_fill_int_urb(urb, hif_dev->udev,
8735 + usb_sndintpipe(hif_dev->udev, USB_REG_OUT_PIPE),
8736 skb->data, skb->len,
8737 - hif_usb_regout_cb, cmd);
8738 + hif_usb_regout_cb, cmd, 1);
8740 usb_anchor_urb(urb, &hif_dev->regout_submitted);
8741 ret = usb_submit_urb(urb, GFP_KERNEL);
8742 @@ -723,11 +723,11 @@ static void ath9k_hif_usb_reg_in_cb(stru
8746 - usb_fill_bulk_urb(urb, hif_dev->udev,
8747 - usb_rcvbulkpipe(hif_dev->udev,
8748 + usb_fill_int_urb(urb, hif_dev->udev,
8749 + usb_rcvintpipe(hif_dev->udev,
8751 nskb->data, MAX_REG_IN_BUF_SIZE,
8752 - ath9k_hif_usb_reg_in_cb, nskb);
8753 + ath9k_hif_usb_reg_in_cb, nskb, 1);
8757 @@ -909,11 +909,11 @@ static int ath9k_hif_usb_alloc_reg_in_ur
8761 - usb_fill_bulk_urb(urb, hif_dev->udev,
8762 - usb_rcvbulkpipe(hif_dev->udev,
8763 + usb_fill_int_urb(urb, hif_dev->udev,
8764 + usb_rcvintpipe(hif_dev->udev,
8766 skb->data, MAX_REG_IN_BUF_SIZE,
8767 - ath9k_hif_usb_reg_in_cb, skb);
8768 + ath9k_hif_usb_reg_in_cb, skb, 1);
8771 usb_anchor_urb(urb, &hif_dev->reg_in_submitted);
8772 @@ -1031,9 +1031,7 @@ static int ath9k_hif_usb_download_fw(str
8774 static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev)
8776 - struct usb_host_interface *alt = &hif_dev->interface->altsetting[0];
8777 - struct usb_endpoint_descriptor *endp;
8781 ret = ath9k_hif_usb_download_fw(hif_dev);
8783 @@ -1043,20 +1041,6 @@ static int ath9k_hif_usb_dev_init(struct
8787 - /* On downloading the firmware to the target, the USB descriptor of EP4
8788 - * is 'patched' to change the type of the endpoint to Bulk. This will
8789 - * bring down CPU usage during the scan period.
8791 - for (idx = 0; idx < alt->desc.bNumEndpoints; idx++) {
8792 - endp = &alt->endpoint[idx].desc;
8793 - if ((endp->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
8794 - == USB_ENDPOINT_XFER_INT) {
8795 - endp->bmAttributes &= ~USB_ENDPOINT_XFERTYPE_MASK;
8796 - endp->bmAttributes |= USB_ENDPOINT_XFER_BULK;
8797 - endp->bInterval = 0;
8802 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
8804 @@ -1268,7 +1252,7 @@ static void ath9k_hif_usb_reboot(struct
8808 - ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, USB_REG_OUT_PIPE),
8809 + ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE),
8812 dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n");
8813 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
8814 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
8816 static enum htc_phymode ath9k_htc_get_curmode(struct ath9k_htc_priv *priv,
8817 struct ath9k_channel *ichan)
8819 - enum htc_phymode mode;
8823 - switch (ichan->chanmode) {
8825 - case CHANNEL_G_HT20:
8826 - case CHANNEL_G_HT40PLUS:
8827 - case CHANNEL_G_HT40MINUS:
8828 - mode = HTC_MODE_11NG;
8831 - case CHANNEL_A_HT20:
8832 - case CHANNEL_A_HT40PLUS:
8833 - case CHANNEL_A_HT40MINUS:
8834 - mode = HTC_MODE_11NA;
8839 + if (IS_CHAN_5GHZ(ichan))
8840 + return HTC_MODE_11NA;
8842 - WARN_ON(mode < 0);
8845 + return HTC_MODE_11NG;
8848 bool ath9k_htc_setpower(struct ath9k_htc_priv *priv,
8849 @@ -926,7 +906,7 @@ static int ath9k_htc_start(struct ieee80
8850 WMI_CMD(WMI_FLUSH_RECV_CMDID);
8852 /* setup initial channel */
8853 - init_channel = ath9k_cmn_get_curchannel(hw, ah);
8854 + init_channel = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
8856 ret = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
8858 @@ -1203,17 +1183,12 @@ static int ath9k_htc_config(struct ieee8
8860 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) {
8861 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
8862 - enum nl80211_channel_type channel_type =
8863 - cfg80211_get_chandef_type(&hw->conf.chandef);
8864 int pos = curchan->hw_value;
8866 ath_dbg(common, CONFIG, "Set channel: %d MHz\n",
8867 curchan->center_freq);
8869 - ath9k_cmn_update_ichannel(&priv->ah->channels[pos],
8870 - hw->conf.chandef.chan,
8873 + ath9k_cmn_get_channel(hw, priv->ah, &hw->conf.chandef);
8874 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
8875 ath_err(common, "Unable to set channel\n");
8877 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
8878 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
8879 @@ -448,6 +448,7 @@ static void ath9k_htc_tx_process(struct
8880 struct ieee80211_conf *cur_conf = &priv->hw->conf;
8883 + int hdrlen, padsize;
8885 slot = strip_drv_header(priv, skb);
8887 @@ -504,6 +505,15 @@ send_mac80211:
8889 ath9k_htc_tx_clear_slot(priv, slot);
8891 + /* Remove padding before handing frame back to mac80211 */
8892 + hdrlen = ieee80211_get_hdrlen_from_skb(skb);
8894 + padsize = hdrlen & 3;
8895 + if (padsize && skb->len > hdrlen + padsize) {
8896 + memmove(skb->data + padsize, skb->data, hdrlen);
8897 + skb_pull(skb, padsize);
8900 /* Send status to mac80211 */
8901 ieee80211_tx_status(priv->hw, skb);
8903 --- a/drivers/net/wireless/ath/ath9k/link.c
8904 +++ b/drivers/net/wireless/ath/ath9k/link.c
8905 @@ -41,7 +41,7 @@ void ath_tx_complete_poll_work(struct wo
8906 txq->axq_tx_inprogress = true;
8909 - ath_txq_unlock_complete(sc, txq);
8910 + ath_txq_unlock(sc, txq);
8914 --- a/drivers/net/wireless/ath/ath9k/mac.c
8915 +++ b/drivers/net/wireless/ath/ath9k/mac.c
8916 @@ -374,7 +374,6 @@ EXPORT_SYMBOL(ath9k_hw_releasetxqueue);
8917 bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q)
8919 struct ath_common *common = ath9k_hw_common(ah);
8920 - struct ath9k_channel *chan = ah->curchan;
8921 struct ath9k_tx_queue_info *qi;
8922 u32 cwMin, chanCwMin, value;
8924 @@ -387,10 +386,7 @@ bool ath9k_hw_resettxqueue(struct ath_hw
8925 ath_dbg(common, QUEUE, "Reset TX queue: %u\n", q);
8927 if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) {
8928 - if (chan && IS_CHAN_B(chan))
8929 - chanCwMin = INIT_CWMIN_11B;
8931 - chanCwMin = INIT_CWMIN;
8932 + chanCwMin = INIT_CWMIN;
8934 for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1);
8936 @@ -583,9 +579,9 @@ int ath9k_hw_rxprocdesc(struct ath_hw *a
8937 rs->rs_rate = MS(ads.ds_rxstatus0, AR_RxRate);
8938 rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
8940 + rs->rs_firstaggr = (ads.ds_rxstatus8 & AR_RxFirstAggr) ? 1 : 0;
8941 rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
8943 - (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
8944 + rs->rs_moreaggr = (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
8945 rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
8947 /* directly mapped flags for ieee80211_rx_status */
8948 --- a/drivers/net/wireless/ath/ath9k/mac.h
8949 +++ b/drivers/net/wireless/ath/ath9k/mac.h
8950 @@ -140,6 +140,7 @@ struct ath_rx_status {
8951 int8_t rs_rssi_ext1;
8952 int8_t rs_rssi_ext2;
8958 @@ -569,6 +570,7 @@ struct ar5416_desc {
8959 #define AR_RxAggr 0x00020000
8960 #define AR_PostDelimCRCErr 0x00040000
8961 #define AR_RxStatusRsvd71 0x3ff80000
8962 +#define AR_RxFirstAggr 0x20000000
8963 #define AR_DecryptBusyErr 0x40000000
8964 #define AR_KeyMiss 0x80000000
8966 @@ -601,8 +603,6 @@ enum ath9k_tx_queue_flags {
8967 #define ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS 0x00000001
8969 #define ATH9K_DECOMP_MASK_SIZE 128
8970 -#define ATH9K_READY_TIME_LO_BOUND 50
8971 -#define ATH9K_READY_TIME_HI_BOUND 96
8973 enum ath9k_pkt_type {
8974 ATH9K_PKT_TYPE_NORMAL = 0,
8975 --- a/drivers/net/wireless/ath/ath9k/rc.c
8976 +++ b/drivers/net/wireless/ath/ath9k/rc.c
8977 @@ -1324,8 +1324,8 @@ static void ath_rate_update(void *priv,
8978 ath_rc_init(sc, priv_sta);
8980 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG,
8981 - "Operating HT Bandwidth changed to: %d\n",
8982 - cfg80211_get_chandef_type(&sc->hw->conf.chandef));
8983 + "Operating Bandwidth changed to: %d\n",
8984 + sc->hw->conf.chandef.width);
8988 --- a/drivers/net/wireless/ath/ath9k/reg.h
8989 +++ b/drivers/net/wireless/ath/ath9k/reg.h
8992 #define AR_SREV_9485(_ah) \
8993 (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485))
8994 -#define AR_SREV_9485_11(_ah) \
8995 - (AR_SREV_9485(_ah) && \
8996 - ((_ah)->hw_version.macRev == AR_SREV_REVISION_9485_11))
8997 +#define AR_SREV_9485_11_OR_LATER(_ah) \
8998 + (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485) && \
8999 + ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9485_11))
9000 #define AR_SREV_9485_OR_LATER(_ah) \
9001 (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9485))
9003 --- a/net/mac80211/main.c
9004 +++ b/net/mac80211/main.c
9005 @@ -101,7 +101,7 @@ static u32 ieee80211_hw_conf_chan(struct
9006 struct ieee80211_sub_if_data *sdata;
9007 struct cfg80211_chan_def chandef = {};
9011 u32 offchannel_flag;
9013 offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;
9014 @@ -155,16 +155,16 @@ static u32 ieee80211_hw_conf_chan(struct
9015 changed |= IEEE80211_CONF_CHANGE_SMPS;
9018 - power = chandef.chan->max_power;
9021 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
9022 if (!rcu_access_pointer(sdata->vif.chanctx_conf))
9024 - power = min(power, sdata->vif.bss_conf.txpower);
9025 + power = max(power, sdata->vif.bss_conf.txpower);
9029 + power = min(power, chandef.chan->max_power);
9031 if (local->hw.conf.power_level != power) {
9032 changed |= IEEE80211_CONF_CHANGE_POWER;
9033 local->hw.conf.power_level = power;
9034 --- a/net/mac80211/status.c
9035 +++ b/net/mac80211/status.c
9036 @@ -180,6 +180,9 @@ static void ieee80211_frame_acked(struct
9037 struct ieee80211_local *local = sta->local;
9038 struct ieee80211_sub_if_data *sdata = sta->sdata;
9040 + if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
9041 + sta->last_rx = jiffies;
9043 if (ieee80211_is_data_qos(mgmt->frame_control)) {
9044 struct ieee80211_hdr *hdr = (void *) skb->data;
9045 u8 *qc = ieee80211_get_qos_ctl(hdr);
9046 --- a/drivers/net/wireless/ath/ath9k/ani.c
9047 +++ b/drivers/net/wireless/ath/ath9k/ani.c
9048 @@ -341,10 +341,9 @@ void ath9k_ani_reset(struct ath_hw *ah,
9049 aniState->cckNoiseImmunityLevel !=
9050 ATH9K_ANI_CCK_DEF_LEVEL) {
9051 ath_dbg(common, ANI,
9052 - "Restore defaults: opmode %u chan %d Mhz/0x%x is_scanning=%d ofdm:%d cck:%d\n",
9053 + "Restore defaults: opmode %u chan %d Mhz is_scanning=%d ofdm:%d cck:%d\n",
9056 - chan->channelFlags,
9058 aniState->ofdmNoiseImmunityLevel,
9059 aniState->cckNoiseImmunityLevel);
9060 @@ -357,10 +356,9 @@ void ath9k_ani_reset(struct ath_hw *ah,
9061 * restore historical levels for this channel
9063 ath_dbg(common, ANI,
9064 - "Restore history: opmode %u chan %d Mhz/0x%x is_scanning=%d ofdm:%d cck:%d\n",
9065 + "Restore history: opmode %u chan %d Mhz is_scanning=%d ofdm:%d cck:%d\n",
9068 - chan->channelFlags,
9070 aniState->ofdmNoiseImmunityLevel,
9071 aniState->cckNoiseImmunityLevel);
9072 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
9073 +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
9074 @@ -33,15 +33,12 @@ static bool ar9002_hw_is_cal_supported(s
9075 bool supported = false;
9076 switch (ah->supp_cals & cal_type) {
9077 case IQ_MISMATCH_CAL:
9078 - /* Run IQ Mismatch for non-CCK only */
9079 - if (!IS_CHAN_B(chan))
9085 /* Run ADC Gain Cal for non-CCK & non 2GHz-HT20 only */
9086 - if (!IS_CHAN_B(chan) &&
9087 - !((IS_CHAN_2GHZ(chan) || IS_CHAN_A_FAST_CLOCK(ah, chan)) &&
9088 + if (!((IS_CHAN_2GHZ(chan) || IS_CHAN_A_FAST_CLOCK(ah, chan)) &&
9089 IS_CHAN_HT20(chan)))
9092 --- a/drivers/net/wireless/ath/ath9k/calib.c
9093 +++ b/drivers/net/wireless/ath/ath9k/calib.c
9094 @@ -186,7 +186,6 @@ void ath9k_hw_reset_calibration(struct a
9095 bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
9097 struct ath_common *common = ath9k_hw_common(ah);
9098 - struct ieee80211_conf *conf = &common->hw->conf;
9099 struct ath9k_cal_list *currCal = ah->cal_list_curr;
9102 @@ -208,7 +207,7 @@ bool ath9k_hw_reset_calvalid(struct ath_
9105 ath_dbg(common, CALIBRATE, "Resetting Cal %d state for channel %u\n",
9106 - currCal->calData->calType, conf->chandef.chan->center_freq);
9107 + currCal->calData->calType, ah->curchan->chan->center_freq);
9109 ah->caldata->CalValid &= ~currCal->calData->calType;
9110 currCal->calState = CAL_WAITING;
9111 @@ -242,7 +241,6 @@ void ath9k_hw_loadnf(struct ath_hw *ah,
9113 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
9114 struct ath_common *common = ath9k_hw_common(ah);
9115 - struct ieee80211_conf *conf = &common->hw->conf;
9116 s16 default_nf = ath9k_hw_get_default_nf(ah, chan);
9119 @@ -252,7 +250,7 @@ void ath9k_hw_loadnf(struct ath_hw *ah,
9120 if (chainmask & (1 << i)) {
9123 - if ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))
9124 + if ((i >= AR5416_MAX_CHAINS) && !IS_CHAN_HT40(chan))
9128 @@ -314,7 +312,7 @@ void ath9k_hw_loadnf(struct ath_hw *ah,
9129 ENABLE_REGWRITE_BUFFER(ah);
9130 for (i = 0; i < NUM_NF_READINGS; i++) {
9131 if (chainmask & (1 << i)) {
9132 - if ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))
9133 + if ((i >= AR5416_MAX_CHAINS) && !IS_CHAN_HT40(chan))
9136 val = REG_READ(ah, ah->nf_regs[i]);
9137 @@ -408,7 +406,6 @@ void ath9k_init_nfcal_hist_buffer(struct
9139 ah->caldata->channel = chan->channel;
9140 ah->caldata->channelFlags = chan->channelFlags;
9141 - ah->caldata->chanmode = chan->chanmode;
9142 h = ah->caldata->nfCalHist;
9143 default_nf = ath9k_hw_get_default_nf(ah, chan);
9144 for (i = 0; i < NUM_NF_READINGS; i++) {
9145 --- a/drivers/net/wireless/ath/ath9k/mci.c
9146 +++ b/drivers/net/wireless/ath/ath9k/mci.c
9147 @@ -661,9 +661,9 @@ void ath9k_mci_update_wlan_channels(stru
9148 chan_start = wlan_chan - 10;
9149 chan_end = wlan_chan + 10;
9151 - if (chan->chanmode == CHANNEL_G_HT40PLUS)
9152 + if (IS_CHAN_HT40PLUS(chan))
9154 - else if (chan->chanmode == CHANNEL_G_HT40MINUS)
9155 + else if (IS_CHAN_HT40MINUS(chan))
9158 /* adjust side band */
9159 @@ -707,11 +707,11 @@ void ath9k_mci_set_txpower(struct ath_so
9162 struct ath9k_hw_cal_data *caldata = &sc->caldata;
9163 - if ((caldata->chanmode == CHANNEL_G_HT40PLUS) &&
9164 + if (IS_CHAN_HT40PLUS(ah->curchan) &&
9165 (ah->curchan->channel > caldata->channel) &&
9166 (ah->curchan->channel <= caldata->channel + 20))
9168 - if ((caldata->chanmode == CHANNEL_G_HT40MINUS) &&
9169 + if (IS_CHAN_HT40MINUS(ah->curchan) &&
9170 (ah->curchan->channel < caldata->channel) &&
9171 (ah->curchan->channel >= caldata->channel - 20))