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