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);
1065 static void ath9k_update_bssid_mask(struct ath_softc *sc,
1069 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1089 sc->hw->wiphy->perm_addr[i]);
1093 /* Called with sc->mutex held. */
1094 void ath9k_calculate_iter_data(struct ath_softc *sc,
1111 ath9k_update_bssid_mask(sc, ctx, iter_data);
1114 static void ath9k_set_assoc_state(struct ath_softc *sc,
1117 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1125 ath9k_hw_write_associd(sc->sc_ah);
1129 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
1131 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1132 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
1133 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1136 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
1137 ath9k_mci_update_wlan_channels(sc, false);
1145 static void ath9k_set_offchannel_state(struct ath_softc *sc)
1147 struct ath_hw *ah = sc->sc_ah;
1151 ath9k_ps_wakeup(sc);
1153 if (sc->offchannel.state < ATH_OFFCHANNEL_ROC_START)
1154 vif = sc->offchannel.scan_vif;
1156 vif = sc->offchannel.roc_vif;
1172 ath9k_hw_write_associd(sc->sc_ah);
1177 ath9k_ps_restore(sc);
1181 /* Called with sc->mutex held. */
1182 void ath9k_calculate_summary_state(struct ath_softc *sc,
1185 struct ath_hw *ah = sc->sc_ah;
1189 ath_chanctx_check_active(sc, ctx);
1191 if (ctx != sc->cur_chan)
1195 if (ctx == &sc->offchannel.chan)
1196 return ath9k_set_offchannel_state(sc);
1199 ath9k_ps_wakeup(sc);
1200 ath9k_calculate_iter_data(sc, ctx, &iter_data);
1214 ath9k_beacon_ensure_primary_slot(sc);
1243 ath9k_set_assoc_state(sc, iter_data.primary_sta,
1250 ath9k_hw_write_associd(sc->sc_ah);
1251 if (ath9k_hw_mci_is_enabled(sc->sc_ah))
1252 ath9k_mci_update_wlan_channels(sc, true);
1255 sc->nbcnvifs = iter_data.nbcnvifs;
1256 ath9k_beacon_config(sc, iter_data.primary_beacon_vif,
1274 ath9k_ps_restore(sc);
1288 /* Called with sc->mutex held. */
1289 void ath9k_set_txpower(struct ath_softc *sc, struct ieee80211_vif *vif)
1292 struct ath_hw *ah = sc->sc_ah;
1295 ath9k_ps_wakeup(sc);
1299 sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
1302 power = sc->hw->conf.power_level;
1304 power = sc->hw->conf.power_level;
1306 sc->cur_chan->txpower = 2 * power;
1307 ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false);
1308 sc->cur_chan->cur_txpower = reg->max_power_level;
1309 ath9k_ps_restore(sc);
1333 struct ath_softc *sc = hw->priv;
1334 struct ath_hw *ah = sc->sc_ah;
1339 mutex_lock(&sc->mutex);
1341 if (sc->cur_chan->nvifs >= 1) {
1342 mutex_unlock(&sc->mutex);
1345 sc->tx99_vif = vif;
1349 sc->cur_chan->nvifs++;
1355 ath9k_beacon_assign_slot(sc, vif);
1359 avp->chanctx = sc->cur_chan;
1363 ath9k_calculate_summary_state(sc, avp->chanctx);
1367 ath9k_set_txpower(sc, vif);
1369 an->sc = sc;
1373 ath_tx_node_init(sc, an);
1375 mutex_unlock(&sc->mutex);
1384 struct ath_softc *sc = hw->priv;
1385 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1388 mutex_lock(&sc->mutex);
1391 mutex_unlock(&sc->mutex);
1398 ath9k_beacon_remove_slot(sc, vif);
1404 ath9k_beacon_assign_slot(sc, vif);
1407 ath9k_calculate_summary_state(sc, avp->chanctx);
1409 ath9k_set_txpower(sc, vif);
1411 mutex_unlock(&sc->mutex);
1418 struct ath_softc *sc = hw->priv;
1419 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1424 mutex_lock(&sc->mutex);
1426 ath9k_p2p_remove_vif(sc, vif);
1428 sc->cur_chan->nvifs--;
1429 sc->tx99_vif = NULL;
1434 ath9k_beacon_remove_slot(sc, vif);
1436 ath_tx_node_cleanup(sc, &avp->mcast_node);
1438 ath9k_calculate_summary_state(sc, avp->chanctx);
1440 ath9k_set_txpower(sc, NULL);
1442 mutex_unlock(&sc->mutex);
1445 static void ath9k_enable_ps(struct ath_softc *sc)
1447 struct ath_hw *ah = sc->sc_ah;
1453 sc->ps_enabled = true;
1464 static void ath9k_disable_ps(struct ath_softc *sc)
1466 struct ath_hw *ah = sc->sc_ah;
1472 sc->ps_enabled = false;
1476 sc->ps_flags &= ~(PS_WAIT_FOR_BEACON |
1490 struct ath_softc *sc = hw->priv;
1491 struct ath_hw *ah = sc->sc_ah;
1494 struct ath_chanctx *ctx = sc->cur_chan;
1496 ath9k_ps_wakeup(sc);
1497 mutex_lock(&sc->mutex);
1500 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1501 if (sc->ps_idle) {
1502 ath_cancel_work(sc);
1503 ath9k_stop_btcoex(sc);
1505 ath9k_start_btcoex(sc);
1510 ath_chanctx_set_channel(sc, ctx, &ctx->chandef);
1522 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1524 ath9k_enable_ps(sc);
1526 ath9k_disable_ps(sc);
1527 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1533 sc->sc_ah->is_monitoring = true;
1536 sc->sc_ah->is_monitoring = false;
1542 ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef);
1546 ath9k_set_txpower(sc, NULL);
1548 mutex_unlock(&sc->mutex);
1549 ath9k_ps_restore(sc);
1564 /* FIXME: sc->sc_full_reset ? */
1570 struct ath_softc *sc = hw->priv;
1576 spin_lock_bh(&sc->chan_lock);
1577 ath_for_each_chanctx(sc, ctx)
1580 sc->offchannel.chan.rxfilter = *total_flags;
1582 spin_unlock_bh(&sc->chan_lock);
1584 ath9k_ps_wakeup(sc);
1585 rfilt = ath_calcrxfilter(sc);
1586 ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
1587 ath9k_ps_restore(sc);
1589 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, "Set HW RX filter: 0x%x\n",
1597 struct ath_softc *sc = hw->priv;
1598 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1603 ath_node_attach(sc, sta, vif);
1618 static void ath9k_del_ps_key(struct ath_softc *sc,
1622 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1637 struct ath_softc *sc = hw->priv;
1639 ath9k_del_ps_key(sc, vif, sta);
1640 ath_node_detach(sc, sta);
1651 struct ath_softc *sc = hw->priv;
1652 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1671 ath_chanctx_event(sc, vif,
1697 struct ath_softc *sc = hw->priv;
1703 ath_tx_aggr_sleep(sta, sc, an);
1704 ath9k_sta_set_tx_filter(sc->sc_ah, an, true);
1707 ath9k_sta_set_tx_filter(sc->sc_ah, an, false);
1709 ath_tx_aggr_wakeup(sc, an);
1719 struct ath_softc *sc = hw->priv;
1720 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1728 txq = sc->tx.txq_map[queue];
1730 ath9k_ps_wakeup(sc);
1731 mutex_lock(&sc->mutex);
1745 ath_update_max_aggr_framelen(sc, queue, qi.tqi_burstTime);
1746 ret = ath_txq_update(sc, txq->axq_qnum, &qi);
1750 mutex_unlock(&sc->mutex);
1751 ath9k_ps_restore(sc);
1762 struct ath_softc *sc = hw->priv;
1763 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1794 mutex_lock(&sc->mutex);
1795 ath9k_ps_wakeup(sc);
1804 ath9k_pending_key_del(sc, i);
1809 ath9k_del_ps_key(sc, vif, sta);
1819 if (sc->sc_ah->sw_mgmt_crypto_tx &&
1835 if (ath9k_txq_has_key(sc, key->hw_key_idx)) {
1839 set_bit(key->hw_key_idx, sc->sc_ah->pending_del_keymap);
1858 ath9k_ps_restore(sc);
1859 mutex_unlock(&sc->mutex);
1874 struct ath_softc *sc = hw->priv;
1875 struct ath_hw *ah = sc->sc_ah;
1880 ath9k_ps_wakeup(sc);
1881 mutex_lock(&sc->mutex);
1891 ath9k_calculate_summary_state(sc, avp->chanctx);
1898 ath9k_hw_write_associd(sc->sc_ah);
1904 ath9k_calculate_summary_state(sc, avp->chanctx);
1907 if ((avp->chanctx == sc->cur_chan) &&
1920 sc->beacon.slottime = slottime;
1921 sc->beacon.updateslot = UPDATE;
1929 ath9k_p2p_bss_info_changed(sc, vif);
1932 ath_check_ani(sc);
1937 ath9k_set_txpower(sc, vif);
1940 mutex_unlock(&sc->mutex);
1941 ath9k_ps_restore(sc);
1948 struct ath_softc *sc = hw->priv;
1952 mutex_lock(&sc->mutex);
1953 ath9k_ps_wakeup(sc);
1955 if (sc->cur_chan == avp->chanctx) {
1956 tsf = ath9k_hw_gettsf64(sc->sc_ah);
1958 tsf = sc->cur_chan->tsf_val +
1959 ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL);
1962 ath9k_ps_restore(sc);
1963 mutex_unlock(&sc->mutex);
1972 struct ath_softc *sc = hw->priv;
1975 mutex_lock(&sc->mutex);
1976 ath9k_ps_wakeup(sc);
1979 if (sc->cur_chan == avp->chanctx)
1980 ath9k_hw_settsf64(sc->sc_ah, tsf);
1982 ath9k_ps_restore(sc);
1983 mutex_unlock(&sc->mutex);
1988 struct ath_softc *sc = hw->priv;
1991 mutex_lock(&sc->mutex);
1993 ath9k_ps_wakeup(sc);
1995 if (sc->cur_chan == avp->chanctx)
1996 ath9k_hw_reset_tsf(sc->sc_ah);
1998 ath9k_ps_restore(sc);
2000 mutex_unlock(&sc->mutex);
2007 struct ath_softc *sc = hw->priv;
2008 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2018 mutex_lock(&sc->mutex);
2032 ath9k_ps_wakeup(sc);
2033 ret = ath_tx_aggr_start(sc, sta, tid, ssn);
2036 ath9k_ps_restore(sc);
2043 ath9k_ps_wakeup(sc);
2044 ath_tx_aggr_stop(sc, sta, tid);
2047 ath9k_ps_restore(sc);
2055 ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n");
2058 mutex_unlock(&sc->mutex);
2066 struct ath_softc *sc = hw->priv;
2067 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2078 ath_update_survey_stats(sc);
2096 memcpy(survey, &sc->survey[pos], sizeof(*survey));
2103 static void ath9k_enable_dynack(struct ath_softc *sc)
2107 struct ath_hw *ah = sc->sc_ah;
2112 rfilt = ath_calcrxfilter(sc);
2120 struct ath_softc *sc = hw->priv;
2121 struct ath_hw *ah = sc->sc_ah;
2126 mutex_lock(&sc->mutex);
2134 rfilt = ath_calcrxfilter(sc);
2137 ath9k_ps_wakeup(sc);
2139 ath9k_ps_restore(sc);
2141 ath9k_enable_dynack(sc);
2144 mutex_unlock(&sc->mutex);
2147 static bool ath9k_has_tx_pending(struct ath_softc *sc,
2153 if (!ATH_TXQ_SETUP(sc, i))
2156 npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i],
2168 struct ath_softc *sc = hw->priv;
2169 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2179 * sc->mutex lock to allow the channel scheduler
2189 mutex_lock(&sc->mutex);
2191 mutex_unlock(&sc->mutex);
2197 struct ath_softc *sc = hw->priv;
2198 struct ath_hw *ah = sc->sc_ah;
2203 cancel_delayed_work_sync(&sc->hw_check_work);
2215 spin_lock_bh(&sc->chan_lock);
2219 timeout = sc->cur_chan->flush_timeout;
2220 spin_unlock_bh(&sc->chan_lock);
2225 if (wait_event_timeout(sc->tx_wait, !ath9k_has_tx_pending(sc, sw_pending),
2230 ath9k_ps_wakeup(sc);
2231 spin_lock_bh(&sc->sc_pcu_lock);
2232 drain_txq = ath_drain_all_txq(sc);
2233 spin_unlock_bh(&sc->sc_pcu_lock);
2236 ath_reset(sc, NULL);
2238 ath9k_ps_restore(sc);
2241 ieee80211_queue_delayed_work(hw, &sc->hw_check_work,
2247 struct ath_softc *sc = hw->priv;
2249 return ath9k_has_tx_pending(sc, true);
2254 struct ath_softc *sc = hw->priv;
2255 struct ath_hw *ah = sc->sc_ah;
2263 vif = sc->beacon.bslot[0];
2272 if (!sc->beacon.tx_processed && !edma) {
2273 tasklet_disable(&sc->bcon_tasklet);
2283 sc->beacon.tx_processed = true;
2284 sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
2287 tasklet_enable(&sc->bcon_tasklet);
2290 return sc->beacon.tx_last;
2296 struct ath_softc *sc = hw->priv;
2297 struct ath_hw *ah = sc->sc_ah;
2344 struct ath_softc *sc = hw->priv;
2345 struct ath_hw *ah = sc->sc_ah;
2353 sc->ant_rx = rx_ant;
2354 sc->ant_tx = tx_ant;
2373 struct ath_softc *sc = hw->priv;
2375 *tx_ant = sc->ant_tx;
2376 *rx_ant = sc->ant_rx;
2384 struct ath_softc *sc = hw->priv;
2385 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2392 struct ath_softc *sc = hw->priv;
2393 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2399 static void ath9k_cancel_pending_offchannel(struct ath_softc *sc)
2401 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2403 if (sc->offchannel.roc_vif) {
2407 del_timer_sync(&sc->offchannel.timer);
2408 if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START)
2409 ath_roc_complete(sc, ATH_ROC_COMPLETE_ABORT);
2416 del_timer_sync(&sc->offchannel.timer);
2417 ath_scan_complete(sc, true);
2425 struct ath_softc *sc = hw->priv;
2426 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2429 mutex_lock(&sc->mutex);
2431 if (WARN_ON(sc->offchannel.scan_req)) {
2436 ath9k_ps_wakeup(sc);
2438 sc->offchannel.scan_vif = vif;
2439 sc->offchannel.scan_req = req;
2440 sc->offchannel.scan_idx = 0;
2445 if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE) {
2447 ath_offchannel_next(sc);
2451 mutex_unlock(&sc->mutex);
2459 struct ath_softc *sc = hw->priv;
2460 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2464 mutex_lock(&sc->mutex);
2465 del_timer_sync(&sc->offchannel.timer);
2466 ath_scan_complete(sc, true);
2467 mutex_unlock(&sc->mutex);
2475 struct ath_softc *sc = hw->priv;
2476 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2479 mutex_lock(&sc->mutex);
2481 if (WARN_ON(sc->offchannel.roc_vif)) {
2486 ath9k_ps_wakeup(sc);
2487 sc->offchannel.roc_vif = vif;
2488 sc->offchannel.roc_chan = chan;
2489 sc->offchannel.roc_duration = duration;
2495 if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE) {
2497 ath_offchannel_next(sc);
2501 mutex_unlock(&sc->mutex);
2509 struct ath_softc *sc = hw->priv;
2510 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2512 mutex_lock(&sc->mutex);
2515 del_timer_sync(&sc->offchannel.timer);
2517 if (sc->offchannel.roc_vif) {
2518 if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START)
2519 ath_roc_complete(sc, ATH_ROC_COMPLETE_CANCEL);
2522 mutex_unlock(&sc->mutex);
2530 struct ath_softc *sc = hw->priv;
2531 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2535 mutex_lock(&sc->mutex);
2537 ath_for_each_chanctx(sc, ctx) {
2544 pos = ctx - &sc->chanctx[0];
2551 ath_chanctx_set_channel(sc, ctx, &conf->def);
2553 mutex_unlock(&sc->mutex);
2557 mutex_unlock(&sc->mutex);
2565 struct ath_softc *sc = hw->priv;
2566 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2569 mutex_lock(&sc->mutex);
2577 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_UNASSIGN);
2579 mutex_unlock(&sc->mutex);
2586 struct ath_softc *sc = hw->priv;
2587 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2590 mutex_lock(&sc->mutex);
2594 ath_chanctx_set_channel(sc, ctx, &conf->def);
2595 mutex_unlock(&sc->mutex);
2603 struct ath_softc *sc = hw->priv;
2604 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2609 ath9k_cancel_pending_offchannel(sc);
2611 mutex_lock(&sc->mutex);
2621 ath9k_calculate_summary_state(sc, ctx);
2625 mutex_unlock(&sc->mutex);
2635 struct ath_softc *sc = hw->priv;
2636 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2641 ath9k_cancel_pending_offchannel(sc);
2643 mutex_lock(&sc->mutex);
2653 ath9k_calculate_summary_state(sc, ctx);
2657 mutex_unlock(&sc->mutex);
2664 struct ath_softc *sc = hw->priv;
2665 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2679 mutex_lock(&sc->mutex);
2681 spin_lock_bh(&sc->chan_lock);
2682 if (sc->next_chan || (sc->cur_chan != avp->chanctx))
2684 spin_unlock_bh(&sc->chan_lock);
2689 ath9k_cancel_pending_offchannel(sc);
2691 go_ctx = ath_is_go_chanctx_present(sc);
2698 spin_lock_bh(&sc->chan_lock);
2699 sc->sched.mgd_prepare_tx = true;
2702 spin_unlock_bh(&sc->chan_lock);
2705 init_completion(&sc->go_beacon);
2707 mutex_unlock(&sc->mutex);
2709 if (wait_for_completion_timeout(&sc->go_beacon,
2714 spin_lock_bh(&sc->chan_lock);
2715 sc->sched.mgd_prepare_tx = false;
2716 spin_unlock_bh(&sc->chan_lock);
2719 mutex_lock(&sc->mutex);
2726 spin_lock_bh(&sc->chan_lock);
2727 sc->next_chan = avp->chanctx;
2728 sc->sched.state = ATH_CHANCTX_STATE_FORCE_ACTIVE;
2729 spin_unlock_bh(&sc->chan_lock);
2731 ath_chanctx_set_next(sc, true);
2733 mutex_unlock(&sc->mutex);
2758 struct ath_softc *sc = hw->priv;
2761 mutex_lock(&sc->mutex);
2765 *dbm = sc->cur_chan->cur_txpower;
2766 mutex_unlock(&sc->mutex);