Lines Matching defs:sc

23 static int ath_set_channel(struct ath_softc *sc)
25 struct ath_hw *ah = sc->sc_ah;
27 struct ieee80211_hw *hw = sc->hw;
29 struct cfg80211_chan_def *chandef = &sc->cur_chan->chandef;
47 ath_update_survey_stats(sc);
57 if (!sc->cur_chan->offchannel && sc->cur_survey != &sc->survey[pos]) {
58 if (sc->cur_survey)
59 sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
61 sc->cur_survey = &sc->survey[pos];
63 memset(sc->cur_survey, 0, sizeof(struct survey_info));
64 sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
65 } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
66 memset(&sc->survey[pos], 0, sizeof(struct survey_info));
69 hchan = &sc->sc_ah->channels[pos];
70 r = ath_reset(sc, hchan);
79 ath_update_survey_nf(sc, old_pos);
96 sc->spec_priv.spectral_mode == SPECTRAL_CHANSCAN)
97 ath9k_cmn_spectral_scan_trigger(common, &sc->spec_priv);
103 void ath_chanctx_init(struct ath_softc *sc)
106 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
117 ctx = &sc->chanctx[i];
130 void ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx,
133 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
136 spin_lock_bh(&sc->chan_lock);
139 cur_chan = sc->cur_chan == ctx;
140 spin_unlock_bh(&sc->chan_lock);
148 ath_set_channel(sc);
157 struct ath_chanctx* ath_is_go_chanctx_present(struct ath_softc *sc)
163 spin_lock_bh(&sc->chan_lock);
165 ath_for_each_chanctx(sc, ctx) {
173 spin_unlock_bh(&sc->chan_lock);
179 spin_unlock_bh(&sc->chan_lock);
233 static u32 chanctx_event_delta(struct ath_softc *sc)
239 old = &sc->last_event_time;
242 sc->last_event_time = ts;
247 void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)
249 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
258 if (ctx == &sc->offchannel.chan) {
259 spin_lock_bh(&sc->chan_lock);
261 if (likely(sc->sched.channel_switch_time))
263 usecs_to_jiffies(sc->sched.channel_switch_time);
268 spin_unlock_bh(&sc->chan_lock);
296 ath_for_each_chanctx(sc, ctx) {
302 spin_lock_bh(&sc->chan_lock);
307 spin_unlock_bh(&sc->chan_lock);
311 ictx->flush_timeout = usecs_to_jiffies(sc->sched.channel_switch_time);
314 spin_unlock_bh(&sc->chan_lock);
318 spin_unlock_bh(&sc->chan_lock);
321 ath_chanctx_event(sc, NULL,
327 ath_chanctx_get_next(struct ath_softc *sc, struct ath_chanctx *ctx)
329 int idx = ctx - &sc->chanctx[0];
331 return &sc->chanctx[!idx];
334 static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc)
341 beacon_int = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval);
343 cur = sc->cur_chan;
344 prev = ath_chanctx_get_next(sc, cur);
373 static void ath_chanctx_setup_timer(struct ath_softc *sc, u32 tsf_time)
375 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
376 struct ath_hw *ah = sc->sc_ah;
379 ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, tsf_time, 1000000);
382 mod_timer(&sc->sched.timer, jiffies + timeout);
389 static void ath_chanctx_handle_bmiss(struct ath_softc *sc,
399 if (ctx->active && sc->sched.extend_absence) {
401 sc->sched.extend_absence = false;
408 if (ctx->active && sc->sched.beacon_miss >= 2) {
410 sc->sched.extend_absence = true;
414 static void ath_chanctx_offchannel_noa(struct ath_softc *sc,
419 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
423 avp->offchannel_duration = sc->sched.offchannel_duration;
440 static void ath_chanctx_set_periodic_noa(struct ath_softc *sc,
446 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
451 if (sc->sched.extend_absence)
453 sc->sched.channel_switch_time;
457 sc->sched.channel_switch_time;
460 sc->sched.extend_absence)
473 static void ath_chanctx_set_oneshot_noa(struct ath_softc *sc,
478 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
484 avp->noa_duration = duration + sc->sched.channel_switch_time;
494 void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
497 struct ath_hw *ah = sc->sc_ah;
508 spin_lock_bh(&sc->chan_lock);
511 sc->cur_chan->chandef.center_freq1,
513 chanctx_state_string(sc->sched.state),
514 chanctx_event_delta(sc));
529 if (avp->chanctx != sc->cur_chan) {
535 if (sc->sched.offchannel_pending && !sc->sched.wait_switch) {
536 sc->sched.offchannel_pending = false;
537 sc->next_chan = &sc->offchannel.chan;
538 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON;
543 ctx = ath_chanctx_get_next(sc, sc->cur_chan);
544 if (ctx->active && sc->sched.state == ATH_CHANCTX_STATE_IDLE) {
545 sc->next_chan = ctx;
546 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON;
552 if (sc->sched.state == ATH_CHANCTX_STATE_WAIT_FOR_TIMER) {
553 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON;
558 if (sc->sched.mgd_prepare_tx)
559 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON;
568 sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) {
576 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON)
581 sc->sched.beacon_pending = true;
582 sc->sched.next_tbtt = REG_READ(ah, AR_NEXT_TBTT_TIMER);
584 cur_conf = &sc->cur_chan->beacon;
588 tsf_time = sc->sched.next_tbtt + beacon_int / 4;
589 sc->sched.switch_start_time = tsf_time;
590 sc->cur_chan->last_beacon = sc->sched.next_tbtt;
597 if (sc->next_chan == &sc->offchannel.chan) {
598 ath_chanctx_offchannel_noa(sc, ctx, avp, tsf_time);
602 ath_chanctx_handle_bmiss(sc, ctx, avp);
610 if (sc->sched.mgd_prepare_tx) {
611 ath_chanctx_set_oneshot_noa(sc, avp, tsf_time,
626 (!avp->noa_duration || sc->sched.force_noa_update))
627 ath_chanctx_set_periodic_noa(sc, avp, cur_conf,
630 if (ctx->active && sc->sched.force_noa_update)
631 sc->sched.force_noa_update = false;
635 if (!sc->sched.beacon_pending) {
641 sc->sched.beacon_pending = false;
643 if (sc->sched.mgd_prepare_tx) {
644 sc->sched.mgd_prepare_tx = false;
645 complete(&sc->go_beacon);
651 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON)
657 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER;
658 ath_chanctx_setup_timer(sc, sc->sched.switch_start_time);
661 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_TIMER)
664 if (!sc->cur_chan->switch_after_beacon &&
665 sc->sched.beacon_pending)
666 sc->sched.beacon_miss++;
671 sc->sched.state = ATH_CHANCTX_STATE_SWITCH;
672 ieee80211_queue_work(sc->hw, &sc->chanctx_work);
676 sc->cur_chan == &sc->offchannel.chan)
679 sc->sched.beacon_pending = false;
680 sc->sched.beacon_miss = 0;
682 if (sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE ||
683 !sc->sched.beacon_adjust ||
684 !sc->cur_chan->tsf_val)
687 ath_chanctx_adjust_tbtt_delta(sc);
692 tsf_time = sc->sched.switch_start_time;
693 tsf_time -= (u32) sc->cur_chan->tsf_val +
694 ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL);
697 sc->sched.beacon_adjust = false;
698 ath_chanctx_setup_timer(sc, tsf_time);
701 if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE ||
702 avp->chanctx != sc->cur_chan)
708 sc->sched.state = ATH_CHANCTX_STATE_IDLE;
712 sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE ||
713 sc->cur_chan->switch_after_beacon ||
714 sc->cur_chan == &sc->offchannel.chan)
720 sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan);
721 cur_conf = &sc->cur_chan->beacon;
726 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER;
727 sc->sched.wait_switch = false;
731 if (sc->sched.extend_absence) {
732 sc->sched.beacon_miss = 0;
736 tsf_time -= sc->sched.channel_switch_time;
737 tsf_time += ath9k_hw_gettsf32(sc->sc_ah);
738 sc->sched.switch_start_time = tsf_time;
740 ath_chanctx_setup_timer(sc, tsf_time);
741 sc->sched.beacon_pending = true;
742 sc->sched.beacon_adjust = true;
745 if (sc->cur_chan == &sc->offchannel.chan ||
746 sc->cur_chan->switch_after_beacon)
749 sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan);
750 ieee80211_queue_work(sc->hw, &sc->chanctx_work);
753 if (sc->cur_chan->assigned) {
754 if (sc->next_chan && !sc->next_chan->assigned &&
755 sc->next_chan != &sc->offchannel.chan)
756 sc->sched.state = ATH_CHANCTX_STATE_IDLE;
760 ctx = ath_chanctx_get_next(sc, sc->cur_chan);
761 sc->sched.state = ATH_CHANCTX_STATE_IDLE;
765 sc->next_chan = ctx;
766 ieee80211_queue_work(sc->hw, &sc->chanctx_work);
774 spin_unlock_bh(&sc->chan_lock);
777 void ath_chanctx_beacon_sent_ev(struct ath_softc *sc,
780 if (sc->sched.beacon_pending)
781 ath_chanctx_event(sc, NULL, ev);
784 void ath_chanctx_beacon_recv_ev(struct ath_softc *sc,
787 ath_chanctx_event(sc, NULL, ev);
790 static int ath_scan_channel_duration(struct ath_softc *sc,
793 struct cfg80211_scan_request *req = sc->offchannel.scan_req;
801 static void ath_chanctx_switch(struct ath_softc *sc, struct ath_chanctx *ctx,
804 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
806 spin_lock_bh(&sc->chan_lock);
809 (sc->cur_chan != ctx) && (ctx == &sc->offchannel.chan)) {
813 sc->sched.offchannel_pending = true;
814 sc->sched.wait_switch = true;
815 sc->sched.offchannel_duration =
816 jiffies_to_usecs(sc->offchannel.duration) +
817 sc->sched.channel_switch_time;
819 spin_unlock_bh(&sc->chan_lock);
825 sc->next_chan = ctx;
832 if (sc->next_chan == &sc->offchannel.chan) {
833 sc->sched.offchannel_duration =
834 jiffies_to_usecs(sc->offchannel.duration) +
835 sc->sched.channel_switch_time;
841 sc->sched.offchannel_duration);
844 spin_unlock_bh(&sc->chan_lock);
845 ieee80211_queue_work(sc->hw, &sc->chanctx_work);
848 static void ath_chanctx_offchan_switch(struct ath_softc *sc,
851 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
858 ath_chanctx_switch(sc, &sc->offchannel.chan, &chandef);
861 static struct ath_chanctx *ath_chanctx_get_oper_chan(struct ath_softc *sc,
866 ath_for_each_chanctx(sc, ctx) {
876 return &sc->chanctx[0];
880 ath_scan_next_channel(struct ath_softc *sc)
882 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
883 struct cfg80211_scan_request *req = sc->offchannel.scan_req;
886 if (sc->offchannel.scan_idx >= req->n_channels) {
890 sc->offchannel.scan_idx,
893 sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
894 ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false),
901 sc->offchannel.scan_idx);
903 chan = req->channels[sc->offchannel.scan_idx++];
904 sc->offchannel.duration = ath_scan_channel_duration(sc, chan);
905 sc->offchannel.state = ATH_OFFCHANNEL_PROBE_SEND;
907 ath_chanctx_offchan_switch(sc, chan);
910 void ath_offchannel_next(struct ath_softc *sc)
914 if (sc->offchannel.scan_req) {
915 vif = sc->offchannel.scan_vif;
916 sc->offchannel.chan.txpower = vif->bss_conf.txpower;
917 ath_scan_next_channel(sc);
918 } else if (sc->offchannel.roc_vif) {
919 vif = sc->offchannel.roc_vif;
920 sc->offchannel.chan.txpower = vif->bss_conf.txpower;
921 sc->offchannel.duration =
922 msecs_to_jiffies(sc->offchannel.roc_duration);
923 sc->offchannel.state = ATH_OFFCHANNEL_ROC_START;
924 ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan);
926 spin_lock_bh(&sc->chan_lock);
927 sc->sched.offchannel_pending = false;
928 sc->sched.wait_switch = false;
929 spin_unlock_bh(&sc->chan_lock);
931 ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false),
933 sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
934 if (sc->ps_idle)
935 ath_cancel_work(sc);
939 void ath_roc_complete(struct ath_softc *sc, enum ath_roc_complete_reason reason)
941 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
943 sc->offchannel.roc_vif = NULL;
944 sc->offchannel.roc_chan = NULL;
949 ieee80211_remain_on_channel_expired(sc->hw);
953 ieee80211_remain_on_channel_expired(sc->hw);
960 ath_offchannel_next(sc);
961 ath9k_ps_restore(sc);
964 void ath_scan_complete(struct ath_softc *sc, bool abort)
966 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
976 sc->offchannel.scan_req = NULL;
977 sc->offchannel.scan_vif = NULL;
978 sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
979 ieee80211_scan_completed(sc->hw, &info);
981 spin_lock_bh(&sc->chan_lock);
983 sc->sched.force_noa_update = true;
984 spin_unlock_bh(&sc->chan_lock);
985 ath_offchannel_next(sc);
986 ath9k_ps_restore(sc);
989 static void ath_scan_send_probe(struct ath_softc *sc,
992 struct cfg80211_scan_request *req = sc->offchannel.scan_req;
993 struct ieee80211_vif *vif = sc->offchannel.scan_vif;
997 int band = sc->offchannel.chan.chandef.chan->band;
999 skb = ieee80211_probereq_get(sc->hw, vif->addr,
1013 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, NULL))
1016 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
1017 if (ath_tx_start(sc->hw, skb, &txctl))
1023 ieee80211_free_txskb(sc->hw, skb);
1026 static void ath_scan_channel_start(struct ath_softc *sc)
1028 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1029 struct cfg80211_scan_request *req = sc->offchannel.scan_req;
1032 if (!(sc->cur_chan->chandef.chan->flags & IEEE80211_CHAN_NO_IR) &&
1035 ath_scan_send_probe(sc, &req->ssids[i]);
1042 sc->offchannel.state = ATH_OFFCHANNEL_PROBE_WAIT;
1043 mod_timer(&sc->offchannel.timer, jiffies + sc->offchannel.duration);
1048 struct ath_softc *sc = from_timer(sc, t, sched.timer);
1049 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1054 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_TSF_TIMER);
1059 struct ath_softc *sc = from_timer(sc, t, offchannel.timer);
1061 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1064 __func__, offchannel_state_string(sc->offchannel.state));
1066 switch (sc->offchannel.state) {
1068 if (!sc->offchannel.scan_req)
1072 ctx = ath_chanctx_get_oper_chan(sc, true);
1078 sc->offchannel.state = ATH_OFFCHANNEL_SUSPEND;
1079 ath_chanctx_switch(sc, ctx, NULL);
1080 mod_timer(&sc->offchannel.timer, jiffies + HZ / 10);
1085 if (!sc->offchannel.scan_req)
1088 ath_scan_next_channel(sc);
1092 sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE;
1093 ath_roc_complete(sc, ATH_ROC_COMPLETE_EXPIRE);
1101 ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, struct ath_vif *avp,
1109 int band = sc->cur_chan->chandef.chan->band;
1116 skb = ieee80211_nullfunc_get(sc->hw, vif, -1, false);
1127 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) {
1137 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
1139 if (ath_tx_start(sc->hw, skb, &txctl)) {
1140 ieee80211_free_txskb(sc->hw, skb);
1148 ath_chanctx_send_ps_frame(struct ath_softc *sc, bool powersave)
1154 list_for_each_entry(avp, &sc->cur_chan->vifs, list) {
1155 if (ath_chanctx_send_vif_ps_frame(sc, avp, powersave))
1163 static bool ath_chanctx_defer_switch(struct ath_softc *sc)
1165 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1167 if (sc->cur_chan == &sc->offchannel.chan)
1170 switch (sc->sched.state) {
1174 if (!sc->cur_chan->switch_after_beacon)
1180 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON;
1189 static void ath_offchannel_channel_change(struct ath_softc *sc)
1191 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1194 __func__, offchannel_state_string(sc->offchannel.state));
1196 switch (sc->offchannel.state) {
1198 if (!sc->offchannel.scan_req)
1201 if (sc->cur_chan->chandef.chan !=
1202 sc->offchannel.chan.chandef.chan)
1205 ath_scan_channel_start(sc);
1208 if (!sc->offchannel.scan_req)
1211 ath_scan_complete(sc, false);
1214 if (sc->cur_chan != &sc->offchannel.chan)
1217 sc->offchannel.state = ATH_OFFCHANNEL_ROC_WAIT;
1218 mod_timer(&sc->offchannel.timer,
1219 jiffies + sc->offchannel.duration);
1220 ieee80211_ready_on_channel(sc->hw);
1229 void ath_chanctx_set_next(struct ath_softc *sc, bool force)
1231 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1238 spin_lock_bh(&sc->chan_lock);
1239 if (!sc->next_chan) {
1240 spin_unlock_bh(&sc->chan_lock);
1244 if (!force && ath_chanctx_defer_switch(sc)) {
1245 spin_unlock_bh(&sc->chan_lock);
1252 sc->cur_chan->chandef.center_freq1,
1253 sc->next_chan->chandef.center_freq1);
1255 if (sc->cur_chan != sc->next_chan) {
1258 sc->cur_chan->chandef.center_freq1);
1259 sc->cur_chan->stopped = true;
1260 spin_unlock_bh(&sc->chan_lock);
1262 if (sc->next_chan == &sc->offchannel.chan) {
1267 ath9k_chanctx_stop_queues(sc, sc->cur_chan);
1270 __ath9k_flush(sc->hw, ~0, true, false, false);
1272 if (ath_chanctx_send_ps_frame(sc, true))
1273 __ath9k_flush(sc->hw, BIT(IEEE80211_AC_VO),
1277 spin_lock_bh(&sc->chan_lock);
1279 if (sc->cur_chan != &sc->offchannel.chan) {
1280 ktime_get_raw_ts64(&sc->cur_chan->tsf_ts);
1281 sc->cur_chan->tsf_val = ath9k_hw_gettsf64(sc->sc_ah);
1284 old_ctx = sc->cur_chan;
1285 sc->cur_chan = sc->next_chan;
1286 sc->cur_chan->stopped = false;
1287 sc->next_chan = NULL;
1289 if (!sc->sched.offchannel_pending)
1290 sc->sched.offchannel_duration = 0;
1292 if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE)
1293 sc->sched.state = ATH_CHANCTX_STATE_IDLE;
1295 spin_unlock_bh(&sc->chan_lock);
1297 if (sc->sc_ah->chip_fullsleep ||
1298 memcmp(&sc->cur_chandef, &sc->cur_chan->chandef,
1299 sizeof(sc->cur_chandef))) {
1302 __func__, sc->cur_chan->chandef.center_freq1);
1303 ath_set_channel(sc);
1305 sc->sched.channel_switch_time =
1315 ath9k_chanctx_wake_queues(sc, old_ctx);
1318 ath_chanctx_send_ps_frame(sc, false);
1320 ath_offchannel_channel_change(sc);
1321 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_SWITCH);
1326 struct ath_softc *sc = container_of(work, struct ath_softc,
1328 mutex_lock(&sc->mutex);
1329 ath_chanctx_set_next(sc, false);
1330 mutex_unlock(&sc->mutex);
1333 void ath9k_offchannel_init(struct ath_softc *sc)
1336 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1347 ctx = &sc->offchannel.chan;
1358 sc->offchannel.chan.offchannel = true;
1361 void ath9k_init_channel_context(struct ath_softc *sc)
1363 INIT_WORK(&sc->chanctx_work, ath_chanctx_work);
1365 timer_setup(&sc->offchannel.timer, ath_offchannel_timer, 0);
1366 timer_setup(&sc->sched.timer, ath_chanctx_timer, 0);
1368 init_completion(&sc->go_beacon);
1371 void ath9k_deinit_channel_context(struct ath_softc *sc)
1373 cancel_work_sync(&sc->chanctx_work);
1385 void ath9k_chanctx_stop_queues(struct ath_softc *sc, struct ath_chanctx *ctx)
1387 struct ath_hw *ah = sc->sc_ah;
1390 if (ctx == &sc->offchannel.chan) {
1391 ieee80211_stop_queue(sc->hw,
1392 sc->hw->offchannel_tx_hw_queue);
1395 ieee80211_stop_queue(sc->hw,
1400 ieee80211_stop_queue(sc->hw, sc->hw->queues - 2);
1404 void ath9k_chanctx_wake_queues(struct ath_softc *sc, struct ath_chanctx *ctx)
1406 struct ath_hw *ah = sc->sc_ah;
1409 if (ctx == &sc->offchannel.chan) {
1410 ieee80211_wake_queue(sc->hw,
1411 sc->hw->offchannel_tx_hw_queue);
1414 ieee80211_wake_queue(sc->hw,
1419 ieee80211_wake_queue(sc->hw, sc->hw->queues - 2);
1426 static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp)
1428 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1429 struct ath_hw *ah = sc->sc_ah;
1435 ath9k_hw_gen_timer_stop(ah, sc->p2p_ps_timer);
1437 tsf = ath9k_hw_gettsf32(sc->sc_ah);
1452 ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, target_tsf, 1000000);
1455 static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
1460 if (!sc->p2p_ps_timer)
1466 sc->p2p_ps_vif = avp;
1468 if (sc->ps_flags & PS_BEACON_SYNC)
1471 tsf = ath9k_hw_gettsf32(sc->sc_ah);
1473 ath9k_update_p2p_ps_timer(sc, avp);
1476 static u8 ath9k_get_ctwin(struct ath_softc *sc, struct ath_vif *avp)
1478 struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon;
1500 void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp,
1530 noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp);
1536 u32 interval = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval);
1557 struct ath_softc *sc = priv;
1558 struct ath_vif *avp = sc->p2p_ps_vif;
1564 del_timer_sync(&sc->sched.timer);
1565 ath9k_hw_gen_timer_stop(sc->sc_ah, sc->p2p_ps_timer);
1566 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_TSF_TIMER);
1568 if (!avp || avp->chanctx != sc->cur_chan)
1571 tsf = ath9k_hw_gettsf32(sc->sc_ah);
1581 ath9k_update_p2p_ps_timer(sc, avp);
1596 ath_tx_aggr_sleep(sta, sc, an);
1598 ath_tx_aggr_wakeup(sc, an);
1604 void ath9k_p2p_bss_info_changed(struct ath_softc *sc,
1609 spin_lock_bh(&sc->sc_pcu_lock);
1610 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1611 ath9k_update_p2p_ps(sc, vif);
1612 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1613 spin_unlock_bh(&sc->sc_pcu_lock);
1616 void ath9k_p2p_beacon_sync(struct ath_softc *sc)
1618 if (sc->p2p_ps_vif)
1619 ath9k_update_p2p_ps(sc, sc->p2p_ps_vif->vif);
1622 void ath9k_p2p_remove_vif(struct ath_softc *sc,
1627 spin_lock_bh(&sc->sc_pcu_lock);
1628 if (avp == sc->p2p_ps_vif) {
1629 sc->p2p_ps_vif = NULL;
1630 ath9k_update_p2p_ps_timer(sc, NULL);
1632 spin_unlock_bh(&sc->sc_pcu_lock);
1635 int ath9k_init_p2p(struct ath_softc *sc)
1637 sc->p2p_ps_timer = ath_gen_timer_alloc(sc->sc_ah, ath9k_p2p_ps_timer,
1638 NULL, sc, AR_FIRST_NDP_TIMER);
1639 if (!sc->p2p_ps_timer)
1645 void ath9k_deinit_p2p(struct ath_softc *sc)
1647 if (sc->p2p_ps_timer)
1648 ath_gen_timer_free(sc->sc_ah, sc->p2p_ps_timer);