Lines Matching refs:sc
60 static bool ath9k_has_pending_frames(struct ath_softc *sc, struct ath_txq *txq,
78 acq = &sc->cur_chan->acq[txq->mac80211_qnum];
87 static bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode)
92 spin_lock_irqsave(&sc->sc_pm_lock, flags);
93 ret = ath9k_hw_setpower(sc->sc_ah, mode);
94 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
101 struct ath_softc *sc = from_timer(sc, t, sleep_timer);
102 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
110 ath9k_hw_setrxabort(sc->sc_ah, 1);
111 ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
113 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
116 void ath9k_ps_wakeup(struct ath_softc *sc)
118 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
122 spin_lock_irqsave(&sc->sc_pm_lock, flags);
123 if (++sc->ps_usecount != 1)
126 del_timer_sync(&sc->sleep_timer);
127 power_mode = sc->sc_ah->power_mode;
128 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
144 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
147 void ath9k_ps_restore(struct ath_softc *sc)
149 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
153 spin_lock_irqsave(&sc->sc_pm_lock, flags);
154 if (--sc->ps_usecount != 0)
157 if (sc->ps_idle) {
158 mod_timer(&sc->sleep_timer, jiffies + HZ / 10);
162 if (sc->ps_enabled &&
163 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
169 if (ath9k_hw_btcoex_is_enabled(sc->sc_ah))
170 ath9k_btcoex_stop_gen_timer(sc);
179 ath9k_hw_setpower(sc->sc_ah, mode);
182 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
185 static void __ath_cancel_work(struct ath_softc *sc)
187 cancel_work_sync(&sc->paprd_work);
188 cancel_delayed_work_sync(&sc->hw_check_work);
189 cancel_delayed_work_sync(&sc->hw_pll_work);
192 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
193 cancel_work_sync(&sc->mci_work);
197 void ath_cancel_work(struct ath_softc *sc)
199 __ath_cancel_work(sc);
200 cancel_work_sync(&sc->hw_reset_work);
203 void ath_restart_work(struct ath_softc *sc)
205 ieee80211_queue_delayed_work(sc->hw, &sc->hw_check_work,
208 if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah))
209 ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
212 ath_start_ani(sc);
215 static bool ath_prepare_reset(struct ath_softc *sc)
217 struct ath_hw *ah = sc->sc_ah;
220 ieee80211_stop_queues(sc->hw);
221 ath_stop_ani(sc);
225 ret &= ath_stoprecv(sc);
226 ret &= ath_drain_all_txq(sc);
228 ret &= ath_drain_all_txq(sc);
229 ret &= ath_stoprecv(sc);
235 static bool ath_complete_reset(struct ath_softc *sc, bool start)
237 struct ath_hw *ah = sc->sc_ah;
241 ath9k_calculate_summary_state(sc, sc->cur_chan);
242 ath_startrecv(sc);
243 ath9k_cmn_update_txpow(ah, sc->cur_chan->cur_txpower,
244 sc->cur_chan->txpower,
245 &sc->cur_chan->cur_txpower);
248 if (!sc->cur_chan->offchannel && start) {
250 if (sc->cur_chan->tsf_val) {
253 offset = ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts,
255 ath9k_hw_settsf64(ah, sc->cur_chan->tsf_val + offset);
264 spin_lock_irqsave(&sc->sc_pm_lock, flags);
265 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
266 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
268 ath9k_set_beacon(sc);
271 ath_restart_work(sc);
272 ath_txq_schedule_all(sc);
275 sc->gtt_cnt = 0;
279 ieee80211_wake_queues(sc->hw);
280 ath9k_p2p_ps_timer(sc);
285 static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan)
287 struct ath_hw *ah = sc->sc_ah;
293 __ath_cancel_work(sc);
295 disable_irq(sc->irq);
296 tasklet_disable(&sc->intr_tq);
297 tasklet_disable(&sc->bcon_tasklet);
298 spin_lock_bh(&sc->sc_pcu_lock);
300 if (!sc->cur_chan->offchannel) {
302 caldata = &sc->cur_chan->caldata;
312 hchan = ath9k_cmn_get_channel(sc->hw, ah, &sc->cur_chan->chandef);
315 if (!ath_prepare_reset(sc))
321 spin_lock_bh(&sc->chan_lock);
322 sc->cur_chandef = sc->cur_chan->chandef;
323 spin_unlock_bh(&sc->chan_lock);
334 ath9k_queue_reset(sc, RESET_TYPE_BB_HANG);
339 if (ath9k_hw_mci_is_enabled(sc->sc_ah) &&
340 sc->cur_chan->offchannel)
341 ath9k_mci_set_txpower(sc, true, false);
343 if (!ath_complete_reset(sc, true))
347 enable_irq(sc->irq);
348 spin_unlock_bh(&sc->sc_pcu_lock);
349 tasklet_enable(&sc->bcon_tasklet);
350 tasklet_enable(&sc->intr_tq);
355 static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
361 an->sc = sc;
366 ath_tx_node_init(sc, an);
368 ath_dynack_node_init(sc->sc_ah, an);
371 static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
374 ath_tx_node_cleanup(sc, an);
376 ath_dynack_node_deinit(sc->sc_ah, an);
381 struct ath_softc *sc = from_tasklet(sc, t, intr_tq);
382 struct ath_hw *ah = sc->sc_ah;
389 spin_lock_irqsave(&sc->intr_lock, flags);
390 status = sc->intrstatus;
391 sc->intrstatus = 0;
392 spin_unlock_irqrestore(&sc->intr_lock, flags);
394 ath9k_ps_wakeup(sc);
395 spin_lock(&sc->sc_pcu_lock);
399 ath9k_queue_reset(sc, type);
413 ath9k_queue_reset(sc, type);
422 sc->gtt_cnt++;
424 if ((sc->gtt_cnt >= MAX_GTT_CNT) && !ath9k_hw_check_alive(ah)) {
426 ath9k_queue_reset(sc, type);
433 spin_lock_irqsave(&sc->sc_pm_lock, flags);
434 if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
440 sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC;
442 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
454 ath_rx_tasklet(sc, 0, true);
456 ath_rx_tasklet(sc, 0, false);
467 sc->gtt_cnt = 0;
469 ath_tx_edma_tasklet(sc);
471 ath_tx_tasklet(sc);
474 wake_up(&sc->tx_wait);
478 ath_gen_timer_isr(sc->sc_ah);
480 ath9k_btcoex_handle_interrupt(sc, status);
485 spin_unlock(&sc->sc_pcu_lock);
486 ath9k_ps_restore(sc);
507 struct ath_softc *sc = dev;
508 struct ath_hw *ah = sc->sc_ah;
533 ath9k_debug_sync_cause(sc, sync_cause);
537 ath9k_hw_kill_interrupts(sc->sc_ah);
549 spin_lock(&sc->intr_lock);
550 sc->intrstatus |= status;
551 spin_unlock(&sc->intr_lock);
568 tasklet_schedule(&sc->bcon_tasklet);
580 if (ATH_DBG_WARN_ON_ONCE(sc->ps_idle))
584 ath9k_setpower(sc, ATH9K_PM_AWAKE);
585 spin_lock(&sc->sc_pm_lock);
586 ath9k_hw_setrxabort(sc->sc_ah, 0);
587 sc->ps_flags |= PS_WAIT_FOR_BEACON;
588 spin_unlock(&sc->sc_pm_lock);
593 ath_debug_stat_interrupt(sc, status);
598 tasklet_schedule(&sc->intr_tq);
610 int ath_reset(struct ath_softc *sc, struct ath9k_channel *hchan)
612 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
615 ath9k_hw_kill_interrupts(sc->sc_ah);
618 ath9k_ps_wakeup(sc);
619 r = ath_reset_internal(sc, hchan);
620 ath9k_ps_restore(sc);
630 void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type)
632 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
634 RESET_STAT_INC(sc, type);
636 ath9k_hw_kill_interrupts(sc->sc_ah);
638 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
643 struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work);
645 ath9k_ps_wakeup(sc);
646 ath_reset_internal(sc, NULL);
647 ath9k_ps_restore(sc);
656 struct ath_softc *sc = hw->priv;
657 struct ath_hw *ah = sc->sc_ah;
659 struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan;
660 struct ath_chanctx *ctx = sc->cur_chan;
668 ath9k_ps_wakeup(sc);
669 mutex_lock(&sc->mutex);
672 sc->cur_chandef = hw->conf.chandef;
684 spin_lock_bh(&sc->sc_pcu_lock);
720 ath_mci_enable(sc);
723 sc->sc_ah->is_monitoring = false;
725 if (!ath_complete_reset(sc, false))
739 ath9k_cmn_init_crypto(sc->sc_ah);
743 spin_unlock_bh(&sc->sc_pcu_lock);
745 ath9k_rng_start(sc);
747 mutex_unlock(&sc->mutex);
749 ath9k_ps_restore(sc);
758 struct ath_softc *sc = hw->priv;
759 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
764 if (sc->ps_enabled) {
778 if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_NETWORK_SLEEP)) {
784 ath9k_ps_wakeup(sc);
785 spin_lock_irqsave(&sc->sc_pm_lock, flags);
786 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
787 ath9k_hw_setrxabort(sc->sc_ah, 0);
791 sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA;
794 sc->ps_flags |= PS_WAIT_FOR_TX_ACK;
801 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
802 ath9k_ps_restore(sc);
809 if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP)) {
815 txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
822 TX_STAT_INC(sc, txctl.txq->axq_qnum, txfailed);
850 static bool ath9k_txq_has_key(struct ath_softc *sc, u32 keyix)
852 struct ath_hw *ah = sc->sc_ah;
858 if (!ATH_TXQ_SETUP(sc, i))
860 txq = &sc->tx.txq[i];
866 ath_txq_lock(sc, txq);
868 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
879 ath_txq_unlock(sc, txq);
885 static void ath9k_pending_key_del(struct ath_softc *sc, u8 keyix)
887 struct ath_hw *ah = sc->sc_ah;
891 ath9k_txq_has_key(sc, keyix))
901 struct ath_softc *sc = hw->priv;
902 struct ath_hw *ah = sc->sc_ah;
907 ath9k_deinit_channel_context(sc);
909 mutex_lock(&sc->mutex);
911 ath9k_rng_stop(sc);
913 ath_cancel_work(sc);
917 mutex_unlock(&sc->mutex);
922 ath9k_ps_wakeup(sc);
924 spin_lock_bh(&sc->sc_pcu_lock);
933 spin_unlock_bh(&sc->sc_pcu_lock);
937 synchronize_irq(sc->irq);
938 tasklet_kill(&sc->intr_tq);
939 tasklet_kill(&sc->bcon_tasklet);
941 prev_idle = sc->ps_idle;
942 sc->ps_idle = true;
944 spin_lock_bh(&sc->sc_pcu_lock);
952 ath_prepare_reset(sc);
954 if (sc->rx.frag) {
955 dev_kfree_skb_any(sc->rx.frag);
956 sc->rx.frag = NULL;
961 &sc->cur_chan->chandef);
971 spin_unlock_bh(&sc->sc_pcu_lock);
974 ath9k_pending_key_del(sc, i);
979 ath9k_cmn_init_crypto(sc->sc_ah);
981 ath9k_ps_restore(sc);
983 sc->ps_idle = prev_idle;
985 mutex_unlock(&sc->mutex);
1068 static void ath9k_update_bssid_mask(struct ath_softc *sc,
1072 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1092 sc->hw->wiphy->perm_addr[i]);
1096 /* Called with sc->mutex held. */
1097 void ath9k_calculate_iter_data(struct ath_softc *sc,
1114 ath9k_update_bssid_mask(sc, ctx, iter_data);
1117 static void ath9k_set_assoc_state(struct ath_softc *sc,
1120 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1128 ath9k_hw_write_associd(sc->sc_ah);
1132 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
1134 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1135 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
1136 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1139 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
1140 ath9k_mci_update_wlan_channels(sc, false);
1148 static void ath9k_set_offchannel_state(struct ath_softc *sc)
1150 struct ath_hw *ah = sc->sc_ah;
1154 ath9k_ps_wakeup(sc);
1156 if (sc->offchannel.state < ATH_OFFCHANNEL_ROC_START)
1157 vif = sc->offchannel.scan_vif;
1159 vif = sc->offchannel.roc_vif;
1175 ath9k_hw_write_associd(sc->sc_ah);
1180 ath9k_ps_restore(sc);
1184 /* Called with sc->mutex held. */
1185 void ath9k_calculate_summary_state(struct ath_softc *sc,
1188 struct ath_hw *ah = sc->sc_ah;
1192 ath_chanctx_check_active(sc, ctx);
1194 if (ctx != sc->cur_chan)
1198 if (ctx == &sc->offchannel.chan)
1199 return ath9k_set_offchannel_state(sc);
1202 ath9k_ps_wakeup(sc);
1203 ath9k_calculate_iter_data(sc, ctx, &iter_data);
1217 ath9k_beacon_ensure_primary_slot(sc);
1248 ath9k_set_assoc_state(sc, iter_data.primary_sta,
1255 ath9k_hw_write_associd(sc->sc_ah);
1256 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
1257 ath9k_mci_update_wlan_channels(sc, true);
1260 sc->nbcnvifs = iter_data.nbcnvifs;
1261 ath9k_beacon_config(sc, iter_data.primary_beacon_vif,
1279 ath9k_ps_restore(sc);
1293 /* Called with sc->mutex held. */
1294 void ath9k_set_txpower(struct ath_softc *sc, struct ieee80211_vif *vif)
1297 struct ath_hw *ah = sc->sc_ah;
1300 ath9k_ps_wakeup(sc);
1304 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
1307 power = sc->hw->conf.power_level;
1309 power = sc->hw->conf.power_level;
1311 sc->cur_chan->txpower = 2 * power;
1312 ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false);
1313 sc->cur_chan->cur_txpower = reg->max_power_level;
1314 ath9k_ps_restore(sc);
1338 struct ath_softc *sc = hw->priv;
1339 struct ath_hw *ah = sc->sc_ah;
1344 mutex_lock(&sc->mutex);
1346 if (sc->cur_chan->nvifs >= 1) {
1347 mutex_unlock(&sc->mutex);
1350 sc->tx99_vif = vif;
1354 sc->cur_chan->nvifs++;
1360 ath9k_beacon_assign_slot(sc, vif);
1364 avp->chanctx = sc->cur_chan;
1368 ath9k_calculate_summary_state(sc, avp->chanctx);
1372 ath9k_set_txpower(sc, vif);
1374 an->sc = sc;
1378 ath_tx_node_init(sc, an);
1380 mutex_unlock(&sc->mutex);
1389 struct ath_softc *sc = hw->priv;
1390 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1393 mutex_lock(&sc->mutex);
1396 mutex_unlock(&sc->mutex);
1403 ath9k_beacon_remove_slot(sc, vif);
1409 ath9k_beacon_assign_slot(sc, vif);
1412 ath9k_calculate_summary_state(sc, avp->chanctx);
1414 ath9k_set_txpower(sc, vif);
1416 mutex_unlock(&sc->mutex);
1423 struct ath_softc *sc = hw->priv;
1424 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1429 mutex_lock(&sc->mutex);
1431 ath9k_p2p_remove_vif(sc, vif);
1433 sc->cur_chan->nvifs--;
1434 sc->tx99_vif = NULL;
1439 ath9k_beacon_remove_slot(sc, vif);
1441 ath_tx_node_cleanup(sc, &avp->mcast_node);
1443 ath9k_calculate_summary_state(sc, avp->chanctx);
1445 ath9k_set_txpower(sc, NULL);
1447 mutex_unlock(&sc->mutex);
1450 static void ath9k_enable_ps(struct ath_softc *sc)
1452 struct ath_hw *ah = sc->sc_ah;
1458 sc->ps_enabled = true;
1469 static void ath9k_disable_ps(struct ath_softc *sc)
1471 struct ath_hw *ah = sc->sc_ah;
1477 sc->ps_enabled = false;
1481 sc->ps_flags &= ~(PS_WAIT_FOR_BEACON |
1495 struct ath_softc *sc = hw->priv;
1496 struct ath_hw *ah = sc->sc_ah;
1499 struct ath_chanctx *ctx = sc->cur_chan;
1501 ath9k_ps_wakeup(sc);
1502 mutex_lock(&sc->mutex);
1505 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1506 if (sc->ps_idle) {
1507 ath_cancel_work(sc);
1508 ath9k_stop_btcoex(sc);
1510 ath9k_start_btcoex(sc);
1515 ath_chanctx_set_channel(sc, ctx, &ctx->chandef);
1527 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1529 ath9k_enable_ps(sc);
1531 ath9k_disable_ps(sc);
1532 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1538 sc->sc_ah->is_monitoring = true;
1541 sc->sc_ah->is_monitoring = false;
1547 ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef);
1551 ath9k_set_txpower(sc, NULL);
1553 mutex_unlock(&sc->mutex);
1554 ath9k_ps_restore(sc);
1569 /* FIXME: sc->sc_full_reset ? */
1575 struct ath_softc *sc = hw->priv;
1582 spin_lock_bh(&sc->chan_lock);
1583 ath_for_each_chanctx(sc, ctx)
1586 sc->offchannel.chan.rxfilter = *total_flags;
1588 spin_unlock_bh(&sc->chan_lock);
1590 ath9k_ps_wakeup(sc);
1591 rfilt = ath_calcrxfilter(sc);
1592 ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
1593 ath9k_ps_restore(sc);
1595 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, "Set HW RX filter: 0x%x\n",
1603 struct ath_softc *sc = hw->priv;
1604 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1609 ath_node_attach(sc, sta, vif);
1624 static void ath9k_del_ps_key(struct ath_softc *sc,
1628 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1643 struct ath_softc *sc = hw->priv;
1645 ath9k_del_ps_key(sc, vif, sta);
1646 ath_node_detach(sc, sta);
1657 struct ath_softc *sc = hw->priv;
1658 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1677 ath_chanctx_event(sc, vif,
1703 struct ath_softc *sc = hw->priv;
1709 ath_tx_aggr_sleep(sta, sc, an);
1710 ath9k_sta_set_tx_filter(sc->sc_ah, an, true);
1713 ath9k_sta_set_tx_filter(sc->sc_ah, an, false);
1715 ath_tx_aggr_wakeup(sc, an);
1724 struct ath_softc *sc = hw->priv;
1725 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1733 txq = sc->tx.txq_map[queue];
1735 ath9k_ps_wakeup(sc);
1736 mutex_lock(&sc->mutex);
1750 ath_update_max_aggr_framelen(sc, queue, qi.tqi_burstTime);
1751 ret = ath_txq_update(sc, txq->axq_qnum, &qi);
1755 mutex_unlock(&sc->mutex);
1756 ath9k_ps_restore(sc);
1767 struct ath_softc *sc = hw->priv;
1768 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1799 mutex_lock(&sc->mutex);
1800 ath9k_ps_wakeup(sc);
1809 ath9k_pending_key_del(sc, i);
1814 ath9k_del_ps_key(sc, vif, sta);
1824 if (sc->sc_ah->sw_mgmt_crypto_tx &&
1840 if (ath9k_txq_has_key(sc, key->hw_key_idx)) {
1844 set_bit(key->hw_key_idx, sc->sc_ah->pending_del_keymap);
1863 ath9k_ps_restore(sc);
1864 mutex_unlock(&sc->mutex);
1879 struct ath_softc *sc = hw->priv;
1880 struct ath_hw *ah = sc->sc_ah;
1885 ath9k_ps_wakeup(sc);
1886 mutex_lock(&sc->mutex);
1896 ath9k_calculate_summary_state(sc, avp->chanctx);
1903 ath9k_hw_write_associd(sc->sc_ah);
1909 ath9k_calculate_summary_state(sc, avp->chanctx);
1912 if ((avp->chanctx == sc->cur_chan) &&
1925 sc->beacon.slottime = slottime;
1926 sc->beacon.updateslot = UPDATE;
1934 ath9k_p2p_bss_info_changed(sc, vif);
1937 ath_check_ani(sc);
1942 ath9k_set_txpower(sc, vif);
1945 mutex_unlock(&sc->mutex);
1946 ath9k_ps_restore(sc);
1953 struct ath_softc *sc = hw->priv;
1957 mutex_lock(&sc->mutex);
1958 ath9k_ps_wakeup(sc);
1960 if (sc->cur_chan == avp->chanctx) {
1961 tsf = ath9k_hw_gettsf64(sc->sc_ah);
1963 tsf = sc->cur_chan->tsf_val +
1964 ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL);
1967 ath9k_ps_restore(sc);
1968 mutex_unlock(&sc->mutex);
1977 struct ath_softc *sc = hw->priv;
1980 mutex_lock(&sc->mutex);
1981 ath9k_ps_wakeup(sc);
1984 if (sc->cur_chan == avp->chanctx)
1985 ath9k_hw_settsf64(sc->sc_ah, tsf);
1987 ath9k_ps_restore(sc);
1988 mutex_unlock(&sc->mutex);
1993 struct ath_softc *sc = hw->priv;
1996 mutex_lock(&sc->mutex);
1998 ath9k_ps_wakeup(sc);
2000 if (sc->cur_chan == avp->chanctx)
2001 ath9k_hw_reset_tsf(sc->sc_ah);
2003 ath9k_ps_restore(sc);
2005 mutex_unlock(&sc->mutex);
2012 struct ath_softc *sc = hw->priv;
2013 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2023 mutex_lock(&sc->mutex);
2037 ath9k_ps_wakeup(sc);
2038 ret = ath_tx_aggr_start(sc, sta, tid, ssn);
2041 ath9k_ps_restore(sc);
2048 ath9k_ps_wakeup(sc);
2049 ath_tx_aggr_stop(sc, sta, tid);
2052 ath9k_ps_restore(sc);
2060 ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n");
2063 mutex_unlock(&sc->mutex);
2071 struct ath_softc *sc = hw->priv;
2072 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2083 ath_update_survey_stats(sc);
2101 memcpy(survey, &sc->survey[pos], sizeof(*survey));
2108 static void ath9k_enable_dynack(struct ath_softc *sc)
2112 struct ath_hw *ah = sc->sc_ah;
2117 rfilt = ath_calcrxfilter(sc);
2125 struct ath_softc *sc = hw->priv;
2126 struct ath_hw *ah = sc->sc_ah;
2131 mutex_lock(&sc->mutex);
2139 rfilt = ath_calcrxfilter(sc);
2142 ath9k_ps_wakeup(sc);
2144 ath9k_ps_restore(sc);
2146 ath9k_enable_dynack(sc);
2149 mutex_unlock(&sc->mutex);
2152 static bool ath9k_has_tx_pending(struct ath_softc *sc,
2158 if (!ATH_TXQ_SETUP(sc, i))
2161 npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i],
2173 struct ath_softc *sc = hw->priv;
2174 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2184 * sc->mutex lock to allow the channel scheduler
2194 mutex_lock(&sc->mutex);
2196 mutex_unlock(&sc->mutex);
2202 struct ath_softc *sc = hw->priv;
2203 struct ath_hw *ah = sc->sc_ah;
2208 cancel_delayed_work_sync(&sc->hw_check_work);
2220 spin_lock_bh(&sc->chan_lock);
2224 timeout = sc->cur_chan->flush_timeout;
2225 spin_unlock_bh(&sc->chan_lock);
2230 if (wait_event_timeout(sc->tx_wait, !ath9k_has_tx_pending(sc, sw_pending),
2235 ath9k_ps_wakeup(sc);
2236 spin_lock_bh(&sc->sc_pcu_lock);
2237 drain_txq = ath_drain_all_txq(sc);
2238 spin_unlock_bh(&sc->sc_pcu_lock);
2241 ath_reset(sc, NULL);
2243 ath9k_ps_restore(sc);
2246 ieee80211_queue_delayed_work(hw, &sc->hw_check_work,
2252 struct ath_softc *sc = hw->priv;
2254 return ath9k_has_tx_pending(sc, true);
2259 struct ath_softc *sc = hw->priv;
2260 struct ath_hw *ah = sc->sc_ah;
2268 vif = sc->beacon.bslot[0];
2277 if (!sc->beacon.tx_processed && !edma) {
2278 tasklet_disable(&sc->bcon_tasklet);
2288 sc->beacon.tx_processed = true;
2289 sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
2292 tasklet_enable(&sc->bcon_tasklet);
2295 return sc->beacon.tx_last;
2301 struct ath_softc *sc = hw->priv;
2302 struct ath_hw *ah = sc->sc_ah;
2349 struct ath_softc *sc = hw->priv;
2350 struct ath_hw *ah = sc->sc_ah;
2358 sc->ant_rx = rx_ant;
2359 sc->ant_tx = tx_ant;
2378 struct ath_softc *sc = hw->priv;
2380 *tx_ant = sc->ant_tx;
2381 *rx_ant = sc->ant_rx;
2389 struct ath_softc *sc = hw->priv;
2390 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2397 struct ath_softc *sc = hw->priv;
2398 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2404 static void ath9k_cancel_pending_offchannel(struct ath_softc *sc)
2406 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2408 if (sc->offchannel.roc_vif) {
2412 del_timer_sync(&sc->offchannel.timer);
2413 if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START)
2414 ath_roc_complete(sc, ATH_ROC_COMPLETE_ABORT);
2421 del_timer_sync(&sc->offchannel.timer);
2422 ath_scan_complete(sc, true);
2430 struct ath_softc *sc = hw->priv;
2431 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2434 mutex_lock(&sc->mutex);
2436 if (WARN_ON(sc->offchannel.scan_req)) {
2441 ath9k_ps_wakeup(sc);
2443 sc->offchannel.scan_vif = vif;
2444 sc->offchannel.scan_req = req;
2445 sc->offchannel.scan_idx = 0;
2450 if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE) {
2452 ath_offchannel_next(sc);
2456 mutex_unlock(&sc->mutex);
2464 struct ath_softc *sc = hw->priv;
2465 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2469 mutex_lock(&sc->mutex);
2470 del_timer_sync(&sc->offchannel.timer);
2471 ath_scan_complete(sc, true);
2472 mutex_unlock(&sc->mutex);
2480 struct ath_softc *sc = hw->priv;
2481 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2484 mutex_lock(&sc->mutex);
2486 if (WARN_ON(sc->offchannel.roc_vif)) {
2491 ath9k_ps_wakeup(sc);
2492 sc->offchannel.roc_vif = vif;
2493 sc->offchannel.roc_chan = chan;
2494 sc->offchannel.roc_duration = duration;
2500 if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE) {
2502 ath_offchannel_next(sc);
2506 mutex_unlock(&sc->mutex);
2514 struct ath_softc *sc = hw->priv;
2515 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2517 mutex_lock(&sc->mutex);
2520 del_timer_sync(&sc->offchannel.timer);
2522 if (sc->offchannel.roc_vif) {
2523 if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START)
2524 ath_roc_complete(sc, ATH_ROC_COMPLETE_CANCEL);
2527 mutex_unlock(&sc->mutex);
2535 struct ath_softc *sc = hw->priv;
2536 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2540 mutex_lock(&sc->mutex);
2542 ath_for_each_chanctx(sc, ctx) {
2549 pos = ctx - &sc->chanctx[0];
2556 ath_chanctx_set_channel(sc, ctx, &conf->def);
2558 mutex_unlock(&sc->mutex);
2562 mutex_unlock(&sc->mutex);
2570 struct ath_softc *sc = hw->priv;
2571 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2574 mutex_lock(&sc->mutex);
2582 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_UNASSIGN);
2584 mutex_unlock(&sc->mutex);
2591 struct ath_softc *sc = hw->priv;
2592 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2595 mutex_lock(&sc->mutex);
2599 ath_chanctx_set_channel(sc, ctx, &conf->def);
2600 mutex_unlock(&sc->mutex);
2607 struct ath_softc *sc = hw->priv;
2608 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2613 ath9k_cancel_pending_offchannel(sc);
2615 mutex_lock(&sc->mutex);
2625 ath9k_calculate_summary_state(sc, ctx);
2629 mutex_unlock(&sc->mutex);
2638 struct ath_softc *sc = hw->priv;
2639 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2644 ath9k_cancel_pending_offchannel(sc);
2646 mutex_lock(&sc->mutex);
2656 ath9k_calculate_summary_state(sc, ctx);
2660 mutex_unlock(&sc->mutex);
2667 struct ath_softc *sc = hw->priv;
2668 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2682 mutex_lock(&sc->mutex);
2684 spin_lock_bh(&sc->chan_lock);
2685 if (sc->next_chan || (sc->cur_chan != avp->chanctx))
2687 spin_unlock_bh(&sc->chan_lock);
2692 ath9k_cancel_pending_offchannel(sc);
2694 go_ctx = ath_is_go_chanctx_present(sc);
2701 spin_lock_bh(&sc->chan_lock);
2702 sc->sched.mgd_prepare_tx = true;
2705 spin_unlock_bh(&sc->chan_lock);
2708 init_completion(&sc->go_beacon);
2710 mutex_unlock(&sc->mutex);
2712 if (wait_for_completion_timeout(&sc->go_beacon,
2717 spin_lock_bh(&sc->chan_lock);
2718 sc->sched.mgd_prepare_tx = false;
2719 spin_unlock_bh(&sc->chan_lock);
2722 mutex_lock(&sc->mutex);
2729 spin_lock_bh(&sc->chan_lock);
2730 sc->next_chan = avp->chanctx;
2731 sc->sched.state = ATH_CHANCTX_STATE_FORCE_ACTIVE;
2732 spin_unlock_bh(&sc->chan_lock);
2734 ath_chanctx_set_next(sc, true);
2736 mutex_unlock(&sc->mutex);
2761 struct ath_softc *sc = hw->priv;
2764 mutex_lock(&sc->mutex);
2768 *dbm = sc->cur_chan->cur_txpower;
2769 mutex_unlock(&sc->mutex);