1 --- a/drivers/net/wireless/ath/ath9k/Makefile
2 +++ b/drivers/net/wireless/ath/ath9k/Makefile
3 @@ -4,7 +4,6 @@ ath9k-y += beacon.o \
9 ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o
10 ath9k-$(CONFIG_PCI) += pci.o
11 --- a/drivers/net/wireless/ath/ath9k/ahb.c
12 +++ b/drivers/net/wireless/ath/ath9k/ahb.c
13 @@ -54,7 +54,6 @@ static struct ath_bus_ops ath_ahb_bus_op
14 static int ath_ahb_probe(struct platform_device *pdev)
17 - struct ath_wiphy *aphy;
19 struct ieee80211_hw *hw;
21 @@ -92,8 +91,7 @@ static int ath_ahb_probe(struct platform
25 - hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy) +
26 - sizeof(struct ath_softc), &ath9k_ops);
27 + hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
29 dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
31 @@ -103,11 +101,7 @@ static int ath_ahb_probe(struct platform
32 SET_IEEE80211_DEV(hw, &pdev->dev);
33 platform_set_drvdata(pdev, hw);
36 - sc = (struct ath_softc *) (aphy + 1);
39 - sc->pri_wiphy = aphy;
44 @@ -151,8 +145,7 @@ static int ath_ahb_remove(struct platfor
45 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
48 - struct ath_wiphy *aphy = hw->priv;
49 - struct ath_softc *sc = aphy->sc;
50 + struct ath_softc *sc = hw->priv;
51 void __iomem *mem = sc->mem;
53 ath9k_deinit_device(sc);
54 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
55 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
56 @@ -234,7 +234,6 @@ struct ath_buf {
59 struct ath_buf_state bf_state;
60 - struct ath_wiphy *aphy;
64 @@ -389,7 +388,6 @@ struct ath_beacon {
67 struct ieee80211_vif *bslot[ATH_BCBUF];
68 - struct ath_wiphy *bslot_aphy[ATH_BCBUF];
71 struct ath9k_tx_queue_info beacon_qi;
72 @@ -400,7 +398,7 @@ struct ath_beacon {
74 void ath_beacon_tasklet(unsigned long data);
75 void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif);
76 -int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif);
77 +int ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_vif *vif);
78 void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp);
79 int ath_beaconq_config(struct ath_softc *sc);
81 @@ -565,7 +563,6 @@ struct ath_ant_comb {
82 #define PS_WAIT_FOR_TX_ACK BIT(3)
83 #define PS_BEACON_SYNC BIT(4)
86 struct ath_rate_table;
88 struct ath9k_vif_iter_data {
89 @@ -586,20 +583,8 @@ struct ath_softc {
90 struct ieee80211_hw *hw;
93 - spinlock_t wiphy_lock; /* spinlock to protect ath_wiphy data */
94 - struct ath_wiphy *pri_wiphy;
95 - struct ath_wiphy **sec_wiphy; /* secondary wiphys (virtual radios); may
96 - * have NULL entries */
97 - int num_sec_wiphy; /* number of sec_wiphy pointers in the array */
100 - struct ath_wiphy *next_wiphy;
101 - struct work_struct chan_work;
102 - int wiphy_select_failures;
103 - unsigned long wiphy_select_first_fail;
104 - struct delayed_work wiphy_work;
105 - unsigned long wiphy_scheduler_int;
106 - int wiphy_scheduler_index;
107 struct survey_info *cur_survey;
108 struct survey_info survey[ATH9K_NUM_CHANNELS];
110 @@ -643,6 +628,9 @@ struct ath_softc {
114 + struct ath9k_hw_cal_data caldata;
119 #ifdef CONFIG_ATH9K_DEBUGFS
120 @@ -662,23 +650,6 @@ struct ath_softc {
121 struct pm_qos_request_list pm_qos_req;
125 - struct ath_softc *sc; /* shared for all virtual wiphys */
126 - struct ieee80211_hw *hw;
127 - struct ath9k_hw_cal_data caldata;
128 - enum ath_wiphy_state {
129 - ATH_WIPHY_INACTIVE,
141 void ath9k_tasklet(unsigned long data);
142 int ath_reset(struct ath_softc *sc, bool retry_tx);
143 int ath_cabq_update(struct ath_softc *);
144 @@ -732,24 +703,6 @@ void ath9k_ps_restore(struct ath_softc *
145 u8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate);
147 void ath9k_set_bssid_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
148 -int ath9k_wiphy_add(struct ath_softc *sc);
149 -int ath9k_wiphy_del(struct ath_wiphy *aphy);
150 -void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, int ftype);
151 -int ath9k_wiphy_pause(struct ath_wiphy *aphy);
152 -int ath9k_wiphy_unpause(struct ath_wiphy *aphy);
153 -int ath9k_wiphy_select(struct ath_wiphy *aphy);
154 -void ath9k_wiphy_set_scheduler(struct ath_softc *sc, unsigned int msec_int);
155 -void ath9k_wiphy_chan_work(struct work_struct *work);
156 -bool ath9k_wiphy_started(struct ath_softc *sc);
157 -void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
158 - struct ath_wiphy *selected);
159 -bool ath9k_wiphy_scanning(struct ath_softc *sc);
160 -void ath9k_wiphy_work(struct work_struct *work);
161 -bool ath9k_all_wiphys_idle(struct ath_softc *sc);
162 -void ath9k_set_wiphy_idle(struct ath_wiphy *aphy, bool idle);
164 -void ath_mac80211_stop_queue(struct ath_softc *sc, u16 skb_queue);
165 -bool ath_mac80211_start_queue(struct ath_softc *sc, u16 skb_queue);
167 void ath_start_rfkill_poll(struct ath_softc *sc);
168 extern void ath9k_rfkill_poll_state(struct ieee80211_hw *hw);
169 --- a/drivers/net/wireless/ath/ath9k/beacon.c
170 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
171 @@ -112,8 +112,7 @@ static void ath_beacon_setup(struct ath_
173 static void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
175 - struct ath_wiphy *aphy = hw->priv;
176 - struct ath_softc *sc = aphy->sc;
177 + struct ath_softc *sc = hw->priv;
178 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
179 struct ath_tx_control txctl;
181 @@ -132,8 +131,7 @@ static void ath_tx_cabq(struct ieee80211
182 static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
183 struct ieee80211_vif *vif)
185 - struct ath_wiphy *aphy = hw->priv;
186 - struct ath_softc *sc = aphy->sc;
187 + struct ath_softc *sc = hw->priv;
188 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
191 @@ -142,9 +140,6 @@ static struct ath_buf *ath_beacon_genera
192 struct ieee80211_tx_info *info;
195 - if (aphy->state != ATH_WIPHY_ACTIVE)
198 avp = (void *)vif->drv_priv;
199 cabq = sc->beacon.cabq;
201 @@ -225,9 +220,8 @@ static struct ath_buf *ath_beacon_genera
205 -int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
206 +int ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_vif *vif)
208 - struct ath_softc *sc = aphy->sc;
209 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
212 @@ -261,7 +255,6 @@ int ath_beacon_alloc(struct ath_wiphy *a
214 BUG_ON(sc->beacon.bslot[avp->av_bslot] != NULL);
215 sc->beacon.bslot[avp->av_bslot] = vif;
216 - sc->beacon.bslot_aphy[avp->av_bslot] = aphy;
220 @@ -332,7 +325,6 @@ void ath_beacon_return(struct ath_softc
222 if (avp->av_bslot != -1) {
223 sc->beacon.bslot[avp->av_bslot] = NULL;
224 - sc->beacon.bslot_aphy[avp->av_bslot] = NULL;
228 @@ -358,7 +350,6 @@ void ath_beacon_tasklet(unsigned long da
229 struct ath_common *common = ath9k_hw_common(ah);
230 struct ath_buf *bf = NULL;
231 struct ieee80211_vif *vif;
232 - struct ath_wiphy *aphy;
234 u32 bfaddr, bc = 0, tsftu;
236 @@ -416,7 +407,6 @@ void ath_beacon_tasklet(unsigned long da
238 slot = ATH_BCBUF - slot - 1;
239 vif = sc->beacon.bslot[slot];
240 - aphy = sc->beacon.bslot_aphy[slot];
242 ath_dbg(common, ATH_DBG_BEACON,
243 "slot %d [tsf %llu tsftu %u intval %u] vif %p\n",
244 @@ -424,7 +414,7 @@ void ath_beacon_tasklet(unsigned long da
248 - bf = ath_beacon_generate(aphy->hw, vif);
249 + bf = ath_beacon_generate(sc->hw, vif);
251 bfaddr = bf->bf_daddr;
253 --- a/drivers/net/wireless/ath/ath9k/debug.c
254 +++ b/drivers/net/wireless/ath/ath9k/debug.c
255 @@ -381,41 +381,21 @@ static const struct file_operations fops
256 .llseek = default_llseek,
259 -static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
262 - case ATH_WIPHY_INACTIVE:
264 - case ATH_WIPHY_ACTIVE:
266 - case ATH_WIPHY_PAUSING:
268 - case ATH_WIPHY_PAUSED:
270 - case ATH_WIPHY_SCAN:
276 static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
277 size_t count, loff_t *ppos)
279 struct ath_softc *sc = file->private_data;
280 - struct ath_wiphy *aphy = sc->pri_wiphy;
281 - struct ieee80211_channel *chan = aphy->hw->conf.channel;
282 + struct ieee80211_channel *chan = sc->hw->conf.channel;
284 unsigned int len = 0;
289 len += snprintf(buf + len, sizeof(buf) - len,
290 - "primary: %s (%s chan=%d ht=%d)\n",
291 - wiphy_name(sc->pri_wiphy->hw->wiphy),
292 - ath_wiphy_state_str(sc->pri_wiphy->state),
293 + "%s (chan=%d ht=%d)\n",
294 + wiphy_name(sc->hw->wiphy),
295 ieee80211_frequency_to_channel(chan->center_freq),
297 + conf_is_ht(&sc->hw->conf));
299 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
300 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
301 @@ -457,123 +437,14 @@ static ssize_t read_file_wiphy(struct fi
303 len += snprintf(buf + len, sizeof(buf) - len, "\n");
305 - /* Put variable-length stuff down here, and check for overflows. */
306 - for (i = 0; i < sc->num_sec_wiphy; i++) {
307 - struct ath_wiphy *aphy_tmp = sc->sec_wiphy[i];
308 - if (aphy_tmp == NULL)
310 - chan = aphy_tmp->hw->conf.channel;
311 - len += snprintf(buf + len, sizeof(buf) - len,
312 - "secondary: %s (%s chan=%d ht=%d)\n",
313 - wiphy_name(aphy_tmp->hw->wiphy),
314 - ath_wiphy_state_str(aphy_tmp->state),
315 - ieee80211_frequency_to_channel(chan->center_freq),
316 - aphy_tmp->chan_is_ht);
318 if (len > sizeof(buf))
321 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
324 -static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name)
327 - if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0)
328 - return sc->pri_wiphy;
329 - for (i = 0; i < sc->num_sec_wiphy; i++) {
330 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
331 - if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0)
337 -static int del_wiphy(struct ath_softc *sc, const char *name)
339 - struct ath_wiphy *aphy = get_wiphy(sc, name);
342 - return ath9k_wiphy_del(aphy);
345 -static int pause_wiphy(struct ath_softc *sc, const char *name)
347 - struct ath_wiphy *aphy = get_wiphy(sc, name);
350 - return ath9k_wiphy_pause(aphy);
353 -static int unpause_wiphy(struct ath_softc *sc, const char *name)
355 - struct ath_wiphy *aphy = get_wiphy(sc, name);
358 - return ath9k_wiphy_unpause(aphy);
361 -static int select_wiphy(struct ath_softc *sc, const char *name)
363 - struct ath_wiphy *aphy = get_wiphy(sc, name);
366 - return ath9k_wiphy_select(aphy);
369 -static int schedule_wiphy(struct ath_softc *sc, const char *msec)
371 - ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0));
375 -static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf,
376 - size_t count, loff_t *ppos)
378 - struct ath_softc *sc = file->private_data;
382 - len = min(count, sizeof(buf) - 1);
383 - if (copy_from_user(buf, user_buf, len))
386 - if (len > 0 && buf[len - 1] == '\n')
387 - buf[len - 1] = '\0';
389 - if (strncmp(buf, "add", 3) == 0) {
390 - int res = ath9k_wiphy_add(sc);
393 - } else if (strncmp(buf, "del=", 4) == 0) {
394 - int res = del_wiphy(sc, buf + 4);
397 - } else if (strncmp(buf, "pause=", 6) == 0) {
398 - int res = pause_wiphy(sc, buf + 6);
401 - } else if (strncmp(buf, "unpause=", 8) == 0) {
402 - int res = unpause_wiphy(sc, buf + 8);
405 - } else if (strncmp(buf, "select=", 7) == 0) {
406 - int res = select_wiphy(sc, buf + 7);
409 - } else if (strncmp(buf, "schedule=", 9) == 0) {
410 - int res = schedule_wiphy(sc, buf + 9);
414 - return -EOPNOTSUPP;
419 static const struct file_operations fops_wiphy = {
420 .read = read_file_wiphy,
421 - .write = write_file_wiphy,
422 .open = ath9k_debugfs_open,
423 .owner = THIS_MODULE,
424 .llseek = default_llseek,
425 --- a/drivers/net/wireless/ath/ath9k/gpio.c
426 +++ b/drivers/net/wireless/ath/ath9k/gpio.c
427 @@ -201,8 +201,7 @@ static bool ath_is_rfkill_set(struct ath
429 void ath9k_rfkill_poll_state(struct ieee80211_hw *hw)
431 - struct ath_wiphy *aphy = hw->priv;
432 - struct ath_softc *sc = aphy->sc;
433 + struct ath_softc *sc = hw->priv;
434 bool blocked = !!ath_is_rfkill_set(sc);
436 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
437 --- a/drivers/net/wireless/ath/ath9k/init.c
438 +++ b/drivers/net/wireless/ath/ath9k/init.c
439 @@ -254,8 +254,7 @@ static int ath9k_reg_notifier(struct wip
440 struct regulatory_request *request)
442 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
443 - struct ath_wiphy *aphy = hw->priv;
444 - struct ath_softc *sc = aphy->sc;
445 + struct ath_softc *sc = hw->priv;
446 struct ath_regulatory *reg = ath9k_hw_regulatory(sc->sc_ah);
448 return ath_reg_notifier_apply(wiphy, request, reg);
449 @@ -517,10 +516,8 @@ static void ath9k_init_misc(struct ath_s
451 sc->beacon.slottime = ATH9K_SLOT_TIME_9;
453 - for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) {
454 + for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++)
455 sc->beacon.bslot[i] = NULL;
456 - sc->beacon.bslot_aphy[i] = NULL;
459 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
460 sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT;
461 @@ -556,7 +553,6 @@ static int ath9k_init_softc(u16 devid, s
462 common->btcoex_enabled = ath9k_btcoex_enable == 1;
463 spin_lock_init(&common->cc_lock);
465 - spin_lock_init(&sc->wiphy_lock);
466 spin_lock_init(&sc->sc_serial_rw);
467 spin_lock_init(&sc->sc_pm_lock);
468 mutex_init(&sc->mutex);
469 @@ -707,7 +703,6 @@ int ath9k_init_device(u16 devid, struct
470 const struct ath_bus_ops *bus_ops)
472 struct ieee80211_hw *hw = sc->hw;
473 - struct ath_wiphy *aphy = hw->priv;
474 struct ath_common *common;
477 @@ -762,10 +757,7 @@ int ath9k_init_device(u16 devid, struct
479 INIT_WORK(&sc->hw_check_work, ath_hw_check);
480 INIT_WORK(&sc->paprd_work, ath_paprd_calibrate);
481 - INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
482 - INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
483 - sc->wiphy_scheduler_int = msecs_to_jiffies(500);
484 - aphy->last_rssi = ATH_RSSI_DUMMY_MARKER;
485 + sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
488 ath_start_rfkill_poll(sc);
489 @@ -823,28 +815,17 @@ static void ath9k_deinit_softc(struct at
490 void ath9k_deinit_device(struct ath_softc *sc)
492 struct ieee80211_hw *hw = sc->hw;
497 wiphy_rfkill_stop_polling(sc->hw->wiphy);
500 - for (i = 0; i < sc->num_sec_wiphy; i++) {
501 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
504 - sc->sec_wiphy[i] = NULL;
505 - ieee80211_unregister_hw(aphy->hw);
506 - ieee80211_free_hw(aphy->hw);
509 ieee80211_unregister_hw(hw);
510 pm_qos_remove_request(&sc->pm_qos_req);
513 ath9k_deinit_softc(sc);
514 - kfree(sc->sec_wiphy);
517 void ath_descdma_cleanup(struct ath_softc *sc,
518 --- a/drivers/net/wireless/ath/ath9k/main.c
519 +++ b/drivers/net/wireless/ath/ath9k/main.c
520 @@ -215,7 +215,6 @@ static void ath_update_survey_stats(stru
521 int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
522 struct ath9k_channel *hchan)
524 - struct ath_wiphy *aphy = hw->priv;
525 struct ath_hw *ah = sc->sc_ah;
526 struct ath_common *common = ath9k_hw_common(ah);
527 struct ieee80211_conf *conf = &common->hw->conf;
528 @@ -262,7 +261,7 @@ int ath_set_channel(struct ath_softc *sc
531 if (!(sc->sc_flags & SC_OP_OFFCHANNEL))
532 - caldata = &aphy->caldata;
533 + caldata = &sc->caldata;
535 ath_dbg(common, ATH_DBG_CONFIG,
536 "(%u MHz) -> (%u MHz), conf_is_ht40: %d fastcc: %d\n",
537 @@ -295,6 +294,8 @@ int ath_set_channel(struct ath_softc *sc
541 + ieee80211_wake_queues(hw);
543 spin_unlock_bh(&sc->sc_pcu_lock);
545 ath9k_ps_restore(sc);
546 @@ -850,7 +851,6 @@ static void ath9k_bss_assoc_info(struct
547 struct ieee80211_vif *vif,
548 struct ieee80211_bss_conf *bss_conf)
550 - struct ath_wiphy *aphy = hw->priv;
551 struct ath_hw *ah = sc->sc_ah;
552 struct ath_common *common = ath9k_hw_common(ah);
554 @@ -874,7 +874,7 @@ static void ath9k_bss_assoc_info(struct
555 ath_beacon_config(sc, vif);
557 /* Reset rssi stats */
558 - aphy->last_rssi = ATH_RSSI_DUMMY_MARKER;
559 + sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
560 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
562 sc->sc_flags |= SC_OP_ANI_RUN;
563 @@ -1073,8 +1073,7 @@ void ath9k_update_ichannel(struct ath_so
565 static int ath9k_start(struct ieee80211_hw *hw)
567 - struct ath_wiphy *aphy = hw->priv;
568 - struct ath_softc *sc = aphy->sc;
569 + struct ath_softc *sc = hw->priv;
570 struct ath_hw *ah = sc->sc_ah;
571 struct ath_common *common = ath9k_hw_common(ah);
572 struct ieee80211_channel *curchan = hw->conf.channel;
573 @@ -1087,29 +1086,7 @@ static int ath9k_start(struct ieee80211_
575 mutex_lock(&sc->mutex);
577 - if (ath9k_wiphy_started(sc)) {
578 - if (sc->chan_idx == curchan->hw_value) {
580 - * Already on the operational channel, the new wiphy
581 - * can be marked active.
583 - aphy->state = ATH_WIPHY_ACTIVE;
584 - ieee80211_wake_queues(hw);
587 - * Another wiphy is on another channel, start the new
588 - * wiphy in paused state.
590 - aphy->state = ATH_WIPHY_PAUSED;
591 - ieee80211_stop_queues(hw);
593 - mutex_unlock(&sc->mutex);
596 - aphy->state = ATH_WIPHY_ACTIVE;
598 /* setup initial channel */
600 sc->chan_idx = curchan->hw_value;
602 init_channel = ath_get_curchannel(sc, hw);
603 @@ -1213,19 +1190,11 @@ mutex_unlock:
604 static int ath9k_tx(struct ieee80211_hw *hw,
607 - struct ath_wiphy *aphy = hw->priv;
608 - struct ath_softc *sc = aphy->sc;
609 + struct ath_softc *sc = hw->priv;
610 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
611 struct ath_tx_control txctl;
612 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
614 - if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
615 - ath_dbg(common, ATH_DBG_XMIT,
616 - "ath9k: %s: TX in unexpected wiphy state %d\n",
617 - wiphy_name(hw->wiphy), aphy->state);
621 if (sc->ps_enabled) {
623 * mac80211 does not set PM field for normal data frames, so we
624 @@ -1284,16 +1253,12 @@ exit:
626 static void ath9k_stop(struct ieee80211_hw *hw)
628 - struct ath_wiphy *aphy = hw->priv;
629 - struct ath_softc *sc = aphy->sc;
630 + struct ath_softc *sc = hw->priv;
631 struct ath_hw *ah = sc->sc_ah;
632 struct ath_common *common = ath9k_hw_common(ah);
635 mutex_lock(&sc->mutex);
637 - aphy->state = ATH_WIPHY_INACTIVE;
640 cancel_delayed_work_sync(&sc->ath_led_blink_work);
642 @@ -1301,27 +1266,12 @@ static void ath9k_stop(struct ieee80211_
643 cancel_work_sync(&sc->paprd_work);
644 cancel_work_sync(&sc->hw_check_work);
646 - for (i = 0; i < sc->num_sec_wiphy; i++) {
647 - if (sc->sec_wiphy[i])
651 - if (i == sc->num_sec_wiphy) {
652 - cancel_delayed_work_sync(&sc->wiphy_work);
653 - cancel_work_sync(&sc->chan_work);
656 if (sc->sc_flags & SC_OP_INVALID) {
657 ath_dbg(common, ATH_DBG_ANY, "Device not present\n");
658 mutex_unlock(&sc->mutex);
662 - if (ath9k_wiphy_started(sc)) {
663 - mutex_unlock(&sc->mutex);
664 - return; /* another wiphy still in use */
667 /* Ensure HW is awake when we try to shut it down. */
670 @@ -1353,7 +1303,6 @@ static void ath9k_stop(struct ieee80211_
671 ath9k_ps_restore(sc);
674 - ath9k_set_wiphy_idle(aphy, true);
675 ath_radio_disable(sc, hw);
677 sc->sc_flags |= SC_OP_INVALID;
678 @@ -1439,11 +1388,9 @@ void ath9k_calculate_iter_data(struct ie
679 struct ieee80211_vif *vif,
680 struct ath9k_vif_iter_data *iter_data)
682 - struct ath_wiphy *aphy = hw->priv;
683 - struct ath_softc *sc = aphy->sc;
684 + struct ath_softc *sc = hw->priv;
685 struct ath_hw *ah = sc->sc_ah;
686 struct ath_common *common = ath9k_hw_common(ah);
690 * Use the hardware MAC address as reference, the hardware uses it
691 @@ -1457,24 +1404,15 @@ void ath9k_calculate_iter_data(struct ie
692 ath9k_vif_iter(iter_data, vif->addr, vif);
694 /* Get list of all active MAC addresses */
695 - spin_lock_bh(&sc->wiphy_lock);
696 ieee80211_iterate_active_interfaces_atomic(sc->hw, ath9k_vif_iter,
698 - for (i = 0; i < sc->num_sec_wiphy; i++) {
699 - if (sc->sec_wiphy[i] == NULL)
701 - ieee80211_iterate_active_interfaces_atomic(
702 - sc->sec_wiphy[i]->hw, ath9k_vif_iter, iter_data);
704 - spin_unlock_bh(&sc->wiphy_lock);
707 /* Called with sc->mutex held. */
708 static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
709 struct ieee80211_vif *vif)
711 - struct ath_wiphy *aphy = hw->priv;
712 - struct ath_softc *sc = aphy->sc;
713 + struct ath_softc *sc = hw->priv;
714 struct ath_hw *ah = sc->sc_ah;
715 struct ath_common *common = ath9k_hw_common(ah);
716 struct ath9k_vif_iter_data iter_data;
717 @@ -1530,8 +1468,7 @@ static void ath9k_calculate_summary_stat
718 static void ath9k_do_vif_add_setup(struct ieee80211_hw *hw,
719 struct ieee80211_vif *vif)
721 - struct ath_wiphy *aphy = hw->priv;
722 - struct ath_softc *sc = aphy->sc;
723 + struct ath_softc *sc = hw->priv;
725 ath9k_calculate_summary_state(hw, vif);
727 @@ -1544,7 +1481,7 @@ static void ath9k_do_vif_add_setup(struc
728 * in the info_changed method and set up beacons properly
731 - error = ath_beacon_alloc(aphy, vif);
732 + error = ath_beacon_alloc(sc, vif);
734 ath9k_reclaim_beacon(sc, vif);
736 @@ -1556,8 +1493,7 @@ static void ath9k_do_vif_add_setup(struc
737 static int ath9k_add_interface(struct ieee80211_hw *hw,
738 struct ieee80211_vif *vif)
740 - struct ath_wiphy *aphy = hw->priv;
741 - struct ath_softc *sc = aphy->sc;
742 + struct ath_softc *sc = hw->priv;
743 struct ath_hw *ah = sc->sc_ah;
744 struct ath_common *common = ath9k_hw_common(ah);
745 struct ath_vif *avp = (void *)vif->drv_priv;
746 @@ -1617,8 +1553,7 @@ static int ath9k_change_interface(struct
747 enum nl80211_iftype new_type,
750 - struct ath_wiphy *aphy = hw->priv;
751 - struct ath_softc *sc = aphy->sc;
752 + struct ath_softc *sc = hw->priv;
753 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
756 @@ -1660,8 +1595,7 @@ out:
757 static void ath9k_remove_interface(struct ieee80211_hw *hw,
758 struct ieee80211_vif *vif)
760 - struct ath_wiphy *aphy = hw->priv;
761 - struct ath_softc *sc = aphy->sc;
762 + struct ath_softc *sc = hw->priv;
763 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
765 ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n");
766 @@ -1715,12 +1649,11 @@ static void ath9k_disable_ps(struct ath_
768 static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
770 - struct ath_wiphy *aphy = hw->priv;
771 - struct ath_softc *sc = aphy->sc;
772 + struct ath_softc *sc = hw->priv;
773 struct ath_hw *ah = sc->sc_ah;
774 struct ath_common *common = ath9k_hw_common(ah);
775 struct ieee80211_conf *conf = &hw->conf;
776 - bool disable_radio;
777 + bool disable_radio = false;
779 mutex_lock(&sc->mutex);
781 @@ -1731,29 +1664,13 @@ static int ath9k_config(struct ieee80211
784 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
786 - bool all_wiphys_idle;
787 - bool idle = !!(conf->flags & IEEE80211_CONF_IDLE);
789 - spin_lock_bh(&sc->wiphy_lock);
790 - all_wiphys_idle = ath9k_all_wiphys_idle(sc);
791 - ath9k_set_wiphy_idle(aphy, idle);
793 - enable_radio = (!idle && all_wiphys_idle);
796 - * After we unlock here its possible another wiphy
797 - * can be re-renabled so to account for that we will
798 - * only disable the radio toward the end of this routine
799 - * if by then all wiphys are still idle.
801 - spin_unlock_bh(&sc->wiphy_lock);
803 - if (enable_radio) {
804 - sc->ps_idle = false;
805 + sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
806 + if (!sc->ps_idle) {
807 ath_radio_enable(sc, hw);
808 ath_dbg(common, ATH_DBG_CONFIG,
809 "not-idle: enabling radio\n");
811 + disable_radio = true;
815 @@ -1794,24 +1711,11 @@ static int ath9k_config(struct ieee80211
817 old_pos = ah->curchan - &ah->channels[0];
819 - aphy->chan_idx = pos;
820 - aphy->chan_is_ht = conf_is_ht(conf);
821 if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
822 sc->sc_flags |= SC_OP_OFFCHANNEL;
824 sc->sc_flags &= ~SC_OP_OFFCHANNEL;
826 - if (aphy->state == ATH_WIPHY_SCAN ||
827 - aphy->state == ATH_WIPHY_ACTIVE)
828 - ath9k_wiphy_pause_all_forced(sc, aphy);
831 - * Do not change operational channel based on a paused
834 - goto skip_chan_change;
837 ath_dbg(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
838 curchan->center_freq);
840 @@ -1858,7 +1762,6 @@ static int ath9k_config(struct ieee80211
841 ath_update_survey_nf(sc, old_pos);
845 if (changed & IEEE80211_CONF_CHANGE_POWER) {
846 sc->config.txpowlimit = 2 * conf->power_level;
848 @@ -1866,13 +1769,8 @@ skip_chan_change:
849 ath9k_ps_restore(sc);
852 - spin_lock_bh(&sc->wiphy_lock);
853 - disable_radio = ath9k_all_wiphys_idle(sc);
854 - spin_unlock_bh(&sc->wiphy_lock);
857 ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
858 - sc->ps_idle = true;
859 ath_radio_disable(sc, hw);
862 @@ -1897,8 +1795,7 @@ static void ath9k_configure_filter(struc
863 unsigned int *total_flags,
866 - struct ath_wiphy *aphy = hw->priv;
867 - struct ath_softc *sc = aphy->sc;
868 + struct ath_softc *sc = hw->priv;
871 changed_flags &= SUPPORTED_FILTERS;
872 @@ -1918,8 +1815,7 @@ static int ath9k_sta_add(struct ieee8021
873 struct ieee80211_vif *vif,
874 struct ieee80211_sta *sta)
876 - struct ath_wiphy *aphy = hw->priv;
877 - struct ath_softc *sc = aphy->sc;
878 + struct ath_softc *sc = hw->priv;
880 ath_node_attach(sc, sta);
882 @@ -1930,8 +1826,7 @@ static int ath9k_sta_remove(struct ieee8
883 struct ieee80211_vif *vif,
884 struct ieee80211_sta *sta)
886 - struct ath_wiphy *aphy = hw->priv;
887 - struct ath_softc *sc = aphy->sc;
888 + struct ath_softc *sc = hw->priv;
890 ath_node_detach(sc, sta);
892 @@ -1941,8 +1836,7 @@ static int ath9k_sta_remove(struct ieee8
893 static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
894 const struct ieee80211_tx_queue_params *params)
896 - struct ath_wiphy *aphy = hw->priv;
897 - struct ath_softc *sc = aphy->sc;
898 + struct ath_softc *sc = hw->priv;
899 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
901 struct ath9k_tx_queue_info qi;
902 @@ -1986,8 +1880,7 @@ static int ath9k_set_key(struct ieee8021
903 struct ieee80211_sta *sta,
904 struct ieee80211_key_conf *key)
906 - struct ath_wiphy *aphy = hw->priv;
907 - struct ath_softc *sc = aphy->sc;
908 + struct ath_softc *sc = hw->priv;
909 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
912 @@ -2031,8 +1924,7 @@ static void ath9k_bss_info_changed(struc
913 struct ieee80211_bss_conf *bss_conf,
916 - struct ath_wiphy *aphy = hw->priv;
917 - struct ath_softc *sc = aphy->sc;
918 + struct ath_softc *sc = hw->priv;
919 struct ath_hw *ah = sc->sc_ah;
920 struct ath_common *common = ath9k_hw_common(ah);
921 struct ath_vif *avp = (void *)vif->drv_priv;
922 @@ -2062,7 +1954,7 @@ static void ath9k_bss_info_changed(struc
923 if ((changed & BSS_CHANGED_BEACON) ||
924 ((changed & BSS_CHANGED_BEACON_ENABLED) && bss_conf->enable_beacon)) {
925 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
926 - error = ath_beacon_alloc(aphy, vif);
927 + error = ath_beacon_alloc(sc, vif);
929 ath_beacon_config(sc, vif);
931 @@ -2099,7 +1991,7 @@ static void ath9k_bss_info_changed(struc
932 if (vif->type == NL80211_IFTYPE_AP) {
933 sc->sc_flags |= SC_OP_TSF_RESET;
934 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
935 - error = ath_beacon_alloc(aphy, vif);
936 + error = ath_beacon_alloc(sc, vif);
938 ath_beacon_config(sc, vif);
940 @@ -2137,9 +2029,8 @@ static void ath9k_bss_info_changed(struc
942 static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
944 + struct ath_softc *sc = hw->priv;
946 - struct ath_wiphy *aphy = hw->priv;
947 - struct ath_softc *sc = aphy->sc;
949 mutex_lock(&sc->mutex);
951 @@ -2152,8 +2043,7 @@ static u64 ath9k_get_tsf(struct ieee8021
953 static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
955 - struct ath_wiphy *aphy = hw->priv;
956 - struct ath_softc *sc = aphy->sc;
957 + struct ath_softc *sc = hw->priv;
959 mutex_lock(&sc->mutex);
961 @@ -2164,8 +2054,7 @@ static void ath9k_set_tsf(struct ieee802
963 static void ath9k_reset_tsf(struct ieee80211_hw *hw)
965 - struct ath_wiphy *aphy = hw->priv;
966 - struct ath_softc *sc = aphy->sc;
967 + struct ath_softc *sc = hw->priv;
969 mutex_lock(&sc->mutex);
971 @@ -2182,8 +2071,7 @@ static int ath9k_ampdu_action(struct iee
972 struct ieee80211_sta *sta,
973 u16 tid, u16 *ssn, u8 buf_size)
975 - struct ath_wiphy *aphy = hw->priv;
976 - struct ath_softc *sc = aphy->sc;
977 + struct ath_softc *sc = hw->priv;
981 @@ -2228,8 +2116,7 @@ static int ath9k_ampdu_action(struct iee
982 static int ath9k_get_survey(struct ieee80211_hw *hw, int idx,
983 struct survey_info *survey)
985 - struct ath_wiphy *aphy = hw->priv;
986 - struct ath_softc *sc = aphy->sc;
987 + struct ath_softc *sc = hw->priv;
988 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
989 struct ieee80211_supported_band *sband;
990 struct ieee80211_channel *chan;
991 @@ -2263,47 +2150,9 @@ static int ath9k_get_survey(struct ieee8
995 -static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
997 - struct ath_wiphy *aphy = hw->priv;
998 - struct ath_softc *sc = aphy->sc;
1000 - mutex_lock(&sc->mutex);
1001 - if (ath9k_wiphy_scanning(sc)) {
1003 - * There is a race here in mac80211 but fixing it requires
1004 - * we revisit how we handle the scan complete callback.
1005 - * After mac80211 fixes we will not have configured hardware
1006 - * to the home channel nor would we have configured the RX
1009 - mutex_unlock(&sc->mutex);
1013 - aphy->state = ATH_WIPHY_SCAN;
1014 - ath9k_wiphy_pause_all_forced(sc, aphy);
1015 - mutex_unlock(&sc->mutex);
1019 - * XXX: this requires a revisit after the driver
1020 - * scan_complete gets moved to another place/removed in mac80211.
1022 -static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
1024 - struct ath_wiphy *aphy = hw->priv;
1025 - struct ath_softc *sc = aphy->sc;
1027 - mutex_lock(&sc->mutex);
1028 - aphy->state = ATH_WIPHY_ACTIVE;
1029 - mutex_unlock(&sc->mutex);
1032 static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
1034 - struct ath_wiphy *aphy = hw->priv;
1035 - struct ath_softc *sc = aphy->sc;
1036 + struct ath_softc *sc = hw->priv;
1037 struct ath_hw *ah = sc->sc_ah;
1039 mutex_lock(&sc->mutex);
1040 @@ -2331,8 +2180,6 @@ struct ieee80211_ops ath9k_ops = {
1041 .reset_tsf = ath9k_reset_tsf,
1042 .ampdu_action = ath9k_ampdu_action,
1043 .get_survey = ath9k_get_survey,
1044 - .sw_scan_start = ath9k_sw_scan_start,
1045 - .sw_scan_complete = ath9k_sw_scan_complete,
1046 .rfkill_poll = ath9k_rfkill_poll_state,
1047 .set_coverage_class = ath9k_set_coverage_class,
1049 --- a/drivers/net/wireless/ath/ath9k/pci.c
1050 +++ b/drivers/net/wireless/ath/ath9k/pci.c
1051 @@ -126,7 +126,6 @@ static const struct ath_bus_ops ath_pci_
1052 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1055 - struct ath_wiphy *aphy;
1056 struct ath_softc *sc;
1057 struct ieee80211_hw *hw;
1059 @@ -198,8 +197,7 @@ static int ath_pci_probe(struct pci_dev
1063 - hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy) +
1064 - sizeof(struct ath_softc), &ath9k_ops);
1065 + hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
1067 dev_err(&pdev->dev, "No memory for ieee80211_hw\n");
1069 @@ -209,11 +207,7 @@ static int ath_pci_probe(struct pci_dev
1070 SET_IEEE80211_DEV(hw, &pdev->dev);
1071 pci_set_drvdata(pdev, hw);
1074 - sc = (struct ath_softc *) (aphy + 1);
1077 - sc->pri_wiphy = aphy;
1080 sc->dev = &pdev->dev;
1082 @@ -260,8 +254,7 @@ err_dma:
1083 static void ath_pci_remove(struct pci_dev *pdev)
1085 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
1086 - struct ath_wiphy *aphy = hw->priv;
1087 - struct ath_softc *sc = aphy->sc;
1088 + struct ath_softc *sc = hw->priv;
1089 void __iomem *mem = sc->mem;
1091 if (!is_ath9k_unloaded)
1092 @@ -281,8 +274,7 @@ static int ath_pci_suspend(struct device
1094 struct pci_dev *pdev = to_pci_dev(device);
1095 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
1096 - struct ath_wiphy *aphy = hw->priv;
1097 - struct ath_softc *sc = aphy->sc;
1098 + struct ath_softc *sc = hw->priv;
1100 ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
1102 @@ -293,8 +285,7 @@ static int ath_pci_resume(struct device
1104 struct pci_dev *pdev = to_pci_dev(device);
1105 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
1106 - struct ath_wiphy *aphy = hw->priv;
1107 - struct ath_softc *sc = aphy->sc;
1108 + struct ath_softc *sc = hw->priv;
1112 @@ -320,7 +311,6 @@ static int ath_pci_resume(struct device
1113 ath9k_ps_restore(sc);
1116 - ath9k_set_wiphy_idle(aphy, true);
1117 ath_radio_disable(sc, hw);
1120 --- a/drivers/net/wireless/ath/ath9k/rc.c
1121 +++ b/drivers/net/wireless/ath/ath9k/rc.c
1122 @@ -1560,8 +1560,7 @@ static void ath_rate_add_sta_debugfs(voi
1124 static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
1126 - struct ath_wiphy *aphy = hw->priv;
1131 static void ath_rate_free(void *priv)
1132 --- a/drivers/net/wireless/ath/ath9k/recv.c
1133 +++ b/drivers/net/wireless/ath/ath9k/recv.c
1134 @@ -34,27 +34,6 @@ static inline bool ath9k_check_auto_slee
1135 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP);
1138 -static struct ieee80211_hw * ath_get_virt_hw(struct ath_softc *sc,
1139 - struct ieee80211_hdr *hdr)
1141 - struct ieee80211_hw *hw = sc->pri_wiphy->hw;
1144 - spin_lock_bh(&sc->wiphy_lock);
1145 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1146 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1149 - if (compare_ether_addr(hdr->addr1, aphy->hw->wiphy->perm_addr)
1155 - spin_unlock_bh(&sc->wiphy_lock);
1160 * Setup and link descriptors.
1162 @@ -463,8 +442,7 @@ u32 ath_calcrxfilter(struct ath_softc *s
1163 if (conf_is_ht(&sc->hw->conf))
1164 rfilt |= ATH9K_RX_FILTER_COMP_BAR;
1166 - if (sc->sec_wiphy || (sc->nvifs > 1) ||
1167 - (sc->rx.rxfilter & FIF_OTHER_BSS)) {
1168 + if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
1169 /* The following may also be needed for other older chips */
1170 if (sc->sc_ah->hw_version.macVersion == AR_SREV_VERSION_9160)
1171 rfilt |= ATH9K_RX_FILTER_PROM;
1172 @@ -668,37 +646,6 @@ static void ath_rx_ps(struct ath_softc *
1176 -static void ath_rx_send_to_mac80211(struct ieee80211_hw *hw,
1177 - struct ath_softc *sc, struct sk_buff *skb)
1179 - struct ieee80211_hdr *hdr;
1181 - hdr = (struct ieee80211_hdr *)skb->data;
1183 - /* Send the frame to mac80211 */
1184 - if (is_multicast_ether_addr(hdr->addr1)) {
1187 - * Deliver broadcast/multicast frames to all suitable
1190 - /* TODO: filter based on channel configuration */
1191 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1192 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1193 - struct sk_buff *nskb;
1196 - nskb = skb_copy(skb, GFP_ATOMIC);
1199 - ieee80211_rx(aphy->hw, nskb);
1201 - ieee80211_rx(sc->hw, skb);
1203 - /* Deliver unicast frames based on receiver address */
1204 - ieee80211_rx(hw, skb);
1207 static bool ath_edma_get_buffers(struct ath_softc *sc,
1208 enum ath9k_rx_qtype qtype)
1210 @@ -980,7 +927,7 @@ static void ath9k_process_rssi(struct at
1211 struct ieee80211_hdr *hdr,
1212 struct ath_rx_status *rx_stats)
1214 - struct ath_wiphy *aphy = hw->priv;
1215 + struct ath_softc *sc = hw->priv;
1216 struct ath_hw *ah = common->ah;
1219 @@ -1000,9 +947,9 @@ static void ath9k_process_rssi(struct at
1222 if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr)
1223 - ATH_RSSI_LPF(aphy->last_rssi, rx_stats->rs_rssi);
1224 + ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
1226 - last_rssi = aphy->last_rssi;
1227 + last_rssi = sc->last_rssi;
1228 if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
1229 rx_stats->rs_rssi = ATH_EP_RND(last_rssi,
1230 ATH_RSSI_EP_MULTIPLIER);
1231 @@ -1644,7 +1591,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
1232 * virtual wiphy so to account for that we iterate over the active
1233 * wiphys and find the appropriate wiphy and therefore hw.
1235 - struct ieee80211_hw *hw = NULL;
1236 + struct ieee80211_hw *hw = sc->hw;
1237 struct ieee80211_hdr *hdr;
1239 bool decrypt_error = false;
1240 @@ -1689,8 +1636,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
1241 hdr = (struct ieee80211_hdr *) (skb->data + rx_status_len);
1242 rxs = IEEE80211_SKB_RXCB(skb);
1244 - hw = ath_get_virt_hw(sc, hdr);
1246 ath_debug_stat_rx(sc, &rs);
1249 @@ -1748,7 +1693,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
1251 bf->bf_buf_addr = 0;
1252 ath_err(common, "dma_mapping_error() on RX\n");
1253 - ath_rx_send_to_mac80211(hw, sc, skb);
1254 + ieee80211_rx(hw, skb);
1258 @@ -1775,7 +1720,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
1259 if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
1260 ath_ant_comb_scan(sc, &rs);
1262 - ath_rx_send_to_mac80211(hw, sc, skb);
1263 + ieee80211_rx(hw, skb);
1267 --- a/drivers/net/wireless/ath/ath9k/virtual.c
1271 - * Copyright (c) 2008-2009 Atheros Communications Inc.
1273 - * Permission to use, copy, modify, and/or distribute this software for any
1274 - * purpose with or without fee is hereby granted, provided that the above
1275 - * copyright notice and this permission notice appear in all copies.
1277 - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1278 - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1279 - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1280 - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1281 - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1282 - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1283 - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1286 -#include <linux/slab.h>
1290 -int ath9k_wiphy_add(struct ath_softc *sc)
1293 - struct ath_wiphy *aphy;
1294 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1295 - struct ieee80211_hw *hw;
1296 - u8 addr[ETH_ALEN];
1298 - hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy), &ath9k_ops);
1302 - spin_lock_bh(&sc->wiphy_lock);
1303 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1304 - if (sc->sec_wiphy[i] == NULL)
1308 - if (i == sc->num_sec_wiphy) {
1309 - /* No empty slot available; increase array length */
1310 - struct ath_wiphy **n;
1311 - n = krealloc(sc->sec_wiphy,
1312 - (sc->num_sec_wiphy + 1) *
1313 - sizeof(struct ath_wiphy *),
1316 - spin_unlock_bh(&sc->wiphy_lock);
1317 - ieee80211_free_hw(hw);
1321 - sc->sec_wiphy = n;
1322 - sc->num_sec_wiphy++;
1325 - SET_IEEE80211_DEV(hw, sc->dev);
1330 - sc->sec_wiphy[i] = aphy;
1331 - aphy->last_rssi = ATH_RSSI_DUMMY_MARKER;
1332 - spin_unlock_bh(&sc->wiphy_lock);
1334 - memcpy(addr, common->macaddr, ETH_ALEN);
1335 - addr[0] |= 0x02; /* Locally managed address */
1337 - * XOR virtual wiphy index into the least significant bits to generate
1338 - * a different MAC address for each virtual wiphy.
1340 - addr[5] ^= i & 0xff;
1341 - addr[4] ^= (i & 0xff00) >> 8;
1342 - addr[3] ^= (i & 0xff0000) >> 16;
1344 - SET_IEEE80211_PERM_ADDR(hw, addr);
1346 - ath9k_set_hw_capab(sc, hw);
1348 - error = ieee80211_register_hw(hw);
1351 - /* Make sure wiphy scheduler is started (if enabled) */
1352 - ath9k_wiphy_set_scheduler(sc, sc->wiphy_scheduler_int);
1358 -int ath9k_wiphy_del(struct ath_wiphy *aphy)
1360 - struct ath_softc *sc = aphy->sc;
1363 - spin_lock_bh(&sc->wiphy_lock);
1364 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1365 - if (aphy == sc->sec_wiphy[i]) {
1366 - sc->sec_wiphy[i] = NULL;
1367 - spin_unlock_bh(&sc->wiphy_lock);
1368 - ieee80211_unregister_hw(aphy->hw);
1369 - ieee80211_free_hw(aphy->hw);
1373 - spin_unlock_bh(&sc->wiphy_lock);
1377 -static int ath9k_send_nullfunc(struct ath_wiphy *aphy,
1378 - struct ieee80211_vif *vif, const u8 *bssid,
1381 - struct ath_softc *sc = aphy->sc;
1382 - struct ath_tx_control txctl;
1383 - struct sk_buff *skb;
1384 - struct ieee80211_hdr *hdr;
1386 - struct ieee80211_tx_info *info;
1388 - skb = dev_alloc_skb(24);
1391 - hdr = (struct ieee80211_hdr *) skb_put(skb, 24);
1392 - memset(hdr, 0, 24);
1393 - fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC |
1394 - IEEE80211_FCTL_TODS);
1396 - fc |= cpu_to_le16(IEEE80211_FCTL_PM);
1397 - hdr->frame_control = fc;
1398 - memcpy(hdr->addr1, bssid, ETH_ALEN);
1399 - memcpy(hdr->addr2, aphy->hw->wiphy->perm_addr, ETH_ALEN);
1400 - memcpy(hdr->addr3, bssid, ETH_ALEN);
1402 - info = IEEE80211_SKB_CB(skb);
1403 - memset(info, 0, sizeof(*info));
1404 - info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS;
1405 - info->control.vif = vif;
1406 - info->control.rates[0].idx = 0;
1407 - info->control.rates[0].count = 4;
1408 - info->control.rates[1].idx = -1;
1410 - memset(&txctl, 0, sizeof(struct ath_tx_control));
1411 - txctl.txq = sc->tx.txq_map[WME_AC_VO];
1412 - txctl.frame_type = ps ? ATH9K_IFT_PAUSE : ATH9K_IFT_UNPAUSE;
1414 - if (ath_tx_start(aphy->hw, skb, &txctl) != 0)
1419 - dev_kfree_skb_any(skb);
1423 -static bool __ath9k_wiphy_pausing(struct ath_softc *sc)
1426 - if (sc->pri_wiphy->state == ATH_WIPHY_PAUSING)
1428 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1429 - if (sc->sec_wiphy[i] &&
1430 - sc->sec_wiphy[i]->state == ATH_WIPHY_PAUSING)
1436 -static bool ath9k_wiphy_pausing(struct ath_softc *sc)
1439 - spin_lock_bh(&sc->wiphy_lock);
1440 - ret = __ath9k_wiphy_pausing(sc);
1441 - spin_unlock_bh(&sc->wiphy_lock);
1445 -static bool __ath9k_wiphy_scanning(struct ath_softc *sc)
1448 - if (sc->pri_wiphy->state == ATH_WIPHY_SCAN)
1450 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1451 - if (sc->sec_wiphy[i] &&
1452 - sc->sec_wiphy[i]->state == ATH_WIPHY_SCAN)
1458 -bool ath9k_wiphy_scanning(struct ath_softc *sc)
1461 - spin_lock_bh(&sc->wiphy_lock);
1462 - ret = __ath9k_wiphy_scanning(sc);
1463 - spin_unlock_bh(&sc->wiphy_lock);
1467 -static int __ath9k_wiphy_unpause(struct ath_wiphy *aphy);
1469 -/* caller must hold wiphy_lock */
1470 -static void __ath9k_wiphy_unpause_ch(struct ath_wiphy *aphy)
1474 - if (aphy->chan_idx != aphy->sc->chan_idx)
1475 - return; /* wiphy not on the selected channel */
1476 - __ath9k_wiphy_unpause(aphy);
1479 -static void ath9k_wiphy_unpause_channel(struct ath_softc *sc)
1482 - spin_lock_bh(&sc->wiphy_lock);
1483 - __ath9k_wiphy_unpause_ch(sc->pri_wiphy);
1484 - for (i = 0; i < sc->num_sec_wiphy; i++)
1485 - __ath9k_wiphy_unpause_ch(sc->sec_wiphy[i]);
1486 - spin_unlock_bh(&sc->wiphy_lock);
1489 -void ath9k_wiphy_chan_work(struct work_struct *work)
1491 - struct ath_softc *sc = container_of(work, struct ath_softc, chan_work);
1492 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1493 - struct ath_wiphy *aphy = sc->next_wiphy;
1499 - * All pending interfaces paused; ready to change
1503 - /* Change channels */
1504 - mutex_lock(&sc->mutex);
1505 - /* XXX: remove me eventually */
1506 - ath9k_update_ichannel(sc, aphy->hw,
1507 - &sc->sc_ah->channels[sc->chan_idx]);
1509 - /* sync hw configuration for hw code */
1510 - common->hw = aphy->hw;
1512 - if (ath_set_channel(sc, aphy->hw,
1513 - &sc->sc_ah->channels[sc->chan_idx]) < 0) {
1514 - printk(KERN_DEBUG "ath9k: Failed to set channel for new "
1515 - "virtual wiphy\n");
1516 - mutex_unlock(&sc->mutex);
1519 - mutex_unlock(&sc->mutex);
1521 - ath9k_wiphy_unpause_channel(sc);
1525 - * ath9k version of ieee80211_tx_status() for TX frames that are generated
1526 - * internally in the driver.
1528 -void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, int ftype)
1530 - struct ath_wiphy *aphy = hw->priv;
1531 - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1533 - if (ftype == ATH9K_IFT_PAUSE && aphy->state == ATH_WIPHY_PAUSING) {
1534 - if (!(tx_info->flags & IEEE80211_TX_STAT_ACK)) {
1535 - printk(KERN_DEBUG "ath9k: %s: no ACK for pause "
1536 - "frame\n", wiphy_name(hw->wiphy));
1538 - * The AP did not reply; ignore this to allow us to
1542 - aphy->state = ATH_WIPHY_PAUSED;
1543 - if (!ath9k_wiphy_pausing(aphy->sc)) {
1545 - * Drop from tasklet to work to allow mutex for channel
1548 - ieee80211_queue_work(aphy->sc->hw,
1549 - &aphy->sc->chan_work);
1553 - dev_kfree_skb(skb);
1556 -static void ath9k_mark_paused(struct ath_wiphy *aphy)
1558 - struct ath_softc *sc = aphy->sc;
1559 - aphy->state = ATH_WIPHY_PAUSED;
1560 - if (!__ath9k_wiphy_pausing(sc))
1561 - ieee80211_queue_work(sc->hw, &sc->chan_work);
1564 -static void ath9k_pause_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
1566 - struct ath_wiphy *aphy = data;
1567 - struct ath_vif *avp = (void *) vif->drv_priv;
1569 - switch (vif->type) {
1570 - case NL80211_IFTYPE_STATION:
1571 - if (!vif->bss_conf.assoc) {
1572 - ath9k_mark_paused(aphy);
1575 - /* TODO: could avoid this if already in PS mode */
1576 - if (ath9k_send_nullfunc(aphy, vif, avp->bssid, 1)) {
1577 - printk(KERN_DEBUG "%s: failed to send PS nullfunc\n",
1579 - ath9k_mark_paused(aphy);
1582 - case NL80211_IFTYPE_AP:
1583 - /* Beacon transmission is paused by aphy->state change */
1584 - ath9k_mark_paused(aphy);
1591 -/* caller must hold wiphy_lock */
1592 -static int __ath9k_wiphy_pause(struct ath_wiphy *aphy)
1594 - ieee80211_stop_queues(aphy->hw);
1595 - aphy->state = ATH_WIPHY_PAUSING;
1597 - * TODO: handle PAUSING->PAUSED for the case where there are multiple
1598 - * active vifs (now we do it on the first vif getting ready; should be
1601 - ieee80211_iterate_active_interfaces_atomic(aphy->hw, ath9k_pause_iter,
1606 -int ath9k_wiphy_pause(struct ath_wiphy *aphy)
1609 - spin_lock_bh(&aphy->sc->wiphy_lock);
1610 - ret = __ath9k_wiphy_pause(aphy);
1611 - spin_unlock_bh(&aphy->sc->wiphy_lock);
1615 -static void ath9k_unpause_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
1617 - struct ath_wiphy *aphy = data;
1618 - struct ath_vif *avp = (void *) vif->drv_priv;
1620 - switch (vif->type) {
1621 - case NL80211_IFTYPE_STATION:
1622 - if (!vif->bss_conf.assoc)
1624 - ath9k_send_nullfunc(aphy, vif, avp->bssid, 0);
1626 - case NL80211_IFTYPE_AP:
1627 - /* Beacon transmission is re-enabled by aphy->state change */
1634 -/* caller must hold wiphy_lock */
1635 -static int __ath9k_wiphy_unpause(struct ath_wiphy *aphy)
1637 - ieee80211_iterate_active_interfaces_atomic(aphy->hw,
1638 - ath9k_unpause_iter, aphy);
1639 - aphy->state = ATH_WIPHY_ACTIVE;
1640 - ieee80211_wake_queues(aphy->hw);
1644 -int ath9k_wiphy_unpause(struct ath_wiphy *aphy)
1647 - spin_lock_bh(&aphy->sc->wiphy_lock);
1648 - ret = __ath9k_wiphy_unpause(aphy);
1649 - spin_unlock_bh(&aphy->sc->wiphy_lock);
1653 -static void __ath9k_wiphy_mark_all_paused(struct ath_softc *sc)
1656 - if (sc->pri_wiphy->state != ATH_WIPHY_INACTIVE)
1657 - sc->pri_wiphy->state = ATH_WIPHY_PAUSED;
1658 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1659 - if (sc->sec_wiphy[i] &&
1660 - sc->sec_wiphy[i]->state != ATH_WIPHY_INACTIVE)
1661 - sc->sec_wiphy[i]->state = ATH_WIPHY_PAUSED;
1665 -/* caller must hold wiphy_lock */
1666 -static void __ath9k_wiphy_pause_all(struct ath_softc *sc)
1669 - if (sc->pri_wiphy->state == ATH_WIPHY_ACTIVE)
1670 - __ath9k_wiphy_pause(sc->pri_wiphy);
1671 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1672 - if (sc->sec_wiphy[i] &&
1673 - sc->sec_wiphy[i]->state == ATH_WIPHY_ACTIVE)
1674 - __ath9k_wiphy_pause(sc->sec_wiphy[i]);
1678 -int ath9k_wiphy_select(struct ath_wiphy *aphy)
1680 - struct ath_softc *sc = aphy->sc;
1683 - spin_lock_bh(&sc->wiphy_lock);
1684 - if (__ath9k_wiphy_scanning(sc)) {
1686 - * For now, we are using mac80211 sw scan and it expects to
1687 - * have full control over channel changes, so avoid wiphy
1688 - * scheduling during a scan. This could be optimized if the
1689 - * scanning control were moved into the driver.
1691 - spin_unlock_bh(&sc->wiphy_lock);
1694 - if (__ath9k_wiphy_pausing(sc)) {
1695 - if (sc->wiphy_select_failures == 0)
1696 - sc->wiphy_select_first_fail = jiffies;
1697 - sc->wiphy_select_failures++;
1698 - if (time_after(jiffies, sc->wiphy_select_first_fail + HZ / 2))
1700 - printk(KERN_DEBUG "ath9k: Previous wiphy select timed "
1701 - "out; disable/enable hw to recover\n");
1702 - __ath9k_wiphy_mark_all_paused(sc);
1704 - * TODO: this workaround to fix hardware is unlikely to
1705 - * be specific to virtual wiphy changes. It can happen
1706 - * on normal channel change, too, and as such, this
1707 - * should really be made more generic. For example,
1708 - * tricker radio disable/enable on GTT interrupt burst
1709 - * (say, 10 GTT interrupts received without any TX
1710 - * frame being completed)
1712 - spin_unlock_bh(&sc->wiphy_lock);
1713 - ath_radio_disable(sc, aphy->hw);
1714 - ath_radio_enable(sc, aphy->hw);
1715 - /* Only the primary wiphy hw is used for queuing work */
1716 - ieee80211_queue_work(aphy->sc->hw,
1717 - &aphy->sc->chan_work);
1718 - return -EBUSY; /* previous select still in progress */
1720 - spin_unlock_bh(&sc->wiphy_lock);
1721 - return -EBUSY; /* previous select still in progress */
1723 - sc->wiphy_select_failures = 0;
1725 - /* Store the new channel */
1726 - sc->chan_idx = aphy->chan_idx;
1727 - sc->chan_is_ht = aphy->chan_is_ht;
1728 - sc->next_wiphy = aphy;
1730 - __ath9k_wiphy_pause_all(sc);
1731 - now = !__ath9k_wiphy_pausing(aphy->sc);
1732 - spin_unlock_bh(&sc->wiphy_lock);
1735 - /* Ready to request channel change immediately */
1736 - ieee80211_queue_work(aphy->sc->hw, &aphy->sc->chan_work);
1740 - * wiphys will be unpaused in ath9k_tx_status() once channel has been
1741 - * changed if any wiphy needs time to become paused.
1747 -bool ath9k_wiphy_started(struct ath_softc *sc)
1750 - spin_lock_bh(&sc->wiphy_lock);
1751 - if (sc->pri_wiphy->state != ATH_WIPHY_INACTIVE) {
1752 - spin_unlock_bh(&sc->wiphy_lock);
1755 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1756 - if (sc->sec_wiphy[i] &&
1757 - sc->sec_wiphy[i]->state != ATH_WIPHY_INACTIVE) {
1758 - spin_unlock_bh(&sc->wiphy_lock);
1762 - spin_unlock_bh(&sc->wiphy_lock);
1766 -static void ath9k_wiphy_pause_chan(struct ath_wiphy *aphy,
1767 - struct ath_wiphy *selected)
1769 - if (selected->state == ATH_WIPHY_SCAN) {
1770 - if (aphy == selected)
1773 - * Pause all other wiphys for the duration of the scan even if
1774 - * they are on the current channel now.
1776 - } else if (aphy->chan_idx == selected->chan_idx)
1778 - aphy->state = ATH_WIPHY_PAUSED;
1779 - ieee80211_stop_queues(aphy->hw);
1782 -void ath9k_wiphy_pause_all_forced(struct ath_softc *sc,
1783 - struct ath_wiphy *selected)
1786 - spin_lock_bh(&sc->wiphy_lock);
1787 - if (sc->pri_wiphy->state == ATH_WIPHY_ACTIVE)
1788 - ath9k_wiphy_pause_chan(sc->pri_wiphy, selected);
1789 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1790 - if (sc->sec_wiphy[i] &&
1791 - sc->sec_wiphy[i]->state == ATH_WIPHY_ACTIVE)
1792 - ath9k_wiphy_pause_chan(sc->sec_wiphy[i], selected);
1794 - spin_unlock_bh(&sc->wiphy_lock);
1797 -void ath9k_wiphy_work(struct work_struct *work)
1799 - struct ath_softc *sc = container_of(work, struct ath_softc,
1801 - struct ath_wiphy *aphy = NULL;
1802 - bool first = true;
1804 - spin_lock_bh(&sc->wiphy_lock);
1806 - if (sc->wiphy_scheduler_int == 0) {
1807 - /* wiphy scheduler is disabled */
1808 - spin_unlock_bh(&sc->wiphy_lock);
1813 - sc->wiphy_scheduler_index++;
1814 - while (sc->wiphy_scheduler_index <= sc->num_sec_wiphy) {
1815 - aphy = sc->sec_wiphy[sc->wiphy_scheduler_index - 1];
1816 - if (aphy && aphy->state != ATH_WIPHY_INACTIVE)
1819 - sc->wiphy_scheduler_index++;
1822 - if (aphy == NULL) {
1823 - sc->wiphy_scheduler_index = 0;
1824 - if (sc->pri_wiphy->state == ATH_WIPHY_INACTIVE) {
1829 - /* No wiphy is ready to be scheduled */
1831 - aphy = sc->pri_wiphy;
1834 - spin_unlock_bh(&sc->wiphy_lock);
1837 - aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN &&
1838 - ath9k_wiphy_select(aphy)) {
1839 - printk(KERN_DEBUG "ath9k: Failed to schedule virtual wiphy "
1843 - ieee80211_queue_delayed_work(sc->hw,
1845 - sc->wiphy_scheduler_int);
1848 -void ath9k_wiphy_set_scheduler(struct ath_softc *sc, unsigned int msec_int)
1850 - cancel_delayed_work_sync(&sc->wiphy_work);
1851 - sc->wiphy_scheduler_int = msecs_to_jiffies(msec_int);
1852 - if (sc->wiphy_scheduler_int)
1853 - ieee80211_queue_delayed_work(sc->hw, &sc->wiphy_work,
1854 - sc->wiphy_scheduler_int);
1857 -/* caller must hold wiphy_lock */
1858 -bool ath9k_all_wiphys_idle(struct ath_softc *sc)
1861 - if (!sc->pri_wiphy->idle)
1863 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1864 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1873 -/* caller must hold wiphy_lock */
1874 -void ath9k_set_wiphy_idle(struct ath_wiphy *aphy, bool idle)
1876 - struct ath_softc *sc = aphy->sc;
1878 - aphy->idle = idle;
1879 - ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
1880 - "Marking %s as %sidle\n",
1881 - wiphy_name(aphy->hw->wiphy), idle ? "" : "not-");
1883 -/* Only bother starting a queue on an active virtual wiphy */
1884 -bool ath_mac80211_start_queue(struct ath_softc *sc, u16 skb_queue)
1886 - struct ieee80211_hw *hw = sc->pri_wiphy->hw;
1888 - bool txq_started = false;
1890 - spin_lock_bh(&sc->wiphy_lock);
1892 - /* Start the primary wiphy */
1893 - if (sc->pri_wiphy->state == ATH_WIPHY_ACTIVE) {
1894 - ieee80211_wake_queue(hw, skb_queue);
1895 - txq_started = true;
1899 - /* Now start the secondary wiphy queues */
1900 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1901 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1904 - if (aphy->state != ATH_WIPHY_ACTIVE)
1908 - ieee80211_wake_queue(hw, skb_queue);
1909 - txq_started = true;
1914 - spin_unlock_bh(&sc->wiphy_lock);
1915 - return txq_started;
1918 -/* Go ahead and propagate information to all virtual wiphys, it won't hurt */
1919 -void ath_mac80211_stop_queue(struct ath_softc *sc, u16 skb_queue)
1921 - struct ieee80211_hw *hw = sc->pri_wiphy->hw;
1924 - spin_lock_bh(&sc->wiphy_lock);
1926 - /* Stop the primary wiphy */
1927 - ieee80211_stop_queue(hw, skb_queue);
1929 - /* Now stop the secondary wiphy queues */
1930 - for (i = 0; i < sc->num_sec_wiphy; i++) {
1931 - struct ath_wiphy *aphy = sc->sec_wiphy[i];
1935 - ieee80211_stop_queue(hw, skb_queue);
1937 - spin_unlock_bh(&sc->wiphy_lock);
1939 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1940 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1941 @@ -57,8 +57,9 @@ static void ath_tx_complete_buf(struct a
1942 static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
1943 struct list_head *head);
1944 static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, int len);
1945 -static void ath_tx_rc_status(struct ath_buf *bf, struct ath_tx_status *ts,
1946 - int nframes, int nbad, int txok, bool update_rc);
1947 +static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,
1948 + struct ath_tx_status *ts, int nframes, int nbad,
1949 + int txok, bool update_rc);
1950 static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
1953 @@ -297,7 +298,6 @@ static struct ath_buf* ath_clone_txbuf(s
1955 ATH_TXBUF_RESET(tbf);
1957 - tbf->aphy = bf->aphy;
1958 tbf->bf_mpdu = bf->bf_mpdu;
1959 tbf->bf_buf_addr = bf->bf_buf_addr;
1960 memcpy(tbf->bf_desc, bf->bf_desc, sc->sc_ah->caps.tx_desc_len);
1961 @@ -345,7 +345,7 @@ static void ath_tx_complete_aggr(struct
1962 struct ath_node *an = NULL;
1963 struct sk_buff *skb;
1964 struct ieee80211_sta *sta;
1965 - struct ieee80211_hw *hw;
1966 + struct ieee80211_hw *hw = sc->hw;
1967 struct ieee80211_hdr *hdr;
1968 struct ieee80211_tx_info *tx_info;
1969 struct ath_atx_tid *tid = NULL;
1970 @@ -364,7 +364,6 @@ static void ath_tx_complete_aggr(struct
1971 hdr = (struct ieee80211_hdr *)skb->data;
1973 tx_info = IEEE80211_SKB_CB(skb);
1974 - hw = bf->aphy->hw;
1976 memcpy(rates, tx_info->control.rates, sizeof(rates));
1978 @@ -383,7 +382,7 @@ static void ath_tx_complete_aggr(struct
1979 !bf->bf_stale || bf_next != NULL)
1980 list_move_tail(&bf->list, &bf_head);
1982 - ath_tx_rc_status(bf, ts, 1, 1, 0, false);
1983 + ath_tx_rc_status(sc, bf, ts, 1, 1, 0, false);
1984 ath_tx_complete_buf(sc, bf, txq, &bf_head, ts,
1987 @@ -489,10 +488,10 @@ static void ath_tx_complete_aggr(struct
1989 if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
1990 memcpy(tx_info->control.rates, rates, sizeof(rates));
1991 - ath_tx_rc_status(bf, ts, nframes, nbad, txok, true);
1992 + ath_tx_rc_status(sc, bf, ts, nframes, nbad, txok, true);
1995 - ath_tx_rc_status(bf, ts, nframes, nbad, txok, false);
1996 + ath_tx_rc_status(sc, bf, ts, nframes, nbad, txok, false);
1999 ath_tx_complete_buf(sc, bf, txq, &bf_head, ts,
2000 @@ -516,7 +515,7 @@ static void ath_tx_complete_aggr(struct
2002 bf->bf_state.bf_type |=
2004 - ath_tx_rc_status(bf, ts, nframes,
2005 + ath_tx_rc_status(sc, bf, ts, nframes,
2007 ath_tx_complete_buf(sc, bf, txq,
2009 @@ -1209,8 +1208,17 @@ bool ath_drain_all_txq(struct ath_softc
2010 ath_err(common, "Failed to stop TX DMA!\n");
2012 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
2013 - if (ATH_TXQ_SETUP(sc, i))
2014 - ath_draintxq(sc, &sc->tx.txq[i], retry_tx);
2015 + if (!ATH_TXQ_SETUP(sc, i))
2019 + * The caller will resume queues with ieee80211_wake_queues.
2020 + * Mark the queue as not stopped to prevent ath_tx_complete
2021 + * from waking the queue too early.
2023 + txq = &sc->tx.txq[i];
2024 + txq->stopped = false;
2025 + ath_draintxq(sc, txq, retry_tx);
2029 @@ -1318,6 +1326,7 @@ static void ath_tx_txqaddbuf(struct ath_
2030 INIT_LIST_HEAD(&txq->txq_fifo[txq->txq_headidx]);
2031 list_splice_init(head, &txq->txq_fifo[txq->txq_headidx]);
2032 INCR(txq->txq_headidx, ATH_TXFIFO_DEPTH);
2033 + TX_STAT_INC(txq->axq_qnum, puttxbuf);
2034 ath9k_hw_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr);
2035 ath_dbg(common, ATH_DBG_XMIT, "TXDP[%u] = %llx (%p)\n",
2036 txq->axq_qnum, ito64(bf->bf_daddr), bf->bf_desc);
2037 @@ -1325,6 +1334,7 @@ static void ath_tx_txqaddbuf(struct ath_
2038 list_splice_tail_init(head, &txq->axq_q);
2040 if (txq->axq_link == NULL) {
2041 + TX_STAT_INC(txq->axq_qnum, puttxbuf);
2042 ath9k_hw_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr);
2043 ath_dbg(common, ATH_DBG_XMIT, "TXDP[%u] = %llx (%p)\n",
2044 txq->axq_qnum, ito64(bf->bf_daddr),
2045 @@ -1338,6 +1348,7 @@ static void ath_tx_txqaddbuf(struct ath_
2047 ath9k_hw_get_desc_link(ah, bf->bf_lastbf->bf_desc,
2049 + TX_STAT_INC(txq->axq_qnum, txstart);
2050 ath9k_hw_txstart(ah, txq->axq_qnum);
2053 @@ -1434,8 +1445,7 @@ static enum ath9k_pkt_type get_hw_packet
2054 static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb,
2057 - struct ath_wiphy *aphy = hw->priv;
2058 - struct ath_softc *sc = aphy->sc;
2059 + struct ath_softc *sc = hw->priv;
2060 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
2061 struct ieee80211_sta *sta = tx_info->control.sta;
2062 struct ieee80211_key_conf *hw_key = tx_info->control.hw_key;
2063 @@ -1653,8 +1663,7 @@ static struct ath_buf *ath_tx_setup_buff
2064 struct ath_txq *txq,
2065 struct sk_buff *skb)
2067 - struct ath_wiphy *aphy = hw->priv;
2068 - struct ath_softc *sc = aphy->sc;
2069 + struct ath_softc *sc = hw->priv;
2070 struct ath_hw *ah = sc->sc_ah;
2071 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2072 struct ath_frame_info *fi = get_frame_info(skb);
2073 @@ -1670,7 +1679,6 @@ static struct ath_buf *ath_tx_setup_buff
2075 ATH_TXBUF_RESET(bf);
2078 bf->bf_flags = setup_tx_flags(skb);
2081 @@ -1756,8 +1764,7 @@ int ath_tx_start(struct ieee80211_hw *hw
2082 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
2083 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2084 struct ieee80211_sta *sta = info->control.sta;
2085 - struct ath_wiphy *aphy = hw->priv;
2086 - struct ath_softc *sc = aphy->sc;
2087 + struct ath_softc *sc = hw->priv;
2088 struct ath_txq *txq = txctl->txq;
2090 int padpos, padsize;
2091 @@ -1809,7 +1816,7 @@ int ath_tx_start(struct ieee80211_hw *hw
2092 spin_lock_bh(&txq->axq_lock);
2093 if (txq == sc->tx.txq_map[q] &&
2094 ++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
2095 - ath_mac80211_stop_queue(sc, q);
2096 + ieee80211_stop_queue(sc->hw, q);
2099 spin_unlock_bh(&txq->axq_lock);
2100 @@ -1824,8 +1831,7 @@ int ath_tx_start(struct ieee80211_hw *hw
2103 static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
2104 - struct ath_wiphy *aphy, int tx_flags, int ftype,
2105 - struct ath_txq *txq)
2106 + int tx_flags, int ftype, struct ath_txq *txq)
2108 struct ieee80211_hw *hw = sc->hw;
2109 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
2110 @@ -1835,9 +1841,6 @@ static void ath_tx_complete(struct ath_s
2112 ath_dbg(common, ATH_DBG_XMIT, "TX complete: skb: %p\n", skb);
2117 if (tx_flags & ATH_TX_BAR)
2118 tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
2120 @@ -1867,19 +1870,20 @@ static void ath_tx_complete(struct ath_s
2121 PS_WAIT_FOR_TX_ACK));
2124 - if (unlikely(ftype))
2125 - ath9k_tx_status(hw, skb, ftype);
2127 - q = skb_get_queue_mapping(skb);
2128 - if (txq == sc->tx.txq_map[q]) {
2129 - spin_lock_bh(&txq->axq_lock);
2130 - if (WARN_ON(--txq->pending_frames < 0))
2131 - txq->pending_frames = 0;
2132 - spin_unlock_bh(&txq->axq_lock);
2134 + q = skb_get_queue_mapping(skb);
2135 + if (txq == sc->tx.txq_map[q]) {
2136 + spin_lock_bh(&txq->axq_lock);
2137 + if (WARN_ON(--txq->pending_frames < 0))
2138 + txq->pending_frames = 0;
2140 - ieee80211_tx_status(hw, skb);
2141 + if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
2142 + ieee80211_wake_queue(sc->hw, q);
2145 + spin_unlock_bh(&txq->axq_lock);
2148 + ieee80211_tx_status(hw, skb);
2151 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
2152 @@ -1910,7 +1914,7 @@ static void ath_tx_complete_buf(struct a
2153 complete(&sc->paprd_complete);
2155 ath_debug_stat_tx(sc, bf, ts);
2156 - ath_tx_complete(sc, skb, bf->aphy, tx_flags,
2157 + ath_tx_complete(sc, skb, tx_flags,
2158 bf->bf_state.bfs_ftype, txq);
2160 /* At this point, skb (bf->bf_mpdu) is consumed...make sure we don't
2161 @@ -1926,14 +1930,14 @@ static void ath_tx_complete_buf(struct a
2162 spin_unlock_irqrestore(&sc->tx.txbuflock, flags);
2165 -static void ath_tx_rc_status(struct ath_buf *bf, struct ath_tx_status *ts,
2166 - int nframes, int nbad, int txok, bool update_rc)
2167 +static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,
2168 + struct ath_tx_status *ts, int nframes, int nbad,
2169 + int txok, bool update_rc)
2171 struct sk_buff *skb = bf->bf_mpdu;
2172 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2173 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
2174 - struct ieee80211_hw *hw = bf->aphy->hw;
2175 - struct ath_softc *sc = bf->aphy->sc;
2176 + struct ieee80211_hw *hw = sc->hw;
2177 struct ath_hw *ah = sc->sc_ah;
2180 @@ -1984,18 +1988,6 @@ static void ath_tx_rc_status(struct ath_
2181 tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1;
2184 -/* Has no locking. Must hold spin_lock_bh(&txq->axq_lock)
2185 - * before calling this.
2187 -static void __ath_wake_mac80211_queue(struct ath_softc *sc, struct ath_txq *txq)
2189 - if (txq->mac80211_qnum >= 0 &&
2190 - txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
2191 - if (ath_mac80211_start_queue(sc, txq->mac80211_qnum))
2196 static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
2198 struct ath_hw *ah = sc->sc_ah;
2199 @@ -2006,7 +1998,6 @@ static void ath_tx_processq(struct ath_s
2200 struct ath_tx_status ts;
2205 ath_dbg(common, ATH_DBG_QUEUE, "tx queue %d (%x), link %p\n",
2206 txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum),
2207 @@ -2085,11 +2076,9 @@ static void ath_tx_processq(struct ath_s
2209 if (ts.ts_status & ATH9K_TXERR_XRETRY)
2210 bf->bf_state.bf_type |= BUF_XRETRY;
2211 - ath_tx_rc_status(bf, &ts, 1, txok ? 0 : 1, txok, true);
2212 + ath_tx_rc_status(sc, bf, &ts, 1, txok ? 0 : 1, txok, true);
2215 - qnum = skb_get_queue_mapping(bf->bf_mpdu);
2218 ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, txok,
2220 @@ -2097,7 +2086,6 @@ static void ath_tx_processq(struct ath_s
2221 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, txok, 0);
2223 spin_lock_bh(&txq->axq_lock);
2224 - __ath_wake_mac80211_queue(sc, txq);
2226 if (sc->sc_flags & SC_OP_TXAGGR)
2227 ath_txq_schedule(sc, txq);
2228 @@ -2153,7 +2141,6 @@ static void ath_tx_complete_poll_work(st
2229 txq->pending_frames,
2230 list_empty(&txq->axq_acq),
2232 - __ath_wake_mac80211_queue(sc, txq);
2233 ath_txq_schedule(sc, txq);
2236 @@ -2195,7 +2182,6 @@ void ath_tx_edma_tasklet(struct ath_soft
2237 struct list_head bf_head;
2243 status = ath9k_hw_txprocdesc(ah, NULL, (void *)&txs);
2244 @@ -2238,11 +2224,9 @@ void ath_tx_edma_tasklet(struct ath_soft
2245 if (!bf_isampdu(bf)) {
2246 if (txs.ts_status & ATH9K_TXERR_XRETRY)
2247 bf->bf_state.bf_type |= BUF_XRETRY;
2248 - ath_tx_rc_status(bf, &txs, 1, txok ? 0 : 1, txok, true);
2249 + ath_tx_rc_status(sc, bf, &txs, 1, txok ? 0 : 1, txok, true);
2252 - qnum = skb_get_queue_mapping(bf->bf_mpdu);
2255 ath_tx_complete_aggr(sc, txq, bf, &bf_head, &txs,
2257 @@ -2251,7 +2235,6 @@ void ath_tx_edma_tasklet(struct ath_soft
2260 spin_lock_bh(&txq->axq_lock);
2261 - __ath_wake_mac80211_queue(sc, txq);
2263 if (!list_empty(&txq->txq_fifo_pending)) {
2264 INIT_LIST_HEAD(&bf_head);
2265 --- a/drivers/net/wireless/ath/ath9k/mac.c
2266 +++ b/drivers/net/wireless/ath/ath9k/mac.c
2274 static void ath9k_hw_set_txq_interrupts(struct ath_hw *ah,
2275 struct ath9k_tx_queue_info *qi)
2276 @@ -52,18 +50,12 @@ EXPORT_SYMBOL(ath9k_hw_gettxbuf);
2278 void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp)
2280 - struct ath_wiphy *aphy = ah->hw->priv;
2281 - struct ath_softc *sc = aphy->sc;
2282 - TX_STAT_INC(q, puttxbuf);
2283 REG_WRITE(ah, AR_QTXDP(q), txdp);
2285 EXPORT_SYMBOL(ath9k_hw_puttxbuf);
2287 void ath9k_hw_txstart(struct ath_hw *ah, u32 q)
2289 - struct ath_wiphy *aphy = ah->hw->priv;
2290 - struct ath_softc *sc = aphy->sc;
2291 - TX_STAT_INC(q, txstart);
2292 ath_dbg(ath9k_hw_common(ah), ATH_DBG_QUEUE,
2293 "Enable TXE on queue: %u\n", q);
2294 REG_WRITE(ah, AR_Q_TXE, 1 << q);