diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-10-08 16:13:54 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-10-11 15:04:20 -0400 |
commit | 7109ca5c80a0bb94378ebd7f8bb6d00edb5e6fba (patch) | |
tree | b3909c6a1cbc24ddd4f044b22e86b3ea0b1b9364 /drivers/net/wireless/ath/ath5k/ani.c | |
parent | b5bfc5683db44a121ad47ec0a9f4efd4aac040e0 (diff) |
ath5k: use the common cycle counter / listen time implementation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath5k/ani.c')
-rw-r--r-- | drivers/net/wireless/ath/ath5k/ani.c | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c index e4a5f046bba4..f1419198a479 100644 --- a/drivers/net/wireless/ath/ath5k/ani.c +++ b/drivers/net/wireless/ath/ath5k/ani.c | |||
@@ -355,41 +355,28 @@ ath5k_ani_lower_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as) | |||
355 | 355 | ||
356 | 356 | ||
357 | /** | 357 | /** |
358 | * ath5k_hw_ani_get_listen_time() - Calculate time spent listening | 358 | * ath5k_hw_ani_get_listen_time() - Update counters and return listening time |
359 | * | 359 | * |
360 | * Return an approximation of the time spent "listening" in milliseconds (ms) | 360 | * Return an approximation of the time spent "listening" in milliseconds (ms) |
361 | * since the last call of this function by deducting the cycles spent | 361 | * since the last call of this function. |
362 | * transmitting and receiving from the total cycle count. | 362 | * Save a snapshot of the counter values for debugging/statistics. |
363 | * Save profile count values for debugging/statistics and because we might want | ||
364 | * to use them later. | ||
365 | * | ||
366 | * We assume no one else clears these registers! | ||
367 | */ | 363 | */ |
368 | static int | 364 | static int |
369 | ath5k_hw_ani_get_listen_time(struct ath5k_hw *ah, struct ath5k_ani_state *as) | 365 | ath5k_hw_ani_get_listen_time(struct ath5k_hw *ah, struct ath5k_ani_state *as) |
370 | { | 366 | { |
367 | struct ath_common *common = ath5k_hw_common(ah); | ||
371 | int listen; | 368 | int listen; |
372 | 369 | ||
373 | /* freeze */ | 370 | spin_lock_bh(&common->cc_lock); |
374 | ath5k_hw_reg_write(ah, AR5K_MIBC_FMC, AR5K_MIBC); | 371 | |
375 | /* read */ | 372 | ath_hw_cycle_counters_update(common); |
376 | as->pfc_cycles = ath5k_hw_reg_read(ah, AR5K_PROFCNT_CYCLE); | 373 | memcpy(&as->last_cc, &common->cc_ani, sizeof(as->last_cc)); |
377 | as->pfc_busy = ath5k_hw_reg_read(ah, AR5K_PROFCNT_RXCLR); | 374 | |
378 | as->pfc_tx = ath5k_hw_reg_read(ah, AR5K_PROFCNT_TX); | 375 | /* clears common->cc_ani */ |
379 | as->pfc_rx = ath5k_hw_reg_read(ah, AR5K_PROFCNT_RX); | 376 | listen = ath_hw_get_listen_time(common); |
380 | /* clear */ | 377 | |
381 | ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_TX); | 378 | spin_unlock_bh(&common->cc_lock); |
382 | ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_RX); | 379 | |
383 | ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_RXCLR); | ||
384 | ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_CYCLE); | ||
385 | /* un-freeze */ | ||
386 | ath5k_hw_reg_write(ah, 0, AR5K_MIBC); | ||
387 | |||
388 | /* TODO: where does 44000 come from? (11g clock rate?) */ | ||
389 | listen = (as->pfc_cycles - as->pfc_rx - as->pfc_tx) / 44000; | ||
390 | |||
391 | if (as->pfc_cycles == 0 || listen < 0) | ||
392 | return 0; | ||
393 | return listen; | 380 | return listen; |
394 | } | 381 | } |
395 | 382 | ||