Date: Fri, 23 Jan 2009 18:40:31 +0000 (UTC) From: Sam Leffler <sam@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r187639 - in user/sam/wifi/sys/dev/ath/ath_hal: . ar5212 ar5416 Message-ID: <200901231840.n0NIeV2V050160@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sam Date: Fri Jan 23 18:40:31 2009 New Revision: 187639 URL: http://svn.freebsd.org/changeset/base/187639 Log: Fix ani state handling when the channel list changes: o add privFlags to record if ani is initialized and setup (latter replaces isSetup in ani state) o move ar52XXGetAniState inline as it's used only once and change it to check privFlags to see when it needs re-setup state; because the regulatory code clears privFlags when the channel list changes this automatically causes per-channel ani state to get setup on next use o add a comment to regulatory code noting how zero'ing the private chan struct should implictly cause any ancillary state to be re-setup While here change CHANNEL_NFCREQUIRED to use IEEE80211_CHAN_PRIV0 instead of "1". Modified: user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212.h user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c user/sam/wifi/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Modified: user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h Fri Jan 23 18:35:09 2009 (r187638) +++ user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h Fri Jan 23 18:40:31 2009 (r187639) @@ -114,9 +114,11 @@ struct ath_hal_rf *ath_hal_rfprobe(struc * using ic_devdata in the ieee80211_channel. */ typedef struct { - uint16_t channel; - uint8_t privFlags; /* XXX remove */ -#define CHANNEL_IQVALID 0x01 /* IQ calibration valid */ + uint16_t channel; /* XXX remove */ + uint8_t privFlags; +#define CHANNEL_IQVALID 0x01 /* IQ calibration valid */ +#define CHANNEL_ANI_INIT 0x02 /* ANI state initialized */ +#define CHANNEL_ANI_SETUP 0x04 /* ANI state setup */ uint8_t calValid; /* bitmask of cal types */ int8_t iCoff; int8_t qCoff; @@ -125,9 +127,8 @@ typedef struct { uint16_t mainSpur; /* cached spur value for this channel */ } HAL_CHANNEL_INTERNAL; -#define CHANNEL_NFCREQUIRED 0x01 /* channel requires noise floor check */ - -/* privFlags */ +/* channel requires noise floor check */ +#define CHANNEL_NFCREQUIRED IEEE80211_CHAN_PRIV0 typedef struct { uint32_t halChanSpreadSupport : 1, Modified: user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c Fri Jan 23 18:35:09 2009 (r187638) +++ user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c Fri Jan 23 18:40:31 2009 (r187639) @@ -2203,6 +2203,11 @@ assignPrivateChannels(struct ath_hal *ah return AH_FALSE; } ic = &AH_PRIVATE(ah)->ah_channels[next]; + /* + * NB: This clears privFlags which means ancillary + * code like ANI and IQ calibration will be + * restarted and re-setup any per-channel state. + */ OS_MEMZERO(ic, sizeof(*ic)); ic->channel = chans[i].ic_freq; chans[i].ic_devdata = next; Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212.h ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212.h Fri Jan 23 18:35:09 2009 (r187638) +++ user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212.h Fri Jan 23 18:40:31 2009 (r187639) @@ -188,7 +188,6 @@ struct ar5212AniState { uint32_t listenTime; /* NB: intentionally ordered so data exported to user space is first */ - HAL_BOOL isSetup; /* has state to do a restore */ uint32_t txFrameCount; /* Last txFrameCount */ uint32_t rxFrameCount; /* Last rx Frame count */ uint32_t cycleCount; /* Last cycleCount Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c Fri Jan 23 18:35:09 2009 (r187638) +++ user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c Fri Jan 23 18:40:31 2009 (r187639) @@ -99,28 +99,6 @@ disableAniMIBCounters(struct ath_hal *ah } /* - * This routine returns the index into the aniState array that - * corresponds to the channel in chan. - */ -static struct ar5212AniState * -ar5212GetAniState(struct ath_hal *ah, - const struct ieee80211_channel *chan) -{ - struct ath_hal_5212 *ahp = AH5212(ah); - /* XXX bounds check ic_devdata */ - struct ar5212AniState *asp = &ahp->ah_ani[chan->ic_devdata]; - - if (asp->params == AH_NULL) { - if (IEEE80211_IS_CHAN_2GHZ(chan)) - asp->params = &ahp->ah_aniParams24; - else - asp->params = &ahp->ah_aniParams5; - asp->isSetup = AH_FALSE; - } - return asp; -} - -/* * Return the current ANI state of the channel we're on */ struct ar5212AniState * @@ -604,20 +582,29 @@ ar5212AniReset(struct ath_hal *ah, const HAL_OPMODE opmode, int restore) { struct ath_hal_5212 *ahp = AH5212(ah); - struct ar5212AniState *aniState; + HAL_CHANNEL_INTERNAL *ichan = ath_hal_checkchannel(ah, chan); + /* XXX bounds check ic_devdata */ + struct ar5212AniState *aniState = &ahp->ah_ani[chan->ic_devdata]; uint32_t rxfilter; - aniState = ar5212GetAniState(ah, chan); + if ((ichan->privFlags & CHANNEL_ANI_INIT) == 0) { + OS_MEMZERO(aniState, sizeof(*aniState)); + if (IEEE80211_IS_CHAN_2GHZ(chan)) + aniState->params = &ahp->ah_aniParams24; + else + aniState->params = &ahp->ah_aniParams5; + ichan->privFlags |= CHANNEL_ANI_INIT; + HALASSERT((ichan->privFlags & CHANNEL_ANI_SETUP) == 0); + } ahp->ah_curani = aniState; #if 0 - ath_hal_printf(ah,"%s: chan %u/0x%x restore %d setup %d opmode %u\n", - __func__, chan->channel, chan->channelFlags, restore, - aniState->isSetup, opmode); + ath_hal_printf(ah,"%s: chan %u/0x%x restore %d opmode %u%s\n", + __func__, chan->ic_freq, chan->ic_flags, restore, opmode, + ichan->privFlags & CHANNEL_ANI_SETUP ? " setup" : ""); #else - HALDEBUG(ah, HAL_DEBUG_ANI, - "%s: chan %u/0x%x restore %d setup %d opmode %u\n", - __func__, chan->ic_freq, chan->ic_flags, restore, - aniState->isSetup, opmode); + HALDEBUG(ah, HAL_DEBUG_ANI, "%s: chan %u/0x%x restore %d opmode %u%s\n", + __func__, chan->ic_freq, chan->ic_flags, restore, opmode, + ichan->privFlags & CHANNEL_ANI_SETUP ? " setup" : ""); #endif OS_MARK(ah, AH_MARK_ANI_RESET, opmode); @@ -639,7 +626,7 @@ ar5212AniReset(struct ath_hal *ah, const * XXX if ANI follows hardware, we don't care what mode we're * XXX in, we should keep the ani parameters */ - if (restore && aniState->isSetup) { + if (restore && (ichan->privFlags & CHANNEL_ANI_SETUP)) { ar5212AniControl(ah, HAL_ANI_NOISE_IMMUNITY_LEVEL, aniState->noiseImmunityLevel); ar5212AniControl(ah, HAL_ANI_SPUR_IMMUNITY_LEVEL, @@ -657,7 +644,7 @@ ar5212AniReset(struct ath_hal *ah, const AH_TRUE); ar5212AniControl(ah, HAL_ANI_CCK_WEAK_SIGNAL_THR, AH_FALSE); ar5212AniControl(ah, HAL_ANI_FIRSTEP_LEVEL, 0); - aniState->isSetup = AH_TRUE; + ichan->privFlags |= CHANNEL_ANI_SETUP; } ar5212AniRestart(ah, aniState); Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Fri Jan 23 18:35:09 2009 (r187638) +++ user/sam/wifi/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Fri Jan 23 18:40:31 2009 (r187639) @@ -102,28 +102,6 @@ disableAniMIBCounters(struct ath_hal *ah OS_REG_WRITE(ah, AR_PHY_ERR_MASK_2, 0); } -/* - * This routine returns the index into the aniState array that - * corresponds to the channel in chan. - */ -static struct ar5212AniState * -ar5416GetAniState(struct ath_hal *ah, - const struct ieee80211_channel *chan) -{ - struct ath_hal_5212 *ahp = AH5212(ah); - /* XXX bounds check ic_devdata */ - struct ar5212AniState *asp = &ahp->ah_ani[chan->ic_devdata]; - - if (asp->params == AH_NULL) { - if (IEEE80211_IS_CHAN_2GHZ(chan)) - asp->params = &ahp->ah_aniParams24; - else - asp->params = &ahp->ah_aniParams5; - asp->isSetup = AH_FALSE; - } - return asp; -} - static void setPhyErrBase(struct ath_hal *ah, struct ar5212AniParams *params) { @@ -523,20 +501,29 @@ ar5416AniReset(struct ath_hal *ah, const HAL_OPMODE opmode, int restore) { struct ath_hal_5212 *ahp = AH5212(ah); - struct ar5212AniState *aniState; + HAL_CHANNEL_INTERNAL *ichan = ath_hal_checkchannel(ah, chan); + /* XXX bounds check ic_devdata */ + struct ar5212AniState *aniState = &ahp->ah_ani[chan->ic_devdata]; uint32_t rxfilter; - aniState = ar5416GetAniState(ah, chan); + if ((ichan->privFlags & CHANNEL_ANI_INIT) == 0) { + OS_MEMZERO(aniState, sizeof(*aniState)); + if (IEEE80211_IS_CHAN_2GHZ(chan)) + aniState->params = &ahp->ah_aniParams24; + else + aniState->params = &ahp->ah_aniParams5; + ichan->privFlags |= CHANNEL_ANI_INIT; + HALASSERT((ichan->privFlags & CHANNEL_ANI_SETUP) == 0); + } ahp->ah_curani = aniState; #if 0 - ath_hal_printf(ah,"%s: chan %u/0x%x restore %d setup %d opmode %u\n", - __func__, chan->ic_freq, chan->ic_flags, restore, - aniState->isSetup, opmode); + ath_hal_printf(ah,"%s: chan %u/0x%x restore %d opmode %u%s\n", + __func__, chan->ic_freq, chan->ic_flags, restore, opmode, + ichan->privFlags & CHANNEL_ANI_SETUP ? " setup" : ""); #else - HALDEBUG(ah, HAL_DEBUG_ANI, - "%s: chan %u/0x%x restore %d setup %d opmode %u\n", - __func__, chan->ic_freq, chan->ic_flags, restore, - aniState->isSetup, opmode); + HALDEBUG(ah, HAL_DEBUG_ANI, "%s: chan %u/0x%x restore %d opmode %u%s\n", + __func__, chan->ic_freq, chan->ic_flags, restore, opmode, + ichan->privFlags & CHANNEL_ANI_SETUP ? " setup" : ""); #endif OS_MARK(ah, AH_MARK_ANI_RESET, opmode); @@ -558,7 +545,7 @@ ar5416AniReset(struct ath_hal *ah, const * XXX if ANI follows hardware, we don't care what mode we're * XXX in, we should keep the ani parameters */ - if (restore && aniState->isSetup) { + if (restore && (ichan->privFlags & CHANNEL_ANI_SETUP)) { ar5416AniControl(ah, HAL_ANI_NOISE_IMMUNITY_LEVEL, aniState->noiseImmunityLevel); ar5416AniControl(ah, HAL_ANI_SPUR_IMMUNITY_LEVEL, @@ -576,7 +563,7 @@ ar5416AniReset(struct ath_hal *ah, const AH_TRUE); ar5416AniControl(ah, HAL_ANI_CCK_WEAK_SIGNAL_THR, AH_FALSE); ar5416AniControl(ah, HAL_ANI_FIRSTEP_LEVEL, 0); - aniState->isSetup = AH_TRUE; + ichan->privFlags |= CHANNEL_ANI_SETUP; } ar5416AniRestart(ah, aniState);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901231840.n0NIeV2V050160>