📄 ar5210_misc.c.svn-base
字号:
else OS_REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_NO_PSPOLL);}/* * Get the current hardware tsf for stamlme. */uint64_tar5210GetTsf64(struct ath_hal *ah){ uint32_t low1, low2, u32; /* sync multi-word read */ low1 = OS_REG_READ(ah, AR_TSF_L32); u32 = OS_REG_READ(ah, AR_TSF_U32); low2 = OS_REG_READ(ah, AR_TSF_L32); if (low2 < low1) { /* roll over */ /* * If we are not preempted this will work. If we are * then we re-reading AR_TSF_U32 does no good as the * low bits will be meaningless. Likewise reading * L32, U32, U32, then comparing the last two reads * to check for rollover doesn't help if preempted--so * we take this approach as it costs one less PCI * 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_tar5210GetTsf32(struct ath_hal *ah){ return OS_REG_READ(ah, AR_TSF_L32);}/* * Reset the current hardware tsf for stamlme */voidar5210ResetTsf(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_tar5210GetRandomSeed(struct ath_hal *ah){ uint32_t nf; nf = (OS_REG_READ(ah, AR_PHY_BASE + (25 << 2)) >> 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_BOOLar5210DetectCardPresent(struct ath_hal *ah){ /* * 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. */ return (AH_PRIVATE(ah)->ah_macRev == (OS_REG_READ(ah, AR_SREV) & 0xff));}/* * Update MIB Counters */voidar5210UpdateMibCounters(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_BOOLar5210SetSifsTime(struct ath_hal *ah, u_int us){ struct ath_hal_5210 *ahp = AH5210(ah); if (us > ath_hal_mac_usec(ah, 0x7ff)) { 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_RMW_FIELD(ah, AR_IFS0, AR_IFS0_SIFS, ath_hal_mac_clks(ah, us)); ahp->ah_sifstime = us; return AH_TRUE; }}u_intar5210GetSifsTime(struct ath_hal *ah){ u_int clks = OS_REG_READ(ah, AR_IFS0) & 0x7ff; return ath_hal_mac_usec(ah, clks); /* convert from system clocks */}HAL_BOOLar5210SetSlotTime(struct ath_hal *ah, u_int us){ struct ath_hal_5210 *ahp = AH5210(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 = (u_int) -1; /* restore default handling */ return AH_FALSE; } else { /* convert to system clocks */ OS_REG_WRITE(ah, AR_SLOT_TIME, ath_hal_mac_clks(ah, us)); ahp->ah_slottime = us; return AH_TRUE; }}u_intar5210GetSlotTime(struct ath_hal *ah){ u_int clks = OS_REG_READ(ah, AR_SLOT_TIME) & 0xffff; return ath_hal_mac_usec(ah, clks); /* convert from system clocks */}HAL_BOOLar5210SetAckTimeout(struct ath_hal *ah, u_int us){ struct ath_hal_5210 *ahp = AH5210(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_intar5210GetAckTimeout(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_intar5210GetAckCTSRate(struct ath_hal *ah){ return ((AH5210(ah)->ah_staId1Defaults & AR_STA_ID1_ACKCTS_6MB) == 0);}HAL_BOOLar5210SetAckCTSRate(struct ath_hal *ah, u_int high){ struct ath_hal_5210 *ahp = AH5210(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_BOOLar5210SetCTSTimeout(struct ath_hal *ah, u_int us){ struct ath_hal_5210 *ahp = AH5210(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_intar5210GetCTSTimeout(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_BOOLar5210SetDecompMask(struct ath_hal *ah, uint16_t keyidx, int en){ /* nothing to do */ return AH_TRUE;}voidar5210SetCoverageClass(struct ath_hal *ah, uint8_t coverageclass, int now){}/* * Control Adaptive Noise Immunity Parameters */HAL_BOOLar5210AniControl(struct ath_hal *ah, HAL_ANI_CMD cmd, int param){ return AH_FALSE;}voidar5210AniPoll(struct ath_hal *ah, const HAL_NODE_STATS *stats, HAL_CHANNEL *chan){}voidar5210MibEvent(struct ath_hal *ah, const HAL_NODE_STATS *stats){}#define AR_DIAG_SW_DIS_CRYPTO (AR_DIAG_SW_DIS_ENC | AR_DIAG_SW_DIS_DEC)HAL_STATUSar5210GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, uint32_t capability, uint32_t *result){ switch (type) { case HAL_CAP_CIPHER: /* cipher handled in hardware */ return (capability == HAL_CIPHER_WEP ? HAL_OK : HAL_ENOTSUPP); default: return ath_hal_getcapability(ah, type, capability, result); }}HAL_BOOLar5210SetCapability(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; case HAL_CAP_RXORN_FATAL: /* HAL_INT_RXORN treated as fatal */ return AH_FALSE; /* NB: disallow */ default: return ath_hal_setcapability(ah, type, capability, setting, status); }}HAL_BOOLar5210GetDiagState(struct ath_hal *ah, int request, const void *args, uint32_t argsize, void **result, uint32_t *resultsize){#ifdef AH_PRIVATE_DIAG uint32_t pcicfg; HAL_BOOL ok; switch (request) { case HAL_DIAG_EEPROM: /* XXX */ break; case HAL_DIAG_EEREAD: if (argsize != sizeof(uint16_t)) return AH_FALSE; pcicfg = OS_REG_READ(ah, AR_PCICFG); OS_REG_WRITE(ah, AR_PCICFG, pcicfg | AR_PCICFG_EEPROMSEL); ok = ath_hal_eepromRead(ah, *(const uint16_t *)args, *result); OS_REG_WRITE(ah, AR_PCICFG, pcicfg); if (ok) *resultsize = sizeof(uint16_t); return ok; }#endif return ath_hal_getdiagstate(ah, request, args, argsize, result, resultsize);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -