diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-12-14 12:03:44 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-12-18 15:23:32 -0500 |
commit | 4ed15762dce67192d4662860470a8be1f6d5fd53 (patch) | |
tree | 1a84b7f067cac5939f8ababd57f8762a7ebd2259 | |
parent | c57b182b9fb7cc731f3d6620f86b43ce5ee702d2 (diff) |
ath9k_hw: clean up station beacon timer API
Remove unused fields, pass timer info in usec instead of TU.
Preparation for fixing nexttbtt calculation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/ath/ath9k/beacon.c | 38 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/htc_drv_beacon.c | 39 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.c | 18 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.h | 6 |
4 files changed, 31 insertions, 70 deletions
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c index 17be35392bb4..5128856d77d2 100644 --- a/drivers/net/wireless/ath/ath9k/beacon.c +++ b/drivers/net/wireless/ath/ath9k/beacon.c | |||
@@ -476,10 +476,9 @@ static void ath9k_beacon_config_sta(struct ath_softc *sc, | |||
476 | struct ath_common *common = ath9k_hw_common(ah); | 476 | struct ath_common *common = ath9k_hw_common(ah); |
477 | struct ath9k_beacon_state bs; | 477 | struct ath9k_beacon_state bs; |
478 | int dtimperiod, dtimcount, sleepduration; | 478 | int dtimperiod, dtimcount, sleepduration; |
479 | int cfpperiod, cfpcount; | ||
480 | u32 nexttbtt = 0, intval, tsftu; | 479 | u32 nexttbtt = 0, intval, tsftu; |
481 | u64 tsf; | 480 | u64 tsf; |
482 | int num_beacons, offset, dtim_dec_count, cfp_dec_count; | 481 | int num_beacons, offset, dtim_dec_count; |
483 | 482 | ||
484 | /* No need to configure beacon if we are not associated */ | 483 | /* No need to configure beacon if we are not associated */ |
485 | if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) { | 484 | if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) { |
@@ -492,21 +491,19 @@ static void ath9k_beacon_config_sta(struct ath_softc *sc, | |||
492 | intval = conf->beacon_interval; | 491 | intval = conf->beacon_interval; |
493 | 492 | ||
494 | /* | 493 | /* |
495 | * Setup dtim and cfp parameters according to | 494 | * Setup dtim parameters according to |
496 | * last beacon we received (which may be none). | 495 | * last beacon we received (which may be none). |
497 | */ | 496 | */ |
498 | dtimperiod = conf->dtim_period; | 497 | dtimperiod = conf->dtim_period; |
499 | dtimcount = conf->dtim_count; | 498 | dtimcount = conf->dtim_count; |
500 | if (dtimcount >= dtimperiod) /* NB: sanity check */ | 499 | if (dtimcount >= dtimperiod) /* NB: sanity check */ |
501 | dtimcount = 0; | 500 | dtimcount = 0; |
502 | cfpperiod = 1; /* NB: no PCF support yet */ | ||
503 | cfpcount = 0; | ||
504 | 501 | ||
505 | sleepduration = conf->listen_interval * intval; | 502 | sleepduration = conf->listen_interval * intval; |
506 | 503 | ||
507 | /* | 504 | /* |
508 | * Pull nexttbtt forward to reflect the current | 505 | * Pull nexttbtt forward to reflect the current |
509 | * TSF and calculate dtim+cfp state for the result. | 506 | * TSF and calculate dtim state for the result. |
510 | */ | 507 | */ |
511 | tsf = ath9k_hw_gettsf64(ah); | 508 | tsf = ath9k_hw_gettsf64(ah); |
512 | tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE; | 509 | tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE; |
@@ -519,26 +516,14 @@ static void ath9k_beacon_config_sta(struct ath_softc *sc, | |||
519 | 516 | ||
520 | /* DTIM Beacon every dtimperiod Beacon */ | 517 | /* DTIM Beacon every dtimperiod Beacon */ |
521 | dtim_dec_count = num_beacons % dtimperiod; | 518 | dtim_dec_count = num_beacons % dtimperiod; |
522 | /* CFP every cfpperiod DTIM Beacon */ | ||
523 | cfp_dec_count = (num_beacons / dtimperiod) % cfpperiod; | ||
524 | if (dtim_dec_count) | ||
525 | cfp_dec_count++; | ||
526 | |||
527 | dtimcount -= dtim_dec_count; | 519 | dtimcount -= dtim_dec_count; |
528 | if (dtimcount < 0) | 520 | if (dtimcount < 0) |
529 | dtimcount += dtimperiod; | 521 | dtimcount += dtimperiod; |
530 | 522 | ||
531 | cfpcount -= cfp_dec_count; | 523 | bs.bs_intval = TU_TO_USEC(intval); |
532 | if (cfpcount < 0) | 524 | bs.bs_nexttbtt = TU_TO_USEC(nexttbtt); |
533 | cfpcount += cfpperiod; | 525 | bs.bs_dtimperiod = dtimperiod * bs.bs_intval; |
534 | 526 | bs.bs_nextdtim = bs.bs_nexttbtt + dtimcount * bs.bs_intval; | |
535 | bs.bs_intval = intval; | ||
536 | bs.bs_nexttbtt = nexttbtt; | ||
537 | bs.bs_dtimperiod = dtimperiod*intval; | ||
538 | bs.bs_nextdtim = bs.bs_nexttbtt + dtimcount*intval; | ||
539 | bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod; | ||
540 | bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod; | ||
541 | bs.bs_cfpmaxduration = 0; | ||
542 | 527 | ||
543 | /* | 528 | /* |
544 | * Calculate the number of consecutive beacons to miss* before taking | 529 | * Calculate the number of consecutive beacons to miss* before taking |
@@ -566,7 +551,8 @@ static void ath9k_beacon_config_sta(struct ath_softc *sc, | |||
566 | * XXX fixed at 100ms | 551 | * XXX fixed at 100ms |
567 | */ | 552 | */ |
568 | 553 | ||
569 | bs.bs_sleepduration = roundup(IEEE80211_MS_TO_TU(100), sleepduration); | 554 | bs.bs_sleepduration = TU_TO_USEC(roundup(IEEE80211_MS_TO_TU(100), |
555 | sleepduration)); | ||
570 | if (bs.bs_sleepduration > bs.bs_dtimperiod) | 556 | if (bs.bs_sleepduration > bs.bs_dtimperiod) |
571 | bs.bs_sleepduration = bs.bs_dtimperiod; | 557 | bs.bs_sleepduration = bs.bs_dtimperiod; |
572 | 558 | ||
@@ -574,10 +560,8 @@ static void ath9k_beacon_config_sta(struct ath_softc *sc, | |||
574 | bs.bs_tsfoor_threshold = ATH9K_TSFOOR_THRESHOLD; | 560 | bs.bs_tsfoor_threshold = ATH9K_TSFOOR_THRESHOLD; |
575 | 561 | ||
576 | ath_dbg(common, BEACON, "tsf: %llu tsftu: %u\n", tsf, tsftu); | 562 | ath_dbg(common, BEACON, "tsf: %llu tsftu: %u\n", tsf, tsftu); |
577 | ath_dbg(common, BEACON, | 563 | ath_dbg(common, BEACON, "bmiss: %u sleep: %u\n", |
578 | "bmiss: %u sleep: %u cfp-period: %u maxdur: %u next: %u\n", | 564 | bs.bs_bmissthreshold, bs.bs_sleepduration); |
579 | bs.bs_bmissthreshold, bs.bs_sleepduration, | ||
580 | bs.bs_cfpperiod, bs.bs_cfpmaxduration, bs.bs_cfpnext); | ||
581 | 565 | ||
582 | /* Set the computed STA beacon timers */ | 566 | /* Set the computed STA beacon timers */ |
583 | 567 | ||
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c index e0c03bd64182..8b5757734596 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c | |||
@@ -70,11 +70,11 @@ static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv, | |||
70 | struct ath9k_beacon_state bs; | 70 | struct ath9k_beacon_state bs; |
71 | enum ath9k_int imask = 0; | 71 | enum ath9k_int imask = 0; |
72 | int dtimperiod, dtimcount, sleepduration; | 72 | int dtimperiod, dtimcount, sleepduration; |
73 | int cfpperiod, cfpcount, bmiss_timeout; | 73 | int bmiss_timeout; |
74 | u32 nexttbtt = 0, intval, tsftu; | 74 | u32 nexttbtt = 0, intval, tsftu; |
75 | __be32 htc_imask = 0; | 75 | __be32 htc_imask = 0; |
76 | u64 tsf; | 76 | u64 tsf; |
77 | int num_beacons, offset, dtim_dec_count, cfp_dec_count; | 77 | int num_beacons, offset, dtim_dec_count; |
78 | int ret __attribute__ ((unused)); | 78 | int ret __attribute__ ((unused)); |
79 | u8 cmd_rsp; | 79 | u8 cmd_rsp; |
80 | 80 | ||
@@ -84,7 +84,7 @@ static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv, | |||
84 | bmiss_timeout = (ATH_DEFAULT_BMISS_LIMIT * bss_conf->beacon_interval); | 84 | bmiss_timeout = (ATH_DEFAULT_BMISS_LIMIT * bss_conf->beacon_interval); |
85 | 85 | ||
86 | /* | 86 | /* |
87 | * Setup dtim and cfp parameters according to | 87 | * Setup dtim parameters according to |
88 | * last beacon we received (which may be none). | 88 | * last beacon we received (which may be none). |
89 | */ | 89 | */ |
90 | dtimperiod = bss_conf->dtim_period; | 90 | dtimperiod = bss_conf->dtim_period; |
@@ -93,8 +93,6 @@ static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv, | |||
93 | dtimcount = 1; | 93 | dtimcount = 1; |
94 | if (dtimcount >= dtimperiod) /* NB: sanity check */ | 94 | if (dtimcount >= dtimperiod) /* NB: sanity check */ |
95 | dtimcount = 0; | 95 | dtimcount = 0; |
96 | cfpperiod = 1; /* NB: no PCF support yet */ | ||
97 | cfpcount = 0; | ||
98 | 96 | ||
99 | sleepduration = intval; | 97 | sleepduration = intval; |
100 | if (sleepduration <= 0) | 98 | if (sleepduration <= 0) |
@@ -102,7 +100,7 @@ static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv, | |||
102 | 100 | ||
103 | /* | 101 | /* |
104 | * Pull nexttbtt forward to reflect the current | 102 | * Pull nexttbtt forward to reflect the current |
105 | * TSF and calculate dtim+cfp state for the result. | 103 | * TSF and calculate dtim state for the result. |
106 | */ | 104 | */ |
107 | tsf = ath9k_hw_gettsf64(priv->ah); | 105 | tsf = ath9k_hw_gettsf64(priv->ah); |
108 | tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE; | 106 | tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE; |
@@ -115,26 +113,14 @@ static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv, | |||
115 | 113 | ||
116 | /* DTIM Beacon every dtimperiod Beacon */ | 114 | /* DTIM Beacon every dtimperiod Beacon */ |
117 | dtim_dec_count = num_beacons % dtimperiod; | 115 | dtim_dec_count = num_beacons % dtimperiod; |
118 | /* CFP every cfpperiod DTIM Beacon */ | ||
119 | cfp_dec_count = (num_beacons / dtimperiod) % cfpperiod; | ||
120 | if (dtim_dec_count) | ||
121 | cfp_dec_count++; | ||
122 | |||
123 | dtimcount -= dtim_dec_count; | 116 | dtimcount -= dtim_dec_count; |
124 | if (dtimcount < 0) | 117 | if (dtimcount < 0) |
125 | dtimcount += dtimperiod; | 118 | dtimcount += dtimperiod; |
126 | 119 | ||
127 | cfpcount -= cfp_dec_count; | 120 | bs.bs_intval = TU_TO_USEC(intval); |
128 | if (cfpcount < 0) | 121 | bs.bs_nexttbtt = TU_TO_USEC(nexttbtt); |
129 | cfpcount += cfpperiod; | 122 | bs.bs_dtimperiod = dtimperiod * bs.bs_intval; |
130 | 123 | bs.bs_nextdtim = bs.bs_nexttbtt + dtimcount * bs.bs_intval; | |
131 | bs.bs_intval = intval; | ||
132 | bs.bs_nexttbtt = nexttbtt; | ||
133 | bs.bs_dtimperiod = dtimperiod*intval; | ||
134 | bs.bs_nextdtim = bs.bs_nexttbtt + dtimcount*intval; | ||
135 | bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod; | ||
136 | bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod; | ||
137 | bs.bs_cfpmaxduration = 0; | ||
138 | 124 | ||
139 | /* | 125 | /* |
140 | * Calculate the number of consecutive beacons to miss* before taking | 126 | * Calculate the number of consecutive beacons to miss* before taking |
@@ -161,7 +147,8 @@ static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv, | |||
161 | * XXX fixed at 100ms | 147 | * XXX fixed at 100ms |
162 | */ | 148 | */ |
163 | 149 | ||
164 | bs.bs_sleepduration = roundup(IEEE80211_MS_TO_TU(100), sleepduration); | 150 | bs.bs_sleepduration = TU_TO_USEC(roundup(IEEE80211_MS_TO_TU(100), |
151 | sleepduration)); | ||
165 | if (bs.bs_sleepduration > bs.bs_dtimperiod) | 152 | if (bs.bs_sleepduration > bs.bs_dtimperiod) |
166 | bs.bs_sleepduration = bs.bs_dtimperiod; | 153 | bs.bs_sleepduration = bs.bs_dtimperiod; |
167 | 154 | ||
@@ -170,10 +157,8 @@ static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv, | |||
170 | 157 | ||
171 | ath_dbg(common, CONFIG, "intval: %u tsf: %llu tsftu: %u\n", | 158 | ath_dbg(common, CONFIG, "intval: %u tsf: %llu tsftu: %u\n", |
172 | intval, tsf, tsftu); | 159 | intval, tsf, tsftu); |
173 | ath_dbg(common, CONFIG, | 160 | ath_dbg(common, CONFIG, "bmiss: %u sleep: %u\n", |
174 | "bmiss: %u sleep: %u cfp-period: %u maxdur: %u next: %u\n", | 161 | bs.bs_bmissthreshold, bs.bs_sleepduration); |
175 | bs.bs_bmissthreshold, bs.bs_sleepduration, | ||
176 | bs.bs_cfpperiod, bs.bs_cfpmaxduration, bs.bs_cfpnext); | ||
177 | 162 | ||
178 | /* Set the computed STA beacon timers */ | 163 | /* Set the computed STA beacon timers */ |
179 | 164 | ||
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 073346abc3f0..2318bb90cd63 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -2292,12 +2292,9 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, | |||
2292 | 2292 | ||
2293 | ENABLE_REGWRITE_BUFFER(ah); | 2293 | ENABLE_REGWRITE_BUFFER(ah); |
2294 | 2294 | ||
2295 | REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(bs->bs_nexttbtt)); | 2295 | REG_WRITE(ah, AR_NEXT_TBTT_TIMER, bs->bs_nexttbtt); |
2296 | 2296 | REG_WRITE(ah, AR_BEACON_PERIOD, bs->bs_intval); | |
2297 | REG_WRITE(ah, AR_BEACON_PERIOD, | 2297 | REG_WRITE(ah, AR_DMA_BEACON_PERIOD, bs->bs_intval); |
2298 | TU_TO_USEC(bs->bs_intval)); | ||
2299 | REG_WRITE(ah, AR_DMA_BEACON_PERIOD, | ||
2300 | TU_TO_USEC(bs->bs_intval)); | ||
2301 | 2298 | ||
2302 | REGWRITE_BUFFER_FLUSH(ah); | 2299 | REGWRITE_BUFFER_FLUSH(ah); |
2303 | 2300 | ||
@@ -2325,9 +2322,8 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, | |||
2325 | 2322 | ||
2326 | ENABLE_REGWRITE_BUFFER(ah); | 2323 | ENABLE_REGWRITE_BUFFER(ah); |
2327 | 2324 | ||
2328 | REG_WRITE(ah, AR_NEXT_DTIM, | 2325 | REG_WRITE(ah, AR_NEXT_DTIM, bs->bs_nextdtim - SLEEP_SLOP); |
2329 | TU_TO_USEC(bs->bs_nextdtim - SLEEP_SLOP)); | 2326 | REG_WRITE(ah, AR_NEXT_TIM, nextTbtt - SLEEP_SLOP); |
2330 | REG_WRITE(ah, AR_NEXT_TIM, TU_TO_USEC(nextTbtt - SLEEP_SLOP)); | ||
2331 | 2327 | ||
2332 | REG_WRITE(ah, AR_SLEEP1, | 2328 | REG_WRITE(ah, AR_SLEEP1, |
2333 | SM((CAB_TIMEOUT_VAL << 3), AR_SLEEP1_CAB_TIMEOUT) | 2329 | SM((CAB_TIMEOUT_VAL << 3), AR_SLEEP1_CAB_TIMEOUT) |
@@ -2341,8 +2337,8 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, | |||
2341 | REG_WRITE(ah, AR_SLEEP2, | 2337 | REG_WRITE(ah, AR_SLEEP2, |
2342 | SM(beacontimeout, AR_SLEEP2_BEACON_TIMEOUT)); | 2338 | SM(beacontimeout, AR_SLEEP2_BEACON_TIMEOUT)); |
2343 | 2339 | ||
2344 | REG_WRITE(ah, AR_TIM_PERIOD, TU_TO_USEC(beaconintval)); | 2340 | REG_WRITE(ah, AR_TIM_PERIOD, beaconintval); |
2345 | REG_WRITE(ah, AR_DTIM_PERIOD, TU_TO_USEC(dtimperiod)); | 2341 | REG_WRITE(ah, AR_DTIM_PERIOD, dtimperiod); |
2346 | 2342 | ||
2347 | REGWRITE_BUFFER_FLUSH(ah); | 2343 | REGWRITE_BUFFER_FLUSH(ah); |
2348 | 2344 | ||
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 4e3b73b62939..54932d8b5edd 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h | |||
@@ -168,7 +168,7 @@ | |||
168 | #define CAB_TIMEOUT_VAL 10 | 168 | #define CAB_TIMEOUT_VAL 10 |
169 | #define BEACON_TIMEOUT_VAL 10 | 169 | #define BEACON_TIMEOUT_VAL 10 |
170 | #define MIN_BEACON_TIMEOUT_VAL 1 | 170 | #define MIN_BEACON_TIMEOUT_VAL 1 |
171 | #define SLEEP_SLOP 3 | 171 | #define SLEEP_SLOP TU_TO_USEC(3) |
172 | 172 | ||
173 | #define INIT_CONFIG_STATUS 0x00000000 | 173 | #define INIT_CONFIG_STATUS 0x00000000 |
174 | #define INIT_RSSI_THR 0x00000700 | 174 | #define INIT_RSSI_THR 0x00000700 |
@@ -451,10 +451,6 @@ struct ath9k_beacon_state { | |||
451 | u32 bs_intval; | 451 | u32 bs_intval; |
452 | #define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */ | 452 | #define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */ |
453 | u32 bs_dtimperiod; | 453 | u32 bs_dtimperiod; |
454 | u16 bs_cfpperiod; | ||
455 | u16 bs_cfpmaxduration; | ||
456 | u32 bs_cfpnext; | ||
457 | u16 bs_timoffset; | ||
458 | u16 bs_bmissthreshold; | 454 | u16 bs_bmissthreshold; |
459 | u32 bs_sleepduration; | 455 | u32 bs_sleepduration; |
460 | u32 bs_tsfoor_threshold; | 456 | u32 bs_tsfoor_threshold; |