1 --- a/drivers/net/wireless/ath/ath9k/recv.c
2 +++ b/drivers/net/wireless/ath/ath9k/recv.c
3 @@ -34,27 +34,6 @@ static inline bool ath9k_check_auto_slee
4 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP);
7 -static struct ieee80211_hw * ath_get_virt_hw(struct ath_softc *sc,
8 - struct ieee80211_hdr *hdr)
10 - struct ieee80211_hw *hw = sc->pri_wiphy->hw;
13 - spin_lock_bh(&sc->wiphy_lock);
14 - for (i = 0; i < sc->num_sec_wiphy; i++) {
15 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
18 - if (compare_ether_addr(hdr->addr1, aphy->hw->wiphy->perm_addr)
24 - spin_unlock_bh(&sc->wiphy_lock);
29 * Setup and link descriptors.
31 @@ -463,8 +442,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
32 if (conf_is_ht(&sc->hw->conf))
33 rfilt |= ATH9K_RX_FILTER_COMP_BAR;
35 - if (sc->sec_wiphy || (sc->nvifs > 1) ||
36 - (sc->rx.rxfilter & FIF_OTHER_BSS)) {
37 + if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
38 /* The following may also be needed for other older chips */
39 if (sc->sc_ah->hw_version.macVersion == AR_SREV_VERSION_9160)
40 rfilt |= ATH9K_RX_FILTER_PROM;
41 @@ -668,37 +646,6 @@ static void ath_rx_ps(struct ath_softc *
45 -static void ath_rx_send_to_mac80211(struct ieee80211_hw *hw,
46 - struct ath_softc *sc, struct sk_buff *skb)
48 - struct ieee80211_hdr *hdr;
50 - hdr = (struct ieee80211_hdr *)skb->data;
52 - /* Send the frame to mac80211 */
53 - if (is_multicast_ether_addr(hdr->addr1)) {
56 - * Deliver broadcast/multicast frames to all suitable
59 - /* TODO: filter based on channel configuration */
60 - for (i = 0; i < sc->num_sec_wiphy; i++) {
61 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
62 - struct sk_buff *nskb;
65 - nskb = skb_copy(skb, GFP_ATOMIC);
68 - ieee80211_rx(aphy->hw, nskb);
70 - ieee80211_rx(sc->hw, skb);
72 - /* Deliver unicast frames based on receiver address */
73 - ieee80211_rx(hw, skb);
76 static bool ath_edma_get_buffers(struct ath_softc *sc,
77 enum ath9k_rx_qtype qtype)
79 @@ -1644,7 +1591,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
80 * virtual wiphy so to account for that we iterate over the active
81 * wiphys and find the appropriate wiphy and therefore hw.
83 - struct ieee80211_hw *hw = NULL;
84 + struct ieee80211_hw *hw = sc->hw;
85 struct ieee80211_hdr *hdr;
87 bool decrypt_error = false;
88 @@ -1689,8 +1636,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
89 hdr = (struct ieee80211_hdr *) (skb->data + rx_status_len);
90 rxs = IEEE80211_SKB_RXCB(skb);
92 - hw = ath_get_virt_hw(sc, hdr);
94 ath_debug_stat_rx(sc, &rs);
97 @@ -1748,7 +1693,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
100 ath_err(common, "dma_mapping_error() on RX\n");
101 - ath_rx_send_to_mac80211(hw, sc, skb);
102 + ieee80211_rx(hw, skb);
106 @@ -1775,7 +1720,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
107 if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
108 ath_ant_comb_scan(sc, &rs);
110 - ath_rx_send_to_mac80211(hw, sc, skb);
111 + ieee80211_rx(hw, skb);
115 --- a/drivers/net/wireless/ath/ath9k/main.c
116 +++ b/drivers/net/wireless/ath/ath9k/main.c
117 @@ -1076,29 +1076,7 @@ static int ath9k_start(struct ieee80211_
119 mutex_lock(&sc->mutex);
121 - if (ath9k_wiphy_started(sc)) {
122 - if (sc->chan_idx == curchan->hw_value) {
124 - * Already on the operational channel, the new wiphy
125 - * can be marked active.
127 - aphy->state = ATH_WIPHY_ACTIVE;
128 - ieee80211_wake_queues(hw);
131 - * Another wiphy is on another channel, start the new
132 - * wiphy in paused state.
134 - aphy->state = ATH_WIPHY_PAUSED;
135 - ieee80211_stop_queues(hw);
137 - mutex_unlock(&sc->mutex);
140 - aphy->state = ATH_WIPHY_ACTIVE;
142 /* setup initial channel */
144 sc->chan_idx = curchan->hw_value;
146 init_channel = ath_get_curchannel(sc, hw);
147 @@ -1208,13 +1186,6 @@ static int ath9k_tx(struct ieee80211_hw
148 struct ath_tx_control txctl;
149 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
151 - if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
152 - ath_dbg(common, ATH_DBG_XMIT,
153 - "ath9k: %s: TX in unexpected wiphy state %d\n",
154 - wiphy_name(hw->wiphy), aphy->state);
158 if (sc->ps_enabled) {
160 * mac80211 does not set PM field for normal data frames, so we
161 @@ -1277,37 +1248,19 @@ static void ath9k_stop(struct ieee80211_
162 struct ath_softc *sc = aphy->sc;
163 struct ath_hw *ah = sc->sc_ah;
164 struct ath_common *common = ath9k_hw_common(ah);
167 mutex_lock(&sc->mutex);
169 - aphy->state = ATH_WIPHY_INACTIVE;
171 cancel_delayed_work_sync(&sc->tx_complete_work);
172 cancel_work_sync(&sc->paprd_work);
173 cancel_work_sync(&sc->hw_check_work);
175 - for (i = 0; i < sc->num_sec_wiphy; i++) {
176 - if (sc->sec_wiphy[i])
180 - if (i == sc->num_sec_wiphy) {
181 - cancel_delayed_work_sync(&sc->wiphy_work);
182 - cancel_work_sync(&sc->chan_work);
185 if (sc->sc_flags & SC_OP_INVALID) {
186 ath_dbg(common, ATH_DBG_ANY, "Device not present\n");
187 mutex_unlock(&sc->mutex);
191 - if (ath9k_wiphy_started(sc)) {
192 - mutex_unlock(&sc->mutex);
193 - return; /* another wiphy still in use */
196 /* Ensure HW is awake when we try to shut it down. */
199 @@ -1339,7 +1292,6 @@ static void ath9k_stop(struct ieee80211_
200 ath9k_ps_restore(sc);
203 - ath9k_set_wiphy_idle(aphy, true);
204 ath_radio_disable(sc, hw);
206 sc->sc_flags |= SC_OP_INVALID;
207 @@ -1429,7 +1381,6 @@ void ath9k_calculate_iter_data(struct ie
208 struct ath_softc *sc = aphy->sc;
209 struct ath_hw *ah = sc->sc_ah;
210 struct ath_common *common = ath9k_hw_common(ah);
214 * Use the hardware MAC address as reference, the hardware uses it
215 @@ -1443,16 +1394,8 @@ void ath9k_calculate_iter_data(struct ie
216 ath9k_vif_iter(iter_data, vif->addr, vif);
218 /* Get list of all active MAC addresses */
219 - spin_lock_bh(&sc->wiphy_lock);
220 ieee80211_iterate_active_interfaces_atomic(sc->hw, ath9k_vif_iter,
222 - for (i = 0; i < sc->num_sec_wiphy; i++) {
223 - if (sc->sec_wiphy[i] == NULL)
225 - ieee80211_iterate_active_interfaces_atomic(
226 - sc->sec_wiphy[i]->hw, ath9k_vif_iter, iter_data);
228 - spin_unlock_bh(&sc->wiphy_lock);
231 /* Called with sc->mutex held. */
232 @@ -1706,7 +1649,7 @@ static int ath9k_config(struct ieee80211
233 struct ath_hw *ah = sc->sc_ah;
234 struct ath_common *common = ath9k_hw_common(ah);
235 struct ieee80211_conf *conf = &hw->conf;
236 - bool disable_radio;
237 + bool disable_radio = false;
239 mutex_lock(&sc->mutex);
241 @@ -1717,29 +1660,13 @@ static int ath9k_config(struct ieee80211
244 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
246 - bool all_wiphys_idle;
247 - bool idle = !!(conf->flags & IEEE80211_CONF_IDLE);
249 - spin_lock_bh(&sc->wiphy_lock);
250 - all_wiphys_idle = ath9k_all_wiphys_idle(sc);
251 - ath9k_set_wiphy_idle(aphy, idle);
253 - enable_radio = (!idle && all_wiphys_idle);
256 - * After we unlock here its possible another wiphy
257 - * can be re-renabled so to account for that we will
258 - * only disable the radio toward the end of this routine
259 - * if by then all wiphys are still idle.
261 - spin_unlock_bh(&sc->wiphy_lock);
263 - if (enable_radio) {
264 - sc->ps_idle = false;
265 + sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
266 + if (!sc->ps_idle) {
267 ath_radio_enable(sc, hw);
268 ath_dbg(common, ATH_DBG_CONFIG,
269 "not-idle: enabling radio\n");
271 + disable_radio = true;
275 @@ -1780,24 +1707,11 @@ static int ath9k_config(struct ieee80211
277 old_pos = ah->curchan - &ah->channels[0];
279 - aphy->chan_idx = pos;
280 - aphy->chan_is_ht = conf_is_ht(conf);
281 if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
282 sc->sc_flags |= SC_OP_OFFCHANNEL;
284 sc->sc_flags &= ~SC_OP_OFFCHANNEL;
286 - if (aphy->state == ATH_WIPHY_SCAN ||
287 - aphy->state == ATH_WIPHY_ACTIVE)
288 - ath9k_wiphy_pause_all_forced(sc, aphy);
291 - * Do not change operational channel based on a paused
294 - goto skip_chan_change;
297 ath_dbg(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
298 curchan->center_freq);
300 @@ -1844,19 +1758,13 @@ static int ath9k_config(struct ieee80211
301 ath_update_survey_nf(sc, old_pos);
305 if (changed & IEEE80211_CONF_CHANGE_POWER) {
306 sc->config.txpowlimit = 2 * conf->power_level;
307 ath_update_txpow(sc);
310 - spin_lock_bh(&sc->wiphy_lock);
311 - disable_radio = ath9k_all_wiphys_idle(sc);
312 - spin_unlock_bh(&sc->wiphy_lock);
315 ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
316 - sc->ps_idle = true;
317 ath_radio_disable(sc, hw);
320 @@ -2247,43 +2155,6 @@ static int ath9k_get_survey(struct ieee8
324 -static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
326 - struct ath_wiphy *aphy = hw->priv;
327 - struct ath_softc *sc = aphy->sc;
329 - mutex_lock(&sc->mutex);
330 - if (ath9k_wiphy_scanning(sc)) {
332 - * There is a race here in mac80211 but fixing it requires
333 - * we revisit how we handle the scan complete callback.
334 - * After mac80211 fixes we will not have configured hardware
335 - * to the home channel nor would we have configured the RX
338 - mutex_unlock(&sc->mutex);
342 - aphy->state = ATH_WIPHY_SCAN;
343 - ath9k_wiphy_pause_all_forced(sc, aphy);
344 - mutex_unlock(&sc->mutex);
348 - * XXX: this requires a revisit after the driver
349 - * scan_complete gets moved to another place/removed in mac80211.
351 -static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
353 - struct ath_wiphy *aphy = hw->priv;
354 - struct ath_softc *sc = aphy->sc;
356 - mutex_lock(&sc->mutex);
357 - aphy->state = ATH_WIPHY_ACTIVE;
358 - mutex_unlock(&sc->mutex);
361 static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
363 struct ath_wiphy *aphy = hw->priv;
364 @@ -2315,8 +2186,6 @@ struct ieee80211_ops ath9k_ops = {
365 .reset_tsf = ath9k_reset_tsf,
366 .ampdu_action = ath9k_ampdu_action,
367 .get_survey = ath9k_get_survey,
368 - .sw_scan_start = ath9k_sw_scan_start,
369 - .sw_scan_complete = ath9k_sw_scan_complete,
370 .rfkill_poll = ath9k_rfkill_poll_state,
371 .set_coverage_class = ath9k_set_coverage_class,
373 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
374 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
375 @@ -381,7 +381,6 @@ struct ath_beacon {
378 struct ieee80211_vif *bslot[ATH_BCBUF];
379 - struct ath_wiphy *bslot_aphy[ATH_BCBUF];
382 struct ath9k_tx_queue_info beacon_qi;
383 @@ -572,20 +571,8 @@ struct ath_softc {
384 struct ieee80211_hw *hw;
387 - spinlock_t wiphy_lock; /* spinlock to protect ath_wiphy data */
388 - struct ath_wiphy *pri_wiphy;
389 - struct ath_wiphy **sec_wiphy; /* secondary wiphys (virtual radios); may
390 - * have NULL entries */
391 - int num_sec_wiphy; /* number of sec_wiphy pointers in the array */
394 - struct ath_wiphy *next_wiphy;
395 - struct work_struct chan_work;
396 - int wiphy_select_failures;
397 - unsigned long wiphy_select_first_fail;
398 - struct delayed_work wiphy_work;
399 - unsigned long wiphy_scheduler_int;
400 - int wiphy_scheduler_index;
401 struct survey_info *cur_survey;
402 struct survey_info survey[ATH9K_NUM_CHANNELS];
404 @@ -645,16 +632,6 @@ struct ath_wiphy {
405 struct ath_softc *sc; /* shared for all virtual wiphys */
406 struct ieee80211_hw *hw;
407 struct ath9k_hw_cal_data caldata;
408 - enum ath_wiphy_state {
409 - ATH_WIPHY_INACTIVE,
421 @@ -711,24 +688,6 @@ void ath9k_ps_restore(struct ath_softc *
422 u8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate);
424 void ath9k_set_bssid_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
425 -int ath9k_wiphy_add(struct ath_softc *sc);
426 -int ath9k_wiphy_del(struct ath_wiphy *aphy);
427 -void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, int ftype);
428 -int ath9k_wiphy_pause(struct ath_wiphy *aphy);
429 -int ath9k_wiphy_unpause(struct ath_wiphy *aphy);
430 -int ath9k_wiphy_select(struct ath_wiphy *aphy);
431 -void ath9k_wiphy_set_scheduler(struct ath_softc *sc, unsigned int msec_int);
432 -void ath9k_wiphy_chan_work(struct work_struct *work);
433 -bool ath9k_wiphy_started(struct ath_softc *sc);
434 -void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
435 - struct ath_wiphy *selected);
436 -bool ath9k_wiphy_scanning(struct ath_softc *sc);
437 -void ath9k_wiphy_work(struct work_struct *work);
438 -bool ath9k_all_wiphys_idle(struct ath_softc *sc);
439 -void ath9k_set_wiphy_idle(struct ath_wiphy *aphy, bool idle);
441 -void ath_mac80211_stop_queue(struct ath_softc *sc, u16 skb_queue);
442 -bool ath_mac80211_start_queue(struct ath_softc *sc, u16 skb_queue);
444 void ath_start_rfkill_poll(struct ath_softc *sc);
445 extern void ath9k_rfkill_poll_state(struct ieee80211_hw *hw);
446 --- a/drivers/net/wireless/ath/ath9k/virtual.c
450 - * Copyright (c) 2008-2009 Atheros Communications Inc.
452 - * Permission to use, copy, modify, and/or distribute this software for any
453 - * purpose with or without fee is hereby granted, provided that the above
454 - * copyright notice and this permission notice appear in all copies.
456 - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
457 - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
458 - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
459 - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
460 - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
461 - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
462 - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
465 -#include <linux/slab.h>
469 -int ath9k_wiphy_add(struct ath_softc *sc)
472 - struct ath_wiphy *aphy;
473 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
474 - struct ieee80211_hw *hw;
477 - hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy), &ath9k_ops);
481 - spin_lock_bh(&sc->wiphy_lock);
482 - for (i = 0; i < sc->num_sec_wiphy; i++) {
483 - if (sc->sec_wiphy[i] == NULL)
487 - if (i == sc->num_sec_wiphy) {
488 - /* No empty slot available; increase array length */
489 - struct ath_wiphy **n;
490 - n = krealloc(sc->sec_wiphy,
491 - (sc->num_sec_wiphy + 1) *
492 - sizeof(struct ath_wiphy *),
495 - spin_unlock_bh(&sc->wiphy_lock);
496 - ieee80211_free_hw(hw);
501 - sc->num_sec_wiphy++;
504 - SET_IEEE80211_DEV(hw, sc->dev);
509 - sc->sec_wiphy[i] = aphy;
510 - aphy->last_rssi = ATH_RSSI_DUMMY_MARKER;
511 - spin_unlock_bh(&sc->wiphy_lock);
513 - memcpy(addr, common->macaddr, ETH_ALEN);
514 - addr[0] |= 0x02; /* Locally managed address */
516 - * XOR virtual wiphy index into the least significant bits to generate
517 - * a different MAC address for each virtual wiphy.
519 - addr[5] ^= i & 0xff;
520 - addr[4] ^= (i & 0xff00) >> 8;
521 - addr[3] ^= (i & 0xff0000) >> 16;
523 - SET_IEEE80211_PERM_ADDR(hw, addr);
525 - ath9k_set_hw_capab(sc, hw);
527 - error = ieee80211_register_hw(hw);
530 - /* Make sure wiphy scheduler is started (if enabled) */
531 - ath9k_wiphy_set_scheduler(sc, sc->wiphy_scheduler_int);
537 -int ath9k_wiphy_del(struct ath_wiphy *aphy)
539 - struct ath_softc *sc = aphy->sc;
542 - spin_lock_bh(&sc->wiphy_lock);
543 - for (i = 0; i < sc->num_sec_wiphy; i++) {
544 - if (aphy == sc->sec_wiphy[i]) {
545 - sc->sec_wiphy[i] = NULL;
546 - spin_unlock_bh(&sc->wiphy_lock);
547 - ieee80211_unregister_hw(aphy->hw);
548 - ieee80211_free_hw(aphy->hw);
552 - spin_unlock_bh(&sc->wiphy_lock);
556 -static int ath9k_send_nullfunc(struct ath_wiphy *aphy,
557 - struct ieee80211_vif *vif, const u8 *bssid,
560 - struct ath_softc *sc = aphy->sc;
561 - struct ath_tx_control txctl;
562 - struct sk_buff *skb;
563 - struct ieee80211_hdr *hdr;
565 - struct ieee80211_tx_info *info;
567 - skb = dev_alloc_skb(24);
570 - hdr = (struct ieee80211_hdr *) skb_put(skb, 24);
571 - memset(hdr, 0, 24);
572 - fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC |
573 - IEEE80211_FCTL_TODS);
575 - fc |= cpu_to_le16(IEEE80211_FCTL_PM);
576 - hdr->frame_control = fc;
577 - memcpy(hdr->addr1, bssid, ETH_ALEN);
578 - memcpy(hdr->addr2, aphy->hw->wiphy->perm_addr, ETH_ALEN);
579 - memcpy(hdr->addr3, bssid, ETH_ALEN);
581 - info = IEEE80211_SKB_CB(skb);
582 - memset(info, 0, sizeof(*info));
583 - info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS;
584 - info->control.vif = vif;
585 - info->control.rates[0].idx = 0;
586 - info->control.rates[0].count = 4;
587 - info->control.rates[1].idx = -1;
589 - memset(&txctl, 0, sizeof(struct ath_tx_control));
590 - txctl.txq = sc->tx.txq_map[WME_AC_VO];
591 - txctl.frame_type = ps ? ATH9K_IFT_PAUSE : ATH9K_IFT_UNPAUSE;
593 - if (ath_tx_start(aphy->hw, skb, &txctl) != 0)
598 - dev_kfree_skb_any(skb);
602 -static bool __ath9k_wiphy_pausing(struct ath_softc *sc)
605 - if (sc->pri_wiphy->state == ATH_WIPHY_PAUSING)
607 - for (i = 0; i < sc->num_sec_wiphy; i++) {
608 - if (sc->sec_wiphy[i] &&
609 - sc->sec_wiphy[i]->state == ATH_WIPHY_PAUSING)
615 -static bool ath9k_wiphy_pausing(struct ath_softc *sc)
618 - spin_lock_bh(&sc->wiphy_lock);
619 - ret = __ath9k_wiphy_pausing(sc);
620 - spin_unlock_bh(&sc->wiphy_lock);
624 -static bool __ath9k_wiphy_scanning(struct ath_softc *sc)
627 - if (sc->pri_wiphy->state == ATH_WIPHY_SCAN)
629 - for (i = 0; i < sc->num_sec_wiphy; i++) {
630 - if (sc->sec_wiphy[i] &&
631 - sc->sec_wiphy[i]->state == ATH_WIPHY_SCAN)
637 -bool ath9k_wiphy_scanning(struct ath_softc *sc)
640 - spin_lock_bh(&sc->wiphy_lock);
641 - ret = __ath9k_wiphy_scanning(sc);
642 - spin_unlock_bh(&sc->wiphy_lock);
646 -static int __ath9k_wiphy_unpause(struct ath_wiphy *aphy);
648 -/* caller must hold wiphy_lock */
649 -static void __ath9k_wiphy_unpause_ch(struct ath_wiphy *aphy)
653 - if (aphy->chan_idx != aphy->sc->chan_idx)
654 - return; /* wiphy not on the selected channel */
655 - __ath9k_wiphy_unpause(aphy);
658 -static void ath9k_wiphy_unpause_channel(struct ath_softc *sc)
661 - spin_lock_bh(&sc->wiphy_lock);
662 - __ath9k_wiphy_unpause_ch(sc->pri_wiphy);
663 - for (i = 0; i < sc->num_sec_wiphy; i++)
664 - __ath9k_wiphy_unpause_ch(sc->sec_wiphy[i]);
665 - spin_unlock_bh(&sc->wiphy_lock);
668 -void ath9k_wiphy_chan_work(struct work_struct *work)
670 - struct ath_softc *sc = container_of(work, struct ath_softc, chan_work);
671 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
672 - struct ath_wiphy *aphy = sc->next_wiphy;
678 - * All pending interfaces paused; ready to change
682 - /* Change channels */
683 - mutex_lock(&sc->mutex);
684 - /* XXX: remove me eventually */
685 - ath9k_update_ichannel(sc, aphy->hw,
686 - &sc->sc_ah->channels[sc->chan_idx]);
688 - /* sync hw configuration for hw code */
689 - common->hw = aphy->hw;
691 - if (ath_set_channel(sc, aphy->hw,
692 - &sc->sc_ah->channels[sc->chan_idx]) < 0) {
693 - printk(KERN_DEBUG "ath9k: Failed to set channel for new "
694 - "virtual wiphy\n");
695 - mutex_unlock(&sc->mutex);
698 - mutex_unlock(&sc->mutex);
700 - ath9k_wiphy_unpause_channel(sc);
704 - * ath9k version of ieee80211_tx_status() for TX frames that are generated
705 - * internally in the driver.
707 -void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, int ftype)
709 - struct ath_wiphy *aphy = hw->priv;
710 - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
712 - if (ftype == ATH9K_IFT_PAUSE && aphy->state == ATH_WIPHY_PAUSING) {
713 - if (!(tx_info->flags & IEEE80211_TX_STAT_ACK)) {
714 - printk(KERN_DEBUG "ath9k: %s: no ACK for pause "
715 - "frame\n", wiphy_name(hw->wiphy));
717 - * The AP did not reply; ignore this to allow us to
721 - aphy->state = ATH_WIPHY_PAUSED;
722 - if (!ath9k_wiphy_pausing(aphy->sc)) {
724 - * Drop from tasklet to work to allow mutex for channel
727 - ieee80211_queue_work(aphy->sc->hw,
728 - &aphy->sc->chan_work);
732 - dev_kfree_skb(skb);
735 -static void ath9k_mark_paused(struct ath_wiphy *aphy)
737 - struct ath_softc *sc = aphy->sc;
738 - aphy->state = ATH_WIPHY_PAUSED;
739 - if (!__ath9k_wiphy_pausing(sc))
740 - ieee80211_queue_work(sc->hw, &sc->chan_work);
743 -static void ath9k_pause_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
745 - struct ath_wiphy *aphy = data;
746 - struct ath_vif *avp = (void *) vif->drv_priv;
748 - switch (vif->type) {
749 - case NL80211_IFTYPE_STATION:
750 - if (!vif->bss_conf.assoc) {
751 - ath9k_mark_paused(aphy);
754 - /* TODO: could avoid this if already in PS mode */
755 - if (ath9k_send_nullfunc(aphy, vif, avp->bssid, 1)) {
756 - printk(KERN_DEBUG "%s: failed to send PS nullfunc\n",
758 - ath9k_mark_paused(aphy);
761 - case NL80211_IFTYPE_AP:
762 - /* Beacon transmission is paused by aphy->state change */
763 - ath9k_mark_paused(aphy);
770 -/* caller must hold wiphy_lock */
771 -static int __ath9k_wiphy_pause(struct ath_wiphy *aphy)
773 - ieee80211_stop_queues(aphy->hw);
774 - aphy->state = ATH_WIPHY_PAUSING;
776 - * TODO: handle PAUSING->PAUSED for the case where there are multiple
777 - * active vifs (now we do it on the first vif getting ready; should be
780 - ieee80211_iterate_active_interfaces_atomic(aphy->hw, ath9k_pause_iter,
785 -int ath9k_wiphy_pause(struct ath_wiphy *aphy)
788 - spin_lock_bh(&aphy->sc->wiphy_lock);
789 - ret = __ath9k_wiphy_pause(aphy);
790 - spin_unlock_bh(&aphy->sc->wiphy_lock);
794 -static void ath9k_unpause_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
796 - struct ath_wiphy *aphy = data;
797 - struct ath_vif *avp = (void *) vif->drv_priv;
799 - switch (vif->type) {
800 - case NL80211_IFTYPE_STATION:
801 - if (!vif->bss_conf.assoc)
803 - ath9k_send_nullfunc(aphy, vif, avp->bssid, 0);
805 - case NL80211_IFTYPE_AP:
806 - /* Beacon transmission is re-enabled by aphy->state change */
813 -/* caller must hold wiphy_lock */
814 -static int __ath9k_wiphy_unpause(struct ath_wiphy *aphy)
816 - ieee80211_iterate_active_interfaces_atomic(aphy->hw,
817 - ath9k_unpause_iter, aphy);
818 - aphy->state = ATH_WIPHY_ACTIVE;
819 - ieee80211_wake_queues(aphy->hw);
823 -int ath9k_wiphy_unpause(struct ath_wiphy *aphy)
826 - spin_lock_bh(&aphy->sc->wiphy_lock);
827 - ret = __ath9k_wiphy_unpause(aphy);
828 - spin_unlock_bh(&aphy->sc->wiphy_lock);
832 -static void __ath9k_wiphy_mark_all_paused(struct ath_softc *sc)
835 - if (sc->pri_wiphy->state != ATH_WIPHY_INACTIVE)
836 - sc->pri_wiphy->state = ATH_WIPHY_PAUSED;
837 - for (i = 0; i < sc->num_sec_wiphy; i++) {
838 - if (sc->sec_wiphy[i] &&
839 - sc->sec_wiphy[i]->state != ATH_WIPHY_INACTIVE)
840 - sc->sec_wiphy[i]->state = ATH_WIPHY_PAUSED;
844 -/* caller must hold wiphy_lock */
845 -static void __ath9k_wiphy_pause_all(struct ath_softc *sc)
848 - if (sc->pri_wiphy->state == ATH_WIPHY_ACTIVE)
849 - __ath9k_wiphy_pause(sc->pri_wiphy);
850 - for (i = 0; i < sc->num_sec_wiphy; i++) {
851 - if (sc->sec_wiphy[i] &&
852 - sc->sec_wiphy[i]->state == ATH_WIPHY_ACTIVE)
853 - __ath9k_wiphy_pause(sc->sec_wiphy[i]);
857 -int ath9k_wiphy_select(struct ath_wiphy *aphy)
859 - struct ath_softc *sc = aphy->sc;
862 - spin_lock_bh(&sc->wiphy_lock);
863 - if (__ath9k_wiphy_scanning(sc)) {
865 - * For now, we are using mac80211 sw scan and it expects to
866 - * have full control over channel changes, so avoid wiphy
867 - * scheduling during a scan. This could be optimized if the
868 - * scanning control were moved into the driver.
870 - spin_unlock_bh(&sc->wiphy_lock);
873 - if (__ath9k_wiphy_pausing(sc)) {
874 - if (sc->wiphy_select_failures == 0)
875 - sc->wiphy_select_first_fail = jiffies;
876 - sc->wiphy_select_failures++;
877 - if (time_after(jiffies, sc->wiphy_select_first_fail + HZ / 2))
879 - printk(KERN_DEBUG "ath9k: Previous wiphy select timed "
880 - "out; disable/enable hw to recover\n");
881 - __ath9k_wiphy_mark_all_paused(sc);
883 - * TODO: this workaround to fix hardware is unlikely to
884 - * be specific to virtual wiphy changes. It can happen
885 - * on normal channel change, too, and as such, this
886 - * should really be made more generic. For example,
887 - * tricker radio disable/enable on GTT interrupt burst
888 - * (say, 10 GTT interrupts received without any TX
889 - * frame being completed)
891 - spin_unlock_bh(&sc->wiphy_lock);
892 - ath_radio_disable(sc, aphy->hw);
893 - ath_radio_enable(sc, aphy->hw);
894 - /* Only the primary wiphy hw is used for queuing work */
895 - ieee80211_queue_work(aphy->sc->hw,
896 - &aphy->sc->chan_work);
897 - return -EBUSY; /* previous select still in progress */
899 - spin_unlock_bh(&sc->wiphy_lock);
900 - return -EBUSY; /* previous select still in progress */
902 - sc->wiphy_select_failures = 0;
904 - /* Store the new channel */
905 - sc->chan_idx = aphy->chan_idx;
906 - sc->chan_is_ht = aphy->chan_is_ht;
907 - sc->next_wiphy = aphy;
909 - __ath9k_wiphy_pause_all(sc);
910 - now = !__ath9k_wiphy_pausing(aphy->sc);
911 - spin_unlock_bh(&sc->wiphy_lock);
914 - /* Ready to request channel change immediately */
915 - ieee80211_queue_work(aphy->sc->hw, &aphy->sc->chan_work);
919 - * wiphys will be unpaused in ath9k_tx_status() once channel has been
920 - * changed if any wiphy needs time to become paused.
926 -bool ath9k_wiphy_started(struct ath_softc *sc)
929 - spin_lock_bh(&sc->wiphy_lock);
930 - if (sc->pri_wiphy->state != ATH_WIPHY_INACTIVE) {
931 - spin_unlock_bh(&sc->wiphy_lock);
934 - for (i = 0; i < sc->num_sec_wiphy; i++) {
935 - if (sc->sec_wiphy[i] &&
936 - sc->sec_wiphy[i]->state != ATH_WIPHY_INACTIVE) {
937 - spin_unlock_bh(&sc->wiphy_lock);
941 - spin_unlock_bh(&sc->wiphy_lock);
945 -static void ath9k_wiphy_pause_chan(struct ath_wiphy *aphy,
946 - struct ath_wiphy *selected)
948 - if (selected->state == ATH_WIPHY_SCAN) {
949 - if (aphy == selected)
952 - * Pause all other wiphys for the duration of the scan even if
953 - * they are on the current channel now.
955 - } else if (aphy->chan_idx == selected->chan_idx)
957 - aphy->state = ATH_WIPHY_PAUSED;
958 - ieee80211_stop_queues(aphy->hw);
961 -void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
962 - struct ath_wiphy *selected)
965 - spin_lock_bh(&sc->wiphy_lock);
966 - if (sc->pri_wiphy->state == ATH_WIPHY_ACTIVE)
967 - ath9k_wiphy_pause_chan(sc->pri_wiphy, selected);
968 - for (i = 0; i < sc->num_sec_wiphy; i++) {
969 - if (sc->sec_wiphy[i] &&
970 - sc->sec_wiphy[i]->state == ATH_WIPHY_ACTIVE)
971 - ath9k_wiphy_pause_chan(sc->sec_wiphy[i], selected);
973 - spin_unlock_bh(&sc->wiphy_lock);
976 -void ath9k_wiphy_work(struct work_struct *work)
978 - struct ath_softc *sc = container_of(work, struct ath_softc,
980 - struct ath_wiphy *aphy = NULL;
983 - spin_lock_bh(&sc->wiphy_lock);
985 - if (sc->wiphy_scheduler_int == 0) {
986 - /* wiphy scheduler is disabled */
987 - spin_unlock_bh(&sc->wiphy_lock);
992 - sc->wiphy_scheduler_index++;
993 - while (sc->wiphy_scheduler_index <= sc->num_sec_wiphy) {
994 - aphy = sc->sec_wiphy[sc->wiphy_scheduler_index - 1];
995 - if (aphy && aphy->state != ATH_WIPHY_INACTIVE)
998 - sc->wiphy_scheduler_index++;
1001 - if (aphy == NULL) {
1002 - sc->wiphy_scheduler_index = 0;
1003 - if (sc->pri_wiphy->state == ATH_WIPHY_INACTIVE) {
1008 - /* No wiphy is ready to be scheduled */
1010 - aphy = sc->pri_wiphy;
1013 - spin_unlock_bh(&sc->wiphy_lock);
1016 - aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN &&
1017 - ath9k_wiphy_select(aphy)) {
1018 - printk(KERN_DEBUG "ath9k: Failed to schedule virtual wiphy "
1022 - ieee80211_queue_delayed_work(sc->hw,
1024 - sc->wiphy_scheduler_int);
1027 -void ath9k_wiphy_set_scheduler(struct ath_softc *sc, unsigned int msec_int)
1029 - cancel_delayed_work_sync(&sc->wiphy_work);
1030 - sc->wiphy_scheduler_int = msecs_to_jiffies(msec_int);
1031 - if (sc->wiphy_scheduler_int)
1032 - ieee80211_queue_delayed_work(sc->hw, &sc->wiphy_work,
1033 - sc->wiphy_scheduler_int);
1036 -/* caller must hold wiphy_lock */
1037 -bool ath9k_all_wiphys_idle(struct ath_softc *sc)
1040 - if (!sc->pri_wiphy->idle)
1042 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1043 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1052 -/* caller must hold wiphy_lock */
1053 -void ath9k_set_wiphy_idle(struct ath_wiphy *aphy, bool idle)
1055 - struct ath_softc *sc = aphy->sc;
1057 - aphy->idle = idle;
1058 - ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
1059 - "Marking %s as %sidle\n",
1060 - wiphy_name(aphy->hw->wiphy), idle ? "" : "not-");
1062 -/* Only bother starting a queue on an active virtual wiphy */
1063 -bool ath_mac80211_start_queue(struct ath_softc *sc, u16 skb_queue)
1065 - struct ieee80211_hw *hw = sc->pri_wiphy->hw;
1067 - bool txq_started = false;
1069 - spin_lock_bh(&sc->wiphy_lock);
1071 - /* Start the primary wiphy */
1072 - if (sc->pri_wiphy->state == ATH_WIPHY_ACTIVE) {
1073 - ieee80211_wake_queue(hw, skb_queue);
1074 - txq_started = true;
1078 - /* Now start the secondary wiphy queues */
1079 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1080 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1083 - if (aphy->state != ATH_WIPHY_ACTIVE)
1087 - ieee80211_wake_queue(hw, skb_queue);
1088 - txq_started = true;
1093 - spin_unlock_bh(&sc->wiphy_lock);
1094 - return txq_started;
1097 -/* Go ahead and propagate information to all virtual wiphys, it won't hurt */
1098 -void ath_mac80211_stop_queue(struct ath_softc *sc, u16 skb_queue)
1100 - struct ieee80211_hw *hw = sc->pri_wiphy->hw;
1103 - spin_lock_bh(&sc->wiphy_lock);
1105 - /* Stop the primary wiphy */
1106 - ieee80211_stop_queue(hw, skb_queue);
1108 - /* Now stop the secondary wiphy queues */
1109 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1110 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1114 - ieee80211_stop_queue(hw, skb_queue);
1116 - spin_unlock_bh(&sc->wiphy_lock);
1118 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1119 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1120 @@ -1816,7 +1816,7 @@ int ath_tx_start(struct ieee80211_hw *hw
1121 spin_lock_bh(&txq->axq_lock);
1122 if (txq == sc->tx.txq_map[q] &&
1123 ++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
1124 - ath_mac80211_stop_queue(sc, q);
1125 + ieee80211_stop_queue(sc->hw, q);
1128 spin_unlock_bh(&txq->axq_lock);
1129 @@ -1874,24 +1874,20 @@ static void ath_tx_complete(struct ath_s
1130 PS_WAIT_FOR_TX_ACK));
1133 - if (unlikely(ftype))
1134 - ath9k_tx_status(hw, skb, ftype);
1136 - q = skb_get_queue_mapping(skb);
1137 - if (txq == sc->tx.txq_map[q]) {
1138 - spin_lock_bh(&txq->axq_lock);
1139 - if (WARN_ON(--txq->pending_frames < 0))
1140 - txq->pending_frames = 0;
1141 + q = skb_get_queue_mapping(skb);
1142 + if (txq == sc->tx.txq_map[q]) {
1143 + spin_lock_bh(&txq->axq_lock);
1144 + if (WARN_ON(--txq->pending_frames < 0))
1145 + txq->pending_frames = 0;
1147 - if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
1148 - if (ath_mac80211_start_queue(sc, q))
1151 - spin_unlock_bh(&txq->axq_lock);
1152 + if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
1153 + ieee80211_wake_queue(sc->hw, q);
1157 - ieee80211_tx_status(hw, skb);
1158 + spin_unlock_bh(&txq->axq_lock);
1161 + ieee80211_tx_status(hw, skb);
1164 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
1165 --- a/drivers/net/wireless/ath/ath9k/Makefile
1166 +++ b/drivers/net/wireless/ath/ath9k/Makefile
1167 @@ -4,7 +4,6 @@ ath9k-y += beacon.o \
1173 ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o
1174 ath9k-$(CONFIG_PCI) += pci.o
1175 --- a/drivers/net/wireless/ath/ath9k/init.c
1176 +++ b/drivers/net/wireless/ath/ath9k/init.c
1177 @@ -532,10 +532,8 @@ static void ath9k_init_misc(struct ath_s
1179 sc->beacon.slottime = ATH9K_SLOT_TIME_9;
1181 - for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) {
1182 + for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++)
1183 sc->beacon.bslot[i] = NULL;
1184 - sc->beacon.bslot_aphy[i] = NULL;
1187 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
1188 sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT;
1189 @@ -577,7 +575,6 @@ static int ath9k_init_softc(u16 devid, s
1190 common->btcoex_enabled = ath9k_btcoex_enable == 1;
1191 spin_lock_init(&common->cc_lock);
1193 - spin_lock_init(&sc->wiphy_lock);
1194 spin_lock_init(&sc->sc_serial_rw);
1195 spin_lock_init(&sc->sc_pm_lock);
1196 mutex_init(&sc->mutex);
1197 @@ -789,9 +786,6 @@ int ath9k_init_device(u16 devid, struct
1199 INIT_WORK(&sc->hw_check_work, ath_hw_check);
1200 INIT_WORK(&sc->paprd_work, ath_paprd_calibrate);
1201 - INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
1202 - INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
1203 - sc->wiphy_scheduler_int = msecs_to_jiffies(500);
1204 aphy->last_rssi = ATH_RSSI_DUMMY_MARKER;
1207 @@ -850,28 +844,17 @@ static void ath9k_deinit_softc(struct at
1208 void ath9k_deinit_device(struct ath_softc *sc)
1210 struct ieee80211_hw *hw = sc->hw;
1213 ath9k_ps_wakeup(sc);
1215 wiphy_rfkill_stop_polling(sc->hw->wiphy);
1216 ath_deinit_leds(sc);
1218 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1219 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1222 - sc->sec_wiphy[i] = NULL;
1223 - ieee80211_unregister_hw(aphy->hw);
1224 - ieee80211_free_hw(aphy->hw);
1227 ieee80211_unregister_hw(hw);
1228 pm_qos_remove_request(&sc->pm_qos_req);
1231 ath9k_deinit_softc(sc);
1232 - kfree(sc->sec_wiphy);
1235 void ath_descdma_cleanup(struct ath_softc *sc,
1236 --- a/drivers/net/wireless/ath/ath9k/pci.c
1237 +++ b/drivers/net/wireless/ath/ath9k/pci.c
1238 @@ -213,7 +213,6 @@ static int ath_pci_probe(struct pci_dev
1239 sc = (struct ath_softc *) (aphy + 1);
1242 - sc->pri_wiphy = aphy;
1244 sc->dev = &pdev->dev;
1246 @@ -320,7 +319,6 @@ static int ath_pci_resume(struct device
1247 ath9k_ps_restore(sc);
1250 - ath9k_set_wiphy_idle(aphy, true);
1251 ath_radio_disable(sc, hw);
1254 --- a/drivers/net/wireless/ath/ath9k/ahb.c
1255 +++ b/drivers/net/wireless/ath/ath9k/ahb.c
1256 @@ -107,7 +107,6 @@ static int ath_ahb_probe(struct platform
1257 sc = (struct ath_softc *) (aphy + 1);
1260 - sc->pri_wiphy = aphy;
1262 sc->dev = &pdev->dev;
1264 --- a/drivers/net/wireless/ath/ath9k/beacon.c
1265 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
1266 @@ -142,9 +142,6 @@ static struct ath_buf *ath_beacon_genera
1267 struct ieee80211_tx_info *info;
1270 - if (aphy->state != ATH_WIPHY_ACTIVE)
1273 avp = (void *)vif->drv_priv;
1274 cabq = sc->beacon.cabq;
1276 @@ -261,7 +258,6 @@ int ath_beacon_alloc(struct ath_wiphy *a
1278 BUG_ON(sc->beacon.bslot[avp->av_bslot] != NULL);
1279 sc->beacon.bslot[avp->av_bslot] = vif;
1280 - sc->beacon.bslot_aphy[avp->av_bslot] = aphy;
1284 @@ -332,7 +328,6 @@ void ath_beacon_return(struct ath_softc
1286 if (avp->av_bslot != -1) {
1287 sc->beacon.bslot[avp->av_bslot] = NULL;
1288 - sc->beacon.bslot_aphy[avp->av_bslot] = NULL;
1292 @@ -358,7 +353,6 @@ void ath_beacon_tasklet(unsigned long da
1293 struct ath_common *common = ath9k_hw_common(ah);
1294 struct ath_buf *bf = NULL;
1295 struct ieee80211_vif *vif;
1296 - struct ath_wiphy *aphy;
1298 u32 bfaddr, bc = 0, tsftu;
1300 @@ -416,7 +410,6 @@ void ath_beacon_tasklet(unsigned long da
1302 slot = ATH_BCBUF - slot - 1;
1303 vif = sc->beacon.bslot[slot];
1304 - aphy = sc->beacon.bslot_aphy[slot];
1306 ath_dbg(common, ATH_DBG_BEACON,
1307 "slot %d [tsf %llu tsftu %u intval %u] vif %p\n",
1308 @@ -424,7 +417,7 @@ void ath_beacon_tasklet(unsigned long da
1312 - bf = ath_beacon_generate(aphy->hw, vif);
1313 + bf = ath_beacon_generate(sc->hw, vif);
1315 bfaddr = bf->bf_daddr;