Lines Matching refs:sc

23 static int ath_set_channel(struct ath_softc *sc)  in ath_set_channel()  argument
25 struct ath_hw *ah = sc->sc_ah; in ath_set_channel()
27 struct ieee80211_hw *hw = sc->hw; in ath_set_channel()
29 struct cfg80211_chan_def *chandef = &sc->cur_chan->chandef; in ath_set_channel()
46 ath_update_survey_stats(sc); in ath_set_channel()
56 if (!sc->cur_chan->offchannel && sc->cur_survey != &sc->survey[pos]) { in ath_set_channel()
57 if (sc->cur_survey) in ath_set_channel()
58 sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE; in ath_set_channel()
60 sc->cur_survey = &sc->survey[pos]; in ath_set_channel()
62 memset(sc->cur_survey, 0, sizeof(struct survey_info)); in ath_set_channel()
63 sc->cur_survey->filled |= SURVEY_INFO_IN_USE; in ath_set_channel()
64 } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) { in ath_set_channel()
65 memset(&sc->survey[pos], 0, sizeof(struct survey_info)); in ath_set_channel()
68 hchan = &sc->sc_ah->channels[pos]; in ath_set_channel()
69 r = ath_reset(sc, hchan); in ath_set_channel()
78 ath_update_survey_nf(sc, old_pos); in ath_set_channel()
95 sc->spec_priv.spectral_mode == SPECTRAL_CHANSCAN) in ath_set_channel()
96 ath9k_cmn_spectral_scan_trigger(common, &sc->spec_priv); in ath_set_channel()
102 void ath_chanctx_init(struct ath_softc *sc) in ath_chanctx_init() argument
105 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_init()
116 ctx = &sc->chanctx[i]; in ath_chanctx_init()
126 void ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx, in ath_chanctx_set_channel() argument
129 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_channel()
132 spin_lock_bh(&sc->chan_lock); in ath_chanctx_set_channel()
135 cur_chan = sc->cur_chan == ctx; in ath_chanctx_set_channel()
136 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_channel()
144 ath_set_channel(sc); in ath_chanctx_set_channel()
153 struct ath_chanctx* ath_is_go_chanctx_present(struct ath_softc *sc) in ath_is_go_chanctx_present() argument
159 spin_lock_bh(&sc->chan_lock); in ath_is_go_chanctx_present()
161 ath_for_each_chanctx(sc, ctx) { in ath_is_go_chanctx_present()
169 spin_unlock_bh(&sc->chan_lock); in ath_is_go_chanctx_present()
175 spin_unlock_bh(&sc->chan_lock); in ath_is_go_chanctx_present()
229 void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx) in ath_chanctx_check_active() argument
231 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_check_active()
240 if (ctx == &sc->offchannel.chan) { in ath_chanctx_check_active()
241 spin_lock_bh(&sc->chan_lock); in ath_chanctx_check_active()
243 if (likely(sc->sched.channel_switch_time)) in ath_chanctx_check_active()
245 usecs_to_jiffies(sc->sched.channel_switch_time); in ath_chanctx_check_active()
250 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_check_active()
278 ath_for_each_chanctx(sc, ctx) { in ath_chanctx_check_active()
284 spin_lock_bh(&sc->chan_lock); in ath_chanctx_check_active()
289 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_check_active()
293 ictx->flush_timeout = usecs_to_jiffies(sc->sched.channel_switch_time); in ath_chanctx_check_active()
296 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_check_active()
300 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_check_active()
303 ath_chanctx_event(sc, NULL, in ath_chanctx_check_active()
309 ath_chanctx_get_next(struct ath_softc *sc, struct ath_chanctx *ctx) in ath_chanctx_get_next() argument
311 int idx = ctx - &sc->chanctx[0]; in ath_chanctx_get_next()
313 return &sc->chanctx[!idx]; in ath_chanctx_get_next()
316 static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc) in ath_chanctx_adjust_tbtt_delta() argument
323 beacon_int = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); in ath_chanctx_adjust_tbtt_delta()
325 cur = sc->cur_chan; in ath_chanctx_adjust_tbtt_delta()
326 prev = ath_chanctx_get_next(sc, cur); in ath_chanctx_adjust_tbtt_delta()
355 static void ath_chanctx_setup_timer(struct ath_softc *sc, u32 tsf_time) in ath_chanctx_setup_timer() argument
357 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_setup_timer()
358 struct ath_hw *ah = sc->sc_ah; in ath_chanctx_setup_timer()
360 ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, tsf_time, 1000000); in ath_chanctx_setup_timer()
363 mod_timer(&sc->sched.timer, jiffies + tsf_time); in ath_chanctx_setup_timer()
369 static void ath_chanctx_handle_bmiss(struct ath_softc *sc, in ath_chanctx_handle_bmiss() argument
379 if (ctx->active && sc->sched.extend_absence) { in ath_chanctx_handle_bmiss()
381 sc->sched.extend_absence = false; in ath_chanctx_handle_bmiss()
388 if (ctx->active && sc->sched.beacon_miss >= 2) { in ath_chanctx_handle_bmiss()
390 sc->sched.extend_absence = true; in ath_chanctx_handle_bmiss()
394 static void ath_chanctx_offchannel_noa(struct ath_softc *sc, in ath_chanctx_offchannel_noa() argument
399 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_offchannel_noa()
403 avp->offchannel_duration = sc->sched.offchannel_duration; in ath_chanctx_offchannel_noa()
420 static void ath_chanctx_set_periodic_noa(struct ath_softc *sc, in ath_chanctx_set_periodic_noa() argument
426 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_periodic_noa()
431 if (sc->sched.extend_absence) in ath_chanctx_set_periodic_noa()
433 sc->sched.channel_switch_time; in ath_chanctx_set_periodic_noa()
437 sc->sched.channel_switch_time; in ath_chanctx_set_periodic_noa()
440 sc->sched.extend_absence) in ath_chanctx_set_periodic_noa()
453 static void ath_chanctx_set_oneshot_noa(struct ath_softc *sc, in ath_chanctx_set_oneshot_noa() argument
458 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_oneshot_noa()
464 avp->noa_duration = duration + sc->sched.channel_switch_time; in ath_chanctx_set_oneshot_noa()
474 void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, in ath_chanctx_event() argument
477 struct ath_hw *ah = sc->sc_ah; in ath_chanctx_event()
488 spin_lock_bh(&sc->chan_lock); in ath_chanctx_event()
491 sc->cur_chan->chandef.center_freq1, in ath_chanctx_event()
493 chanctx_state_string(sc->sched.state)); in ath_chanctx_event()
508 if (avp->chanctx != sc->cur_chan) { in ath_chanctx_event()
514 if (sc->sched.offchannel_pending && !sc->sched.wait_switch) { in ath_chanctx_event()
515 sc->sched.offchannel_pending = false; in ath_chanctx_event()
516 sc->next_chan = &sc->offchannel.chan; in ath_chanctx_event()
517 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_event()
522 ctx = ath_chanctx_get_next(sc, sc->cur_chan); in ath_chanctx_event()
523 if (ctx->active && sc->sched.state == ATH_CHANCTX_STATE_IDLE) { in ath_chanctx_event()
524 sc->next_chan = ctx; in ath_chanctx_event()
525 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_event()
531 if (sc->sched.state == ATH_CHANCTX_STATE_WAIT_FOR_TIMER) { in ath_chanctx_event()
532 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_event()
537 if (sc->sched.mgd_prepare_tx) in ath_chanctx_event()
538 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_event()
547 sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) { in ath_chanctx_event()
555 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) in ath_chanctx_event()
560 sc->sched.beacon_pending = true; in ath_chanctx_event()
561 sc->sched.next_tbtt = REG_READ(ah, AR_NEXT_TBTT_TIMER); in ath_chanctx_event()
563 cur_conf = &sc->cur_chan->beacon; in ath_chanctx_event()
567 tsf_time = sc->sched.next_tbtt + beacon_int / 4; in ath_chanctx_event()
568 sc->sched.switch_start_time = tsf_time; in ath_chanctx_event()
569 sc->cur_chan->last_beacon = sc->sched.next_tbtt; in ath_chanctx_event()
576 if (sc->next_chan == &sc->offchannel.chan) { in ath_chanctx_event()
577 ath_chanctx_offchannel_noa(sc, ctx, avp, tsf_time); in ath_chanctx_event()
581 ath_chanctx_handle_bmiss(sc, ctx, avp); in ath_chanctx_event()
589 if (sc->sched.mgd_prepare_tx) { in ath_chanctx_event()
590 ath_chanctx_set_oneshot_noa(sc, avp, tsf_time, in ath_chanctx_event()
605 (!avp->noa_duration || sc->sched.force_noa_update)) in ath_chanctx_event()
606 ath_chanctx_set_periodic_noa(sc, avp, cur_conf, in ath_chanctx_event()
609 if (ctx->active && sc->sched.force_noa_update) in ath_chanctx_event()
610 sc->sched.force_noa_update = false; in ath_chanctx_event()
614 if (!sc->sched.beacon_pending) { in ath_chanctx_event()
620 sc->sched.beacon_pending = false; in ath_chanctx_event()
622 if (sc->sched.mgd_prepare_tx) { in ath_chanctx_event()
623 sc->sched.mgd_prepare_tx = false; in ath_chanctx_event()
624 complete(&sc->go_beacon); in ath_chanctx_event()
630 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) in ath_chanctx_event()
636 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER; in ath_chanctx_event()
637 ath_chanctx_setup_timer(sc, sc->sched.switch_start_time); in ath_chanctx_event()
640 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_TIMER) in ath_chanctx_event()
643 if (!sc->cur_chan->switch_after_beacon && in ath_chanctx_event()
644 sc->sched.beacon_pending) in ath_chanctx_event()
645 sc->sched.beacon_miss++; in ath_chanctx_event()
650 sc->sched.state = ATH_CHANCTX_STATE_SWITCH; in ath_chanctx_event()
651 ieee80211_queue_work(sc->hw, &sc->chanctx_work); in ath_chanctx_event()
655 sc->cur_chan == &sc->offchannel.chan) in ath_chanctx_event()
658 sc->sched.beacon_pending = false; in ath_chanctx_event()
659 sc->sched.beacon_miss = 0; in ath_chanctx_event()
661 if (sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE || in ath_chanctx_event()
662 !sc->sched.beacon_adjust || in ath_chanctx_event()
663 !sc->cur_chan->tsf_val) in ath_chanctx_event()
666 ath_chanctx_adjust_tbtt_delta(sc); in ath_chanctx_event()
671 tsf_time = sc->sched.switch_start_time; in ath_chanctx_event()
672 tsf_time -= (u32) sc->cur_chan->tsf_val + in ath_chanctx_event()
673 ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, NULL); in ath_chanctx_event()
676 sc->sched.beacon_adjust = false; in ath_chanctx_event()
677 ath_chanctx_setup_timer(sc, tsf_time); in ath_chanctx_event()
680 if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE || in ath_chanctx_event()
681 avp->chanctx != sc->cur_chan) in ath_chanctx_event()
687 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_event()
691 sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE || in ath_chanctx_event()
692 sc->cur_chan->switch_after_beacon || in ath_chanctx_event()
693 sc->cur_chan == &sc->offchannel.chan) in ath_chanctx_event()
699 sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan); in ath_chanctx_event()
700 cur_conf = &sc->cur_chan->beacon; in ath_chanctx_event()
705 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER; in ath_chanctx_event()
706 sc->sched.wait_switch = false; in ath_chanctx_event()
710 if (sc->sched.extend_absence) { in ath_chanctx_event()
711 sc->sched.beacon_miss = 0; in ath_chanctx_event()
715 tsf_time -= sc->sched.channel_switch_time; in ath_chanctx_event()
716 tsf_time += ath9k_hw_gettsf32(sc->sc_ah); in ath_chanctx_event()
717 sc->sched.switch_start_time = tsf_time; in ath_chanctx_event()
719 ath_chanctx_setup_timer(sc, tsf_time); in ath_chanctx_event()
720 sc->sched.beacon_pending = true; in ath_chanctx_event()
721 sc->sched.beacon_adjust = true; in ath_chanctx_event()
724 if (sc->cur_chan == &sc->offchannel.chan || in ath_chanctx_event()
725 sc->cur_chan->switch_after_beacon) in ath_chanctx_event()
728 sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan); in ath_chanctx_event()
729 ieee80211_queue_work(sc->hw, &sc->chanctx_work); in ath_chanctx_event()
732 if (sc->cur_chan->assigned) { in ath_chanctx_event()
733 if (sc->next_chan && !sc->next_chan->assigned && in ath_chanctx_event()
734 sc->next_chan != &sc->offchannel.chan) in ath_chanctx_event()
735 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_event()
739 ctx = ath_chanctx_get_next(sc, sc->cur_chan); in ath_chanctx_event()
740 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_event()
744 sc->next_chan = ctx; in ath_chanctx_event()
745 ieee80211_queue_work(sc->hw, &sc->chanctx_work); in ath_chanctx_event()
753 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_event()
756 void ath_chanctx_beacon_sent_ev(struct ath_softc *sc, in ath_chanctx_beacon_sent_ev() argument
759 if (sc->sched.beacon_pending) in ath_chanctx_beacon_sent_ev()
760 ath_chanctx_event(sc, NULL, ev); in ath_chanctx_beacon_sent_ev()
763 void ath_chanctx_beacon_recv_ev(struct ath_softc *sc, in ath_chanctx_beacon_recv_ev() argument
766 ath_chanctx_event(sc, NULL, ev); in ath_chanctx_beacon_recv_ev()
769 static int ath_scan_channel_duration(struct ath_softc *sc, in ath_scan_channel_duration() argument
772 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_channel_duration()
780 static void ath_chanctx_switch(struct ath_softc *sc, struct ath_chanctx *ctx, in ath_chanctx_switch() argument
783 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_switch()
785 spin_lock_bh(&sc->chan_lock); in ath_chanctx_switch()
788 (sc->cur_chan != ctx) && (ctx == &sc->offchannel.chan)) { in ath_chanctx_switch()
792 sc->sched.offchannel_pending = true; in ath_chanctx_switch()
793 sc->sched.wait_switch = true; in ath_chanctx_switch()
794 sc->sched.offchannel_duration = in ath_chanctx_switch()
795 jiffies_to_usecs(sc->offchannel.duration) + in ath_chanctx_switch()
796 sc->sched.channel_switch_time; in ath_chanctx_switch()
798 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_switch()
804 sc->next_chan = ctx; in ath_chanctx_switch()
811 if (sc->next_chan == &sc->offchannel.chan) { in ath_chanctx_switch()
812 sc->sched.offchannel_duration = in ath_chanctx_switch()
813 jiffies_to_usecs(sc->offchannel.duration) + in ath_chanctx_switch()
814 sc->sched.channel_switch_time; in ath_chanctx_switch()
820 sc->sched.offchannel_duration); in ath_chanctx_switch()
823 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_switch()
824 ieee80211_queue_work(sc->hw, &sc->chanctx_work); in ath_chanctx_switch()
827 static void ath_chanctx_offchan_switch(struct ath_softc *sc, in ath_chanctx_offchan_switch() argument
830 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_offchan_switch()
837 ath_chanctx_switch(sc, &sc->offchannel.chan, &chandef); in ath_chanctx_offchan_switch()
840 static struct ath_chanctx *ath_chanctx_get_oper_chan(struct ath_softc *sc, in ath_chanctx_get_oper_chan() argument
845 ath_for_each_chanctx(sc, ctx) { in ath_chanctx_get_oper_chan()
855 return &sc->chanctx[0]; in ath_chanctx_get_oper_chan()
859 ath_scan_next_channel(struct ath_softc *sc) in ath_scan_next_channel() argument
861 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_scan_next_channel()
862 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_next_channel()
865 if (sc->offchannel.scan_idx >= req->n_channels) { in ath_scan_next_channel()
869 sc->offchannel.scan_idx, in ath_scan_next_channel()
872 sc->offchannel.state = ATH_OFFCHANNEL_IDLE; in ath_scan_next_channel()
873 ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false), in ath_scan_next_channel()
880 sc->offchannel.scan_idx); in ath_scan_next_channel()
882 chan = req->channels[sc->offchannel.scan_idx++]; in ath_scan_next_channel()
883 sc->offchannel.duration = ath_scan_channel_duration(sc, chan); in ath_scan_next_channel()
884 sc->offchannel.state = ATH_OFFCHANNEL_PROBE_SEND; in ath_scan_next_channel()
886 ath_chanctx_offchan_switch(sc, chan); in ath_scan_next_channel()
889 void ath_offchannel_next(struct ath_softc *sc) in ath_offchannel_next() argument
893 if (sc->offchannel.scan_req) { in ath_offchannel_next()
894 vif = sc->offchannel.scan_vif; in ath_offchannel_next()
895 sc->offchannel.chan.txpower = vif->bss_conf.txpower; in ath_offchannel_next()
896 ath_scan_next_channel(sc); in ath_offchannel_next()
897 } else if (sc->offchannel.roc_vif) { in ath_offchannel_next()
898 vif = sc->offchannel.roc_vif; in ath_offchannel_next()
899 sc->offchannel.chan.txpower = vif->bss_conf.txpower; in ath_offchannel_next()
900 sc->offchannel.duration = in ath_offchannel_next()
901 msecs_to_jiffies(sc->offchannel.roc_duration); in ath_offchannel_next()
902 sc->offchannel.state = ATH_OFFCHANNEL_ROC_START; in ath_offchannel_next()
903 ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan); in ath_offchannel_next()
905 spin_lock_bh(&sc->chan_lock); in ath_offchannel_next()
906 sc->sched.offchannel_pending = false; in ath_offchannel_next()
907 sc->sched.wait_switch = false; in ath_offchannel_next()
908 spin_unlock_bh(&sc->chan_lock); in ath_offchannel_next()
910 ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false), in ath_offchannel_next()
912 sc->offchannel.state = ATH_OFFCHANNEL_IDLE; in ath_offchannel_next()
913 if (sc->ps_idle) in ath_offchannel_next()
914 ath_cancel_work(sc); in ath_offchannel_next()
918 void ath_roc_complete(struct ath_softc *sc, enum ath_roc_complete_reason reason) in ath_roc_complete() argument
920 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_roc_complete()
922 sc->offchannel.roc_vif = NULL; in ath_roc_complete()
923 sc->offchannel.roc_chan = NULL; in ath_roc_complete()
928 ieee80211_remain_on_channel_expired(sc->hw); in ath_roc_complete()
932 ieee80211_remain_on_channel_expired(sc->hw); in ath_roc_complete()
939 ath_offchannel_next(sc); in ath_roc_complete()
940 ath9k_ps_restore(sc); in ath_roc_complete()
943 void ath_scan_complete(struct ath_softc *sc, bool abort) in ath_scan_complete() argument
945 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_scan_complete()
952 sc->offchannel.scan_req = NULL; in ath_scan_complete()
953 sc->offchannel.scan_vif = NULL; in ath_scan_complete()
954 sc->offchannel.state = ATH_OFFCHANNEL_IDLE; in ath_scan_complete()
955 ieee80211_scan_completed(sc->hw, abort); in ath_scan_complete()
957 spin_lock_bh(&sc->chan_lock); in ath_scan_complete()
959 sc->sched.force_noa_update = true; in ath_scan_complete()
960 spin_unlock_bh(&sc->chan_lock); in ath_scan_complete()
961 ath_offchannel_next(sc); in ath_scan_complete()
962 ath9k_ps_restore(sc); in ath_scan_complete()
965 static void ath_scan_send_probe(struct ath_softc *sc, in ath_scan_send_probe() argument
968 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_send_probe()
969 struct ieee80211_vif *vif = sc->offchannel.scan_vif; in ath_scan_send_probe()
973 int band = sc->offchannel.chan.chandef.chan->band; in ath_scan_send_probe()
975 skb = ieee80211_probereq_get(sc->hw, vif->addr, in ath_scan_send_probe()
989 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, NULL)) in ath_scan_send_probe()
992 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO]; in ath_scan_send_probe()
994 if (ath_tx_start(sc->hw, skb, &txctl)) in ath_scan_send_probe()
1000 ieee80211_free_txskb(sc->hw, skb); in ath_scan_send_probe()
1003 static void ath_scan_channel_start(struct ath_softc *sc) in ath_scan_channel_start() argument
1005 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_scan_channel_start()
1006 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_channel_start()
1009 if (!(sc->cur_chan->chandef.chan->flags & IEEE80211_CHAN_NO_IR) && in ath_scan_channel_start()
1012 ath_scan_send_probe(sc, &req->ssids[i]); in ath_scan_channel_start()
1019 sc->offchannel.state = ATH_OFFCHANNEL_PROBE_WAIT; in ath_scan_channel_start()
1020 mod_timer(&sc->offchannel.timer, jiffies + sc->offchannel.duration); in ath_scan_channel_start()
1025 struct ath_softc *sc = (struct ath_softc *) data; in ath_chanctx_timer() local
1026 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_timer()
1031 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_TSF_TIMER); in ath_chanctx_timer()
1036 struct ath_softc *sc = (struct ath_softc *)data; in ath_offchannel_timer() local
1038 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_offchannel_timer()
1041 __func__, offchannel_state_string(sc->offchannel.state)); in ath_offchannel_timer()
1043 switch (sc->offchannel.state) { in ath_offchannel_timer()
1045 if (!sc->offchannel.scan_req) in ath_offchannel_timer()
1049 ctx = ath_chanctx_get_oper_chan(sc, true); in ath_offchannel_timer()
1055 sc->offchannel.state = ATH_OFFCHANNEL_SUSPEND; in ath_offchannel_timer()
1056 ath_chanctx_switch(sc, ctx, NULL); in ath_offchannel_timer()
1057 mod_timer(&sc->offchannel.timer, jiffies + HZ / 10); in ath_offchannel_timer()
1062 if (!sc->offchannel.scan_req) in ath_offchannel_timer()
1065 ath_scan_next_channel(sc); in ath_offchannel_timer()
1069 sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE; in ath_offchannel_timer()
1070 ath_roc_complete(sc, ATH_ROC_COMPLETE_EXPIRE); in ath_offchannel_timer()
1078 ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, struct ath_vif *avp, in ath_chanctx_send_vif_ps_frame() argument
1086 int band = sc->cur_chan->chandef.chan->band; in ath_chanctx_send_vif_ps_frame()
1093 skb = ieee80211_nullfunc_get(sc->hw, vif); in ath_chanctx_send_vif_ps_frame()
1103 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) { in ath_chanctx_send_vif_ps_frame()
1113 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO]; in ath_chanctx_send_vif_ps_frame()
1116 if (ath_tx_start(sc->hw, skb, &txctl)) { in ath_chanctx_send_vif_ps_frame()
1117 ieee80211_free_txskb(sc->hw, skb); in ath_chanctx_send_vif_ps_frame()
1125 ath_chanctx_send_ps_frame(struct ath_softc *sc, bool powersave) in ath_chanctx_send_ps_frame() argument
1131 list_for_each_entry(avp, &sc->cur_chan->vifs, list) { in ath_chanctx_send_ps_frame()
1132 if (ath_chanctx_send_vif_ps_frame(sc, avp, powersave)) in ath_chanctx_send_ps_frame()
1140 static bool ath_chanctx_defer_switch(struct ath_softc *sc) in ath_chanctx_defer_switch() argument
1142 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_defer_switch()
1144 if (sc->cur_chan == &sc->offchannel.chan) in ath_chanctx_defer_switch()
1147 switch (sc->sched.state) { in ath_chanctx_defer_switch()
1151 if (!sc->cur_chan->switch_after_beacon) in ath_chanctx_defer_switch()
1157 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_defer_switch()
1166 static void ath_offchannel_channel_change(struct ath_softc *sc) in ath_offchannel_channel_change() argument
1168 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_offchannel_channel_change()
1171 __func__, offchannel_state_string(sc->offchannel.state)); in ath_offchannel_channel_change()
1173 switch (sc->offchannel.state) { in ath_offchannel_channel_change()
1175 if (!sc->offchannel.scan_req) in ath_offchannel_channel_change()
1178 if (sc->cur_chan->chandef.chan != in ath_offchannel_channel_change()
1179 sc->offchannel.chan.chandef.chan) in ath_offchannel_channel_change()
1182 ath_scan_channel_start(sc); in ath_offchannel_channel_change()
1185 if (!sc->offchannel.scan_req) in ath_offchannel_channel_change()
1188 ath_scan_complete(sc, false); in ath_offchannel_channel_change()
1191 if (sc->cur_chan != &sc->offchannel.chan) in ath_offchannel_channel_change()
1194 sc->offchannel.state = ATH_OFFCHANNEL_ROC_WAIT; in ath_offchannel_channel_change()
1195 mod_timer(&sc->offchannel.timer, in ath_offchannel_channel_change()
1196 jiffies + sc->offchannel.duration); in ath_offchannel_channel_change()
1197 ieee80211_ready_on_channel(sc->hw); in ath_offchannel_channel_change()
1206 void ath_chanctx_set_next(struct ath_softc *sc, bool force) in ath_chanctx_set_next() argument
1208 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_next()
1215 spin_lock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1216 if (!sc->next_chan) { in ath_chanctx_set_next()
1217 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1221 if (!force && ath_chanctx_defer_switch(sc)) { in ath_chanctx_set_next()
1222 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1229 sc->cur_chan->chandef.center_freq1, in ath_chanctx_set_next()
1230 sc->next_chan->chandef.center_freq1); in ath_chanctx_set_next()
1232 if (sc->cur_chan != sc->next_chan) { in ath_chanctx_set_next()
1235 sc->cur_chan->chandef.center_freq1); in ath_chanctx_set_next()
1236 sc->cur_chan->stopped = true; in ath_chanctx_set_next()
1237 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1239 if (sc->next_chan == &sc->offchannel.chan) { in ath_chanctx_set_next()
1244 ath9k_chanctx_stop_queues(sc, sc->cur_chan); in ath_chanctx_set_next()
1247 __ath9k_flush(sc->hw, ~0, true, false, false); in ath_chanctx_set_next()
1249 if (ath_chanctx_send_ps_frame(sc, true)) in ath_chanctx_set_next()
1250 __ath9k_flush(sc->hw, BIT(IEEE80211_AC_VO), in ath_chanctx_set_next()
1254 spin_lock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1256 if (sc->cur_chan != &sc->offchannel.chan) { in ath_chanctx_set_next()
1257 getrawmonotonic(&sc->cur_chan->tsf_ts); in ath_chanctx_set_next()
1258 sc->cur_chan->tsf_val = ath9k_hw_gettsf64(sc->sc_ah); in ath_chanctx_set_next()
1261 old_ctx = sc->cur_chan; in ath_chanctx_set_next()
1262 sc->cur_chan = sc->next_chan; in ath_chanctx_set_next()
1263 sc->cur_chan->stopped = false; in ath_chanctx_set_next()
1264 sc->next_chan = NULL; in ath_chanctx_set_next()
1266 if (!sc->sched.offchannel_pending) in ath_chanctx_set_next()
1267 sc->sched.offchannel_duration = 0; in ath_chanctx_set_next()
1269 if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE) in ath_chanctx_set_next()
1270 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_set_next()
1272 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1274 if (sc->sc_ah->chip_fullsleep || in ath_chanctx_set_next()
1275 memcmp(&sc->cur_chandef, &sc->cur_chan->chandef, in ath_chanctx_set_next()
1276 sizeof(sc->cur_chandef))) { in ath_chanctx_set_next()
1279 __func__, sc->cur_chan->chandef.center_freq1); in ath_chanctx_set_next()
1280 ath_set_channel(sc); in ath_chanctx_set_next()
1282 sc->sched.channel_switch_time = in ath_chanctx_set_next()
1292 ath9k_chanctx_wake_queues(sc, old_ctx); in ath_chanctx_set_next()
1295 ath_chanctx_send_ps_frame(sc, false); in ath_chanctx_set_next()
1297 ath_offchannel_channel_change(sc); in ath_chanctx_set_next()
1298 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_SWITCH); in ath_chanctx_set_next()
1303 struct ath_softc *sc = container_of(work, struct ath_softc, in ath_chanctx_work() local
1305 mutex_lock(&sc->mutex); in ath_chanctx_work()
1306 ath_chanctx_set_next(sc, false); in ath_chanctx_work()
1307 mutex_unlock(&sc->mutex); in ath_chanctx_work()
1310 void ath9k_offchannel_init(struct ath_softc *sc) in ath9k_offchannel_init() argument
1313 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_offchannel_init()
1324 ctx = &sc->offchannel.chan; in ath9k_offchannel_init()
1332 sc->offchannel.chan.offchannel = true; in ath9k_offchannel_init()
1335 void ath9k_init_channel_context(struct ath_softc *sc) in ath9k_init_channel_context() argument
1337 INIT_WORK(&sc->chanctx_work, ath_chanctx_work); in ath9k_init_channel_context()
1339 setup_timer(&sc->offchannel.timer, ath_offchannel_timer, in ath9k_init_channel_context()
1340 (unsigned long)sc); in ath9k_init_channel_context()
1341 setup_timer(&sc->sched.timer, ath_chanctx_timer, in ath9k_init_channel_context()
1342 (unsigned long)sc); in ath9k_init_channel_context()
1344 init_completion(&sc->go_beacon); in ath9k_init_channel_context()
1347 void ath9k_deinit_channel_context(struct ath_softc *sc) in ath9k_deinit_channel_context() argument
1349 cancel_work_sync(&sc->chanctx_work); in ath9k_deinit_channel_context()
1361 void ath9k_chanctx_stop_queues(struct ath_softc *sc, struct ath_chanctx *ctx) in ath9k_chanctx_stop_queues() argument
1363 struct ath_hw *ah = sc->sc_ah; in ath9k_chanctx_stop_queues()
1366 if (ctx == &sc->offchannel.chan) { in ath9k_chanctx_stop_queues()
1367 ieee80211_stop_queue(sc->hw, in ath9k_chanctx_stop_queues()
1368 sc->hw->offchannel_tx_hw_queue); in ath9k_chanctx_stop_queues()
1371 ieee80211_stop_queue(sc->hw, in ath9k_chanctx_stop_queues()
1376 ieee80211_stop_queue(sc->hw, sc->hw->queues - 2); in ath9k_chanctx_stop_queues()
1380 void ath9k_chanctx_wake_queues(struct ath_softc *sc, struct ath_chanctx *ctx) in ath9k_chanctx_wake_queues() argument
1382 struct ath_hw *ah = sc->sc_ah; in ath9k_chanctx_wake_queues()
1385 if (ctx == &sc->offchannel.chan) { in ath9k_chanctx_wake_queues()
1386 ieee80211_wake_queue(sc->hw, in ath9k_chanctx_wake_queues()
1387 sc->hw->offchannel_tx_hw_queue); in ath9k_chanctx_wake_queues()
1390 ieee80211_wake_queue(sc->hw, in ath9k_chanctx_wake_queues()
1395 ieee80211_wake_queue(sc->hw, sc->hw->queues - 2); in ath9k_chanctx_wake_queues()
1402 static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp) in ath9k_update_p2p_ps_timer() argument
1404 struct ath_hw *ah = sc->sc_ah; in ath9k_update_p2p_ps_timer()
1410 ath9k_hw_gen_timer_stop(ah, sc->p2p_ps_timer); in ath9k_update_p2p_ps_timer()
1412 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_update_p2p_ps_timer()
1421 ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, (u32) target_tsf, 1000000); in ath9k_update_p2p_ps_timer()
1424 static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif) in ath9k_update_p2p_ps() argument
1429 if (!sc->p2p_ps_timer) in ath9k_update_p2p_ps()
1435 sc->p2p_ps_vif = avp; in ath9k_update_p2p_ps()
1436 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_update_p2p_ps()
1438 ath9k_update_p2p_ps_timer(sc, avp); in ath9k_update_p2p_ps()
1441 static u8 ath9k_get_ctwin(struct ath_softc *sc, struct ath_vif *avp) in ath9k_get_ctwin() argument
1443 struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon; in ath9k_get_ctwin()
1465 void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, in ath9k_beacon_add_noa() argument
1497 noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp); in ath9k_beacon_add_noa()
1501 u32 interval = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); in ath9k_beacon_add_noa()
1522 struct ath_softc *sc = priv; in ath9k_p2p_ps_timer() local
1523 struct ath_vif *avp = sc->p2p_ps_vif; in ath9k_p2p_ps_timer()
1529 del_timer_sync(&sc->sched.timer); in ath9k_p2p_ps_timer()
1530 ath9k_hw_gen_timer_stop(sc->sc_ah, sc->p2p_ps_timer); in ath9k_p2p_ps_timer()
1531 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_TSF_TIMER); in ath9k_p2p_ps_timer()
1533 if (!avp || avp->chanctx != sc->cur_chan) in ath9k_p2p_ps_timer()
1536 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_p2p_ps_timer()
1544 ath9k_update_p2p_ps_timer(sc, avp); in ath9k_p2p_ps_timer()
1559 ath_tx_aggr_sleep(sta, sc, an); in ath9k_p2p_ps_timer()
1561 ath_tx_aggr_wakeup(sc, an); in ath9k_p2p_ps_timer()
1567 void ath9k_p2p_bss_info_changed(struct ath_softc *sc, in ath9k_p2p_bss_info_changed() argument
1572 spin_lock_bh(&sc->sc_pcu_lock); in ath9k_p2p_bss_info_changed()
1573 spin_lock_irqsave(&sc->sc_pm_lock, flags); in ath9k_p2p_bss_info_changed()
1574 if (!(sc->ps_flags & PS_BEACON_SYNC)) in ath9k_p2p_bss_info_changed()
1575 ath9k_update_p2p_ps(sc, vif); in ath9k_p2p_bss_info_changed()
1576 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); in ath9k_p2p_bss_info_changed()
1577 spin_unlock_bh(&sc->sc_pcu_lock); in ath9k_p2p_bss_info_changed()
1580 void ath9k_p2p_beacon_sync(struct ath_softc *sc) in ath9k_p2p_beacon_sync() argument
1582 if (sc->p2p_ps_vif) in ath9k_p2p_beacon_sync()
1583 ath9k_update_p2p_ps(sc, sc->p2p_ps_vif->vif); in ath9k_p2p_beacon_sync()
1586 void ath9k_p2p_remove_vif(struct ath_softc *sc, in ath9k_p2p_remove_vif() argument
1591 spin_lock_bh(&sc->sc_pcu_lock); in ath9k_p2p_remove_vif()
1592 if (avp == sc->p2p_ps_vif) { in ath9k_p2p_remove_vif()
1593 sc->p2p_ps_vif = NULL; in ath9k_p2p_remove_vif()
1594 ath9k_update_p2p_ps_timer(sc, NULL); in ath9k_p2p_remove_vif()
1596 spin_unlock_bh(&sc->sc_pcu_lock); in ath9k_p2p_remove_vif()
1599 int ath9k_init_p2p(struct ath_softc *sc) in ath9k_init_p2p() argument
1601 sc->p2p_ps_timer = ath_gen_timer_alloc(sc->sc_ah, ath9k_p2p_ps_timer, in ath9k_init_p2p()
1602 NULL, sc, AR_FIRST_NDP_TIMER); in ath9k_init_p2p()
1603 if (!sc->p2p_ps_timer) in ath9k_init_p2p()
1609 void ath9k_deinit_p2p(struct ath_softc *sc) in ath9k_deinit_p2p() argument
1611 if (sc->p2p_ps_timer) in ath9k_deinit_p2p()
1612 ath_gen_timer_free(sc->sc_ah, sc->p2p_ps_timer); in ath9k_deinit_p2p()