ah.h revision 237622
1/*
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2008 Atheros Communications, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 *
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ah.h 237622 2012-06-27 03:24:27Z adrian $
18 */
19
20#ifndef _ATH_AH_H_
21#define _ATH_AH_H_
22/*
23 * Atheros Hardware Access Layer
24 *
25 * Clients of the HAL call ath_hal_attach to obtain a reference to an ath_hal
26 * structure for use with the device.  Hardware-related operations that
27 * follow must call back into the HAL through interface, supplying the
28 * reference as the first parameter.
29 */
30
31#include "ah_osdep.h"
32
33/*
34 * The maximum number of TX/RX chains supported.
35 * This is intended to be used by various statistics gathering operations
36 * (NF, RSSI, EVM).
37 */
38#define	AH_MIMO_MAX_CHAINS		3
39#define	AH_MIMO_MAX_EVM_PILOTS		6
40
41/*
42 * __ahdecl is analogous to _cdecl; it defines the calling
43 * convention used within the HAL.  For most systems this
44 * can just default to be empty and the compiler will (should)
45 * use _cdecl.  For systems where _cdecl is not compatible this
46 * must be defined.  See linux/ah_osdep.h for an example.
47 */
48#ifndef __ahdecl
49#define __ahdecl
50#endif
51
52/*
53 * Status codes that may be returned by the HAL.  Note that
54 * interfaces that return a status code set it only when an
55 * error occurs--i.e. you cannot check it for success.
56 */
57typedef enum {
58	HAL_OK		= 0,	/* No error */
59	HAL_ENXIO	= 1,	/* No hardware present */
60	HAL_ENOMEM	= 2,	/* Memory allocation failed */
61	HAL_EIO		= 3,	/* Hardware didn't respond as expected */
62	HAL_EEMAGIC	= 4,	/* EEPROM magic number invalid */
63	HAL_EEVERSION	= 5,	/* EEPROM version invalid */
64	HAL_EELOCKED	= 6,	/* EEPROM unreadable */
65	HAL_EEBADSUM	= 7,	/* EEPROM checksum invalid */
66	HAL_EEREAD	= 8,	/* EEPROM read problem */
67	HAL_EEBADMAC	= 9,	/* EEPROM mac address invalid */
68	HAL_EESIZE	= 10,	/* EEPROM size not supported */
69	HAL_EEWRITE	= 11,	/* Attempt to change write-locked EEPROM */
70	HAL_EINVAL	= 12,	/* Invalid parameter to function */
71	HAL_ENOTSUPP	= 13,	/* Hardware revision not supported */
72	HAL_ESELFTEST	= 14,	/* Hardware self-test failed */
73	HAL_EINPROGRESS	= 15,	/* Operation incomplete */
74	HAL_EEBADREG	= 16,	/* EEPROM invalid regulatory contents */
75	HAL_EEBADCC	= 17,	/* EEPROM invalid country code */
76} HAL_STATUS;
77
78typedef enum {
79	AH_FALSE = 0,		/* NB: lots of code assumes false is zero */
80	AH_TRUE  = 1,
81} HAL_BOOL;
82
83typedef enum {
84	HAL_CAP_REG_DMN		= 0,	/* current regulatory domain */
85	HAL_CAP_CIPHER		= 1,	/* hardware supports cipher */
86	HAL_CAP_TKIP_MIC	= 2,	/* handle TKIP MIC in hardware */
87	HAL_CAP_TKIP_SPLIT	= 3,	/* hardware TKIP uses split keys */
88	HAL_CAP_PHYCOUNTERS	= 4,	/* hardware PHY error counters */
89	HAL_CAP_DIVERSITY	= 5,	/* hardware supports fast diversity */
90	HAL_CAP_KEYCACHE_SIZE	= 6,	/* number of entries in key cache */
91	HAL_CAP_NUM_TXQUEUES	= 7,	/* number of hardware xmit queues */
92	HAL_CAP_VEOL		= 9,	/* hardware supports virtual EOL */
93	HAL_CAP_PSPOLL		= 10,	/* hardware has working PS-Poll support */
94	HAL_CAP_DIAG		= 11,	/* hardware diagnostic support */
95	HAL_CAP_COMPRESSION	= 12,	/* hardware supports compression */
96	HAL_CAP_BURST		= 13,	/* hardware supports packet bursting */
97	HAL_CAP_FASTFRAME	= 14,	/* hardware supoprts fast frames */
98	HAL_CAP_TXPOW		= 15,	/* global tx power limit  */
99	HAL_CAP_TPC		= 16,	/* per-packet tx power control  */
100	HAL_CAP_PHYDIAG		= 17,	/* hardware phy error diagnostic */
101	HAL_CAP_BSSIDMASK	= 18,	/* hardware supports bssid mask */
102	HAL_CAP_MCAST_KEYSRCH	= 19,	/* hardware has multicast key search */
103	HAL_CAP_TSF_ADJUST	= 20,	/* hardware has beacon tsf adjust */
104	/* 21 was HAL_CAP_XR */
105	HAL_CAP_WME_TKIPMIC 	= 22,   /* hardware can support TKIP MIC when WMM is turned on */
106	/* 23 was HAL_CAP_CHAN_HALFRATE */
107	/* 24 was HAL_CAP_CHAN_QUARTERRATE */
108	HAL_CAP_RFSILENT	= 25,	/* hardware has rfsilent support  */
109	HAL_CAP_TPC_ACK		= 26,	/* ack txpower with per-packet tpc */
110	HAL_CAP_TPC_CTS		= 27,	/* cts txpower with per-packet tpc */
111	HAL_CAP_11D		= 28,   /* 11d beacon support for changing cc */
112
113	HAL_CAP_HT		= 30,   /* hardware can support HT */
114	HAL_CAP_GTXTO		= 31,	/* hardware supports global tx timeout */
115	HAL_CAP_FAST_CC		= 32,	/* hardware supports fast channel change */
116	HAL_CAP_TX_CHAINMASK	= 33,	/* mask of TX chains supported */
117	HAL_CAP_RX_CHAINMASK	= 34,	/* mask of RX chains supported */
118	HAL_CAP_NUM_GPIO_PINS	= 36,	/* number of GPIO pins */
119
120	HAL_CAP_CST		= 38,	/* hardware supports carrier sense timeout */
121
122	HAL_CAP_RTS_AGGR_LIMIT	= 42,	/* aggregation limit with RTS */
123	HAL_CAP_4ADDR_AGGR	= 43,	/* hardware is capable of 4addr aggregation */
124	HAL_CAP_DFS_DMN		= 44,	/* current DFS domain */
125	HAL_CAP_EXT_CHAN_DFS	= 45,	/* DFS support for extension channel */
126	HAL_CAP_COMBINED_RADAR_RSSI	= 46,	/* Is combined RSSI for radar accurate */
127
128	HAL_CAP_AUTO_SLEEP	= 48,	/* hardware can go to network sleep
129					   automatically after waking up to receive TIM */
130	HAL_CAP_MBSSID_AGGR_SUPPORT	= 49, /* Support for mBSSID Aggregation */
131	HAL_CAP_SPLIT_4KB_TRANS	= 50,	/* hardware supports descriptors straddling a 4k page boundary */
132	HAL_CAP_REG_FLAG	= 51,	/* Regulatory domain flags */
133
134	HAL_CAP_BT_COEX		= 60,	/* hardware is capable of bluetooth coexistence */
135
136	HAL_CAP_HT20_SGI	= 96,	/* hardware supports HT20 short GI */
137
138	HAL_CAP_RXTSTAMP_PREC	= 100,	/* rx desc tstamp precision (bits) */
139	HAL_CAP_ENHANCED_DFS_SUPPORT	= 117,	/* hardware supports enhanced DFS */
140
141	/* The following are private to the FreeBSD HAL (224 onward) */
142
143	HAL_CAP_INTMIT		= 229,	/* interference mitigation */
144	HAL_CAP_RXORN_FATAL	= 230,	/* HAL_INT_RXORN treated as fatal */
145	HAL_CAP_BB_HANG		= 235,	/* can baseband hang */
146	HAL_CAP_MAC_HANG	= 236,	/* can MAC hang */
147	HAL_CAP_INTRMASK	= 237,	/* bitmask of supported interrupts */
148	HAL_CAP_BSSIDMATCH	= 238,	/* hardware has disable bssid match */
149	HAL_CAP_STREAMS		= 239,	/* how many 802.11n spatial streams are available */
150	HAL_CAP_RXDESC_SELFLINK	= 242,	/* support a self-linked tail RX descriptor */
151	HAL_CAP_LONG_RXDESC_TSF	= 243,	/* hardware supports 32bit TSF in RX descriptor */
152	HAL_CAP_BB_READ_WAR	= 244,	/* baseband read WAR */
153	HAL_CAP_SERIALISE_WAR	= 245,	/* serialise register access on PCI */
154} HAL_CAPABILITY_TYPE;
155
156/*
157 * "States" for setting the LED.  These correspond to
158 * the possible 802.11 operational states and there may
159 * be a many-to-one mapping between these states and the
160 * actual hardware state for the LED's (i.e. the hardware
161 * may have fewer states).
162 */
163typedef enum {
164	HAL_LED_INIT	= 0,
165	HAL_LED_SCAN	= 1,
166	HAL_LED_AUTH	= 2,
167	HAL_LED_ASSOC	= 3,
168	HAL_LED_RUN	= 4
169} HAL_LED_STATE;
170
171/*
172 * Transmit queue types/numbers.  These are used to tag
173 * each transmit queue in the hardware and to identify a set
174 * of transmit queues for operations such as start/stop dma.
175 */
176typedef enum {
177	HAL_TX_QUEUE_INACTIVE	= 0,		/* queue is inactive/unused */
178	HAL_TX_QUEUE_DATA	= 1,		/* data xmit q's */
179	HAL_TX_QUEUE_BEACON	= 2,		/* beacon xmit q */
180	HAL_TX_QUEUE_CAB	= 3,		/* "crap after beacon" xmit q */
181	HAL_TX_QUEUE_UAPSD	= 4,		/* u-apsd power save xmit q */
182	HAL_TX_QUEUE_PSPOLL	= 5,		/* power save poll xmit q */
183} HAL_TX_QUEUE;
184
185#define	HAL_NUM_TX_QUEUES	10		/* max possible # of queues */
186
187/*
188 * Transmit queue subtype.  These map directly to
189 * WME Access Categories (except for UPSD).  Refer
190 * to Table 5 of the WME spec.
191 */
192typedef enum {
193	HAL_WME_AC_BK	= 0,			/* background access category */
194	HAL_WME_AC_BE	= 1, 			/* best effort access category*/
195	HAL_WME_AC_VI	= 2,			/* video access category */
196	HAL_WME_AC_VO	= 3,			/* voice access category */
197	HAL_WME_UPSD	= 4,			/* uplink power save */
198} HAL_TX_QUEUE_SUBTYPE;
199
200/*
201 * Transmit queue flags that control various
202 * operational parameters.
203 */
204typedef enum {
205	/*
206	 * Per queue interrupt enables.  When set the associated
207	 * interrupt may be delivered for packets sent through
208	 * the queue.  Without these enabled no interrupts will
209	 * be delivered for transmits through the queue.
210	 */
211	HAL_TXQ_TXOKINT_ENABLE	   = 0x0001,	/* enable TXOK interrupt */
212	HAL_TXQ_TXERRINT_ENABLE	   = 0x0001,	/* enable TXERR interrupt */
213	HAL_TXQ_TXDESCINT_ENABLE   = 0x0002,	/* enable TXDESC interrupt */
214	HAL_TXQ_TXEOLINT_ENABLE	   = 0x0004,	/* enable TXEOL interrupt */
215	HAL_TXQ_TXURNINT_ENABLE	   = 0x0008,	/* enable TXURN interrupt */
216	/*
217	 * Enable hardware compression for packets sent through
218	 * the queue.  The compression buffer must be setup and
219	 * packets must have a key entry marked in the tx descriptor.
220	 */
221	HAL_TXQ_COMPRESSION_ENABLE  = 0x0010,	/* enable h/w compression */
222	/*
223	 * Disable queue when veol is hit or ready time expires.
224	 * By default the queue is disabled only on reaching the
225	 * physical end of queue (i.e. a null link ptr in the
226	 * descriptor chain).
227	 */
228	HAL_TXQ_RDYTIME_EXP_POLICY_ENABLE = 0x0020,
229	/*
230	 * Schedule frames on delivery of a DBA (DMA Beacon Alert)
231	 * event.  Frames will be transmitted only when this timer
232	 * fires, e.g to transmit a beacon in ap or adhoc modes.
233	 */
234	HAL_TXQ_DBA_GATED	    = 0x0040,	/* schedule based on DBA */
235	/*
236	 * Each transmit queue has a counter that is incremented
237	 * each time the queue is enabled and decremented when
238	 * the list of frames to transmit is traversed (or when
239	 * the ready time for the queue expires).  This counter
240	 * must be non-zero for frames to be scheduled for
241	 * transmission.  The following controls disable bumping
242	 * this counter under certain conditions.  Typically this
243	 * is used to gate frames based on the contents of another
244	 * queue (e.g. CAB traffic may only follow a beacon frame).
245	 * These are meaningful only when frames are scheduled
246	 * with a non-ASAP policy (e.g. DBA-gated).
247	 */
248	HAL_TXQ_CBR_DIS_QEMPTY	    = 0x0080,	/* disable on this q empty */
249	HAL_TXQ_CBR_DIS_BEMPTY	    = 0x0100,	/* disable on beacon q empty */
250
251	/*
252	 * Fragment burst backoff policy.  Normally the no backoff
253	 * is done after a successful transmission, the next fragment
254	 * is sent at SIFS.  If this flag is set backoff is done
255	 * after each fragment, regardless whether it was ack'd or
256	 * not, after the backoff count reaches zero a normal channel
257	 * access procedure is done before the next transmit (i.e.
258	 * wait AIFS instead of SIFS).
259	 */
260	HAL_TXQ_FRAG_BURST_BACKOFF_ENABLE = 0x00800000,
261	/*
262	 * Disable post-tx backoff following each frame.
263	 */
264	HAL_TXQ_BACKOFF_DISABLE	    = 0x00010000, /* disable post backoff  */
265	/*
266	 * DCU arbiter lockout control.  This controls how
267	 * lower priority tx queues are handled with respect to
268	 * to a specific queue when multiple queues have frames
269	 * to send.  No lockout means lower priority queues arbitrate
270	 * concurrently with this queue.  Intra-frame lockout
271	 * means lower priority queues are locked out until the
272	 * current frame transmits (e.g. including backoffs and bursting).
273	 * Global lockout means nothing lower can arbitrary so
274	 * long as there is traffic activity on this queue (frames,
275	 * backoff, etc).
276	 */
277	HAL_TXQ_ARB_LOCKOUT_INTRA   = 0x00020000, /* intra-frame lockout */
278	HAL_TXQ_ARB_LOCKOUT_GLOBAL  = 0x00040000, /* full lockout s */
279
280	HAL_TXQ_IGNORE_VIRTCOL	    = 0x00080000, /* ignore virt collisions */
281	HAL_TXQ_SEQNUM_INC_DIS	    = 0x00100000, /* disable seqnum increment */
282} HAL_TX_QUEUE_FLAGS;
283
284typedef struct {
285	uint32_t	tqi_ver;		/* hal TXQ version */
286	HAL_TX_QUEUE_SUBTYPE tqi_subtype;	/* subtype if applicable */
287	HAL_TX_QUEUE_FLAGS tqi_qflags;		/* flags (see above) */
288	uint32_t	tqi_priority;		/* (not used) */
289	uint32_t	tqi_aifs;		/* aifs */
290	uint32_t	tqi_cwmin;		/* cwMin */
291	uint32_t	tqi_cwmax;		/* cwMax */
292	uint16_t	tqi_shretry;		/* rts retry limit */
293	uint16_t	tqi_lgretry;		/* long retry limit (not used)*/
294	uint32_t	tqi_cbrPeriod;		/* CBR period (us) */
295	uint32_t	tqi_cbrOverflowLimit;	/* threshold for CBROVF int */
296	uint32_t	tqi_burstTime;		/* max burst duration (us) */
297	uint32_t	tqi_readyTime;		/* frame schedule time (us) */
298	uint32_t	tqi_compBuf;		/* comp buffer phys addr */
299} HAL_TXQ_INFO;
300
301#define HAL_TQI_NONVAL 0xffff
302
303/* token to use for aifs, cwmin, cwmax */
304#define	HAL_TXQ_USEDEFAULT	((uint32_t) -1)
305
306/* compression definitions */
307#define HAL_COMP_BUF_MAX_SIZE           9216            /* 9K */
308#define HAL_COMP_BUF_ALIGN_SIZE         512
309
310/*
311 * Transmit packet types.  This belongs in ah_desc.h, but
312 * is here so we can give a proper type to various parameters
313 * (and not require everyone include the file).
314 *
315 * NB: These values are intentionally assigned for
316 *     direct use when setting up h/w descriptors.
317 */
318typedef enum {
319	HAL_PKT_TYPE_NORMAL	= 0,
320	HAL_PKT_TYPE_ATIM	= 1,
321	HAL_PKT_TYPE_PSPOLL	= 2,
322	HAL_PKT_TYPE_BEACON	= 3,
323	HAL_PKT_TYPE_PROBE_RESP	= 4,
324	HAL_PKT_TYPE_CHIRP	= 5,
325	HAL_PKT_TYPE_GRP_POLL	= 6,
326	HAL_PKT_TYPE_AMPDU	= 7,
327} HAL_PKT_TYPE;
328
329/* Rx Filter Frame Types */
330typedef enum {
331	/*
332	 * These bits correspond to AR_RX_FILTER for all chips.
333	 * Not all bits are supported by all chips.
334	 */
335	HAL_RX_FILTER_UCAST	= 0x00000001,	/* Allow unicast frames */
336	HAL_RX_FILTER_MCAST	= 0x00000002,	/* Allow multicast frames */
337	HAL_RX_FILTER_BCAST	= 0x00000004,	/* Allow broadcast frames */
338	HAL_RX_FILTER_CONTROL	= 0x00000008,	/* Allow control frames */
339	HAL_RX_FILTER_BEACON	= 0x00000010,	/* Allow beacon frames */
340	HAL_RX_FILTER_PROM	= 0x00000020,	/* Promiscuous mode */
341	HAL_RX_FILTER_PROBEREQ	= 0x00000080,	/* Allow probe request frames */
342	HAL_RX_FILTER_PHYERR	= 0x00000100,	/* Allow phy errors */
343	HAL_RX_FILTER_COMPBAR	= 0x00000400,	/* Allow compressed BAR */
344	HAL_RX_FILTER_COMP_BA	= 0x00000800,	/* Allow compressed blockack */
345	HAL_RX_FILTER_PHYRADAR	= 0x00002000,	/* Allow phy radar errors */
346	HAL_RX_FILTER_PSPOLL	= 0x00004000,	/* Allow PS-POLL frames */
347	HAL_RX_FILTER_MCAST_BCAST_ALL	= 0x00008000,
348						/* Allow all mcast/bcast frames */
349
350	/*
351	 * Magic RX filter flags that aren't targetting hardware bits
352	 * but instead the HAL sets individual bits - eg PHYERR will result
353	 * in OFDM/CCK timing error frames being received.
354	 */
355	HAL_RX_FILTER_BSSID	= 0x40000000,	/* Disable BSSID match */
356} HAL_RX_FILTER;
357
358typedef enum {
359	HAL_PM_AWAKE		= 0,
360	HAL_PM_FULL_SLEEP	= 1,
361	HAL_PM_NETWORK_SLEEP	= 2,
362	HAL_PM_UNDEFINED	= 3
363} HAL_POWER_MODE;
364
365/*
366 * NOTE WELL:
367 * These are mapped to take advantage of the common locations for many of
368 * the bits on all of the currently supported MAC chips. This is to make
369 * the ISR as efficient as possible, while still abstracting HW differences.
370 * When new hardware breaks this commonality this enumerated type, as well
371 * as the HAL functions using it, must be modified. All values are directly
372 * mapped unless commented otherwise.
373 */
374typedef enum {
375	HAL_INT_RX	= 0x00000001,	/* Non-common mapping */
376	HAL_INT_RXDESC	= 0x00000002,
377	HAL_INT_RXNOFRM	= 0x00000008,
378	HAL_INT_RXEOL	= 0x00000010,
379	HAL_INT_RXORN	= 0x00000020,
380	HAL_INT_TX	= 0x00000040,	/* Non-common mapping */
381	HAL_INT_TXDESC	= 0x00000080,
382	HAL_INT_TIM_TIMER= 0x00000100,
383	HAL_INT_TXURN	= 0x00000800,
384	HAL_INT_MIB	= 0x00001000,
385	HAL_INT_RXPHY	= 0x00004000,
386	HAL_INT_RXKCM	= 0x00008000,
387	HAL_INT_SWBA	= 0x00010000,
388	HAL_INT_BMISS	= 0x00040000,
389	HAL_INT_BNR	= 0x00100000,
390	HAL_INT_TIM	= 0x00200000,	/* Non-common mapping */
391	HAL_INT_DTIM	= 0x00400000,	/* Non-common mapping */
392	HAL_INT_DTIMSYNC= 0x00800000,	/* Non-common mapping */
393	HAL_INT_GPIO	= 0x01000000,
394	HAL_INT_CABEND	= 0x02000000,	/* Non-common mapping */
395	HAL_INT_TSFOOR	= 0x04000000,	/* Non-common mapping */
396	HAL_INT_TBTT	= 0x08000000,	/* Non-common mapping */
397	HAL_INT_CST	= 0x10000000,	/* Non-common mapping */
398	HAL_INT_GTT	= 0x20000000,	/* Non-common mapping */
399	HAL_INT_FATAL	= 0x40000000,	/* Non-common mapping */
400#define	HAL_INT_GLOBAL	0x80000000	/* Set/clear IER */
401	HAL_INT_BMISC	= HAL_INT_TIM
402			| HAL_INT_DTIM
403			| HAL_INT_DTIMSYNC
404			| HAL_INT_CABEND
405			| HAL_INT_TBTT,
406
407	/* Interrupt bits that map directly to ISR/IMR bits */
408	HAL_INT_COMMON  = HAL_INT_RXNOFRM
409			| HAL_INT_RXDESC
410			| HAL_INT_RXEOL
411			| HAL_INT_RXORN
412			| HAL_INT_TXDESC
413			| HAL_INT_TXURN
414			| HAL_INT_MIB
415			| HAL_INT_RXPHY
416			| HAL_INT_RXKCM
417			| HAL_INT_SWBA
418			| HAL_INT_BMISS
419			| HAL_INT_BNR
420			| HAL_INT_GPIO,
421} HAL_INT;
422
423/*
424 * MSI vector assignments
425 */
426typedef enum {
427	HAL_MSIVEC_MISC = 0,
428	HAL_MSIVEC_TX   = 1,
429	HAL_MSIVEC_RXLP = 2,
430	HAL_MSIVEC_RXHP = 3,
431} HAL_MSIVEC;
432
433typedef enum {
434	HAL_INT_LINE = 0,
435	HAL_INT_MSI  = 1,
436} HAL_INT_TYPE;
437
438/* For interrupt mitigation registers */
439typedef enum {
440	HAL_INT_RX_FIRSTPKT=0,
441	HAL_INT_RX_LASTPKT,
442	HAL_INT_TX_FIRSTPKT,
443	HAL_INT_TX_LASTPKT,
444	HAL_INT_THRESHOLD
445} HAL_INT_MITIGATION;
446
447typedef enum {
448	HAL_GPIO_OUTPUT_MUX_AS_OUTPUT		= 0,
449	HAL_GPIO_OUTPUT_MUX_PCIE_ATTENTION_LED	= 1,
450	HAL_GPIO_OUTPUT_MUX_PCIE_POWER_LED	= 2,
451	HAL_GPIO_OUTPUT_MUX_MAC_NETWORK_LED	= 3,
452	HAL_GPIO_OUTPUT_MUX_MAC_POWER_LED	= 4,
453	HAL_GPIO_OUTPUT_MUX_AS_WLAN_ACTIVE	= 5,
454	HAL_GPIO_OUTPUT_MUX_AS_TX_FRAME		= 6
455} HAL_GPIO_MUX_TYPE;
456
457typedef enum {
458	HAL_GPIO_INTR_LOW		= 0,
459	HAL_GPIO_INTR_HIGH		= 1,
460	HAL_GPIO_INTR_DISABLE		= 2
461} HAL_GPIO_INTR_TYPE;
462
463typedef enum {
464	HAL_RFGAIN_INACTIVE		= 0,
465	HAL_RFGAIN_READ_REQUESTED	= 1,
466	HAL_RFGAIN_NEED_CHANGE		= 2
467} HAL_RFGAIN;
468
469typedef uint16_t HAL_CTRY_CODE;		/* country code */
470typedef uint16_t HAL_REG_DOMAIN;		/* regulatory domain code */
471
472#define HAL_ANTENNA_MIN_MODE  0
473#define HAL_ANTENNA_FIXED_A   1
474#define HAL_ANTENNA_FIXED_B   2
475#define HAL_ANTENNA_MAX_MODE  3
476
477typedef struct {
478	uint32_t	ackrcv_bad;
479	uint32_t	rts_bad;
480	uint32_t	rts_good;
481	uint32_t	fcs_bad;
482	uint32_t	beacons;
483} HAL_MIB_STATS;
484
485enum {
486	HAL_MODE_11A	= 0x001,		/* 11a channels */
487	HAL_MODE_TURBO	= 0x002,		/* 11a turbo-only channels */
488	HAL_MODE_11B	= 0x004,		/* 11b channels */
489	HAL_MODE_PUREG	= 0x008,		/* 11g channels (OFDM only) */
490#ifdef notdef
491	HAL_MODE_11G	= 0x010,		/* 11g channels (OFDM/CCK) */
492#else
493	HAL_MODE_11G	= 0x008,		/* XXX historical */
494#endif
495	HAL_MODE_108G	= 0x020,		/* 11g+Turbo channels */
496	HAL_MODE_108A	= 0x040,		/* 11a+Turbo channels */
497	HAL_MODE_11A_HALF_RATE = 0x200,		/* 11a half width channels */
498	HAL_MODE_11A_QUARTER_RATE = 0x400,	/* 11a quarter width channels */
499	HAL_MODE_11G_HALF_RATE = 0x800,		/* 11g half width channels */
500	HAL_MODE_11G_QUARTER_RATE = 0x1000,	/* 11g quarter width channels */
501	HAL_MODE_11NG_HT20	= 0x008000,
502	HAL_MODE_11NA_HT20  	= 0x010000,
503	HAL_MODE_11NG_HT40PLUS	= 0x020000,
504	HAL_MODE_11NG_HT40MINUS	= 0x040000,
505	HAL_MODE_11NA_HT40PLUS	= 0x080000,
506	HAL_MODE_11NA_HT40MINUS	= 0x100000,
507	HAL_MODE_ALL	= 0xffffff
508};
509
510typedef struct {
511	int		rateCount;		/* NB: for proper padding */
512	uint8_t		rateCodeToIndex[144];	/* back mapping */
513	struct {
514		uint8_t		valid;		/* valid for rate control use */
515		uint8_t		phy;		/* CCK/OFDM/XR */
516		uint32_t	rateKbps;	/* transfer rate in kbs */
517		uint8_t		rateCode;	/* rate for h/w descriptors */
518		uint8_t		shortPreamble;	/* mask for enabling short
519						 * preamble in CCK rate code */
520		uint8_t		dot11Rate;	/* value for supported rates
521						 * info element of MLME */
522		uint8_t		controlRate;	/* index of next lower basic
523						 * rate; used for dur. calcs */
524		uint16_t	lpAckDuration;	/* long preamble ACK duration */
525		uint16_t	spAckDuration;	/* short preamble ACK duration*/
526	} info[32];
527} HAL_RATE_TABLE;
528
529typedef struct {
530	u_int		rs_count;		/* number of valid entries */
531	uint8_t	rs_rates[32];		/* rates */
532} HAL_RATE_SET;
533
534/*
535 * 802.11n specific structures and enums
536 */
537typedef enum {
538	HAL_CHAINTYPE_TX	= 1,	/* Tx chain type */
539	HAL_CHAINTYPE_RX	= 2,	/* RX chain type */
540} HAL_CHAIN_TYPE;
541
542typedef struct {
543	u_int	Tries;
544	u_int	Rate;
545	u_int	PktDuration;
546	u_int	ChSel;
547	u_int	RateFlags;
548#define	HAL_RATESERIES_RTS_CTS		0x0001	/* use rts/cts w/this series */
549#define	HAL_RATESERIES_2040		0x0002	/* use ext channel for series */
550#define	HAL_RATESERIES_HALFGI		0x0004	/* use half-gi for series */
551} HAL_11N_RATE_SERIES;
552
553typedef enum {
554	HAL_HT_MACMODE_20	= 0,	/* 20 MHz operation */
555	HAL_HT_MACMODE_2040	= 1,	/* 20/40 MHz operation */
556} HAL_HT_MACMODE;
557
558typedef enum {
559	HAL_HT_PHYMODE_20	= 0,	/* 20 MHz operation */
560	HAL_HT_PHYMODE_2040	= 1,	/* 20/40 MHz operation */
561} HAL_HT_PHYMODE;
562
563typedef enum {
564	HAL_HT_EXTPROTSPACING_20 = 0,	/* 20 MHz spacing */
565	HAL_HT_EXTPROTSPACING_25 = 1,	/* 25 MHz spacing */
566} HAL_HT_EXTPROTSPACING;
567
568
569typedef enum {
570	HAL_RX_CLEAR_CTL_LOW	= 0x1,	/* force control channel to appear busy */
571	HAL_RX_CLEAR_EXT_LOW	= 0x2,	/* force extension channel to appear busy */
572} HAL_HT_RXCLEAR;
573
574/*
575 * Antenna switch control.  By default antenna selection
576 * enables multiple (2) antenna use.  To force use of the
577 * A or B antenna only specify a fixed setting.  Fixing
578 * the antenna will also disable any diversity support.
579 */
580typedef enum {
581	HAL_ANT_VARIABLE = 0,			/* variable by programming */
582	HAL_ANT_FIXED_A	 = 1,			/* fixed antenna A */
583	HAL_ANT_FIXED_B	 = 2,			/* fixed antenna B */
584} HAL_ANT_SETTING;
585
586typedef enum {
587	HAL_M_STA	= 1,			/* infrastructure station */
588	HAL_M_IBSS	= 0,			/* IBSS (adhoc) station */
589	HAL_M_HOSTAP	= 6,			/* Software Access Point */
590	HAL_M_MONITOR	= 8			/* Monitor mode */
591} HAL_OPMODE;
592
593typedef struct {
594	uint8_t		kv_type;		/* one of HAL_CIPHER */
595	uint8_t		kv_pad;
596	uint16_t	kv_len;			/* length in bits */
597	uint8_t		kv_val[16];		/* enough for 128-bit keys */
598	uint8_t		kv_mic[8];		/* TKIP MIC key */
599	uint8_t		kv_txmic[8];		/* TKIP TX MIC key (optional) */
600} HAL_KEYVAL;
601
602typedef enum {
603	HAL_CIPHER_WEP		= 0,
604	HAL_CIPHER_AES_OCB	= 1,
605	HAL_CIPHER_AES_CCM	= 2,
606	HAL_CIPHER_CKIP		= 3,
607	HAL_CIPHER_TKIP		= 4,
608	HAL_CIPHER_CLR		= 5,		/* no encryption */
609
610	HAL_CIPHER_MIC		= 127		/* TKIP-MIC, not a cipher */
611} HAL_CIPHER;
612
613enum {
614	HAL_SLOT_TIME_6	 = 6,			/* NB: for turbo mode */
615	HAL_SLOT_TIME_9	 = 9,
616	HAL_SLOT_TIME_20 = 20,
617};
618
619/*
620 * Per-station beacon timer state.  Note that the specified
621 * beacon interval (given in TU's) can also include flags
622 * to force a TSF reset and to enable the beacon xmit logic.
623 * If bs_cfpmaxduration is non-zero the hardware is setup to
624 * coexist with a PCF-capable AP.
625 */
626typedef struct {
627	uint32_t	bs_nexttbtt;		/* next beacon in TU */
628	uint32_t	bs_nextdtim;		/* next DTIM in TU */
629	uint32_t	bs_intval;		/* beacon interval+flags */
630#define	HAL_BEACON_PERIOD	0x0000ffff	/* beacon interval period */
631#define	HAL_BEACON_ENA		0x00800000	/* beacon xmit enable */
632#define	HAL_BEACON_RESET_TSF	0x01000000	/* clear TSF */
633	uint32_t	bs_dtimperiod;
634	uint16_t	bs_cfpperiod;		/* CFP period in TU */
635	uint16_t	bs_cfpmaxduration;	/* max CFP duration in TU */
636	uint32_t	bs_cfpnext;		/* next CFP in TU */
637	uint16_t	bs_timoffset;		/* byte offset to TIM bitmap */
638	uint16_t	bs_bmissthreshold;	/* beacon miss threshold */
639	uint32_t	bs_sleepduration;	/* max sleep duration */
640} HAL_BEACON_STATE;
641
642/*
643 * Like HAL_BEACON_STATE but for non-station mode setup.
644 * NB: see above flag definitions for bt_intval.
645 */
646typedef struct {
647	uint32_t	bt_intval;		/* beacon interval+flags */
648	uint32_t	bt_nexttbtt;		/* next beacon in TU */
649	uint32_t	bt_nextatim;		/* next ATIM in TU */
650	uint32_t	bt_nextdba;		/* next DBA in 1/8th TU */
651	uint32_t	bt_nextswba;		/* next SWBA in 1/8th TU */
652	uint32_t	bt_flags;		/* timer enables */
653#define HAL_BEACON_TBTT_EN	0x00000001
654#define HAL_BEACON_DBA_EN	0x00000002
655#define HAL_BEACON_SWBA_EN	0x00000004
656} HAL_BEACON_TIMERS;
657
658/*
659 * Per-node statistics maintained by the driver for use in
660 * optimizing signal quality and other operational aspects.
661 */
662typedef struct {
663	uint32_t	ns_avgbrssi;	/* average beacon rssi */
664	uint32_t	ns_avgrssi;	/* average data rssi */
665	uint32_t	ns_avgtxrssi;	/* average tx rssi */
666} HAL_NODE_STATS;
667
668#define	HAL_RSSI_EP_MULTIPLIER	(1<<7)	/* pow2 to optimize out * and / */
669
670struct ath_desc;
671struct ath_tx_status;
672struct ath_rx_status;
673struct ieee80211_channel;
674
675/*
676 * This is a channel survey sample entry.
677 *
678 * The AR5212 ANI routines fill these samples. The ANI code then uses it
679 * when calculating listen time; it is also exported via a diagnostic
680 * API.
681 */
682typedef struct {
683	uint32_t        seq_num;
684	uint32_t        tx_busy;
685	uint32_t        rx_busy;
686	uint32_t        chan_busy;
687	uint32_t        ext_chan_busy;
688	uint32_t        cycle_count;
689	/* XXX TODO */
690	uint32_t        ofdm_phyerr_count;
691	uint32_t        cck_phyerr_count;
692} HAL_SURVEY_SAMPLE;
693
694/*
695 * This provides 3.2 seconds of sample space given an
696 * ANI time of 1/10th of a second. This may not be enough!
697 */
698#define	CHANNEL_SURVEY_SAMPLE_COUNT	32
699
700typedef struct {
701	HAL_SURVEY_SAMPLE samples[CHANNEL_SURVEY_SAMPLE_COUNT];
702	uint32_t cur_sample;	/* current sample in sequence */
703	uint32_t cur_seq;	/* current sequence number */
704} HAL_CHANNEL_SURVEY;
705
706/*
707 * ANI commands.
708 *
709 * These are used both internally and externally via the diagnostic
710 * API.
711 *
712 * Note that this is NOT the ANI commands being used via the INTMIT
713 * capability - that has a different mapping for some reason.
714 */
715typedef enum {
716	HAL_ANI_PRESENT = 0,			/* is ANI support present */
717	HAL_ANI_NOISE_IMMUNITY_LEVEL = 1,	/* set level */
718	HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION = 2,	/* enable/disable */
719	HAL_ANI_CCK_WEAK_SIGNAL_THR = 3,	/* enable/disable */
720	HAL_ANI_FIRSTEP_LEVEL = 4,		/* set level */
721	HAL_ANI_SPUR_IMMUNITY_LEVEL = 5,	/* set level */
722	HAL_ANI_MODE = 6,			/* 0 => manual, 1 => auto (XXX do not change) */
723	HAL_ANI_PHYERR_RESET = 7,		/* reset phy error stats */
724} HAL_ANI_CMD;
725
726/*
727 * This is the layout of the ANI INTMIT capability.
728 *
729 * Notice that the command values differ to HAL_ANI_CMD.
730 */
731typedef enum {
732	HAL_CAP_INTMIT_PRESENT = 0,
733	HAL_CAP_INTMIT_ENABLE = 1,
734	HAL_CAP_INTMIT_NOISE_IMMUNITY_LEVEL = 2,
735	HAL_CAP_INTMIT_OFDM_WEAK_SIGNAL_LEVEL = 3,
736	HAL_CAP_INTMIT_CCK_WEAK_SIGNAL_THR = 4,
737	HAL_CAP_INTMIT_FIRSTEP_LEVEL = 5,
738	HAL_CAP_INTMIT_SPUR_IMMUNITY_LEVEL = 6
739} HAL_CAP_INTMIT_CMD;
740
741typedef struct {
742	int32_t		pe_firpwr;	/* FIR pwr out threshold */
743	int32_t		pe_rrssi;	/* Radar rssi thresh */
744	int32_t		pe_height;	/* Pulse height thresh */
745	int32_t		pe_prssi;	/* Pulse rssi thresh */
746	int32_t		pe_inband;	/* Inband thresh */
747
748	/* The following params are only for AR5413 and later */
749	u_int32_t	pe_relpwr;	/* Relative power threshold in 0.5dB steps */
750	u_int32_t	pe_relstep;	/* Pulse Relative step threshold in 0.5dB steps */
751	u_int32_t	pe_maxlen;	/* Max length of radar sign in 0.8us units */
752	int32_t		pe_usefir128;	/* Use the average in-band power measured over 128 cycles */
753	int32_t		pe_blockradar;	/*
754					 * Enable to block radar check if pkt detect is done via OFDM
755					 * weak signal detect or pkt is detected immediately after tx
756					 * to rx transition
757					 */
758	int32_t		pe_enmaxrssi;	/*
759					 * Enable to use the max rssi instead of the last rssi during
760					 * fine gain changes for radar detection
761					 */
762	int32_t		pe_extchannel;	/* Enable DFS on ext channel */
763	int32_t		pe_enabled;	/* Whether radar detection is enabled */
764	int32_t		pe_enrelpwr;
765	int32_t		pe_en_relstep_check;
766} HAL_PHYERR_PARAM;
767
768#define	HAL_PHYERR_PARAM_NOVAL	65535
769
770/*
771 * DFS operating mode flags.
772 */
773typedef enum {
774	HAL_DFS_UNINIT_DOMAIN	= 0,	/* Uninitialized dfs domain */
775	HAL_DFS_FCC_DOMAIN	= 1,	/* FCC3 dfs domain */
776	HAL_DFS_ETSI_DOMAIN	= 2,	/* ETSI dfs domain */
777	HAL_DFS_MKK4_DOMAIN	= 3,	/* Japan dfs domain */
778} HAL_DFS_DOMAIN;
779
780/*
781 * Flag for setting QUIET period
782 */
783typedef enum {
784	HAL_QUIET_DISABLE		= 0x0,
785	HAL_QUIET_ENABLE		= 0x1,
786	HAL_QUIET_ADD_CURRENT_TSF	= 0x2,	/* add current TSF to next_start offset */
787	HAL_QUIET_ADD_SWBA_RESP_TIME	= 0x4,	/* add beacon response time to next_start offset */
788} HAL_QUIET_FLAG;
789
790#define	HAL_DFS_EVENT_PRICH		0x0000001
791#define	HAL_DFS_EVENT_EXTCH		0x0000002
792#define	HAL_DFS_EVENT_EXTEARLY		0x0000004
793#define	HAL_DFS_EVENT_ISDC		0x0000008
794
795struct hal_dfs_event {
796	uint64_t	re_full_ts;	/* 64-bit full timestamp from interrupt time */
797	uint32_t	re_ts;		/* Original 15 bit recv timestamp */
798	uint8_t		re_rssi;	/* rssi of radar event */
799	uint8_t		re_dur;		/* duration of radar pulse */
800	uint32_t	re_flags;	/* Flags (see above) */
801};
802typedef struct hal_dfs_event HAL_DFS_EVENT;
803
804/*
805 * BT Co-existence definitions
806 */
807typedef enum {
808	HAL_BT_MODULE_CSR_BC4	= 0,	/* CSR BlueCore v4 */
809	HAL_BT_MODULE_JANUS	= 1,	/* Kite + Valkyrie combo */
810	HAL_BT_MODULE_HELIUS	= 2,	/* Kiwi + Valkyrie combo */
811	HAL_MAX_BT_MODULES
812} HAL_BT_MODULE;
813
814typedef struct {
815	HAL_BT_MODULE	bt_module;
816	u_int8_t	bt_coex_config;
817	u_int8_t	bt_gpio_bt_active;
818	u_int8_t	bt_gpio_bt_priority;
819	u_int8_t	bt_gpio_wlan_active;
820	u_int8_t	bt_active_polarity;
821	HAL_BOOL	bt_single_ant;
822	u_int8_t	bt_dutyCycle;
823	u_int8_t	bt_isolation;
824	u_int8_t	bt_period;
825} HAL_BT_COEX_INFO;
826
827typedef enum {
828	HAL_BT_COEX_MODE_LEGACY		= 0,	/* legacy rx_clear mode */
829	HAL_BT_COEX_MODE_UNSLOTTED	= 1,	/* untimed/unslotted mode */
830	HAL_BT_COEX_MODE_SLOTTED	= 2,	/* slotted mode */
831	HAL_BT_COEX_MODE_DISALBED	= 3,	/* coexistence disabled */
832} HAL_BT_COEX_MODE;
833
834typedef enum {
835	HAL_BT_COEX_CFG_NONE,		/* No bt coex enabled */
836	HAL_BT_COEX_CFG_2WIRE_2CH,	/* 2-wire with 2 chains */
837	HAL_BT_COEX_CFG_2WIRE_CH1,	/* 2-wire with ch1 */
838	HAL_BT_COEX_CFG_2WIRE_CH0,	/* 2-wire with ch0 */
839	HAL_BT_COEX_CFG_3WIRE,		/* 3-wire */
840	HAL_BT_COEX_CFG_MCI		/* MCI */
841} HAL_BT_COEX_CFG;
842
843typedef enum {
844	HAL_BT_COEX_SET_ACK_PWR		= 0,	/* Change ACK power setting */
845	HAL_BT_COEX_LOWER_TX_PWR,		/* Change transmit power */
846	HAL_BT_COEX_ANTENNA_DIVERSITY,	/* Enable RX diversity for Kite */
847} HAL_BT_COEX_SET_PARAMETER;
848
849#define	HAL_BT_COEX_FLAG_LOW_ACK_PWR	0x00000001
850#define	HAL_BT_COEX_FLAG_LOWER_TX_PWR	0x00000002
851/* Check Rx Diversity is allowed */
852#define	HAL_BT_COEX_FLAG_ANT_DIV_ALLOW	0x00000004
853/* Check Diversity is on or off */
854#define	HAL_BT_COEX_FLAG_ANT_DIV_ENABLE	0x00000008
855
856#define	HAL_BT_COEX_ANTDIV_CONTROL1_ENABLE	0x0b
857/* main: LNA1, alt: LNA2 */
858#define	HAL_BT_COEX_ANTDIV_CONTROL2_ENABLE	0x09
859#define	HAL_BT_COEX_ANTDIV_CONTROL1_FIXED_A	0x04
860#define	HAL_BT_COEX_ANTDIV_CONTROL2_FIXED_A	0x09
861#define	HAL_BT_COEX_ANTDIV_CONTROL1_FIXED_B	0x02
862#define	HAL_BT_COEX_ANTDIV_CONTROL2_FIXED_B	0x06
863
864#define	HAL_BT_COEX_ISOLATION_FOR_NO_COEX	30
865
866#define	HAL_BT_COEX_ANT_DIV_SWITCH_COM	0x66666666
867
868#define	HAL_BT_COEX_HELIUS_CHAINMASK	0x02
869
870#define	HAL_BT_COEX_LOW_ACK_POWER	0x0
871#define	HAL_BT_COEX_HIGH_ACK_POWER	0x3f3f3f
872
873typedef enum {
874	HAL_BT_COEX_NO_STOMP = 0,
875	HAL_BT_COEX_STOMP_ALL,
876	HAL_BT_COEX_STOMP_LOW,
877	HAL_BT_COEX_STOMP_NONE,
878	HAL_BT_COEX_STOMP_ALL_FORCE,
879	HAL_BT_COEX_STOMP_LOW_FORCE,
880} HAL_BT_COEX_STOMP_TYPE;
881
882typedef struct {
883	/* extend rx_clear after tx/rx to protect the burst (in usec). */
884	u_int8_t	bt_time_extend;
885
886	/*
887	 * extend rx_clear as long as txsm is
888	 * transmitting or waiting for ack.
889	 */
890	HAL_BOOL	bt_txstate_extend;
891
892	/*
893	 * extend rx_clear so that when tx_frame
894	 * is asserted, rx_clear will drop.
895	 */
896	HAL_BOOL	bt_txframe_extend;
897
898	/*
899	 * coexistence mode
900	 */
901	HAL_BT_COEX_MODE	bt_mode;
902
903	/*
904	 * treat BT high priority traffic as
905	 * a quiet collision
906	 */
907	HAL_BOOL	bt_quiet_collision;
908
909	/*
910	 * invert rx_clear as WLAN_ACTIVE
911	 */
912	HAL_BOOL	bt_rxclear_polarity;
913
914	/*
915	 * slotted mode only. indicate the time in usec
916	 * from the rising edge of BT_ACTIVE to the time
917	 * BT_PRIORITY can be sampled to indicate priority.
918	 */
919	u_int8_t	bt_priority_time;
920
921	/*
922	 * slotted mode only. indicate the time in usec
923	 * from the rising edge of BT_ACTIVE to the time
924	 * BT_PRIORITY can be sampled to indicate tx/rx and
925	 * BT_FREQ is sampled.
926	 */
927	u_int8_t	bt_first_slot_time;
928
929	/*
930	 * slotted mode only. rx_clear and bt_ant decision
931	 * will be held the entire time that BT_ACTIVE is asserted,
932	 * otherwise the decision is made before every slot boundry.
933	 */
934	HAL_BOOL	bt_hold_rxclear;
935} HAL_BT_COEX_CONFIG;
936
937typedef struct
938{
939	int ah_debug;			/* only used if AH_DEBUG is defined */
940	int ah_ar5416_biasadj;		/* enable AR2133 radio specific bias fiddling */
941
942	/* NB: these are deprecated; they exist for now for compatibility */
943	int ah_dma_beacon_response_time;/* in TU's */
944	int ah_sw_beacon_response_time;	/* in TU's */
945	int ah_additional_swba_backoff;	/* in TU's */
946	int ah_force_full_reset;	/* force full chip reset rather then warm reset */
947	int ah_serialise_reg_war;	/* force serialisation of register IO */
948} HAL_OPS_CONFIG;
949
950/*
951 * Hardware Access Layer (HAL) API.
952 *
953 * Clients of the HAL call ath_hal_attach to obtain a reference to an
954 * ath_hal structure for use with the device.  Hardware-related operations
955 * that follow must call back into the HAL through interface, supplying
956 * the reference as the first parameter.  Note that before using the
957 * reference returned by ath_hal_attach the caller should verify the
958 * ABI version number.
959 */
960struct ath_hal {
961	uint32_t	ah_magic;	/* consistency check magic number */
962	uint16_t	ah_devid;	/* PCI device ID */
963	uint16_t	ah_subvendorid;	/* PCI subvendor ID */
964	HAL_SOFTC	ah_sc;		/* back pointer to driver/os state */
965	HAL_BUS_TAG	ah_st;		/* params for register r+w */
966	HAL_BUS_HANDLE	ah_sh;
967	HAL_CTRY_CODE	ah_countryCode;
968
969	uint32_t	ah_macVersion;	/* MAC version id */
970	uint16_t	ah_macRev;	/* MAC revision */
971	uint16_t	ah_phyRev;	/* PHY revision */
972	/* NB: when only one radio is present the rev is in 5Ghz */
973	uint16_t	ah_analog5GhzRev;/* 5GHz radio revision */
974	uint16_t	ah_analog2GhzRev;/* 2GHz radio revision */
975
976	uint16_t	*ah_eepromdata;	/* eeprom buffer, if needed */
977
978	uint32_t	ah_intrstate[8];	/* last int state */
979	uint32_t	ah_syncstate;		/* last sync intr state */
980
981	HAL_OPS_CONFIG ah_config;
982	const HAL_RATE_TABLE *__ahdecl(*ah_getRateTable)(struct ath_hal *,
983				u_int mode);
984	void	  __ahdecl(*ah_detach)(struct ath_hal*);
985
986	/* Reset functions */
987	HAL_BOOL  __ahdecl(*ah_reset)(struct ath_hal *, HAL_OPMODE,
988				struct ieee80211_channel *,
989				HAL_BOOL bChannelChange, HAL_STATUS *status);
990	HAL_BOOL  __ahdecl(*ah_phyDisable)(struct ath_hal *);
991	HAL_BOOL  __ahdecl(*ah_disable)(struct ath_hal *);
992	void	  __ahdecl(*ah_configPCIE)(struct ath_hal *, HAL_BOOL restore,
993				HAL_BOOL power_off);
994	void	  __ahdecl(*ah_disablePCIE)(struct ath_hal *);
995	void	  __ahdecl(*ah_setPCUConfig)(struct ath_hal *);
996	HAL_BOOL  __ahdecl(*ah_perCalibration)(struct ath_hal*,
997			struct ieee80211_channel *, HAL_BOOL *);
998	HAL_BOOL  __ahdecl(*ah_perCalibrationN)(struct ath_hal *,
999			struct ieee80211_channel *, u_int chainMask,
1000			HAL_BOOL longCal, HAL_BOOL *isCalDone);
1001	HAL_BOOL  __ahdecl(*ah_resetCalValid)(struct ath_hal *,
1002			const struct ieee80211_channel *);
1003	HAL_BOOL  __ahdecl(*ah_setTxPower)(struct ath_hal *,
1004	    		const struct ieee80211_channel *, uint16_t *);
1005	HAL_BOOL  __ahdecl(*ah_setTxPowerLimit)(struct ath_hal *, uint32_t);
1006	HAL_BOOL  __ahdecl(*ah_setBoardValues)(struct ath_hal *,
1007	    		const struct ieee80211_channel *);
1008
1009	/* Transmit functions */
1010	HAL_BOOL  __ahdecl(*ah_updateTxTrigLevel)(struct ath_hal*,
1011				HAL_BOOL incTrigLevel);
1012	int	  __ahdecl(*ah_setupTxQueue)(struct ath_hal *, HAL_TX_QUEUE,
1013				const HAL_TXQ_INFO *qInfo);
1014	HAL_BOOL  __ahdecl(*ah_setTxQueueProps)(struct ath_hal *, int q,
1015				const HAL_TXQ_INFO *qInfo);
1016	HAL_BOOL  __ahdecl(*ah_getTxQueueProps)(struct ath_hal *, int q,
1017				HAL_TXQ_INFO *qInfo);
1018	HAL_BOOL  __ahdecl(*ah_releaseTxQueue)(struct ath_hal *ah, u_int q);
1019	HAL_BOOL  __ahdecl(*ah_resetTxQueue)(struct ath_hal *ah, u_int q);
1020	uint32_t __ahdecl(*ah_getTxDP)(struct ath_hal*, u_int);
1021	HAL_BOOL  __ahdecl(*ah_setTxDP)(struct ath_hal*, u_int, uint32_t txdp);
1022	uint32_t __ahdecl(*ah_numTxPending)(struct ath_hal *, u_int q);
1023	HAL_BOOL  __ahdecl(*ah_startTxDma)(struct ath_hal*, u_int);
1024	HAL_BOOL  __ahdecl(*ah_stopTxDma)(struct ath_hal*, u_int);
1025	HAL_BOOL  __ahdecl(*ah_setupTxDesc)(struct ath_hal *, struct ath_desc *,
1026				u_int pktLen, u_int hdrLen,
1027				HAL_PKT_TYPE type, u_int txPower,
1028				u_int txRate0, u_int txTries0,
1029				u_int keyIx, u_int antMode, u_int flags,
1030				u_int rtsctsRate, u_int rtsctsDuration,
1031				u_int compicvLen, u_int compivLen,
1032				u_int comp);
1033	HAL_BOOL  __ahdecl(*ah_setupXTxDesc)(struct ath_hal *, struct ath_desc*,
1034				u_int txRate1, u_int txTries1,
1035				u_int txRate2, u_int txTries2,
1036				u_int txRate3, u_int txTries3);
1037	HAL_BOOL  __ahdecl(*ah_fillTxDesc)(struct ath_hal *, struct ath_desc *,
1038				u_int segLen, HAL_BOOL firstSeg,
1039				HAL_BOOL lastSeg, const struct ath_desc *);
1040	HAL_STATUS __ahdecl(*ah_procTxDesc)(struct ath_hal *,
1041				struct ath_desc *, struct ath_tx_status *);
1042	void	   __ahdecl(*ah_getTxIntrQueue)(struct ath_hal *, uint32_t *);
1043	void	   __ahdecl(*ah_reqTxIntrDesc)(struct ath_hal *, struct ath_desc*);
1044	HAL_BOOL	__ahdecl(*ah_getTxCompletionRates)(struct ath_hal *,
1045				const struct ath_desc *ds, int *rates, int *tries);
1046
1047	/* Receive Functions */
1048	uint32_t __ahdecl(*ah_getRxDP)(struct ath_hal*);
1049	void	  __ahdecl(*ah_setRxDP)(struct ath_hal*, uint32_t rxdp);
1050	void	  __ahdecl(*ah_enableReceive)(struct ath_hal*);
1051	HAL_BOOL  __ahdecl(*ah_stopDmaReceive)(struct ath_hal*);
1052	void	  __ahdecl(*ah_startPcuReceive)(struct ath_hal*);
1053	void	  __ahdecl(*ah_stopPcuReceive)(struct ath_hal*);
1054	void	  __ahdecl(*ah_setMulticastFilter)(struct ath_hal*,
1055				uint32_t filter0, uint32_t filter1);
1056	HAL_BOOL  __ahdecl(*ah_setMulticastFilterIndex)(struct ath_hal*,
1057				uint32_t index);
1058	HAL_BOOL  __ahdecl(*ah_clrMulticastFilterIndex)(struct ath_hal*,
1059				uint32_t index);
1060	uint32_t __ahdecl(*ah_getRxFilter)(struct ath_hal*);
1061	void	  __ahdecl(*ah_setRxFilter)(struct ath_hal*, uint32_t);
1062	HAL_BOOL  __ahdecl(*ah_setupRxDesc)(struct ath_hal *, struct ath_desc *,
1063				uint32_t size, u_int flags);
1064	HAL_STATUS __ahdecl(*ah_procRxDesc)(struct ath_hal *,
1065				struct ath_desc *, uint32_t phyAddr,
1066				struct ath_desc *next, uint64_t tsf,
1067				struct ath_rx_status *);
1068	void	  __ahdecl(*ah_rxMonitor)(struct ath_hal *,
1069				const HAL_NODE_STATS *,
1070				const struct ieee80211_channel *);
1071	void      __ahdecl(*ah_aniPoll)(struct ath_hal *,
1072				const struct ieee80211_channel *);
1073	void	  __ahdecl(*ah_procMibEvent)(struct ath_hal *,
1074				const HAL_NODE_STATS *);
1075	void	  __ahdecl(*ah_rxAntCombDiversity)(struct ath_hal *,
1076				struct ath_rx_status *,
1077				unsigned long, int);
1078
1079	/* Misc Functions */
1080	HAL_STATUS __ahdecl(*ah_getCapability)(struct ath_hal *,
1081				HAL_CAPABILITY_TYPE, uint32_t capability,
1082				uint32_t *result);
1083	HAL_BOOL   __ahdecl(*ah_setCapability)(struct ath_hal *,
1084				HAL_CAPABILITY_TYPE, uint32_t capability,
1085				uint32_t setting, HAL_STATUS *);
1086	HAL_BOOL   __ahdecl(*ah_getDiagState)(struct ath_hal *, int request,
1087				const void *args, uint32_t argsize,
1088				void **result, uint32_t *resultsize);
1089	void	  __ahdecl(*ah_getMacAddress)(struct ath_hal *, uint8_t *);
1090	HAL_BOOL  __ahdecl(*ah_setMacAddress)(struct ath_hal *, const uint8_t*);
1091	void	  __ahdecl(*ah_getBssIdMask)(struct ath_hal *, uint8_t *);
1092	HAL_BOOL  __ahdecl(*ah_setBssIdMask)(struct ath_hal *, const uint8_t*);
1093	HAL_BOOL  __ahdecl(*ah_setRegulatoryDomain)(struct ath_hal*,
1094				uint16_t, HAL_STATUS *);
1095	void	  __ahdecl(*ah_setLedState)(struct ath_hal*, HAL_LED_STATE);
1096	void	  __ahdecl(*ah_writeAssocid)(struct ath_hal*,
1097				const uint8_t *bssid, uint16_t assocId);
1098	HAL_BOOL  __ahdecl(*ah_gpioCfgOutput)(struct ath_hal *,
1099				uint32_t gpio, HAL_GPIO_MUX_TYPE);
1100	HAL_BOOL  __ahdecl(*ah_gpioCfgInput)(struct ath_hal *, uint32_t gpio);
1101	uint32_t __ahdecl(*ah_gpioGet)(struct ath_hal *, uint32_t gpio);
1102	HAL_BOOL  __ahdecl(*ah_gpioSet)(struct ath_hal *,
1103				uint32_t gpio, uint32_t val);
1104	void	  __ahdecl(*ah_gpioSetIntr)(struct ath_hal*, u_int, uint32_t);
1105	uint32_t __ahdecl(*ah_getTsf32)(struct ath_hal*);
1106	uint64_t __ahdecl(*ah_getTsf64)(struct ath_hal*);
1107	void	  __ahdecl(*ah_resetTsf)(struct ath_hal*);
1108	HAL_BOOL  __ahdecl(*ah_detectCardPresent)(struct ath_hal*);
1109	void	  __ahdecl(*ah_updateMibCounters)(struct ath_hal*,
1110				HAL_MIB_STATS*);
1111	HAL_RFGAIN __ahdecl(*ah_getRfGain)(struct ath_hal*);
1112	u_int	  __ahdecl(*ah_getDefAntenna)(struct ath_hal*);
1113	void	  __ahdecl(*ah_setDefAntenna)(struct ath_hal*, u_int);
1114	HAL_ANT_SETTING	 __ahdecl(*ah_getAntennaSwitch)(struct ath_hal*);
1115	HAL_BOOL  __ahdecl(*ah_setAntennaSwitch)(struct ath_hal*,
1116				HAL_ANT_SETTING);
1117	HAL_BOOL  __ahdecl(*ah_setSifsTime)(struct ath_hal*, u_int);
1118	u_int	  __ahdecl(*ah_getSifsTime)(struct ath_hal*);
1119	HAL_BOOL  __ahdecl(*ah_setSlotTime)(struct ath_hal*, u_int);
1120	u_int	  __ahdecl(*ah_getSlotTime)(struct ath_hal*);
1121	HAL_BOOL  __ahdecl(*ah_setAckTimeout)(struct ath_hal*, u_int);
1122	u_int	  __ahdecl(*ah_getAckTimeout)(struct ath_hal*);
1123	HAL_BOOL  __ahdecl(*ah_setAckCTSRate)(struct ath_hal*, u_int);
1124	u_int	  __ahdecl(*ah_getAckCTSRate)(struct ath_hal*);
1125	HAL_BOOL  __ahdecl(*ah_setCTSTimeout)(struct ath_hal*, u_int);
1126	u_int	  __ahdecl(*ah_getCTSTimeout)(struct ath_hal*);
1127	HAL_BOOL  __ahdecl(*ah_setDecompMask)(struct ath_hal*, uint16_t, int);
1128	void	  __ahdecl(*ah_setCoverageClass)(struct ath_hal*, uint8_t, int);
1129	HAL_STATUS	__ahdecl(*ah_setQuiet)(struct ath_hal *ah, uint32_t period,
1130				uint32_t duration, uint32_t nextStart,
1131				HAL_QUIET_FLAG flag);
1132
1133	/* DFS functions */
1134	void	  __ahdecl(*ah_enableDfs)(struct ath_hal *ah,
1135				HAL_PHYERR_PARAM *pe);
1136	void	  __ahdecl(*ah_getDfsThresh)(struct ath_hal *ah,
1137				HAL_PHYERR_PARAM *pe);
1138	HAL_BOOL  __ahdecl(*ah_procRadarEvent)(struct ath_hal *ah,
1139				struct ath_rx_status *rxs, uint64_t fulltsf,
1140				const char *buf, HAL_DFS_EVENT *event);
1141	HAL_BOOL  __ahdecl(*ah_isFastClockEnabled)(struct ath_hal *ah);
1142
1143	/* Key Cache Functions */
1144	uint32_t __ahdecl(*ah_getKeyCacheSize)(struct ath_hal*);
1145	HAL_BOOL  __ahdecl(*ah_resetKeyCacheEntry)(struct ath_hal*, uint16_t);
1146	HAL_BOOL  __ahdecl(*ah_isKeyCacheEntryValid)(struct ath_hal *,
1147				uint16_t);
1148	HAL_BOOL  __ahdecl(*ah_setKeyCacheEntry)(struct ath_hal*,
1149				uint16_t, const HAL_KEYVAL *,
1150				const uint8_t *, int);
1151	HAL_BOOL  __ahdecl(*ah_setKeyCacheEntryMac)(struct ath_hal*,
1152				uint16_t, const uint8_t *);
1153
1154	/* Power Management Functions */
1155	HAL_BOOL  __ahdecl(*ah_setPowerMode)(struct ath_hal*,
1156				HAL_POWER_MODE mode, int setChip);
1157	HAL_POWER_MODE __ahdecl(*ah_getPowerMode)(struct ath_hal*);
1158	int16_t   __ahdecl(*ah_getChanNoise)(struct ath_hal *,
1159				const struct ieee80211_channel *);
1160
1161	/* Beacon Management Functions */
1162	void	  __ahdecl(*ah_setBeaconTimers)(struct ath_hal*,
1163				const HAL_BEACON_TIMERS *);
1164	/* NB: deprecated, use ah_setBeaconTimers instead */
1165	void	  __ahdecl(*ah_beaconInit)(struct ath_hal *,
1166				uint32_t nexttbtt, uint32_t intval);
1167	void	  __ahdecl(*ah_setStationBeaconTimers)(struct ath_hal*,
1168				const HAL_BEACON_STATE *);
1169	void	  __ahdecl(*ah_resetStationBeaconTimers)(struct ath_hal*);
1170	uint64_t  __ahdecl(*ah_getNextTBTT)(struct ath_hal *);
1171
1172	/* 802.11n Functions */
1173	HAL_BOOL  __ahdecl(*ah_chainTxDesc)(struct ath_hal *,
1174				struct ath_desc *, u_int, u_int, HAL_PKT_TYPE,
1175				u_int, HAL_CIPHER, uint8_t, u_int, HAL_BOOL,
1176				HAL_BOOL, HAL_BOOL);
1177	HAL_BOOL  __ahdecl(*ah_setupFirstTxDesc)(struct ath_hal *,
1178				struct ath_desc *, u_int, u_int, u_int,
1179				u_int, u_int, u_int, u_int, u_int);
1180	HAL_BOOL  __ahdecl(*ah_setupLastTxDesc)(struct ath_hal *,
1181				struct ath_desc *, const struct ath_desc *);
1182	void	  __ahdecl(*ah_set11nRateScenario)(struct ath_hal *,
1183	    			struct ath_desc *, u_int, u_int,
1184				HAL_11N_RATE_SERIES [], u_int, u_int);
1185	void	  __ahdecl(*ah_set11nAggrFirst)(struct ath_hal *,
1186				struct ath_desc *, u_int, u_int);
1187	void	  __ahdecl(*ah_set11nAggrMiddle)(struct ath_hal *,
1188	    			struct ath_desc *, u_int);
1189	void	  __ahdecl(*ah_set11nAggrLast)(struct ath_hal *,
1190				struct ath_desc *);
1191	void	  __ahdecl(*ah_clr11nAggr)(struct ath_hal *,
1192	    			struct ath_desc *);
1193	void	  __ahdecl(*ah_set11nBurstDuration)(struct ath_hal *,
1194	    			struct ath_desc *, u_int);
1195	HAL_BOOL  __ahdecl(*ah_getMibCycleCounts) (struct ath_hal *,
1196				HAL_SURVEY_SAMPLE *);
1197
1198	uint32_t  __ahdecl(*ah_get11nExtBusy)(struct ath_hal *);
1199	void      __ahdecl(*ah_set11nMac2040)(struct ath_hal *,
1200				HAL_HT_MACMODE);
1201	HAL_HT_RXCLEAR __ahdecl(*ah_get11nRxClear)(struct ath_hal *ah);
1202	void	  __ahdecl(*ah_set11nRxClear)(struct ath_hal *,
1203	    			HAL_HT_RXCLEAR);
1204
1205	/* Interrupt functions */
1206	HAL_BOOL  __ahdecl(*ah_isInterruptPending)(struct ath_hal*);
1207	HAL_BOOL  __ahdecl(*ah_getPendingInterrupts)(struct ath_hal*, HAL_INT*);
1208	HAL_INT	  __ahdecl(*ah_getInterrupts)(struct ath_hal*);
1209	HAL_INT	  __ahdecl(*ah_setInterrupts)(struct ath_hal*, HAL_INT);
1210};
1211
1212/*
1213 * Check the PCI vendor ID and device ID against Atheros' values
1214 * and return a printable description for any Atheros hardware.
1215 * AH_NULL is returned if the ID's do not describe Atheros hardware.
1216 */
1217extern	const char *__ahdecl ath_hal_probe(uint16_t vendorid, uint16_t devid);
1218
1219/*
1220 * Attach the HAL for use with the specified device.  The device is
1221 * defined by the PCI device ID.  The caller provides an opaque pointer
1222 * to an upper-layer data structure (HAL_SOFTC) that is stored in the
1223 * HAL state block for later use.  Hardware register accesses are done
1224 * using the specified bus tag and handle.  On successful return a
1225 * reference to a state block is returned that must be supplied in all
1226 * subsequent HAL calls.  Storage associated with this reference is
1227 * dynamically allocated and must be freed by calling the ah_detach
1228 * method when the client is done.  If the attach operation fails a
1229 * null (AH_NULL) reference will be returned and a status code will
1230 * be returned if the status parameter is non-zero.
1231 */
1232extern	struct ath_hal * __ahdecl ath_hal_attach(uint16_t devid, HAL_SOFTC,
1233		HAL_BUS_TAG, HAL_BUS_HANDLE, uint16_t *eepromdata, HAL_STATUS* status);
1234
1235extern	const char *ath_hal_mac_name(struct ath_hal *);
1236extern	const char *ath_hal_rf_name(struct ath_hal *);
1237
1238/*
1239 * Regulatory interfaces.  Drivers should use ath_hal_init_channels to
1240 * request a set of channels for a particular country code and/or
1241 * regulatory domain.  If CTRY_DEFAULT and SKU_NONE are specified then
1242 * this list is constructed according to the contents of the EEPROM.
1243 * ath_hal_getchannels acts similarly but does not alter the operating
1244 * state; this can be used to collect information for a particular
1245 * regulatory configuration.  Finally ath_hal_set_channels installs a
1246 * channel list constructed outside the driver.  The HAL will adopt the
1247 * channel list and setup internal state according to the specified
1248 * regulatory configuration (e.g. conformance test limits).
1249 *
1250 * For all interfaces the channel list is returned in the supplied array.
1251 * maxchans defines the maximum size of this array.  nchans contains the
1252 * actual number of channels returned.  If a problem occurred then a
1253 * status code != HAL_OK is returned.
1254 */
1255struct ieee80211_channel;
1256
1257/*
1258 * Return a list of channels according to the specified regulatory.
1259 */
1260extern	HAL_STATUS __ahdecl ath_hal_getchannels(struct ath_hal *,
1261    struct ieee80211_channel *chans, u_int maxchans, int *nchans,
1262    u_int modeSelect, HAL_CTRY_CODE cc, HAL_REG_DOMAIN regDmn,
1263    HAL_BOOL enableExtendedChannels);
1264
1265/*
1266 * Return a list of channels and install it as the current operating
1267 * regulatory list.
1268 */
1269extern	HAL_STATUS __ahdecl ath_hal_init_channels(struct ath_hal *,
1270    struct ieee80211_channel *chans, u_int maxchans, int *nchans,
1271    u_int modeSelect, HAL_CTRY_CODE cc, HAL_REG_DOMAIN rd,
1272    HAL_BOOL enableExtendedChannels);
1273
1274/*
1275 * Install the list of channels as the current operating regulatory
1276 * and setup related state according to the country code and sku.
1277 */
1278extern	HAL_STATUS __ahdecl ath_hal_set_channels(struct ath_hal *,
1279    struct ieee80211_channel *chans, int nchans,
1280    HAL_CTRY_CODE cc, HAL_REG_DOMAIN regDmn);
1281
1282/*
1283 * Fetch the ctl/ext noise floor values reported by a MIMO
1284 * radio. Returns 1 for valid results, 0 for invalid channel.
1285 */
1286extern int __ahdecl ath_hal_get_mimo_chan_noise(struct ath_hal *ah,
1287    const struct ieee80211_channel *chan, int16_t *nf_ctl,
1288    int16_t *nf_ext);
1289
1290/*
1291 * Calibrate noise floor data following a channel scan or similar.
1292 * This must be called prior retrieving noise floor data.
1293 */
1294extern	void __ahdecl ath_hal_process_noisefloor(struct ath_hal *ah);
1295
1296/*
1297 * Return bit mask of wireless modes supported by the hardware.
1298 */
1299extern	u_int __ahdecl ath_hal_getwirelessmodes(struct ath_hal*);
1300
1301/*
1302 * Calculate the packet TX time for a legacy or 11n frame
1303 */
1304extern uint32_t __ahdecl ath_hal_pkt_txtime(struct ath_hal *ah,
1305    const HAL_RATE_TABLE *rates, uint32_t frameLen,
1306    uint16_t rateix, HAL_BOOL isht40, HAL_BOOL shortPreamble);
1307
1308/*
1309 * Calculate the duration of an 11n frame.
1310 */
1311extern uint32_t __ahdecl ath_computedur_ht(uint32_t frameLen, uint16_t rate,
1312    int streams, HAL_BOOL isht40, HAL_BOOL isShortGI);
1313
1314/*
1315 * Calculate the transmit duration of a legacy frame.
1316 */
1317extern uint16_t __ahdecl ath_hal_computetxtime(struct ath_hal *,
1318		const HAL_RATE_TABLE *rates, uint32_t frameLen,
1319		uint16_t rateix, HAL_BOOL shortPreamble);
1320
1321/*
1322 * Adjust the TSF.
1323 */
1324extern void __ahdecl ath_hal_adjusttsf(struct ath_hal *ah, int32_t tsfdelta);
1325
1326/*
1327 * Enable or disable CCA.
1328 */
1329void __ahdecl ath_hal_setcca(struct ath_hal *ah, int ena);
1330
1331/*
1332 * Get CCA setting.
1333 */
1334int __ahdecl ath_hal_getcca(struct ath_hal *ah);
1335
1336/*
1337 * Read EEPROM data from ah_eepromdata
1338 */
1339HAL_BOOL __ahdecl ath_hal_EepromDataRead(struct ath_hal *ah,
1340		u_int off, uint16_t *data);
1341
1342#endif /* _ATH_AH_H_ */
1343