From owner-svn-src-user@FreeBSD.ORG Thu Nov 3 03:07:42 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3199F1065672; Thu, 3 Nov 2011 03:07:42 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 21EA18FC0C; Thu, 3 Nov 2011 03:07:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA337gD6050125; Thu, 3 Nov 2011 03:07:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA337g4E050123; Thu, 3 Nov 2011 03:07:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201111030307.pA337g4E050123@svn.freebsd.org> From: Adrian Chadd Date: Thu, 3 Nov 2011 03:07:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227048 - user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2011 03:07:42 -0000 Author: adrian Date: Thu Nov 3 03:07:41 2011 New Revision: 227048 URL: http://svn.freebsd.org/changeset/base/227048 Log: Begin some dirty hacks to implement channel survey support and unify some of the MIB counter access. The reference HAL has a handful of routines which fondle the MIB registers. This commit modifies the ar5416AniGetListenTime() to use ar5416GetMibCycleCountsPct() which grabs the TX/RX/RC counters and returns the percentage of time the channel is busy. This way it doesn't also do its own register reading. The last values are cached in the ath_hal state, so they can be used by other parts of the code. This will (eventually) include channel survey support, which will keep a per-channel history of these values. Also - run this every ANI interval, whether it's enabled or not. The listen time routine should be modified to not use ANI state at all so it can be called if it's disabled without the fear of aniState being NULL, but that can come in a subsequent commit. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Thu Nov 3 03:00:39 2011 (r227047) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Thu Nov 3 03:07:41 2011 (r227048) @@ -793,15 +793,15 @@ ar5416AniGetListenTime(struct ath_hal *a { 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 @@ -810,14 +810,18 @@ ar5416AniGetListenTime(struct ath_hal *a 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; } @@ -884,10 +888,13 @@ ar5416AniPoll(struct ath_hal *ah, const /* 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 */