Lines Matching refs:sc
22 static void ath9k_reset_beacon_status(struct ath_softc *sc) in ath9k_reset_beacon_status() argument
24 sc->beacon.tx_processed = false; in ath9k_reset_beacon_status()
25 sc->beacon.tx_last = false; in ath9k_reset_beacon_status()
33 static void ath9k_beaconq_config(struct ath_softc *sc) in ath9k_beaconq_config() argument
35 struct ath_hw *ah = sc->sc_ah; in ath9k_beaconq_config()
40 ath9k_hw_get_txq_props(ah, sc->beacon.beaconq, &qi); in ath9k_beaconq_config()
42 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP || in ath9k_beaconq_config()
43 sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) { in ath9k_beaconq_config()
50 txq = sc->tx.txq_map[IEEE80211_AC_BE]; in ath9k_beaconq_config()
60 if (!ath9k_hw_set_txq_props(ah, sc->beacon.beaconq, &qi)) { in ath9k_beaconq_config()
63 ath9k_hw_resettxqueue(ah, sc->beacon.beaconq); in ath9k_beaconq_config()
72 static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif, in ath9k_beacon_setup() argument
76 struct ath_hw *ah = sc->sc_ah; in ath9k_beacon_setup()
83 sband = &common->sbands[sc->cur_chandef.chan->band]; in ath9k_beacon_setup()
103 info.qcu = sc->beacon.beaconq; in ath9k_beacon_setup()
107 info.rates[0].ChSel = ath_txchainmask_reduction(sc, chainmask, rate); in ath9k_beacon_setup()
115 struct ath_softc *sc = hw->priv; in ath9k_beacon_generate() local
116 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_beacon_generate()
120 struct ath_txq *cabq = sc->beacon.cabq; in ath9k_beacon_generate()
131 dma_unmap_single(sc->dev, bf->bf_buf_addr, in ath9k_beacon_generate()
153 ath9k_beacon_add_noa(sc, avp, skb); in ath9k_beacon_generate()
155 bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, in ath9k_beacon_generate()
157 if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { in ath9k_beacon_generate()
180 if (sc->cur_chan->nvifs > 1) { in ath9k_beacon_generate()
183 ath_draintxq(sc, cabq); in ath9k_beacon_generate()
187 ath9k_beacon_setup(sc, vif, bf, info->control.rates[0].idx); in ath9k_beacon_generate()
195 void ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif) in ath9k_beacon_assign_slot() argument
197 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_beacon_assign_slot()
201 avp->av_bcbuf = list_first_entry(&sc->beacon.bbuf, struct ath_buf, list); in ath9k_beacon_assign_slot()
205 if (sc->beacon.bslot[slot] == NULL) { in ath9k_beacon_assign_slot()
211 sc->beacon.bslot[avp->av_bslot] = vif; in ath9k_beacon_assign_slot()
217 void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif) in ath9k_beacon_remove_slot() argument
219 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_beacon_remove_slot()
226 tasklet_disable(&sc->bcon_tasklet); in ath9k_beacon_remove_slot()
230 dma_unmap_single(sc->dev, bf->bf_buf_addr, in ath9k_beacon_remove_slot()
238 sc->beacon.bslot[avp->av_bslot] = NULL; in ath9k_beacon_remove_slot()
239 list_add_tail(&bf->list, &sc->beacon.bbuf); in ath9k_beacon_remove_slot()
241 tasklet_enable(&sc->bcon_tasklet); in ath9k_beacon_remove_slot()
244 void ath9k_beacon_ensure_primary_slot(struct ath_softc *sc) in ath9k_beacon_ensure_primary_slot() argument
246 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_beacon_ensure_primary_slot()
254 tasklet_disable_in_atomic(&sc->bcon_tasklet); in ath9k_beacon_ensure_primary_slot()
258 if (sc->beacon.bslot[slot]) { in ath9k_beacon_ensure_primary_slot()
269 vif = sc->beacon.bslot[slot + first_slot]; in ath9k_beacon_ensure_primary_slot()
270 sc->beacon.bslot[slot] = vif; in ath9k_beacon_ensure_primary_slot()
277 sc->beacon.bslot[slot] = NULL; in ath9k_beacon_ensure_primary_slot()
281 vif = sc->beacon.bslot[0]; in ath9k_beacon_ensure_primary_slot()
295 if (sc->cur_chan == avp->chanctx) { in ath9k_beacon_ensure_primary_slot()
297 ath9k_hw_settsf64(sc->sc_ah, avp->chanctx->tsf_val + offset); in ath9k_beacon_ensure_primary_slot()
303 tasklet_enable(&sc->bcon_tasklet); in ath9k_beacon_ensure_primary_slot()
306 static int ath9k_beacon_choose_slot(struct ath_softc *sc) in ath9k_beacon_choose_slot() argument
308 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_beacon_choose_slot()
309 struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon; in ath9k_beacon_choose_slot()
315 if (sc->sc_ah->opmode != NL80211_IFTYPE_AP && in ath9k_beacon_choose_slot()
316 sc->sc_ah->opmode != NL80211_IFTYPE_MESH_POINT) { in ath9k_beacon_choose_slot()
318 ath9k_hw_gettsf64(sc->sc_ah)); in ath9k_beacon_choose_slot()
323 tsf = ath9k_hw_gettsf64(sc->sc_ah); in ath9k_beacon_choose_slot()
324 tsf += TU_TO_USEC(sc->sc_ah->config.sw_beacon_response_time); in ath9k_beacon_choose_slot()
334 static void ath9k_set_tsfadjust(struct ath_softc *sc, in ath9k_set_tsfadjust() argument
337 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_set_tsfadjust()
344 if (!sc->beacon.bslot[slot]) in ath9k_set_tsfadjust()
347 avp = (void *)sc->beacon.bslot[slot]->drv_priv; in ath9k_set_tsfadjust()
363 bool ath9k_csa_is_finished(struct ath_softc *sc, struct ieee80211_vif *vif) in ath9k_csa_is_finished() argument
377 struct ath_softc *sc = data; in ath9k_csa_update_vif() local
378 ath9k_csa_is_finished(sc, vif); in ath9k_csa_update_vif()
381 void ath9k_csa_update(struct ath_softc *sc) in ath9k_csa_update() argument
383 ieee80211_iterate_active_interfaces_atomic(sc->hw, in ath9k_csa_update()
385 ath9k_csa_update_vif, sc); in ath9k_csa_update()
390 struct ath_softc *sc = from_tasklet(sc, t, bcon_tasklet); in ath9k_beacon_tasklet() local
391 struct ath_hw *ah = sc->sc_ah; in ath9k_beacon_tasklet()
411 if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0) { in ath9k_beacon_tasklet()
412 sc->beacon.bmisscnt++; in ath9k_beacon_tasklet()
422 if (!ath_hw_check(sc)) in ath9k_beacon_tasklet()
425 if (sc->beacon.bmisscnt < BSTUCK_THRESH * sc->nbcnvifs) { in ath9k_beacon_tasklet()
428 sc->beacon.bmisscnt); in ath9k_beacon_tasklet()
429 ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq); in ath9k_beacon_tasklet()
430 if (sc->beacon.bmisscnt > 3) in ath9k_beacon_tasklet()
432 } else if (sc->beacon.bmisscnt >= BSTUCK_THRESH) { in ath9k_beacon_tasklet()
434 sc->beacon.bmisscnt = 0; in ath9k_beacon_tasklet()
435 ath9k_queue_reset(sc, RESET_TYPE_BEACON_STUCK); in ath9k_beacon_tasklet()
441 slot = ath9k_beacon_choose_slot(sc); in ath9k_beacon_tasklet()
442 vif = sc->beacon.bslot[slot]; in ath9k_beacon_tasklet()
447 ath_chanctx_beacon_sent_ev(sc, in ath9k_beacon_tasklet()
451 if (ath9k_csa_is_finished(sc, vif)) in ath9k_beacon_tasklet()
459 ath_chanctx_event(sc, vif, ATH_CHANCTX_EVENT_BEACON_PREPARE); in ath9k_beacon_tasklet()
462 bf = ath9k_beacon_generate(sc->hw, vif); in ath9k_beacon_tasklet()
464 if (sc->beacon.bmisscnt != 0) { in ath9k_beacon_tasklet()
466 sc->beacon.bmisscnt); in ath9k_beacon_tasklet()
467 sc->beacon.bmisscnt = 0; in ath9k_beacon_tasklet()
486 if (sc->beacon.updateslot == UPDATE) { in ath9k_beacon_tasklet()
487 sc->beacon.updateslot = COMMIT; in ath9k_beacon_tasklet()
488 sc->beacon.slotupdate = slot; in ath9k_beacon_tasklet()
489 } else if (sc->beacon.updateslot == COMMIT && in ath9k_beacon_tasklet()
490 sc->beacon.slotupdate == slot) { in ath9k_beacon_tasklet()
491 ah->slottime = sc->beacon.slottime; in ath9k_beacon_tasklet()
493 sc->beacon.updateslot = OK; in ath9k_beacon_tasklet()
497 ath9k_reset_beacon_status(sc); in ath9k_beacon_tasklet()
503 ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bf->bf_daddr); in ath9k_beacon_tasklet()
506 ath9k_hw_txstart(ah, sc->beacon.beaconq); in ath9k_beacon_tasklet()
513 static void ath9k_beacon_init(struct ath_softc *sc, u32 nexttbtt, in ath9k_beacon_init() argument
516 struct ath_hw *ah = sc->sc_ah; in ath9k_beacon_init()
519 ath9k_beaconq_config(sc); in ath9k_beacon_init()
522 sc->beacon.bmisscnt = 0; in ath9k_beacon_init()
527 static void ath9k_beacon_stop(struct ath_softc *sc) in ath9k_beacon_stop() argument
529 ath9k_hw_disable_interrupts(sc->sc_ah); in ath9k_beacon_stop()
530 sc->sc_ah->imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS); in ath9k_beacon_stop()
531 sc->beacon.bmisscnt = 0; in ath9k_beacon_stop()
532 ath9k_hw_set_interrupts(sc->sc_ah); in ath9k_beacon_stop()
533 ath9k_hw_enable_interrupts(sc->sc_ah); in ath9k_beacon_stop()
541 static void ath9k_beacon_config_ap(struct ath_softc *sc, in ath9k_beacon_config_ap() argument
544 struct ath_hw *ah = sc->sc_ah; in ath9k_beacon_config_ap()
547 ath9k_beacon_init(sc, conf->nexttbtt, conf->intval); in ath9k_beacon_config_ap()
566 static void ath9k_beacon_config_adhoc(struct ath_softc *sc, in ath9k_beacon_config_adhoc() argument
569 struct ath_hw *ah = sc->sc_ah; in ath9k_beacon_config_adhoc()
572 ath9k_reset_beacon_status(sc); in ath9k_beacon_config_adhoc()
576 ath9k_beacon_init(sc, conf->nexttbtt, conf->intval); in ath9k_beacon_config_adhoc()
586 static void ath9k_cache_beacon_config(struct ath_softc *sc, in ath9k_cache_beacon_config() argument
591 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_cache_beacon_config()
622 ath9k_set_tsfadjust(sc, cur_conf); in ath9k_cache_beacon_config()
625 void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *main_vif, in ath9k_beacon_config() argument
628 struct ath_hw *ah = sc->sc_ah; in ath9k_beacon_config()
639 ath9k_beacon_stop(sc); in ath9k_beacon_config()
652 if (sc->sc_ah->opmode == NL80211_IFTYPE_STATION) { in ath9k_beacon_config()
653 ath9k_cache_beacon_config(sc, ctx, main_vif); in ath9k_beacon_config()
655 ath9k_set_beacon(sc); in ath9k_beacon_config()
661 ath9k_cache_beacon_config(sc, ctx, main_vif); in ath9k_beacon_config()
673 if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC && in ath9k_beacon_config()
675 spin_lock_irqsave(&sc->sc_pm_lock, flags); in ath9k_beacon_config()
676 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON; in ath9k_beacon_config()
677 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); in ath9k_beacon_config()
687 ath9k_set_beacon(sc); in ath9k_beacon_config()
690 ath9k_beacon_stop(sc); in ath9k_beacon_config()
694 ath9k_beacon_stop(sc); in ath9k_beacon_config()
698 void ath9k_set_beacon(struct ath_softc *sc) in ath9k_set_beacon() argument
700 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath9k_set_beacon()
701 struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon; in ath9k_set_beacon()
703 switch (sc->sc_ah->opmode) { in ath9k_set_beacon()
706 ath9k_beacon_config_ap(sc, cur_conf); in ath9k_set_beacon()
709 ath9k_beacon_config_adhoc(sc, cur_conf); in ath9k_set_beacon()
712 ath9k_beacon_config_sta(sc->sc_ah, cur_conf); in ath9k_set_beacon()