2 * Copyright (c) 2008-2011 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/nl80211.h>
18 #include <linux/delay.h>
22 static void ath9k_set_assoc_state(struct ath_softc *sc,
23 struct ieee80211_vif *vif);
25 u8 ath9k_parse_mpdudensity(u8 mpdudensity)
28 * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
29 * 0 for no restriction
38 switch (mpdudensity) {
44 /* Our lower layer calculations limit our precision to
60 static bool ath9k_has_pending_frames(struct ath_softc *sc, struct ath_txq *txq)
64 spin_lock_bh(&txq->axq_lock);
66 if (txq->axq_depth || !list_empty(&txq->axq_acq))
69 spin_unlock_bh(&txq->axq_lock);
73 static bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode)
78 spin_lock_irqsave(&sc->sc_pm_lock, flags);
79 ret = ath9k_hw_setpower(sc->sc_ah, mode);
80 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
85 void ath9k_ps_wakeup(struct ath_softc *sc)
87 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
89 enum ath9k_power_mode power_mode;
91 spin_lock_irqsave(&sc->sc_pm_lock, flags);
92 if (++sc->ps_usecount != 1)
95 power_mode = sc->sc_ah->power_mode;
96 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
99 * While the hardware is asleep, the cycle counters contain no
100 * useful data. Better clear them now so that they don't mess up
101 * survey data results.
103 if (power_mode != ATH9K_PM_AWAKE) {
104 spin_lock(&common->cc_lock);
105 ath_hw_cycle_counters_update(common);
106 memset(&common->cc_survey, 0, sizeof(common->cc_survey));
107 memset(&common->cc_ani, 0, sizeof(common->cc_ani));
108 spin_unlock(&common->cc_lock);
112 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
115 void ath9k_ps_restore(struct ath_softc *sc)
117 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
118 enum ath9k_power_mode mode;
122 spin_lock_irqsave(&sc->sc_pm_lock, flags);
123 if (--sc->ps_usecount != 0)
127 ath9k_hw_setrxabort(sc->sc_ah, 1);
128 ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
129 mode = ATH9K_PM_FULL_SLEEP;
130 } else if (sc->ps_enabled &&
131 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
133 PS_WAIT_FOR_PSPOLL_DATA |
136 mode = ATH9K_PM_NETWORK_SLEEP;
137 if (ath9k_hw_btcoex_is_enabled(sc->sc_ah))
138 ath9k_btcoex_stop_gen_timer(sc);
143 spin_lock(&common->cc_lock);
144 ath_hw_cycle_counters_update(common);
145 spin_unlock(&common->cc_lock);
147 ath9k_hw_setpower(sc->sc_ah, mode);
150 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
153 static void __ath_cancel_work(struct ath_softc *sc)
155 cancel_work_sync(&sc->paprd_work);
156 cancel_work_sync(&sc->hw_check_work);
157 cancel_delayed_work_sync(&sc->tx_complete_work);
158 cancel_delayed_work_sync(&sc->hw_pll_work);
160 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
161 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
162 cancel_work_sync(&sc->mci_work);
166 static void ath_cancel_work(struct ath_softc *sc)
168 __ath_cancel_work(sc);
169 cancel_work_sync(&sc->hw_reset_work);
172 static void ath_restart_work(struct ath_softc *sc)
174 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
176 if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah))
177 ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
178 msecs_to_jiffies(ATH_PLL_WORK_INTERVAL));
180 ath_start_rx_poll(sc, 3);
184 static bool ath_prepare_reset(struct ath_softc *sc)
186 struct ath_hw *ah = sc->sc_ah;
189 ieee80211_stop_queues(sc->hw);
191 sc->hw_busy_count = 0;
193 del_timer_sync(&sc->rx_poll_timer);
195 ath9k_hw_disable_interrupts(ah);
197 if (!ath_drain_all_txq(sc))
200 if (!ath_stoprecv(sc))
206 static bool ath_complete_reset(struct ath_softc *sc, bool start)
208 struct ath_hw *ah = sc->sc_ah;
209 struct ath_common *common = ath9k_hw_common(ah);
212 if (ath_startrecv(sc) != 0) {
213 ath_err(common, "Unable to restart recv logic\n");
217 ath9k_cmn_update_txpow(ah, sc->curtxpow,
218 sc->config.txpowlimit, &sc->curtxpow);
220 clear_bit(SC_OP_HW_RESET, &sc->sc_flags);
221 ath9k_hw_set_interrupts(ah);
222 ath9k_hw_enable_interrupts(ah);
224 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) && start) {
225 if (!test_bit(SC_OP_BEACONS, &sc->sc_flags))
228 if (ah->opmode == NL80211_IFTYPE_STATION &&
229 test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
230 spin_lock_irqsave(&sc->sc_pm_lock, flags);
231 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
232 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
234 ath9k_set_beacon(sc);
237 ath_restart_work(sc);
240 ieee80211_wake_queues(sc->hw);
245 static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan)
247 struct ath_hw *ah = sc->sc_ah;
248 struct ath_common *common = ath9k_hw_common(ah);
249 struct ath9k_hw_cal_data *caldata = NULL;
253 __ath_cancel_work(sc);
255 tasklet_disable(&sc->intr_tq);
256 spin_lock_bh(&sc->sc_pcu_lock);
258 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
260 caldata = &sc->caldata;
268 if (!ath_prepare_reset(sc))
271 ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
272 hchan->channel, IS_CHAN_HT40(hchan), fastcc);
274 r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
277 "Unable to reset channel, reset status %d\n", r);
279 ath9k_hw_enable_interrupts(ah);
280 ath9k_queue_reset(sc, RESET_TYPE_BB_HANG);
285 if (ath9k_hw_mci_is_enabled(sc->sc_ah) &&
286 (sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL))
287 ath9k_mci_set_txpower(sc, true, false);
289 if (!ath_complete_reset(sc, true))
293 spin_unlock_bh(&sc->sc_pcu_lock);
294 tasklet_enable(&sc->intr_tq);
301 * Set/change channels. If the channel is really being changed, it's done
302 * by reseting the chip. To accomplish this we must first cleanup any pending
303 * DMA, then restart stuff.
305 static int ath_set_channel(struct ath_softc *sc, struct cfg80211_chan_def *chandef)
307 struct ath_hw *ah = sc->sc_ah;
308 struct ath_common *common = ath9k_hw_common(ah);
309 struct ieee80211_hw *hw = sc->hw;
310 struct ath9k_channel *hchan;
311 struct ieee80211_channel *chan = chandef->chan;
314 int pos = chan->hw_value;
318 if (test_bit(SC_OP_INVALID, &sc->sc_flags))
321 offchannel = !!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL);
324 old_pos = ah->curchan - &ah->channels[0];
326 ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n",
327 chan->center_freq, chandef->width);
329 /* update survey stats for the old channel before switching */
330 spin_lock_irqsave(&common->cc_lock, flags);
331 ath_update_survey_stats(sc);
332 spin_unlock_irqrestore(&common->cc_lock, flags);
334 ath9k_cmn_get_channel(hw, ah, chandef);
337 * If the operating channel changes, change the survey in-use flags
339 * Reset the survey data for the new channel, unless we're switching
340 * back to the operating channel from an off-channel operation.
342 if (!offchannel && sc->cur_survey != &sc->survey[pos]) {
344 sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
346 sc->cur_survey = &sc->survey[pos];
348 memset(sc->cur_survey, 0, sizeof(struct survey_info));
349 sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
350 } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
351 memset(&sc->survey[pos], 0, sizeof(struct survey_info));
354 hchan = &sc->sc_ah->channels[pos];
355 r = ath_reset_internal(sc, hchan);
360 * The most recent snapshot of channel->noisefloor for the old
361 * channel is only available after the hardware reset. Copy it to
362 * the survey stats now.
365 ath_update_survey_nf(sc, old_pos);
368 * Enable radar pulse detection if on a DFS channel. Spectral
369 * scanning and radar detection can not be used concurrently.
371 if (hw->conf.radar_enabled) {
374 /* set HW specific DFS configuration */
375 ath9k_hw_set_radar_params(ah);
376 rxfilter = ath9k_hw_getrxfilter(ah);
377 rxfilter |= ATH9K_RX_FILTER_PHYRADAR |
378 ATH9K_RX_FILTER_PHYERR;
379 ath9k_hw_setrxfilter(ah, rxfilter);
380 ath_dbg(common, DFS, "DFS enabled at freq %d\n",
383 /* perform spectral scan if requested. */
384 if (test_bit(SC_OP_SCANNING, &sc->sc_flags) &&
385 sc->spectral_mode == SPECTRAL_CHANSCAN)
386 ath9k_spectral_scan_trigger(hw);
392 static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
393 struct ieee80211_vif *vif)
396 an = (struct ath_node *)sta->drv_priv;
402 ath_tx_node_init(sc, an);
404 if (sta->ht_cap.ht_supported) {
405 an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
406 sta->ht_cap.ampdu_factor);
407 an->mpdudensity = ath9k_parse_mpdudensity(sta->ht_cap.ampdu_density);
411 static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
413 struct ath_node *an = (struct ath_node *)sta->drv_priv;
414 ath_tx_node_cleanup(sc, an);
417 void ath9k_tasklet(unsigned long data)
419 struct ath_softc *sc = (struct ath_softc *)data;
420 struct ath_hw *ah = sc->sc_ah;
421 struct ath_common *common = ath9k_hw_common(ah);
422 enum ath_reset_type type;
424 u32 status = sc->intrstatus;
428 spin_lock(&sc->sc_pcu_lock);
430 if ((status & ATH9K_INT_FATAL) ||
431 (status & ATH9K_INT_BB_WATCHDOG)) {
433 if (status & ATH9K_INT_FATAL)
434 type = RESET_TYPE_FATAL_INT;
436 type = RESET_TYPE_BB_WATCHDOG;
438 ath9k_queue_reset(sc, type);
441 * Increment the ref. counter here so that
442 * interrupts are enabled in the reset routine.
444 atomic_inc(&ah->intr_ref_cnt);
445 ath_dbg(common, ANY, "FATAL: Skipping interrupts\n");
449 spin_lock_irqsave(&sc->sc_pm_lock, flags);
450 if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
452 * TSF sync does not look correct; remain awake to sync with
455 ath_dbg(common, PS, "TSFOOR - Sync with next Beacon\n");
456 sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC;
458 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
460 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
461 rxmask = (ATH9K_INT_RXHP | ATH9K_INT_RXLP | ATH9K_INT_RXEOL |
464 rxmask = (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
466 if (status & rxmask) {
467 /* Check for high priority Rx first */
468 if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
469 (status & ATH9K_INT_RXHP))
470 ath_rx_tasklet(sc, 0, true);
472 ath_rx_tasklet(sc, 0, false);
475 if (status & ATH9K_INT_TX) {
476 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
477 ath_tx_edma_tasklet(sc);
482 ath9k_btcoex_handle_interrupt(sc, status);
484 /* re-enable hardware interrupt */
485 ath9k_hw_enable_interrupts(ah);
487 spin_unlock(&sc->sc_pcu_lock);
488 ath9k_ps_restore(sc);
491 irqreturn_t ath_isr(int irq, void *dev)
493 #define SCHED_INTR ( \
495 ATH9K_INT_BB_WATCHDOG | \
505 ATH9K_INT_GENTIMER | \
508 struct ath_softc *sc = dev;
509 struct ath_hw *ah = sc->sc_ah;
510 struct ath_common *common = ath9k_hw_common(ah);
511 enum ath9k_int status;
515 * The hardware is not ready/present, don't
516 * touch anything. Note this can happen early
517 * on if the IRQ is shared.
519 if (test_bit(SC_OP_INVALID, &sc->sc_flags))
522 /* shared irq, not for us */
524 if (!ath9k_hw_intrpend(ah))
527 if (test_bit(SC_OP_HW_RESET, &sc->sc_flags)) {
528 ath9k_hw_kill_interrupts(ah);
533 * Figure out the reason(s) for the interrupt. Note
534 * that the hal returns a pseudo-ISR that may include
535 * bits we haven't explicitly enabled so we mask the
536 * value to insure we only process bits we requested.
538 ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
539 status &= ah->imask; /* discard unasked-for bits */
542 * If there are no status bits set, then this interrupt was not
543 * for me (should have been caught above).
548 /* Cache the status */
549 sc->intrstatus = status;
551 if (status & SCHED_INTR)
555 * If a FATAL or RXORN interrupt is received, we have to reset the
558 if ((status & ATH9K_INT_FATAL) || ((status & ATH9K_INT_RXORN) &&
559 !(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)))
562 if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
563 (status & ATH9K_INT_BB_WATCHDOG)) {
565 spin_lock(&common->cc_lock);
566 ath_hw_cycle_counters_update(common);
567 ar9003_hw_bb_watchdog_dbg_info(ah);
568 spin_unlock(&common->cc_lock);
572 #ifdef CONFIG_PM_SLEEP
573 if (status & ATH9K_INT_BMISS) {
574 if (atomic_read(&sc->wow_sleep_proc_intr) == 0) {
575 ath_dbg(common, ANY, "during WoW we got a BMISS\n");
576 atomic_inc(&sc->wow_got_bmiss_intr);
577 atomic_dec(&sc->wow_sleep_proc_intr);
581 if (status & ATH9K_INT_SWBA)
582 tasklet_schedule(&sc->bcon_tasklet);
584 if (status & ATH9K_INT_TXURN)
585 ath9k_hw_updatetxtriglevel(ah, true);
587 if (status & ATH9K_INT_RXEOL) {
588 ah->imask &= ~(ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
589 ath9k_hw_set_interrupts(ah);
592 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
593 if (status & ATH9K_INT_TIM_TIMER) {
594 if (ATH_DBG_WARN_ON_ONCE(sc->ps_idle))
596 /* Clear RxAbort bit so that we can
598 ath9k_setpower(sc, ATH9K_PM_AWAKE);
599 spin_lock(&sc->sc_pm_lock);
600 ath9k_hw_setrxabort(sc->sc_ah, 0);
601 sc->ps_flags |= PS_WAIT_FOR_BEACON;
602 spin_unlock(&sc->sc_pm_lock);
607 ath_debug_stat_interrupt(sc, status);
610 /* turn off every interrupt */
611 ath9k_hw_disable_interrupts(ah);
612 tasklet_schedule(&sc->intr_tq);
620 static int ath_reset(struct ath_softc *sc)
626 r = ath_reset_internal(sc, NULL);
628 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
629 if (!ATH_TXQ_SETUP(sc, i))
632 spin_lock_bh(&sc->tx.txq[i].axq_lock);
633 ath_txq_schedule(sc, &sc->tx.txq[i]);
634 spin_unlock_bh(&sc->tx.txq[i].axq_lock);
637 ath9k_ps_restore(sc);
642 void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type)
644 #ifdef CONFIG_ATH9K_DEBUGFS
645 RESET_STAT_INC(sc, type);
647 set_bit(SC_OP_HW_RESET, &sc->sc_flags);
648 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
651 void ath_reset_work(struct work_struct *work)
653 struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work);
658 /**********************/
659 /* mac80211 callbacks */
660 /**********************/
662 static int ath9k_start(struct ieee80211_hw *hw)
664 struct ath_softc *sc = hw->priv;
665 struct ath_hw *ah = sc->sc_ah;
666 struct ath_common *common = ath9k_hw_common(ah);
667 struct ieee80211_channel *curchan = hw->conf.chandef.chan;
668 struct ath9k_channel *init_channel;
671 ath_dbg(common, CONFIG,
672 "Starting driver with initial channel: %d MHz\n",
673 curchan->center_freq);
676 mutex_lock(&sc->mutex);
678 init_channel = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
680 /* Reset SERDES registers */
681 ath9k_hw_configpcipowersave(ah, false);
684 * The basic interface to setting the hardware in a good
685 * state is ``reset''. On return the hardware is known to
686 * be powered up and with interrupts disabled. This must
687 * be followed by initialization of the appropriate bits
688 * and then setup of the interrupt mask.
690 spin_lock_bh(&sc->sc_pcu_lock);
692 atomic_set(&ah->intr_ref_cnt, -1);
694 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
697 "Unable to reset hardware; reset status %d (freq %u MHz)\n",
698 r, curchan->center_freq);
699 ah->reset_power_on = false;
702 /* Setup our intr mask. */
703 ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL |
704 ATH9K_INT_RXORN | ATH9K_INT_FATAL |
707 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
708 ah->imask |= ATH9K_INT_RXHP |
710 ATH9K_INT_BB_WATCHDOG;
712 ah->imask |= ATH9K_INT_RX;
714 ah->imask |= ATH9K_INT_GTT;
716 if (ah->caps.hw_caps & ATH9K_HW_CAP_HT)
717 ah->imask |= ATH9K_INT_CST;
721 clear_bit(SC_OP_INVALID, &sc->sc_flags);
722 sc->sc_ah->is_monitoring = false;
724 if (!ath_complete_reset(sc, false))
725 ah->reset_power_on = false;
727 if (ah->led_pin >= 0) {
728 ath9k_hw_cfg_output(ah, ah->led_pin,
729 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
730 ath9k_hw_set_gpio(ah, ah->led_pin, 0);
734 * Reset key cache to sane defaults (all entries cleared) instead of
735 * semi-random values after suspend/resume.
737 ath9k_cmn_init_crypto(sc->sc_ah);
739 spin_unlock_bh(&sc->sc_pcu_lock);
741 mutex_unlock(&sc->mutex);
743 ath9k_ps_restore(sc);
748 static void ath9k_tx(struct ieee80211_hw *hw,
749 struct ieee80211_tx_control *control,
752 struct ath_softc *sc = hw->priv;
753 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
754 struct ath_tx_control txctl;
755 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
758 if (sc->ps_enabled) {
760 * mac80211 does not set PM field for normal data frames, so we
761 * need to update that based on the current PS mode.
763 if (ieee80211_is_data(hdr->frame_control) &&
764 !ieee80211_is_nullfunc(hdr->frame_control) &&
765 !ieee80211_has_pm(hdr->frame_control)) {
767 "Add PM=1 for a TX frame while in PS mode\n");
768 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
772 if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_NETWORK_SLEEP)) {
774 * We are using PS-Poll and mac80211 can request TX while in
775 * power save mode. Need to wake up hardware for the TX to be
776 * completed and if needed, also for RX of buffered frames.
779 spin_lock_irqsave(&sc->sc_pm_lock, flags);
780 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
781 ath9k_hw_setrxabort(sc->sc_ah, 0);
782 if (ieee80211_is_pspoll(hdr->frame_control)) {
784 "Sending PS-Poll to pick a buffered frame\n");
785 sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA;
787 ath_dbg(common, PS, "Wake up to complete TX\n");
788 sc->ps_flags |= PS_WAIT_FOR_TX_ACK;
791 * The actual restore operation will happen only after
792 * the ps_flags bit is cleared. We are just dropping
793 * the ps_usecount here.
795 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
796 ath9k_ps_restore(sc);
800 * Cannot tx while the hardware is in full sleep, it first needs a full
801 * chip reset to recover from that
803 if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP)) {
804 ath_err(common, "TX while HW is in FULL_SLEEP mode\n");
808 memset(&txctl, 0, sizeof(struct ath_tx_control));
809 txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
810 txctl.sta = control->sta;
812 ath_dbg(common, XMIT, "transmitting packet, skb: %p\n", skb);
814 if (ath_tx_start(hw, skb, &txctl) != 0) {
815 ath_dbg(common, XMIT, "TX failed\n");
816 TX_STAT_INC(txctl.txq->axq_qnum, txfailed);
822 ieee80211_free_txskb(hw, skb);
825 static void ath9k_stop(struct ieee80211_hw *hw)
827 struct ath_softc *sc = hw->priv;
828 struct ath_hw *ah = sc->sc_ah;
829 struct ath_common *common = ath9k_hw_common(ah);
832 mutex_lock(&sc->mutex);
835 del_timer_sync(&sc->rx_poll_timer);
837 if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
838 ath_dbg(common, ANY, "Device not present\n");
839 mutex_unlock(&sc->mutex);
843 /* Ensure HW is awake when we try to shut it down. */
846 spin_lock_bh(&sc->sc_pcu_lock);
848 /* prevent tasklets to enable interrupts once we disable them */
849 ah->imask &= ~ATH9K_INT_GLOBAL;
851 /* make sure h/w will not generate any interrupt
852 * before setting the invalid flag. */
853 ath9k_hw_disable_interrupts(ah);
855 spin_unlock_bh(&sc->sc_pcu_lock);
857 /* we can now sync irq and kill any running tasklets, since we already
858 * disabled interrupts and not holding a spin lock */
859 synchronize_irq(sc->irq);
860 tasklet_kill(&sc->intr_tq);
861 tasklet_kill(&sc->bcon_tasklet);
863 prev_idle = sc->ps_idle;
866 spin_lock_bh(&sc->sc_pcu_lock);
868 if (ah->led_pin >= 0) {
869 ath9k_hw_set_gpio(ah, ah->led_pin, 1);
870 ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
873 ath_prepare_reset(sc);
876 dev_kfree_skb_any(sc->rx.frag);
881 ah->curchan = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
883 ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
884 ath9k_hw_phy_disable(ah);
886 ath9k_hw_configpcipowersave(ah, true);
888 spin_unlock_bh(&sc->sc_pcu_lock);
890 ath9k_ps_restore(sc);
892 set_bit(SC_OP_INVALID, &sc->sc_flags);
893 sc->ps_idle = prev_idle;
895 mutex_unlock(&sc->mutex);
897 ath_dbg(common, CONFIG, "Driver halt\n");
900 static bool ath9k_uses_beacons(int type)
903 case NL80211_IFTYPE_AP:
904 case NL80211_IFTYPE_ADHOC:
905 case NL80211_IFTYPE_MESH_POINT:
912 static void ath9k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
914 struct ath9k_vif_iter_data *iter_data = data;
917 if (iter_data->has_hw_macaddr) {
918 for (i = 0; i < ETH_ALEN; i++)
919 iter_data->mask[i] &=
920 ~(iter_data->hw_macaddr[i] ^ mac[i]);
922 memcpy(iter_data->hw_macaddr, mac, ETH_ALEN);
923 iter_data->has_hw_macaddr = true;
927 case NL80211_IFTYPE_AP:
930 case NL80211_IFTYPE_STATION:
931 iter_data->nstations++;
933 case NL80211_IFTYPE_ADHOC:
934 iter_data->nadhocs++;
936 case NL80211_IFTYPE_MESH_POINT:
937 iter_data->nmeshes++;
939 case NL80211_IFTYPE_WDS:
947 static void ath9k_sta_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
949 struct ath_softc *sc = data;
950 struct ath_vif *avp = (void *)vif->drv_priv;
952 if (vif->type != NL80211_IFTYPE_STATION)
955 if (avp->primary_sta_vif)
956 ath9k_set_assoc_state(sc, vif);
959 /* Called with sc->mutex held. */
960 void ath9k_calculate_iter_data(struct ieee80211_hw *hw,
961 struct ieee80211_vif *vif,
962 struct ath9k_vif_iter_data *iter_data)
964 struct ath_softc *sc = hw->priv;
965 struct ath_hw *ah = sc->sc_ah;
966 struct ath_common *common = ath9k_hw_common(ah);
969 * Use the hardware MAC address as reference, the hardware uses it
970 * together with the BSSID mask when matching addresses.
972 memset(iter_data, 0, sizeof(*iter_data));
973 memset(&iter_data->mask, 0xff, ETH_ALEN);
976 ath9k_vif_iter(iter_data, vif->addr, vif);
978 /* Get list of all active MAC addresses */
979 ieee80211_iterate_active_interfaces_atomic(
980 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
981 ath9k_vif_iter, iter_data);
983 memcpy(common->macaddr, iter_data->hw_macaddr, ETH_ALEN);
986 /* Called with sc->mutex held. */
987 static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
988 struct ieee80211_vif *vif)
990 struct ath_softc *sc = hw->priv;
991 struct ath_hw *ah = sc->sc_ah;
992 struct ath_common *common = ath9k_hw_common(ah);
993 struct ath9k_vif_iter_data iter_data;
994 enum nl80211_iftype old_opmode = ah->opmode;
996 ath9k_calculate_iter_data(hw, vif, &iter_data);
998 memcpy(common->bssidmask, iter_data.mask, ETH_ALEN);
999 ath_hw_setbssidmask(common);
1001 if (iter_data.naps > 0) {
1002 ath9k_hw_set_tsfadjust(ah, true);
1003 ah->opmode = NL80211_IFTYPE_AP;
1005 ath9k_hw_set_tsfadjust(ah, false);
1007 if (iter_data.nmeshes)
1008 ah->opmode = NL80211_IFTYPE_MESH_POINT;
1009 else if (iter_data.nwds)
1010 ah->opmode = NL80211_IFTYPE_AP;
1011 else if (iter_data.nadhocs)
1012 ah->opmode = NL80211_IFTYPE_ADHOC;
1014 ah->opmode = NL80211_IFTYPE_STATION;
1017 ath9k_hw_setopmode(ah);
1019 if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0)
1020 ah->imask |= ATH9K_INT_TSFOOR;
1022 ah->imask &= ~ATH9K_INT_TSFOOR;
1024 ath9k_hw_set_interrupts(ah);
1027 * If we are changing the opmode to STATION,
1028 * a beacon sync needs to be done.
1030 if (ah->opmode == NL80211_IFTYPE_STATION &&
1031 old_opmode == NL80211_IFTYPE_AP &&
1032 test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
1033 ieee80211_iterate_active_interfaces_atomic(
1034 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
1035 ath9k_sta_vif_iter, sc);
1039 static int ath9k_add_interface(struct ieee80211_hw *hw,
1040 struct ieee80211_vif *vif)
1042 struct ath_softc *sc = hw->priv;
1043 struct ath_hw *ah = sc->sc_ah;
1044 struct ath_common *common = ath9k_hw_common(ah);
1045 struct ath_vif *avp = (void *)vif->drv_priv;
1046 struct ath_node *an = &avp->mcast_node;
1048 mutex_lock(&sc->mutex);
1050 ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type);
1053 ath9k_ps_wakeup(sc);
1054 ath9k_calculate_summary_state(hw, vif);
1055 ath9k_ps_restore(sc);
1057 if (ath9k_uses_beacons(vif->type))
1058 ath9k_beacon_assign_slot(sc, vif);
1063 an->no_ps_filter = true;
1064 ath_tx_node_init(sc, an);
1066 mutex_unlock(&sc->mutex);
1070 static int ath9k_change_interface(struct ieee80211_hw *hw,
1071 struct ieee80211_vif *vif,
1072 enum nl80211_iftype new_type,
1075 struct ath_softc *sc = hw->priv;
1076 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1078 ath_dbg(common, CONFIG, "Change Interface\n");
1079 mutex_lock(&sc->mutex);
1081 if (ath9k_uses_beacons(vif->type))
1082 ath9k_beacon_remove_slot(sc, vif);
1084 vif->type = new_type;
1087 ath9k_ps_wakeup(sc);
1088 ath9k_calculate_summary_state(hw, vif);
1089 ath9k_ps_restore(sc);
1091 if (ath9k_uses_beacons(vif->type))
1092 ath9k_beacon_assign_slot(sc, vif);
1094 mutex_unlock(&sc->mutex);
1098 static void ath9k_remove_interface(struct ieee80211_hw *hw,
1099 struct ieee80211_vif *vif)
1101 struct ath_softc *sc = hw->priv;
1102 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1103 struct ath_vif *avp = (void *)vif->drv_priv;
1105 ath_dbg(common, CONFIG, "Detach Interface\n");
1107 mutex_lock(&sc->mutex);
1111 if (ath9k_uses_beacons(vif->type))
1112 ath9k_beacon_remove_slot(sc, vif);
1114 if (sc->csa_vif == vif)
1117 ath9k_ps_wakeup(sc);
1118 ath9k_calculate_summary_state(hw, NULL);
1119 ath9k_ps_restore(sc);
1121 ath_tx_node_cleanup(sc, &avp->mcast_node);
1123 mutex_unlock(&sc->mutex);
1126 static void ath9k_enable_ps(struct ath_softc *sc)
1128 struct ath_hw *ah = sc->sc_ah;
1129 struct ath_common *common = ath9k_hw_common(ah);
1131 sc->ps_enabled = true;
1132 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
1133 if ((ah->imask & ATH9K_INT_TIM_TIMER) == 0) {
1134 ah->imask |= ATH9K_INT_TIM_TIMER;
1135 ath9k_hw_set_interrupts(ah);
1137 ath9k_hw_setrxabort(ah, 1);
1139 ath_dbg(common, PS, "PowerSave enabled\n");
1142 static void ath9k_disable_ps(struct ath_softc *sc)
1144 struct ath_hw *ah = sc->sc_ah;
1145 struct ath_common *common = ath9k_hw_common(ah);
1147 sc->ps_enabled = false;
1148 ath9k_hw_setpower(ah, ATH9K_PM_AWAKE);
1149 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
1150 ath9k_hw_setrxabort(ah, 0);
1151 sc->ps_flags &= ~(PS_WAIT_FOR_BEACON |
1153 PS_WAIT_FOR_PSPOLL_DATA |
1154 PS_WAIT_FOR_TX_ACK);
1155 if (ah->imask & ATH9K_INT_TIM_TIMER) {
1156 ah->imask &= ~ATH9K_INT_TIM_TIMER;
1157 ath9k_hw_set_interrupts(ah);
1160 ath_dbg(common, PS, "PowerSave disabled\n");
1163 void ath9k_spectral_scan_trigger(struct ieee80211_hw *hw)
1165 struct ath_softc *sc = hw->priv;
1166 struct ath_hw *ah = sc->sc_ah;
1167 struct ath_common *common = ath9k_hw_common(ah);
1170 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
1171 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
1175 ath9k_ps_wakeup(sc);
1176 rxfilter = ath9k_hw_getrxfilter(ah);
1177 ath9k_hw_setrxfilter(ah, rxfilter |
1178 ATH9K_RX_FILTER_PHYRADAR |
1179 ATH9K_RX_FILTER_PHYERR);
1181 /* TODO: usually this should not be neccesary, but for some reason
1182 * (or in some mode?) the trigger must be called after the
1183 * configuration, otherwise the register will have its values reset
1184 * (on my ar9220 to value 0x01002310)
1186 ath9k_spectral_scan_config(hw, sc->spectral_mode);
1187 ath9k_hw_ops(ah)->spectral_scan_trigger(ah);
1188 ath9k_ps_restore(sc);
1191 int ath9k_spectral_scan_config(struct ieee80211_hw *hw,
1192 enum spectral_mode spectral_mode)
1194 struct ath_softc *sc = hw->priv;
1195 struct ath_hw *ah = sc->sc_ah;
1196 struct ath_common *common = ath9k_hw_common(ah);
1198 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
1199 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
1203 switch (spectral_mode) {
1204 case SPECTRAL_DISABLED:
1205 sc->spec_config.enabled = 0;
1207 case SPECTRAL_BACKGROUND:
1208 /* send endless samples.
1209 * TODO: is this really useful for "background"?
1211 sc->spec_config.endless = 1;
1212 sc->spec_config.enabled = 1;
1214 case SPECTRAL_CHANSCAN:
1215 case SPECTRAL_MANUAL:
1216 sc->spec_config.endless = 0;
1217 sc->spec_config.enabled = 1;
1223 ath9k_ps_wakeup(sc);
1224 ath9k_hw_ops(ah)->spectral_scan_config(ah, &sc->spec_config);
1225 ath9k_ps_restore(sc);
1227 sc->spectral_mode = spectral_mode;
1232 static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1234 struct ath_softc *sc = hw->priv;
1235 struct ath_hw *ah = sc->sc_ah;
1236 struct ath_common *common = ath9k_hw_common(ah);
1237 struct ieee80211_conf *conf = &hw->conf;
1238 bool reset_channel = false;
1240 ath9k_ps_wakeup(sc);
1241 mutex_lock(&sc->mutex);
1243 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
1244 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1246 ath_cancel_work(sc);
1247 ath9k_stop_btcoex(sc);
1249 ath9k_start_btcoex(sc);
1251 * The chip needs a reset to properly wake up from
1254 reset_channel = ah->chip_fullsleep;
1259 * We just prepare to enable PS. We have to wait until our AP has
1260 * ACK'd our null data frame to disable RX otherwise we'll ignore
1261 * those ACKs and end up retransmitting the same null data frames.
1262 * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode.
1264 if (changed & IEEE80211_CONF_CHANGE_PS) {
1265 unsigned long flags;
1266 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1267 if (conf->flags & IEEE80211_CONF_PS)
1268 ath9k_enable_ps(sc);
1270 ath9k_disable_ps(sc);
1271 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1274 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
1275 if (conf->flags & IEEE80211_CONF_MONITOR) {
1276 ath_dbg(common, CONFIG, "Monitor mode is enabled\n");
1277 sc->sc_ah->is_monitoring = true;
1279 ath_dbg(common, CONFIG, "Monitor mode is disabled\n");
1280 sc->sc_ah->is_monitoring = false;
1284 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
1285 if (ath_set_channel(sc, &hw->conf.chandef) < 0) {
1286 ath_err(common, "Unable to set channel\n");
1287 mutex_unlock(&sc->mutex);
1288 ath9k_ps_restore(sc);
1293 if (changed & IEEE80211_CONF_CHANGE_POWER) {
1294 ath_dbg(common, CONFIG, "Set power: %d\n", conf->power_level);
1295 sc->config.txpowlimit = 2 * conf->power_level;
1296 ath9k_cmn_update_txpow(ah, sc->curtxpow,
1297 sc->config.txpowlimit, &sc->curtxpow);
1300 mutex_unlock(&sc->mutex);
1301 ath9k_ps_restore(sc);
1306 #define SUPPORTED_FILTERS \
1307 (FIF_PROMISC_IN_BSS | \
1312 FIF_BCN_PRBRESP_PROMISC | \
1316 /* FIXME: sc->sc_full_reset ? */
1317 static void ath9k_configure_filter(struct ieee80211_hw *hw,
1318 unsigned int changed_flags,
1319 unsigned int *total_flags,
1322 struct ath_softc *sc = hw->priv;
1325 changed_flags &= SUPPORTED_FILTERS;
1326 *total_flags &= SUPPORTED_FILTERS;
1328 sc->rx.rxfilter = *total_flags;
1329 ath9k_ps_wakeup(sc);
1330 rfilt = ath_calcrxfilter(sc);
1331 ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
1332 ath9k_ps_restore(sc);
1334 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, "Set HW RX filter: 0x%x\n",
1338 static int ath9k_sta_add(struct ieee80211_hw *hw,
1339 struct ieee80211_vif *vif,
1340 struct ieee80211_sta *sta)
1342 struct ath_softc *sc = hw->priv;
1343 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1344 struct ath_node *an = (struct ath_node *) sta->drv_priv;
1345 struct ieee80211_key_conf ps_key = { };
1348 ath_node_attach(sc, sta, vif);
1350 if (vif->type != NL80211_IFTYPE_AP &&
1351 vif->type != NL80211_IFTYPE_AP_VLAN)
1354 key = ath_key_config(common, vif, sta, &ps_key);
1361 static void ath9k_del_ps_key(struct ath_softc *sc,
1362 struct ieee80211_vif *vif,
1363 struct ieee80211_sta *sta)
1365 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1366 struct ath_node *an = (struct ath_node *) sta->drv_priv;
1367 struct ieee80211_key_conf ps_key = { .hw_key_idx = an->ps_key };
1372 ath_key_delete(common, &ps_key);
1376 static int ath9k_sta_remove(struct ieee80211_hw *hw,
1377 struct ieee80211_vif *vif,
1378 struct ieee80211_sta *sta)
1380 struct ath_softc *sc = hw->priv;
1382 ath9k_del_ps_key(sc, vif, sta);
1383 ath_node_detach(sc, sta);
1388 static void ath9k_sta_notify(struct ieee80211_hw *hw,
1389 struct ieee80211_vif *vif,
1390 enum sta_notify_cmd cmd,
1391 struct ieee80211_sta *sta)
1393 struct ath_softc *sc = hw->priv;
1394 struct ath_node *an = (struct ath_node *) sta->drv_priv;
1397 case STA_NOTIFY_SLEEP:
1398 an->sleeping = true;
1399 ath_tx_aggr_sleep(sta, sc, an);
1401 case STA_NOTIFY_AWAKE:
1402 an->sleeping = false;
1403 ath_tx_aggr_wakeup(sc, an);
1408 static int ath9k_conf_tx(struct ieee80211_hw *hw,
1409 struct ieee80211_vif *vif, u16 queue,
1410 const struct ieee80211_tx_queue_params *params)
1412 struct ath_softc *sc = hw->priv;
1413 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1414 struct ath_txq *txq;
1415 struct ath9k_tx_queue_info qi;
1418 if (queue >= IEEE80211_NUM_ACS)
1421 txq = sc->tx.txq_map[queue];
1423 ath9k_ps_wakeup(sc);
1424 mutex_lock(&sc->mutex);
1426 memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
1428 qi.tqi_aifs = params->aifs;
1429 qi.tqi_cwmin = params->cw_min;
1430 qi.tqi_cwmax = params->cw_max;
1431 qi.tqi_burstTime = params->txop * 32;
1433 ath_dbg(common, CONFIG,
1434 "Configure tx [queue/halq] [%d/%d], aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
1435 queue, txq->axq_qnum, params->aifs, params->cw_min,
1436 params->cw_max, params->txop);
1438 ath_update_max_aggr_framelen(sc, queue, qi.tqi_burstTime);
1439 ret = ath_txq_update(sc, txq->axq_qnum, &qi);
1441 ath_err(common, "TXQ Update failed\n");
1443 mutex_unlock(&sc->mutex);
1444 ath9k_ps_restore(sc);
1449 static int ath9k_set_key(struct ieee80211_hw *hw,
1450 enum set_key_cmd cmd,
1451 struct ieee80211_vif *vif,
1452 struct ieee80211_sta *sta,
1453 struct ieee80211_key_conf *key)
1455 struct ath_softc *sc = hw->priv;
1456 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1459 if (ath9k_modparam_nohwcrypt)
1462 if ((vif->type == NL80211_IFTYPE_ADHOC ||
1463 vif->type == NL80211_IFTYPE_MESH_POINT) &&
1464 (key->cipher == WLAN_CIPHER_SUITE_TKIP ||
1465 key->cipher == WLAN_CIPHER_SUITE_CCMP) &&
1466 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
1468 * For now, disable hw crypto for the RSN IBSS group keys. This
1469 * could be optimized in the future to use a modified key cache
1470 * design to support per-STA RX GTK, but until that gets
1471 * implemented, use of software crypto for group addressed
1472 * frames is a acceptable to allow RSN IBSS to be used.
1477 mutex_lock(&sc->mutex);
1478 ath9k_ps_wakeup(sc);
1479 ath_dbg(common, CONFIG, "Set HW Key\n");
1484 ath9k_del_ps_key(sc, vif, sta);
1486 ret = ath_key_config(common, vif, sta, key);
1488 key->hw_key_idx = ret;
1489 /* push IV and Michael MIC generation to stack */
1490 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1491 if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
1492 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1493 if (sc->sc_ah->sw_mgmt_crypto &&
1494 key->cipher == WLAN_CIPHER_SUITE_CCMP)
1495 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
1500 ath_key_delete(common, key);
1506 ath9k_ps_restore(sc);
1507 mutex_unlock(&sc->mutex);
1512 static void ath9k_set_assoc_state(struct ath_softc *sc,
1513 struct ieee80211_vif *vif)
1515 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1516 struct ath_vif *avp = (void *)vif->drv_priv;
1517 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1518 unsigned long flags;
1520 set_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags);
1521 avp->primary_sta_vif = true;
1524 * Set the AID, BSSID and do beacon-sync only when
1525 * the HW opmode is STATION.
1527 * But the primary bit is set above in any case.
1529 if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION)
1532 memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
1533 common->curaid = bss_conf->aid;
1534 ath9k_hw_write_associd(sc->sc_ah);
1536 sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
1537 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
1539 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1540 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
1541 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1543 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
1544 ath9k_mci_update_wlan_channels(sc, false);
1546 ath_dbg(common, CONFIG,
1547 "Primary Station interface: %pM, BSSID: %pM\n",
1548 vif->addr, common->curbssid);
1551 static void ath9k_bss_assoc_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
1553 struct ath_softc *sc = data;
1554 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1556 if (test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags))
1559 if (bss_conf->assoc)
1560 ath9k_set_assoc_state(sc, vif);
1563 static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
1564 struct ieee80211_vif *vif,
1565 struct ieee80211_bss_conf *bss_conf,
1569 (BSS_CHANGED_ASSOC | \
1570 BSS_CHANGED_IBSS | \
1571 BSS_CHANGED_BEACON_ENABLED)
1573 struct ath_softc *sc = hw->priv;
1574 struct ath_hw *ah = sc->sc_ah;
1575 struct ath_common *common = ath9k_hw_common(ah);
1576 struct ath_vif *avp = (void *)vif->drv_priv;
1579 ath9k_ps_wakeup(sc);
1580 mutex_lock(&sc->mutex);
1582 if (changed & BSS_CHANGED_ASSOC) {
1583 ath_dbg(common, CONFIG, "BSSID %pM Changed ASSOC %d\n",
1584 bss_conf->bssid, bss_conf->assoc);
1586 if (avp->primary_sta_vif && !bss_conf->assoc) {
1587 clear_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags);
1588 avp->primary_sta_vif = false;
1590 if (ah->opmode == NL80211_IFTYPE_STATION)
1591 clear_bit(SC_OP_BEACONS, &sc->sc_flags);
1594 ieee80211_iterate_active_interfaces_atomic(
1595 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
1596 ath9k_bss_assoc_iter, sc);
1598 if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags) &&
1599 ah->opmode == NL80211_IFTYPE_STATION) {
1600 memset(common->curbssid, 0, ETH_ALEN);
1602 ath9k_hw_write_associd(sc->sc_ah);
1603 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
1604 ath9k_mci_update_wlan_channels(sc, true);
1608 if (changed & BSS_CHANGED_IBSS) {
1609 memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
1610 common->curaid = bss_conf->aid;
1611 ath9k_hw_write_associd(sc->sc_ah);
1614 if ((changed & BSS_CHANGED_BEACON_ENABLED) ||
1615 (changed & BSS_CHANGED_BEACON_INT)) {
1616 if (ah->opmode == NL80211_IFTYPE_AP &&
1617 bss_conf->enable_beacon)
1618 ath9k_set_tsfadjust(sc, vif);
1619 if (ath9k_allow_beacon_config(sc, vif))
1620 ath9k_beacon_config(sc, vif, changed);
1623 if (changed & BSS_CHANGED_ERP_SLOT) {
1624 if (bss_conf->use_short_slot)
1628 if (vif->type == NL80211_IFTYPE_AP) {
1630 * Defer update, so that connected stations can adjust
1631 * their settings at the same time.
1632 * See beacon.c for more details
1634 sc->beacon.slottime = slottime;
1635 sc->beacon.updateslot = UPDATE;
1637 ah->slottime = slottime;
1638 ath9k_hw_init_global_settings(ah);
1642 if (changed & CHECK_ANI)
1645 mutex_unlock(&sc->mutex);
1646 ath9k_ps_restore(sc);
1651 static u64 ath9k_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1653 struct ath_softc *sc = hw->priv;
1656 mutex_lock(&sc->mutex);
1657 ath9k_ps_wakeup(sc);
1658 tsf = ath9k_hw_gettsf64(sc->sc_ah);
1659 ath9k_ps_restore(sc);
1660 mutex_unlock(&sc->mutex);
1665 static void ath9k_set_tsf(struct ieee80211_hw *hw,
1666 struct ieee80211_vif *vif,
1669 struct ath_softc *sc = hw->priv;
1671 mutex_lock(&sc->mutex);
1672 ath9k_ps_wakeup(sc);
1673 ath9k_hw_settsf64(sc->sc_ah, tsf);
1674 ath9k_ps_restore(sc);
1675 mutex_unlock(&sc->mutex);
1678 static void ath9k_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1680 struct ath_softc *sc = hw->priv;
1682 mutex_lock(&sc->mutex);
1684 ath9k_ps_wakeup(sc);
1685 ath9k_hw_reset_tsf(sc->sc_ah);
1686 ath9k_ps_restore(sc);
1688 mutex_unlock(&sc->mutex);
1691 static int ath9k_ampdu_action(struct ieee80211_hw *hw,
1692 struct ieee80211_vif *vif,
1693 enum ieee80211_ampdu_mlme_action action,
1694 struct ieee80211_sta *sta,
1695 u16 tid, u16 *ssn, u8 buf_size)
1697 struct ath_softc *sc = hw->priv;
1701 mutex_lock(&sc->mutex);
1704 case IEEE80211_AMPDU_RX_START:
1706 case IEEE80211_AMPDU_RX_STOP:
1708 case IEEE80211_AMPDU_TX_START:
1709 ath9k_ps_wakeup(sc);
1710 ret = ath_tx_aggr_start(sc, sta, tid, ssn);
1712 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1713 ath9k_ps_restore(sc);
1715 case IEEE80211_AMPDU_TX_STOP_FLUSH:
1716 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
1718 case IEEE80211_AMPDU_TX_STOP_CONT:
1719 ath9k_ps_wakeup(sc);
1720 ath_tx_aggr_stop(sc, sta, tid);
1722 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1723 ath9k_ps_restore(sc);
1725 case IEEE80211_AMPDU_TX_OPERATIONAL:
1726 ath9k_ps_wakeup(sc);
1727 ath_tx_aggr_resume(sc, sta, tid);
1728 ath9k_ps_restore(sc);
1731 ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n");
1734 mutex_unlock(&sc->mutex);
1739 static int ath9k_get_survey(struct ieee80211_hw *hw, int idx,
1740 struct survey_info *survey)
1742 struct ath_softc *sc = hw->priv;
1743 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1744 struct ieee80211_supported_band *sband;
1745 struct ieee80211_channel *chan;
1746 unsigned long flags;
1749 spin_lock_irqsave(&common->cc_lock, flags);
1751 ath_update_survey_stats(sc);
1753 sband = hw->wiphy->bands[IEEE80211_BAND_2GHZ];
1754 if (sband && idx >= sband->n_channels) {
1755 idx -= sband->n_channels;
1760 sband = hw->wiphy->bands[IEEE80211_BAND_5GHZ];
1762 if (!sband || idx >= sband->n_channels) {
1763 spin_unlock_irqrestore(&common->cc_lock, flags);
1767 chan = &sband->channels[idx];
1768 pos = chan->hw_value;
1769 memcpy(survey, &sc->survey[pos], sizeof(*survey));
1770 survey->channel = chan;
1771 spin_unlock_irqrestore(&common->cc_lock, flags);
1776 static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
1778 struct ath_softc *sc = hw->priv;
1779 struct ath_hw *ah = sc->sc_ah;
1781 mutex_lock(&sc->mutex);
1782 ah->coverage_class = coverage_class;
1784 ath9k_ps_wakeup(sc);
1785 ath9k_hw_init_global_settings(ah);
1786 ath9k_ps_restore(sc);
1788 mutex_unlock(&sc->mutex);
1791 static void ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
1793 struct ath_softc *sc = hw->priv;
1794 struct ath_hw *ah = sc->sc_ah;
1795 struct ath_common *common = ath9k_hw_common(ah);
1796 int timeout = 200; /* ms */
1800 mutex_lock(&sc->mutex);
1801 cancel_delayed_work_sync(&sc->tx_complete_work);
1803 if (ah->ah_flags & AH_UNPLUGGED) {
1804 ath_dbg(common, ANY, "Device has been unplugged!\n");
1805 mutex_unlock(&sc->mutex);
1809 if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
1810 ath_dbg(common, ANY, "Device not present\n");
1811 mutex_unlock(&sc->mutex);
1815 for (j = 0; j < timeout; j++) {
1819 usleep_range(1000, 2000);
1821 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1822 if (!ATH_TXQ_SETUP(sc, i))
1825 npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
1836 ath9k_ps_wakeup(sc);
1837 spin_lock_bh(&sc->sc_pcu_lock);
1838 drain_txq = ath_drain_all_txq(sc);
1839 spin_unlock_bh(&sc->sc_pcu_lock);
1844 ath9k_ps_restore(sc);
1845 ieee80211_wake_queues(hw);
1848 ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
1849 mutex_unlock(&sc->mutex);
1852 static bool ath9k_tx_frames_pending(struct ieee80211_hw *hw)
1854 struct ath_softc *sc = hw->priv;
1857 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1858 if (!ATH_TXQ_SETUP(sc, i))
1861 if (ath9k_has_pending_frames(sc, &sc->tx.txq[i]))
1867 static int ath9k_tx_last_beacon(struct ieee80211_hw *hw)
1869 struct ath_softc *sc = hw->priv;
1870 struct ath_hw *ah = sc->sc_ah;
1871 struct ieee80211_vif *vif;
1872 struct ath_vif *avp;
1874 struct ath_tx_status ts;
1875 bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
1878 vif = sc->beacon.bslot[0];
1882 if (!vif->bss_conf.enable_beacon)
1885 avp = (void *)vif->drv_priv;
1887 if (!sc->beacon.tx_processed && !edma) {
1888 tasklet_disable(&sc->bcon_tasklet);
1891 if (!bf || !bf->bf_mpdu)
1894 status = ath9k_hw_txprocdesc(ah, bf->bf_desc, &ts);
1895 if (status == -EINPROGRESS)
1898 sc->beacon.tx_processed = true;
1899 sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
1902 tasklet_enable(&sc->bcon_tasklet);
1905 return sc->beacon.tx_last;
1908 static int ath9k_get_stats(struct ieee80211_hw *hw,
1909 struct ieee80211_low_level_stats *stats)
1911 struct ath_softc *sc = hw->priv;
1912 struct ath_hw *ah = sc->sc_ah;
1913 struct ath9k_mib_stats *mib_stats = &ah->ah_mibStats;
1915 stats->dot11ACKFailureCount = mib_stats->ackrcv_bad;
1916 stats->dot11RTSFailureCount = mib_stats->rts_bad;
1917 stats->dot11FCSErrorCount = mib_stats->fcs_bad;
1918 stats->dot11RTSSuccessCount = mib_stats->rts_good;
1922 static u32 fill_chainmask(u32 cap, u32 new)
1927 for (i = 0; cap && new; i++, cap >>= 1) {
1928 if (!(cap & BIT(0)))
1940 static bool validate_antenna_mask(struct ath_hw *ah, u32 val)
1942 if (AR_SREV_9300_20_OR_LATER(ah))
1945 switch (val & 0x7) {
1951 return (ah->caps.rx_chainmask == 1);
1957 static int ath9k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
1959 struct ath_softc *sc = hw->priv;
1960 struct ath_hw *ah = sc->sc_ah;
1962 if (ah->caps.rx_chainmask != 1)
1965 if (!validate_antenna_mask(ah, rx_ant) || !tx_ant)
1968 sc->ant_rx = rx_ant;
1969 sc->ant_tx = tx_ant;
1971 if (ah->caps.rx_chainmask == 1)
1974 /* AR9100 runs into calibration issues if not all rx chains are enabled */
1975 if (AR_SREV_9100(ah))
1976 ah->rxchainmask = 0x7;
1978 ah->rxchainmask = fill_chainmask(ah->caps.rx_chainmask, rx_ant);
1980 ah->txchainmask = fill_chainmask(ah->caps.tx_chainmask, tx_ant);
1981 ath9k_reload_chainmask_settings(sc);
1986 static int ath9k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
1988 struct ath_softc *sc = hw->priv;
1990 *tx_ant = sc->ant_tx;
1991 *rx_ant = sc->ant_rx;
1995 #ifdef CONFIG_PM_SLEEP
1997 static void ath9k_wow_map_triggers(struct ath_softc *sc,
1998 struct cfg80211_wowlan *wowlan,
2001 if (wowlan->disconnect)
2002 *wow_triggers |= AH_WOW_LINK_CHANGE |
2004 if (wowlan->magic_pkt)
2005 *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN;
2007 if (wowlan->n_patterns)
2008 *wow_triggers |= AH_WOW_USER_PATTERN_EN;
2010 sc->wow_enabled = *wow_triggers;
2014 static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc)
2016 struct ath_hw *ah = sc->sc_ah;
2017 struct ath_common *common = ath9k_hw_common(ah);
2018 int pattern_count = 0;
2020 u8 dis_deauth_pattern[MAX_PATTERN_SIZE];
2021 u8 dis_deauth_mask[MAX_PATTERN_SIZE];
2023 memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE);
2024 memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE);
2027 * Create Dissassociate / Deauthenticate packet filter
2029 * 2 bytes 2 byte 6 bytes 6 bytes 6 bytes
2030 * +--------------+----------+---------+--------+--------+----
2031 * + Frame Control+ Duration + DA + SA + BSSID +
2032 * +--------------+----------+---------+--------+--------+----
2034 * The above is the management frame format for disassociate/
2035 * deauthenticate pattern, from this we need to match the first byte
2036 * of 'Frame Control' and DA, SA, and BSSID fields
2037 * (skipping 2nd byte of FC and Duration feild.
2039 * Disassociate pattern
2040 * --------------------
2041 * Frame control = 00 00 1010
2042 * DA, SA, BSSID = x:x:x:x:x:x
2043 * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x
2044 * | x:x:x:x:x:x -- 22 bytes
2046 * Deauthenticate pattern
2047 * ----------------------
2048 * Frame control = 00 00 1100
2049 * DA, SA, BSSID = x:x:x:x:x:x
2050 * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x
2051 * | x:x:x:x:x:x -- 22 bytes
2054 /* Create Disassociate Pattern first */
2058 /* Fill out the mask with all FF's */
2060 for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++)
2061 dis_deauth_mask[i] = 0xff;
2063 /* copy the first byte of frame control field */
2064 dis_deauth_pattern[byte_cnt] = 0xa0;
2067 /* skip 2nd byte of frame control and Duration field */
2071 * need not match the destination mac address, it can be a broadcast
2072 * mac address or an unicast to this station
2076 /* copy the source mac address */
2077 memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
2081 /* copy the bssid, its same as the source mac address */
2083 memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
2085 /* Create Disassociate pattern mask */
2087 dis_deauth_mask[0] = 0xfe;
2088 dis_deauth_mask[1] = 0x03;
2089 dis_deauth_mask[2] = 0xc0;
2091 ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n");
2093 ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
2094 pattern_count, byte_cnt);
2098 * for de-authenticate pattern, only the first byte of the frame
2099 * control field gets changed from 0xA0 to 0xC0
2101 dis_deauth_pattern[0] = 0xC0;
2103 ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
2104 pattern_count, byte_cnt);
2108 static void ath9k_wow_add_pattern(struct ath_softc *sc,
2109 struct cfg80211_wowlan *wowlan)
2111 struct ath_hw *ah = sc->sc_ah;
2112 struct ath9k_wow_pattern *wow_pattern = NULL;
2113 struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
2117 if (!wowlan->n_patterns)
2121 * Add the new user configured patterns
2123 for (i = 0; i < wowlan->n_patterns; i++) {
2125 wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL);
2131 * TODO: convert the generic user space pattern to
2132 * appropriate chip specific/802.11 pattern.
2135 mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
2136 memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE);
2137 memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE);
2138 memcpy(wow_pattern->pattern_bytes, patterns[i].pattern,
2139 patterns[i].pattern_len);
2140 memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len);
2141 wow_pattern->pattern_len = patterns[i].pattern_len;
2144 * just need to take care of deauth and disssoc pattern,
2145 * make sure we don't overwrite them.
2148 ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes,
2149 wow_pattern->mask_bytes,
2151 wow_pattern->pattern_len);
2158 static int ath9k_suspend(struct ieee80211_hw *hw,
2159 struct cfg80211_wowlan *wowlan)
2161 struct ath_softc *sc = hw->priv;
2162 struct ath_hw *ah = sc->sc_ah;
2163 struct ath_common *common = ath9k_hw_common(ah);
2164 u32 wow_triggers_enabled = 0;
2167 mutex_lock(&sc->mutex);
2169 ath_cancel_work(sc);
2171 del_timer_sync(&sc->rx_poll_timer);
2173 if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
2174 ath_dbg(common, ANY, "Device not present\n");
2179 if (WARN_ON(!wowlan)) {
2180 ath_dbg(common, WOW, "None of the WoW triggers enabled\n");
2185 if (!device_can_wakeup(sc->dev)) {
2186 ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n");
2192 * none of the sta vifs are associated
2193 * and we are not currently handling multivif
2194 * cases, for instance we have to seperately
2195 * configure 'keep alive frame' for each
2199 if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
2200 ath_dbg(common, WOW, "None of the STA vifs are associated\n");
2205 if (sc->nvifs > 1) {
2206 ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
2211 ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
2213 ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n",
2214 wow_triggers_enabled);
2216 ath9k_ps_wakeup(sc);
2218 ath9k_stop_btcoex(sc);
2221 * Enable wake up on recieving disassoc/deauth
2224 ath9k_wow_add_disassoc_deauth_pattern(sc);
2226 if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN)
2227 ath9k_wow_add_pattern(sc, wowlan);
2229 spin_lock_bh(&sc->sc_pcu_lock);
2231 * To avoid false wake, we enable beacon miss interrupt only
2232 * when we go to sleep. We save the current interrupt mask
2233 * so we can restore it after the system wakes up
2235 sc->wow_intr_before_sleep = ah->imask;
2236 ah->imask &= ~ATH9K_INT_GLOBAL;
2237 ath9k_hw_disable_interrupts(ah);
2238 ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL;
2239 ath9k_hw_set_interrupts(ah);
2240 ath9k_hw_enable_interrupts(ah);
2242 spin_unlock_bh(&sc->sc_pcu_lock);
2245 * we can now sync irq and kill any running tasklets, since we already
2246 * disabled interrupts and not holding a spin lock
2248 synchronize_irq(sc->irq);
2249 tasklet_kill(&sc->intr_tq);
2251 ath9k_hw_wow_enable(ah, wow_triggers_enabled);
2253 ath9k_ps_restore(sc);
2254 ath_dbg(common, ANY, "WoW enabled in ath9k\n");
2255 atomic_inc(&sc->wow_sleep_proc_intr);
2258 mutex_unlock(&sc->mutex);
2262 static int ath9k_resume(struct ieee80211_hw *hw)
2264 struct ath_softc *sc = hw->priv;
2265 struct ath_hw *ah = sc->sc_ah;
2266 struct ath_common *common = ath9k_hw_common(ah);
2269 mutex_lock(&sc->mutex);
2271 ath9k_ps_wakeup(sc);
2273 spin_lock_bh(&sc->sc_pcu_lock);
2275 ath9k_hw_disable_interrupts(ah);
2276 ah->imask = sc->wow_intr_before_sleep;
2277 ath9k_hw_set_interrupts(ah);
2278 ath9k_hw_enable_interrupts(ah);
2280 spin_unlock_bh(&sc->sc_pcu_lock);
2282 wow_status = ath9k_hw_wow_wakeup(ah);
2284 if (atomic_read(&sc->wow_got_bmiss_intr) == 0) {
2286 * some devices may not pick beacon miss
2287 * as the reason they woke up so we add
2288 * that here for that shortcoming.
2290 wow_status |= AH_WOW_BEACON_MISS;
2291 atomic_dec(&sc->wow_got_bmiss_intr);
2292 ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n");
2295 atomic_dec(&sc->wow_sleep_proc_intr);
2298 ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n",
2299 ath9k_hw_wow_event_to_string(wow_status), wow_status);
2302 ath_restart_work(sc);
2303 ath9k_start_btcoex(sc);
2305 ath9k_ps_restore(sc);
2306 mutex_unlock(&sc->mutex);
2311 static void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
2313 struct ath_softc *sc = hw->priv;
2315 mutex_lock(&sc->mutex);
2316 device_init_wakeup(sc->dev, 1);
2317 device_set_wakeup_enable(sc->dev, enabled);
2318 mutex_unlock(&sc->mutex);
2322 static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
2324 struct ath_softc *sc = hw->priv;
2325 set_bit(SC_OP_SCANNING, &sc->sc_flags);
2328 static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
2330 struct ath_softc *sc = hw->priv;
2331 clear_bit(SC_OP_SCANNING, &sc->sc_flags);
2334 static void ath9k_channel_switch_beacon(struct ieee80211_hw *hw,
2335 struct ieee80211_vif *vif,
2336 struct cfg80211_chan_def *chandef)
2338 struct ath_softc *sc = hw->priv;
2340 /* mac80211 does not support CSA in multi-if cases (yet) */
2341 if (WARN_ON(sc->csa_vif))
2347 struct ieee80211_ops ath9k_ops = {
2349 .start = ath9k_start,
2351 .add_interface = ath9k_add_interface,
2352 .change_interface = ath9k_change_interface,
2353 .remove_interface = ath9k_remove_interface,
2354 .config = ath9k_config,
2355 .configure_filter = ath9k_configure_filter,
2356 .sta_add = ath9k_sta_add,
2357 .sta_remove = ath9k_sta_remove,
2358 .sta_notify = ath9k_sta_notify,
2359 .conf_tx = ath9k_conf_tx,
2360 .bss_info_changed = ath9k_bss_info_changed,
2361 .set_key = ath9k_set_key,
2362 .get_tsf = ath9k_get_tsf,
2363 .set_tsf = ath9k_set_tsf,
2364 .reset_tsf = ath9k_reset_tsf,
2365 .ampdu_action = ath9k_ampdu_action,
2366 .get_survey = ath9k_get_survey,
2367 .rfkill_poll = ath9k_rfkill_poll_state,
2368 .set_coverage_class = ath9k_set_coverage_class,
2369 .flush = ath9k_flush,
2370 .tx_frames_pending = ath9k_tx_frames_pending,
2371 .tx_last_beacon = ath9k_tx_last_beacon,
2372 .release_buffered_frames = ath9k_release_buffered_frames,
2373 .get_stats = ath9k_get_stats,
2374 .set_antenna = ath9k_set_antenna,
2375 .get_antenna = ath9k_get_antenna,
2377 #ifdef CONFIG_PM_SLEEP
2378 .suspend = ath9k_suspend,
2379 .resume = ath9k_resume,
2380 .set_wakeup = ath9k_set_wakeup,
2383 #ifdef CONFIG_ATH9K_DEBUGFS
2384 .get_et_sset_count = ath9k_get_et_sset_count,
2385 .get_et_stats = ath9k_get_et_stats,
2386 .get_et_strings = ath9k_get_et_strings,
2389 #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS)
2390 .sta_add_debugfs = ath9k_sta_add_debugfs,
2392 .sw_scan_start = ath9k_sw_scan_start,
2393 .sw_scan_complete = ath9k_sw_scan_complete,
2394 .channel_switch_beacon = ath9k_channel_switch_beacon,