Lines Matching full: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()
47 ath_update_survey_stats(sc); in ath_set_channel()
57 if (!sc->cur_chan->offchannel && sc->cur_survey != &sc->survey[pos]) { in ath_set_channel()
58 if (sc->cur_survey) in ath_set_channel()
59 sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE; in ath_set_channel()
61 sc->cur_survey = &sc->survey[pos]; in ath_set_channel()
63 memset(sc->cur_survey, 0, sizeof(struct survey_info)); in ath_set_channel()
64 sc->cur_survey->filled |= SURVEY_INFO_IN_USE; in ath_set_channel()
65 } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) { in ath_set_channel()
66 memset(&sc->survey[pos], 0, sizeof(struct survey_info)); in ath_set_channel()
69 hchan = &sc->sc_ah->channels[pos]; in ath_set_channel()
70 r = ath_reset(sc, hchan); in ath_set_channel()
79 ath_update_survey_nf(sc, old_pos); in ath_set_channel()
96 sc->spec_priv.spectral_mode == SPECTRAL_CHANSCAN) in ath_set_channel()
97 ath9k_cmn_spectral_scan_trigger(common, &sc->spec_priv); in ath_set_channel()
103 void ath_chanctx_init(struct ath_softc *sc) in ath_chanctx_init() argument
106 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_init()
117 ctx = &sc->chanctx[i]; in ath_chanctx_init()
130 void ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx, in ath_chanctx_set_channel() argument
133 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_channel()
136 spin_lock_bh(&sc->chan_lock); in ath_chanctx_set_channel()
139 cur_chan = sc->cur_chan == ctx; in ath_chanctx_set_channel()
140 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_channel()
148 ath_set_channel(sc); in ath_chanctx_set_channel()
157 struct ath_chanctx* ath_is_go_chanctx_present(struct ath_softc *sc) in ath_is_go_chanctx_present() argument
163 spin_lock_bh(&sc->chan_lock); in ath_is_go_chanctx_present()
165 ath_for_each_chanctx(sc, ctx) { in ath_is_go_chanctx_present()
173 spin_unlock_bh(&sc->chan_lock); in ath_is_go_chanctx_present()
179 spin_unlock_bh(&sc->chan_lock); in ath_is_go_chanctx_present()
233 static u32 chanctx_event_delta(struct ath_softc *sc) in chanctx_event_delta() argument
236 s64 ms = ktime_ms_delta(ts, sc->last_event_time); in chanctx_event_delta()
238 sc->last_event_time = ts; in chanctx_event_delta()
242 void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx) in ath_chanctx_check_active() argument
244 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_check_active()
253 if (ctx == &sc->offchannel.chan) { in ath_chanctx_check_active()
254 spin_lock_bh(&sc->chan_lock); in ath_chanctx_check_active()
256 if (likely(sc->sched.channel_switch_time)) in ath_chanctx_check_active()
258 usecs_to_jiffies(sc->sched.channel_switch_time); in ath_chanctx_check_active()
263 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_check_active()
291 ath_for_each_chanctx(sc, ctx) { in ath_chanctx_check_active()
297 spin_lock_bh(&sc->chan_lock); in ath_chanctx_check_active()
302 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_check_active()
306 ictx->flush_timeout = usecs_to_jiffies(sc->sched.channel_switch_time); in ath_chanctx_check_active()
309 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_check_active()
313 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_check_active()
316 ath_chanctx_event(sc, NULL, in ath_chanctx_check_active()
322 ath_chanctx_get_next(struct ath_softc *sc, struct ath_chanctx *ctx) in ath_chanctx_get_next() argument
324 int idx = ctx - &sc->chanctx[0]; in ath_chanctx_get_next()
326 return &sc->chanctx[!idx]; in ath_chanctx_get_next()
329 static void ath_chanctx_adjust_tbtt_delta(struct ath_softc *sc) in ath_chanctx_adjust_tbtt_delta() argument
336 beacon_int = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); in ath_chanctx_adjust_tbtt_delta()
338 cur = sc->cur_chan; in ath_chanctx_adjust_tbtt_delta()
339 prev = ath_chanctx_get_next(sc, cur); in ath_chanctx_adjust_tbtt_delta()
368 static void ath_chanctx_setup_timer(struct ath_softc *sc, u32 tsf_time) in ath_chanctx_setup_timer() argument
370 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_setup_timer()
371 struct ath_hw *ah = sc->sc_ah; in ath_chanctx_setup_timer()
374 ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, tsf_time, 1000000); in ath_chanctx_setup_timer()
377 mod_timer(&sc->sched.timer, jiffies + timeout); in ath_chanctx_setup_timer()
384 static void ath_chanctx_handle_bmiss(struct ath_softc *sc, in ath_chanctx_handle_bmiss() argument
394 if (ctx->active && sc->sched.extend_absence) { in ath_chanctx_handle_bmiss()
396 sc->sched.extend_absence = false; in ath_chanctx_handle_bmiss()
403 if (ctx->active && sc->sched.beacon_miss >= 2) { in ath_chanctx_handle_bmiss()
405 sc->sched.extend_absence = true; in ath_chanctx_handle_bmiss()
409 static void ath_chanctx_offchannel_noa(struct ath_softc *sc, in ath_chanctx_offchannel_noa() argument
414 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_offchannel_noa()
418 avp->offchannel_duration = sc->sched.offchannel_duration; in ath_chanctx_offchannel_noa()
435 static void ath_chanctx_set_periodic_noa(struct ath_softc *sc, in ath_chanctx_set_periodic_noa() argument
441 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_periodic_noa()
446 if (sc->sched.extend_absence) in ath_chanctx_set_periodic_noa()
448 sc->sched.channel_switch_time; in ath_chanctx_set_periodic_noa()
452 sc->sched.channel_switch_time; in ath_chanctx_set_periodic_noa()
455 sc->sched.extend_absence) in ath_chanctx_set_periodic_noa()
468 static void ath_chanctx_set_oneshot_noa(struct ath_softc *sc, in ath_chanctx_set_oneshot_noa() argument
473 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_oneshot_noa()
479 avp->noa_duration = duration + sc->sched.channel_switch_time; in ath_chanctx_set_oneshot_noa()
489 void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, in ath_chanctx_event() argument
492 struct ath_hw *ah = sc->sc_ah; in ath_chanctx_event()
503 spin_lock_bh(&sc->chan_lock); in ath_chanctx_event()
506 sc->cur_chan->chandef.center_freq1, in ath_chanctx_event()
508 chanctx_state_string(sc->sched.state), in ath_chanctx_event()
509 chanctx_event_delta(sc)); in ath_chanctx_event()
524 if (avp->chanctx != sc->cur_chan) { in ath_chanctx_event()
530 if (sc->sched.offchannel_pending && !sc->sched.wait_switch) { in ath_chanctx_event()
531 sc->sched.offchannel_pending = false; in ath_chanctx_event()
532 sc->next_chan = &sc->offchannel.chan; in ath_chanctx_event()
533 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_event()
538 ctx = ath_chanctx_get_next(sc, sc->cur_chan); in ath_chanctx_event()
539 if (ctx->active && sc->sched.state == ATH_CHANCTX_STATE_IDLE) { in ath_chanctx_event()
540 sc->next_chan = ctx; in ath_chanctx_event()
541 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_event()
547 if (sc->sched.state == ATH_CHANCTX_STATE_WAIT_FOR_TIMER) { in ath_chanctx_event()
548 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_event()
553 if (sc->sched.mgd_prepare_tx) in ath_chanctx_event()
554 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_event()
563 sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) { in ath_chanctx_event()
571 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) in ath_chanctx_event()
576 sc->sched.beacon_pending = true; in ath_chanctx_event()
577 sc->sched.next_tbtt = REG_READ(ah, AR_NEXT_TBTT_TIMER); in ath_chanctx_event()
579 cur_conf = &sc->cur_chan->beacon; in ath_chanctx_event()
583 tsf_time = sc->sched.next_tbtt + beacon_int / 4; in ath_chanctx_event()
584 sc->sched.switch_start_time = tsf_time; in ath_chanctx_event()
585 sc->cur_chan->last_beacon = sc->sched.next_tbtt; in ath_chanctx_event()
592 if (sc->next_chan == &sc->offchannel.chan) { in ath_chanctx_event()
593 ath_chanctx_offchannel_noa(sc, ctx, avp, tsf_time); in ath_chanctx_event()
597 ath_chanctx_handle_bmiss(sc, ctx, avp); in ath_chanctx_event()
605 if (sc->sched.mgd_prepare_tx) { in ath_chanctx_event()
606 ath_chanctx_set_oneshot_noa(sc, avp, tsf_time, in ath_chanctx_event()
621 (!avp->noa_duration || sc->sched.force_noa_update)) in ath_chanctx_event()
622 ath_chanctx_set_periodic_noa(sc, avp, cur_conf, in ath_chanctx_event()
625 if (ctx->active && sc->sched.force_noa_update) in ath_chanctx_event()
626 sc->sched.force_noa_update = false; in ath_chanctx_event()
630 if (!sc->sched.beacon_pending) { in ath_chanctx_event()
636 sc->sched.beacon_pending = false; in ath_chanctx_event()
638 if (sc->sched.mgd_prepare_tx) { in ath_chanctx_event()
639 sc->sched.mgd_prepare_tx = false; in ath_chanctx_event()
640 complete(&sc->go_beacon); in ath_chanctx_event()
646 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON) in ath_chanctx_event()
652 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER; in ath_chanctx_event()
653 ath_chanctx_setup_timer(sc, sc->sched.switch_start_time); in ath_chanctx_event()
656 if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_TIMER) in ath_chanctx_event()
659 if (!sc->cur_chan->switch_after_beacon && in ath_chanctx_event()
660 sc->sched.beacon_pending) in ath_chanctx_event()
661 sc->sched.beacon_miss++; in ath_chanctx_event()
666 sc->sched.state = ATH_CHANCTX_STATE_SWITCH; in ath_chanctx_event()
667 ieee80211_queue_work(sc->hw, &sc->chanctx_work); in ath_chanctx_event()
671 sc->cur_chan == &sc->offchannel.chan) in ath_chanctx_event()
674 sc->sched.beacon_pending = false; in ath_chanctx_event()
675 sc->sched.beacon_miss = 0; in ath_chanctx_event()
677 if (sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE || in ath_chanctx_event()
678 !sc->sched.beacon_adjust || in ath_chanctx_event()
679 !sc->cur_chan->tsf_val) in ath_chanctx_event()
682 ath_chanctx_adjust_tbtt_delta(sc); in ath_chanctx_event()
687 tsf_time = sc->sched.switch_start_time; in ath_chanctx_event()
688 tsf_time -= (u32) sc->cur_chan->tsf_val + in ath_chanctx_event()
689 ath9k_hw_get_tsf_offset(sc->cur_chan->tsf_ts, 0); in ath_chanctx_event()
692 sc->sched.beacon_adjust = false; in ath_chanctx_event()
693 ath_chanctx_setup_timer(sc, tsf_time); in ath_chanctx_event()
696 if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE || in ath_chanctx_event()
697 avp->chanctx != sc->cur_chan) in ath_chanctx_event()
703 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_event()
707 sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE || in ath_chanctx_event()
708 sc->cur_chan->switch_after_beacon || in ath_chanctx_event()
709 sc->cur_chan == &sc->offchannel.chan) in ath_chanctx_event()
715 sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan); in ath_chanctx_event()
716 cur_conf = &sc->cur_chan->beacon; in ath_chanctx_event()
721 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_TIMER; in ath_chanctx_event()
722 sc->sched.wait_switch = false; in ath_chanctx_event()
726 if (sc->sched.extend_absence) { in ath_chanctx_event()
727 sc->sched.beacon_miss = 0; in ath_chanctx_event()
731 tsf_time -= sc->sched.channel_switch_time; in ath_chanctx_event()
732 tsf_time += ath9k_hw_gettsf32(sc->sc_ah); in ath_chanctx_event()
733 sc->sched.switch_start_time = tsf_time; in ath_chanctx_event()
735 ath_chanctx_setup_timer(sc, tsf_time); in ath_chanctx_event()
736 sc->sched.beacon_pending = true; in ath_chanctx_event()
737 sc->sched.beacon_adjust = true; in ath_chanctx_event()
740 if (sc->cur_chan == &sc->offchannel.chan || in ath_chanctx_event()
741 sc->cur_chan->switch_after_beacon) in ath_chanctx_event()
744 sc->next_chan = ath_chanctx_get_next(sc, sc->cur_chan); in ath_chanctx_event()
745 ieee80211_queue_work(sc->hw, &sc->chanctx_work); in ath_chanctx_event()
748 if (sc->cur_chan->assigned) { in ath_chanctx_event()
749 if (sc->next_chan && !sc->next_chan->assigned && in ath_chanctx_event()
750 sc->next_chan != &sc->offchannel.chan) in ath_chanctx_event()
751 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_event()
755 ctx = ath_chanctx_get_next(sc, sc->cur_chan); in ath_chanctx_event()
756 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_event()
760 sc->next_chan = ctx; in ath_chanctx_event()
761 ieee80211_queue_work(sc->hw, &sc->chanctx_work); in ath_chanctx_event()
769 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_event()
772 void ath_chanctx_beacon_sent_ev(struct ath_softc *sc, in ath_chanctx_beacon_sent_ev() argument
775 if (sc->sched.beacon_pending) in ath_chanctx_beacon_sent_ev()
776 ath_chanctx_event(sc, NULL, ev); in ath_chanctx_beacon_sent_ev()
779 void ath_chanctx_beacon_recv_ev(struct ath_softc *sc, in ath_chanctx_beacon_recv_ev() argument
782 ath_chanctx_event(sc, NULL, ev); in ath_chanctx_beacon_recv_ev()
785 static int ath_scan_channel_duration(struct ath_softc *sc, in ath_scan_channel_duration() argument
788 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_channel_duration()
796 static void ath_chanctx_switch(struct ath_softc *sc, struct ath_chanctx *ctx, in ath_chanctx_switch() argument
799 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_switch()
801 spin_lock_bh(&sc->chan_lock); in ath_chanctx_switch()
804 (sc->cur_chan != ctx) && (ctx == &sc->offchannel.chan)) { in ath_chanctx_switch()
808 sc->sched.offchannel_pending = true; in ath_chanctx_switch()
809 sc->sched.wait_switch = true; in ath_chanctx_switch()
810 sc->sched.offchannel_duration = in ath_chanctx_switch()
811 jiffies_to_usecs(sc->offchannel.duration) + in ath_chanctx_switch()
812 sc->sched.channel_switch_time; in ath_chanctx_switch()
814 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_switch()
820 sc->next_chan = ctx; in ath_chanctx_switch()
827 if (sc->next_chan == &sc->offchannel.chan) { in ath_chanctx_switch()
828 sc->sched.offchannel_duration = in ath_chanctx_switch()
829 jiffies_to_usecs(sc->offchannel.duration) + in ath_chanctx_switch()
830 sc->sched.channel_switch_time; in ath_chanctx_switch()
836 sc->sched.offchannel_duration); in ath_chanctx_switch()
839 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_switch()
840 ieee80211_queue_work(sc->hw, &sc->chanctx_work); in ath_chanctx_switch()
843 static void ath_chanctx_offchan_switch(struct ath_softc *sc, in ath_chanctx_offchan_switch() argument
846 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_offchan_switch()
853 ath_chanctx_switch(sc, &sc->offchannel.chan, &chandef); in ath_chanctx_offchan_switch()
856 static struct ath_chanctx *ath_chanctx_get_oper_chan(struct ath_softc *sc, in ath_chanctx_get_oper_chan() argument
861 ath_for_each_chanctx(sc, ctx) { in ath_chanctx_get_oper_chan()
871 return &sc->chanctx[0]; in ath_chanctx_get_oper_chan()
875 ath_scan_next_channel(struct ath_softc *sc) in ath_scan_next_channel() argument
877 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_scan_next_channel()
878 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_next_channel()
881 if (sc->offchannel.scan_idx >= req->n_channels) { in ath_scan_next_channel()
885 sc->offchannel.scan_idx, in ath_scan_next_channel()
888 sc->offchannel.state = ATH_OFFCHANNEL_IDLE; in ath_scan_next_channel()
889 ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false), in ath_scan_next_channel()
896 sc->offchannel.scan_idx); in ath_scan_next_channel()
898 chan = req->channels[sc->offchannel.scan_idx++]; in ath_scan_next_channel()
899 sc->offchannel.duration = ath_scan_channel_duration(sc, chan); in ath_scan_next_channel()
900 sc->offchannel.state = ATH_OFFCHANNEL_PROBE_SEND; in ath_scan_next_channel()
902 ath_chanctx_offchan_switch(sc, chan); in ath_scan_next_channel()
905 void ath_offchannel_next(struct ath_softc *sc) in ath_offchannel_next() argument
909 if (sc->offchannel.scan_req) { in ath_offchannel_next()
910 vif = sc->offchannel.scan_vif; in ath_offchannel_next()
911 sc->offchannel.chan.txpower = vif->bss_conf.txpower; in ath_offchannel_next()
912 ath_scan_next_channel(sc); in ath_offchannel_next()
913 } else if (sc->offchannel.roc_vif) { in ath_offchannel_next()
914 vif = sc->offchannel.roc_vif; in ath_offchannel_next()
915 sc->offchannel.chan.txpower = vif->bss_conf.txpower; in ath_offchannel_next()
916 sc->offchannel.duration = in ath_offchannel_next()
917 msecs_to_jiffies(sc->offchannel.roc_duration); in ath_offchannel_next()
918 sc->offchannel.state = ATH_OFFCHANNEL_ROC_START; in ath_offchannel_next()
919 ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan); in ath_offchannel_next()
921 spin_lock_bh(&sc->chan_lock); in ath_offchannel_next()
922 sc->sched.offchannel_pending = false; in ath_offchannel_next()
923 sc->sched.wait_switch = false; in ath_offchannel_next()
924 spin_unlock_bh(&sc->chan_lock); in ath_offchannel_next()
926 ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false), in ath_offchannel_next()
928 sc->offchannel.state = ATH_OFFCHANNEL_IDLE; in ath_offchannel_next()
929 if (sc->ps_idle) in ath_offchannel_next()
930 ath_cancel_work(sc); in ath_offchannel_next()
934 void ath_roc_complete(struct ath_softc *sc, enum ath_roc_complete_reason reason) in ath_roc_complete() argument
936 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_roc_complete()
938 sc->offchannel.roc_vif = NULL; in ath_roc_complete()
939 sc->offchannel.roc_chan = NULL; in ath_roc_complete()
944 ieee80211_remain_on_channel_expired(sc->hw); in ath_roc_complete()
948 ieee80211_remain_on_channel_expired(sc->hw); in ath_roc_complete()
955 ath_offchannel_next(sc); in ath_roc_complete()
956 ath9k_ps_restore(sc); in ath_roc_complete()
959 void ath_scan_complete(struct ath_softc *sc, bool abort) in ath_scan_complete() argument
961 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_scan_complete()
971 sc->offchannel.scan_req = NULL; in ath_scan_complete()
972 sc->offchannel.scan_vif = NULL; in ath_scan_complete()
973 sc->offchannel.state = ATH_OFFCHANNEL_IDLE; in ath_scan_complete()
974 ieee80211_scan_completed(sc->hw, &info); in ath_scan_complete()
976 spin_lock_bh(&sc->chan_lock); in ath_scan_complete()
978 sc->sched.force_noa_update = true; in ath_scan_complete()
979 spin_unlock_bh(&sc->chan_lock); in ath_scan_complete()
980 ath_offchannel_next(sc); in ath_scan_complete()
981 ath9k_ps_restore(sc); in ath_scan_complete()
984 static void ath_scan_send_probe(struct ath_softc *sc, in ath_scan_send_probe() argument
987 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_send_probe()
988 struct ieee80211_vif *vif = sc->offchannel.scan_vif; in ath_scan_send_probe()
992 int band = sc->offchannel.chan.chandef.chan->band; in ath_scan_send_probe()
994 skb = ieee80211_probereq_get(sc->hw, vif->addr, in ath_scan_send_probe()
1008 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, NULL)) in ath_scan_send_probe()
1011 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO]; in ath_scan_send_probe()
1012 if (ath_tx_start(sc->hw, skb, &txctl)) in ath_scan_send_probe()
1018 ieee80211_free_txskb(sc->hw, skb); in ath_scan_send_probe()
1021 static void ath_scan_channel_start(struct ath_softc *sc) in ath_scan_channel_start() argument
1023 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_scan_channel_start()
1024 struct cfg80211_scan_request *req = sc->offchannel.scan_req; in ath_scan_channel_start()
1027 if (!(sc->cur_chan->chandef.chan->flags & IEEE80211_CHAN_NO_IR) && in ath_scan_channel_start()
1030 ath_scan_send_probe(sc, &req->ssids[i]); in ath_scan_channel_start()
1037 sc->offchannel.state = ATH_OFFCHANNEL_PROBE_WAIT; in ath_scan_channel_start()
1038 mod_timer(&sc->offchannel.timer, jiffies + sc->offchannel.duration); in ath_scan_channel_start()
1043 struct ath_softc *sc = from_timer(sc, t, sched.timer); in ath_chanctx_timer() local
1044 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_timer()
1049 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_TSF_TIMER); in ath_chanctx_timer()
1054 struct ath_softc *sc = from_timer(sc, t, offchannel.timer); in ath_offchannel_timer() local
1056 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_offchannel_timer()
1059 __func__, offchannel_state_string(sc->offchannel.state)); in ath_offchannel_timer()
1061 switch (sc->offchannel.state) { in ath_offchannel_timer()
1063 if (!sc->offchannel.scan_req) in ath_offchannel_timer()
1067 ctx = ath_chanctx_get_oper_chan(sc, true); in ath_offchannel_timer()
1073 sc->offchannel.state = ATH_OFFCHANNEL_SUSPEND; in ath_offchannel_timer()
1074 ath_chanctx_switch(sc, ctx, NULL); in ath_offchannel_timer()
1075 mod_timer(&sc->offchannel.timer, jiffies + HZ / 10); in ath_offchannel_timer()
1080 if (!sc->offchannel.scan_req) in ath_offchannel_timer()
1083 ath_scan_next_channel(sc); in ath_offchannel_timer()
1087 sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE; in ath_offchannel_timer()
1088 ath_roc_complete(sc, ATH_ROC_COMPLETE_EXPIRE); in ath_offchannel_timer()
1096 ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, struct ath_vif *avp, in ath_chanctx_send_vif_ps_frame() argument
1104 int band = sc->cur_chan->chandef.chan->band; in ath_chanctx_send_vif_ps_frame()
1111 skb = ieee80211_nullfunc_get(sc->hw, vif, -1, false); in ath_chanctx_send_vif_ps_frame()
1122 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) { in ath_chanctx_send_vif_ps_frame()
1132 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO]; in ath_chanctx_send_vif_ps_frame()
1134 if (ath_tx_start(sc->hw, skb, &txctl)) { in ath_chanctx_send_vif_ps_frame()
1135 ieee80211_free_txskb(sc->hw, skb); in ath_chanctx_send_vif_ps_frame()
1143 ath_chanctx_send_ps_frame(struct ath_softc *sc, bool powersave) in ath_chanctx_send_ps_frame() argument
1149 list_for_each_entry(avp, &sc->cur_chan->vifs, list) { in ath_chanctx_send_ps_frame()
1150 if (ath_chanctx_send_vif_ps_frame(sc, avp, powersave)) in ath_chanctx_send_ps_frame()
1158 static bool ath_chanctx_defer_switch(struct ath_softc *sc) in ath_chanctx_defer_switch() argument
1160 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_defer_switch()
1162 if (sc->cur_chan == &sc->offchannel.chan) in ath_chanctx_defer_switch()
1165 switch (sc->sched.state) { in ath_chanctx_defer_switch()
1169 if (!sc->cur_chan->switch_after_beacon) in ath_chanctx_defer_switch()
1175 sc->sched.state = ATH_CHANCTX_STATE_WAIT_FOR_BEACON; in ath_chanctx_defer_switch()
1184 static void ath_offchannel_channel_change(struct ath_softc *sc) in ath_offchannel_channel_change() argument
1186 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_offchannel_channel_change()
1189 __func__, offchannel_state_string(sc->offchannel.state)); in ath_offchannel_channel_change()
1191 switch (sc->offchannel.state) { in ath_offchannel_channel_change()
1193 if (!sc->offchannel.scan_req) in ath_offchannel_channel_change()
1196 if (sc->cur_chan->chandef.chan != in ath_offchannel_channel_change()
1197 sc->offchannel.chan.chandef.chan) in ath_offchannel_channel_change()
1200 ath_scan_channel_start(sc); in ath_offchannel_channel_change()
1203 if (!sc->offchannel.scan_req) in ath_offchannel_channel_change()
1206 ath_scan_complete(sc, false); in ath_offchannel_channel_change()
1209 if (sc->cur_chan != &sc->offchannel.chan) in ath_offchannel_channel_change()
1212 sc->offchannel.state = ATH_OFFCHANNEL_ROC_WAIT; in ath_offchannel_channel_change()
1213 mod_timer(&sc->offchannel.timer, in ath_offchannel_channel_change()
1214 jiffies + sc->offchannel.duration); in ath_offchannel_channel_change()
1215 ieee80211_ready_on_channel(sc->hw); in ath_offchannel_channel_change()
1224 void ath_chanctx_set_next(struct ath_softc *sc, bool force) in ath_chanctx_set_next() argument
1226 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_chanctx_set_next()
1233 spin_lock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1234 if (!sc->next_chan) { in ath_chanctx_set_next()
1235 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1239 if (!force && ath_chanctx_defer_switch(sc)) { in ath_chanctx_set_next()
1240 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1247 sc->cur_chan->chandef.center_freq1, in ath_chanctx_set_next()
1248 sc->next_chan->chandef.center_freq1); in ath_chanctx_set_next()
1250 if (sc->cur_chan != sc->next_chan) { in ath_chanctx_set_next()
1253 sc->cur_chan->chandef.center_freq1); in ath_chanctx_set_next()
1254 sc->cur_chan->stopped = true; in ath_chanctx_set_next()
1255 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1257 if (sc->next_chan == &sc->offchannel.chan) { in ath_chanctx_set_next()
1262 ath9k_chanctx_stop_queues(sc, sc->cur_chan); in ath_chanctx_set_next()
1265 __ath9k_flush(sc->hw, ~0, true, false, false); in ath_chanctx_set_next()
1267 if (ath_chanctx_send_ps_frame(sc, true)) in ath_chanctx_set_next()
1268 __ath9k_flush(sc->hw, BIT(IEEE80211_AC_VO), in ath_chanctx_set_next()
1272 spin_lock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1274 if (sc->cur_chan != &sc->offchannel.chan) { in ath_chanctx_set_next()
1275 sc->cur_chan->tsf_ts = ktime_get_raw(); in ath_chanctx_set_next()
1276 sc->cur_chan->tsf_val = ath9k_hw_gettsf64(sc->sc_ah); in ath_chanctx_set_next()
1279 old_ctx = sc->cur_chan; in ath_chanctx_set_next()
1280 sc->cur_chan = sc->next_chan; in ath_chanctx_set_next()
1281 sc->cur_chan->stopped = false; in ath_chanctx_set_next()
1282 sc->next_chan = NULL; in ath_chanctx_set_next()
1284 if (!sc->sched.offchannel_pending) in ath_chanctx_set_next()
1285 sc->sched.offchannel_duration = 0; in ath_chanctx_set_next()
1287 if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE) in ath_chanctx_set_next()
1288 sc->sched.state = ATH_CHANCTX_STATE_IDLE; in ath_chanctx_set_next()
1290 spin_unlock_bh(&sc->chan_lock); in ath_chanctx_set_next()
1292 if (sc->sc_ah->chip_fullsleep || in ath_chanctx_set_next()
1293 memcmp(&sc->cur_chandef, &sc->cur_chan->chandef, in ath_chanctx_set_next()
1294 sizeof(sc->cur_chandef))) { in ath_chanctx_set_next()
1297 __func__, sc->cur_chan->chandef.center_freq1); in ath_chanctx_set_next()
1298 ath_set_channel(sc); in ath_chanctx_set_next()
1300 sc->sched.channel_switch_time = in ath_chanctx_set_next()
1310 ath9k_chanctx_wake_queues(sc, old_ctx); in ath_chanctx_set_next()
1313 ath_chanctx_send_ps_frame(sc, false); in ath_chanctx_set_next()
1315 ath_offchannel_channel_change(sc); in ath_chanctx_set_next()
1316 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_SWITCH); in ath_chanctx_set_next()
1321 struct ath_softc *sc = container_of(work, struct ath_softc, in ath_chanctx_work() local
1323 mutex_lock(&sc->mutex); in ath_chanctx_work()
1324 ath_chanctx_set_next(sc, false); in ath_chanctx_work()
1325 mutex_unlock(&sc->mutex); in ath_chanctx_work()
1328 void ath9k_offchannel_init(struct ath_softc *sc) in ath9k_offchannel_init() argument
1331 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_offchannel_init()
1342 ctx = &sc->offchannel.chan; in ath9k_offchannel_init()
1353 sc->offchannel.chan.offchannel = true; in ath9k_offchannel_init()
1356 void ath9k_init_channel_context(struct ath_softc *sc) in ath9k_init_channel_context() argument
1358 INIT_WORK(&sc->chanctx_work, ath_chanctx_work); in ath9k_init_channel_context()
1360 timer_setup(&sc->offchannel.timer, ath_offchannel_timer, 0); in ath9k_init_channel_context()
1361 timer_setup(&sc->sched.timer, ath_chanctx_timer, 0); in ath9k_init_channel_context()
1363 init_completion(&sc->go_beacon); in ath9k_init_channel_context()
1366 void ath9k_deinit_channel_context(struct ath_softc *sc) in ath9k_deinit_channel_context() argument
1368 cancel_work_sync(&sc->chanctx_work); in ath9k_deinit_channel_context()
1380 void ath9k_chanctx_stop_queues(struct ath_softc *sc, struct ath_chanctx *ctx) in ath9k_chanctx_stop_queues() argument
1382 struct ath_hw *ah = sc->sc_ah; in ath9k_chanctx_stop_queues()
1385 if (ctx == &sc->offchannel.chan) { in ath9k_chanctx_stop_queues()
1386 ieee80211_stop_queue(sc->hw, in ath9k_chanctx_stop_queues()
1387 sc->hw->offchannel_tx_hw_queue); in ath9k_chanctx_stop_queues()
1390 ieee80211_stop_queue(sc->hw, in ath9k_chanctx_stop_queues()
1395 ieee80211_stop_queue(sc->hw, sc->hw->queues - 2); in ath9k_chanctx_stop_queues()
1399 void ath9k_chanctx_wake_queues(struct ath_softc *sc, struct ath_chanctx *ctx) in ath9k_chanctx_wake_queues() argument
1401 struct ath_hw *ah = sc->sc_ah; in ath9k_chanctx_wake_queues()
1404 if (ctx == &sc->offchannel.chan) { in ath9k_chanctx_wake_queues()
1405 ieee80211_wake_queue(sc->hw, in ath9k_chanctx_wake_queues()
1406 sc->hw->offchannel_tx_hw_queue); in ath9k_chanctx_wake_queues()
1409 ieee80211_wake_queue(sc->hw, in ath9k_chanctx_wake_queues()
1414 ieee80211_wake_queue(sc->hw, sc->hw->queues - 2); in ath9k_chanctx_wake_queues()
1421 static void ath9k_update_p2p_ps_timer(struct ath_softc *sc, struct ath_vif *avp) in ath9k_update_p2p_ps_timer() argument
1423 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_update_p2p_ps_timer()
1424 struct ath_hw *ah = sc->sc_ah; in ath9k_update_p2p_ps_timer()
1430 ath9k_hw_gen_timer_stop(ah, sc->p2p_ps_timer); in ath9k_update_p2p_ps_timer()
1432 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_update_p2p_ps_timer()
1447 ath9k_hw_gen_timer_start(ah, sc->p2p_ps_timer, target_tsf, 1000000); in ath9k_update_p2p_ps_timer()
1450 static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif) in ath9k_update_p2p_ps() argument
1455 if (!sc->p2p_ps_timer) in ath9k_update_p2p_ps()
1461 sc->p2p_ps_vif = avp; in ath9k_update_p2p_ps()
1463 if (sc->ps_flags & PS_BEACON_SYNC) in ath9k_update_p2p_ps()
1466 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_update_p2p_ps()
1468 ath9k_update_p2p_ps_timer(sc, avp); in ath9k_update_p2p_ps()
1471 static u8 ath9k_get_ctwin(struct ath_softc *sc, struct ath_vif *avp) in ath9k_get_ctwin() argument
1473 struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon; in ath9k_get_ctwin()
1495 void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, in ath9k_beacon_add_noa() argument
1525 noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp); in ath9k_beacon_add_noa()
1531 u32 interval = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval); in ath9k_beacon_add_noa()
1552 struct ath_softc *sc = priv; in ath9k_p2p_ps_timer() local
1553 struct ath_vif *avp = sc->p2p_ps_vif; in ath9k_p2p_ps_timer()
1559 del_timer_sync(&sc->sched.timer); in ath9k_p2p_ps_timer()
1560 ath9k_hw_gen_timer_stop(sc->sc_ah, sc->p2p_ps_timer); in ath9k_p2p_ps_timer()
1561 ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_TSF_TIMER); in ath9k_p2p_ps_timer()
1563 if (!avp || avp->chanctx != sc->cur_chan) in ath9k_p2p_ps_timer()
1566 tsf = ath9k_hw_gettsf32(sc->sc_ah); in ath9k_p2p_ps_timer()
1576 ath9k_update_p2p_ps_timer(sc, avp); in ath9k_p2p_ps_timer()
1591 ath_tx_aggr_sleep(sta, sc, an); in ath9k_p2p_ps_timer()
1593 ath_tx_aggr_wakeup(sc, an); in ath9k_p2p_ps_timer()
1599 void ath9k_p2p_bss_info_changed(struct ath_softc *sc, in ath9k_p2p_bss_info_changed() argument
1604 spin_lock_bh(&sc->sc_pcu_lock); in ath9k_p2p_bss_info_changed()
1605 spin_lock_irqsave(&sc->sc_pm_lock, flags); in ath9k_p2p_bss_info_changed()
1606 ath9k_update_p2p_ps(sc, vif); in ath9k_p2p_bss_info_changed()
1607 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); in ath9k_p2p_bss_info_changed()
1608 spin_unlock_bh(&sc->sc_pcu_lock); in ath9k_p2p_bss_info_changed()
1611 void ath9k_p2p_beacon_sync(struct ath_softc *sc) in ath9k_p2p_beacon_sync() argument
1613 if (sc->p2p_ps_vif) in ath9k_p2p_beacon_sync()
1614 ath9k_update_p2p_ps(sc, sc->p2p_ps_vif->vif); in ath9k_p2p_beacon_sync()
1617 void ath9k_p2p_remove_vif(struct ath_softc *sc, in ath9k_p2p_remove_vif() argument
1622 spin_lock_bh(&sc->sc_pcu_lock); in ath9k_p2p_remove_vif()
1623 if (avp == sc->p2p_ps_vif) { in ath9k_p2p_remove_vif()
1624 sc->p2p_ps_vif = NULL; in ath9k_p2p_remove_vif()
1625 ath9k_update_p2p_ps_timer(sc, NULL); in ath9k_p2p_remove_vif()
1627 spin_unlock_bh(&sc->sc_pcu_lock); in ath9k_p2p_remove_vif()
1630 int ath9k_init_p2p(struct ath_softc *sc) in ath9k_init_p2p() argument
1632 sc->p2p_ps_timer = ath_gen_timer_alloc(sc->sc_ah, ath9k_p2p_ps_timer, in ath9k_init_p2p()
1633 NULL, sc, AR_FIRST_NDP_TIMER); in ath9k_init_p2p()
1634 if (!sc->p2p_ps_timer) in ath9k_init_p2p()
1640 void ath9k_deinit_p2p(struct ath_softc *sc) in ath9k_deinit_p2p() argument
1642 if (sc->p2p_ps_timer) in ath9k_deinit_p2p()
1643 ath_gen_timer_free(sc->sc_ah, sc->p2p_ps_timer); in ath9k_deinit_p2p()