aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-05-20 14:56:39 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-05-22 14:06:01 -0400
commit267a90127472be70b02ab13cbd355b5013e2aa51 (patch)
tree916825c0db1c68751ad280a54ee65e03395821c6
parentd26285f873c3066fefe648b47b9ecf3ec18bcfbc (diff)
ath9k: Optimize TBTT/DTIM calculation for timers
The previous version used a simple loop to go through all Beacon frames when determining the next TBTT and DTIM count. This is not too bad for the case where the setup happens before timesync (i.e., very small TSF), but this can become very heavy operation if a short Beacon interval is used and the current TSF is large. In preparation for a patch to update timer setup based on Beacon timestamp, optimize this routine to take fixed time regardless of the actual TSF value. Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 57f91a9ff0eb..a21b21339fbc 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -559,6 +559,7 @@ static void ath_beacon_config_sta(struct ath_softc *sc,
559 int cfpperiod, cfpcount; 559 int cfpperiod, cfpcount;
560 u32 nexttbtt = 0, intval, tsftu; 560 u32 nexttbtt = 0, intval, tsftu;
561 u64 tsf; 561 u64 tsf;
562 int num_beacons, offset, dtim_dec_count, cfp_dec_count;
562 563
563 memset(&bs, 0, sizeof(bs)); 564 memset(&bs, 0, sizeof(bs));
564 intval = conf->beacon_interval & ATH9K_BEACON_PERIOD; 565 intval = conf->beacon_interval & ATH9K_BEACON_PERIOD;
@@ -586,14 +587,27 @@ static void ath_beacon_config_sta(struct ath_softc *sc,
586 */ 587 */
587 tsf = ath9k_hw_gettsf64(sc->sc_ah); 588 tsf = ath9k_hw_gettsf64(sc->sc_ah);
588 tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE; 589 tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE;
589 do { 590
591 num_beacons = tsftu / intval + 1;
592 offset = tsftu % intval;
593 nexttbtt = tsftu - offset;
594 if (offset)
590 nexttbtt += intval; 595 nexttbtt += intval;
591 if (--dtimcount < 0) { 596
592 dtimcount = dtimperiod - 1; 597 /* DTIM Beacon every dtimperiod Beacon */
593 if (--cfpcount < 0) 598 dtim_dec_count = num_beacons % dtimperiod;
594 cfpcount = cfpperiod - 1; 599 /* CFP every cfpperiod DTIM Beacon */
595 } 600 cfp_dec_count = (num_beacons / dtimperiod) % cfpperiod;
596 } while (nexttbtt < tsftu); 601 if (dtim_dec_count)
602 cfp_dec_count++;
603
604 dtimcount -= dtim_dec_count;
605 if (dtimcount < 0)
606 dtimcount += dtimperiod;
607
608 cfpcount -= cfp_dec_count;
609 if (cfpcount < 0)
610 cfpcount += cfpperiod;
597 611
598 bs.bs_intval = intval; 612 bs.bs_intval = intval;
599 bs.bs_nexttbtt = nexttbtt; 613 bs.bs_nexttbtt = nexttbtt;