Home | History | Annotate | Line # | Download | only in dist
ah_internal.h revision 1.2
      1  1.1  alc /*
      2  1.1  alc  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
      3  1.1  alc  * Copyright (c) 2002-2008 Atheros Communications, Inc.
      4  1.1  alc  *
      5  1.1  alc  * Permission to use, copy, modify, and/or distribute this software for any
      6  1.1  alc  * purpose with or without fee is hereby granted, provided that the above
      7  1.1  alc  * copyright notice and this permission notice appear in all copies.
      8  1.1  alc  *
      9  1.1  alc  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     10  1.1  alc  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     11  1.1  alc  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     12  1.1  alc  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     13  1.1  alc  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     14  1.1  alc  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     15  1.1  alc  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     16  1.1  alc  *
     17  1.2  alc  * $Id: ah_internal.h,v 1.2 2008/12/11 05:30:29 alc Exp $
     18  1.1  alc  */
     19  1.1  alc #ifndef _ATH_AH_INTERAL_H_
     20  1.1  alc #define _ATH_AH_INTERAL_H_
     21  1.1  alc /*
     22  1.1  alc  * Atheros Device Hardware Access Layer (HAL).
     23  1.1  alc  *
     24  1.1  alc  * Internal definitions.
     25  1.1  alc  */
     26  1.1  alc #define	AH_NULL	0
     27  1.1  alc #define	AH_MIN(a,b)	((a)<(b)?(a):(b))
     28  1.1  alc #define	AH_MAX(a,b)	((a)>(b)?(a):(b))
     29  1.1  alc 
     30  1.1  alc #ifndef NBBY
     31  1.1  alc #define	NBBY	8			/* number of bits/byte */
     32  1.1  alc #endif
     33  1.1  alc 
     34  1.1  alc #ifndef roundup
     35  1.1  alc #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
     36  1.1  alc #endif
     37  1.1  alc #ifndef howmany
     38  1.1  alc #define	howmany(x, y)	(((x)+((y)-1))/(y))
     39  1.1  alc #endif
     40  1.1  alc 
     41  1.1  alc #ifndef offsetof
     42  1.1  alc #define	offsetof(type, field)	((size_t)(&((type *)0)->field))
     43  1.1  alc #endif
     44  1.1  alc 
     45  1.1  alc /*
     46  1.1  alc  * Remove const in a way that keeps the compiler happy.
     47  1.1  alc  * This works for gcc but may require other magic for
     48  1.1  alc  * other compilers (not sure where this should reside).
     49  1.1  alc  * Note that uintptr_t is C99.
     50  1.1  alc  */
     51  1.1  alc #ifndef __DECONST
     52  1.2  alc #define	__DECONST(type, var)	((type)(unsigned long)(const void *)(var))
     53  1.1  alc #endif
     54  1.1  alc 
     55  1.1  alc typedef struct {
     56  1.1  alc 	uint16_t	start;		/* first register */
     57  1.1  alc 	uint16_t	end;		/* ending register or zero */
     58  1.1  alc } HAL_REGRANGE;
     59  1.1  alc 
     60  1.1  alc /*
     61  1.1  alc  * Transmit power scale factor.
     62  1.1  alc  *
     63  1.1  alc  * NB: This is not public because we want to discourage the use of
     64  1.1  alc  *     scaling; folks should use the tx power limit interface.
     65  1.1  alc  */
     66  1.1  alc typedef enum {
     67  1.1  alc 	HAL_TP_SCALE_MAX	= 0,		/* no scaling (default) */
     68  1.1  alc 	HAL_TP_SCALE_50		= 1,		/* 50% of max (-3 dBm) */
     69  1.1  alc 	HAL_TP_SCALE_25		= 2,		/* 25% of max (-6 dBm) */
     70  1.1  alc 	HAL_TP_SCALE_12		= 3,		/* 12% of max (-9 dBm) */
     71  1.1  alc 	HAL_TP_SCALE_MIN	= 4,		/* min, but still on */
     72  1.1  alc } HAL_TP_SCALE;
     73  1.1  alc 
     74  1.1  alc typedef enum {
     75  1.1  alc  	HAL_CAP_RADAR		= 0,		/* Radar capability */
     76  1.1  alc  	HAL_CAP_AR		= 1,		/* AR capability */
     77  1.1  alc } HAL_PHYDIAG_CAPS;
     78  1.1  alc 
     79  1.1  alc /*
     80  1.1  alc  * Each chip or class of chips registers to offer support.
     81  1.1  alc  */
     82  1.1  alc struct ath_hal_chip {
     83  1.1  alc 	const char	*name;
     84  1.1  alc 	const char	*(*probe)(uint16_t vendorid, uint16_t devid);
     85  1.1  alc 	struct ath_hal	*(*attach)(uint16_t devid, HAL_SOFTC,
     86  1.1  alc 			    HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS *error);
     87  1.1  alc };
     88  1.1  alc #ifndef AH_CHIP
     89  1.1  alc #define	AH_CHIP(_name, _probe, _attach)				\
     90  1.1  alc static struct ath_hal_chip name##_chip = {			\
     91  1.1  alc 	.name		= #_name,				\
     92  1.1  alc 	.probe		= _probe,				\
     93  1.1  alc 	.attach		= _attach				\
     94  1.1  alc };								\
     95  1.1  alc OS_DATA_SET(ah_chips, name##_chip)
     96  1.1  alc #endif
     97  1.1  alc 
     98  1.1  alc /*
     99  1.1  alc  * Each RF backend registers to offer support; this is mostly
    100  1.1  alc  * used by multi-chip 5212 solutions.  Single-chip solutions
    101  1.1  alc  * have a fixed idea about which RF to use.
    102  1.1  alc  */
    103  1.1  alc struct ath_hal_rf {
    104  1.1  alc 	const char	*name;
    105  1.1  alc 	HAL_BOOL	(*probe)(struct ath_hal *ah);
    106  1.1  alc 	HAL_BOOL	(*attach)(struct ath_hal *ah, HAL_STATUS *ecode);
    107  1.1  alc };
    108  1.1  alc #ifndef AH_RF
    109  1.1  alc #define	AH_RF(_name, _probe, _attach)				\
    110  1.2  alc static struct ath_hal_rf _name##_rf = {				\
    111  1.2  alc 	.name		= __STRING(_name),			\
    112  1.1  alc 	.probe		= _probe,				\
    113  1.1  alc 	.attach		= _attach				\
    114  1.1  alc };								\
    115  1.2  alc OS_DATA_SET(ah_rfs, _name##_rf)
    116  1.1  alc #endif
    117  1.1  alc 
    118  1.1  alc struct ath_hal_rf *ath_hal_rfprobe(struct ath_hal *ah, HAL_STATUS *ecode);
    119  1.1  alc 
    120  1.1  alc /*
    121  1.1  alc  * Internal form of a HAL_CHANNEL.  Note that the structure
    122  1.1  alc  * must be defined such that you can cast references to a
    123  1.1  alc  * HAL_CHANNEL so don't shuffle the first two members.
    124  1.1  alc  */
    125  1.1  alc typedef struct {
    126  1.1  alc 	uint32_t	channelFlags;
    127  1.1  alc 	uint16_t	channel;	/* NB: must be first for casting */
    128  1.1  alc 	uint8_t		privFlags;
    129  1.1  alc 	int8_t		maxRegTxPower;
    130  1.1  alc 	int8_t		maxTxPower;
    131  1.1  alc 	int8_t		minTxPower;	/* as above... */
    132  1.1  alc 
    133  1.1  alc 	HAL_BOOL	bssSendHere;
    134  1.1  alc 	uint8_t		gainI;
    135  1.1  alc 	HAL_BOOL	iqCalValid;
    136  1.1  alc 	uint8_t		calValid;		/* bitmask of cal types */
    137  1.1  alc 	int8_t		iCoff;
    138  1.1  alc 	int8_t		qCoff;
    139  1.1  alc 	int16_t		rawNoiseFloor;
    140  1.1  alc 	int16_t		noiseFloorAdjust;
    141  1.1  alc 	int8_t		antennaMax;
    142  1.1  alc 	uint32_t	regDmnFlags;		/* Flags for channel use in reg */
    143  1.1  alc 	uint32_t	conformanceTestLimit;	/* conformance test limit from reg domain */
    144  1.1  alc 	uint16_t	mainSpur;		/* cached spur value for this cahnnel */
    145  1.1  alc } HAL_CHANNEL_INTERNAL;
    146  1.1  alc 
    147  1.1  alc typedef struct {
    148  1.1  alc 	uint32_t	halChanSpreadSupport 		: 1,
    149  1.1  alc 			halSleepAfterBeaconBroken	: 1,
    150  1.1  alc 			halCompressSupport		: 1,
    151  1.1  alc 			halBurstSupport			: 1,
    152  1.1  alc 			halFastFramesSupport		: 1,
    153  1.1  alc 			halChapTuningSupport		: 1,
    154  1.1  alc 			halTurboGSupport		: 1,
    155  1.1  alc 			halTurboPrimeSupport		: 1,
    156  1.1  alc 			halMicAesCcmSupport		: 1,
    157  1.1  alc 			halMicCkipSupport		: 1,
    158  1.1  alc 			halMicTkipSupport		: 1,
    159  1.1  alc 			halTkipMicTxRxKeySupport	: 1,
    160  1.1  alc 			halCipherAesCcmSupport		: 1,
    161  1.1  alc 			halCipherCkipSupport		: 1,
    162  1.1  alc 			halCipherTkipSupport		: 1,
    163  1.1  alc 			halPSPollBroken			: 1,
    164  1.1  alc 			halVEOLSupport			: 1,
    165  1.1  alc 			halBssIdMaskSupport		: 1,
    166  1.1  alc 			halMcastKeySrchSupport		: 1,
    167  1.1  alc 			halTsfAddSupport		: 1,
    168  1.1  alc 			halChanHalfRate			: 1,
    169  1.1  alc 			halChanQuarterRate		: 1,
    170  1.1  alc 			halHTSupport			: 1,
    171  1.1  alc 			halRfSilentSupport		: 1,
    172  1.1  alc 			halHwPhyCounterSupport		: 1,
    173  1.1  alc 			halWowSupport			: 1,
    174  1.1  alc 			halWowMatchPatternExact		: 1,
    175  1.1  alc 			halAutoSleepSupport		: 1,
    176  1.1  alc 			halFastCCSupport		: 1,
    177  1.1  alc 			halBtCoexSupport		: 1;
    178  1.1  alc 	uint32_t	halRxStbcSupport		: 1,
    179  1.1  alc 			halTxStbcSupport		: 1,
    180  1.1  alc 			halGTTSupport			: 1,
    181  1.1  alc 			halCSTSupport			: 1,
    182  1.1  alc 			halRifsRxSupport		: 1,
    183  1.1  alc 			halRifsTxSupport		: 1,
    184  1.1  alc 			halExtChanDfsSupport		: 1,
    185  1.1  alc 			halForcePpmSupport		: 1,
    186  1.1  alc 			halEnhancedPmSupport		: 1,
    187  1.1  alc 			halMbssidAggrSupport		: 1;
    188  1.1  alc 	uint32_t	halWirelessModes;
    189  1.1  alc 	uint16_t	halTotalQueues;
    190  1.1  alc 	uint16_t	halKeyCacheSize;
    191  1.1  alc 	uint16_t	halLow5GhzChan, halHigh5GhzChan;
    192  1.1  alc 	uint16_t	halLow2GhzChan, halHigh2GhzChan;
    193  1.1  alc 	int		halTstampPrecision;
    194  1.1  alc 	int		halRtsAggrLimit;
    195  1.1  alc 	uint8_t		halTxChainMask;
    196  1.1  alc 	uint8_t		halRxChainMask;
    197  1.1  alc 	uint8_t		halNumGpioPins;
    198  1.1  alc 	uint8_t		halNumAntCfg2GHz;
    199  1.1  alc 	uint8_t		halNumAntCfg5GHz;
    200  1.1  alc } HAL_CAPABILITIES;
    201  1.1  alc 
    202  1.1  alc /*
    203  1.1  alc  * The ``private area'' follows immediately after the ``public area''
    204  1.1  alc  * in the data structure returned by ath_hal_attach.  Private data are
    205  1.1  alc  * used by device-independent code such as the regulatory domain support.
    206  1.1  alc  * In general, code within the HAL should never depend on data in the
    207  1.1  alc  * public area.  Instead any public data needed internally should be
    208  1.1  alc  * shadowed here.
    209  1.1  alc  *
    210  1.1  alc  * When declaring a device-specific ath_hal data structure this structure
    211  1.1  alc  * is assumed to at the front; e.g.
    212  1.1  alc  *
    213  1.1  alc  *	struct ath_hal_5212 {
    214  1.1  alc  *		struct ath_hal_private	ah_priv;
    215  1.1  alc  *		...
    216  1.1  alc  *	};
    217  1.1  alc  *
    218  1.1  alc  * It might be better to manage the method pointers in this structure
    219  1.1  alc  * using an indirect pointer to a read-only data structure but this would
    220  1.1  alc  * disallow class-style method overriding.
    221  1.1  alc  */
    222  1.1  alc struct ath_hal_private {
    223  1.1  alc 	struct ath_hal	h;			/* public area */
    224  1.1  alc 
    225  1.1  alc 	/* NB: all methods go first to simplify initialization */
    226  1.1  alc 	HAL_BOOL	(*ah_getChannelEdges)(struct ath_hal*,
    227  1.1  alc 				uint16_t channelFlags,
    228  1.1  alc 				uint16_t *lowChannel, uint16_t *highChannel);
    229  1.1  alc 	u_int		(*ah_getWirelessModes)(struct ath_hal*);
    230  1.1  alc 	HAL_BOOL	(*ah_eepromRead)(struct ath_hal *, u_int off,
    231  1.1  alc 				uint16_t *data);
    232  1.1  alc 	HAL_BOOL	(*ah_eepromWrite)(struct ath_hal *, u_int off,
    233  1.1  alc 				uint16_t data);
    234  1.1  alc 	HAL_BOOL	(*ah_gpioCfgOutput)(struct ath_hal *, uint32_t gpio);
    235  1.1  alc 	HAL_BOOL	(*ah_gpioCfgInput)(struct ath_hal *, uint32_t gpio);
    236  1.1  alc 	uint32_t	(*ah_gpioGet)(struct ath_hal *, uint32_t gpio);
    237  1.1  alc 	HAL_BOOL	(*ah_gpioSet)(struct ath_hal *,
    238  1.1  alc 				uint32_t gpio, uint32_t val);
    239  1.1  alc 	void		(*ah_gpioSetIntr)(struct ath_hal*, u_int, uint32_t);
    240  1.1  alc 	HAL_BOOL	(*ah_getChipPowerLimits)(struct ath_hal *,
    241  1.1  alc 				HAL_CHANNEL *, uint32_t);
    242  1.1  alc 	int16_t		(*ah_getNfAdjust)(struct ath_hal *,
    243  1.1  alc 				const HAL_CHANNEL_INTERNAL*);
    244  1.1  alc 	void		(*ah_getNoiseFloor)(struct ath_hal *,
    245  1.1  alc 				int16_t nfarray[]);
    246  1.1  alc 
    247  1.1  alc 	void		*ah_eeprom;		/* opaque EEPROM state */
    248  1.1  alc 	uint16_t	ah_eeversion;		/* EEPROM version */
    249  1.1  alc 	void		(*ah_eepromDetach)(struct ath_hal *);
    250  1.1  alc 	HAL_STATUS	(*ah_eepromGet)(struct ath_hal *, int, void *);
    251  1.1  alc 	HAL_BOOL	(*ah_eepromSet)(struct ath_hal *, int, int);
    252  1.1  alc 	uint16_t	(*ah_getSpurChan)(struct ath_hal *, int, HAL_BOOL);
    253  1.1  alc 	HAL_BOOL	(*ah_eepromDiag)(struct ath_hal *, int request,
    254  1.1  alc 			    const void *args, uint32_t argsize,
    255  1.1  alc 			    void **result, uint32_t *resultsize);
    256  1.1  alc 
    257  1.1  alc 	/*
    258  1.1  alc 	 * Device revision information.
    259  1.1  alc 	 */
    260  1.1  alc 	uint16_t	ah_devid;		/* PCI device ID */
    261  1.1  alc 	uint16_t	ah_subvendorid;		/* PCI subvendor ID */
    262  1.1  alc 	uint32_t	ah_macVersion;		/* MAC version id */
    263  1.1  alc 	uint16_t	ah_macRev;		/* MAC revision */
    264  1.1  alc 	uint16_t	ah_phyRev;		/* PHY revision */
    265  1.1  alc 	uint16_t	ah_analog5GhzRev;	/* 2GHz radio revision */
    266  1.1  alc 	uint16_t	ah_analog2GhzRev;	/* 5GHz radio revision */
    267  1.1  alc 
    268  1.1  alc 
    269  1.1  alc 	HAL_OPMODE	ah_opmode;		/* operating mode from reset */
    270  1.1  alc 	HAL_CAPABILITIES ah_caps;		/* device capabilities */
    271  1.1  alc 	uint32_t	ah_diagreg;		/* user-specified AR_DIAG_SW */
    272  1.1  alc 	int16_t		ah_powerLimit;		/* tx power cap */
    273  1.1  alc 	uint16_t	ah_maxPowerLevel;	/* calculated max tx power */
    274  1.1  alc 	u_int		ah_tpScale;		/* tx power scale factor */
    275  1.1  alc 	uint32_t	ah_11nCompat;		/* 11n compat controls */
    276  1.1  alc 
    277  1.1  alc 	/*
    278  1.1  alc 	 * State for regulatory domain handling.
    279  1.1  alc 	 */
    280  1.1  alc 	HAL_REG_DOMAIN	ah_currentRD;		/* Current regulatory domain */
    281  1.1  alc 	HAL_CTRY_CODE	ah_countryCode;		/* current country code */
    282  1.1  alc 	HAL_CHANNEL_INTERNAL ah_channels[256];	/* calculated channel list */
    283  1.1  alc 	u_int		ah_nchan;		/* valid channels in list */
    284  1.1  alc 	HAL_CHANNEL_INTERNAL *ah_curchan;	/* current channel */
    285  1.1  alc 
    286  1.1  alc 	uint8_t    	ah_coverageClass;   	/* coverage class */
    287  1.1  alc 	HAL_BOOL    	ah_regdomainUpdate;     /* regdomain is updated? */
    288  1.1  alc 	/*
    289  1.1  alc 	 * RF Silent handling; setup according to the EEPROM.
    290  1.1  alc 	 */
    291  1.1  alc 	uint16_t	ah_rfsilent;		/* GPIO pin + polarity */
    292  1.1  alc 	HAL_BOOL	ah_rfkillEnabled;	/* enable/disable RfKill */
    293  1.1  alc 	/*
    294  1.1  alc 	 * Diagnostic support for discriminating HIUERR reports.
    295  1.1  alc 	 */
    296  1.1  alc 	uint32_t	ah_fatalState[6];	/* AR_ISR+shadow regs */
    297  1.1  alc 	int		ah_rxornIsFatal;	/* how to treat HAL_INT_RXORN */
    298  1.1  alc };
    299  1.1  alc 
    300  1.1  alc #define	AH_PRIVATE(_ah)	((struct ath_hal_private *)(_ah))
    301  1.1  alc 
    302  1.1  alc #define	ath_hal_getChannelEdges(_ah, _cf, _lc, _hc) \
    303  1.1  alc 	AH_PRIVATE(_ah)->ah_getChannelEdges(_ah, _cf, _lc, _hc)
    304  1.1  alc #define	ath_hal_getWirelessModes(_ah) \
    305  1.1  alc 	AH_PRIVATE(_ah)->ah_getWirelessModes(_ah)
    306  1.1  alc #define	ath_hal_eepromRead(_ah, _off, _data) \
    307  1.1  alc 	AH_PRIVATE(_ah)->ah_eepromRead(_ah, _off, _data)
    308  1.1  alc #define	ath_hal_eepromWrite(_ah, _off, _data) \
    309  1.1  alc 	AH_PRIVATE(_ah)->ah_eepromWrite(_ah, _off, _data)
    310  1.1  alc #define	ath_hal_gpioCfgOutput(_ah, _gpio) \
    311  1.1  alc 	AH_PRIVATE(_ah)->ah_gpioCfgOutput(_ah, _gpio)
    312  1.1  alc #define	ath_hal_gpioCfgInput(_ah, _gpio) \
    313  1.1  alc 	AH_PRIVATE(_ah)->ah_gpioCfgInput(_ah, _gpio)
    314  1.1  alc #define	ath_hal_gpioGet(_ah, _gpio) \
    315  1.1  alc 	AH_PRIVATE(_ah)->ah_gpioGet(_ah, _gpio)
    316  1.1  alc #define	ath_hal_gpioSet(_ah, _gpio, _val) \
    317  1.1  alc 	AH_PRIVATE(_ah)->ah_gpioGet(_ah, _gpio, _val)
    318  1.1  alc #define	ath_hal_gpioSetIntr(_ah, _gpio, _ilevel) \
    319  1.1  alc 	AH_PRIVATE(_ah)->ah_gpioSetIntr(_ah, _gpio, _ilevel)
    320  1.1  alc #define	ath_hal_getpowerlimits(_ah, _chans, _nchan) \
    321  1.1  alc 	AH_PRIVATE(_ah)->ah_getChipPowerLimits(_ah, _chans, _nchan)
    322  1.1  alc #define ath_hal_getNfAdjust(_ah, _c) \
    323  1.1  alc 	AH_PRIVATE(_ah)->ah_getNfAdjust(_ah, _c)
    324  1.1  alc #define	ath_hal_getNoiseFloor(_ah, _nfArray) \
    325  1.1  alc 	AH_PRIVATE(_ah)->ah_getNoiseFloor(_ah, _nfArray)
    326  1.1  alc 
    327  1.1  alc #define	ath_hal_eepromDetach(_ah) \
    328  1.1  alc 	AH_PRIVATE(_ah)->ah_eepromDetach(_ah)
    329  1.1  alc #define	ath_hal_eepromGet(_ah, _param, _val) \
    330  1.1  alc 	AH_PRIVATE(_ah)->ah_eepromGet(_ah, _param, _val)
    331  1.1  alc #define	ath_hal_eepromSet(_ah, _param, _val) \
    332  1.1  alc 	AH_PRIVATE(_ah)->ah_eepromSet(_ah, _param, _val)
    333  1.1  alc #define	ath_hal_eepromGetFlag(_ah, _param) \
    334  1.1  alc 	(AH_PRIVATE(_ah)->ah_eepromGet(_ah, _param, AH_NULL) == HAL_OK)
    335  1.1  alc #define ath_hal_getSpurChan(_ah, _ix, _is2G) \
    336  1.1  alc 	AH_PRIVATE(_ah)->ah_getSpurChan(_ah, _ix, _is2G)
    337  1.1  alc #define	ath_hal_eepromDiag(_ah, _request, _a, _asize, _r, _rsize) \
    338  1.1  alc 	AH_PRIVATE(_ah)->ah_eepromDiag(_ah, _request, _a, _asize,  _r, _rsize)
    339  1.1  alc 
    340  1.1  alc #if !defined(_NET_IF_IEEE80211_H_) && !defined(_NET80211__IEEE80211_H_)
    341  1.1  alc /*
    342  1.1  alc  * Stuff that would naturally come from _ieee80211.h
    343  1.1  alc  */
    344  1.1  alc #define	IEEE80211_ADDR_LEN		6
    345  1.1  alc 
    346  1.1  alc #define	IEEE80211_WEP_KEYLEN			5	/* 40bit */
    347  1.1  alc #define	IEEE80211_WEP_IVLEN			3	/* 24bit */
    348  1.1  alc #define	IEEE80211_WEP_KIDLEN			1	/* 1 octet */
    349  1.1  alc #define	IEEE80211_WEP_CRCLEN			4	/* CRC-32 */
    350  1.1  alc 
    351  1.1  alc #define	IEEE80211_CRC_LEN			4
    352  1.1  alc 
    353  1.1  alc #define	IEEE80211_MTU				1500
    354  1.1  alc #define	IEEE80211_MAX_LEN			(2300 + IEEE80211_CRC_LEN + \
    355  1.1  alc     (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
    356  1.1  alc 
    357  1.1  alc enum {
    358  1.1  alc 	IEEE80211_T_DS,			/* direct sequence spread spectrum */
    359  1.1  alc 	IEEE80211_T_FH,			/* frequency hopping */
    360  1.1  alc 	IEEE80211_T_OFDM,		/* frequency division multiplexing */
    361  1.1  alc 	IEEE80211_T_TURBO,		/* high rate DS */
    362  1.1  alc 	IEEE80211_T_HT,			/* HT - full GI */
    363  1.1  alc };
    364  1.1  alc #define	IEEE80211_T_CCK	IEEE80211_T_DS	/* more common nomenclatur */
    365  1.1  alc #endif /* _NET_IF_IEEE80211_H_ */
    366  1.1  alc 
    367  1.1  alc /* NB: these are defined privately until XR support is announced */
    368  1.1  alc enum {
    369  1.1  alc 	ATHEROS_T_XR	= IEEE80211_T_HT+1,	/* extended range */
    370  1.1  alc };
    371  1.1  alc 
    372  1.1  alc #define HAL_TXQ_USE_LOCKOUT_BKOFF_DIS	0x00000001
    373  1.1  alc 
    374  1.1  alc #define INIT_AIFS		2
    375  1.1  alc #define INIT_CWMIN		15
    376  1.1  alc #define INIT_CWMIN_11B		31
    377  1.1  alc #define INIT_CWMAX		1023
    378  1.1  alc #define INIT_SH_RETRY		10
    379  1.1  alc #define INIT_LG_RETRY		10
    380  1.1  alc #define INIT_SSH_RETRY		32
    381  1.1  alc #define INIT_SLG_RETRY		32
    382  1.1  alc 
    383  1.1  alc typedef struct {
    384  1.1  alc 	uint32_t	tqi_ver;		/* HAL TXQ verson */
    385  1.1  alc 	HAL_TX_QUEUE	tqi_type;		/* hw queue type*/
    386  1.1  alc 	HAL_TX_QUEUE_SUBTYPE tqi_subtype;	/* queue subtype, if applicable */
    387  1.1  alc 	HAL_TX_QUEUE_FLAGS tqi_qflags;		/* queue flags */
    388  1.1  alc 	uint32_t	tqi_priority;
    389  1.1  alc 	uint32_t	tqi_aifs;		/* aifs */
    390  1.1  alc 	uint32_t	tqi_cwmin;		/* cwMin */
    391  1.1  alc 	uint32_t	tqi_cwmax;		/* cwMax */
    392  1.1  alc 	uint16_t	tqi_shretry;		/* frame short retry limit */
    393  1.1  alc 	uint16_t	tqi_lgretry;		/* frame long retry limit */
    394  1.1  alc 	uint32_t	tqi_cbrPeriod;
    395  1.1  alc 	uint32_t	tqi_cbrOverflowLimit;
    396  1.1  alc 	uint32_t	tqi_burstTime;
    397  1.1  alc 	uint32_t	tqi_readyTime;
    398  1.1  alc 	uint32_t	tqi_physCompBuf;
    399  1.1  alc 	uint32_t	tqi_intFlags;		/* flags for internal use */
    400  1.1  alc } HAL_TX_QUEUE_INFO;
    401  1.1  alc 
    402  1.1  alc extern	HAL_BOOL ath_hal_setTxQProps(struct ath_hal *ah,
    403  1.1  alc 		HAL_TX_QUEUE_INFO *qi, const HAL_TXQ_INFO *qInfo);
    404  1.1  alc extern	HAL_BOOL ath_hal_getTxQProps(struct ath_hal *ah,
    405  1.1  alc 		HAL_TXQ_INFO *qInfo, const HAL_TX_QUEUE_INFO *qi);
    406  1.1  alc 
    407  1.1  alc typedef enum {
    408  1.1  alc 	HAL_ANI_PRESENT,			/* is ANI support present */
    409  1.1  alc 	HAL_ANI_NOISE_IMMUNITY_LEVEL,		/* set level */
    410  1.1  alc 	HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION,	/* enable/disable */
    411  1.1  alc 	HAL_ANI_CCK_WEAK_SIGNAL_THR,		/* enable/disable */
    412  1.1  alc 	HAL_ANI_FIRSTEP_LEVEL,			/* set level */
    413  1.1  alc 	HAL_ANI_SPUR_IMMUNITY_LEVEL,		/* set level */
    414  1.1  alc 	HAL_ANI_MODE = 6,	/* 0 => manual, 1 => auto (XXX do not change) */
    415  1.1  alc 	HAL_ANI_PHYERR_RESET,			/* reset phy error stats */
    416  1.1  alc } HAL_ANI_CMD;
    417  1.1  alc 
    418  1.1  alc #define	HAL_SPUR_VAL_MASK		0x3FFF
    419  1.1  alc #define	HAL_SPUR_CHAN_WIDTH		87
    420  1.1  alc #define	HAL_BIN_WIDTH_BASE_100HZ	3125
    421  1.1  alc #define	HAL_BIN_WIDTH_TURBO_100HZ	6250
    422  1.1  alc #define	HAL_MAX_BINS_ALLOWED		28
    423  1.1  alc 
    424  1.1  alc /*
    425  1.1  alc  * A    = 5GHZ|OFDM
    426  1.1  alc  * T    = 5GHZ|OFDM|TURBO
    427  1.1  alc  *
    428  1.1  alc  * IS_CHAN_A(T) will return TRUE.  This is probably
    429  1.1  alc  * not the default behavior we want.  We should migrate to a better mask --
    430  1.1  alc  * perhaps CHANNEL_ALL.
    431  1.1  alc  *
    432  1.1  alc  * For now, IS_CHAN_G() masks itself with CHANNEL_108G.
    433  1.1  alc  *
    434  1.1  alc  */
    435  1.1  alc 
    436  1.1  alc #define	IS_CHAN_A(_c)	(((_c)->channelFlags & CHANNEL_A) == CHANNEL_A)
    437  1.1  alc #define	IS_CHAN_B(_c)	(((_c)->channelFlags & CHANNEL_B) == CHANNEL_B)
    438  1.1  alc #define	IS_CHAN_G(_c)	(((_c)->channelFlags & (CHANNEL_108G|CHANNEL_G)) == CHANNEL_G)
    439  1.1  alc #define	IS_CHAN_108G(_c)(((_c)->channelFlags & CHANNEL_108G) == CHANNEL_108G)
    440  1.1  alc #define	IS_CHAN_T(_c)	(((_c)->channelFlags & CHANNEL_T) == CHANNEL_T)
    441  1.1  alc #define	IS_CHAN_PUREG(_c) \
    442  1.1  alc 	(((_c)->channelFlags & CHANNEL_PUREG) == CHANNEL_PUREG)
    443  1.1  alc 
    444  1.1  alc #define	IS_CHAN_TURBO(_c)	(((_c)->channelFlags & CHANNEL_TURBO) != 0)
    445  1.1  alc #define	IS_CHAN_CCK(_c)		(((_c)->channelFlags & CHANNEL_CCK) != 0)
    446  1.1  alc #define	IS_CHAN_OFDM(_c)	(((_c)->channelFlags & CHANNEL_OFDM) != 0)
    447  1.1  alc #define	IS_CHAN_5GHZ(_c)	(((_c)->channelFlags & CHANNEL_5GHZ) != 0)
    448  1.1  alc #define	IS_CHAN_2GHZ(_c)	(((_c)->channelFlags & CHANNEL_2GHZ) != 0)
    449  1.1  alc #define	IS_CHAN_PASSIVE(_c)	(((_c)->channelFlags & CHANNEL_PASSIVE) != 0)
    450  1.1  alc #define	IS_CHAN_HALF_RATE(_c)	(((_c)->channelFlags & CHANNEL_HALF) != 0)
    451  1.1  alc #define	IS_CHAN_QUARTER_RATE(_c) (((_c)->channelFlags & CHANNEL_QUARTER) != 0)
    452  1.1  alc 
    453  1.1  alc #define	IS_CHAN_IN_PUBLIC_SAFETY_BAND(_c) ((_c) > 4940 && (_c) < 4990)
    454  1.1  alc 
    455  1.1  alc #define	CHANNEL_HT40		(CHANNEL_HT40PLUS | CHANNEL_HT40MINUS)
    456  1.1  alc #define	CHANNEL_HT		(CHANNEL_HT20 | CHANNEL_HT40)
    457  1.1  alc #define	IS_CHAN_HT(_c)		(((_c)->channelFlags & CHANNEL_HT) != 0)
    458  1.1  alc #define	IS_CHAN_HT20(_c)	(((_c)->channelFlags & CHANNEL_HT) == CHANNEL_HT20)
    459  1.1  alc #define	IS_CHAN_HT40(_c)	(((_c)->channelFlags & CHANNEL_HT40) != 0)
    460  1.1  alc 
    461  1.1  alc /*
    462  1.1  alc  * Deduce if the host cpu has big- or litt-endian byte order.
    463  1.1  alc  */
    464  1.1  alc static __inline__ int
    465  1.1  alc isBigEndian(void)
    466  1.1  alc {
    467  1.1  alc 	union {
    468  1.1  alc 		int32_t i;
    469  1.1  alc 		char c[4];
    470  1.1  alc 	} u;
    471  1.1  alc 	u.i = 1;
    472  1.1  alc 	return (u.c[0] == 0);
    473  1.1  alc }
    474  1.1  alc 
    475  1.1  alc /* unalligned little endian access */
    476  1.1  alc #define LE_READ_2(p)							\
    477  1.1  alc 	((uint16_t)							\
    478  1.1  alc 	 ((((const uint8_t *)(p))[0]    ) | (((const uint8_t *)(p))[1]<< 8)))
    479  1.1  alc #define LE_READ_4(p)							\
    480  1.1  alc 	((uint32_t)							\
    481  1.1  alc 	 ((((const uint8_t *)(p))[0]    ) | (((const uint8_t *)(p))[1]<< 8) |\
    482  1.1  alc 	  (((const uint8_t *)(p))[2]<<16) | (((const uint8_t *)(p))[3]<<24)))
    483  1.1  alc 
    484  1.1  alc /*
    485  1.1  alc  * Register manipulation macros that expect bit field defines
    486  1.1  alc  * to follow the convention that an _S suffix is appended for
    487  1.1  alc  * a shift count, while the field mask has no suffix.
    488  1.1  alc  */
    489  1.1  alc #define	SM(_v, _f)	(((_v) << _f##_S) & (_f))
    490  1.1  alc #define	MS(_v, _f)	(((_v) & (_f)) >> _f##_S)
    491  1.1  alc #define	OS_REG_RMW_FIELD(_a, _r, _f, _v) \
    492  1.1  alc 	OS_REG_WRITE(_a, _r, \
    493  1.1  alc 		(OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f)))
    494  1.1  alc #define	OS_REG_SET_BIT(_a, _r, _f) \
    495  1.1  alc 	OS_REG_WRITE(_a, _r, OS_REG_READ(_a, _r) | (_f))
    496  1.1  alc #define	OS_REG_CLR_BIT(_a, _r, _f) \
    497  1.1  alc 	OS_REG_WRITE(_a, _r, OS_REG_READ(_a, _r) &~ (_f))
    498  1.1  alc 
    499  1.1  alc /*
    500  1.1  alc  * Regulatory domain support.
    501  1.1  alc  */
    502  1.1  alc 
    503  1.1  alc /*
    504  1.1  alc  * Return the max allowed antenna gain based on the current
    505  1.1  alc  * regulatory domain.
    506  1.1  alc  */
    507  1.1  alc extern	u_int ath_hal_getantennareduction(struct ath_hal *,
    508  1.1  alc 		HAL_CHANNEL *, u_int twiceGain);
    509  1.1  alc /*
    510  1.1  alc  * Return the test group for the specific channel based on
    511  1.1  alc  * the current regulator domain.
    512  1.1  alc  */
    513  1.1  alc extern	u_int ath_hal_getctl(struct ath_hal *, HAL_CHANNEL *);
    514  1.1  alc /*
    515  1.1  alc  * Return whether or not a noise floor check is required
    516  1.1  alc  * based on the current regulatory domain for the specified
    517  1.1  alc  * channel.
    518  1.1  alc  */
    519  1.1  alc extern	u_int ath_hal_getnfcheckrequired(struct ath_hal *, HAL_CHANNEL *);
    520  1.1  alc 
    521  1.1  alc /*
    522  1.1  alc  * Map a public channel definition to the corresponding
    523  1.1  alc  * internal data structure.  This implicitly specifies
    524  1.1  alc  * whether or not the specified channel is ok to use
    525  1.1  alc  * based on the current regulatory domain constraints.
    526  1.1  alc  */
    527  1.1  alc extern	HAL_CHANNEL_INTERNAL *ath_hal_checkchannel(struct ath_hal *,
    528  1.1  alc 		const HAL_CHANNEL *);
    529  1.1  alc 
    530  1.1  alc /* system-configurable parameters */
    531  1.1  alc extern	int ath_hal_dma_beacon_response_time;	/* in TU's */
    532  1.1  alc extern	int ath_hal_sw_beacon_response_time;	/* in TU's */
    533  1.1  alc extern	int ath_hal_additional_swba_backoff;	/* in TU's */
    534  1.1  alc 
    535  1.1  alc /* wait for the register contents to have the specified value */
    536  1.1  alc extern	HAL_BOOL ath_hal_wait(struct ath_hal *, u_int reg,
    537  1.1  alc 		uint32_t mask, uint32_t val);
    538  1.1  alc 
    539  1.1  alc /* return the first n bits in val reversed */
    540  1.1  alc extern	uint32_t ath_hal_reverseBits(uint32_t val, uint32_t n);
    541  1.1  alc 
    542  1.1  alc /* printf interfaces */
    543  1.1  alc extern	void ath_hal_printf(struct ath_hal *, const char*, ...)
    544  1.1  alc 		__printflike(2,3);
    545  1.2  alc extern	void ath_hal_vprintf(struct ath_hal *, const char*, va_list)
    546  1.1  alc 		__printflike(2, 0);
    547  1.1  alc extern	const char* ath_hal_ether_sprintf(const uint8_t *mac);
    548  1.1  alc 
    549  1.1  alc /* allocate and free memory */
    550  1.1  alc extern	void *ath_hal_malloc(size_t);
    551  1.1  alc extern	void ath_hal_free(void *);
    552  1.1  alc 
    553  1.1  alc /* common debugging interfaces */
    554  1.1  alc #ifdef AH_DEBUG
    555  1.1  alc #include "ah_debug.h"
    556  1.1  alc extern	int ath_hal_debug;
    557  1.1  alc extern	void HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...)
    558  1.1  alc 	__printflike(3,4);
    559  1.1  alc #else
    560  1.1  alc #define HALDEBUG(_ah, __m, _fmt, ...)
    561  1.1  alc #endif /* AH_DEBUG */
    562  1.1  alc 
    563  1.1  alc /*
    564  1.1  alc  * Register logging definitions shared with ardecode.
    565  1.1  alc  */
    566  1.1  alc #include "ah_decode.h"
    567  1.1  alc 
    568  1.1  alc /*
    569  1.1  alc  * Common assertion interface.  Note: it is a bad idea to generate
    570  1.1  alc  * an assertion failure for any recoverable event.  Instead catch
    571  1.1  alc  * the violation and, if possible, fix it up or recover from it; either
    572  1.1  alc  * with an error return value or a diagnostic messages.  System software
    573  1.1  alc  * does not panic unless the situation is hopeless.
    574  1.1  alc  */
    575  1.1  alc #ifdef AH_ASSERT
    576  1.1  alc extern	void ath_hal_assert_failed(const char* filename,
    577  1.1  alc 		int lineno, const char* msg);
    578  1.1  alc 
    579  1.1  alc #define	HALASSERT(_x) do {					\
    580  1.1  alc 	if (!(_x)) {						\
    581  1.1  alc 		ath_hal_assert_failed(__FILE__, __LINE__, #_x);	\
    582  1.1  alc 	}							\
    583  1.1  alc } while (0)
    584  1.1  alc #else
    585  1.1  alc #define	HALASSERT(_x)
    586  1.1  alc #endif /* AH_ASSERT */
    587  1.1  alc 
    588  1.1  alc /*
    589  1.1  alc  * Convert between microseconds and core system clocks.
    590  1.1  alc  */
    591  1.1  alc extern	u_int ath_hal_mac_clks(struct ath_hal *ah, u_int usecs);
    592  1.1  alc extern	u_int ath_hal_mac_usec(struct ath_hal *ah, u_int clks);
    593  1.1  alc 
    594  1.1  alc /*
    595  1.1  alc  * Generic get/set capability support.  Each chip overrides
    596  1.1  alc  * this routine to support chip-specific capabilities.
    597  1.1  alc  */
    598  1.1  alc extern	HAL_STATUS ath_hal_getcapability(struct ath_hal *ah,
    599  1.1  alc 		HAL_CAPABILITY_TYPE type, uint32_t capability,
    600  1.1  alc 		uint32_t *result);
    601  1.1  alc extern	HAL_BOOL ath_hal_setcapability(struct ath_hal *ah,
    602  1.1  alc 		HAL_CAPABILITY_TYPE type, uint32_t capability,
    603  1.1  alc 		uint32_t setting, HAL_STATUS *status);
    604  1.1  alc 
    605  1.1  alc /*
    606  1.1  alc  * Diagnostic interface.  This is an open-ended interface that
    607  1.1  alc  * is opaque to applications.  Diagnostic programs use this to
    608  1.1  alc  * retrieve internal data structures, etc.  There is no guarantee
    609  1.1  alc  * that calling conventions for calls other than HAL_DIAG_REVS
    610  1.1  alc  * are stable between HAL releases; a diagnostic application must
    611  1.1  alc  * use the HAL revision information to deal with ABI/API differences.
    612  1.1  alc  *
    613  1.1  alc  * NB: do not renumber these, certain codes are publicly used.
    614  1.1  alc  */
    615  1.1  alc enum {
    616  1.1  alc 	HAL_DIAG_REVS		= 0,	/* MAC/PHY/Radio revs */
    617  1.1  alc 	HAL_DIAG_EEPROM		= 1,	/* EEPROM contents */
    618  1.1  alc 	HAL_DIAG_EEPROM_EXP_11A	= 2,	/* EEPROM 5112 power exp for 11a */
    619  1.1  alc 	HAL_DIAG_EEPROM_EXP_11B	= 3,	/* EEPROM 5112 power exp for 11b */
    620  1.1  alc 	HAL_DIAG_EEPROM_EXP_11G	= 4,	/* EEPROM 5112 power exp for 11g */
    621  1.1  alc 	HAL_DIAG_ANI_CURRENT	= 5,	/* ANI current channel state */
    622  1.1  alc 	HAL_DIAG_ANI_OFDM	= 6,	/* ANI OFDM timing error stats */
    623  1.1  alc 	HAL_DIAG_ANI_CCK	= 7,	/* ANI CCK timing error stats */
    624  1.1  alc 	HAL_DIAG_ANI_STATS	= 8,	/* ANI statistics */
    625  1.1  alc 	HAL_DIAG_RFGAIN		= 9,	/* RfGain GAIN_VALUES */
    626  1.1  alc 	HAL_DIAG_RFGAIN_CURSTEP	= 10,	/* RfGain GAIN_OPTIMIZATION_STEP */
    627  1.1  alc 	HAL_DIAG_PCDAC		= 11,	/* PCDAC table */
    628  1.1  alc 	HAL_DIAG_TXRATES	= 12,	/* Transmit rate table */
    629  1.1  alc 	HAL_DIAG_REGS		= 13,	/* Registers */
    630  1.1  alc 	HAL_DIAG_ANI_CMD	= 14,	/* ANI issue command (XXX do not change!) */
    631  1.1  alc 	HAL_DIAG_SETKEY		= 15,	/* Set keycache backdoor */
    632  1.1  alc 	HAL_DIAG_RESETKEY	= 16,	/* Reset keycache backdoor */
    633  1.1  alc 	HAL_DIAG_EEREAD		= 17,	/* Read EEPROM word */
    634  1.1  alc 	HAL_DIAG_EEWRITE	= 18,	/* Write EEPROM word */
    635  1.1  alc 	/* 19 was HAL_DIAG_TXCONT, 20-23 were for radar */
    636  1.1  alc 	HAL_DIAG_REGREAD        = 24,   /* Reg reads */
    637  1.1  alc 	HAL_DIAG_REGWRITE       = 25,   /* Reg writes */
    638  1.1  alc 	HAL_DIAG_GET_REGBASE    = 26,   /* Get register base */
    639  1.1  alc 	HAL_DIAG_RDWRITE	= 27,	/* Write regulatory domain */
    640  1.1  alc 	HAL_DIAG_RDREAD		= 28,	/* Get regulatory domain */
    641  1.1  alc 	HAL_DIAG_FATALERR	= 29,	/* Read cached interrupt state */
    642  1.1  alc 	HAL_DIAG_11NCOMPAT	= 30,	/* 11n compatibility tweaks */
    643  1.1  alc 	HAL_DIAG_ANI_PARAMS	= 31,	/* ANI noise immunity parameters */
    644  1.1  alc 	HAL_DIAG_CHECK_HANGS	= 32,	/* check h/w hangs */
    645  1.1  alc };
    646  1.1  alc 
    647  1.1  alc enum {
    648  1.1  alc     HAL_BB_HANG_DFS		= 0x0001,
    649  1.1  alc     HAL_BB_HANG_RIFS		= 0x0002,
    650  1.1  alc     HAL_BB_HANG_RX_CLEAR	= 0x0004,
    651  1.1  alc     HAL_BB_HANG_UNKNOWN		= 0x0080,
    652  1.1  alc 
    653  1.1  alc     HAL_MAC_HANG_SIG1		= 0x0100,
    654  1.1  alc     HAL_MAC_HANG_SIG2		= 0x0200,
    655  1.1  alc     HAL_MAC_HANG_UNKNOWN	= 0x8000,
    656  1.1  alc 
    657  1.1  alc     HAL_BB_HANGS = HAL_BB_HANG_DFS
    658  1.1  alc 		 | HAL_BB_HANG_RIFS
    659  1.1  alc 		 | HAL_BB_HANG_RX_CLEAR
    660  1.1  alc 		 | HAL_BB_HANG_UNKNOWN,
    661  1.1  alc     HAL_MAC_HANGS = HAL_MAC_HANG_SIG1
    662  1.1  alc 		 | HAL_MAC_HANG_SIG2
    663  1.1  alc 		 | HAL_MAC_HANG_UNKNOWN,
    664  1.1  alc };
    665  1.1  alc 
    666  1.1  alc /*
    667  1.1  alc  * Device revision information.
    668  1.1  alc  */
    669  1.1  alc typedef struct {
    670  1.1  alc 	uint16_t	ah_devid;		/* PCI device ID */
    671  1.1  alc 	uint16_t	ah_subvendorid;		/* PCI subvendor ID */
    672  1.1  alc 	uint32_t	ah_macVersion;		/* MAC version id */
    673  1.1  alc 	uint16_t	ah_macRev;		/* MAC revision */
    674  1.1  alc 	uint16_t	ah_phyRev;		/* PHY revision */
    675  1.1  alc 	uint16_t	ah_analog5GhzRev;	/* 2GHz radio revision */
    676  1.1  alc 	uint16_t	ah_analog2GhzRev;	/* 5GHz radio revision */
    677  1.1  alc } HAL_REVS;
    678  1.1  alc 
    679  1.1  alc /*
    680  1.1  alc  * Argument payload for HAL_DIAG_SETKEY.
    681  1.1  alc  */
    682  1.1  alc typedef struct {
    683  1.1  alc 	HAL_KEYVAL	dk_keyval;
    684  1.1  alc 	uint16_t	dk_keyix;	/* key index */
    685  1.1  alc 	uint8_t		dk_mac[IEEE80211_ADDR_LEN];
    686  1.1  alc 	int		dk_xor;		/* XOR key data */
    687  1.1  alc } HAL_DIAG_KEYVAL;
    688  1.1  alc 
    689  1.1  alc /*
    690  1.1  alc  * Argument payload for HAL_DIAG_EEWRITE.
    691  1.1  alc  */
    692  1.1  alc typedef struct {
    693  1.1  alc 	uint16_t	ee_off;		/* eeprom offset */
    694  1.1  alc 	uint16_t	ee_data;	/* write data */
    695  1.1  alc } HAL_DIAG_EEVAL;
    696  1.1  alc 
    697  1.1  alc 
    698  1.1  alc typedef struct {
    699  1.1  alc 	u_int offset;		/* reg offset */
    700  1.1  alc 	uint32_t val;		/* reg value  */
    701  1.1  alc } HAL_DIAG_REGVAL;
    702  1.1  alc 
    703  1.1  alc /*
    704  1.1  alc  * 11n compatibility tweaks.
    705  1.1  alc  */
    706  1.1  alc #define	HAL_DIAG_11N_SERVICES	0x00000003
    707  1.1  alc #define	HAL_DIAG_11N_SERVICES_S	0
    708  1.1  alc #define	HAL_DIAG_11N_TXSTOMP	0x0000000c
    709  1.1  alc #define	HAL_DIAG_11N_TXSTOMP_S	2
    710  1.1  alc 
    711  1.1  alc typedef struct {
    712  1.1  alc 	int		maxNoiseImmunityLevel;	/* [0..4] */
    713  1.1  alc 	int		totalSizeDesired[5];
    714  1.1  alc 	int		coarseHigh[5];
    715  1.1  alc 	int		coarseLow[5];
    716  1.1  alc 	int		firpwr[5];
    717  1.1  alc 
    718  1.1  alc 	int		maxSpurImmunityLevel;	/* [0..7] */
    719  1.1  alc 	int		cycPwrThr1[8];
    720  1.1  alc 
    721  1.1  alc 	int		maxFirstepLevel;	/* [0..2] */
    722  1.1  alc 	int		firstep[3];
    723  1.1  alc 
    724  1.1  alc 	uint32_t	ofdmTrigHigh;
    725  1.1  alc 	uint32_t	ofdmTrigLow;
    726  1.1  alc 	int32_t		cckTrigHigh;
    727  1.1  alc 	int32_t		cckTrigLow;
    728  1.1  alc 	int32_t		rssiThrLow;
    729  1.1  alc 	int32_t		rssiThrHigh;
    730  1.1  alc 
    731  1.1  alc 	int		period;			/* update listen period */
    732  1.1  alc } HAL_ANI_PARAMS;
    733  1.1  alc 
    734  1.1  alc extern	HAL_BOOL ath_hal_getdiagstate(struct ath_hal *ah, int request,
    735  1.1  alc 			const void *args, uint32_t argsize,
    736  1.1  alc 			void **result, uint32_t *resultsize);
    737  1.1  alc 
    738  1.1  alc /*
    739  1.1  alc  * Setup a h/w rate table for use.
    740  1.1  alc  */
    741  1.1  alc extern	void ath_hal_setupratetable(struct ath_hal *ah, HAL_RATE_TABLE *rt);
    742  1.1  alc 
    743  1.1  alc /*
    744  1.1  alc  * Common routine for implementing getChanNoise api.
    745  1.1  alc  */
    746  1.1  alc extern	int16_t ath_hal_getChanNoise(struct ath_hal *ah, HAL_CHANNEL *chan);
    747  1.1  alc 
    748  1.1  alc /*
    749  1.1  alc  * Initialization support.
    750  1.1  alc  */
    751  1.1  alc typedef struct {
    752  1.1  alc 	const uint32_t	*data;
    753  1.1  alc 	int		rows, cols;
    754  1.1  alc } HAL_INI_ARRAY;
    755  1.1  alc 
    756  1.1  alc #define	HAL_INI_INIT(_ia, _data, _cols) do {			\
    757  1.1  alc 	(_ia)->data = (const uint32_t *)(_data);		\
    758  1.1  alc 	(_ia)->rows = sizeof(_data) / sizeof((_data)[0]);	\
    759  1.1  alc 	(_ia)->cols = (_cols);					\
    760  1.1  alc } while (0)
    761  1.1  alc #define	HAL_INI_VAL(_ia, _r, _c) \
    762  1.1  alc 	((_ia)->data[((_r)*(_ia)->cols) + (_c)])
    763  1.1  alc 
    764  1.1  alc /*
    765  1.1  alc  * OS_DELAY() does a PIO READ on the PCI bus which allows
    766  1.1  alc  * other cards' DMA reads to complete in the middle of our reset.
    767  1.1  alc  */
    768  1.1  alc #define DMA_YIELD(x) do {		\
    769  1.1  alc 	if ((++(x) % 64) == 0)		\
    770  1.1  alc 		OS_DELAY(1);		\
    771  1.1  alc } while (0)
    772  1.1  alc 
    773  1.1  alc #define HAL_INI_WRITE_ARRAY(ah, regArray, col, regWr) do {             	\
    774  1.1  alc 	int r;								\
    775  1.1  alc 	for (r = 0; r < N(regArray); r++) {				\
    776  1.1  alc 		OS_REG_WRITE(ah, (regArray)[r][0], (regArray)[r][col]);	\
    777  1.1  alc 		DMA_YIELD(regWr);					\
    778  1.1  alc 	}								\
    779  1.1  alc } while (0)
    780  1.1  alc 
    781  1.1  alc #define HAL_INI_WRITE_BANK(ah, regArray, bankData, regWr) do {		\
    782  1.1  alc 	int r;								\
    783  1.1  alc 	for (r = 0; r < N(regArray); r++) {				\
    784  1.1  alc 		OS_REG_WRITE(ah, (regArray)[r][0], (bankData)[r]);	\
    785  1.1  alc 		DMA_YIELD(regWr);					\
    786  1.1  alc 	}								\
    787  1.1  alc } while (0)
    788  1.1  alc 
    789  1.1  alc extern	int ath_hal_ini_write(struct ath_hal *ah, const HAL_INI_ARRAY *ia,
    790  1.1  alc 		int col, int regWr);
    791  1.1  alc extern	void ath_hal_ini_bank_setup(uint32_t data[], const HAL_INI_ARRAY *ia,
    792  1.1  alc 		int col);
    793  1.1  alc extern	int ath_hal_ini_bank_write(struct ath_hal *ah, const HAL_INI_ARRAY *ia,
    794  1.1  alc 		const uint32_t data[], int regWr);
    795  1.1  alc 
    796  1.1  alc #define	WLAN_CTRL_FRAME_SIZE	(2+2+6+4)	/* ACK+FCS */
    797  1.1  alc #endif /* _ATH_AH_INTERAL_H_ */
    798