svn commit: r280828 - in head/sys/dev/ath/ath_hal: . ar5212 ar5416

Adrian Chadd adrian at FreeBSD.org
Sun Mar 29 21:50:25 UTC 2015


Author: adrian
Date: Sun Mar 29 21:50:21 2015
New Revision: 280828
URL: https://svnweb.freebsd.org/changeset/base/280828

Log:
  Move the HAL channel survey support out to be in the top-level HAL,
  rathe than private in each HAL module.
  
  Whilst here, modify ath_hal_private to always have the per-channel
  noisefloor stats, rather than conditionally.  This just makes
  life easier in general (no strange ABI differences between different
  HAL compile options.)
  
  Add a couple of methods (clear/reset, add) rather than using
  hand-rolled versions of things.

Modified:
  head/sys/dev/ath/ath_hal/ah.c
  head/sys/dev/ath/ath_hal/ah_internal.h
  head/sys/dev/ath/ath_hal/ar5212/ar5212.h
  head/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c
  head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c
  head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c
  head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c
  head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c

Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c	Sun Mar 29 21:45:48 2015	(r280827)
+++ head/sys/dev/ath/ath_hal/ah.c	Sun Mar 29 21:50:21 2015	(r280828)
@@ -881,6 +881,7 @@ ath_hal_getdiagstate(struct ath_hal *ah,
 	const void *args, uint32_t argsize,
 	void **result, uint32_t *resultsize)
 {
+
 	switch (request) {
 	case HAL_DIAG_REVS:
 		*result = &AH_PRIVATE(ah)->ah_devid;
@@ -938,6 +939,10 @@ ath_hal_getdiagstate(struct ath_hal *ah,
 		} else
 			return AH_FALSE;
 		return AH_TRUE;
+	case HAL_DIAG_CHANSURVEY:
+		*result = &AH_PRIVATE(ah)->ah_chansurvey;
+		*resultsize = sizeof(HAL_CHANNEL_SURVEY);
+		return AH_TRUE;
 	}
 	return AH_FALSE;
 }
@@ -1433,3 +1438,32 @@ ath_hal_mhz2ieee_2ghz(struct ath_hal *ah
 	else
 		return 15 + ((ichan->channel - 2512) / 20);
 }
+
+/*
+ * Clear the current survey data.
+ *
+ * This should be done during a channel change.
+ */
+void
+ath_hal_survey_clear(struct ath_hal *ah)
+{
+
+	OS_MEMZERO(&AH_PRIVATE(ah)->ah_chansurvey,
+	    sizeof(AH_PRIVATE(ah)->ah_chansurvey));
+}
+
+/*
+ * Add a sample to the channel survey.
+ */
+void
+ath_hal_survey_add_sample(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hs)
+{
+	HAL_CHANNEL_SURVEY *cs;
+
+	cs = &AH_PRIVATE(ah)->ah_chansurvey;
+
+	OS_MEMCPY(&cs->samples[cs->cur_sample], hs, sizeof(*hs));
+	cs->samples[cs->cur_sample].seq_num = cs->cur_seq;
+	cs->cur_sample = (cs->cur_sample + 1) % CHANNEL_SURVEY_SAMPLE_COUNT;
+	cs->cur_seq++;
+}

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Sun Mar 29 21:45:48 2015	(r280827)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Sun Mar 29 21:50:21 2015	(r280828)
@@ -422,9 +422,13 @@ struct ath_hal_private {
 	uint32_t	ah_fatalState[6];	/* AR_ISR+shadow regs */
 	int		ah_rxornIsFatal;	/* how to treat HAL_INT_RXORN */
 
-#ifndef	ATH_NF_PER_CHAN
+	/* Only used if ATH_NF_PER_CHAN is defined */
 	HAL_NFCAL_HIST_FULL	nf_cal_hist;
-#endif	/* ! ATH_NF_PER_CHAN */
+
+	/*
+	 * Channel survey history - current channel only.
+	 */
+	 HAL_CHANNEL_SURVEY	ah_chansurvey;	/* channel survey */
 };
 
 #define	AH_PRIVATE(_ah)	((struct ath_hal_private *)(_ah))
