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, bool abort) in ath_roc_complete() argument
920 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_roc_complete()
927 sc->offchannel.roc_vif = NULL; in ath_roc_complete()
928 sc->offchannel.roc_chan = NULL; in ath_roc_complete()
929 ieee80211_remain_on_channel_expired(sc->hw); in ath_roc_complete()
930 ath_offchannel_next(sc); in ath_roc_complete()
931 ath9k_ps_restore(sc); in ath_roc_complete()
934 void ath_scan_complete(struct ath_softc *sc, bool abort) in ath_scan_complete() argument
936 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_scan_complete()
943 sc->offchannel.scan_req = NULL; in ath_scan_complete()
944 sc->offchannel.scan_vif = NULL; in ath_scan_complete()
945 sc->offchannel.state = ATH_OFFCHANNEL_IDLE; in ath_scan_complete()
946 ieee80211_scan_completed(sc->hw, abort); in ath_scan_complete()
948 spin_lock_bh(&sc->chan_lock); in ath_scan_complete()
950 sc->sched.force_noa_update = true; in ath_scan_complete()
951 spin_unlock_bh(&sc->chan_lock); in ath_scan_complete()
952 ath_offchannel_next(sc); in ath_scan_complete()
953 ath9k_ps_restore(sc); in ath_scan_complete()
956 static void ath_scan_send_probe(struct ath_softc *sc, in ath_scan_send_probe() argument
959 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_send_probe()
960 struct ieee80211_vif *vif = sc->offchannel.scan_vif; in ath_scan_send_probe()
964 int band = sc->offchannel.chan.chandef.chan->band; in ath_scan_send_probe()
966 skb = ieee80211_probereq_get(sc->hw, vif->addr, in ath_scan_send_probe()
980 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, NULL)) in ath_scan_send_probe()
983 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO]; in ath_scan_send_probe()
985 if (ath_tx_start(sc->hw, skb, &txctl)) in ath_scan_send_probe()
991 ieee80211_free_txskb(sc->hw, skb); in ath_scan_send_probe()
994 static void ath_scan_channel_start(struct ath_softc *sc) in ath_scan_channel_start() argument
996 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_scan_channel_start()
997 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_channel_start()
1000 if (!(sc->cur_chan->chandef.chan->flags & IEEE80211_CHAN_NO_IR) && in ath_scan_channel_start()
1003 ath_scan_send_probe(sc, &req->ssids[i]); in ath_scan_channel_start()
1010 sc->offchannel.state = ATH_OFFCHANNEL_PROBE_WAIT; in ath_scan_channel_start()
1011 mod_timer(&sc->offchannel.timer, jiffies + sc->offchannel.duration); in ath_scan_channel_start()
1016 struct ath_softc *sc = (struct ath_softc *) data; in ath_chanctx_timer() local
1017 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_timer()
1022 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_TSF_TIMER); in ath_chanctx_timer()
1027 struct ath_softc *sc = (struct ath_softc *)data; in ath_offchannel_timer() local
1029 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_offchannel_timer()
1032 __func__, offchannel_state_string(sc->offchannel.state)); in ath_offchannel_timer()
1034 switch (sc->offchannel.state) { in ath_offchannel_timer()
1036 if (!sc->offchannel.scan_req) in ath_offchannel_timer()
1040 ctx = ath_chanctx_get_oper_chan(sc, true); in ath_offchannel_timer()
1046 sc->offchannel.state = ATH_OFFCHANNEL_SUSPEND; in ath_offchannel_timer()
1047 ath_chanctx_switch(sc, ctx, NULL); in ath_offchannel_timer()
1048 mod_timer(&sc->offchannel.timer, jiffies + HZ / 10); in ath_offchannel_timer()
1053 if (!sc->offchannel.scan_req) in ath_offchannel_timer()
1056 ath_scan_next_channel(sc); in ath_offchannel_timer()
1060 sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE; in ath_offchannel_timer()
1061 ath_roc_complete(sc, false); in ath_offchannel_timer()
1069 ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, struct ath_vif *avp, in ath_chanctx_send_vif_ps_frame() argument
1077 int band = sc->cur_chan->chandef.chan->band; in ath_chanctx_send_vif_ps_frame()
1084 skb = ieee80211_nullfunc_get(sc->hw, vif); in ath_chanctx_send_vif_ps_frame()
1094 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) { in ath_chanctx_send_vif_ps_frame()
1104 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO]; in ath_chanctx_send_vif_ps_frame()
1107 if (ath_tx_start(sc->hw, skb, &txctl)) { in ath_chanctx_send_vif_ps_frame()
1108 ieee80211_free_txskb(sc->hw, skb); in ath_chanctx_send_vif_ps_frame()
1116 ath_chanctx_send_ps_frame(struct ath_softc *sc, bool powersave) in ath_chanctx_send_ps_frame() argument
1122 list_for_each_entry(avp, &sc->cur_chan->vifs, list) { in ath_chanctx_send_ps_frame()
1123 if (ath_chanctx_send_vif_ps_frame(sc, avp, powersave)) in ath_chanctx_send_ps_frame()
1131 static bool ath_chanctx_defer_switch(struct ath_softc *sc) in ath_chanctx_defer_switch() argument
1133 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_defer_switch()
1135 if (sc->cur_chan == &sc->offchannel.chan) in ath_chanctx_defer_switch()
1138 switch (sc->sched.state) { in ath_chanctx_defer_switch()
1142 if (!sc->cur_chan->switch_after_beacon) in ath_chanctx_defer_switch()
1148 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_defer_switch()
1157 static void ath_offchannel_channel_change(struct ath_softc *sc) in ath_offchannel_channel_change() argument
1159 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_offchannel_channel_change()
1162 __func__, offchannel_state_string(sc->offchannel.state)); in ath_offchannel_channel_change()
1164 switch (sc->offchannel.state) { in ath_offchannel_channel_change()
1166 if (!sc->offchannel.scan_req) in ath_offchannel_channel_change()
1169 if (sc->cur_chan->chandef.chan != in ath_offchannel_channel_change()
1170 sc->offchannel.chan.chandef.chan) in ath_offchannel_channel_change()
1173 ath_scan_channel_start(sc); in ath_offchannel_channel_change()
1176 if (!sc->offchannel.scan_req) in ath_offchannel_channel_change()
1179 ath_scan_complete(sc, false); in ath_offchannel_channel_change()
1182 if (sc->cur_chan != &sc->offchannel.chan) in ath_offchannel_channel_change()
1185 sc->offchannel.state = ATH_OFFCHANNEL_ROC_WAIT; in ath_offchannel_channel_change()
1186 mod_timer(&sc->offchannel.timer, in ath_offchannel_channel_change()
1187 jiffies + sc->offchannel.duration); in ath_offchannel_channel_change()
1188 ieee80211_ready_on_channel(sc->hw); in ath_offchannel_channel_change()
1197 void ath_chanctx_set_next(struct ath_softc *sc, bool force) in ath_chanctx_set_next() argument
1199 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_next()
1206 spin_lock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1207 if (!sc->next_chan) { in ath_chanctx_set_next()
1208 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1212 if (!force && ath_chanctx_defer_switch(sc)) { in ath_chanctx_set_next()
1213 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1220 sc->cur_chan->chandef.center_freq1, in ath_chanctx_set_next()
1221 sc->next_chan->chandef.center_freq1); in ath_chanctx_set_next()
1223 if (sc->cur_chan != sc->next_chan) { in ath_chanctx_set_next()
1226 sc->cur_chan->chandef.center_freq1); in ath_chanctx_set_next()
1227 sc->cur_chan->stopped = true; in ath_chanctx_set_next()
1228 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1230 if (sc->next_chan == &sc->offchannel.chan) { in ath_chanctx_set_next()
1235 ath9k_chanctx_stop_queues(sc, sc->cur_chan); in ath_chanctx_set_next()
1238 __ath9k_flush(sc->hw, ~0, true, false, false); in ath_chanctx_set_next()
1240 if (ath_chanctx_send_ps_frame(sc, true)) in ath_chanctx_set_next()
1241 __ath9k_flush(sc->hw, BIT(IEEE80211_AC_VO), in ath_chanctx_set_next()
1245 spin_lock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1247 if (sc->cur_chan != &sc->offchannel.chan) { in ath_chanctx_set_next()
1248 getrawmonotonic(&sc->cur_chan->tsf_ts); in ath_chanctx_set_next()
1249 sc->cur_chan->tsf_val = ath9k_hw_gettsf64(sc->sc_ah); in ath_chanctx_set_next()
1252 old_ctx = sc->cur_chan; in ath_chanctx_set_next()
1253 sc->cur_chan = sc->next_chan; in ath_chanctx_set_next()
1254 sc->cur_chan->stopped = false; in ath_chanctx_set_next()
1255 sc->next_chan = NULL; in ath_chanctx_set_next()
1257 if (!sc->sched.offchannel_pending) in ath_chanctx_set_next()
1258 sc->sched.offchannel_duration = 0; in ath_chanctx_set_next()
1260 if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE) in ath_chanctx_set_next()
1261 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_set_next()
1263 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1265 if (sc->sc_ah->chip_fullsleep || in ath_chanctx_set_next()
1266 memcmp(&sc->cur_chandef, &sc->cur_chan->chandef, in ath_chanctx_set_next()
1267 sizeof(sc->cur_chandef))) { in ath_chanctx_set_next()
1270 __func__, sc->cur_chan->chandef.center_freq1); in ath_chanctx_set_next()
1271 ath_set_channel(sc); in ath_chanctx_set_next()
1273 sc->sched.channel_switch_time = in ath_chanctx_set_next()
1283 ath9k_chanctx_wake_queues(sc, old_ctx); in ath_chanctx_set_next()
1286 ath_chanctx_send_ps_frame(sc, false); in ath_chanctx_set_next()
1288 ath_offchannel_channel_change(sc); in ath_chanctx_set_next()
1289 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_SWITCH); in ath_chanctx_set_next()
1294 struct ath_softc *sc = container_of(work, struct ath_softc, in ath_chanctx_work() local
1296 mutex_lock(&sc->mutex); in ath_chanctx_work()
1297 ath_chanctx_set_next(sc, false); in ath_chanctx_work()
1298 mutex_unlock(&sc->mutex); in ath_chanctx_work()
1301 void ath9k_offchannel_init(struct ath_softc *sc) in ath9k_offchannel_init() argument
1304 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_offchannel_init()
1315 ctx = &sc->offchannel.chan; in ath9k_offchannel_init()
1323 sc->offchannel.chan.offchannel = true; in ath9k_offchannel_init()
1326 void ath9k_init_channel_context(struct ath_softc *sc) in ath9k_init_channel_context() argument
1328 INIT_WORK(&sc->chanctx_work, ath_chanctx_work); in ath9k_init_channel_context()
1330 setup_timer(&sc->offchannel.timer, ath_offchannel_timer, in ath9k_init_channel_context()
1331 (unsigned long)sc); in ath9k_init_channel_context()
1332 setup_timer(&sc->sched.timer, ath_chanctx_timer, in ath9k_init_channel_context()
1333 (unsigned long)sc); in ath9k_init_channel_context()
1335 init_completion(&sc->go_beacon); in ath9k_init_channel_context()
1338 void ath9k_deinit_channel_context(struct ath_softc *sc) in ath9k_deinit_channel_context() argument
1340 cancel_work_sync(&sc->chanctx_work); in ath9k_deinit_channel_context()
1352 void ath9k_chanctx_stop_queues(struct ath_softc *sc, struct ath_chanctx *ctx) in ath9k_chanctx_stop_queues() argument
1354 struct ath_hw *ah = sc->sc_ah; in ath9k_chanctx_stop_queues()
1357 if (ctx == &sc->offchannel.chan) { in ath9k_chanctx_stop_queues()
1358 ieee80211_stop_queue(sc->hw, in ath9k_chanctx_stop_queues()
1359 sc->hw->offchannel_tx_hw_queue); in ath9k_chanctx_stop_queues()
1362 ieee80211_stop_queue(sc->hw, in ath9k_chanctx_stop_queues()
1367 ieee80211_stop_queue(sc->hw, sc->hw->queues - 2); in ath9k_chanctx_stop_queues()
1371 void ath9k_chanctx_wake_queues(struct ath_softc *sc, struct ath_chanctx *ctx) in ath9k_chanctx_wake_queues() argument
1373 struct ath_hw *ah = sc->sc_ah; in ath9k_chanctx_wake_queues()
1376 if (ctx == &sc->offchannel.chan) { in ath9k_chanctx_wake_queues()
1377 ieee80211_wake_queue(sc->hw, in ath9k_chanctx_wake_queues()
1378 sc->hw->offchannel_tx_hw_queue); in ath9k_chanctx_wake_queues()
1381 ieee80211_wake_queue(sc->hw, in ath9k_chanctx_wake_queues()
1386 ieee80211_wake_queue(sc->hw, sc->hw->queues - 2); in ath9k_chanctx_wake_queues()
1393 static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp) in ath9k_update_p2p_ps_timer() argument
1395 struct ath_hw *ah = sc->sc_ah; in ath9k_update_p2p_ps_timer()
1401 ath9k_hw_gen_timer_stop(ah, sc->p2p_ps_timer); in ath9k_update_p2p_ps_timer()
1403 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_update_p2p_ps_timer()
1412 ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, (u32) target_tsf, 1000000); in ath9k_update_p2p_ps_timer()
1415 static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif) in ath9k_update_p2p_ps() argument
1420 if (!sc->p2p_ps_timer) in ath9k_update_p2p_ps()
1426 sc->p2p_ps_vif = avp; in ath9k_update_p2p_ps()
1427 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_update_p2p_ps()
1429 ath9k_update_p2p_ps_timer(sc, avp); in ath9k_update_p2p_ps()
1432 static u8 ath9k_get_ctwin(struct ath_softc *sc, struct ath_vif *avp) in ath9k_get_ctwin() argument
1434 struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon; in ath9k_get_ctwin()
1456 void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, in ath9k_beacon_add_noa() argument
1488 noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp); in ath9k_beacon_add_noa()
1492 u32 interval = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); in ath9k_beacon_add_noa()
1513 struct ath_softc *sc = priv; in ath9k_p2p_ps_timer() local
1514 struct ath_vif *avp = sc->p2p_ps_vif; in ath9k_p2p_ps_timer()
1520 del_timer_sync(&sc->sched.timer); in ath9k_p2p_ps_timer()
1521 ath9k_hw_gen_timer_stop(sc->sc_ah, sc->p2p_ps_timer); in ath9k_p2p_ps_timer()
1522 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_TSF_TIMER); in ath9k_p2p_ps_timer()
1524 if (!avp || avp->chanctx != sc->cur_chan) in ath9k_p2p_ps_timer()
1527 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_p2p_ps_timer()
1535 ath9k_update_p2p_ps_timer(sc, avp); in ath9k_p2p_ps_timer()
1550 ath_tx_aggr_sleep(sta, sc, an); in ath9k_p2p_ps_timer()
1552 ath_tx_aggr_wakeup(sc, an); in ath9k_p2p_ps_timer()
1558 void ath9k_p2p_bss_info_changed(struct ath_softc *sc, in ath9k_p2p_bss_info_changed() argument
1563 spin_lock_bh(&sc->sc_pcu_lock); in ath9k_p2p_bss_info_changed()
1564 spin_lock_irqsave(&sc->sc_pm_lock, flags); in ath9k_p2p_bss_info_changed()
1565 if (!(sc->ps_flags & PS_BEACON_SYNC)) in ath9k_p2p_bss_info_changed()
1566 ath9k_update_p2p_ps(sc, vif); in ath9k_p2p_bss_info_changed()
1567 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); in ath9k_p2p_bss_info_changed()
1568 spin_unlock_bh(&sc->sc_pcu_lock); in ath9k_p2p_bss_info_changed()
1571 void ath9k_p2p_beacon_sync(struct ath_softc *sc) in ath9k_p2p_beacon_sync() argument
1573 if (sc->p2p_ps_vif) in ath9k_p2p_beacon_sync()
1574 ath9k_update_p2p_ps(sc, sc->p2p_ps_vif->vif); in ath9k_p2p_beacon_sync()
1577 void ath9k_p2p_remove_vif(struct ath_softc *sc, in ath9k_p2p_remove_vif() argument
1582 spin_lock_bh(&sc->sc_pcu_lock); in ath9k_p2p_remove_vif()
1583 if (avp == sc->p2p_ps_vif) { in ath9k_p2p_remove_vif()
1584 sc->p2p_ps_vif = NULL; in ath9k_p2p_remove_vif()
1585 ath9k_update_p2p_ps_timer(sc, NULL); in ath9k_p2p_remove_vif()
1587 spin_unlock_bh(&sc->sc_pcu_lock); in ath9k_p2p_remove_vif()
1590 int ath9k_init_p2p(struct ath_softc *sc) in ath9k_init_p2p() argument
1592 sc->p2p_ps_timer = ath_gen_timer_alloc(sc->sc_ah, ath9k_p2p_ps_timer, in ath9k_init_p2p()
1593 NULL, sc, AR_FIRST_NDP_TIMER); in ath9k_init_p2p()
1594 if (!sc->p2p_ps_timer) in ath9k_init_p2p()
1600 void ath9k_deinit_p2p(struct ath_softc *sc) in ath9k_deinit_p2p() argument
1602 if (sc->p2p_ps_timer) in ath9k_deinit_p2p()
1603 ath_gen_timer_free(sc->sc_ah, sc->p2p_ps_timer); in ath9k_deinit_p2p()