22 static void ath9k_reset_beacon_status(
struct ath_softc *
sc)
24 sc->
beacon.tx_processed =
false;
25 sc->
beacon.tx_last =
false;
33 static void ath9k_beaconq_config(
struct ath_softc *
sc)
51 qi.tqi_aifs = qi_be.tqi_aifs;
53 qi.tqi_cwmin = 2*qi_be.tqi_cwmin;
55 qi.tqi_cwmin = 4*qi_be.tqi_cwmin;
56 qi.tqi_cwmax = qi_be.tqi_cwmax;
60 ath_err(common,
"Unable to update h/w beacon queue parameters\n");
76 struct ath_common *common = ath9k_hw_common(ah);
82 sband = &sc->
sbands[common->
hw->conf.channel->band];
83 rate = sband->
bitrates[rateidx].hw_value;
84 if (vif->
bss_conf.use_short_preamble)
85 rate |= sband->
bitrates[rateidx].hw_value_short;
103 info.rates[0].Tries = 1;
117 txctl.txq = sc->
beacon.cabq;
119 ath_dbg(common, XMIT,
"transmitting CABQ packet, skb: %p\n", skb);
122 ath_dbg(common, XMIT,
"CABQ TX failed\n");
133 struct ath_vif *avp = (
void *)vif->drv_priv;
152 skb = ieee80211_beacon_get(hw, vif);
161 info = IEEE80211_SKB_CB(skb);
168 sc->
tx.seq_no += 0x10;
179 ath_err(common,
"dma_mapping_error on beaconing\n");
193 spin_lock_bh(&cabq->axq_lock);
194 cabq_depth = cabq->axq_depth;
195 spin_unlock_bh(&cabq->axq_lock);
197 if (skb && cabq_depth) {
200 "Flushing previous cabq traffic\n");
205 ath9k_beacon_setup(sc, vif, bf,
info->control.rates[0].idx);
208 ath9k_tx_cabq(hw, skb);
218 struct ath_vif *avp = (
void *)vif->drv_priv;
234 ath_dbg(common,
CONFIG,
"Added interface at beacon slot: %d\n",
241 struct ath_vif *avp = (
void *)vif->drv_priv;
244 ath_dbg(common,
CONFIG,
"Removing interface at beacon slot: %d\n",
266 static int ath9k_beacon_choose_slot(
struct ath_softc *sc)
285 slot = (tsftu % (intval *
ATH_BCBUF)) / intval;
297 struct ath_vif *avp = (
void *)vif->drv_priv;
306 ath_dbg(common,
CONFIG,
"tsfadjust is: %llu for bslot: %d\n",
307 (
unsigned long long)tsfadjust, avp->
av_bslot);
314 struct ath_common *common = ath9k_hw_common(ah);
322 "reset work is pending, skip beaconing now\n");
341 "missed %u consecutive beacons\n",
344 if (sc->
beacon.bmisscnt > 3)
347 ath_dbg(common, BSTUCK,
"beacon is officially stuck\n");
355 slot = ath9k_beacon_choose_slot(sc);
358 if (!vif || !vif->
bss_conf.enable_beacon)
361 bf = ath9k_beacon_generate(sc->
hw, vif);
364 if (sc->
beacon.bmisscnt != 0) {
365 ath_dbg(common, BSTUCK,
"resume beacon xmit after %u misses\n",
387 sc->
beacon.updateslot = COMMIT;
389 }
else if (sc->
beacon.updateslot == COMMIT &&
390 sc->
beacon.slotupdate == slot) {
397 ath9k_reset_beacon_status(sc);
400 "Transmitting beacon for slot: %d\n", slot);
410 static void ath9k_beacon_init(
struct ath_softc *sc,
u32 nexttbtt,
u32 intval)
416 ath9k_beaconq_config(sc);
428 static void ath9k_beacon_config_ap(
struct ath_softc *sc,
432 struct ath_common *common = ath9k_hw_common(ah);
433 u32 nexttbtt, intval;
445 ath_dbg(common,
BEACON,
"AP nexttbtt: %u intval: %u conf_intval: %u\n",
448 ath9k_beacon_init(sc, nexttbtt, intval);
459 static void ath9k_beacon_config_sta(
struct ath_softc *sc,
463 struct ath_common *common = ath9k_hw_common(ah);
465 int dtimperiod, dtimcount, sleepduration;
466 int cfpperiod, cfpcount;
467 u32 nexttbtt = 0, intval, tsftu;
469 int num_beacons,
offset, dtim_dec_count, cfp_dec_count;
474 "STA is not yet associated..skipping beacon config\n");
478 memset(&bs, 0,
sizeof(bs));
487 if (dtimcount >= dtimperiod)
501 num_beacons = tsftu / intval + 1;
502 offset = tsftu % intval;
503 nexttbtt = tsftu -
offset;
508 dtim_dec_count = num_beacons % dtimperiod;
510 cfp_dec_count = (num_beacons / dtimperiod) % cfpperiod;
514 dtimcount -= dtim_dec_count;
516 dtimcount += dtimperiod;
518 cfpcount -= cfp_dec_count;
520 cfpcount += cfpperiod;
522 bs.bs_intval = intval;
523 bs.bs_nexttbtt = nexttbtt;
524 bs.bs_dtimperiod = dtimperiod*intval;
525 bs.bs_nextdtim = bs.bs_nexttbtt + dtimcount*intval;
526 bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod;
527 bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod;
528 bs.bs_cfpmaxduration = 0;
536 if (sleepduration > intval) {
541 if (bs.bs_bmissthreshold > 15)
542 bs.bs_bmissthreshold = 15;
543 else if (bs.bs_bmissthreshold <= 0)
544 bs.bs_bmissthreshold = 1;
557 if (bs.bs_sleepduration > bs.bs_dtimperiod)
558 bs.bs_sleepduration = bs.bs_dtimperiod;
563 ath_dbg(common,
BEACON,
"tsf: %llu tsftu: %u\n", tsf, tsftu);
565 "bmiss: %u sleep: %u cfp-period: %u maxdur: %u next: %u\n",
566 bs.bs_bmissthreshold, bs.bs_sleepduration,
567 bs.bs_cfpperiod, bs.bs_cfpmaxduration, bs.bs_cfpnext);
579 static void ath9k_beacon_config_adhoc(
struct ath_softc *sc,
583 struct ath_common *common = ath9k_hw_common(ah);
584 u32 intval, nexttbtt;
586 ath9k_reset_beacon_status(sc);
596 ath_dbg(common,
BEACON,
"IBSS nexttbtt: %u intval: %u conf_intval: %u\n",
599 ath9k_beacon_init(sc, nexttbtt, intval);
605 struct ath_vif *avp = (
void *)vif->drv_priv;
611 "An AP interface is already present !\n");
621 "Beacon already configured for a station interface\n");
629 static void ath9k_cache_beacon_config(
struct ath_softc *sc,
636 "Caching beacon data for BSS: %pM\n", bss_conf->
bssid);
671 ath9k_cache_beacon_config(sc, bss_conf);
685 ath9k_cache_beacon_config(sc, bss_conf);
705 switch (sc->
sc_ah->opmode) {
707 ath9k_beacon_config_ap(sc, cur_conf);
711 ath9k_beacon_config_adhoc(sc, cur_conf);
714 ath9k_beacon_config_sta(sc, cur_conf);