From owner-svn-src-head@FreeBSD.ORG Wed May 11 13:40:14 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E7D2106566C; Wed, 11 May 2011 13:40:14 +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 228F98FC12; Wed, 11 May 2011 13:40:14 +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 p4BDeEWU092254; Wed, 11 May 2011 13:40:14 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4BDeEKp092252; Wed, 11 May 2011 13:40:14 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201105111340.p4BDeEKp092252@svn.freebsd.org> From: Adrian Chadd Date: Wed, 11 May 2011 13:40:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r221779 - head/sys/dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 May 2011 13:40:14 -0000 Author: adrian Date: Wed May 11 13:40:13 2011 New Revision: 221779 URL: http://svn.freebsd.org/changeset/base/221779 Log: Make the NF calibration logic (hopefully!) more resistive to noisy environments. In setups where NF calibration can take a while, don't load the CCA and kick off a new NF calibration if the previous one hasn't yet completed. This shouldn't happen unless the environment is noisy but those exist (hi phk!). Here, if the previous NF hasn't completed when ar5416LoadNf() is run (which reads the NF), it skips updating the history buffer, loading the NF CCA array and kicking off the next NF cal. It's hoped it'll occur in the next long calibration interval. Obtained from: Atheros, ath9k, my local HAL Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Wed May 11 13:25:43 2011 (r221778) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Wed May 11 13:40:13 2011 (r221779) @@ -442,6 +442,7 @@ ar5416PerCalibrationN(struct ath_hal *ah struct ar5416PerCal *cal = &AH5416(ah)->ah_cal; HAL_CAL_LIST *currCal = cal->cal_curr; HAL_CHANNEL_INTERNAL *ichan; + int r; OS_MARK(ah, AH_MARK_PERCAL, chan->ic_freq); @@ -498,17 +499,24 @@ ar5416PerCalibrationN(struct ath_hal *ah * Get the value from the previous NF cal * and update the history buffer. */ - ar5416GetNf(ah, chan); - - /* - * Load the NF from history buffer of the current channel. - * NF is slow time-variant, so it is OK to use a - * historical value. - */ - ar5416LoadNF(ah, AH_PRIVATE(ah)->ah_curchan); + r = ar5416GetNf(ah, chan); + if (r <= 0) { + /* NF calibration result isn't valid */ + HALDEBUG(ah, HAL_DEBUG_UNMASKABLE, "%s: NF calibration" + " didn't finish; delaying CCA\n", __func__); + } else { + /* + * NF calibration result is valid. + * + * Load the NF from history buffer of the current channel. + * NF is slow time-variant, so it is OK to use a + * historical value. + */ + ar5416LoadNF(ah, AH_PRIVATE(ah)->ah_curchan); - /* start NF calibration, without updating BB NF register*/ - ar5416StartNFCal(ah); + /* start NF calibration, without updating BB NF register*/ + ar5416StartNFCal(ah); + } } return AH_TRUE; } @@ -758,17 +766,22 @@ ar5416SanitizeNF(struct ath_hal *ah, int /* * Read the NF and check it against the noise floor threshhold + * + * Return 0 if the NF calibration hadn't finished, 0 if it was + * invalid, or > 0 for a valid NF reading. */ static int16_t ar5416GetNf(struct ath_hal *ah, struct ieee80211_channel *chan) { int16_t nf, nfThresh; int i; + int retval = 0; if (ar5212IsNFCalInProgress(ah)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: NF didn't complete in calibration window\n", __func__); nf = 0; + retval = -1; /* NF didn't finish */ } else { /* Finished NF cal, check against threshold */ int16_t nfarray[NUM_NOISEFLOOR_READINGS] = { 0 }; @@ -780,7 +793,7 @@ ar5416GetNf(struct ath_hal *ah, struct i ar5416SanitizeNF(ah, nfarray); if (ar5416GetEepromNoiseFloorThresh(ah, chan, &nfThresh)) { if (nf > nfThresh) { - HALDEBUG(ah, HAL_DEBUG_ANY, + HALDEBUG(ah, HAL_DEBUG_UNMASKABLE, "%s: noise floor failed detected; " "detected %d, threshold %d\n", __func__, nf, nfThresh); @@ -791,9 +804,11 @@ ar5416GetNf(struct ath_hal *ah, struct i */ chan->ic_state |= IEEE80211_CHANSTATE_CWINT; nf = 0; + retval = 0; } } else { nf = 0; + retval = 0; } /* Update MIMO channel statistics, regardless of validity or not (for now) */ for (i = 0; i < 3; i++) { @@ -804,6 +819,7 @@ ar5416GetNf(struct ath_hal *ah, struct i ar5416UpdateNFHistBuff(ah, AH5416(ah)->ah_cal.nfCalHist, nfarray); ichan->rawNoiseFloor = nf; + retval = nf; } - return nf; + return retval; }