Path: blob/main/sys/dev/ath/ath_hal/ar5211/ar5211.h
39566 views
/*-1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2002-2009 Sam Leffler, Errno Consulting4* Copyright (c) 2002-2006 Atheros Communications, Inc.5*6* Permission to use, copy, modify, and/or distribute this software for any7* purpose with or without fee is hereby granted, provided that the above8* copyright notice and this permission notice appear in all copies.9*10* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES11* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR13* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES14* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN15* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF16* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.17*/18#ifndef _ATH_AR5211_H_19#define _ATH_AR5211_H_2021#include "ah_eeprom.h"2223#define AR5211_MAGIC 0x195704052425/* Classes for WME streams */26#define AC_BK 027#define AC_BE 128#define AC_VI 229#define AC_VO 33031/* DCU Transmit Filter macros */32#define CALC_MMR(dcu, idx) \33( (4 * dcu) + (idx < 32 ? 0 : (idx < 64 ? 1 : (idx < 96 ? 2 : 3))) )34#define TXBLK_FROM_MMR(mmr) \35(AR_D_TXBLK_BASE + ((mmr & 0x1f) << 6) + ((mmr & 0x20) >> 3))36#define CALC_TXBLK_ADDR(dcu, idx) (TXBLK_FROM_MMR(CALC_MMR(dcu, idx)))37#define CALC_TXBLK_VALUE(idx) (1 << (idx & 0x1f))3839/* MAC register values */4041#define INIT_INTERRUPT_MASK \42( AR_IMR_TXERR | AR_IMR_TXOK | AR_IMR_RXORN | \43AR_IMR_RXERR | AR_IMR_RXOK | AR_IMR_TXURN | \44AR_IMR_HIUERR )45#define INIT_BEACON_CONTROL \46( (INIT_RESET_TSF << 24) | (INIT_BEACON_EN << 23) | \47(INIT_TIM_OFFSET << 16) | INIT_BEACON_PERIOD )4849#define INIT_CONFIG_STATUS 0x0000000050#define INIT_RSSI_THR 0x00000700 /* Missed beacon counter initialized to 0x7 (max is 0xff) */51#define INIT_IQCAL_LOG_COUNT_MAX 0xF52#define INIT_BCON_CNTRL_REG 0x000000005354#define INIT_BEACON_PERIOD 0xffff55#define INIT_TIM_OFFSET 056#define INIT_BEACON_EN 0 /* this should be set by AP only when it's ready */57#define INIT_RESET_TSF 05859/*60* Various fifo fill before Tx start, in 64-byte units61* i.e. put the frame in the air while still DMAing62*/63#define MIN_TX_FIFO_THRESHOLD 0x164#define MAX_TX_FIFO_THRESHOLD ((IEEE80211_MAX_LEN / 64) + 1)65#define INIT_TX_FIFO_THRESHOLD MIN_TX_FIFO_THRESHOLD6667/*68* Gain support.69*/70typedef struct _gainOptStep {71int16_t paramVal[4];72int32_t stepGain;73int8_t stepName[16];74} GAIN_OPTIMIZATION_STEP;7576typedef struct {77uint32_t numStepsInLadder;78uint32_t defaultStepNum;79GAIN_OPTIMIZATION_STEP optStep[10];80} GAIN_OPTIMIZATION_LADDER;8182typedef struct {83uint32_t currStepNum;84uint32_t currGain;85uint32_t targetGain;86uint32_t loTrig;87uint32_t hiTrig;88uint32_t active;89const GAIN_OPTIMIZATION_STEP *currStep;90} GAIN_VALUES;9192enum {93RFGAIN_INACTIVE,94RFGAIN_READ_REQUESTED,95RFGAIN_NEED_CHANGE96};9798/*99* Header Info - general parameters and100* values set for each chipset board solution101* that are programmed every reset102*/103struct ath_hal_5211 {104struct ath_hal_private ah_priv; /* base class */105106GAIN_VALUES ah_gainValues;107108uint8_t ah_macaddr[IEEE80211_ADDR_LEN];109uint8_t ah_bssid[IEEE80211_ADDR_LEN];110111/*112* Runtime state.113*/114uint32_t ah_maskReg; /* copy of AR_IMR */115uint32_t ah_txOkInterruptMask;116uint32_t ah_txErrInterruptMask;117uint32_t ah_txDescInterruptMask;118uint32_t ah_txEolInterruptMask;119uint32_t ah_txUrnInterruptMask;120HAL_TX_QUEUE_INFO ah_txq[HAL_NUM_TX_QUEUES];121HAL_ANT_SETTING ah_diversityControl; /* antenna setting */122uint32_t ah_calibrationTime;123HAL_BOOL ah_bIQCalibration;124int ah_rfgainState;125uint32_t ah_tx6PowerInHalfDbm; /* power output for 6Mb tx */126uint32_t ah_staId1Defaults; /* STA_ID1 default settings */127uint32_t ah_beaconInterval;128uint32_t ah_rssiThr; /* RSSI_THR settings */129130u_int ah_sifstime; /* user-specified sifs time */131u_int ah_slottime; /* user-specified slot time */132u_int ah_acktimeout; /* user-specified ack timeout */133u_int ah_ctstimeout; /* user-specified cts timeout */134/*135* RF Silent handling.136*/137uint32_t ah_gpioSelect; /* GPIO pin to use */138uint32_t ah_polarity; /* polarity to disable RF */139uint32_t ah_gpioBit; /* after init, prev value */140};141#define AH5211(ah) ((struct ath_hal_5211 *)(ah))142143struct ath_hal;144145extern void ar5211Detach(struct ath_hal *);146147extern HAL_BOOL ar5211Reset(struct ath_hal *, HAL_OPMODE,148struct ieee80211_channel *, HAL_BOOL bChannelChange,149HAL_RESET_TYPE,150HAL_STATUS *);151extern HAL_BOOL ar5211PhyDisable(struct ath_hal *);152extern HAL_BOOL ar5211Disable(struct ath_hal *);153extern HAL_BOOL ar5211ChipReset(struct ath_hal *,154const struct ieee80211_channel *);155extern HAL_BOOL ar5211PerCalibration(struct ath_hal *, struct ieee80211_channel *, HAL_BOOL *);156extern HAL_BOOL ar5211PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan,157u_int chainMask, HAL_BOOL longCal, HAL_BOOL *isCalDone);158extern HAL_BOOL ar5211ResetCalValid(struct ath_hal *ah, const struct ieee80211_channel *);159extern HAL_BOOL ar5211SetTxPowerLimit(struct ath_hal *, uint32_t limit);160extern HAL_BOOL ar5211CalNoiseFloor(struct ath_hal *,161const struct ieee80211_channel *);162extern HAL_BOOL ar5211SetAntennaSwitchInternal(struct ath_hal *,163HAL_ANT_SETTING, const struct ieee80211_channel *);164extern int16_t ar5211GetNfAdjust(struct ath_hal *,165const HAL_CHANNEL_INTERNAL *);166extern HAL_BOOL ar5211ResetDma(struct ath_hal *, HAL_OPMODE);167extern void ar5211InitializeGainValues(struct ath_hal *);168extern HAL_RFGAIN ar5211GetRfgain(struct ath_hal *);169extern void ar5211SetPCUConfig(struct ath_hal *);170171extern HAL_BOOL ar5211SetTxQueueProps(struct ath_hal *ah, int q,172const HAL_TXQ_INFO *qInfo);173extern HAL_BOOL ar5211GetTxQueueProps(struct ath_hal *ah, int q,174HAL_TXQ_INFO *qInfo);175extern int ar5211SetupTxQueue(struct ath_hal *ah, HAL_TX_QUEUE type,176const HAL_TXQ_INFO *qInfo);177extern HAL_BOOL ar5211ReleaseTxQueue(struct ath_hal *ah, u_int q);178extern HAL_BOOL ar5211ResetTxQueue(struct ath_hal *ah, u_int q);179extern uint32_t ar5211GetTxDP(struct ath_hal *, u_int);180extern HAL_BOOL ar5211SetTxDP(struct ath_hal *, u_int, uint32_t txdp);181extern HAL_BOOL ar5211UpdateTxTrigLevel(struct ath_hal *, HAL_BOOL);182extern HAL_BOOL ar5211StartTxDma(struct ath_hal *, u_int);183extern HAL_BOOL ar5211StopTxDma(struct ath_hal *, u_int);184extern uint32_t ar5211NumTxPending(struct ath_hal *, u_int qnum);185extern HAL_BOOL ar5211IsTxQueueStopped(struct ath_hal *, u_int);186extern HAL_BOOL ar5211GetTransmitFilterIndex(struct ath_hal *, uint32_t);187extern HAL_BOOL ar5211SetupTxDesc(struct ath_hal *, struct ath_desc *,188u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int txPower,189u_int txRate0, u_int txTries0,190u_int keyIx, u_int antMode, u_int flags,191u_int rtsctsRate, u_int rtsctsDuration,192u_int compicvLen, u_int compivLen, u_int comp);193extern HAL_BOOL ar5211SetupXTxDesc(struct ath_hal *, struct ath_desc *,194u_int txRate1, u_int txRetries1,195u_int txRate2, u_int txRetries2,196u_int txRate3, u_int txRetries3);197extern HAL_BOOL ar5211FillTxDesc(struct ath_hal *, struct ath_desc *,198HAL_DMA_ADDR *bufAddrList, uint32_t *segLenList,199u_int descId, u_int qcuId, HAL_BOOL firstSeg, HAL_BOOL lastSeg,200const struct ath_desc *ds0);201extern HAL_STATUS ar5211ProcTxDesc(struct ath_hal *,202struct ath_desc *, struct ath_tx_status *);203extern void ar5211GetTxIntrQueue(struct ath_hal *ah, uint32_t *);204extern void ar5211IntrReqTxDesc(struct ath_hal *ah, struct ath_desc *);205extern HAL_BOOL ar5211GetTxCompletionRates(struct ath_hal *ah,206const struct ath_desc *ds0, int *rates, int *tries);207extern void ar5211SetTxDescLink(struct ath_hal *ah, void *ds,208uint32_t link);209extern void ar5211GetTxDescLink(struct ath_hal *ah, void *ds,210uint32_t *link);211extern void ar5211GetTxDescLinkPtr(struct ath_hal *ah, void *ds,212uint32_t **linkptr);213214extern uint32_t ar5211GetRxDP(struct ath_hal *, HAL_RX_QUEUE);215extern void ar5211SetRxDP(struct ath_hal *, uint32_t rxdp, HAL_RX_QUEUE);216extern void ar5211EnableReceive(struct ath_hal *);217extern HAL_BOOL ar5211StopDmaReceive(struct ath_hal *);218extern void ar5211StartPcuReceive(struct ath_hal *, HAL_BOOL);219extern void ar5211StopPcuReceive(struct ath_hal *);220extern void ar5211SetMulticastFilter(struct ath_hal *,221uint32_t filter0, uint32_t filter1);222extern HAL_BOOL ar5211ClrMulticastFilterIndex(struct ath_hal *, uint32_t);223extern HAL_BOOL ar5211SetMulticastFilterIndex(struct ath_hal *, uint32_t);224extern uint32_t ar5211GetRxFilter(struct ath_hal *);225extern void ar5211SetRxFilter(struct ath_hal *, uint32_t);226extern HAL_BOOL ar5211SetupRxDesc(struct ath_hal *, struct ath_desc *,227uint32_t, u_int flags);228extern HAL_STATUS ar5211ProcRxDesc(struct ath_hal *, struct ath_desc *,229uint32_t, struct ath_desc *, uint64_t,230struct ath_rx_status *);231232extern void ar5211GetMacAddress(struct ath_hal *, uint8_t *);233extern HAL_BOOL ar5211SetMacAddress(struct ath_hal *ah, const uint8_t *);234extern void ar5211GetBssIdMask(struct ath_hal *, uint8_t *);235extern HAL_BOOL ar5211SetBssIdMask(struct ath_hal *, const uint8_t *);236extern HAL_BOOL ar5211EepromRead(struct ath_hal *, u_int off, uint16_t *data);237extern HAL_BOOL ar5211EepromWrite(struct ath_hal *, u_int off, uint16_t data);238extern HAL_BOOL ar5211SetRegulatoryDomain(struct ath_hal *,239uint16_t, HAL_STATUS *);240extern u_int ar5211GetWirelessModes(struct ath_hal *);241extern void ar5211EnableRfKill(struct ath_hal *);242extern uint32_t ar5211GpioGet(struct ath_hal *, uint32_t gpio);243extern void ar5211GpioSetIntr(struct ath_hal *, u_int, uint32_t ilevel);244extern HAL_BOOL ar5211GpioCfgOutput(struct ath_hal *, uint32_t gpio,245HAL_GPIO_MUX_TYPE);246extern HAL_BOOL ar5211GpioCfgInput(struct ath_hal *, uint32_t gpio);247extern HAL_BOOL ar5211GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val);248extern void ar5211SetLedState(struct ath_hal *, HAL_LED_STATE);249extern u_int ar5211AntennaGet(struct ath_hal *);250extern void ar5211WriteAssocid(struct ath_hal *,251const uint8_t *bssid, uint16_t assocId);252extern uint64_t ar5211GetTsf64(struct ath_hal *);253extern uint32_t ar5211GetTsf32(struct ath_hal *);254extern void ar5211ResetTsf(struct ath_hal *);255extern uint32_t ar5211GetMaxTurboRate(struct ath_hal *);256extern uint32_t ar5211GetRandomSeed(struct ath_hal *);257extern HAL_BOOL ar5211DetectCardPresent(struct ath_hal *);258extern void ar5211UpdateMibCounters(struct ath_hal *, HAL_MIB_STATS *);259extern void ar5211EnableHwEncryption(struct ath_hal *);260extern void ar5211DisableHwEncryption(struct ath_hal *);261extern HAL_BOOL ar5211SetSlotTime(struct ath_hal *, u_int);262extern u_int ar5211GetSlotTime(struct ath_hal *);263extern HAL_BOOL ar5211SetAckTimeout(struct ath_hal *, u_int);264extern u_int ar5211GetAckTimeout(struct ath_hal *);265extern HAL_BOOL ar5211SetAckCTSRate(struct ath_hal *, u_int);266extern u_int ar5211GetAckCTSRate(struct ath_hal *);267extern HAL_BOOL ar5211SetCTSTimeout(struct ath_hal *, u_int);268extern u_int ar5211GetCTSTimeout(struct ath_hal *);269extern HAL_BOOL ar5211SetSifsTime(struct ath_hal *, u_int);270extern u_int ar5211GetSifsTime(struct ath_hal *);271extern HAL_BOOL ar5211SetDecompMask(struct ath_hal *, uint16_t, int);272extern void ar5211SetCoverageClass(struct ath_hal *, uint8_t, int);273extern HAL_STATUS ar5211SetQuiet(struct ath_hal *, uint32_t, uint32_t,274uint32_t, HAL_QUIET_FLAG);275extern uint32_t ar5211GetCurRssi(struct ath_hal *);276extern u_int ar5211GetDefAntenna(struct ath_hal *);277extern void ar5211SetDefAntenna(struct ath_hal *ah, u_int antenna);278extern HAL_ANT_SETTING ar5211GetAntennaSwitch(struct ath_hal *);279extern HAL_BOOL ar5211SetAntennaSwitch(struct ath_hal *, HAL_ANT_SETTING);280extern HAL_STATUS ar5211GetCapability(struct ath_hal *, HAL_CAPABILITY_TYPE,281uint32_t, uint32_t *);282extern HAL_BOOL ar5211SetCapability(struct ath_hal *, HAL_CAPABILITY_TYPE,283uint32_t, uint32_t, HAL_STATUS *);284extern HAL_BOOL ar5211GetDiagState(struct ath_hal *ah, int request,285const void *args, uint32_t argsize,286void **result, uint32_t *resultsize);287extern uint32_t ar5211Get11nExtBusy(struct ath_hal *);288extern HAL_BOOL ar5211GetMibCycleCounts(struct ath_hal *,289HAL_SURVEY_SAMPLE *);290extern void ar5211SetChainMasks(struct ath_hal *ah, uint32_t, uint32_t);291extern void ar5211SetNav(struct ath_hal *ah, u_int);292extern u_int ar5211GetNav(struct ath_hal *ah);293294extern void ar5211EnableDfs(struct ath_hal *, HAL_PHYERR_PARAM *);295extern void ar5211GetDfsThresh(struct ath_hal *, HAL_PHYERR_PARAM *);296297extern u_int ar5211GetKeyCacheSize(struct ath_hal *);298extern HAL_BOOL ar5211IsKeyCacheEntryValid(struct ath_hal *, uint16_t);299extern HAL_BOOL ar5211ResetKeyCacheEntry(struct ath_hal *, uint16_t entry);300extern HAL_BOOL ar5211SetKeyCacheEntry(struct ath_hal *, uint16_t entry,301const HAL_KEYVAL *, const uint8_t *mac,302int xorKey);303extern HAL_BOOL ar5211SetKeyCacheEntryMac(struct ath_hal *,304uint16_t, const uint8_t *);305306extern HAL_BOOL ar5211SetPowerMode(struct ath_hal *, HAL_POWER_MODE mode,307int setChip);308extern HAL_POWER_MODE ar5211GetPowerMode(struct ath_hal *);309310extern void ar5211SetBeaconTimers(struct ath_hal *,311const HAL_BEACON_TIMERS *);312extern void ar5211BeaconInit(struct ath_hal *, uint32_t, uint32_t);313extern void ar5211SetStaBeaconTimers(struct ath_hal *,314const HAL_BEACON_STATE *);315extern void ar5211ResetStaBeaconTimers(struct ath_hal *);316extern uint64_t ar5211GetNextTBTT(struct ath_hal *);317318extern HAL_BOOL ar5211IsInterruptPending(struct ath_hal *);319extern HAL_BOOL ar5211GetPendingInterrupts(struct ath_hal *, HAL_INT *);320extern HAL_INT ar5211GetInterrupts(struct ath_hal *);321extern HAL_INT ar5211SetInterrupts(struct ath_hal *, HAL_INT ints);322323extern const HAL_RATE_TABLE *ar5211GetRateTable(struct ath_hal *, u_int mode);324325extern HAL_BOOL ar5211AniControl(struct ath_hal *, HAL_ANI_CMD, int );326extern void ar5211RxMonitor(struct ath_hal *, const HAL_NODE_STATS *,327const struct ieee80211_channel *);328extern void ar5211AniPoll(struct ath_hal *, const struct ieee80211_channel *);329extern void ar5211MibEvent(struct ath_hal *, const HAL_NODE_STATS *);330#endif /* _ATH_AR5211_H_ */331332333