58 "Unable to update beacon queue %u!\n", priv->
beaconq);
71 int dtimperiod, dtimcount, sleepduration;
72 int cfpperiod, cfpcount, bmiss_timeout;
73 u32 nexttbtt = 0, intval, tsftu;
76 int num_beacons,
offset, dtim_dec_count, cfp_dec_count;
80 memset(&bs, 0,
sizeof(bs));
93 if (dtimcount >= dtimperiod)
98 sleepduration = intval;
99 if (sleepduration <= 0)
100 sleepduration = intval;
109 num_beacons = tsftu / intval + 1;
110 offset = tsftu % intval;
111 nexttbtt = tsftu -
offset;
116 dtim_dec_count = num_beacons % dtimperiod;
118 cfp_dec_count = (num_beacons / dtimperiod) % cfpperiod;
122 dtimcount -= dtim_dec_count;
124 dtimcount += dtimperiod;
126 cfpcount -= cfp_dec_count;
128 cfpcount += cfpperiod;
130 bs.bs_intval = intval;
131 bs.bs_nexttbtt = nexttbtt;
132 bs.bs_dtimperiod = dtimperiod*intval;
133 bs.bs_nextdtim = bs.bs_nexttbtt + dtimcount*intval;
134 bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod;
135 bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod;
136 bs.bs_cfpmaxduration = 0;
144 if (sleepduration > intval) {
147 bs.bs_bmissthreshold =
DIV_ROUND_UP(bmiss_timeout, intval);
148 if (bs.bs_bmissthreshold > 15)
149 bs.bs_bmissthreshold = 15;
150 else if (bs.bs_bmissthreshold <= 0)
151 bs.bs_bmissthreshold = 1;
164 if (bs.bs_sleepduration > bs.bs_dtimperiod)
165 bs.bs_sleepduration = bs.bs_dtimperiod;
173 "bmiss: %u sleep: %u cfp-period: %u maxdur: %u next: %u\n",
174 bs.bs_bmissthreshold, bs.bs_sleepduration,
175 bs.bs_cfpperiod, bs.bs_cfpmaxduration, bs.bs_cfpnext);
186 static void ath9k_htc_beacon_config_ap(
struct ath9k_htc_priv *priv,
191 u32 nexttbtt, intval, tsftu;
221 }
while (nexttbtt < tsftu);
228 "AP Beacon config, intval: %d, nexttbtt: %u, resp_time: %d imask: 0x%x\n",
230 priv->
ah->config.sw_beacon_response_time, imask);
241 static void ath9k_htc_beacon_config_adhoc(
struct ath9k_htc_priv *priv,
246 u32 nexttbtt, intval, tsftu;
262 }
while (nexttbtt < tsftu);
276 "IBSS Beacon config, intval: %d, nexttbtt: %u, resp_time: %d, imask: 0x%x\n",
278 priv->
ah->config.sw_beacon_response_time, imask);
312 padsize = padpos & 3;
313 if (padsize && skb->
len > padpos) {
314 if (skb_headroom(skb) <
padsize) {
324 ath_dbg(common, XMIT,
"No free CAB slot\n");
334 ath_dbg(common, XMIT,
"Failed to send CAB frame\n");
336 spin_lock_bh(&priv->
tx.tx_lock);
337 priv->
tx.queued_cnt++;
338 spin_unlock_bh(&priv->
tx.tx_lock);
374 beacon = ieee80211_beacon_get(priv->
hw, vif);
387 info = IEEE80211_SKB_CB(beacon);
396 tx_ctl = HTC_SKB_CB(beacon);
397 memset(tx_ctl, 0,
sizeof(*tx_ctl));
402 beacon_hdr.vif_index = avp->
index;
403 tx_fhdr =
skb_push(beacon,
sizeof(beacon_hdr));
404 memcpy(tx_fhdr, (
u8 *) &beacon_hdr,
sizeof(beacon_hdr));
410 "Failed to send beacon, no free TX buffer\n");
435 "Choose slot: %d, tsf: %llu, tsftu: %u, intval: %u\n",
436 slot, tsf, tsftu, intval);
450 ath_dbg(common, BSTUCK,
"Beacon stuck, HW reset\n");
459 "Resuming beacon xmit after %u misses\n",
464 slot = ath9k_htc_choose_bslot(priv, swba);
472 ath9k_htc_send_buffered(priv, slot);
473 ath9k_htc_send_beacon(priv, slot);
494 ath_dbg(common,
CONFIG,
"Added interface at beacon slot: %d\n",
508 ath_dbg(common,
CONFIG,
"Removed interface at beacon slot: %d\n",
535 ath_dbg(common,
CONFIG,
"tsfadjust is: %llu for bslot: %d\n",
546 *beacon_configured =
true;
549 static bool ath9k_htc_check_beacon_config(
struct ath9k_htc_priv *priv,
555 bool beacon_configured;
567 "Changing beacon interval of multiple AP interfaces !\n");
578 "HW in AP mode, cannot set STA beacon parameters\n");
589 beacon_configured =
false;
591 ath9k_htc_beacon_iter,
594 if (beacon_configured) {
596 "Beacon already configured for a station interface\n");
612 if (!ath9k_htc_check_beacon_config(priv, vif))
625 ath9k_htc_beacon_config_sta(priv, cur_conf);
629 ath9k_htc_beacon_config_adhoc(priv, cur_conf);
632 ath9k_htc_beacon_config_ap(priv, cur_conf);
645 switch (priv->
ah->opmode) {
647 ath9k_htc_beacon_config_sta(priv, cur_conf);
650 ath9k_htc_beacon_config_adhoc(priv, cur_conf);
653 ath9k_htc_beacon_config_ap(priv, cur_conf);