aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-05-16 17:22:00 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-05-19 13:53:54 -0400
commitc6820f1e6c8273ca4b8f94c2354193d19e1a5c47 (patch)
tree7f7dbc8c88d7cb31ec280d2c1fc486249ea97aec
parented9d01026f156db2d638cbb045231c7a8fde877d (diff)
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 <nbd@openwrt.org> Reported-by: Rajkumar Manoharan <rmanoharan@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 637dbc5f7b67..c7f46797c75c 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -351,9 +351,7 @@ void ath_beacon_tasklet(unsigned long data)
351 struct ath_buf *bf = NULL; 351 struct ath_buf *bf = NULL;
352 struct ieee80211_vif *vif; 352 struct ieee80211_vif *vif;
353 int slot; 353 int slot;
354 u32 bfaddr, bc = 0, tsftu; 354 u32 bfaddr, bc = 0;
355 u64 tsf;
356 u16 intval;
357 355
358 /* 356 /*
359 * Check if the previous beacon has gone out. If 357 * Check if the previous beacon has gone out. If
@@ -388,17 +386,27 @@ void ath_beacon_tasklet(unsigned long data)
388 * on the tsf to safeguard against missing an swba. 386 * on the tsf to safeguard against missing an swba.
389 */ 387 */
390 388
391 intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
392 389
393 tsf = ath9k_hw_gettsf64(ah); 390 if (ah->opmode == NL80211_IFTYPE_AP) {
394 tsf += TU_TO_USEC(ah->config.sw_beacon_response_time); 391 u16 intval;
395 tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF); 392 u32 tsftu;
396 slot = (tsftu % (intval * ATH_BCBUF)) / intval; 393 u64 tsf;
397 vif = sc->beacon.bslot[slot]; 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 }
398 409
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);
402 410
403 bfaddr = 0; 411 bfaddr = 0;
404 if (vif) { 412 if (vif) {