From owner-svn-src-user@FreeBSD.ORG Thu Sep 15 09:06:28 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 7DF611065676; Thu, 15 Sep 2011 09:06:28 +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 62EC48FC08; Thu, 15 Sep 2011 09:06:28 +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 p8F96SHC065177; Thu, 15 Sep 2011 09:06:28 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8F96SbF065172; Thu, 15 Sep 2011 09:06:28 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109150906.p8F96SbF065172@svn.freebsd.org> From: Adrian Chadd Date: Thu, 15 Sep 2011 09:06:28 +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: r225572 - in 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, 15 Sep 2011 09:06:28 -0000 Author: adrian Date: Thu Sep 15 09:06:28 2011 New Revision: 225572 URL: http://svn.freebsd.org/changeset/base/225572 Log: Bring over a HAL function from the reference code which calculates the amount of time spent in TX/RX/channel busy. This is just for debugging; it shouldn't be merged in this form to -HEAD. Obtained from: Atheros Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah.h user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.h user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah.h Thu Sep 15 08:49:54 2011 (r225571) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ah.h Thu Sep 15 09:06:28 2011 (r225572) @@ -1012,6 +1012,9 @@ struct ath_hal { struct ath_desc *); void __ahdecl(*ah_set11nBurstDuration)(struct ath_hal *, struct ath_desc *, u_int); + uint32_t __ahdecl(*ah_get_mib_cycle_counts_pct) (struct ath_hal *, + uint32_t *, uint32_t *, uint32_t *, uint32_t *); + uint32_t __ahdecl(*ah_get11nExtBusy)(struct ath_hal *); void __ahdecl(*ah_set11nMac2040)(struct ath_hal *, HAL_HT_MACMODE); Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.h Thu Sep 15 08:49:54 2011 (r225571) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.h Thu Sep 15 09:06:28 2011 (r225572) @@ -112,11 +112,13 @@ struct ath_hal_5416 { int ah_hangs; /* h/w hangs state */ uint8_t ah_keytype[AR5416_KEYTABLE_SIZE]; /* - * Extension Channel Rx Clear State + * Primary / Extension Channel Rx Clear State */ uint32_t ah_cycleCount; uint32_t ah_ctlBusy; uint32_t ah_extBusy; + uint32_t ah_rxBusy; + uint32_t ah_txBusy; uint32_t ah_rx_chainmask; uint32_t ah_tx_chainmask; @@ -190,6 +192,9 @@ extern void ar5416ResetTsf(struct ath_ha extern HAL_BOOL ar5416SetAntennaSwitch(struct ath_hal *, HAL_ANT_SETTING); extern HAL_BOOL ar5416SetDecompMask(struct ath_hal *, uint16_t, int); extern void ar5416SetCoverageClass(struct ath_hal *, uint8_t, int); +extern uint32_t ar5416GetMibCycleCountsPct(struct ath_hal *ah, + uint32_t *rxc_pcnt, uint32_t *rxextc_pcnt, uint32_t *rxf_pcnt, + uint32_t *txf_pcnt); extern uint32_t ar5416Get11nExtBusy(struct ath_hal *ah); extern void ar5416Set11nMac2040(struct ath_hal *ah, HAL_HT_MACMODE mode); extern HAL_HT_RXCLEAR ar5416Get11nRxClear(struct ath_hal *ah); Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Thu Sep 15 08:49:54 2011 (r225571) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Thu Sep 15 09:06:28 2011 (r225572) @@ -170,6 +170,7 @@ ar5416InitState(struct ath_hal_5416 *ahp ah->ah_set11nAggrLast = ar5416Set11nAggrLast; ah->ah_clr11nAggr = ar5416Clr11nAggr; ah->ah_set11nBurstDuration = ar5416Set11nBurstDuration; + ah->ah_get_mib_cycle_counts_pct = ar5416GetMibCycleCountsPct; ah->ah_get11nExtBusy = ar5416Get11nExtBusy; ah->ah_set11nMac2040 = ar5416Set11nMac2040; ah->ah_get11nRxClear = ar5416Get11nRxClear; Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Thu Sep 15 08:49:54 2011 (r225571) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Thu Sep 15 09:06:28 2011 (r225572) @@ -131,6 +131,57 @@ ar5416SetCoverageClass(struct ath_hal *a } /* + * Return the busy for rx_frame, rx_clear, and tx_frame + */ +uint32_t +ar5416GetMibCycleCountsPct(struct ath_hal *ah, uint32_t *rxc_pcnt, + uint32_t *extc_pcnt, uint32_t *rxf_pcnt, uint32_t *txf_pcnt) +{ + struct ath_hal_5416 *ahp = AH5416(ah); + u_int32_t good = 1; + + /* XXX freeze/unfreeze mib counters */ + uint32_t rc = OS_REG_READ(ah, AR_RCCNT); + uint32_t ec = OS_REG_READ(ah, AR_EXTRCCNT); + uint32_t rf = OS_REG_READ(ah, AR_RFCNT); + uint32_t tf = OS_REG_READ(ah, AR_TFCNT); + uint32_t cc = OS_REG_READ(ah, AR_CCCNT); /* read cycles last */ + + if (ahp->ah_cycleCount == 0 || ahp->ah_cycleCount > cc) { + /* + * Cycle counter wrap (or initial call); it's not possible + * to accurately calculate a value because the registers + * right shift rather than wrap--so punt and return 0. + */ + HALDEBUG(ah, HAL_DEBUG_ANY, + "%s: cycle counter wrap. ExtBusy = 0\n", __func__); + good = 0; + } else { + uint32_t cc_d = cc - ahp->ah_cycleCount; + uint32_t rc_d = rc - ahp->ah_ctlBusy; + uint32_t ec_d = ec - ahp->ah_extBusy; + uint32_t rf_d = rf - ahp->ah_rxBusy; + uint32_t tf_d = tf - ahp->ah_txBusy; + + if (cc_d != 0) { + *rxc_pcnt = rc_d * 100 / cc_d; + *rxf_pcnt = rf_d * 100 / cc_d; + *txf_pcnt = tf_d * 100 / cc_d; + *extc_pcnt = ec_d * 100 / cc_d; + } else { + good = 0; + } + } + ahp->ah_cycleCount = cc; + ahp->ah_rxBusy = rf; + ahp->ah_ctlBusy = rc; + ahp->ah_txBusy = tf; + ahp->ah_extBusy = ec; + + return good; +} + +/* * Return approximation of extension channel busy over an time interval * 0% (clear) -> 100% (busy) *