Bring over the relevant registers to use when implementing the quiet time

portion of 802.11h.

The AR5212 code has been brought over as a reference, it's currently
untested.

Obtained from:	Atheros
This commit is contained in:
Adrian Chadd 2011-06-03 07:27:53 +00:00
parent 1524677adf
commit 04d172db03
8 changed files with 63 additions and 0 deletions

View File

@ -735,6 +735,16 @@ typedef struct {
#define HAL_PHYERR_PARAM_ENABLE 0x8000 /* Enable/Disable if applicable */ #define HAL_PHYERR_PARAM_ENABLE 0x8000 /* Enable/Disable if applicable */
/*
* Flag for setting QUIET period
*/
typedef enum {
HAL_QUIET_DISABLE = 0x0,
HAL_QUIET_ENABLE = 0x1,
HAL_QUIET_ADD_CURRENT_TSF = 0x2, /* add current TSF to next_start offset */
HAL_QUIET_ADD_SWBA_RESP_TIME = 0x4, /* add beacon response time to next_start offset */
} HAL_QUIET_FLAG;
/* /*
* Hardware Access Layer (HAL) API. * Hardware Access Layer (HAL) API.
* *
@ -909,6 +919,9 @@ struct ath_hal {
u_int __ahdecl(*ah_getCTSTimeout)(struct ath_hal*); u_int __ahdecl(*ah_getCTSTimeout)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_setDecompMask)(struct ath_hal*, uint16_t, int); HAL_BOOL __ahdecl(*ah_setDecompMask)(struct ath_hal*, uint16_t, int);
void __ahdecl(*ah_setCoverageClass)(struct ath_hal*, uint8_t, int); void __ahdecl(*ah_setCoverageClass)(struct ath_hal*, uint8_t, int);
HAL_STATUS __ahdecl(*ah_setQuiet)(struct ath_hal *ah, uint32_t period,
uint32_t duration, uint32_t nextStart,
HAL_QUIET_FLAG flag);
/* DFS functions */ /* DFS functions */
void __ahdecl(*ah_enableDfs)(struct ath_hal *ah, void __ahdecl(*ah_enableDfs)(struct ath_hal *ah,

View File

@ -506,6 +506,8 @@ extern HAL_BOOL ar5212SetCapability(struct ath_hal *, HAL_CAPABILITY_TYPE,
extern HAL_BOOL ar5212GetDiagState(struct ath_hal *ah, int request, extern HAL_BOOL ar5212GetDiagState(struct ath_hal *ah, int request,
const void *args, uint32_t argsize, const void *args, uint32_t argsize,
void **result, uint32_t *resultsize); void **result, uint32_t *resultsize);
extern HAL_STATUS ar5212SetQuiet(struct ath_hal *ah, uint32_t period,
uint32_t duration, uint32_t nextStart, HAL_QUIET_FLAG flag);
extern HAL_BOOL ar5212SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, extern HAL_BOOL ar5212SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode,
int setChip); int setChip);

View File

@ -127,6 +127,7 @@ static const struct ath_hal_private ar5212hal = {{
.ah_getCTSTimeout = ar5212GetCTSTimeout, .ah_getCTSTimeout = ar5212GetCTSTimeout,
.ah_setDecompMask = ar5212SetDecompMask, .ah_setDecompMask = ar5212SetDecompMask,
.ah_setCoverageClass = ar5212SetCoverageClass, .ah_setCoverageClass = ar5212SetCoverageClass,
.ah_setQuiet = ar5212SetQuiet,
/* DFS Functions */ /* DFS Functions */
.ah_enableDfs = ar5212EnableDfs, .ah_enableDfs = ar5212EnableDfs,

View File

@ -634,6 +634,20 @@ ar5212SetCoverageClass(struct ath_hal *ah, uint8_t coverageclass, int now)
} }
} }
HAL_STATUS
ar5212SetQuiet(struct ath_hal *ah, uint32_t period, uint32_t duration,
uint32_t nextStart, HAL_QUIET_FLAG flag)
{
OS_REG_WRITE(ah, AR_QUIET2, period | (duration << AR_QUIET2_QUIET_DUR_S));
if (flag & HAL_QUIET_ENABLE) {
OS_REG_WRITE(ah, AR_QUIET1, nextStart | (1 << 16));
}
else {
OS_REG_WRITE(ah, AR_QUIET1, nextStart);
}
return HAL_OK;
}
void void
ar5212SetPCUConfig(struct ath_hal *ah) ar5212SetPCUConfig(struct ath_hal *ah)
{ {

View File

@ -300,6 +300,7 @@
#define AR_QUIET1_NEXT_QUIET 0xffff #define AR_QUIET1_NEXT_QUIET 0xffff
#define AR_QUIET1_QUIET_ENABLE 0x10000 /* Enable Quiet time operation */ #define AR_QUIET1_QUIET_ENABLE 0x10000 /* Enable Quiet time operation */
#define AR_QUIET1_QUIET_ACK_CTS_ENABLE 0x20000 /* Do we ack/cts during quiet period */ #define AR_QUIET1_QUIET_ACK_CTS_ENABLE 0x20000 /* Do we ack/cts during quiet period */
#define AR_QUIET1_QUIET_ACK_CTS_ENABLE_S 17
#define AR_QUIET2 0x8100 /* More Quiet time programming */ #define AR_QUIET2 0x8100 /* More Quiet time programming */
#define AR_QUIET2_QUIET_PER_S 0 /* Periodicity of quiet period (TU) */ #define AR_QUIET2_QUIET_PER_S 0 /* Periodicity of quiet period (TU) */

View File

@ -194,6 +194,8 @@ extern uint32_t ar5416Get11nExtBusy(struct ath_hal *ah);
extern void ar5416Set11nMac2040(struct ath_hal *ah, HAL_HT_MACMODE mode); extern void ar5416Set11nMac2040(struct ath_hal *ah, HAL_HT_MACMODE mode);
extern HAL_HT_RXCLEAR ar5416Get11nRxClear(struct ath_hal *ah); extern HAL_HT_RXCLEAR ar5416Get11nRxClear(struct ath_hal *ah);
extern void ar5416Set11nRxClear(struct ath_hal *ah, HAL_HT_RXCLEAR rxclear); extern void ar5416Set11nRxClear(struct ath_hal *ah, HAL_HT_RXCLEAR rxclear);
extern HAL_STATUS ar5416SetQuiet(struct ath_hal *ah, uint32_t period,
uint32_t duration, uint32_t nextStart, HAL_QUIET_FLAG flag);
extern HAL_STATUS ar5416GetCapability(struct ath_hal *ah, extern HAL_STATUS ar5416GetCapability(struct ath_hal *ah,
HAL_CAPABILITY_TYPE type, uint32_t capability, uint32_t *result); HAL_CAPABILITY_TYPE type, uint32_t capability, uint32_t *result);
extern HAL_BOOL ar5416GetDiagState(struct ath_hal *ah, int request, extern HAL_BOOL ar5416GetDiagState(struct ath_hal *ah, int request,

View File

@ -139,6 +139,7 @@ ar5416InitState(struct ath_hal_5416 *ahp5416, uint16_t devid, HAL_SOFTC sc,
ah->ah_setAntennaSwitch = ar5416SetAntennaSwitch; ah->ah_setAntennaSwitch = ar5416SetAntennaSwitch;
ah->ah_setDecompMask = ar5416SetDecompMask; ah->ah_setDecompMask = ar5416SetDecompMask;
ah->ah_setCoverageClass = ar5416SetCoverageClass; ah->ah_setCoverageClass = ar5416SetCoverageClass;
ah->ah_setQuiet = ar5416SetQuiet;
ah->ah_resetKeyCacheEntry = ar5416ResetKeyCacheEntry; ah->ah_resetKeyCacheEntry = ar5416ResetKeyCacheEntry;
ah->ah_setKeyCacheEntry = ar5416SetKeyCacheEntry; ah->ah_setKeyCacheEntry = ar5416SetKeyCacheEntry;

View File

@ -273,6 +273,35 @@ ar5416Set11nRxClear(struct ath_hal *ah, HAL_HT_RXCLEAR rxclear)
} }
} }
/* XXX shouldn't be here! */
#define TU_TO_USEC(_tu) ((_tu) << 10)
HAL_STATUS
ar5416SetQuiet(struct ath_hal *ah, uint32_t period, uint32_t duration,
uint32_t nextStart, HAL_QUIET_FLAG flag)
{
uint32_t period_us = TU_TO_USEC(period); /* convert to us unit */
uint32_t nextStart_us = TU_TO_USEC(nextStart); /* convert to us unit */
if (flag & HAL_QUIET_ENABLE) {
if ((!nextStart) || (flag & HAL_QUIET_ADD_CURRENT_TSF)) {
/* Add the nextStart offset to the current TSF */
nextStart_us += OS_REG_READ(ah, AR_TSF_L32);
}
if (flag & HAL_QUIET_ADD_SWBA_RESP_TIME) {
nextStart_us += ath_hal_sw_beacon_response_time;
}
OS_REG_RMW_FIELD(ah, AR_QUIET1, AR_QUIET1_QUIET_ACK_CTS_ENABLE, 1);
OS_REG_WRITE(ah, AR_QUIET2, SM(duration, AR_QUIET2_QUIET_DUR));
OS_REG_WRITE(ah, AR_QUIET_PERIOD, period_us);
OS_REG_WRITE(ah, AR_NEXT_QUIET, nextStart_us);
OS_REG_SET_BIT(ah, AR_TIMER_MODE, AR_TIMER_MODE_QUIET);
} else {
OS_REG_CLR_BIT(ah, AR_TIMER_MODE, AR_TIMER_MODE_QUIET);
}
return HAL_OK;
}
#undef TU_TO_USEC
HAL_STATUS HAL_STATUS
ar5416GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, ar5416GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type,
uint32_t capability, uint32_t *result) uint32_t capability, uint32_t *result)