Skip to content

Commit c6820f1

Browse files
Felix Fietkaulinvjw
authored andcommitted
ath9k: fix ad-hoc mode beacon selection
In ad-hoc mode, beacon timers are configured differently compared to AP mode, and (depending on the scenario) can vary enough to make the beacon tasklet not detect slot 0 based on the TSF. Since staggered beacons are not (and cannot be) used in ad-hoc mode, it makes more sense to just hardcode slot 0 here, avoiding unnecessary TSF reads and calculations. Signed-off-by: Felix Fietkau <[email protected]> Reported-by: Rajkumar Manoharan <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent ed9d010 commit c6820f1

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

drivers/net/wireless/ath/ath9k/beacon.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,7 @@ void ath_beacon_tasklet(unsigned long data)
351351
struct ath_buf *bf = NULL;
352352
struct ieee80211_vif *vif;
353353
int slot;
354-
u32 bfaddr, bc = 0, tsftu;
355-
u64 tsf;
356-
u16 intval;
354+
u32 bfaddr, bc = 0;
357355

358356
/*
359357
* Check if the previous beacon has gone out. If
@@ -388,17 +386,27 @@ void ath_beacon_tasklet(unsigned long data)
388386
* on the tsf to safeguard against missing an swba.
389387
*/
390388

391-
intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
392389

393-
tsf = ath9k_hw_gettsf64(ah);
394-
tsf += TU_TO_USEC(ah->config.sw_beacon_response_time);
395-
tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
396-
slot = (tsftu % (intval * ATH_BCBUF)) / intval;
397-
vif = sc->beacon.bslot[slot];
390+
if (ah->opmode == NL80211_IFTYPE_AP) {
391+
u16 intval;
392+
u32 tsftu;
393+
u64 tsf;
394+
395+
intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
396+
tsf = ath9k_hw_gettsf64(ah);
397+
tsf += TU_TO_USEC(ah->config.sw_beacon_response_time);
398+
tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
399+
slot = (tsftu % (intval * ATH_BCBUF)) / intval;
400+
vif = sc->beacon.bslot[slot];
401+
402+
ath_dbg(common, ATH_DBG_BEACON,
403+
"slot %d [tsf %llu tsftu %u intval %u] vif %p\n",
404+
slot, tsf, tsftu / ATH_BCBUF, intval, vif);
405+
} else {
406+
slot = 0;
407+
vif = sc->beacon.bslot[slot];
408+
}
398409

399-
ath_dbg(common, ATH_DBG_BEACON,
400-
"slot %d [tsf %llu tsftu %u intval %u] vif %p\n",
401-
slot, tsf, tsftu / ATH_BCBUF, intval, vif);
402410

403411
bfaddr = 0;
404412
if (vif) {

0 commit comments

Comments
 (0)