Lines Matching defs: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);
143 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
146 void ath9k_ps_restore(struct ath_softc *sc)
148 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
152 spin_lock_irqsave(&sc->sc_pm_lock, flags);
153 if (--sc->ps_usecount != 0)
156 if (sc->ps_idle) {
157 mod_timer(&sc->sleep_timer, jiffies + HZ / 10);
161 if (sc->ps_enabled &&
162 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
168 if (ath9k_hw_btcoex_is_enabled(sc->sc_ah))
169 ath9k_btcoex_stop_gen_timer(sc);
178 ath9k_hw_setpower(sc->sc_ah, mode);
181 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
184 static void __ath_cancel_work(struct ath_softc *sc)
186 cancel_work_sync(&sc->paprd_work);
187 cancel_delayed_work_sync(&sc->hw_check_work);
188 cancel_delayed_work_sync(&sc->hw_pll_work);
191 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
192 cancel_work_sync(&sc->mci_work);
196 void ath_cancel_work(struct ath_softc *sc)
198 __ath_cancel_work(sc);
199 cancel_work_sync(&sc->hw_reset_work);
202 void ath_restart_work(struct ath_softc *sc)
204 ieee80211_queue_delayed_work(sc->hw, &sc->hw_check_work,
207 if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah))
208 ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
211 ath_start_ani(sc);
214 static bool ath_prepare_reset(struct ath_softc *sc)
216 struct ath_hw *ah = sc->sc_ah;
219 ieee80211_stop_queues(sc->hw);
220 ath_stop_ani(sc);
224 ret &= ath_stoprecv(sc);
225 ret &= ath_drain_all_txq(sc);
227 ret &= ath_drain_all_txq(sc);
228 ret &= ath_stoprecv(sc);
234 static bool ath_complete_reset(struct ath_softc *sc, bool start)
236 struct ath_hw *ah = sc->sc_ah;
240 ath9k_calculate_summary_state(sc, sc->cur_chan);
241 ath_startrecv(sc);
242 ath9k_cmn_update_txpow(ah, sc->cur_chan->cur_txpower,
243 sc->cur_chan->txpower,
244 &sc->cur_chan->cur_txpower);
247 if (!sc->cur_chan->offchannel && start) {
249 if (sc->cur_chan->tsf_val) {
252 offset = ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts,
254 ath9k_hw_settsf64(ah, sc->cur_chan->tsf_val + offset);
263 spin_lock_irqsave(&sc->sc_pm_lock, flags);
264 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
265 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
267 ath9k_set_beacon(sc);
270 ath_restart_work(sc);
271 ath_txq_schedule_all(sc);
274 sc->gtt_cnt = 0;
278 ieee80211_wake_queues(sc->hw);
279 ath9k_p2p_ps_timer(sc);
284 static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan)
286 struct ath_hw *ah = sc->sc_ah;
292 __ath_cancel_work(sc);
294 disable_irq(sc->irq);
295 tasklet_disable(&sc->intr_tq);
296 tasklet_disable(&sc->bcon_tasklet);
297 spin_lock_bh(&sc->sc_pcu_lock);
299 if (!sc->cur_chan->offchannel) {
301 caldata = &sc->cur_chan->caldata;
311 hchan = ath9k_cmn_get_channel(sc->hw, ah, &sc->cur_chan->chandef);
314 if (!ath_prepare_reset(sc))
320 spin_lock_bh(&sc->chan_lock);
321 sc->cur_chandef = sc->cur_chan->chandef;
322 spin_unlock_bh(&sc->chan_lock);
333 ath9k_queue_reset(sc, RESET_TYPE_BB_HANG);
338 if (ath9k_hw_mci_is_enabled(sc->sc_ah) &&
339 sc->cur_chan->offchannel)
340 ath9k_mci_set_txpower(sc, true, false);
342 if (!ath_complete_reset(sc, true))
346 enable_irq(sc->irq);
347 spin_unlock_bh(&sc->sc_pcu_lock);
348 tasklet_enable(&sc->bcon_tasklet);
349 tasklet_enable(&sc->intr_tq);
354 static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
360 an->sc = sc;
365 ath_tx_node_init(sc, an);
367 ath_dynack_node_init(sc->sc_ah, an);
370 static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
373 ath_tx_node_cleanup(sc, an);
375 ath_dynack_node_deinit(sc->sc_ah, an);
380 struct ath_softc *sc = from_tasklet(sc, t, intr_tq);
381 struct ath_hw *ah = sc->sc_ah;
388 spin_lock_irqsave(&sc->intr_lock, flags);
389 status = sc->intrstatus;
390 sc->intrstatus = 0;
391 spin_unlock_irqrestore(&sc->intr_lock, flags);
393 ath9k_ps_wakeup(sc);
394 spin_lock(&sc->sc_pcu_lock);
398 ath9k_queue_reset(sc, type);
412 ath9k_queue_reset(sc, type);
421 sc->gtt_cnt++;
423 if ((sc->gtt_cnt >= MAX_GTT_CNT) && !ath9k_hw_check_alive(ah)) {
425 ath9k_queue_reset(sc, type);
432 spin_lock_irqsave(&sc->sc_pm_lock, flags);
433 if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
439 sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC;
441 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
453 ath_rx_tasklet(sc, 0, true);
455 ath_rx_tasklet(sc, 0, false);
466 sc->gtt_cnt = 0;
468 ath_tx_edma_tasklet(sc);
470 ath_tx_tasklet(sc);
473 wake_up(&sc->tx_wait);
477 ath_gen_timer_isr(sc->sc_ah);
479 ath9k_btcoex_handle_interrupt(sc, status);
484 spin_unlock(&sc->sc_pcu_lock);
485 ath9k_ps_restore(sc);
506 struct ath_softc *sc = dev;
507 struct ath_hw *ah = sc->sc_ah;
532 ath9k_debug_sync_cause(sc, sync_cause);
536 ath9k_hw_kill_interrupts(sc->sc_ah);
548 spin_lock(&sc->intr_lock);
549 sc->intrstatus |= status;
550 spin_unlock(&sc->intr_lock);
567 tasklet_schedule(&sc->bcon_tasklet);
579 if (ATH_DBG_WARN_ON_ONCE(sc->ps_idle))
583 ath9k_setpower(sc, ATH9K_PM_AWAKE);
584 spin_lock(&sc->sc_pm_lock);
585 ath9k_hw_setrxabort(sc->sc_ah, 0);
586 sc->ps_flags |= PS_WAIT_FOR_BEACON;
587 spin_unlock(&sc->sc_pm_lock);
592 ath_debug_stat_interrupt(sc, status);
597 tasklet_schedule(&sc->intr_tq);
609 int ath_reset(struct ath_softc *sc, struct ath9k_channel *hchan)
611 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
614 ath9k_hw_kill_interrupts(sc->sc_ah);
617 ath9k_ps_wakeup(sc);
618 r = ath_reset_internal(sc, hchan);
619 ath9k_ps_restore(sc);
629 void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type)
631 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
633 RESET_STAT_INC(sc, type);
635 ath9k_hw_kill_interrupts(sc->sc_ah);
637 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
642 struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work);
644 ath9k_ps_wakeup(sc);
645 ath_reset_internal(sc, NULL);
646 ath9k_ps_restore(sc);
655 struct ath_softc *sc = hw->priv;
656 struct ath_hw *ah = sc->sc_ah;
658 struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan;
659 struct ath_chanctx *ctx = sc->cur_chan;
667 ath9k_ps_wakeup(sc);
668 mutex_lock(&sc->mutex);
671 sc->cur_chandef = hw->conf.chandef;
683 spin_lock_bh(&sc->sc_pcu_lock);
719 ath_mci_enable(sc);
722 sc->sc_ah->is_monitoring = false;
724 if (!ath_complete_reset(sc, false))
738 ath9k_cmn_init_crypto(sc->sc_ah);
742 spin_unlock_bh(&sc->sc_pcu_lock);
744 ath9k_rng_start(sc);
746 mutex_unlock(&sc->mutex);
748 ath9k_ps_restore(sc);
757 struct ath_softc *sc = hw->priv;
758 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
763 if (sc->ps_enabled) {
777 if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_NETWORK_SLEEP)) {
783 ath9k_ps_wakeup(sc);
784 spin_lock_irqsave(&sc->sc_pm_lock, flags);
785 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
786 ath9k_hw_setrxabort(sc->sc_ah, 0);
790 sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA;
793 sc->ps_flags |= PS_WAIT_FOR_TX_ACK;
800 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
801 ath9k_ps_restore(sc);
808 if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP)) {
814 txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
821 TX_STAT_INC(sc, txctl.txq->axq_qnum, txfailed);
849 static bool ath9k_txq_has_key(struct ath_softc *sc, u32 keyix)
851 struct ath_hw *ah = sc->sc_ah;
857 if (!ATH_TXQ_SETUP(sc, i))
859 txq = &sc->tx.txq[i];
865 ath_txq_lock(sc, txq);
867 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
878 ath_txq_unlock(sc, txq);
884 static void ath9k_pending_key_del(struct ath_softc *sc, u8 keyix)
886 struct ath_hw *ah = sc->sc_ah;
890 ath9k_txq_has_key(sc, keyix))
900 struct ath_softc *sc = hw->priv;
901 struct ath_hw *ah = sc->sc_ah;
906 ath9k_deinit_channel_context(sc);
908 mutex_lock(&sc->mutex);
910 ath9k_rng_stop(sc);
912 ath_cancel_work(sc);
916 mutex_unlock(&sc->mutex);
921 ath9k_ps_wakeup(sc);
923 spin_lock_bh(&sc->sc_pcu_lock);
932 spin_unlock_bh(&sc->sc_pcu_lock);
936 synchronize_irq(sc->irq);
937 tasklet_kill(&sc->intr_tq);
938 tasklet_kill(&sc->bcon_tasklet);
940 prev_idle = sc->ps_idle;
941 sc->ps_idle = true;
943 spin_lock_bh(&sc->sc_pcu_lock);
951 ath_prepare_reset(sc);
953 if (sc->rx.frag) {
954 dev_kfree_skb_any(sc->rx.frag);
955 sc->rx.frag = NULL;
960 &sc->cur_chan->chandef);
970 spin_unlock_bh(&sc->sc_pcu_lock);
973 ath9k_pending_key_del(sc, i);
978 ath9k_cmn_init_crypto(sc->sc_ah);
980 ath9k_ps_restore(sc);
982 sc->ps_idle = prev_idle;
984 mutex_unlock(&sc->mutex);
1064 static void ath9k_update_bssid_mask(struct ath_softc *sc,
1068 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1088 sc->hw->wiphy->perm_addr[i]);
1092 /* Called with sc->mutex held. */
1093 void ath9k_calculate_iter_data(struct ath_softc *sc,
1110 ath9k_update_bssid_mask(sc, ctx, iter_data);
1113 static void ath9k_set_assoc_state(struct ath_softc *sc,
1116 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1124 ath9k_hw_write_associd(sc->sc_ah);
1128 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
1130 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1131 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
1132 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1135 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
1136 ath9k_mci_update_wlan_channels(sc, false);
1144 static void ath9k_set_offchannel_state(struct ath_softc *sc)
1146 struct ath_hw *ah = sc->sc_ah;
1150 ath9k_ps_wakeup(sc);
1152 if (sc->offchannel.state < ATH_OFFCHANNEL_ROC_START)
1153 vif = sc->offchannel.scan_vif;
1155 vif = sc->offchannel.roc_vif;
1171 ath9k_hw_write_associd(sc->sc_ah);
1176 ath9k_ps_restore(sc);
1180 /* Called with sc->mutex held. */
1181 void ath9k_calculate_summary_state(struct ath_softc *sc,
1184 struct ath_hw *ah = sc->sc_ah;
1188 ath_chanctx_check_active(sc, ctx);
1190 if (ctx != sc->cur_chan)
1194 if (ctx == &sc->offchannel.chan)
1195 return ath9k_set_offchannel_state(sc);
1198 ath9k_ps_wakeup(sc);
1199 ath9k_calculate_iter_data(sc, ctx, &iter_data);
1213 ath9k_beacon_ensure_primary_slot(sc);
1242 ath9k_set_assoc_state(sc, iter_data.primary_sta,
1249 ath9k_hw_write_associd(sc->sc_ah);
1250 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
1251 ath9k_mci_update_wlan_channels(sc, true);
1254 sc->nbcnvifs = iter_data.nbcnvifs;
1255 ath9k_beacon_config(sc, iter_data.primary_beacon_vif,
1273 ath9k_ps_restore(sc);
1287 /* Called with sc->mutex held. */
1288 void ath9k_set_txpower(struct ath_softc *sc, struct ieee80211_vif *vif)
1291 struct ath_hw *ah = sc->sc_ah;
1294 ath9k_ps_wakeup(sc);
1298 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
1301 power = sc->hw->conf.power_level;
1303 power = sc->hw->conf.power_level;
1305 sc->cur_chan->txpower = 2 * power;
1306 ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false);
1307 sc->cur_chan->cur_txpower = reg->max_power_level;
1308 ath9k_ps_restore(sc);
1332 struct ath_softc *sc = hw->priv;
1333 struct ath_hw *ah = sc->sc_ah;
1338 mutex_lock(&sc->mutex);
1340 if (sc->cur_chan->nvifs >= 1) {
1341 mutex_unlock(&sc->mutex);
1344 sc->tx99_vif = vif;
1348 sc->cur_chan->nvifs++;
1354 ath9k_beacon_assign_slot(sc, vif);
1358 avp->chanctx = sc->cur_chan;
1362 ath9k_calculate_summary_state(sc, avp->chanctx);
1366 ath9k_set_txpower(sc, vif);
1368 an->sc = sc;
1372 ath_tx_node_init(sc, an);
1374 mutex_unlock(&sc->mutex);
1383 struct ath_softc *sc = hw->priv;
1384 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1387 mutex_lock(&sc->mutex);
1390 mutex_unlock(&sc->mutex);
1397 ath9k_beacon_remove_slot(sc, vif);
1403 ath9k_beacon_assign_slot(sc, vif);
1406 ath9k_calculate_summary_state(sc, avp->chanctx);
1408 ath9k_set_txpower(sc, vif);
1410 mutex_unlock(&sc->mutex);
1417 struct ath_softc *sc = hw->priv;
1418 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1423 mutex_lock(&sc->mutex);
1425 ath9k_p2p_remove_vif(sc, vif);
1427 sc->cur_chan->nvifs--;
1428 sc->tx99_vif = NULL;
1433 ath9k_beacon_remove_slot(sc, vif);
1435 ath_tx_node_cleanup(sc, &avp->mcast_node);
1437 ath9k_calculate_summary_state(sc, avp->chanctx);
1439 ath9k_set_txpower(sc, NULL);
1441 mutex_unlock(&sc->mutex);
1444 static void ath9k_enable_ps(struct ath_softc *sc)
1446 struct ath_hw *ah = sc->sc_ah;
1452 sc->ps_enabled = true;
1463 static void ath9k_disable_ps(struct ath_softc *sc)
1465 struct ath_hw *ah = sc->sc_ah;
1471 sc->ps_enabled = false;
1475 sc->ps_flags &= ~(PS_WAIT_FOR_BEACON |
1489 struct ath_softc *sc = hw->priv;
1490 struct ath_hw *ah = sc->sc_ah;
1493 struct ath_chanctx *ctx = sc->cur_chan;
1495 ath9k_ps_wakeup(sc);
1496 mutex_lock(&sc->mutex);
1499 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1500 if (sc->ps_idle) {
1501 ath_cancel_work(sc);
1502 ath9k_stop_btcoex(sc);
1504 ath9k_start_btcoex(sc);
1509 ath_chanctx_set_channel(sc, ctx, &ctx->chandef);
1521 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1523 ath9k_enable_ps(sc);
1525 ath9k_disable_ps(sc);
1526 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1532 sc->sc_ah->is_monitoring = true;
1535 sc->sc_ah->is_monitoring = false;
1541 ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef);
1545 ath9k_set_txpower(sc, NULL);
1547 mutex_unlock(&sc->mutex);
1548 ath9k_ps_restore(sc);
1563 /* FIXME: sc->sc_full_reset ? */
1569 struct ath_softc *sc = hw->priv;
1575 spin_lock_bh(&sc->chan_lock);
1576 ath_for_each_chanctx(sc, ctx)
1579 sc->offchannel.chan.rxfilter = *total_flags;
1581 spin_unlock_bh(&sc->chan_lock);
1583 ath9k_ps_wakeup(sc);
1584 rfilt = ath_calcrxfilter(sc);
1585 ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
1586 ath9k_ps_restore(sc);
1588 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, "Set HW RX filter: 0x%x\n",
1596 struct ath_softc *sc = hw->priv;
1597 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1602 ath_node_attach(sc, sta, vif);
1617 static void ath9k_del_ps_key(struct ath_softc *sc,
1621 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1636 struct ath_softc *sc = hw->priv;
1638 ath9k_del_ps_key(sc, vif, sta);
1639 ath_node_detach(sc, sta);
1650 struct ath_softc *sc = hw->priv;
1651 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1670 ath_chanctx_event(sc, vif,
1696 struct ath_softc *sc = hw->priv;
1702 ath_tx_aggr_sleep(sta, sc, an);
1703 ath9k_sta_set_tx_filter(sc->sc_ah, an, true);
1706 ath9k_sta_set_tx_filter(sc->sc_ah, an, false);
1708 ath_tx_aggr_wakeup(sc, an);
1718 struct ath_softc *sc = hw->priv;
1719 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1727 txq = sc->tx.txq_map[queue];
1729 ath9k_ps_wakeup(sc);
1730 mutex_lock(&sc->mutex);
1744 ath_update_max_aggr_framelen(sc, queue, qi.tqi_burstTime);
1745 ret = ath_txq_update(sc, txq->axq_qnum, &qi);
1749 mutex_unlock(&sc->mutex);
1750 ath9k_ps_restore(sc);
1761 struct ath_softc *sc = hw->priv;
1762 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1793 mutex_lock(&sc->mutex);
1794 ath9k_ps_wakeup(sc);
1803 ath9k_pending_key_del(sc, i);
1808 ath9k_del_ps_key(sc, vif, sta);
1818 if (sc->sc_ah->sw_mgmt_crypto_tx &&
1834 if (ath9k_txq_has_key(sc, key->hw_key_idx)) {
1838 set_bit(key->hw_key_idx, sc->sc_ah->pending_del_keymap);
1857 ath9k_ps_restore(sc);
1858 mutex_unlock(&sc->mutex);
1873 struct ath_softc *sc = hw->priv;
1874 struct ath_hw *ah = sc->sc_ah;
1879 ath9k_ps_wakeup(sc);
1880 mutex_lock(&sc->mutex);
1890 ath9k_calculate_summary_state(sc, avp->chanctx);
1897 ath9k_hw_write_associd(sc->sc_ah);
1903 ath9k_calculate_summary_state(sc, avp->chanctx);
1906 if ((avp->chanctx == sc->cur_chan) &&
1919 sc->beacon.slottime = slottime;
1920 sc->beacon.updateslot = UPDATE;
1928 ath9k_p2p_bss_info_changed(sc, vif);
1931 ath_check_ani(sc);
1936 ath9k_set_txpower(sc, vif);
1939 mutex_unlock(&sc->mutex);
1940 ath9k_ps_restore(sc);
1947 struct ath_softc *sc = hw->priv;
1951 mutex_lock(&sc->mutex);
1952 ath9k_ps_wakeup(sc);
1954 if (sc->cur_chan == avp->chanctx) {
1955 tsf = ath9k_hw_gettsf64(sc->sc_ah);
1957 tsf = sc->cur_chan->tsf_val +
1958 ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL);
1961 ath9k_ps_restore(sc);
1962 mutex_unlock(&sc->mutex);
1971 struct ath_softc *sc = hw->priv;
1974 mutex_lock(&sc->mutex);
1975 ath9k_ps_wakeup(sc);
1978 if (sc->cur_chan == avp->chanctx)
1979 ath9k_hw_settsf64(sc->sc_ah, tsf);
1981 ath9k_ps_restore(sc);
1982 mutex_unlock(&sc->mutex);
1987 struct ath_softc *sc = hw->priv;
1990 mutex_lock(&sc->mutex);
1992 ath9k_ps_wakeup(sc);
1994 if (sc->cur_chan == avp->chanctx)
1995 ath9k_hw_reset_tsf(sc->sc_ah);
1997 ath9k_ps_restore(sc);
1999 mutex_unlock(&sc->mutex);
2006 struct ath_softc *sc = hw->priv;
2007 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2017 mutex_lock(&sc->mutex);
2031 ath9k_ps_wakeup(sc);
2032 ret = ath_tx_aggr_start(sc, sta, tid, ssn);
2035 ath9k_ps_restore(sc);
2042 ath9k_ps_wakeup(sc);
2043 ath_tx_aggr_stop(sc, sta, tid);
2046 ath9k_ps_restore(sc);
2054 ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n");
2057 mutex_unlock(&sc->mutex);
2065 struct ath_softc *sc = hw->priv;
2066 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2077 ath_update_survey_stats(sc);
2095 memcpy(survey, &sc->survey[pos], sizeof(*survey));
2102 static void ath9k_enable_dynack(struct ath_softc *sc)
2106 struct ath_hw *ah = sc->sc_ah;
2111 rfilt = ath_calcrxfilter(sc);
2119 struct ath_softc *sc = hw->priv;
2120 struct ath_hw *ah = sc->sc_ah;
2125 mutex_lock(&sc->mutex);
2133 rfilt = ath_calcrxfilter(sc);
2136 ath9k_ps_wakeup(sc);
2138 ath9k_ps_restore(sc);
2140 ath9k_enable_dynack(sc);
2143 mutex_unlock(&sc->mutex);
2146 static bool ath9k_has_tx_pending(struct ath_softc *sc,
2152 if (!ATH_TXQ_SETUP(sc, i))
2155 npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i],
2167 struct ath_softc *sc = hw->priv;
2168 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2178 * sc->mutex lock to allow the channel scheduler
2188 mutex_lock(&sc->mutex);
2190 mutex_unlock(&sc->mutex);
2196 struct ath_softc *sc = hw->priv;
2197 struct ath_hw *ah = sc->sc_ah;
2202 cancel_delayed_work_sync(&sc->hw_check_work);
2214 spin_lock_bh(&sc->chan_lock);
2218 timeout = sc->cur_chan->flush_timeout;
2219 spin_unlock_bh(&sc->chan_lock);
2224 if (wait_event_timeout(sc->tx_wait, !ath9k_has_tx_pending(sc, sw_pending),
2229 ath9k_ps_wakeup(sc);
2230 spin_lock_bh(&sc->sc_pcu_lock);
2231 drain_txq = ath_drain_all_txq(sc);
2232 spin_unlock_bh(&sc->sc_pcu_lock);
2235 ath_reset(sc, NULL);
2237 ath9k_ps_restore(sc);
2240 ieee80211_queue_delayed_work(hw, &sc->hw_check_work,
2246 struct ath_softc *sc = hw->priv;
2248 return ath9k_has_tx_pending(sc, true);
2253 struct ath_softc *sc = hw->priv;
2254 struct ath_hw *ah = sc->sc_ah;
2262 vif = sc->beacon.bslot[0];
2271 if (!sc->beacon.tx_processed && !edma) {
2272 tasklet_disable(&sc->bcon_tasklet);
2282 sc->beacon.tx_processed = true;
2283 sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
2286 tasklet_enable(&sc->bcon_tasklet);
2289 return sc->beacon.tx_last;
2295 struct ath_softc *sc = hw->priv;
2296 struct ath_hw *ah = sc->sc_ah;
2343 struct ath_softc *sc = hw->priv;
2344 struct ath_hw *ah = sc->sc_ah;
2352 sc->ant_rx = rx_ant;
2353 sc->ant_tx = tx_ant;
2372 struct ath_softc *sc = hw->priv;
2374 *tx_ant = sc->ant_tx;
2375 *rx_ant = sc->ant_rx;
2383 struct ath_softc *sc = hw->priv;
2384 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2385 struct cfg80211_chan_def *chandef = &sc->cur_chan->chandef;
2391 if (!sc->cur_chan->offchannel) {
2392 if (sc->cur_survey != &sc->survey[pos]) {
2393 if (sc->cur_survey)
2394 sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
2395 sc->cur_survey = &sc->survey[pos];
2398 memset(sc->cur_survey, 0, sizeof(struct survey_info));
2399 sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
2406 struct ath_softc *sc = hw->priv;
2407 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2413 static void ath9k_cancel_pending_offchannel(struct ath_softc *sc)
2415 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2417 if (sc->offchannel.roc_vif) {
2421 del_timer_sync(&sc->offchannel.timer);
2422 if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START)
2423 ath_roc_complete(sc, ATH_ROC_COMPLETE_ABORT);
2430 del_timer_sync(&sc->offchannel.timer);
2431 ath_scan_complete(sc, true);
2439 struct ath_softc *sc = hw->priv;
2440 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2443 mutex_lock(&sc->mutex);
2445 if (WARN_ON(sc->offchannel.scan_req)) {
2450 ath9k_ps_wakeup(sc);
2452 sc->offchannel.scan_vif = vif;
2453 sc->offchannel.scan_req = req;
2454 sc->offchannel.scan_idx = 0;
2459 if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE) {
2461 ath_offchannel_next(sc);
2465 mutex_unlock(&sc->mutex);
2473 struct ath_softc *sc = hw->priv;
2474 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2478 mutex_lock(&sc->mutex);
2479 del_timer_sync(&sc->offchannel.timer);
2480 ath_scan_complete(sc, true);
2481 mutex_unlock(&sc->mutex);
2489 struct ath_softc *sc = hw->priv;
2490 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2493 mutex_lock(&sc->mutex);
2495 if (WARN_ON(sc->offchannel.roc_vif)) {
2500 ath9k_ps_wakeup(sc);
2501 sc->offchannel.roc_vif = vif;
2502 sc->offchannel.roc_chan = chan;
2503 sc->offchannel.roc_duration = duration;
2509 if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE) {
2511 ath_offchannel_next(sc);
2515 mutex_unlock(&sc->mutex);
2523 struct ath_softc *sc = hw->priv;
2524 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2526 mutex_lock(&sc->mutex);
2529 del_timer_sync(&sc->offchannel.timer);
2531 if (sc->offchannel.roc_vif) {
2532 if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START)
2533 ath_roc_complete(sc, ATH_ROC_COMPLETE_CANCEL);
2536 mutex_unlock(&sc->mutex);
2544 struct ath_softc *sc = hw->priv;
2545 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2549 mutex_lock(&sc->mutex);
2551 ath_for_each_chanctx(sc, ctx) {
2558 pos = ctx - &sc->chanctx[0];
2565 ath_chanctx_set_channel(sc, ctx, &conf->def);
2567 mutex_unlock(&sc->mutex);
2571 mutex_unlock(&sc->mutex);
2579 struct ath_softc *sc = hw->priv;
2580 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2583 mutex_lock(&sc->mutex);
2591 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_UNASSIGN);
2593 mutex_unlock(&sc->mutex);
2600 struct ath_softc *sc = hw->priv;
2601 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2604 mutex_lock(&sc->mutex);
2608 ath_chanctx_set_channel(sc, ctx, &conf->def);
2609 mutex_unlock(&sc->mutex);
2617 struct ath_softc *sc = hw->priv;
2618 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2623 ath9k_cancel_pending_offchannel(sc);
2625 mutex_lock(&sc->mutex);
2635 ath9k_calculate_summary_state(sc, ctx);
2639 mutex_unlock(&sc->mutex);
2649 struct ath_softc *sc = hw->priv;
2650 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2655 ath9k_cancel_pending_offchannel(sc);
2657 mutex_lock(&sc->mutex);
2667 ath9k_calculate_summary_state(sc, ctx);
2671 mutex_unlock(&sc->mutex);
2678 struct ath_softc *sc = hw->priv;
2679 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2693 mutex_lock(&sc->mutex);
2695 spin_lock_bh(&sc->chan_lock);
2696 if (sc->next_chan || (sc->cur_chan != avp->chanctx))
2698 spin_unlock_bh(&sc->chan_lock);
2703 ath9k_cancel_pending_offchannel(sc);
2705 go_ctx = ath_is_go_chanctx_present(sc);
2712 spin_lock_bh(&sc->chan_lock);
2713 sc->sched.mgd_prepare_tx = true;
2716 spin_unlock_bh(&sc->chan_lock);
2719 init_completion(&sc->go_beacon);
2721 mutex_unlock(&sc->mutex);
2723 if (wait_for_completion_timeout(&sc->go_beacon,
2728 spin_lock_bh(&sc->chan_lock);
2729 sc->sched.mgd_prepare_tx = false;
2730 spin_unlock_bh(&sc->chan_lock);
2733 mutex_lock(&sc->mutex);
2740 spin_lock_bh(&sc->chan_lock);
2741 sc->next_chan = avp->chanctx;
2742 sc->sched.state = ATH_CHANCTX_STATE_FORCE_ACTIVE;
2743 spin_unlock_bh(&sc->chan_lock);
2745 ath_chanctx_set_next(sc, true);
2747 mutex_unlock(&sc->mutex);
2772 struct ath_softc *sc = hw->priv;
2775 mutex_lock(&sc->mutex);
2779 *dbm = sc->cur_chan->cur_txpower;
2780 mutex_unlock(&sc->mutex);