@@ -1029,4 +1033,15 @@ ath_hal_getantennaallowed(struct ath_hal
  */
 extern	int ath_hal_mhz2ieee_2ghz(struct ath_hal *, HAL_CHANNEL_INTERNAL *);
 
+/*
+ * Clear the channel survey data.
+ */
+extern	void ath_hal_survey_clear(struct ath_hal *ah);
+
+/*
+ * Add a sample to the channel survey data.
+ */
+extern	void ath_hal_survey_add_sample(struct ath_hal *ah,
+	    HAL_SURVEY_SAMPLE *hs);
+
 #endif /* _ATH_AH_INTERAL_H_ */

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212.h	Sun Mar 29 21:45:48 2015	(r280827)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212.h	Sun Mar 29 21:50:21 2015	(r280828)
@@ -319,7 +319,6 @@ struct ath_hal_5212 {
 	struct ar5212AniParams ah_aniParams5;	/* 5GHz parameters */
 	struct ar5212AniState	*ah_curani;	/* cached last reference */
 	struct ar5212AniState	ah_ani[AH_MAXCHAN]; /* per-channel state */
-	HAL_CHANNEL_SURVEY	ah_chansurvey; /* channel survey */
 
 	/* AR5416 uses some of the AR5212 ANI code; these are the ANI methods */
 	HAL_BOOL	(*ah_aniControl) (struct ath_hal *, HAL_ANI_CMD cmd, int param);

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c	Sun Mar 29 21:45:48 2015	(r280827)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_ani.c	Sun Mar 29 21:50:21 2015	(r280828)
@@ -869,7 +869,6 @@ ar5212AniGetListenTime(struct ath_hal *a
 	int32_t listenTime = 0;
 	int good;
 	HAL_SURVEY_SAMPLE hs;
-	HAL_CHANNEL_SURVEY *cs = AH_NULL;
 
 	/*
 	 * We shouldn't see ah_curchan be NULL, but just in case..
@@ -879,21 +878,13 @@ ar5212AniGetListenTime(struct ath_hal *a
 		return (0);
 	}
 
-	cs = &ahp->ah_chansurvey;
-
 	/*
 	 * Fetch the current statistics, squirrel away the current
 	 * sample, bump the sequence/sample counter.
 	 */
 	OS_MEMZERO(&hs, sizeof(hs));
 	good = ar5212GetMibCycleCounts(ah, &hs);
-	if (cs != AH_NULL) {
-		OS_MEMCPY(&cs->samples[cs->cur_sample], &hs, sizeof(hs));
-		cs->samples[cs->cur_sample].seq_num = cs->cur_seq;
-		cs->cur_sample =
-		    (cs->cur_sample + 1) % CHANNEL_SURVEY_SAMPLE_COUNT;
-		cs->cur_seq++;
-	}
+	ath_hal_survey_add_sample(ah, &hs);
 
 	if (ANI_ENA(ah))
 		aniState = ahp->ah_curani;

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Sun Mar 29 21:45:48 2015	(r280827)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c	Sun Mar 29 21:50:21 2015	(r280828)
@@ -1113,10 +1113,6 @@ ar5212GetDiagState(struct ath_hal *ah, i
 			return ar5212AniSetParams(ah, args, args);
 		}
 		break;
-	case HAL_DIAG_CHANSURVEY:
-		*result = &ahp->ah_chansurvey;
-		*resultsize = sizeof(HAL_CHANNEL_SURVEY);
-		return AH_TRUE;
 	}
 	return AH_FALSE;
 }

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c	Sun Mar 29 21:45:48 2015	(r280827)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c	Sun Mar 29 21:50:21 2015	(r280828)
@@ -197,7 +197,8 @@ ar5212Reset(struct ath_hal *ah, HAL_OPMO
 		saveFrameSeqCount = 0;		/* NB: silence compiler */
 
 	/* Blank the channel survey statistics */
-	OS_MEMZERO(&ahp->ah_chansurvey, sizeof(ahp->ah_chansurvey));
+	ath_hal_survey_clear(ah);
+
 #if 0
 	/*
 	 * XXX disable for now; this appears to sometimes cause OFDM

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c	Sun Mar 29 21:45:48 2015	(r280827)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c	Sun Mar 29 21:50:21 2015	(r280828)
@@ -818,7 +818,6 @@ ar5416AniGetListenTime(struct ath_hal *a
 	int32_t listenTime = 0;
 	int good;
 	HAL_SURVEY_SAMPLE hs;
-	HAL_CHANNEL_SURVEY *cs = AH_NULL;
 
 	/*
 	 * We shouldn't see ah_curchan be NULL, but just in case..
@@ -828,21 +827,13 @@ ar5416AniGetListenTime(struct ath_hal *a
 		return (0);
 	}
 
-	cs = &ahp->ah_chansurvey;
-
 	/*
 	 * Fetch the current statistics, squirrel away the current
-	 * sample, bump the sequence/sample counter.
+	 * sample.
 	 */
 	OS_MEMZERO(&hs, sizeof(hs));
 	good = ar5416GetMibCycleCounts(ah, &hs);
-	if (cs != AH_NULL) {
-		OS_MEMCPY(&cs->samples[cs->cur_sample], &hs, sizeof(hs));
-		cs->samples[cs->cur_sample].seq_num = cs->cur_seq;
-		cs->cur_sample =
-		    (cs->cur_sample + 1) % CHANNEL_SURVEY_SAMPLE_COUNT;
-		cs->cur_seq++;
-	}
+	ath_hal_survey_add_sample(ah, &hs);
 
 	if (ANI_ENA(ah))
 		aniState = ahp->ah_curani;

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Sun Mar 29 21:45:48 2015	(r280827)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Sun Mar 29 21:50:21 2015	(r280828)
@@ -120,9 +120,10 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMO
 	HALASSERT(AH_PRIVATE(ah)->ah_eeversion >= AR_EEPROM_VER14_1);
 
 	/* Blank the channel survey statistics */
-	OS_MEMZERO(&ahp->ah_chansurvey, sizeof(ahp->ah_chansurvey));
+	ath_hal_survey_clear(ah);
 
 	/* XXX Turn on fast channel change for 5416 */
+
 	/*
 	 * Preserve the bmiss rssi threshold and count threshold
 	 * across resets


More information about the svn-src-head mailing list