aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2011-11-09 05:48:20 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2011-11-09 05:48:20 +0000
commit2e4464a4af1dbce74adc22d4617039ddb4c90322 (patch)
treef1c4f1d7adc36bf917097db047e63a008d909092 /sys/dev
parent26ae0bb475b65d5fb8ba5275ad0124d1b6842853 (diff)
downloadsrc-2e4464a4af1dbce74adc22d4617039ddb4c90322.tar.gz
src-2e4464a4af1dbce74adc22d4617039ddb4c90322.zip
Migrate the AR5416 ANI code to use the previously introduced method
to fetch the current channel busy statistics, rather than duplicating it here. This forms the (very crude) basis for doing basic channel surveying. Sponsored by: Hobnob, Inc.
Notes
Notes: svn path=/head/; revision=227381
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ath/ath_hal/ar5416/ar5416_ani.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c b/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c
index 4c4fd94a374b..a521d5a0acf4 100644
--- a/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c
+++ b/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c
@@ -815,15 +815,15 @@ ar5416AniGetListenTime(struct ath_hal *ah)
{
struct ath_hal_5212 *ahp = AH5212(ah);
struct ar5212AniState *aniState;
- uint32_t txFrameCount, rxFrameCount, cycleCount;
+ uint32_t rxc_pct, extc_pct, rxf_pct, txf_pct;
int32_t listenTime;
+ int good;
- txFrameCount = OS_REG_READ(ah, AR_TFCNT);
- rxFrameCount = OS_REG_READ(ah, AR_RFCNT);
- cycleCount = OS_REG_READ(ah, AR_CCCNT);
+ good = ar5416GetMibCycleCountsPct(ah,
+ &rxc_pct, &extc_pct, &rxf_pct, &txf_pct);
aniState = ahp->ah_curani;
- if (aniState->cycleCount == 0 || aniState->cycleCount > cycleCount) {
+ if (good == 0) {
/*
* Cycle counter wrap (or initial call); it's not possible
* to accurately calculate a value because the registers
@@ -832,14 +832,18 @@ ar5416AniGetListenTime(struct ath_hal *ah)
listenTime = 0;
ahp->ah_stats.ast_ani_lzero++;
} else {
- int32_t ccdelta = cycleCount - aniState->cycleCount;
- int32_t rfdelta = rxFrameCount - aniState->rxFrameCount;
- int32_t tfdelta = txFrameCount - aniState->txFrameCount;
+ int32_t ccdelta = AH5416(ah)->ah_cycleCount - aniState->cycleCount;
+ int32_t rfdelta = AH5416(ah)->ah_rxBusy - aniState->rxFrameCount;
+ int32_t tfdelta = AH5416(ah)->ah_txBusy - aniState->txFrameCount;
listenTime = (ccdelta - rfdelta - tfdelta) / CLOCK_RATE;
}
- aniState->cycleCount = cycleCount;
- aniState->txFrameCount = txFrameCount;
- aniState->rxFrameCount = rxFrameCount;
+ aniState->cycleCount = AH5416(ah)->ah_cycleCount;
+ aniState->txFrameCount = AH5416(ah)->ah_rxBusy;
+ aniState->rxFrameCount = AH5416(ah)->ah_txBusy;
+
+ HALDEBUG(ah, HAL_DEBUG_ANI, "rxc=%d, extc=%d, rxf=%d, txf=%d\n",
+ rxc_pct, extc_pct, rxf_pct, txf_pct);
+
return listenTime;
}
@@ -906,10 +910,13 @@ ar5416AniPoll(struct ath_hal *ah, const struct ieee80211_channel *chan)
/* XXX can aniState be null? */
if (aniState == AH_NULL)
return;
+
+ /* Always update from the MIB, for statistics gathering */
+ listenTime = ar5416AniGetListenTime(ah);
+
if (!ANI_ENA(ah))
return;
- listenTime = ar5416AniGetListenTime(ah);
if (listenTime < 0) {
ahp->ah_stats.ast_ani_lneg++;
/* restart ANI period if listenTime is invalid */