2 * Copyright (c) 2008 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #define ATHEROS_VENDOR_ID 0x168c
24 #define AR5416_DEVID_PCI 0x0023
25 #define AR5416_DEVID_PCIE 0x0024
26 #define AR9160_DEVID_PCI 0x0027
27 #define AR9280_DEVID_PCI 0x0029
28 #define AR9280_DEVID_PCIE 0x002a
30 #define AR5416_AR9100_DEVID 0x000b
32 #define AR_SUBVENDOR_ID_NOG 0x0e11
33 #define AR_SUBVENDOR_ID_NEW_A 0x7065
35 #define ATH9K_TXERR_XRETRY 0x01
36 #define ATH9K_TXERR_FILT 0x02
37 #define ATH9K_TXERR_FIFO 0x04
38 #define ATH9K_TXERR_XTXOP 0x08
39 #define ATH9K_TXERR_TIMER_EXPIRED 0x10
41 #define ATH9K_TX_BA 0x01
42 #define ATH9K_TX_PWRMGMT 0x02
43 #define ATH9K_TX_DESC_CFG_ERR 0x04
44 #define ATH9K_TX_DATA_UNDERRUN 0x08
45 #define ATH9K_TX_DELIM_UNDERRUN 0x10
46 #define ATH9K_TX_SW_ABORTED 0x40
47 #define ATH9K_TX_SW_FILTERED 0x80
51 #define howmany(x, y) (((x)+((y)-1))/(y))
54 struct ath_tx_status
{
59 u_int8_t ts_rateindex
;
61 u_int8_t ts_shortretry
;
62 u_int8_t ts_longretry
;
80 struct ath_rx_status
{
98 u_int8_t rs_num_delims
;
105 #define ATH9K_RXERR_CRC 0x01
106 #define ATH9K_RXERR_PHY 0x02
107 #define ATH9K_RXERR_FIFO 0x04
108 #define ATH9K_RXERR_DECRYPT 0x08
109 #define ATH9K_RXERR_MIC 0x10
111 #define ATH9K_RX_MORE 0x01
112 #define ATH9K_RX_MORE_AGGR 0x02
113 #define ATH9K_RX_GI 0x04
114 #define ATH9K_RX_2040 0x08
115 #define ATH9K_RX_DELIM_CRC_PRE 0x10
116 #define ATH9K_RX_DELIM_CRC_POST 0x20
117 #define ATH9K_RX_DECRYPT_BUSY 0x40
119 #define HAL_RXKEYIX_INVALID ((u_int8_t)-1)
120 #define HAL_TXKEYIX_INVALID ((u_int)-1)
129 struct ath_tx_status tx
;
130 struct ath_rx_status rx
;
136 #define ds_txstat ds_us.tx
137 #define ds_rxstat ds_us.rx
138 #define ds_stat ds_us.stats
140 #define HAL_TXDESC_CLRDMASK 0x0001
141 #define HAL_TXDESC_NOACK 0x0002
142 #define HAL_TXDESC_RTSENA 0x0004
143 #define HAL_TXDESC_CTSENA 0x0008
144 #define HAL_TXDESC_INTREQ 0x0010
145 #define HAL_TXDESC_VEOL 0x0020
146 #define HAL_TXDESC_EXT_ONLY 0x0040
147 #define HAL_TXDESC_EXT_AND_CTL 0x0080
148 #define HAL_TXDESC_VMF 0x0100
149 #define HAL_TXDESC_FRAG_IS_ON 0x0200
151 #define HAL_RXDESC_INTREQ 0x0020
153 enum hal_capability_type
{
162 HAL_CAP_MCAST_KEYSRCH
,
166 HAL_CAP_ANT_CFG_2GHZ
,
170 struct hal_capabilities
{
171 u_int halChanSpreadSupport
:1,
172 halChapTuningSupport
:1,
173 halMicAesCcmSupport
:1,
176 halCipherAesCcmSupport
:1,
177 halCipherCkipSupport
:1,
178 halCipherTkipSupport
:1,
180 halBssIdMaskSupport
:1,
181 halMcastKeySrchSupport
:1,
184 halChanQuarterRate
:1,
188 halRfSilentSupport
:1,
191 halEnhancedPmSupport
:1,
192 halAutoSleepSupport
:1,
193 hal4kbSplitTransSupport
:1,
194 halWowMatchPatternExact
:1;
195 u_int32_t halWirelessModes
;
196 u_int16_t halTotalQueues
;
197 u_int16_t halKeyCacheSize
;
198 u_int16_t halLow5GhzChan
, halHigh5GhzChan
;
199 u_int16_t halLow2GhzChan
, halHigh2GhzChan
;
200 u_int16_t halNumMRRetries
;
201 u_int16_t halRtsAggrLimit
;
202 u_int8_t halTxChainMask
;
203 u_int8_t halRxChainMask
;
204 u_int16_t halTxTrigLevelMax
;
206 u_int8_t halNumGpioPins
;
207 u_int8_t halNumAntCfg2GHz
;
208 u_int8_t halNumAntCfg5GHz
;
211 struct hal_ops_config
{
212 int ath_hal_dma_beacon_response_time
;
213 int ath_hal_sw_beacon_response_time
;
214 int ath_hal_additional_swba_backoff
;
216 int ath_hal_cwmIgnoreExtCCA
;
217 u_int8_t ath_hal_pciePowerSaveEnable
;
218 u_int8_t ath_hal_pcieL1SKPEnable
;
219 u_int8_t ath_hal_pcieClockReq
;
220 u_int32_t ath_hal_pcieWaen
;
221 int ath_hal_pciePowerReset
;
222 u_int8_t ath_hal_pcieRestore
;
223 u_int8_t ath_hal_analogShiftReg
;
224 u_int8_t ath_hal_htEnable
;
225 u_int32_t ath_hal_ofdmTrigLow
;
226 u_int32_t ath_hal_ofdmTrigHigh
;
227 u_int32_t ath_hal_cckTrigHigh
;
228 u_int32_t ath_hal_cckTrigLow
;
229 u_int32_t ath_hal_enableANI
;
230 u_int8_t ath_hal_noiseImmunityLvl
;
231 u_int32_t ath_hal_ofdmWeakSigDet
;
232 u_int32_t ath_hal_cckWeakSigThr
;
233 u_int8_t ath_hal_spurImmunityLvl
;
234 u_int8_t ath_hal_firStepLvl
;
235 int8_t ath_hal_rssiThrHigh
;
236 int8_t ath_hal_rssiThrLow
;
237 u_int16_t ath_hal_diversityControl
;
238 u_int16_t ath_hal_antennaSwitchSwap
;
239 int ath_hal_serializeRegMode
;
240 int ath_hal_intrMitigation
;
241 #define SPUR_DISABLE 0
242 #define SPUR_ENABLE_IOCTL 1
243 #define SPUR_ENABLE_EEPROM 2
244 #define AR_EEPROM_MODAL_SPURS 5
245 #define AR_SPUR_5413_1 1640
246 #define AR_SPUR_5413_2 1200
247 #define AR_NO_SPUR 0x8000
248 #define AR_BASE_FREQ_2GHZ 2300
249 #define AR_BASE_FREQ_5GHZ 4900
250 #define AR_SPUR_FEEQ_BOUND_HT40 19
251 #define AR_SPUR_FEEQ_BOUND_HT20 10
252 int ath_hal_spurMode
;
253 u_int16_t ath_hal_spurChans
[AR_EEPROM_MODAL_SPURS
][2];
257 HAL_TX_QUEUE_INACTIVE
= 0,
265 #define HAL_NUM_TX_QUEUES 10
267 enum hal_tx_queue_subtype
{
275 enum hal_tx_queue_flags
{
276 TXQ_FLAG_TXOKINT_ENABLE
= 0x0001,
277 TXQ_FLAG_TXERRINT_ENABLE
= 0x0001,
278 TXQ_FLAG_TXDESCINT_ENABLE
= 0x0002,
279 TXQ_FLAG_TXEOLINT_ENABLE
= 0x0004,
280 TXQ_FLAG_TXURNINT_ENABLE
= 0x0008,
281 TXQ_FLAG_BACKOFF_DISABLE
= 0x0010,
282 TXQ_FLAG_COMPRESSION_ENABLE
= 0x0020,
283 TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE
= 0x0040,
284 TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE
= 0x0080,
287 struct hal_txq_info
{
289 enum hal_tx_queue_subtype tqi_subtype
;
290 enum hal_tx_queue_flags tqi_qflags
;
291 u_int32_t tqi_priority
;
295 u_int16_t tqi_shretry
;
296 u_int16_t tqi_lgretry
;
297 u_int32_t tqi_cbrPeriod
;
298 u_int32_t tqi_cbrOverflowLimit
;
299 u_int32_t tqi_burstTime
;
300 u_int32_t tqi_readyTime
;
301 u_int32_t tqi_compBuf
;
304 #define HAL_TQI_NONVAL 0xffff
306 #define HAL_TXQ_USEDEFAULT ((u_int32_t) -1)
308 #define HAL_COMP_BUF_MAX_SIZE 9216
309 #define HAL_COMP_BUF_ALIGN_SIZE 512
310 #define HAL_DECOMP_MASK_SIZE 128
312 #define HAL_READY_TIME_LO_BOUND 50
313 #define HAL_READY_TIME_HI_BOUND 96
316 HAL_PKT_TYPE_NORMAL
= 0,
320 HAL_PKT_TYPE_PROBE_RESP
,
322 HAL_PKT_TYPE_GRP_POLL
,
325 struct hal_tx_queue_info
{
327 enum hal_tx_queue tqi_type
;
328 enum hal_tx_queue_subtype tqi_subtype
;
329 enum hal_tx_queue_flags tqi_qflags
;
330 u_int32_t tqi_priority
;
334 u_int16_t tqi_shretry
;
335 u_int16_t tqi_lgretry
;
336 u_int32_t tqi_cbrPeriod
;
337 u_int32_t tqi_cbrOverflowLimit
;
338 u_int32_t tqi_burstTime
;
339 u_int32_t tqi_readyTime
;
340 u_int32_t tqi_physCompBuf
;
341 u_int32_t tqi_intFlags
;
345 HAL_RX_FILTER_UCAST
= 0x00000001,
346 HAL_RX_FILTER_MCAST
= 0x00000002,
347 HAL_RX_FILTER_BCAST
= 0x00000004,
348 HAL_RX_FILTER_CONTROL
= 0x00000008,
349 HAL_RX_FILTER_BEACON
= 0x00000010,
350 HAL_RX_FILTER_PROM
= 0x00000020,
351 HAL_RX_FILTER_PROBEREQ
= 0x00000080,
352 HAL_RX_FILTER_PSPOLL
= 0x00004000,
353 HAL_RX_FILTER_PHYERR
= 0x00000100,
354 HAL_RX_FILTER_PHYRADAR
= 0x00002000,
358 HAL_INT_RX
= 0x00000001,
359 HAL_INT_RXDESC
= 0x00000002,
360 HAL_INT_RXNOFRM
= 0x00000008,
361 HAL_INT_RXEOL
= 0x00000010,
362 HAL_INT_RXORN
= 0x00000020,
363 HAL_INT_TX
= 0x00000040,
364 HAL_INT_TXDESC
= 0x00000080,
365 HAL_INT_TIM_TIMER
= 0x00000100,
366 HAL_INT_TXURN
= 0x00000800,
367 HAL_INT_MIB
= 0x00001000,
368 HAL_INT_RXPHY
= 0x00004000,
369 HAL_INT_RXKCM
= 0x00008000,
370 HAL_INT_SWBA
= 0x00010000,
371 HAL_INT_BMISS
= 0x00040000,
372 HAL_INT_BNR
= 0x00100000,
373 HAL_INT_TIM
= 0x00200000,
374 HAL_INT_DTIM
= 0x00400000,
375 HAL_INT_DTIMSYNC
= 0x00800000,
376 HAL_INT_GPIO
= 0x01000000,
377 HAL_INT_CABEND
= 0x02000000,
378 HAL_INT_CST
= 0x10000000,
379 HAL_INT_GTT
= 0x20000000,
380 HAL_INT_FATAL
= 0x40000000,
381 HAL_INT_GLOBAL
= 0x80000000,
382 HAL_INT_BMISC
= HAL_INT_TIM
383 | HAL_INT_DTIM
| HAL_INT_DTIMSYNC
| HAL_INT_CABEND
,
384 HAL_INT_COMMON
= HAL_INT_RXNOFRM
392 | HAL_INT_RXKCM
| HAL_INT_SWBA
| HAL_INT_BMISS
| HAL_INT_GPIO
,
393 HAL_INT_NOCARD
= 0xffffffff
396 struct hal_rate_table
{
398 u_int8_t rateCodeToIndex
[256];
404 u_int8_t shortPreamble
;
406 u_int8_t controlRate
;
407 u_int16_t lpAckDuration
;
408 u_int16_t spAckDuration
;
412 #define HAL_RATESERIES_RTS_CTS 0x0001
413 #define HAL_RATESERIES_2040 0x0002
414 #define HAL_RATESERIES_HALFGI 0x0004
416 struct hal_11n_rate_series
{
426 u_int32_t channelFlags
;
428 int8_t maxRegTxPower
;
433 #define CHANNEL_CW_INT 0x00002
434 #define CHANNEL_CCK 0x00020
435 #define CHANNEL_OFDM 0x00040
436 #define CHANNEL_2GHZ 0x00080
437 #define CHANNEL_5GHZ 0x00100
438 #define CHANNEL_PASSIVE 0x00200
439 #define CHANNEL_DYN 0x00400
440 #define CHANNEL_HALF 0x04000
441 #define CHANNEL_QUARTER 0x08000
442 #define CHANNEL_HT20 0x10000
443 #define CHANNEL_HT40PLUS 0x20000
444 #define CHANNEL_HT40MINUS 0x40000
446 #define CHANNEL_INTERFERENCE 0x01
447 #define CHANNEL_DFS 0x02
448 #define CHANNEL_4MS_LIMIT 0x04
449 #define CHANNEL_DFS_CLEAR 0x08
450 #define CHANNEL_DISALLOW_ADHOC 0x10
451 #define CHANNEL_PER_11D_ADHOC 0x20
453 #define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM)
454 #define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK)
455 #define CHANNEL_PUREG (CHANNEL_2GHZ|CHANNEL_OFDM)
456 #define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM)
457 #define CHANNEL_G_HT20 (CHANNEL_2GHZ|CHANNEL_HT20)
458 #define CHANNEL_A_HT20 (CHANNEL_5GHZ|CHANNEL_HT20)
459 #define CHANNEL_G_HT40PLUS (CHANNEL_2GHZ|CHANNEL_HT40PLUS)
460 #define CHANNEL_G_HT40MINUS (CHANNEL_2GHZ|CHANNEL_HT40MINUS)
461 #define CHANNEL_A_HT40PLUS (CHANNEL_5GHZ|CHANNEL_HT40PLUS)
462 #define CHANNEL_A_HT40MINUS (CHANNEL_5GHZ|CHANNEL_HT40MINUS)
463 #define CHANNEL_ALL \
472 struct hal_channel_internal
{
474 u_int32_t channelFlags
;
476 int8_t maxRegTxPower
;
483 bool oneTimeCalsDone
;
486 int16_t rawNoiseFloor
;
487 int16_t noiseFloorAdjust
;
489 u_int32_t regDmnFlags
;
490 u_int32_t conformanceTestLimit
;
491 u_int64_t ah_tsf_last
;
492 u_int64_t ah_channel_time
;
495 #ifdef ATH_NF_PER_CHAN
496 struct hal_nfcal_hist nfCalHist
[NUM_NF_READINGS
];
500 #define HAL_SPUR_VAL_MASK 0x3FFF
501 #define HAL_SPUR_CHAN_WIDTH 87
502 #define HAL_BIN_WIDTH_BASE_100HZ 3125
503 #define HAL_MAX_BINS_ALLOWED 28
505 #define IS_CHAN_A(_c) ((((_c)->channelFlags & CHANNEL_A) == CHANNEL_A) || \
506 (((_c)->channelFlags & CHANNEL_A_HT20) == CHANNEL_A_HT20) || \
507 (((_c)->channelFlags & CHANNEL_A_HT40PLUS) == CHANNEL_A_HT40PLUS) || \
508 (((_c)->channelFlags & CHANNEL_A_HT40MINUS) == CHANNEL_A_HT40MINUS))
509 #define IS_CHAN_B(_c) (((_c)->channelFlags & CHANNEL_B) == CHANNEL_B)
510 #define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \
511 (((_c)->channelFlags & CHANNEL_G_HT20) == CHANNEL_G_HT20) || \
512 (((_c)->channelFlags & CHANNEL_G_HT40PLUS) == CHANNEL_G_HT40PLUS) || \
513 (((_c)->channelFlags & CHANNEL_G_HT40MINUS) == CHANNEL_G_HT40MINUS))
514 #define IS_CHAN_PUREG(_c) \
515 (((_c)->channelFlags & CHANNEL_PUREG) == CHANNEL_PUREG)
516 #define IS_CHAN_CCK(_c) (((_c)->channelFlags & CHANNEL_CCK) != 0)
517 #define IS_CHAN_OFDM(_c) (((_c)->channelFlags & CHANNEL_OFDM) != 0)
518 #define IS_CHAN_5GHZ(_c) (((_c)->channelFlags & CHANNEL_5GHZ) != 0)
519 #define IS_CHAN_2GHZ(_c) (((_c)->channelFlags & CHANNEL_2GHZ) != 0)
520 #define IS_CHAN_PASSIVE(_c) (((_c)->channelFlags & CHANNEL_PASSIVE) != 0)
521 #define IS_CHAN_HALF_RATE(_c) (((_c)->channelFlags & CHANNEL_HALF) != 0)
522 #define IS_CHAN_QUARTER_RATE(_c) (((_c)->channelFlags & CHANNEL_QUARTER) != 0)
523 #define IS_CHAN_HT20(_c) (((_c)->channelFlags & CHANNEL_HT20) != 0)
524 #define IS_CHAN_HT40(_c) ((((_c)->channelFlags & CHANNEL_HT40PLUS) != 0) \
525 || (((_c)->channelFlags & CHANNEL_HT40MINUS) != 0))
526 #define IS_CHAN_HT(_c) (IS_CHAN_HT20((_c)) || IS_CHAN_HT40((_c)))
527 #define IS_CHAN_IN_PUBLIC_SAFETY_BAND(_c) ((_c) > 4940 && (_c) < 4990)
528 #define IS_CHAN_A_5MHZ_SPACED(_c) \
529 ((((_c)->channelFlags & CHANNEL_5GHZ) != 0) && \
530 (((_c)->channel % 20) != 0) && \
531 (((_c)->channel % 10) != 0))
539 u_int8_t kv_txmic
[8];
551 HAL_CIPHER_AES_OCB
= 1,
552 HAL_CIPHER_AES_CCM
= 2,
559 #define AR_EEPROM_EEPCAP_COMPRESS_DIS 0x0001
560 #define AR_EEPROM_EEPCAP_AES_DIS 0x0002
561 #define AR_EEPROM_EEPCAP_FASTFRAME_DIS 0x0004
562 #define AR_EEPROM_EEPCAP_BURST_DIS 0x0008
563 #define AR_EEPROM_EEPCAP_MAXQCU 0x01F0
564 #define AR_EEPROM_EEPCAP_MAXQCU_S 4
565 #define AR_EEPROM_EEPCAP_HEAVY_CLIP_EN 0x0200
566 #define AR_EEPROM_EEPCAP_KC_ENTRIES 0xF000
567 #define AR_EEPROM_EEPCAP_KC_ENTRIES_S 12
569 #define AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND 0x0040
570 #define AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN 0x0080
571 #define AR_EEPROM_EEREGCAP_EN_KK_U2 0x0100
572 #define AR_EEPROM_EEREGCAP_EN_KK_MIDBAND 0x0200
573 #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD 0x0400
574 #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A 0x0800
576 #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD_PRE4_0 0x4000
577 #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A_PRE4_0 0x8000
579 #define SD_NO_CTL 0xE0
590 #define AR_EEPROM_MAC(i) (0x1d+(i))
591 #define EEP_SCALE 100
594 #define AR_EEPROM_RFSILENT_GPIO_SEL 0x001c
595 #define AR_EEPROM_RFSILENT_GPIO_SEL_S 2
596 #define AR_EEPROM_RFSILENT_POLARITY 0x0002
597 #define AR_EEPROM_RFSILENT_POLARITY_S 1
604 enum reg_ext_bitmap
{
605 REG_EXT_JAPAN_MIDBAND
= 1,
606 REG_EXT_FCC_DFS_HT40
= 2,
607 REG_EXT_JAPAN_NONDFS_HT40
= 3,
608 REG_EXT_JAPAN_DFS_HT40
= 4
611 struct hal_country_entry
{
612 u_int16_t countryCode
;
613 u_int16_t regDmnEnum
;
616 u_int8_t isMultidomain
;
620 #define REG_WRITE(_ah, _reg, _val) iowrite32(_val, _ah->ah_sh + _reg)
621 #define REG_READ(_ah, _reg) ioread32(_ah->ah_sh + _reg)
623 #define SM(_v, _f) (((_v) << _f##_S) & _f)
624 #define MS(_v, _f) (((_v) & _f) >> _f##_S)
625 #define REG_RMW(_a, _r, _set, _clr) \
626 REG_WRITE(_a, _r, (REG_READ(_a, _r) & ~(_clr)) | (_set))
627 #define REG_RMW_FIELD(_a, _r, _f, _v) \
629 (REG_READ(_a, _r) & ~_f) | (((_v) << _f##_S) & _f))
630 #define REG_SET_BIT(_a, _r, _f) \
631 REG_WRITE(_a, _r, REG_READ(_a, _r) | _f)
632 #define REG_CLR_BIT(_a, _r, _f) \
633 REG_WRITE(_a, _r, REG_READ(_a, _r) & ~_f)
635 #define HAL_COMP_BUF_MAX_SIZE 9216
636 #define HAL_COMP_BUF_ALIGN_SIZE 512
638 #define HAL_TXQ_USE_LOCKOUT_BKOFF_DIS 0x00000001
641 #define INIT_CWMIN 15
642 #define INIT_CWMIN_11B 31
643 #define INIT_CWMAX 1023
644 #define INIT_SH_RETRY 10
645 #define INIT_LG_RETRY 10
646 #define INIT_SSH_RETRY 32
647 #define INIT_SLG_RETRY 32
649 #define WLAN_CTRL_FRAME_SIZE (2+2+6+4)
651 #define ATH_AMPDU_LIMIT_MAX (64 * 1024 - 1)
652 #define ATH_AMPDU_LIMIT_DEFAULT ATH_AMPDU_LIMIT_MAX
654 #define IEEE80211_WEP_IVLEN 3
655 #define IEEE80211_WEP_KIDLEN 1
656 #define IEEE80211_WEP_CRCLEN 4
657 #define IEEE80211_MAX_MPDU_LEN (3840 + FCS_LEN + \
658 (IEEE80211_WEP_IVLEN + \
659 IEEE80211_WEP_KIDLEN + \
660 IEEE80211_WEP_CRCLEN))
661 #define IEEE80211_MAX_LEN (2300 + FCS_LEN + \
662 (IEEE80211_WEP_IVLEN + \
663 IEEE80211_WEP_KIDLEN + \
664 IEEE80211_WEP_CRCLEN))
666 #define MAX_REG_ADD_COUNT 129
667 #define MAX_RATE_POWER 63
669 #define LE_READ_2(p) \
671 ((((const u_int8_t *)(p))[0]) | \
672 (((const u_int8_t *)(p))[1] << 8)))
674 #define LE_READ_4(p) \
676 ((((const u_int8_t *)(p))[0]) | \
677 (((const u_int8_t *)(p))[1] << 8) | \
678 (((const u_int8_t *)(p))[2] << 16) | \
679 (((const u_int8_t *)(p))[3] << 24)))
700 enum hal_power_mode
{
703 HAL_PM_NETWORK_SLEEP
,
708 HAL_RFGAIN_INACTIVE
= 0,
709 HAL_RFGAIN_READ_REQUESTED
,
710 HAL_RFGAIN_NEED_CHANGE
713 #define HAL_ANTENNA_MIN_MODE 0
714 #define HAL_ANTENNA_FIXED_A 1
715 #define HAL_ANTENNA_FIXED_B 2
716 #define HAL_ANTENNA_MAX_MODE 3
718 struct hal_mib_stats
{
719 u_int32_t ackrcv_bad
;
726 enum hal_ant_setting
{
727 HAL_ANT_VARIABLE
= 0,
742 HAL_SLOT_TIME_20
= 20,
746 enum hal_ht_macmode
{
747 HAL_HT_MACMODE_20
= 0,
748 HAL_HT_MACMODE_2040
= 1,
751 enum hal_ht_extprotspacing
{
752 HAL_HT_EXTPROTSPACING_20
= 0,
753 HAL_HT_EXTPROTSPACING_25
= 1,
757 enum hal_ht_macmode ht_macmode
;
758 enum hal_ht_extprotspacing ht_extprotspacing
;
762 HAL_FREQ_BAND_5GHZ
= 0,
763 HAL_FREQ_BAND_2GHZ
= 1,
776 HAL_ANI_PRESENT
= 0x1,
777 HAL_ANI_NOISE_IMMUNITY_LEVEL
= 0x2,
778 HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION
= 0x4,
779 HAL_ANI_CCK_WEAK_SIGNAL_THR
= 0x8,
780 HAL_ANI_FIRSTEP_LEVEL
= 0x10,
781 HAL_ANI_SPUR_IMMUNITY_LEVEL
= 0x20,
783 HAL_ANI_PHYERR_RESET
= 0x80,
794 #define PHY_CCK PHY_DS
796 enum start_adhoc_option
{
804 HAL_TP_SCALE_MAX
= 0,
812 SER_REG_MODE_OFF
= 0,
814 SER_REG_MODE_AUTO
= 2,
817 #define AR_PHY_CCA_MAX_GOOD_VALUE -85
818 #define AR_PHY_CCA_MAX_HIGH_VALUE -62
819 #define AR_PHY_CCA_MIN_BAD_VALUE -121
820 #define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT 3
821 #define AR_PHY_CCA_FILTERWINDOW_LENGTH 5
823 #define HAL_NF_CAL_HIST_MAX 5
824 #define NUM_NF_READINGS 6
826 struct hal_nfcal_hist
{
827 int16_t nfCalBuffer
[HAL_NF_CAL_HIST_MAX
];
830 u_int8_t invalidNFcount
;
833 struct hal_beacon_state
{
834 u_int32_t bs_nexttbtt
;
835 u_int32_t bs_nextdtim
;
837 #define HAL_BEACON_PERIOD 0x0000ffff
838 #define HAL_BEACON_ENA 0x00800000
839 #define HAL_BEACON_RESET_TSF 0x01000000
840 u_int32_t bs_dtimperiod
;
841 u_int16_t bs_cfpperiod
;
842 u_int16_t bs_cfpmaxduration
;
843 u_int32_t bs_cfpnext
;
844 u_int16_t bs_timoffset
;
845 u_int16_t bs_bmissthreshold
;
846 u_int32_t bs_sleepduration
;
849 struct hal_node_stats
{
850 u_int32_t ns_avgbrssi
;
851 u_int32_t ns_avgrssi
;
852 u_int32_t ns_avgtxrssi
;
853 u_int32_t ns_avgtxrate
;
856 #define HAL_RSSI_EP_MULTIPLIER (1<<7)
857 #define HAL_RATE_EP_MULTIPLIER (1<<7)
859 enum hal_gpio_output_mux_type
{
860 HAL_GPIO_OUTPUT_MUX_AS_OUTPUT
,
861 HAL_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED
,
862 HAL_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED
,
863 HAL_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED
,
864 HAL_GPIO_OUTPUT_MUX_AS_MAC_POWER_LED
,
865 HAL_GPIO_OUTPUT_MUX_NUM_ENTRIES
874 #define AH_USE_EEPROM 0x1
875 #define AH_IS_HB63 0x2
880 u_int16_t ah_subvendorid
;
881 struct ath_softc
*ah_sc
;
883 u_int16_t ah_countryCode
;
884 u_int32_t ah_macVersion
;
887 u_int16_t ah_analog5GhzRev
;
888 u_int16_t ah_analog2GhzRev
;
889 u_int8_t ah_decompMask
[HAL_DECOMP_MASK_SIZE
];
891 enum hal_opmode ah_opmode
;
892 struct hal_ops_config ah_config
;
893 struct hal_capabilities ah_caps
;
894 int16_t ah_powerLimit
;
895 u_int16_t ah_maxPowerLevel
;
897 u_int16_t ah_currentRD
;
898 u_int16_t ah_currentRDExt
;
899 u_int16_t ah_currentRDInUse
;
900 u_int16_t ah_currentRD5G
;
901 u_int16_t ah_currentRD2G
;
903 enum start_adhoc_option ah_adHocMode
;
905 struct hal_channel_internal ah_channels
[150];
907 struct hal_channel_internal
*ah_curchan
;
908 u_int16_t ah_rfsilent
;
909 bool ah_rfkillEnabled
;
910 bool ah_isPciExpress
;
911 u_int16_t ah_txTrigLevel
;
912 #ifndef ATH_NF_PER_CHAN
913 struct hal_nfcal_hist nfCalHist
[NUM_NF_READINGS
];
918 WIRELESS_MODE_11a
= 0,
919 WIRELESS_MODE_11b
= 2,
920 WIRELESS_MODE_11g
= 3,
921 WIRELESS_MODE_11NA_HT20
= 6,
922 WIRELESS_MODE_11NG_HT20
= 7,
923 WIRELESS_MODE_11NA_HT40PLUS
= 8,
924 WIRELESS_MODE_11NA_HT40MINUS
= 9,
925 WIRELESS_MODE_11NG_HT40PLUS
= 10,
926 WIRELESS_MODE_11NG_HT40MINUS
= 11,
931 ATH9K_MODE_SEL_11A
= 0x00001,
932 ATH9K_MODE_SEL_11B
= 0x00002,
933 ATH9K_MODE_SEL_11G
= 0x00004,
934 ATH9K_MODE_SEL_11NG_HT20
= 0x00008,
935 ATH9K_MODE_SEL_11NA_HT20
= 0x00010,
936 ATH9K_MODE_SEL_11NG_HT40PLUS
= 0x00020,
937 ATH9K_MODE_SEL_11NG_HT40MINUS
= 0x00040,
938 ATH9K_MODE_SEL_11NA_HT40PLUS
= 0x00080,
939 ATH9K_MODE_SEL_11NA_HT40MINUS
= 0x00100,
940 ATH9K_MODE_SEL_2GHZ
= (ATH9K_MODE_SEL_11B
|
942 ATH9K_MODE_SEL_11NG_HT20
),
943 ATH9K_MODE_SEL_5GHZ
= (ATH9K_MODE_SEL_11A
|
944 ATH9K_MODE_SEL_11NA_HT20
),
945 ATH9K_MODE_SEL_ALL
= 0xffffffff
948 struct chan_centers
{
949 u_int16_t synth_center
;
950 u_int16_t ctl_center
;
951 u_int16_t ext_center
;
954 enum hal_status
ath_hal_getcapability(struct ath_hal
*ah
,
955 enum hal_capability_type type
,
956 u_int32_t capability
,
958 const struct hal_rate_table
*ath9k_hw_getratetable(struct ath_hal
*ah
,
960 void ath9k_hw_detach(struct ath_hal
*ah
);
961 struct ath_hal
*ath9k_hw_attach(u_int16_t devid
,
962 struct ath_softc
*sc
,
964 enum hal_status
*error
);
965 bool ath9k_regd_init_channels(struct ath_hal
*ah
,
966 struct hal_channel
*chans
,
967 u_int maxchans
, u_int
*nchans
,
968 u_int8_t
*regclassids
,
969 u_int maxregids
, u_int
*nregids
,
970 u_int16_t cc
, u_int32_t modeSelect
,
972 bool enableExtendedChannels
);
973 u_int
ath9k_hw_mhz2ieee(struct ath_hal
*ah
, u_int freq
, u_int flags
);
974 enum hal_int
ath9k_hw_set_interrupts(struct ath_hal
*ah
,
976 bool ath9k_hw_reset(struct ath_hal
*ah
, enum hal_opmode opmode
,
977 struct hal_channel
*chan
,
978 enum hal_ht_macmode macmode
,
979 u_int8_t txchainmask
, u_int8_t rxchainmask
,
980 enum hal_ht_extprotspacing extprotspacing
,
982 enum hal_status
*status
);
983 bool ath9k_hw_phy_disable(struct ath_hal
*ah
);
984 void ath9k_hw_reset_calvalid(struct ath_hal
*ah
, struct hal_channel
*chan
,
986 void ath9k_hw_ani_monitor(struct ath_hal
*ah
,
987 const struct hal_node_stats
*stats
,
988 struct hal_channel
*chan
);
989 bool ath9k_hw_calibrate(struct ath_hal
*ah
,
990 struct hal_channel
*chan
,
991 u_int8_t rxchainmask
,
994 int16_t ath9k_hw_getchan_noise(struct ath_hal
*ah
,
995 struct hal_channel
*chan
);
996 void ath9k_hw_write_associd(struct ath_hal
*ah
, const u_int8_t
*bssid
,
998 void ath9k_hw_setrxfilter(struct ath_hal
*ah
, u_int32_t bits
);
999 void ath9k_hw_write_associd(struct ath_hal
*ah
, const u_int8_t
*bssid
,
1001 bool ath9k_hw_stoptxdma(struct ath_hal
*ah
, u_int q
);
1002 void ath9k_hw_reset_tsf(struct ath_hal
*ah
);
1003 bool ath9k_hw_keyisvalid(struct ath_hal
*ah
, u_int16_t entry
);
1004 bool ath9k_hw_keysetmac(struct ath_hal
*ah
, u_int16_t entry
,
1005 const u_int8_t
*mac
);
1006 bool ath9k_hw_set_keycache_entry(struct ath_hal
*ah
,
1008 const struct hal_keyval
*k
,
1009 const u_int8_t
*mac
,
1011 bool ath9k_hw_set_tsfadjust(struct ath_hal
*ah
,
1013 void ath9k_hw_configpcipowersave(struct ath_hal
*ah
, int restore
);
1014 bool ath9k_hw_intrpend(struct ath_hal
*ah
);
1015 bool ath9k_hw_getisr(struct ath_hal
*ah
, enum hal_int
*masked
);
1016 bool ath9k_hw_updatetxtriglevel(struct ath_hal
*ah
,
1017 bool bIncTrigLevel
);
1018 void ath9k_hw_procmibevent(struct ath_hal
*ah
,
1019 const struct hal_node_stats
*stats
);
1020 bool ath9k_hw_setrxabort(struct ath_hal
*ah
, bool set
);
1021 void ath9k_hw_set11nmac2040(struct ath_hal
*ah
, enum hal_ht_macmode mode
);
1022 bool ath9k_hw_phycounters(struct ath_hal
*ah
);
1023 bool ath9k_hw_keyreset(struct ath_hal
*ah
, u_int16_t entry
);
1024 bool ath9k_hw_getcapability(struct ath_hal
*ah
,
1025 enum hal_capability_type type
,
1026 u_int32_t capability
,
1028 bool ath9k_hw_setcapability(struct ath_hal
*ah
,
1029 enum hal_capability_type type
,
1030 u_int32_t capability
,
1032 enum hal_status
*status
);
1033 u_int
ath9k_hw_getdefantenna(struct ath_hal
*ah
);
1034 void ath9k_hw_getmac(struct ath_hal
*ah
, u_int8_t
*mac
);
1035 void ath9k_hw_getbssidmask(struct ath_hal
*ah
, u_int8_t
*mask
);
1036 bool ath9k_hw_setbssidmask(struct ath_hal
*ah
,
1037 const u_int8_t
*mask
);
1038 bool ath9k_hw_setpower(struct ath_hal
*ah
,
1039 enum hal_power_mode mode
);
1040 enum hal_int
ath9k_hw_intrget(struct ath_hal
*ah
);
1041 u_int64_t
ath9k_hw_gettsf64(struct ath_hal
*ah
);
1042 u_int
ath9k_hw_getdefantenna(struct ath_hal
*ah
);
1043 bool ath9k_hw_setslottime(struct ath_hal
*ah
, u_int us
);
1044 bool ath9k_hw_setantennaswitch(struct ath_hal
*ah
,
1045 enum hal_ant_setting settings
,
1046 struct hal_channel
*chan
,
1047 u_int8_t
*tx_chainmask
,
1048 u_int8_t
*rx_chainmask
,
1049 u_int8_t
*antenna_cfgd
);
1050 void ath9k_hw_setantenna(struct ath_hal
*ah
, u_int antenna
);
1051 enum hal_status
ath9k_hw_select_antconfig(struct ath_hal
*ah
,
1053 bool ath9k_hw_puttxbuf(struct ath_hal
*ah
, u_int q
,
1055 bool ath9k_hw_txstart(struct ath_hal
*ah
, u_int q
);
1056 u_int16_t
ath9k_hw_computetxtime(struct ath_hal
*ah
,
1057 const struct hal_rate_table
*rates
,
1058 u_int32_t frameLen
, u_int16_t rateix
,
1059 bool shortPreamble
);
1060 void ath9k_hw_set11n_ratescenario(struct ath_hal
*ah
, struct ath_desc
*ds
,
1061 struct ath_desc
*lastds
,
1062 u_int durUpdateEn
, u_int rtsctsRate
,
1063 u_int rtsctsDuration
,
1064 struct hal_11n_rate_series series
[],
1065 u_int nseries
, u_int flags
);
1066 void ath9k_hw_set11n_burstduration(struct ath_hal
*ah
,
1067 struct ath_desc
*ds
,
1068 u_int burstDuration
);
1069 void ath9k_hw_cleartxdesc(struct ath_hal
*ah
, struct ath_desc
*ds
);
1070 u_int32_t
ath9k_hw_reverse_bits(u_int32_t val
, u_int32_t n
);
1071 bool ath9k_hw_resettxqueue(struct ath_hal
*ah
, u_int q
);
1072 u_int
ath9k_regd_get_ctl(struct ath_hal
*ah
, struct hal_channel
*chan
);
1073 u_int
ath9k_regd_get_antenna_allowed(struct ath_hal
*ah
,
1074 struct hal_channel
*chan
);
1075 u_int
ath9k_hw_mhz2ieee(struct ath_hal
*ah
, u_int freq
, u_int flags
);
1076 bool ath9k_hw_gettxqueueprops(struct ath_hal
*ah
, int q
,
1077 struct hal_txq_info
*qInfo
);
1078 bool ath9k_hw_settxqueueprops(struct ath_hal
*ah
, int q
,
1079 const struct hal_txq_info
*qInfo
);
1080 struct hal_channel_internal
*ath9k_regd_check_channel(struct ath_hal
*ah
,
1081 const struct hal_channel
*c
);
1082 void ath9k_hw_set11n_txdesc(struct ath_hal
*ah
, struct ath_desc
*ds
,
1083 u_int pktLen
, enum hal_pkt_type type
,
1084 u_int txPower
, u_int keyIx
,
1085 enum hal_key_type keyType
, u_int flags
);
1086 bool ath9k_hw_filltxdesc(struct ath_hal
*ah
, struct ath_desc
*ds
,
1087 u_int segLen
, bool firstSeg
,
1089 const struct ath_desc
*ds0
);
1090 u_int32_t
ath9k_hw_GetMibCycleCountsPct(struct ath_hal
*ah
,
1091 u_int32_t
*rxc_pcnt
,
1092 u_int32_t
*rxf_pcnt
,
1093 u_int32_t
*txf_pcnt
);
1094 void ath9k_hw_dmaRegDump(struct ath_hal
*ah
);
1095 void ath9k_hw_beaconinit(struct ath_hal
*ah
,
1096 u_int32_t next_beacon
, u_int32_t beacon_period
);
1097 void ath9k_hw_set_sta_beacon_timers(struct ath_hal
*ah
,
1098 const struct hal_beacon_state
*bs
);
1099 bool ath9k_hw_setuprxdesc(struct ath_hal
*ah
, struct ath_desc
*ds
,
1100 u_int32_t size
, u_int flags
);
1101 void ath9k_hw_putrxbuf(struct ath_hal
*ah
, u_int32_t rxdp
);
1102 void ath9k_hw_rxena(struct ath_hal
*ah
);
1103 void ath9k_hw_setopmode(struct ath_hal
*ah
);
1104 bool ath9k_hw_setmac(struct ath_hal
*ah
, const u_int8_t
*mac
);
1105 void ath9k_hw_setmcastfilter(struct ath_hal
*ah
, u_int32_t filter0
,
1107 u_int32_t
ath9k_hw_getrxfilter(struct ath_hal
*ah
);
1108 void ath9k_hw_startpcureceive(struct ath_hal
*ah
);
1109 void ath9k_hw_stoppcurecv(struct ath_hal
*ah
);
1110 bool ath9k_hw_stopdmarecv(struct ath_hal
*ah
);
1111 enum hal_status
ath9k_hw_rxprocdesc(struct ath_hal
*ah
,
1112 struct ath_desc
*ds
, u_int32_t pa
,
1113 struct ath_desc
*nds
, u_int64_t tsf
);
1114 u_int32_t
ath9k_hw_gettxbuf(struct ath_hal
*ah
, u_int q
);
1115 enum hal_status
ath9k_hw_txprocdesc(struct ath_hal
*ah
,
1116 struct ath_desc
*ds
);
1117 void ath9k_hw_set11n_aggr_middle(struct ath_hal
*ah
, struct ath_desc
*ds
,
1119 void ath9k_hw_set11n_aggr_first(struct ath_hal
*ah
, struct ath_desc
*ds
,
1121 void ath9k_hw_set11n_aggr_last(struct ath_hal
*ah
, struct ath_desc
*ds
);
1122 bool ath9k_hw_releasetxqueue(struct ath_hal
*ah
, u_int q
);
1123 void ath9k_hw_gettxintrtxqs(struct ath_hal
*ah
, u_int32_t
*txqs
);
1124 void ath9k_hw_clr11n_aggr(struct ath_hal
*ah
, struct ath_desc
*ds
);
1125 void ath9k_hw_set11n_virtualmorefrag(struct ath_hal
*ah
,
1126 struct ath_desc
*ds
, u_int vmf
);
1127 bool ath9k_hw_set_txpowerlimit(struct ath_hal
*ah
, u_int32_t limit
);
1128 bool ath9k_regd_is_public_safety_sku(struct ath_hal
*ah
);
1129 int ath9k_hw_setuptxqueue(struct ath_hal
*ah
, enum hal_tx_queue type
,
1130 const struct hal_txq_info
*qInfo
);
1131 u_int32_t
ath9k_hw_numtxpending(struct ath_hal
*ah
, u_int q
);
1132 const char *ath9k_hw_probe(u_int16_t vendorid
, u_int16_t devid
);
1133 bool ath9k_hw_disable(struct ath_hal
*ah
);
1134 void ath9k_hw_rfdetach(struct ath_hal
*ah
);
1135 void ath9k_hw_get_channel_centers(struct ath_hal
*ah
,
1136 struct hal_channel_internal
*chan
,
1137 struct chan_centers
*centers
);
1138 bool ath9k_get_channel_edges(struct ath_hal
*ah
,
1139 u_int16_t flags
, u_int16_t
*low
,
1141 bool ath9k_hw_get_chip_power_limits(struct ath_hal
*ah
,
1142 struct hal_channel
*chans
,