#ifndef _ATH_AH_INTERAL_H_
#define _ATH_AH_INTERAL_H_
#define AH_NULL 0
#define AH_MIN(a,b) ((a)<(b)?(a):(b))
#define AH_MAX(a,b) ((a)>(b)?(a):(b))
#include <net80211/_ieee80211.h>
#include <sys/queue.h>
#ifndef NBBY
#define NBBY 8
#endif
#ifndef roundup
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
#endif
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
#endif
#ifndef offsetof
#define offsetof(type, field) ((size_t)(&((type *)0)->field))
#endif
typedef struct {
uint32_t start;
uint32_t end;
} HAL_REGRANGE;
typedef struct {
uint32_t addr;
uint32_t value;
} HAL_REGWRITE;
typedef enum {
HAL_TP_SCALE_MAX = 0,
HAL_TP_SCALE_50 = 1,
HAL_TP_SCALE_25 = 2,
HAL_TP_SCALE_12 = 3,
HAL_TP_SCALE_MIN = 4,
} HAL_TP_SCALE;
typedef enum {
HAL_CAP_RADAR = 0,
HAL_CAP_AR = 1,
} HAL_PHYDIAG_CAPS;
#define HAL_CAP_STRONG_DIV 2
struct ath_hal_chip {
const char *name;
const char *(*probe)(uint16_t vendorid, uint16_t devid);
struct ath_hal *(*attach)(uint16_t devid, HAL_SOFTC,
HAL_BUS_TAG, HAL_BUS_HANDLE, uint16_t *eepromdata,
HAL_OPS_CONFIG *ah,
HAL_STATUS *error);
TAILQ_ENTRY(ath_hal_chip) node;
};
#ifndef AH_CHIP
#define AH_CHIP(_name, _probe, _attach) \
struct ath_hal_chip _name##_chip = { \
.name = #_name, \
.probe = _probe, \
.attach = _attach, \
}; \
OS_DATA_SET(ah_chips, _name##_chip)
#endif
struct ath_hal_rf {
const char *name;
HAL_BOOL (*probe)(struct ath_hal *ah);
HAL_BOOL (*attach)(struct ath_hal *ah, HAL_STATUS *ecode);
TAILQ_ENTRY(ath_hal_rf) node;
};
#ifndef AH_RF
#define AH_RF(_name, _probe, _attach) \
struct ath_hal_rf _name##_rf = { \
.name = __STRING(_name), \
.probe = _probe, \
.attach = _attach, \
}; \
OS_DATA_SET(ah_rfs, _name##_rf)
#endif
struct ath_hal_rf *ath_hal_rfprobe(struct ath_hal *ah, HAL_STATUS *ecode);
#ifndef AH_MAXCHAN
#define AH_MAXCHAN 128
#endif
#define HAL_NF_CAL_HIST_LEN_FULL 5
#define HAL_NF_CAL_HIST_LEN_SMALL 1
#define HAL_NUM_NF_READINGS 6
#define HAL_NF_LOAD_DELAY 1000
typedef struct {
u_int8_t curr_index;
int8_t invalidNFcount;
int16_t priv_nf[HAL_NUM_NF_READINGS];
} HAL_NFCAL_BASE;
typedef struct {
HAL_NFCAL_BASE base;
int16_t nf_cal_buffer[HAL_NF_CAL_HIST_LEN_FULL][HAL_NUM_NF_READINGS];
} HAL_NFCAL_HIST_FULL;
typedef struct {
HAL_NFCAL_BASE base;
int16_t nf_cal_buffer[HAL_NF_CAL_HIST_LEN_SMALL][HAL_NUM_NF_READINGS];
} HAL_NFCAL_HIST_SMALL;
#ifdef ATH_NF_PER_CHAN
typedef HAL_NFCAL_HIST_FULL HAL_CHAN_NFCAL_HIST;
#define AH_HOME_CHAN_NFCAL_HIST(ah, ichan) (ichan ? &ichan->nf_cal_hist: NULL)
#else
typedef HAL_NFCAL_HIST_SMALL HAL_CHAN_NFCAL_HIST;
#define AH_HOME_CHAN_NFCAL_HIST(ah, ichan) (&AH_PRIVATE(ah)->nf_cal_hist)
#endif
typedef struct {
uint16_t channel;
uint8_t privFlags;
#define CHANNEL_IQVALID 0x01
#define CHANNEL_ANI_INIT 0x02
#define CHANNEL_ANI_SETUP 0x04
#define CHANNEL_MIMO_NF_VALID 0x04
uint8_t calValid;
int8_t iCoff;
int8_t qCoff;
int16_t rawNoiseFloor;
int16_t noiseFloorAdjust;
int16_t noiseFloorCtl[AH_MAX_CHAINS];
int16_t noiseFloorExt[AH_MAX_CHAINS];
uint16_t mainSpur;
uint8_t paprd_done:1,
paprd_table_write_done:1;
int one_time_cals_done;
HAL_CHAN_NFCAL_HIST nf_cal_hist;
} HAL_CHANNEL_INTERNAL;
#define CHANNEL_NFCREQUIRED IEEE80211_CHAN_PRIV0
#define IEEE80211_CHAN_ALLFULL \
(IEEE80211_CHAN_ALL - (IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER))
#define IEEE80211_CHAN_ALLTURBOFULL \
(IEEE80211_CHAN_ALLTURBO - \
(IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER))
typedef struct {
uint32_t halChanSpreadSupport : 1,
halSleepAfterBeaconBroken : 1,
halCompressSupport : 1,
halBurstSupport : 1,
halFastFramesSupport : 1,
halChapTuningSupport : 1,
halTurboGSupport : 1,
halTurboPrimeSupport : 1,
halMicAesCcmSupport : 1,
halMicCkipSupport : 1,
halMicTkipSupport : 1,
halTkipMicTxRxKeySupport : 1,
halCipherAesCcmSupport : 1,
halCipherCkipSupport : 1,
halCipherTkipSupport : 1,
halPSPollBroken : 1,
halVEOLSupport : 1,
halBssIdMaskSupport : 1,
halMcastKeySrchSupport : 1,
halTsfAddSupport : 1,
halChanHalfRate : 1,
halChanQuarterRate : 1,
halHTSupport : 1,
halHTSGI20Support : 1,
halRfSilentSupport : 1,
halHwPhyCounterSupport : 1,
halWowSupport : 1,
halWowMatchPatternExact : 1,
halAutoSleepSupport : 1,
halFastCCSupport : 1,
halBtCoexSupport : 1;
uint32_t halRxStbcSupport : 1,
halTxStbcSupport : 1,
halGTTSupport : 1,
halCSTSupport : 1,
halRifsRxSupport : 1,
halRifsTxSupport : 1,
hal4AddrAggrSupport : 1,
halExtChanDfsSupport : 1,
halUseCombinedRadarRssi : 1,
halForcePpmSupport : 1,
halEnhancedPmSupport : 1,
halEnhancedDfsSupport : 1,
halMbssidAggrSupport : 1,
halBssidMatchSupport : 1,
hal4kbSplitTransSupport : 1,
halHasRxSelfLinkedTail : 1,
halSupportsFastClock5GHz : 1,
halHasBBReadWar : 1,
halSerialiseRegWar : 1,
halMciSupport : 1,
halRxTxAbortSupport : 1,
halPaprdEnabled : 1,
halHasUapsdSupport : 1,
halWpsPushButtonSupport : 1,
halBtCoexApsmWar : 1,
halGenTimerSupport : 1,
halLDPCSupport : 1,
halHwBeaconProcSupport : 1,
halEnhancedDmaSupport : 1;
uint32_t halIsrRacSupport : 1,
halApmEnable : 1,
halIntrMitigation : 1,
hal49GhzSupport : 1,
halAntDivCombSupport : 1,
halAntDivCombSupportOrg : 1,
halRadioRetentionSupport : 1,
halSpectralScanSupport : 1,
halRxUsingLnaMixing : 1,
halRxDoMyBeacon : 1,
halHwUapsdTrig : 1;
uint32_t halWirelessModes;
uint16_t halTotalQueues;
uint16_t halKeyCacheSize;
uint16_t halLow5GhzChan, halHigh5GhzChan;
uint16_t halLow2GhzChan, halHigh2GhzChan;
int halTxTstampPrecision;
int halRxTstampPrecision;
int halRtsAggrLimit;
uint8_t halTxChainMask;
uint8_t halRxChainMask;
uint8_t halNumGpioPins;
uint8_t halNumAntCfg2GHz;
uint8_t halNumAntCfg5GHz;
uint32_t halIntrMask;
uint8_t halTxStreams;
uint8_t halRxStreams;
HAL_MFP_OPT_T halMfpSupport;
int hal_paprd_enabled;
int hal_pcie_lcr_offset;
int hal_pcie_lcr_extsync_en;
int halNumTxMaps;
int halTxDescLen;
int halTxStatusLen;
int halRxStatusLen;
int halRxHpFifoDepth;
int halRxLpFifoDepth;
uint32_t halRegCap;
int halNumMRRetries;
int hal_ani_poll_interval;
int hal_channel_switch_time_usec;
} HAL_CAPABILITIES;
struct regDomain;
#define AH_USE_EEPROM 0x1
#define AH_IS_HB63 0x2
struct ath_hal_private {
struct ath_hal h;
HAL_BOOL (*ah_getChannelEdges)(struct ath_hal*,
uint16_t channelFlags,
uint16_t *lowChannel, uint16_t *highChannel);
u_int (*ah_getWirelessModes)(struct ath_hal*);
HAL_BOOL (*ah_eepromRead)(struct ath_hal *, u_int off,
uint16_t *data);
HAL_BOOL (*ah_eepromWrite)(struct ath_hal *, u_int off,
uint16_t data);
HAL_BOOL (*ah_getChipPowerLimits)(struct ath_hal *,
struct ieee80211_channel *);
int16_t (*ah_getNfAdjust)(struct ath_hal *,
const HAL_CHANNEL_INTERNAL*);
void (*ah_getNoiseFloor)(struct ath_hal *,
int16_t nfarray[]);
void *ah_eeprom;
uint16_t ah_eeversion;
void (*ah_eepromDetach)(struct ath_hal *);
HAL_STATUS (*ah_eepromGet)(struct ath_hal *, int, void *);
HAL_STATUS (*ah_eepromSet)(struct ath_hal *, int, int);
uint16_t (*ah_getSpurChan)(struct ath_hal *, int, HAL_BOOL);
HAL_BOOL (*ah_eepromDiag)(struct ath_hal *, int request,
const void *args, uint32_t argsize,
void **result, uint32_t *resultsize);
uint16_t ah_devid;
uint16_t ah_subvendorid;
uint32_t ah_macVersion;
uint16_t ah_macRev;
uint16_t ah_phyRev;
uint16_t ah_analog5GhzRev;
uint16_t ah_analog2GhzRev;
uint32_t ah_flags;
uint8_t ah_ispcie;
uint8_t ah_devType;
HAL_OPMODE ah_opmode;
const struct ieee80211_channel *ah_curchan;
HAL_CAPABILITIES ah_caps;
uint32_t ah_diagreg;
int16_t ah_powerLimit;
uint16_t ah_maxPowerLevel;
u_int ah_tpScale;
u_int16_t ah_extraTxPow;
uint32_t ah_11nCompat;
HAL_REG_DOMAIN ah_currentRD;
HAL_REG_DOMAIN ah_currentRDext;
HAL_DFS_DOMAIN ah_dfsDomain;
HAL_CHANNEL_INTERNAL ah_channels[AH_MAXCHAN];
u_int ah_nchan;
const struct regDomain *ah_rd2GHz;
const struct regDomain *ah_rd5GHz;
uint8_t ah_coverageClass;
uint16_t ah_rfsilent;
HAL_BOOL ah_rfkillEnabled;
uint32_t ah_fatalState[6];
int ah_rxornIsFatal;
HAL_NFCAL_HIST_FULL nf_cal_hist;
HAL_CHANNEL_SURVEY ah_chansurvey;
};
#define AH_PRIVATE(_ah) ((struct ath_hal_private *)(_ah))
#define ath_hal_getChannelEdges(_ah, _cf, _lc, _hc) \
AH_PRIVATE(_ah)->ah_getChannelEdges(_ah, _cf, _lc, _hc)
#define ath_hal_getWirelessModes(_ah) \
AH_PRIVATE(_ah)->ah_getWirelessModes(_ah)
#define ath_hal_eepromRead(_ah, _off, _data) \
AH_PRIVATE(_ah)->ah_eepromRead(_ah, _off, _data)
#define ath_hal_eepromWrite(_ah, _off, _data) \
AH_PRIVATE(_ah)->ah_eepromWrite(_ah, _off, _data)
#define ath_hal_gpioCfgOutput(_ah, _gpio, _type) \
(_ah)->ah_gpioCfgOutput(_ah, _gpio, _type)
#define ath_hal_gpioCfgInput(_ah, _gpio) \
(_ah)->ah_gpioCfgInput(_ah, _gpio)
#define ath_hal_gpioGet(_ah, _gpio) \
(_ah)->ah_gpioGet(_ah, _gpio)
#define ath_hal_gpioSet(_ah, _gpio, _val) \
(_ah)->ah_gpioSet(_ah, _gpio, _val)
#define ath_hal_gpioSetIntr(_ah, _gpio, _ilevel) \
(_ah)->ah_gpioSetIntr(_ah, _gpio, _ilevel)
#define ath_hal_getpowerlimits(_ah, _chan) \
AH_PRIVATE(_ah)->ah_getChipPowerLimits(_ah, _chan)
#define ath_hal_getNfAdjust(_ah, _c) \
AH_PRIVATE(_ah)->ah_getNfAdjust(_ah, _c)
#define ath_hal_getNoiseFloor(_ah, _nfArray) \
AH_PRIVATE(_ah)->ah_getNoiseFloor(_ah, _nfArray)
#define ath_hal_configPCIE(_ah, _reset, _poweroff) \
(_ah)->ah_configPCIE(_ah, _reset, _poweroff)
#define ath_hal_disablePCIE(_ah) \
(_ah)->ah_disablePCIE(_ah)
#define ath_hal_setInterrupts(_ah, _mask) \
(_ah)->ah_setInterrupts(_ah, _mask)
#define ath_hal_isrfkillenabled(_ah) \
(ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 1, AH_NULL) == HAL_OK)
#define ath_hal_enable_rfkill(_ah, _v) \
ath_hal_setcapability(_ah, HAL_CAP_RFSILENT, 1, _v, AH_NULL)
#define ath_hal_hasrfkill_int(_ah) \
(ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 3, AH_NULL) == HAL_OK)
#define ath_hal_eepromDetach(_ah) do { \
if (AH_PRIVATE(_ah)->ah_eepromDetach != AH_NULL) \
AH_PRIVATE(_ah)->ah_eepromDetach(_ah); \
} while (0)
#define ath_hal_eepromGet(_ah, _param, _val) \
AH_PRIVATE(_ah)->ah_eepromGet(_ah, _param, _val)
#define ath_hal_eepromSet(_ah, _param, _val) \
AH_PRIVATE(_ah)->ah_eepromSet(_ah, _param, _val)
#define ath_hal_eepromGetFlag(_ah, _param) \
(AH_PRIVATE(_ah)->ah_eepromGet(_ah, _param, AH_NULL) == HAL_OK)
#define ath_hal_getSpurChan(_ah, _ix, _is2G) \
AH_PRIVATE(_ah)->ah_getSpurChan(_ah, _ix, _is2G)
#define ath_hal_eepromDiag(_ah, _request, _a, _asize, _r, _rsize) \
AH_PRIVATE(_ah)->ah_eepromDiag(_ah, _request, _a, _asize, _r, _rsize)
#ifndef _NET_IF_IEEE80211_H_
#define IEEE80211_ADDR_LEN 6
#define IEEE80211_WEP_IVLEN 3
#define IEEE80211_WEP_KIDLEN 1
#define IEEE80211_WEP_CRCLEN 4
#define IEEE80211_CRC_LEN 4
#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \
(IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
#endif
#define HAL_TXQ_USE_LOCKOUT_BKOFF_DIS 0x00000001
#define INIT_AIFS 2
#define INIT_CWMIN 15
#define INIT_CWMIN_11B 31
#define INIT_CWMAX 1023
#define INIT_SH_RETRY 10
#define INIT_LG_RETRY 10
#define INIT_SSH_RETRY 32
#define INIT_SLG_RETRY 32
typedef struct {
uint32_t tqi_ver;
HAL_TX_QUEUE tqi_type;
HAL_TX_QUEUE_SUBTYPE tqi_subtype;
HAL_TX_QUEUE_FLAGS tqi_qflags;
uint32_t tqi_priority;
uint32_t tqi_aifs;
uint32_t tqi_cwmin;
uint32_t tqi_cwmax;
uint16_t tqi_shretry;
uint16_t tqi_lgretry;
uint32_t tqi_cbrPeriod;
uint32_t tqi_cbrOverflowLimit;
uint32_t tqi_burstTime;
uint32_t tqi_readyTime;
uint32_t tqi_physCompBuf;
uint32_t tqi_intFlags;
} HAL_TX_QUEUE_INFO;
extern HAL_BOOL ath_hal_setTxQProps(struct ath_hal *ah,
HAL_TX_QUEUE_INFO *qi, const HAL_TXQ_INFO *qInfo);
extern HAL_BOOL ath_hal_getTxQProps(struct ath_hal *ah,
HAL_TXQ_INFO *qInfo, const HAL_TX_QUEUE_INFO *qi);
#define HAL_SPUR_VAL_MASK 0x3FFF
#define HAL_SPUR_CHAN_WIDTH 87
#define HAL_BIN_WIDTH_BASE_100HZ 3125
#define HAL_BIN_WIDTH_TURBO_100HZ 6250
#define HAL_MAX_BINS_ALLOWED 28
#define IS_CHAN_5GHZ(_c) ((_c)->channel > 4900)
#define IS_CHAN_2GHZ(_c) (!IS_CHAN_5GHZ(_c))
#define IS_CHAN_IN_PUBLIC_SAFETY_BAND(_c) ((_c) > 4940 && (_c) < 4990)
static __inline__ int
isBigEndian(void)
{
union {
int32_t i;
char c[4];
} u;
u.i = 1;
return (u.c[0] == 0);
}
#define LE_READ_2(p) \
((uint16_t) \
((((const uint8_t *)(p))[0] ) | (((const uint8_t *)(p))[1]<< 8)))
#define LE_READ_4(p) \
((uint32_t) \
((((const uint8_t *)(p))[0] ) | (((const uint8_t *)(p))[1]<< 8) |\
(((const uint8_t *)(p))[2]<<16) | (((const uint8_t *)(p))[3]<<24)))
#define SM(_v, _f) (((_v) << _f##_S) & (_f))
#define MS(_v, _f) (((_v) & (_f)) >> _f##_S)
#define OS_REG_RMW(_a, _r, _set, _clr) \
OS_REG_WRITE(_a, _r, (OS_REG_READ(_a, _r) & ~(_clr)) | (_set))
#define OS_REG_RMW_FIELD(_a, _r, _f, _v) \
OS_REG_WRITE(_a, _r, \
(OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f)))
#define OS_REG_SET_BIT(_a, _r, _f) \
OS_REG_WRITE(_a, _r, OS_REG_READ(_a, _r) | (_f))
#define OS_REG_CLR_BIT(_a, _r, _f) \
OS_REG_WRITE(_a, _r, OS_REG_READ(_a, _r) &~ (_f))
#define OS_REG_IS_BIT_SET(_a, _r, _f) \
((OS_REG_READ(_a, _r) & (_f)) != 0)
#define OS_REG_RMW_FIELD_ALT(_a, _r, _f, _v) \
OS_REG_WRITE(_a, _r, \
(OS_REG_READ(_a, _r) &~(_f<<_f##_S)) | \
(((_v) << _f##_S) & (_f<<_f##_S)))
#define OS_REG_READ_FIELD(_a, _r, _f) \
(((OS_REG_READ(_a, _r) & _f) >> _f##_S))
#define OS_REG_READ_FIELD_ALT(_a, _r, _f) \
((OS_REG_READ(_a, _r) >> (_f##_S))&(_f))
#define OS_A_REG_RMW_FIELD(_a, _r, _f, _v) \
do { OS_REG_WRITE(_a, _r, (OS_REG_READ(_a, _r) &~ (_f)) | \
(((_v) << _f##_S) & (_f))) ; OS_DELAY(100); } while (0)
#define OS_A_REG_WRITE(_a, _r, _v) \
do { OS_REG_WRITE(_a, _r, _v); OS_DELAY(100); } while (0)
extern HAL_BOOL ath_hal_wait(struct ath_hal *, u_int reg,
uint32_t mask, uint32_t val);
extern HAL_BOOL ath_hal_waitfor(struct ath_hal *, u_int reg,
uint32_t mask, uint32_t val, uint32_t timeout);
extern uint32_t ath_hal_reverseBits(uint32_t val, uint32_t n);
extern void ath_hal_printf(struct ath_hal *, const char*, ...)
__printflike(2,3);
extern void ath_hal_vprintf(struct ath_hal *, const char*, __va_list)
__printflike(2, 0);
extern const char* ath_hal_ether_sprintf(const uint8_t *mac);
extern void *ath_hal_malloc(size_t);
extern void ath_hal_free(void *);
#ifdef AH_DEBUG
#include "ah_debug.h"
extern int ath_hal_debug;
#define HALDEBUG(_ah, __m, ...) \
do { \
if ((__m) == HAL_DEBUG_UNMASKABLE || \
ath_hal_debug & (__m) || \
((_ah) != NULL && \
((struct ath_hal *) (_ah))->ah_config.ah_debug & (__m))) { \
DO_HALDEBUG((_ah), (__m), __VA_ARGS__); \
} \
} while(0);
extern void DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...)
__printflike(3,4);
#else
#define HALDEBUG(_ah, __m, ...)
#endif
#include "ah_decode.h"
#ifdef AH_ASSERT
extern void ath_hal_assert_failed(const char* filename,
int lineno, const char* msg);
#define HALASSERT(_x) do { \
if (!(_x)) { \
ath_hal_assert_failed(__FILE__, __LINE__, #_x); \
} \
} while (0)
#else
#define HALASSERT(_x)
#endif
u_int ath_hal_getantennareduction(struct ath_hal *ah,
const struct ieee80211_channel *chan, u_int twiceGain);
u_int ath_hal_getctl(struct ath_hal *, const struct ieee80211_channel *);
#ifndef AH_DEBUG
static OS_INLINE HAL_CHANNEL_INTERNAL *
ath_hal_checkchannel(struct ath_hal *ah, const struct ieee80211_channel *c)
{
HAL_CHANNEL_INTERNAL *cc;
HALASSERT(c->ic_devdata < AH_PRIVATE(ah)->ah_nchan);
cc = &AH_PRIVATE(ah)->ah_channels[c->ic_devdata];
HALASSERT(c->ic_freq == cc->channel || IEEE80211_IS_CHAN_GSM(c));
return cc;
}
#else
HAL_CHANNEL_INTERNAL *ath_hal_checkchannel(struct ath_hal *,
const struct ieee80211_channel *);
#endif
static OS_INLINE uint16_t
ath_hal_gethwchannel(struct ath_hal *ah, const struct ieee80211_channel *c)
{
return ath_hal_checkchannel(ah, c)->channel;
}
extern HAL_STATUS ath_hal_getcapability(struct ath_hal *ah,
HAL_CAPABILITY_TYPE type, uint32_t capability,
uint32_t *result);
extern HAL_BOOL ath_hal_setcapability(struct ath_hal *ah,
HAL_CAPABILITY_TYPE type, uint32_t capability,
uint32_t setting, HAL_STATUS *status);
#include "ah_diagcodes.h"
typedef struct {
uint32_t hang_reg_offset;
uint32_t hang_val;
uint32_t hang_mask;
uint32_t hang_offset;
} hal_hw_hang_check_t;
typedef struct {
uint32_t dma_dbg_3;
uint32_t dma_dbg_4;
uint32_t dma_dbg_5;
uint32_t dma_dbg_6;
} mac_dbg_regs_t;
typedef enum {
dcu_chain_state = 0x1,
dcu_complete_state = 0x2,
qcu_state = 0x4,
qcu_fsp_ok = 0x8,
qcu_fsp_state = 0x10,
qcu_stitch_state = 0x20,
qcu_fetch_state = 0x40,
qcu_complete_state = 0x80
} hal_mac_hangs_t;
typedef struct {
int states;
uint8_t dcu_chain_state;
uint8_t dcu_complete_state;
uint8_t qcu_state;
uint8_t qcu_fsp_ok;
uint8_t qcu_fsp_state;
uint8_t qcu_stitch_state;
uint8_t qcu_fetch_state;
uint8_t qcu_complete_state;
} hal_mac_hang_check_t;
enum {
HAL_BB_HANG_DFS = 0x0001,
HAL_BB_HANG_RIFS = 0x0002,
HAL_BB_HANG_RX_CLEAR = 0x0004,
HAL_BB_HANG_UNKNOWN = 0x0080,
HAL_MAC_HANG_SIG1 = 0x0100,
HAL_MAC_HANG_SIG2 = 0x0200,
HAL_MAC_HANG_UNKNOWN = 0x8000,
HAL_BB_HANGS = HAL_BB_HANG_DFS
| HAL_BB_HANG_RIFS
| HAL_BB_HANG_RX_CLEAR
| HAL_BB_HANG_UNKNOWN,
HAL_MAC_HANGS = HAL_MAC_HANG_SIG1
| HAL_MAC_HANG_SIG2
| HAL_MAC_HANG_UNKNOWN,
};
typedef enum hal_hw_hangs {
HAL_DFS_BB_HANG_WAR = 0x1,
HAL_RIFS_BB_HANG_WAR = 0x2,
HAL_RX_STUCK_LOW_BB_HANG_WAR = 0x4,
HAL_MAC_HANG_WAR = 0x8,
HAL_PHYRESTART_CLR_WAR = 0x10,
HAL_MAC_HANG_DETECTED = 0x40000000,
HAL_BB_HANG_DETECTED = 0x80000000
} hal_hw_hangs_t;
typedef struct {
uint16_t ah_devid;
uint16_t ah_subvendorid;
uint32_t ah_macVersion;
uint16_t ah_macRev;
uint16_t ah_phyRev;
uint16_t ah_analog5GhzRev;
uint16_t ah_analog2GhzRev;
} HAL_REVS;
typedef struct {
HAL_KEYVAL dk_keyval;
uint16_t dk_keyix;
uint8_t dk_mac[IEEE80211_ADDR_LEN];
int dk_xor;
} HAL_DIAG_KEYVAL;
typedef struct {
uint16_t ee_off;
uint16_t ee_data;
} HAL_DIAG_EEVAL;
typedef struct {
u_int offset;
uint32_t val;
} HAL_DIAG_REGVAL;
#define HAL_DIAG_11N_SERVICES 0x00000003
#define HAL_DIAG_11N_SERVICES_S 0
#define HAL_DIAG_11N_TXSTOMP 0x0000000c
#define HAL_DIAG_11N_TXSTOMP_S 2
typedef struct {
int maxNoiseImmunityLevel;
int totalSizeDesired[5];
int coarseHigh[5];
int coarseLow[5];
int firpwr[5];
int maxSpurImmunityLevel;
int cycPwrThr1[8];
int maxFirstepLevel;
int firstep[3];
uint32_t ofdmTrigHigh;
uint32_t ofdmTrigLow;
int32_t cckTrigHigh;
int32_t cckTrigLow;
int32_t rssiThrLow;
int32_t rssiThrHigh;
int period;
} HAL_ANI_PARAMS;
extern HAL_BOOL ath_hal_getdiagstate(struct ath_hal *ah, int request,
const void *args, uint32_t argsize,
void **result, uint32_t *resultsize);
extern void ath_hal_setupratetable(struct ath_hal *ah, HAL_RATE_TABLE *rt);
int16_t ath_hal_getChanNoise(struct ath_hal *, const struct ieee80211_channel *);
typedef struct {
const uint32_t *data;
int rows, cols;
} HAL_INI_ARRAY;
#define HAL_INI_INIT(_ia, _data, _cols) do { \
(_ia)->data = (const uint32_t *)(_data); \
(_ia)->rows = sizeof(_data) / sizeof((_data)[0]); \
(_ia)->cols = (_cols); \
} while (0)
#define HAL_INI_VAL(_ia, _r, _c) \
((_ia)->data[((_r)*(_ia)->cols) + (_c)])
#define DMA_YIELD(x) do { \
if ((++(x) % 64) == 0) \
OS_DELAY(1); \
} while (0)
#define HAL_INI_WRITE_ARRAY(ah, regArray, col, regWr) do { \
int r; \
for (r = 0; r < N(regArray); r++) { \
OS_REG_WRITE(ah, (regArray)[r][0], (regArray)[r][col]); \
DMA_YIELD(regWr); \
} \
} while (0)
#define HAL_INI_WRITE_BANK(ah, regArray, bankData, regWr) do { \
int r; \
for (r = 0; r < N(regArray); r++) { \
OS_REG_WRITE(ah, (regArray)[r][0], (bankData)[r]); \
DMA_YIELD(regWr); \
} \
} while (0)
extern int ath_hal_ini_write(struct ath_hal *ah, const HAL_INI_ARRAY *ia,
int col, int regWr);
extern void ath_hal_ini_bank_setup(uint32_t data[], const HAL_INI_ARRAY *ia,
int col);
extern int ath_hal_ini_bank_write(struct ath_hal *ah, const HAL_INI_ARRAY *ia,
const uint32_t data[], int regWr);
#define CCK_SIFS_TIME 10
#define CCK_PREAMBLE_BITS 144
#define CCK_PLCP_BITS 48
#define OFDM_SIFS_TIME 16
#define OFDM_PREAMBLE_TIME 20
#define OFDM_PLCP_BITS 22
#define OFDM_SYMBOL_TIME 4
#define OFDM_HALF_SIFS_TIME 32
#define OFDM_HALF_PREAMBLE_TIME 40
#define OFDM_HALF_PLCP_BITS 22
#define OFDM_HALF_SYMBOL_TIME 8
#define OFDM_QUARTER_SIFS_TIME 64
#define OFDM_QUARTER_PREAMBLE_TIME 80
#define OFDM_QUARTER_PLCP_BITS 22
#define OFDM_QUARTER_SYMBOL_TIME 16
#define TURBO_SIFS_TIME 8
#define TURBO_PREAMBLE_TIME 14
#define TURBO_PLCP_BITS 22
#define TURBO_SYMBOL_TIME 4
#define WLAN_CTRL_FRAME_SIZE (2+2+6+4)
extern HAL_BOOL ath_ee_getLowerUpperIndex(uint8_t target, uint8_t *pList,
uint16_t listSize, uint16_t *indexL, uint16_t *indexR);
extern HAL_BOOL ath_ee_FillVpdTable(uint8_t pwrMin, uint8_t pwrMax,
uint8_t *pPwrList, uint8_t *pVpdList, uint16_t numIntercepts,
uint8_t *pRetVpdList);
extern int16_t ath_ee_interpolate(uint16_t target, uint16_t srcLeft,
uint16_t srcRight, int16_t targetLeft, int16_t targetRight);
#define IS_5GHZ_FAST_CLOCK_EN(_ah, _c) \
(IEEE80211_IS_CHAN_5GHZ(_c) && \
AH_PRIVATE((_ah))->ah_caps.halSupportsFastClock5GHz && \
ath_hal_eepromGetFlag((_ah), AR_EEP_FSTCLK_5G))
static inline int
ath_hal_get_twice_max_regpower(struct ath_hal_private *ahp,
const HAL_CHANNEL_INTERNAL *ichan, const struct ieee80211_channel *chan)
{
struct ath_hal *ah = &ahp->h;
if (! chan) {
ath_hal_printf(ah, "%s: called with chan=NULL!\n", __func__);
return (0);
}
return (chan->ic_maxpower);
}
static inline int
ath_hal_getantennaallowed(struct ath_hal *ah,
const struct ieee80211_channel *chan)
{
if (! chan)
return (0);
return (chan->ic_maxantgain);
}
extern int ath_hal_mhz2ieee_2ghz(struct ath_hal *, int freq);
extern void ath_hal_survey_clear(struct ath_hal *ah);
extern void ath_hal_survey_add_sample(struct ath_hal *ah,
HAL_SURVEY_SAMPLE *hs);
extern int ath_hal_add_chip(struct ath_hal_chip *ahc);
extern int ath_hal_remove_chip(struct ath_hal_chip *ahc);
extern int ath_hal_add_rf(struct ath_hal_rf *arf);
extern int ath_hal_remove_rf(struct ath_hal_rf *arf);
#endif