aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2010-06-12 00:33:40 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-06-14 15:39:29 -0400
commit37e5bf6535a4d697fb9fa6f268a8354a612cbc00 (patch)
treeaec79f56fac9cdf6ff1b749804039693735fa34b /drivers/net
parent7337725609d5b9ef053011d32727cbe7e8b33563 (diff)
ath9k_hw: fix clock rate calculations for ANI
The clock rate was assumed to be static but it actually changes depending on the mode of operation, correct this to help improve the calcuation of the listenTime for ANI. This change will help adjust ANI more accurately on different PHY thresholds. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath/ath9k/ani.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c
index 3da820ffc65e..e879055c058f 100644
--- a/drivers/net/wireless/ath/ath9k/ani.c
+++ b/drivers/net/wireless/ath/ath9k/ani.c
@@ -259,6 +259,27 @@ static void ath9k_hw_ani_lower_immunity(struct ath_hw *ah)
259 } 259 }
260} 260}
261 261
262static u8 ath9k_hw_chan_2_clockrate_mhz(struct ath_hw *ah)
263{
264 struct ath9k_channel *chan = ah->curchan;
265 struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
266 u8 clockrate; /* in MHz */
267
268 if (!ah->curchan) /* should really check for CCK instead */
269 clockrate = ATH9K_CLOCK_RATE_CCK;
270 else if (conf->channel->band == IEEE80211_BAND_2GHZ)
271 clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
272 else if (IS_CHAN_A_FAST_CLOCK(ah, chan))
273 clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
274 else
275 clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM;
276
277 if (conf_is_ht40(conf))
278 return clockrate * 2;
279
280 return clockrate * 2;
281}
282
262static int32_t ath9k_hw_ani_get_listen_time(struct ath_hw *ah) 283static int32_t ath9k_hw_ani_get_listen_time(struct ath_hw *ah)
263{ 284{
264 struct ar5416AniState *aniState; 285 struct ar5416AniState *aniState;
@@ -278,7 +299,15 @@ static int32_t ath9k_hw_ani_get_listen_time(struct ath_hw *ah)
278 int32_t ccdelta = cycleCount - aniState->cycleCount; 299 int32_t ccdelta = cycleCount - aniState->cycleCount;
279 int32_t rfdelta = rxFrameCount - aniState->rxFrameCount; 300 int32_t rfdelta = rxFrameCount - aniState->rxFrameCount;
280 int32_t tfdelta = txFrameCount - aniState->txFrameCount; 301 int32_t tfdelta = txFrameCount - aniState->txFrameCount;
281 listenTime = (ccdelta - rfdelta - tfdelta) / 44000; 302 int32_t clock_rate = ath9k_hw_chan_2_clockrate_mhz(ah) * 1000;;
303
304 /*
305 * convert HW counter values to ms using mode
306 * specifix clock rate
307 */
308 clock_rate = ath9k_hw_chan_2_clockrate_mhz(ah) * 1000;;
309
310 listenTime = (ccdelta - rfdelta - tfdelta) / clock_rate;
282 } 311 }
283 aniState->cycleCount = cycleCount; 312 aniState->cycleCount = cycleCount;
284 aniState->txFrameCount = txFrameCount; 313 aniState->txFrameCount = txFrameCount;