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.
This commit is contained in:
Adrian Chadd 2015-03-29 21:50:21 +00:00
parent 5f63869372
commit b0602bec18
8 changed files with 58 additions and 30 deletions

View File

@ -881,6 +881,7 @@ ath_hal_getdiagstate(struct ath_hal *ah, int request,
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, int request,
} 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, HAL_CHANNEL_INTERNAL *ichan)
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++;
}

View File

@ -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 *ah,
*/
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_ */

View File

@ -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);

View File

@ -869,7 +869,6 @@ ar5212AniGetListenTime(struct ath_hal *ah)
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 *ah)
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;

View File

@ -1113,10 +1113,6 @@ ar5212GetDiagState(struct ath_hal *ah, int request,
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;
}

View File

@ -197,7 +197,8 @@ ar5212Reset(struct ath_hal *ah, HAL_OPMODE opmode,
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

View File

@ -818,7 +818,6 @@ ar5416AniGetListenTime(struct ath_hal *ah)
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 *ah)
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;

View File

@ -120,9 +120,10 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode,
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