📄 ar5211_misc.c.svn-base
字号:
* read which can be noticeable when doing things * like timestamping packets in monitor mode. */ u32++; } return (((uint64_t) u32) << 32) | ((uint64_t) low2);}/* * Get the current hardware tsf for stamlme. */uint32_tar5211GetTsf32(struct ath_hal *ah){ return OS_REG_READ(ah, AR_TSF_L32);}/* * Reset the current hardware tsf for stamlme */voidar5211ResetTsf(struct ath_hal *ah){ uint32_t val = OS_REG_READ(ah, AR_BEACON); OS_REG_WRITE(ah, AR_BEACON, val | AR_BEACON_RESET_TSF);}/* * Grab a semi-random value from hardware registers - may not * change often */uint32_tar5211GetRandomSeed(struct ath_hal *ah){ uint32_t nf; nf = (OS_REG_READ(ah, AR_PHY(25)) >> 19) & 0x1ff; if (nf & 0x100) nf = 0 - ((nf ^ 0x1ff) + 1); return (OS_REG_READ(ah, AR_TSF_U32) ^ OS_REG_READ(ah, AR_TSF_L32) ^ nf);}/* * Detect if our card is present */HAL_BOOLar5211DetectCardPresent(struct ath_hal *ah){ uint16_t macVersion, macRev; uint32_t v; /* * Read the Silicon Revision register and compare that * to what we read at attach time. If the same, we say * a card/device is present. */ v = OS_REG_READ(ah, AR_SREV) & AR_SREV_ID_M; macVersion = v >> AR_SREV_ID_S; macRev = v & AR_SREV_REVISION_M; return (AH_PRIVATE(ah)->ah_macVersion == macVersion && AH_PRIVATE(ah)->ah_macRev == macRev);}/* * Update MIB Counters */voidar5211UpdateMibCounters(struct ath_hal *ah, HAL_MIB_STATS *stats){ stats->ackrcv_bad += OS_REG_READ(ah, AR_ACK_FAIL); stats->rts_bad += OS_REG_READ(ah, AR_RTS_FAIL); stats->fcs_bad += OS_REG_READ(ah, AR_FCS_FAIL); stats->rts_good += OS_REG_READ(ah, AR_RTS_OK); stats->beacons += OS_REG_READ(ah, AR_BEACON_CNT);}HAL_BOOLar5211SetSifsTime(struct ath_hal *ah, u_int us){ struct ath_hal_5211 *ahp = AH5211(ah); if (us > ath_hal_mac_usec(ah, 0xffff)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad SIFS time %u\n", __func__, us); ahp->ah_sifstime = (u_int) -1; /* restore default handling */ return AH_FALSE; } else { /* convert to system clocks */ OS_REG_WRITE(ah, AR_D_GBL_IFS_SIFS, ath_hal_mac_clks(ah, us)); ahp->ah_slottime = us; return AH_TRUE; }}u_intar5211GetSifsTime(struct ath_hal *ah){ u_int clks = OS_REG_READ(ah, AR_D_GBL_IFS_SIFS) & 0xffff; return ath_hal_mac_usec(ah, clks); /* convert from system clocks */}HAL_BOOLar5211SetSlotTime(struct ath_hal *ah, u_int us){ struct ath_hal_5211 *ahp = AH5211(ah); if (us < HAL_SLOT_TIME_9 || us > ath_hal_mac_usec(ah, 0xffff)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad slot time %u\n", __func__, us); ahp->ah_slottime = us; /* restore default handling */ return AH_FALSE; } else { /* convert to system clocks */ OS_REG_WRITE(ah, AR_D_GBL_IFS_SLOT, ath_hal_mac_clks(ah, us)); ahp->ah_slottime = us; return AH_TRUE; }}u_intar5211GetSlotTime(struct ath_hal *ah){ u_int clks = OS_REG_READ(ah, AR_D_GBL_IFS_SLOT) & 0xffff; return ath_hal_mac_usec(ah, clks); /* convert from system clocks */}HAL_BOOLar5211SetAckTimeout(struct ath_hal *ah, u_int us){ struct ath_hal_5211 *ahp = AH5211(ah); if (us > ath_hal_mac_usec(ah, MS(0xffffffff, AR_TIME_OUT_ACK))) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad ack timeout %u\n", __func__, us); ahp->ah_acktimeout = (u_int) -1; /* restore default handling */ return AH_FALSE; } else { /* convert to system clocks */ OS_REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_ACK, ath_hal_mac_clks(ah, us)); ahp->ah_acktimeout = us; return AH_TRUE; }}u_intar5211GetAckTimeout(struct ath_hal *ah){ u_int clks = MS(OS_REG_READ(ah, AR_TIME_OUT), AR_TIME_OUT_ACK); return ath_hal_mac_usec(ah, clks); /* convert from system clocks */}u_intar5211GetAckCTSRate(struct ath_hal *ah){ return ((AH5211(ah)->ah_staId1Defaults & AR_STA_ID1_ACKCTS_6MB) == 0);}HAL_BOOLar5211SetAckCTSRate(struct ath_hal *ah, u_int high){ struct ath_hal_5211 *ahp = AH5211(ah); if (high) { OS_REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_ACKCTS_6MB); ahp->ah_staId1Defaults &= ~AR_STA_ID1_ACKCTS_6MB; } else { OS_REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_ACKCTS_6MB); ahp->ah_staId1Defaults |= AR_STA_ID1_ACKCTS_6MB; } return AH_TRUE;}HAL_BOOLar5211SetCTSTimeout(struct ath_hal *ah, u_int us){ struct ath_hal_5211 *ahp = AH5211(ah); if (us > ath_hal_mac_usec(ah, MS(0xffffffff, AR_TIME_OUT_CTS))) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad cts timeout %u\n", __func__, us); ahp->ah_ctstimeout = (u_int) -1; /* restore default handling */ return AH_FALSE; } else { /* convert to system clocks */ OS_REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_CTS, ath_hal_mac_clks(ah, us)); ahp->ah_ctstimeout = us; return AH_TRUE; }}u_intar5211GetCTSTimeout(struct ath_hal *ah){ u_int clks = MS(OS_REG_READ(ah, AR_TIME_OUT), AR_TIME_OUT_CTS); return ath_hal_mac_usec(ah, clks); /* convert from system clocks */}HAL_BOOLar5211SetDecompMask(struct ath_hal *ah, uint16_t keyidx, int en){ /* nothing to do */ return AH_TRUE;}voidar5211SetCoverageClass(struct ath_hal *ah, uint8_t coverageclass, int now){}/* * Control Adaptive Noise Immunity Parameters */HAL_BOOLar5211AniControl(struct ath_hal *ah, HAL_ANI_CMD cmd, int param){ return AH_FALSE;}voidar5211AniPoll(struct ath_hal *ah, const HAL_NODE_STATS *stats, HAL_CHANNEL *chan){}voidar5211MibEvent(struct ath_hal *ah, const HAL_NODE_STATS *stats){}/* * Get the rssi of frame curently being received. */uint32_tar5211GetCurRssi(struct ath_hal *ah){ return (OS_REG_READ(ah, AR_PHY_CURRENT_RSSI) & 0xff);}u_intar5211GetDefAntenna(struct ath_hal *ah){ return (OS_REG_READ(ah, AR_DEF_ANTENNA) & 0x7);} voidar5211SetDefAntenna(struct ath_hal *ah, u_int antenna){ OS_REG_WRITE(ah, AR_DEF_ANTENNA, (antenna & 0x7));}HAL_ANT_SETTINGar5211GetAntennaSwitch(struct ath_hal *ah){ return AH5211(ah)->ah_diversityControl;}HAL_BOOLar5211SetAntennaSwitch(struct ath_hal *ah, HAL_ANT_SETTING settings){ const HAL_CHANNEL *chan = (const HAL_CHANNEL *) AH_PRIVATE(ah)->ah_curchan; if (chan == AH_NULL) { AH5211(ah)->ah_diversityControl = settings; return AH_TRUE; } return ar5211SetAntennaSwitchInternal(ah, settings, chan);}HAL_STATUSar5211GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, uint32_t capability, uint32_t *result){ switch (type) { case HAL_CAP_CIPHER: /* cipher handled in hardware */ switch (capability) { case HAL_CIPHER_AES_OCB: case HAL_CIPHER_WEP: case HAL_CIPHER_CLR: return HAL_OK; default: return HAL_ENOTSUPP; } default: return ath_hal_getcapability(ah, type, capability, result); }}HAL_BOOLar5211SetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, uint32_t capability, uint32_t setting, HAL_STATUS *status){ switch (type) { case HAL_CAP_DIAG: /* hardware diagnostic support */ /* * NB: could split this up into virtual capabilities, * (e.g. 1 => ACK, 2 => CTS, etc.) but it hardly * seems worth the additional complexity. */#ifdef AH_DEBUG AH_PRIVATE(ah)->ah_diagreg = setting;#else AH_PRIVATE(ah)->ah_diagreg = setting & 0x6; /* ACK+CTS */#endif OS_REG_WRITE(ah, AR_DIAG_SW, AH_PRIVATE(ah)->ah_diagreg); return AH_TRUE; default: return ath_hal_setcapability(ah, type, capability, setting, status); }}HAL_BOOLar5211GetDiagState(struct ath_hal *ah, int request, const void *args, uint32_t argsize, void **result, uint32_t *resultsize){ struct ath_hal_5211 *ahp = AH5211(ah); (void) ahp; if (ath_hal_getdiagstate(ah, request, args, argsize, result, resultsize)) return AH_TRUE; switch (request) { case HAL_DIAG_EEPROM: return ath_hal_eepromDiag(ah, request, args, argsize, result, resultsize); case HAL_DIAG_RFGAIN: *result = &ahp->ah_gainValues; *resultsize = sizeof(GAIN_VALUES); return AH_TRUE; case HAL_DIAG_RFGAIN_CURSTEP: *result = __DECONST(void *, ahp->ah_gainValues.currStep); *resultsize = (*result == AH_NULL) ? 0 : sizeof(GAIN_OPTIMIZATION_STEP); return AH_TRUE; } return AH_FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -