ah.h revision 234088
1185377Ssam/*
2187831Ssam * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3185377Ssam * Copyright (c) 2002-2008 Atheros Communications, Inc.
4185377Ssam *
5185377Ssam * Permission to use, copy, modify, and/or distribute this software for any
6185377Ssam * purpose with or without fee is hereby granted, provided that the above
7185377Ssam * copyright notice and this permission notice appear in all copies.
8185377Ssam *
9185377Ssam * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10185377Ssam * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11185377Ssam * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12185377Ssam * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13185377Ssam * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14185377Ssam * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15185377Ssam * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16185377Ssam *
17187831Ssam * $FreeBSD: head/sys/dev/ath/ath_hal/ah.h 234088 2012-04-10 07:11:33Z adrian $
18185377Ssam */
19185377Ssam
20185377Ssam#ifndef _ATH_AH_H_
21185377Ssam#define _ATH_AH_H_
22185377Ssam/*
23185377Ssam * Atheros Hardware Access Layer
24185377Ssam *
25185377Ssam * Clients of the HAL call ath_hal_attach to obtain a reference to an ath_hal
26185377Ssam * structure for use with the device.  Hardware-related operations that
27185377Ssam * follow must call back into the HAL through interface, supplying the
28185377Ssam * reference as the first parameter.
29185377Ssam */
30185377Ssam
31185377Ssam#include "ah_osdep.h"
32185377Ssam
33185377Ssam/*
34220442Sadrian * The maximum number of TX/RX chains supported.
35220442Sadrian * This is intended to be used by various statistics gathering operations
36220442Sadrian * (NF, RSSI, EVM).
37220442Sadrian */
38220442Sadrian#define	AH_MIMO_MAX_CHAINS		3
39220442Sadrian#define	AH_MIMO_MAX_EVM_PILOTS		6
40220442Sadrian
41220442Sadrian/*
42185377Ssam * __ahdecl is analogous to _cdecl; it defines the calling
43185377Ssam * convention used within the HAL.  For most systems this
44185377Ssam * can just default to be empty and the compiler will (should)
45185377Ssam * use _cdecl.  For systems where _cdecl is not compatible this
46185377Ssam * must be defined.  See linux/ah_osdep.h for an example.
47185377Ssam */
48185377Ssam#ifndef __ahdecl
49185377Ssam#define __ahdecl
50185377Ssam#endif
51185377Ssam
52185377Ssam/*
53185377Ssam * Status codes that may be returned by the HAL.  Note that
54185377Ssam * interfaces that return a status code set it only when an
55185377Ssam * error occurs--i.e. you cannot check it for success.
56185377Ssam */
57185377Ssamtypedef enum {
58185377Ssam	HAL_OK		= 0,	/* No error */
59185377Ssam	HAL_ENXIO	= 1,	/* No hardware present */
60185377Ssam	HAL_ENOMEM	= 2,	/* Memory allocation failed */
61185377Ssam	HAL_EIO		= 3,	/* Hardware didn't respond as expected */
62185377Ssam	HAL_EEMAGIC	= 4,	/* EEPROM magic number invalid */
63185377Ssam	HAL_EEVERSION	= 5,	/* EEPROM version invalid */
64185377Ssam	HAL_EELOCKED	= 6,	/* EEPROM unreadable */
65185377Ssam	HAL_EEBADSUM	= 7,	/* EEPROM checksum invalid */
66185377Ssam	HAL_EEREAD	= 8,	/* EEPROM read problem */
67185377Ssam	HAL_EEBADMAC	= 9,	/* EEPROM mac address invalid */
68185377Ssam	HAL_EESIZE	= 10,	/* EEPROM size not supported */
69185377Ssam	HAL_EEWRITE	= 11,	/* Attempt to change write-locked EEPROM */
70185377Ssam	HAL_EINVAL	= 12,	/* Invalid parameter to function */
71185377Ssam	HAL_ENOTSUPP	= 13,	/* Hardware revision not supported */
72185377Ssam	HAL_ESELFTEST	= 14,	/* Hardware self-test failed */
73185377Ssam	HAL_EINPROGRESS	= 15,	/* Operation incomplete */
74187831Ssam	HAL_EEBADREG	= 16,	/* EEPROM invalid regulatory contents */
75187831Ssam	HAL_EEBADCC	= 17,	/* EEPROM invalid country code */
76185377Ssam} HAL_STATUS;
77185377Ssam
78185377Ssamtypedef enum {
79185377Ssam	AH_FALSE = 0,		/* NB: lots of code assumes false is zero */
80185377Ssam	AH_TRUE  = 1,
81185377Ssam} HAL_BOOL;
82185377Ssam
83185377Ssamtypedef enum {
84185377Ssam	HAL_CAP_REG_DMN		= 0,	/* current regulatory domain */
85185377Ssam	HAL_CAP_CIPHER		= 1,	/* hardware supports cipher */
86185377Ssam	HAL_CAP_TKIP_MIC	= 2,	/* handle TKIP MIC in hardware */
87185377Ssam	HAL_CAP_TKIP_SPLIT	= 3,	/* hardware TKIP uses split keys */
88185377Ssam	HAL_CAP_PHYCOUNTERS	= 4,	/* hardware PHY error counters */
89185377Ssam	HAL_CAP_DIVERSITY	= 5,	/* hardware supports fast diversity */
90185377Ssam	HAL_CAP_KEYCACHE_SIZE	= 6,	/* number of entries in key cache */
91185377Ssam	HAL_CAP_NUM_TXQUEUES	= 7,	/* number of hardware xmit queues */
92185377Ssam	HAL_CAP_VEOL		= 9,	/* hardware supports virtual EOL */
93185377Ssam	HAL_CAP_PSPOLL		= 10,	/* hardware has working PS-Poll support */
94185377Ssam	HAL_CAP_DIAG		= 11,	/* hardware diagnostic support */
95185377Ssam	HAL_CAP_COMPRESSION	= 12,	/* hardware supports compression */
96185377Ssam	HAL_CAP_BURST		= 13,	/* hardware supports packet bursting */
97185377Ssam	HAL_CAP_FASTFRAME	= 14,	/* hardware supoprts fast frames */
98185377Ssam	HAL_CAP_TXPOW		= 15,	/* global tx power limit  */
99185377Ssam	HAL_CAP_TPC		= 16,	/* per-packet tx power control  */
100185377Ssam	HAL_CAP_PHYDIAG		= 17,	/* hardware phy error diagnostic */
101185377Ssam	HAL_CAP_BSSIDMASK	= 18,	/* hardware supports bssid mask */
102185377Ssam	HAL_CAP_MCAST_KEYSRCH	= 19,	/* hardware has multicast key search */
103185377Ssam	HAL_CAP_TSF_ADJUST	= 20,	/* hardware has beacon tsf adjust */
104185377Ssam	/* 21 was HAL_CAP_XR */
105185377Ssam	HAL_CAP_WME_TKIPMIC 	= 22,   /* hardware can support TKIP MIC when WMM is turned on */
106185380Ssam	/* 23 was HAL_CAP_CHAN_HALFRATE */
107185380Ssam	/* 24 was HAL_CAP_CHAN_QUARTERRATE */
108185377Ssam	HAL_CAP_RFSILENT	= 25,	/* hardware has rfsilent support  */
109185377Ssam	HAL_CAP_TPC_ACK		= 26,	/* ack txpower with per-packet tpc */
110185377Ssam	HAL_CAP_TPC_CTS		= 27,	/* cts txpower with per-packet tpc */
111185377Ssam	HAL_CAP_11D		= 28,   /* 11d beacon support for changing cc */
112221581Sadrian
113221603Sadrian	HAL_CAP_HT		= 30,   /* hardware can support HT */
114221603Sadrian	HAL_CAP_GTXTO		= 31,	/* hardware supports global tx timeout */
115221603Sadrian	HAL_CAP_FAST_CC		= 32,	/* hardware supports fast channel change */
116221603Sadrian	HAL_CAP_TX_CHAINMASK	= 33,	/* mask of TX chains supported */
117221603Sadrian	HAL_CAP_RX_CHAINMASK	= 34,	/* mask of RX chains supported */
118221603Sadrian	HAL_CAP_NUM_GPIO_PINS	= 36,	/* number of GPIO pins */
119221581Sadrian
120221603Sadrian	HAL_CAP_CST		= 38,	/* hardware supports carrier sense timeout */
121221581Sadrian
122221603Sadrian	HAL_CAP_RTS_AGGR_LIMIT	= 42,	/* aggregation limit with RTS */
123221603Sadrian	HAL_CAP_4ADDR_AGGR	= 43,	/* hardware is capable of 4addr aggregation */
124222584Sadrian	HAL_CAP_DFS_DMN		= 44,	/* current DFS domain */
125222584Sadrian	HAL_CAP_EXT_CHAN_DFS	= 45,	/* DFS support for extension channel */
126222584Sadrian	HAL_CAP_COMBINED_RADAR_RSSI	= 46,	/* Is combined RSSI for radar accurate */
127221603Sadrian
128221603Sadrian	HAL_CAP_AUTO_SLEEP	= 48,	/* hardware can go to network sleep
129221603Sadrian					   automatically after waking up to receive TIM */
130221603Sadrian	HAL_CAP_MBSSID_AGGR_SUPPORT	= 49, /* Support for mBSSID Aggregation */
131221603Sadrian	HAL_CAP_SPLIT_4KB_TRANS	= 50,	/* hardware supports descriptors straddling a 4k page boundary */
132221603Sadrian	HAL_CAP_REG_FLAG	= 51,	/* Regulatory domain flags */
133221603Sadrian
134221603Sadrian	HAL_CAP_BT_COEX		= 60,	/* hardware is capable of bluetooth coexistence */
135221603Sadrian
136221603Sadrian	HAL_CAP_HT20_SGI	= 96,	/* hardware supports HT20 short GI */
137221603Sadrian
138221603Sadrian	HAL_CAP_RXTSTAMP_PREC	= 100,	/* rx desc tstamp precision (bits) */
139222584Sadrian	HAL_CAP_ENHANCED_DFS_SUPPORT	= 117,	/* hardware supports enhanced DFS */
140221603Sadrian
141221581Sadrian	/* The following are private to the FreeBSD HAL (224 onward) */
142221581Sadrian
143221603Sadrian	HAL_CAP_INTMIT		= 229,	/* interference mitigation */
144221603Sadrian	HAL_CAP_RXORN_FATAL	= 230,	/* HAL_INT_RXORN treated as fatal */
145221603Sadrian	HAL_CAP_BB_HANG		= 235,	/* can baseband hang */
146221603Sadrian	HAL_CAP_MAC_HANG	= 236,	/* can MAC hang */
147221603Sadrian	HAL_CAP_INTRMASK	= 237,	/* bitmask of supported interrupts */
148221603Sadrian	HAL_CAP_BSSIDMATCH	= 238,	/* hardware has disable bssid match */
149221603Sadrian	HAL_CAP_STREAMS		= 239,	/* how many 802.11n spatial streams are available */
150221603Sadrian	HAL_CAP_RXDESC_SELFLINK	= 242,	/* support a self-linked tail RX descriptor */
151225444Sadrian	HAL_CAP_LONG_RXDESC_TSF	= 243,	/* hardware supports 32bit TSF in RX descriptor */
152226488Sadrian	HAL_CAP_BB_READ_WAR	= 244,	/* baseband read WAR */
153227410Sadrian	HAL_CAP_SERIALISE_WAR	= 245,	/* serialise register access on PCI */
154185377Ssam} HAL_CAPABILITY_TYPE;
155185377Ssam
156185377Ssam/*
157185377Ssam * "States" for setting the LED.  These correspond to
158185377Ssam * the possible 802.11 operational states and there may
159185377Ssam * be a many-to-one mapping between these states and the
160185377Ssam * actual hardware state for the LED's (i.e. the hardware
161185377Ssam * may have fewer states).
162185377Ssam */
163185377Ssamtypedef enum {
164185377Ssam	HAL_LED_INIT	= 0,
165185377Ssam	HAL_LED_SCAN	= 1,
166185377Ssam	HAL_LED_AUTH	= 2,
167185377Ssam	HAL_LED_ASSOC	= 3,
168185377Ssam	HAL_LED_RUN	= 4
169185377Ssam} HAL_LED_STATE;
170185377Ssam
171185377Ssam/*
172185377Ssam * Transmit queue types/numbers.  These are used to tag
173185377Ssam * each transmit queue in the hardware and to identify a set
174185377Ssam * of transmit queues for operations such as start/stop dma.
175185377Ssam */
176185377Ssamtypedef enum {
177185377Ssam	HAL_TX_QUEUE_INACTIVE	= 0,		/* queue is inactive/unused */
178185377Ssam	HAL_TX_QUEUE_DATA	= 1,		/* data xmit q's */
179185377Ssam	HAL_TX_QUEUE_BEACON	= 2,		/* beacon xmit q */
180185377Ssam	HAL_TX_QUEUE_CAB	= 3,		/* "crap after beacon" xmit q */
181185377Ssam	HAL_TX_QUEUE_UAPSD	= 4,		/* u-apsd power save xmit q */
182219790Sadrian	HAL_TX_QUEUE_PSPOLL	= 5,		/* power save poll xmit q */
183185377Ssam} HAL_TX_QUEUE;
184185377Ssam
185185377Ssam#define	HAL_NUM_TX_QUEUES	10		/* max possible # of queues */
186185377Ssam
187185377Ssam/*
188185377Ssam * Transmit queue subtype.  These map directly to
189185377Ssam * WME Access Categories (except for UPSD).  Refer
190185377Ssam * to Table 5 of the WME spec.
191185377Ssam */
192185377Ssamtypedef enum {
193185377Ssam	HAL_WME_AC_BK	= 0,			/* background access category */
194185377Ssam	HAL_WME_AC_BE	= 1, 			/* best effort access category*/
195185377Ssam	HAL_WME_AC_VI	= 2,			/* video access category */
196185377Ssam	HAL_WME_AC_VO	= 3,			/* voice access category */
197185377Ssam	HAL_WME_UPSD	= 4,			/* uplink power save */
198185377Ssam} HAL_TX_QUEUE_SUBTYPE;
199185377Ssam
200185377Ssam/*
201185377Ssam * Transmit queue flags that control various
202185377Ssam * operational parameters.
203185377Ssam */
204185377Ssamtypedef enum {
205185377Ssam	/*
206185377Ssam	 * Per queue interrupt enables.  When set the associated
207185377Ssam	 * interrupt may be delivered for packets sent through
208185377Ssam	 * the queue.  Without these enabled no interrupts will
209185377Ssam	 * be delivered for transmits through the queue.
210185377Ssam	 */
211185377Ssam	HAL_TXQ_TXOKINT_ENABLE	   = 0x0001,	/* enable TXOK interrupt */
212185377Ssam	HAL_TXQ_TXERRINT_ENABLE	   = 0x0001,	/* enable TXERR interrupt */
213185377Ssam	HAL_TXQ_TXDESCINT_ENABLE   = 0x0002,	/* enable TXDESC interrupt */
214185377Ssam	HAL_TXQ_TXEOLINT_ENABLE	   = 0x0004,	/* enable TXEOL interrupt */
215185377Ssam	HAL_TXQ_TXURNINT_ENABLE	   = 0x0008,	/* enable TXURN interrupt */
216185377Ssam	/*
217185377Ssam	 * Enable hardware compression for packets sent through
218185377Ssam	 * the queue.  The compression buffer must be setup and
219185377Ssam	 * packets must have a key entry marked in the tx descriptor.
220185377Ssam	 */
221185377Ssam	HAL_TXQ_COMPRESSION_ENABLE  = 0x0010,	/* enable h/w compression */
222185377Ssam	/*
223185377Ssam	 * Disable queue when veol is hit or ready time expires.
224185377Ssam	 * By default the queue is disabled only on reaching the
225185377Ssam	 * physical end of queue (i.e. a null link ptr in the
226185377Ssam	 * descriptor chain).
227185377Ssam	 */
228185377Ssam	HAL_TXQ_RDYTIME_EXP_POLICY_ENABLE = 0x0020,
229185377Ssam	/*
230185377Ssam	 * Schedule frames on delivery of a DBA (DMA Beacon Alert)
231185377Ssam	 * event.  Frames will be transmitted only when this timer
232185377Ssam	 * fires, e.g to transmit a beacon in ap or adhoc modes.
233185377Ssam	 */
234185377Ssam	HAL_TXQ_DBA_GATED	    = 0x0040,	/* schedule based on DBA */
235185377Ssam	/*
236185377Ssam	 * Each transmit queue has a counter that is incremented
237185377Ssam	 * each time the queue is enabled and decremented when
238185377Ssam	 * the list of frames to transmit is traversed (or when
239185377Ssam	 * the ready time for the queue expires).  This counter
240185377Ssam	 * must be non-zero for frames to be scheduled for
241185377Ssam	 * transmission.  The following controls disable bumping
242185377Ssam	 * this counter under certain conditions.  Typically this
243185377Ssam	 * is used to gate frames based on the contents of another
244185377Ssam	 * queue (e.g. CAB traffic may only follow a beacon frame).
245185377Ssam	 * These are meaningful only when frames are scheduled
246185377Ssam	 * with a non-ASAP policy (e.g. DBA-gated).
247185377Ssam	 */
248185377Ssam	HAL_TXQ_CBR_DIS_QEMPTY	    = 0x0080,	/* disable on this q empty */
249185377Ssam	HAL_TXQ_CBR_DIS_BEMPTY	    = 0x0100,	/* disable on beacon q empty */
250185377Ssam
251185377Ssam	/*
252185377Ssam	 * Fragment burst backoff policy.  Normally the no backoff
253185377Ssam	 * is done after a successful transmission, the next fragment
254185377Ssam	 * is sent at SIFS.  If this flag is set backoff is done
255185377Ssam	 * after each fragment, regardless whether it was ack'd or
256185377Ssam	 * not, after the backoff count reaches zero a normal channel
257185377Ssam	 * access procedure is done before the next transmit (i.e.
258185377Ssam	 * wait AIFS instead of SIFS).
259185377Ssam	 */
260185377Ssam	HAL_TXQ_FRAG_BURST_BACKOFF_ENABLE = 0x00800000,
261185377Ssam	/*
262185377Ssam	 * Disable post-tx backoff following each frame.
263185377Ssam	 */
264185377Ssam	HAL_TXQ_BACKOFF_DISABLE	    = 0x00010000, /* disable post backoff  */
265185377Ssam	/*
266185377Ssam	 * DCU arbiter lockout control.  This controls how
267185377Ssam	 * lower priority tx queues are handled with respect to
268185377Ssam	 * to a specific queue when multiple queues have frames
269185377Ssam	 * to send.  No lockout means lower priority queues arbitrate
270185377Ssam	 * concurrently with this queue.  Intra-frame lockout
271185377Ssam	 * means lower priority queues are locked out until the
272185377Ssam	 * current frame transmits (e.g. including backoffs and bursting).
273185377Ssam	 * Global lockout means nothing lower can arbitrary so
274185377Ssam	 * long as there is traffic activity on this queue (frames,
275185377Ssam	 * backoff, etc).
276185377Ssam	 */
277185377Ssam	HAL_TXQ_ARB_LOCKOUT_INTRA   = 0x00020000, /* intra-frame lockout */
278185377Ssam	HAL_TXQ_ARB_LOCKOUT_GLOBAL  = 0x00040000, /* full lockout s */
279185377Ssam
280185377Ssam	HAL_TXQ_IGNORE_VIRTCOL	    = 0x00080000, /* ignore virt collisions */
281185377Ssam	HAL_TXQ_SEQNUM_INC_DIS	    = 0x00100000, /* disable seqnum increment */
282185377Ssam} HAL_TX_QUEUE_FLAGS;
283185377Ssam
284185377Ssamtypedef struct {
285185377Ssam	uint32_t	tqi_ver;		/* hal TXQ version */
286185377Ssam	HAL_TX_QUEUE_SUBTYPE tqi_subtype;	/* subtype if applicable */
287185377Ssam	HAL_TX_QUEUE_FLAGS tqi_qflags;		/* flags (see above) */
288185377Ssam	uint32_t	tqi_priority;		/* (not used) */
289185377Ssam	uint32_t	tqi_aifs;		/* aifs */
290185377Ssam	uint32_t	tqi_cwmin;		/* cwMin */
291185377Ssam	uint32_t	tqi_cwmax;		/* cwMax */
292185377Ssam	uint16_t	tqi_shretry;		/* rts retry limit */
293185377Ssam	uint16_t	tqi_lgretry;		/* long retry limit (not used)*/
294185377Ssam	uint32_t	tqi_cbrPeriod;		/* CBR period (us) */
295185377Ssam	uint32_t	tqi_cbrOverflowLimit;	/* threshold for CBROVF int */
296185377Ssam	uint32_t	tqi_burstTime;		/* max burst duration (us) */
297185377Ssam	uint32_t	tqi_readyTime;		/* frame schedule time (us) */
298185377Ssam	uint32_t	tqi_compBuf;		/* comp buffer phys addr */
299185377Ssam} HAL_TXQ_INFO;
300185377Ssam
301185377Ssam#define HAL_TQI_NONVAL 0xffff
302185377Ssam
303185377Ssam/* token to use for aifs, cwmin, cwmax */
304185377Ssam#define	HAL_TXQ_USEDEFAULT	((uint32_t) -1)
305185377Ssam
306185377Ssam/* compression definitions */
307185377Ssam#define HAL_COMP_BUF_MAX_SIZE           9216            /* 9K */
308185377Ssam#define HAL_COMP_BUF_ALIGN_SIZE         512
309185377Ssam
310185377Ssam/*
311185377Ssam * Transmit packet types.  This belongs in ah_desc.h, but
312185377Ssam * is here so we can give a proper type to various parameters
313185377Ssam * (and not require everyone include the file).
314185377Ssam *
315185377Ssam * NB: These values are intentionally assigned for
316185377Ssam *     direct use when setting up h/w descriptors.
317185377Ssam */
318185377Ssamtypedef enum {
319185377Ssam	HAL_PKT_TYPE_NORMAL	= 0,
320185377Ssam	HAL_PKT_TYPE_ATIM	= 1,
321185377Ssam	HAL_PKT_TYPE_PSPOLL	= 2,
322185377Ssam	HAL_PKT_TYPE_BEACON	= 3,
323185377Ssam	HAL_PKT_TYPE_PROBE_RESP	= 4,
324185377Ssam	HAL_PKT_TYPE_CHIRP	= 5,
325185377Ssam	HAL_PKT_TYPE_GRP_POLL	= 6,
326185377Ssam	HAL_PKT_TYPE_AMPDU	= 7,
327185377Ssam} HAL_PKT_TYPE;
328185377Ssam
329185377Ssam/* Rx Filter Frame Types */
330185377Ssamtypedef enum {
331220022Sadrian	/*
332220022Sadrian	 * These bits correspond to AR_RX_FILTER for all chips.
333220022Sadrian	 * Not all bits are supported by all chips.
334220022Sadrian	 */
335185377Ssam	HAL_RX_FILTER_UCAST	= 0x00000001,	/* Allow unicast frames */
336185377Ssam	HAL_RX_FILTER_MCAST	= 0x00000002,	/* Allow multicast frames */
337185377Ssam	HAL_RX_FILTER_BCAST	= 0x00000004,	/* Allow broadcast frames */
338185377Ssam	HAL_RX_FILTER_CONTROL	= 0x00000008,	/* Allow control frames */
339185377Ssam	HAL_RX_FILTER_BEACON	= 0x00000010,	/* Allow beacon frames */
340185377Ssam	HAL_RX_FILTER_PROM	= 0x00000020,	/* Promiscuous mode */
341185377Ssam	HAL_RX_FILTER_PROBEREQ	= 0x00000080,	/* Allow probe request frames */
342220025Sadrian	HAL_RX_FILTER_PHYERR	= 0x00000100,	/* Allow phy errors */
343185377Ssam	HAL_RX_FILTER_COMPBAR	= 0x00000400,	/* Allow compressed BAR */
344220022Sadrian	HAL_RX_FILTER_COMP_BA	= 0x00000800,	/* Allow compressed blockack */
345220025Sadrian	HAL_RX_FILTER_PHYRADAR	= 0x00002000,	/* Allow phy radar errors */
346220022Sadrian	HAL_RX_FILTER_PSPOLL	= 0x00004000,	/* Allow PS-POLL frames */
347220022Sadrian	HAL_RX_FILTER_MCAST_BCAST_ALL	= 0x00008000,
348220022Sadrian						/* Allow all mcast/bcast frames */
349220022Sadrian
350220022Sadrian	/*
351220022Sadrian	 * Magic RX filter flags that aren't targetting hardware bits
352220022Sadrian	 * but instead the HAL sets individual bits - eg PHYERR will result
353220022Sadrian	 * in OFDM/CCK timing error frames being received.
354220022Sadrian	 */
355220022Sadrian	HAL_RX_FILTER_BSSID	= 0x40000000,	/* Disable BSSID match */
356185377Ssam} HAL_RX_FILTER;
357185377Ssam
358185377Ssamtypedef enum {
359185377Ssam	HAL_PM_AWAKE		= 0,
360185377Ssam	HAL_PM_FULL_SLEEP	= 1,
361185377Ssam	HAL_PM_NETWORK_SLEEP	= 2,
362185377Ssam	HAL_PM_UNDEFINED	= 3
363185377Ssam} HAL_POWER_MODE;
364185377Ssam
365185377Ssam/*
366185377Ssam * NOTE WELL:
367185377Ssam * These are mapped to take advantage of the common locations for many of
368185377Ssam * the bits on all of the currently supported MAC chips. This is to make
369185377Ssam * the ISR as efficient as possible, while still abstracting HW differences.
370185377Ssam * When new hardware breaks this commonality this enumerated type, as well
371185377Ssam * as the HAL functions using it, must be modified. All values are directly
372185377Ssam * mapped unless commented otherwise.
373185377Ssam */
374185377Ssamtypedef enum {
375185377Ssam	HAL_INT_RX	= 0x00000001,	/* Non-common mapping */
376185377Ssam	HAL_INT_RXDESC	= 0x00000002,
377185377Ssam	HAL_INT_RXNOFRM	= 0x00000008,
378185377Ssam	HAL_INT_RXEOL	= 0x00000010,
379185377Ssam	HAL_INT_RXORN	= 0x00000020,
380185377Ssam	HAL_INT_TX	= 0x00000040,	/* Non-common mapping */
381185377Ssam	HAL_INT_TXDESC	= 0x00000080,
382208711Srpaulo	HAL_INT_TIM_TIMER= 0x00000100,
383185377Ssam	HAL_INT_TXURN	= 0x00000800,
384185377Ssam	HAL_INT_MIB	= 0x00001000,
385185377Ssam	HAL_INT_RXPHY	= 0x00004000,
386185377Ssam	HAL_INT_RXKCM	= 0x00008000,
387185377Ssam	HAL_INT_SWBA	= 0x00010000,
388185377Ssam	HAL_INT_BMISS	= 0x00040000,
389192401Ssam	HAL_INT_BNR	= 0x00100000,
390185377Ssam	HAL_INT_TIM	= 0x00200000,	/* Non-common mapping */
391185377Ssam	HAL_INT_DTIM	= 0x00400000,	/* Non-common mapping */
392185377Ssam	HAL_INT_DTIMSYNC= 0x00800000,	/* Non-common mapping */
393185377Ssam	HAL_INT_GPIO	= 0x01000000,
394185377Ssam	HAL_INT_CABEND	= 0x02000000,	/* Non-common mapping */
395185377Ssam	HAL_INT_TSFOOR	= 0x04000000,	/* Non-common mapping */
396192400Ssam	HAL_INT_TBTT	= 0x08000000,	/* Non-common mapping */
397185377Ssam	HAL_INT_CST	= 0x10000000,	/* Non-common mapping */
398185377Ssam	HAL_INT_GTT	= 0x20000000,	/* Non-common mapping */
399185377Ssam	HAL_INT_FATAL	= 0x40000000,	/* Non-common mapping */
400185377Ssam#define	HAL_INT_GLOBAL	0x80000000	/* Set/clear IER */
401185377Ssam	HAL_INT_BMISC	= HAL_INT_TIM
402185377Ssam			| HAL_INT_DTIM
403185377Ssam			| HAL_INT_DTIMSYNC
404192400Ssam			| HAL_INT_CABEND
405192400Ssam			| HAL_INT_TBTT,
406185377Ssam
407185377Ssam	/* Interrupt bits that map directly to ISR/IMR bits */
408185377Ssam	HAL_INT_COMMON  = HAL_INT_RXNOFRM
409185377Ssam			| HAL_INT_RXDESC
410185377Ssam			| HAL_INT_RXEOL
411185377Ssam			| HAL_INT_RXORN
412192396Ssam			| HAL_INT_TXDESC
413185377Ssam			| HAL_INT_TXURN
414185377Ssam			| HAL_INT_MIB
415185377Ssam			| HAL_INT_RXPHY
416185377Ssam			| HAL_INT_RXKCM
417185377Ssam			| HAL_INT_SWBA
418185377Ssam			| HAL_INT_BMISS
419192397Ssam			| HAL_INT_BNR
420185377Ssam			| HAL_INT_GPIO,
421185377Ssam} HAL_INT;
422185377Ssam
423185377Ssamtypedef enum {
424188974Ssam	HAL_GPIO_MUX_OUTPUT		= 0,
425188974Ssam	HAL_GPIO_MUX_PCIE_ATTENTION_LED	= 1,
426188974Ssam	HAL_GPIO_MUX_PCIE_POWER_LED	= 2,
427188974Ssam	HAL_GPIO_MUX_TX_FRAME		= 3,
428188974Ssam	HAL_GPIO_MUX_RX_CLEAR_EXTERNAL	= 4,
429188974Ssam	HAL_GPIO_MUX_MAC_NETWORK_LED	= 5,
430188974Ssam	HAL_GPIO_MUX_MAC_POWER_LED	= 6
431188974Ssam} HAL_GPIO_MUX_TYPE;
432188974Ssam
433188974Ssamtypedef enum {
434188974Ssam	HAL_GPIO_INTR_LOW		= 0,
435188974Ssam	HAL_GPIO_INTR_HIGH		= 1,
436188974Ssam	HAL_GPIO_INTR_DISABLE		= 2
437188974Ssam} HAL_GPIO_INTR_TYPE;
438188974Ssam
439188974Ssamtypedef enum {
440185377Ssam	HAL_RFGAIN_INACTIVE		= 0,
441185377Ssam	HAL_RFGAIN_READ_REQUESTED	= 1,
442185377Ssam	HAL_RFGAIN_NEED_CHANGE		= 2
443185377Ssam} HAL_RFGAIN;
444185377Ssam
445187831Ssamtypedef uint16_t HAL_CTRY_CODE;		/* country code */
446187831Ssamtypedef uint16_t HAL_REG_DOMAIN;		/* regulatory domain code */
447185377Ssam
448185377Ssam#define HAL_ANTENNA_MIN_MODE  0
449185377Ssam#define HAL_ANTENNA_FIXED_A   1
450185377Ssam#define HAL_ANTENNA_FIXED_B   2
451185377Ssam#define HAL_ANTENNA_MAX_MODE  3
452185377Ssam
453185377Ssamtypedef struct {
454185377Ssam	uint32_t	ackrcv_bad;
455185377Ssam	uint32_t	rts_bad;
456185377Ssam	uint32_t	rts_good;
457185377Ssam	uint32_t	fcs_bad;
458185377Ssam	uint32_t	beacons;
459185377Ssam} HAL_MIB_STATS;
460185377Ssam
461185377Ssamenum {
462185377Ssam	HAL_MODE_11A	= 0x001,		/* 11a channels */
463185377Ssam	HAL_MODE_TURBO	= 0x002,		/* 11a turbo-only channels */
464185377Ssam	HAL_MODE_11B	= 0x004,		/* 11b channels */
465185377Ssam	HAL_MODE_PUREG	= 0x008,		/* 11g channels (OFDM only) */
466185377Ssam#ifdef notdef
467185377Ssam	HAL_MODE_11G	= 0x010,		/* 11g channels (OFDM/CCK) */
468185377Ssam#else
469185377Ssam	HAL_MODE_11G	= 0x008,		/* XXX historical */
470185377Ssam#endif
471185377Ssam	HAL_MODE_108G	= 0x020,		/* 11g+Turbo channels */
472185377Ssam	HAL_MODE_108A	= 0x040,		/* 11a+Turbo channels */
473185380Ssam	HAL_MODE_11A_HALF_RATE = 0x200,		/* 11a half width channels */
474185380Ssam	HAL_MODE_11A_QUARTER_RATE = 0x400,	/* 11a quarter width channels */
475185380Ssam	HAL_MODE_11G_HALF_RATE = 0x800,		/* 11g half width channels */
476185380Ssam	HAL_MODE_11G_QUARTER_RATE = 0x1000,	/* 11g quarter width channels */
477185377Ssam	HAL_MODE_11NG_HT20	= 0x008000,
478185377Ssam	HAL_MODE_11NA_HT20  	= 0x010000,
479185377Ssam	HAL_MODE_11NG_HT40PLUS	= 0x020000,
480185377Ssam	HAL_MODE_11NG_HT40MINUS	= 0x040000,
481185377Ssam	HAL_MODE_11NA_HT40PLUS	= 0x080000,
482185377Ssam	HAL_MODE_11NA_HT40MINUS	= 0x100000,
483185377Ssam	HAL_MODE_ALL	= 0xffffff
484185377Ssam};
485185377Ssam
486185377Ssamtypedef struct {
487185377Ssam	int		rateCount;		/* NB: for proper padding */
488185377Ssam	uint8_t		rateCodeToIndex[144];	/* back mapping */
489185377Ssam	struct {
490188770Ssam		uint8_t		valid;		/* valid for rate control use */
491188770Ssam		uint8_t		phy;		/* CCK/OFDM/XR */
492185377Ssam		uint32_t	rateKbps;	/* transfer rate in kbs */
493185377Ssam		uint8_t		rateCode;	/* rate for h/w descriptors */
494185377Ssam		uint8_t		shortPreamble;	/* mask for enabling short
495185377Ssam						 * preamble in CCK rate code */
496185377Ssam		uint8_t		dot11Rate;	/* value for supported rates
497185377Ssam						 * info element of MLME */
498185377Ssam		uint8_t		controlRate;	/* index of next lower basic
499185377Ssam						 * rate; used for dur. calcs */
500185377Ssam		uint16_t	lpAckDuration;	/* long preamble ACK duration */
501185377Ssam		uint16_t	spAckDuration;	/* short preamble ACK duration*/
502185377Ssam	} info[32];
503185377Ssam} HAL_RATE_TABLE;
504185377Ssam
505185377Ssamtypedef struct {
506185377Ssam	u_int		rs_count;		/* number of valid entries */
507185377Ssam	uint8_t	rs_rates[32];		/* rates */
508185377Ssam} HAL_RATE_SET;
509185377Ssam
510185377Ssam/*
511185377Ssam * 802.11n specific structures and enums
512185377Ssam */
513185377Ssamtypedef enum {
514185377Ssam	HAL_CHAINTYPE_TX	= 1,	/* Tx chain type */
515185377Ssam	HAL_CHAINTYPE_RX	= 2,	/* RX chain type */
516185377Ssam} HAL_CHAIN_TYPE;
517185377Ssam
518185377Ssamtypedef struct {
519185377Ssam	u_int	Tries;
520185377Ssam	u_int	Rate;
521185377Ssam	u_int	PktDuration;
522185377Ssam	u_int	ChSel;
523185377Ssam	u_int	RateFlags;
524185377Ssam#define	HAL_RATESERIES_RTS_CTS		0x0001	/* use rts/cts w/this series */
525185377Ssam#define	HAL_RATESERIES_2040		0x0002	/* use ext channel for series */
526185377Ssam#define	HAL_RATESERIES_HALFGI		0x0004	/* use half-gi for series */
527185377Ssam} HAL_11N_RATE_SERIES;
528185377Ssam
529185377Ssamtypedef enum {
530185377Ssam	HAL_HT_MACMODE_20	= 0,	/* 20 MHz operation */
531185377Ssam	HAL_HT_MACMODE_2040	= 1,	/* 20/40 MHz operation */
532185377Ssam} HAL_HT_MACMODE;
533185377Ssam
534185377Ssamtypedef enum {
535185377Ssam	HAL_HT_PHYMODE_20	= 0,	/* 20 MHz operation */
536185377Ssam	HAL_HT_PHYMODE_2040	= 1,	/* 20/40 MHz operation */
537185377Ssam} HAL_HT_PHYMODE;
538185377Ssam
539185377Ssamtypedef enum {
540185377Ssam	HAL_HT_EXTPROTSPACING_20 = 0,	/* 20 MHz spacing */
541185377Ssam	HAL_HT_EXTPROTSPACING_25 = 1,	/* 25 MHz spacing */
542185377Ssam} HAL_HT_EXTPROTSPACING;
543185377Ssam
544185377Ssam
545185377Ssamtypedef enum {
546185377Ssam	HAL_RX_CLEAR_CTL_LOW	= 0x1,	/* force control channel to appear busy */
547185377Ssam	HAL_RX_CLEAR_EXT_LOW	= 0x2,	/* force extension channel to appear busy */
548185377Ssam} HAL_HT_RXCLEAR;
549185377Ssam
550185377Ssam/*
551185377Ssam * Antenna switch control.  By default antenna selection
552185377Ssam * enables multiple (2) antenna use.  To force use of the
553185377Ssam * A or B antenna only specify a fixed setting.  Fixing
554185377Ssam * the antenna will also disable any diversity support.
555185377Ssam */
556185377Ssamtypedef enum {
557185377Ssam	HAL_ANT_VARIABLE = 0,			/* variable by programming */
558185377Ssam	HAL_ANT_FIXED_A	 = 1,			/* fixed antenna A */
559185377Ssam	HAL_ANT_FIXED_B	 = 2,			/* fixed antenna B */
560185377Ssam} HAL_ANT_SETTING;
561185377Ssam
562185377Ssamtypedef enum {
563185377Ssam	HAL_M_STA	= 1,			/* infrastructure station */
564185377Ssam	HAL_M_IBSS	= 0,			/* IBSS (adhoc) station */
565185377Ssam	HAL_M_HOSTAP	= 6,			/* Software Access Point */
566185377Ssam	HAL_M_MONITOR	= 8			/* Monitor mode */
567185377Ssam} HAL_OPMODE;
568185377Ssam
569185377Ssamtypedef struct {
570185377Ssam	uint8_t		kv_type;		/* one of HAL_CIPHER */
571185377Ssam	uint8_t		kv_pad;
572185377Ssam	uint16_t	kv_len;			/* length in bits */
573185377Ssam	uint8_t		kv_val[16];		/* enough for 128-bit keys */
574185377Ssam	uint8_t		kv_mic[8];		/* TKIP MIC key */
575185377Ssam	uint8_t		kv_txmic[8];		/* TKIP TX MIC key (optional) */
576185377Ssam} HAL_KEYVAL;
577185377Ssam
578185377Ssamtypedef enum {
579185377Ssam	HAL_CIPHER_WEP		= 0,
580185377Ssam	HAL_CIPHER_AES_OCB	= 1,
581185377Ssam	HAL_CIPHER_AES_CCM	= 2,
582185377Ssam	HAL_CIPHER_CKIP		= 3,
583185377Ssam	HAL_CIPHER_TKIP		= 4,
584185377Ssam	HAL_CIPHER_CLR		= 5,		/* no encryption */
585185377Ssam
586185377Ssam	HAL_CIPHER_MIC		= 127		/* TKIP-MIC, not a cipher */
587185377Ssam} HAL_CIPHER;
588185377Ssam
589185377Ssamenum {
590185377Ssam	HAL_SLOT_TIME_6	 = 6,			/* NB: for turbo mode */
591185377Ssam	HAL_SLOT_TIME_9	 = 9,
592185377Ssam	HAL_SLOT_TIME_20 = 20,
593185377Ssam};
594185377Ssam
595185377Ssam/*
596185377Ssam * Per-station beacon timer state.  Note that the specified
597185377Ssam * beacon interval (given in TU's) can also include flags
598185377Ssam * to force a TSF reset and to enable the beacon xmit logic.
599185377Ssam * If bs_cfpmaxduration is non-zero the hardware is setup to
600185377Ssam * coexist with a PCF-capable AP.
601185377Ssam */
602185377Ssamtypedef struct {
603185377Ssam	uint32_t	bs_nexttbtt;		/* next beacon in TU */
604185377Ssam	uint32_t	bs_nextdtim;		/* next DTIM in TU */
605185377Ssam	uint32_t	bs_intval;		/* beacon interval+flags */
606185377Ssam#define	HAL_BEACON_PERIOD	0x0000ffff	/* beacon interval period */
607185377Ssam#define	HAL_BEACON_ENA		0x00800000	/* beacon xmit enable */
608185377Ssam#define	HAL_BEACON_RESET_TSF	0x01000000	/* clear TSF */
609185377Ssam	uint32_t	bs_dtimperiod;
610185377Ssam	uint16_t	bs_cfpperiod;		/* CFP period in TU */
611185377Ssam	uint16_t	bs_cfpmaxduration;	/* max CFP duration in TU */
612185377Ssam	uint32_t	bs_cfpnext;		/* next CFP in TU */
613185377Ssam	uint16_t	bs_timoffset;		/* byte offset to TIM bitmap */
614185377Ssam	uint16_t	bs_bmissthreshold;	/* beacon miss threshold */
615185377Ssam	uint32_t	bs_sleepduration;	/* max sleep duration */
616185377Ssam} HAL_BEACON_STATE;
617185377Ssam
618185377Ssam/*
619185377Ssam * Like HAL_BEACON_STATE but for non-station mode setup.
620185377Ssam * NB: see above flag definitions for bt_intval.
621185377Ssam */
622185377Ssamtypedef struct {
623185377Ssam	uint32_t	bt_intval;		/* beacon interval+flags */
624185377Ssam	uint32_t	bt_nexttbtt;		/* next beacon in TU */
625185377Ssam	uint32_t	bt_nextatim;		/* next ATIM in TU */
626185377Ssam	uint32_t	bt_nextdba;		/* next DBA in 1/8th TU */
627185377Ssam	uint32_t	bt_nextswba;		/* next SWBA in 1/8th TU */
628185377Ssam	uint32_t	bt_flags;		/* timer enables */
629185377Ssam#define HAL_BEACON_TBTT_EN	0x00000001
630185377Ssam#define HAL_BEACON_DBA_EN	0x00000002
631185377Ssam#define HAL_BEACON_SWBA_EN	0x00000004
632185377Ssam} HAL_BEACON_TIMERS;
633185377Ssam
634185377Ssam/*
635185377Ssam * Per-node statistics maintained by the driver for use in
636185377Ssam * optimizing signal quality and other operational aspects.
637185377Ssam */
638185377Ssamtypedef struct {
639185377Ssam	uint32_t	ns_avgbrssi;	/* average beacon rssi */
640185377Ssam	uint32_t	ns_avgrssi;	/* average data rssi */
641185377Ssam	uint32_t	ns_avgtxrssi;	/* average tx rssi */
642185377Ssam} HAL_NODE_STATS;
643185377Ssam
644185377Ssam#define	HAL_RSSI_EP_MULTIPLIER	(1<<7)	/* pow2 to optimize out * and / */
645185377Ssam
646185377Ssamstruct ath_desc;
647185377Ssamstruct ath_tx_status;
648185377Ssamstruct ath_rx_status;
649187831Ssamstruct ieee80211_channel;
650185377Ssam
651185377Ssam/*
652219773Sadrian * This is a channel survey sample entry.
653219773Sadrian *
654219773Sadrian * The AR5212 ANI routines fill these samples. The ANI code then uses it
655219773Sadrian * when calculating listen time; it is also exported via a diagnostic
656219773Sadrian * API.
657219773Sadrian */
658219773Sadriantypedef struct {
659219773Sadrian	uint32_t        seq_num;
660219773Sadrian	uint32_t        tx_busy;
661219773Sadrian	uint32_t        rx_busy;
662219773Sadrian	uint32_t        chan_busy;
663219773Sadrian	uint32_t        cycle_count;
664219773Sadrian} HAL_SURVEY_SAMPLE;
665219773Sadrian
666219773Sadrian/*
667219773Sadrian * This provides 3.2 seconds of sample space given an
668219773Sadrian * ANI time of 1/10th of a second. This may not be enough!
669219773Sadrian */
670219773Sadrian#define	CHANNEL_SURVEY_SAMPLE_COUNT	32
671219773Sadrian
672219773Sadriantypedef struct {
673219773Sadrian	HAL_SURVEY_SAMPLE samples[CHANNEL_SURVEY_SAMPLE_COUNT];
674219773Sadrian	uint32_t cur_sample;	/* current sample in sequence */
675219773Sadrian	uint32_t cur_seq;	/* current sequence number */
676219773Sadrian} HAL_CHANNEL_SURVEY;
677219773Sadrian
678219773Sadrian/*
679222277Sadrian * ANI commands.
680222277Sadrian *
681222277Sadrian * These are used both internally and externally via the diagnostic
682222277Sadrian * API.
683222277Sadrian *
684222277Sadrian * Note that this is NOT the ANI commands being used via the INTMIT
685222277Sadrian * capability - that has a different mapping for some reason.
686222277Sadrian */
687222277Sadriantypedef enum {
688222277Sadrian	HAL_ANI_PRESENT = 0,			/* is ANI support present */
689222277Sadrian	HAL_ANI_NOISE_IMMUNITY_LEVEL = 1,	/* set level */
690222277Sadrian	HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION = 2,	/* enable/disable */
691222277Sadrian	HAL_ANI_CCK_WEAK_SIGNAL_THR = 3,	/* enable/disable */
692222277Sadrian	HAL_ANI_FIRSTEP_LEVEL = 4,		/* set level */
693222277Sadrian	HAL_ANI_SPUR_IMMUNITY_LEVEL = 5,	/* set level */
694222277Sadrian	HAL_ANI_MODE = 6,			/* 0 => manual, 1 => auto (XXX do not change) */
695222277Sadrian	HAL_ANI_PHYERR_RESET = 7,		/* reset phy error stats */
696222277Sadrian} HAL_ANI_CMD;
697222277Sadrian
698222277Sadrian/*
699222277Sadrian * This is the layout of the ANI INTMIT capability.
700222277Sadrian *
701222277Sadrian * Notice that the command values differ to HAL_ANI_CMD.
702222277Sadrian */
703222277Sadriantypedef enum {
704222277Sadrian	HAL_CAP_INTMIT_PRESENT = 0,
705222277Sadrian	HAL_CAP_INTMIT_ENABLE = 1,
706222277Sadrian	HAL_CAP_INTMIT_NOISE_IMMUNITY_LEVEL = 2,
707222277Sadrian	HAL_CAP_INTMIT_OFDM_WEAK_SIGNAL_LEVEL = 3,
708222277Sadrian	HAL_CAP_INTMIT_CCK_WEAK_SIGNAL_THR = 4,
709222277Sadrian	HAL_CAP_INTMIT_FIRSTEP_LEVEL = 5,
710222277Sadrian	HAL_CAP_INTMIT_SPUR_IMMUNITY_LEVEL = 6
711222277Sadrian} HAL_CAP_INTMIT_CMD;
712222277Sadrian
713222584Sadriantypedef struct {
714222584Sadrian	int32_t		pe_firpwr;	/* FIR pwr out threshold */
715222584Sadrian	int32_t		pe_rrssi;	/* Radar rssi thresh */
716222584Sadrian	int32_t		pe_height;	/* Pulse height thresh */
717222584Sadrian	int32_t		pe_prssi;	/* Pulse rssi thresh */
718222584Sadrian	int32_t		pe_inband;	/* Inband thresh */
719222584Sadrian
720222584Sadrian	/* The following params are only for AR5413 and later */
721222584Sadrian	u_int32_t	pe_relpwr;	/* Relative power threshold in 0.5dB steps */
722222584Sadrian	u_int32_t	pe_relstep;	/* Pulse Relative step threshold in 0.5dB steps */
723222584Sadrian	u_int32_t	pe_maxlen;	/* Max length of radar sign in 0.8us units */
724224244Sadrian	int32_t		pe_usefir128;	/* Use the average in-band power measured over 128 cycles */
725224244Sadrian	int32_t		pe_blockradar;	/*
726222584Sadrian					 * Enable to block radar check if pkt detect is done via OFDM
727222584Sadrian					 * weak signal detect or pkt is detected immediately after tx
728222584Sadrian					 * to rx transition
729222584Sadrian					 */
730224244Sadrian	int32_t		pe_enmaxrssi;	/*
731222584Sadrian					 * Enable to use the max rssi instead of the last rssi during
732222584Sadrian					 * fine gain changes for radar detection
733222584Sadrian					 */
734224244Sadrian	int32_t		pe_extchannel;	/* Enable DFS on ext channel */
735224244Sadrian	int32_t		pe_enabled;	/* Whether radar detection is enabled */
736231708Sadrian	int32_t		pe_enrelpwr;
737231708Sadrian	int32_t		pe_en_relstep_check;
738222584Sadrian} HAL_PHYERR_PARAM;
739222584Sadrian
740222584Sadrian#define	HAL_PHYERR_PARAM_NOVAL	65535
741222584Sadrian
742224716Sadrian/*
743224716Sadrian * DFS operating mode flags.
744224716Sadrian */
745224716Sadriantypedef enum {
746224716Sadrian	HAL_DFS_UNINIT_DOMAIN	= 0,	/* Uninitialized dfs domain */
747224716Sadrian	HAL_DFS_FCC_DOMAIN	= 1,	/* FCC3 dfs domain */
748224716Sadrian	HAL_DFS_ETSI_DOMAIN	= 2,	/* ETSI dfs domain */
749224716Sadrian	HAL_DFS_MKK4_DOMAIN	= 3,	/* Japan dfs domain */
750224716Sadrian} HAL_DFS_DOMAIN;
751222584Sadrian
752222277Sadrian/*
753222644Sadrian * Flag for setting QUIET period
754222644Sadrian */
755222644Sadriantypedef enum {
756222644Sadrian	HAL_QUIET_DISABLE		= 0x0,
757222644Sadrian	HAL_QUIET_ENABLE		= 0x1,
758222644Sadrian	HAL_QUIET_ADD_CURRENT_TSF	= 0x2,	/* add current TSF to next_start offset */
759222644Sadrian	HAL_QUIET_ADD_SWBA_RESP_TIME	= 0x4,	/* add beacon response time to next_start offset */
760222644Sadrian} HAL_QUIET_FLAG;
761222644Sadrian
762222815Sadrian#define	HAL_DFS_EVENT_PRICH		0x0000001
763224539Sadrian#define	HAL_DFS_EVENT_EXTCH		0x0000002
764224539Sadrian#define	HAL_DFS_EVENT_EXTEARLY		0x0000004
765224539Sadrian#define	HAL_DFS_EVENT_ISDC		0x0000008
766222815Sadrian
767224633Sadrianstruct hal_dfs_event {
768222815Sadrian	uint64_t	re_full_ts;	/* 64-bit full timestamp from interrupt time */
769222815Sadrian	uint32_t	re_ts;		/* Original 15 bit recv timestamp */
770222815Sadrian	uint8_t		re_rssi;	/* rssi of radar event */
771222815Sadrian	uint8_t		re_dur;		/* duration of radar pulse */
772222815Sadrian	uint32_t	re_flags;	/* Flags (see above) */
773222815Sadrian};
774224633Sadriantypedef struct hal_dfs_event HAL_DFS_EVENT;
775222815Sadrian
776223459Sadriantypedef struct
777223459Sadrian{
778223459Sadrian	int ah_debug;			/* only used if AH_DEBUG is defined */
779223459Sadrian	int ah_ar5416_biasadj;		/* enable AR2133 radio specific bias fiddling */
780223459Sadrian
781223459Sadrian	/* NB: these are deprecated; they exist for now for compatibility */
782223459Sadrian	int ah_dma_beacon_response_time;/* in TU's */
783223459Sadrian	int ah_sw_beacon_response_time;	/* in TU's */
784223459Sadrian	int ah_additional_swba_backoff;	/* in TU's */
785227375Sadrian	int ah_force_full_reset;	/* force full chip reset rather then warm reset */
786227410Sadrian	int ah_serialise_reg_war;	/* force serialisation of register IO */
787224633Sadrian} HAL_OPS_CONFIG;
788223459Sadrian
789222644Sadrian/*
790185377Ssam * Hardware Access Layer (HAL) API.
791185377Ssam *
792185377Ssam * Clients of the HAL call ath_hal_attach to obtain a reference to an
793185377Ssam * ath_hal structure for use with the device.  Hardware-related operations
794185377Ssam * that follow must call back into the HAL through interface, supplying
795185377Ssam * the reference as the first parameter.  Note that before using the
796185377Ssam * reference returned by ath_hal_attach the caller should verify the
797185377Ssam * ABI version number.
798185377Ssam */
799185377Ssamstruct ath_hal {
800185377Ssam	uint32_t	ah_magic;	/* consistency check magic number */
801185377Ssam	uint16_t	ah_devid;	/* PCI device ID */
802185377Ssam	uint16_t	ah_subvendorid;	/* PCI subvendor ID */
803185377Ssam	HAL_SOFTC	ah_sc;		/* back pointer to driver/os state */
804185377Ssam	HAL_BUS_TAG	ah_st;		/* params for register r+w */
805185377Ssam	HAL_BUS_HANDLE	ah_sh;
806185377Ssam	HAL_CTRY_CODE	ah_countryCode;
807185377Ssam
808185377Ssam	uint32_t	ah_macVersion;	/* MAC version id */
809185377Ssam	uint16_t	ah_macRev;	/* MAC revision */
810185377Ssam	uint16_t	ah_phyRev;	/* PHY revision */
811185377Ssam	/* NB: when only one radio is present the rev is in 5Ghz */
812185377Ssam	uint16_t	ah_analog5GhzRev;/* 5GHz radio revision */
813185377Ssam	uint16_t	ah_analog2GhzRev;/* 2GHz radio revision */
814185377Ssam
815217624Sadrian	uint16_t	*ah_eepromdata;	/* eeprom buffer, if needed */
816217624Sadrian
817227365Sadrian	uint32_t	ah_intrstate[8];	/* last int state */
818234088Sadrian	uint32_t	ah_syncstate;		/* last sync intr state */
819227365Sadrian
820223459Sadrian	HAL_OPS_CONFIG ah_config;
821185377Ssam	const HAL_RATE_TABLE *__ahdecl(*ah_getRateTable)(struct ath_hal *,
822185377Ssam				u_int mode);
823185377Ssam	void	  __ahdecl(*ah_detach)(struct ath_hal*);
824185377Ssam
825185377Ssam	/* Reset functions */
826185377Ssam	HAL_BOOL  __ahdecl(*ah_reset)(struct ath_hal *, HAL_OPMODE,
827187831Ssam				struct ieee80211_channel *,
828187831Ssam				HAL_BOOL bChannelChange, HAL_STATUS *status);
829185377Ssam	HAL_BOOL  __ahdecl(*ah_phyDisable)(struct ath_hal *);
830185377Ssam	HAL_BOOL  __ahdecl(*ah_disable)(struct ath_hal *);
831188979Ssam	void	  __ahdecl(*ah_configPCIE)(struct ath_hal *, HAL_BOOL restore);
832188979Ssam	void	  __ahdecl(*ah_disablePCIE)(struct ath_hal *);
833185377Ssam	void	  __ahdecl(*ah_setPCUConfig)(struct ath_hal *);
834187831Ssam	HAL_BOOL  __ahdecl(*ah_perCalibration)(struct ath_hal*,
835187831Ssam			struct ieee80211_channel *, HAL_BOOL *);
836187831Ssam	HAL_BOOL  __ahdecl(*ah_perCalibrationN)(struct ath_hal *,
837187831Ssam			struct ieee80211_channel *, u_int chainMask,
838187831Ssam			HAL_BOOL longCal, HAL_BOOL *isCalDone);
839187831Ssam	HAL_BOOL  __ahdecl(*ah_resetCalValid)(struct ath_hal *,
840187831Ssam			const struct ieee80211_channel *);
841203930Srpaulo	HAL_BOOL  __ahdecl(*ah_setTxPower)(struct ath_hal *,
842203930Srpaulo	    		const struct ieee80211_channel *, uint16_t *);
843185377Ssam	HAL_BOOL  __ahdecl(*ah_setTxPowerLimit)(struct ath_hal *, uint32_t);
844203930Srpaulo	HAL_BOOL  __ahdecl(*ah_setBoardValues)(struct ath_hal *,
845203930Srpaulo	    		const struct ieee80211_channel *);
846185377Ssam
847185377Ssam	/* Transmit functions */
848185377Ssam	HAL_BOOL  __ahdecl(*ah_updateTxTrigLevel)(struct ath_hal*,
849185377Ssam				HAL_BOOL incTrigLevel);
850185377Ssam	int	  __ahdecl(*ah_setupTxQueue)(struct ath_hal *, HAL_TX_QUEUE,
851185377Ssam				const HAL_TXQ_INFO *qInfo);
852185377Ssam	HAL_BOOL  __ahdecl(*ah_setTxQueueProps)(struct ath_hal *, int q,
853185377Ssam				const HAL_TXQ_INFO *qInfo);
854185377Ssam	HAL_BOOL  __ahdecl(*ah_getTxQueueProps)(struct ath_hal *, int q,
855185377Ssam				HAL_TXQ_INFO *qInfo);
856185377Ssam	HAL_BOOL  __ahdecl(*ah_releaseTxQueue)(struct ath_hal *ah, u_int q);
857185377Ssam	HAL_BOOL  __ahdecl(*ah_resetTxQueue)(struct ath_hal *ah, u_int q);
858185377Ssam	uint32_t __ahdecl(*ah_getTxDP)(struct ath_hal*, u_int);
859185377Ssam	HAL_BOOL  __ahdecl(*ah_setTxDP)(struct ath_hal*, u_int, uint32_t txdp);
860185377Ssam	uint32_t __ahdecl(*ah_numTxPending)(struct ath_hal *, u_int q);
861185377Ssam	HAL_BOOL  __ahdecl(*ah_startTxDma)(struct ath_hal*, u_int);
862185377Ssam	HAL_BOOL  __ahdecl(*ah_stopTxDma)(struct ath_hal*, u_int);
863185377Ssam	HAL_BOOL  __ahdecl(*ah_setupTxDesc)(struct ath_hal *, struct ath_desc *,
864185377Ssam				u_int pktLen, u_int hdrLen,
865185377Ssam				HAL_PKT_TYPE type, u_int txPower,
866185377Ssam				u_int txRate0, u_int txTries0,
867185377Ssam				u_int keyIx, u_int antMode, u_int flags,
868185377Ssam				u_int rtsctsRate, u_int rtsctsDuration,
869185377Ssam				u_int compicvLen, u_int compivLen,
870185377Ssam				u_int comp);
871185377Ssam	HAL_BOOL  __ahdecl(*ah_setupXTxDesc)(struct ath_hal *, struct ath_desc*,
872185377Ssam				u_int txRate1, u_int txTries1,
873185377Ssam				u_int txRate2, u_int txTries2,
874185377Ssam				u_int txRate3, u_int txTries3);
875185377Ssam	HAL_BOOL  __ahdecl(*ah_fillTxDesc)(struct ath_hal *, struct ath_desc *,
876185377Ssam				u_int segLen, HAL_BOOL firstSeg,
877185377Ssam				HAL_BOOL lastSeg, const struct ath_desc *);
878185377Ssam	HAL_STATUS __ahdecl(*ah_procTxDesc)(struct ath_hal *,
879185377Ssam				struct ath_desc *, struct ath_tx_status *);
880185377Ssam	void	   __ahdecl(*ah_getTxIntrQueue)(struct ath_hal *, uint32_t *);
881185377Ssam	void	   __ahdecl(*ah_reqTxIntrDesc)(struct ath_hal *, struct ath_desc*);
882217621Sadrian	HAL_BOOL	__ahdecl(*ah_getTxCompletionRates)(struct ath_hal *,
883217621Sadrian				const struct ath_desc *ds, int *rates, int *tries);
884185377Ssam
885185377Ssam	/* Receive Functions */
886185377Ssam	uint32_t __ahdecl(*ah_getRxDP)(struct ath_hal*);
887185377Ssam	void	  __ahdecl(*ah_setRxDP)(struct ath_hal*, uint32_t rxdp);
888185377Ssam	void	  __ahdecl(*ah_enableReceive)(struct ath_hal*);
889185377Ssam	HAL_BOOL  __ahdecl(*ah_stopDmaReceive)(struct ath_hal*);
890185377Ssam	void	  __ahdecl(*ah_startPcuReceive)(struct ath_hal*);
891185377Ssam	void	  __ahdecl(*ah_stopPcuReceive)(struct ath_hal*);
892185377Ssam	void	  __ahdecl(*ah_setMulticastFilter)(struct ath_hal*,
893185377Ssam				uint32_t filter0, uint32_t filter1);
894185377Ssam	HAL_BOOL  __ahdecl(*ah_setMulticastFilterIndex)(struct ath_hal*,
895185377Ssam				uint32_t index);
896185377Ssam	HAL_BOOL  __ahdecl(*ah_clrMulticastFilterIndex)(struct ath_hal*,
897185377Ssam				uint32_t index);
898185377Ssam	uint32_t __ahdecl(*ah_getRxFilter)(struct ath_hal*);
899185377Ssam	void	  __ahdecl(*ah_setRxFilter)(struct ath_hal*, uint32_t);
900185377Ssam	HAL_BOOL  __ahdecl(*ah_setupRxDesc)(struct ath_hal *, struct ath_desc *,
901185377Ssam				uint32_t size, u_int flags);
902185377Ssam	HAL_STATUS __ahdecl(*ah_procRxDesc)(struct ath_hal *,
903185377Ssam				struct ath_desc *, uint32_t phyAddr,
904185377Ssam				struct ath_desc *next, uint64_t tsf,
905185377Ssam				struct ath_rx_status *);
906185377Ssam	void	  __ahdecl(*ah_rxMonitor)(struct ath_hal *,
907187831Ssam				const HAL_NODE_STATS *,
908187831Ssam				const struct ieee80211_channel *);
909217684Sadrian	void      __ahdecl(*ah_aniPoll)(struct ath_hal *,
910217684Sadrian				const struct ieee80211_channel *);
911185377Ssam	void	  __ahdecl(*ah_procMibEvent)(struct ath_hal *,
912185377Ssam				const HAL_NODE_STATS *);
913220600Sadrian	void	  __ahdecl(*ah_rxAntCombDiversity)(struct ath_hal *,
914220600Sadrian				struct ath_rx_status *,
915220600Sadrian				unsigned long, int);
916185377Ssam
917185377Ssam	/* Misc Functions */
918185377Ssam	HAL_STATUS __ahdecl(*ah_getCapability)(struct ath_hal *,
919185377Ssam				HAL_CAPABILITY_TYPE, uint32_t capability,
920185377Ssam				uint32_t *result);
921185377Ssam	HAL_BOOL   __ahdecl(*ah_setCapability)(struct ath_hal *,
922185377Ssam				HAL_CAPABILITY_TYPE, uint32_t capability,
923185377Ssam				uint32_t setting, HAL_STATUS *);
924185377Ssam	HAL_BOOL   __ahdecl(*ah_getDiagState)(struct ath_hal *, int request,
925185377Ssam				const void *args, uint32_t argsize,
926185377Ssam				void **result, uint32_t *resultsize);
927185377Ssam	void	  __ahdecl(*ah_getMacAddress)(struct ath_hal *, uint8_t *);
928185377Ssam	HAL_BOOL  __ahdecl(*ah_setMacAddress)(struct ath_hal *, const uint8_t*);
929185377Ssam	void	  __ahdecl(*ah_getBssIdMask)(struct ath_hal *, uint8_t *);
930185377Ssam	HAL_BOOL  __ahdecl(*ah_setBssIdMask)(struct ath_hal *, const uint8_t*);
931185377Ssam	HAL_BOOL  __ahdecl(*ah_setRegulatoryDomain)(struct ath_hal*,
932185377Ssam				uint16_t, HAL_STATUS *);
933185377Ssam	void	  __ahdecl(*ah_setLedState)(struct ath_hal*, HAL_LED_STATE);
934185377Ssam	void	  __ahdecl(*ah_writeAssocid)(struct ath_hal*,
935185377Ssam				const uint8_t *bssid, uint16_t assocId);
936188974Ssam	HAL_BOOL  __ahdecl(*ah_gpioCfgOutput)(struct ath_hal *,
937188974Ssam				uint32_t gpio, HAL_GPIO_MUX_TYPE);
938185377Ssam	HAL_BOOL  __ahdecl(*ah_gpioCfgInput)(struct ath_hal *, uint32_t gpio);
939185377Ssam	uint32_t __ahdecl(*ah_gpioGet)(struct ath_hal *, uint32_t gpio);
940185377Ssam	HAL_BOOL  __ahdecl(*ah_gpioSet)(struct ath_hal *,
941185377Ssam				uint32_t gpio, uint32_t val);
942185377Ssam	void	  __ahdecl(*ah_gpioSetIntr)(struct ath_hal*, u_int, uint32_t);
943185377Ssam	uint32_t __ahdecl(*ah_getTsf32)(struct ath_hal*);
944185377Ssam	uint64_t __ahdecl(*ah_getTsf64)(struct ath_hal*);
945185377Ssam	void	  __ahdecl(*ah_resetTsf)(struct ath_hal*);
946185377Ssam	HAL_BOOL  __ahdecl(*ah_detectCardPresent)(struct ath_hal*);
947185377Ssam	void	  __ahdecl(*ah_updateMibCounters)(struct ath_hal*,
948185377Ssam				HAL_MIB_STATS*);
949185377Ssam	HAL_RFGAIN __ahdecl(*ah_getRfGain)(struct ath_hal*);
950185377Ssam	u_int	  __ahdecl(*ah_getDefAntenna)(struct ath_hal*);
951185377Ssam	void	  __ahdecl(*ah_setDefAntenna)(struct ath_hal*, u_int);
952185377Ssam	HAL_ANT_SETTING	 __ahdecl(*ah_getAntennaSwitch)(struct ath_hal*);
953185377Ssam	HAL_BOOL  __ahdecl(*ah_setAntennaSwitch)(struct ath_hal*,
954185377Ssam				HAL_ANT_SETTING);
955185377Ssam	HAL_BOOL  __ahdecl(*ah_setSifsTime)(struct ath_hal*, u_int);
956185377Ssam	u_int	  __ahdecl(*ah_getSifsTime)(struct ath_hal*);
957185377Ssam	HAL_BOOL  __ahdecl(*ah_setSlotTime)(struct ath_hal*, u_int);
958185377Ssam	u_int	  __ahdecl(*ah_getSlotTime)(struct ath_hal*);
959185377Ssam	HAL_BOOL  __ahdecl(*ah_setAckTimeout)(struct ath_hal*, u_int);
960185377Ssam	u_int	  __ahdecl(*ah_getAckTimeout)(struct ath_hal*);
961185377Ssam	HAL_BOOL  __ahdecl(*ah_setAckCTSRate)(struct ath_hal*, u_int);
962185377Ssam	u_int	  __ahdecl(*ah_getAckCTSRate)(struct ath_hal*);
963185377Ssam	HAL_BOOL  __ahdecl(*ah_setCTSTimeout)(struct ath_hal*, u_int);
964185377Ssam	u_int	  __ahdecl(*ah_getCTSTimeout)(struct ath_hal*);
965185377Ssam	HAL_BOOL  __ahdecl(*ah_setDecompMask)(struct ath_hal*, uint16_t, int);
966185377Ssam	void	  __ahdecl(*ah_setCoverageClass)(struct ath_hal*, uint8_t, int);
967222644Sadrian	HAL_STATUS	__ahdecl(*ah_setQuiet)(struct ath_hal *ah, uint32_t period,
968222644Sadrian				uint32_t duration, uint32_t nextStart,
969222644Sadrian				HAL_QUIET_FLAG flag);
970185377Ssam
971222584Sadrian	/* DFS functions */
972222584Sadrian	void	  __ahdecl(*ah_enableDfs)(struct ath_hal *ah,
973222584Sadrian				HAL_PHYERR_PARAM *pe);
974222584Sadrian	void	  __ahdecl(*ah_getDfsThresh)(struct ath_hal *ah,
975222584Sadrian				HAL_PHYERR_PARAM *pe);
976222815Sadrian	HAL_BOOL  __ahdecl(*ah_procRadarEvent)(struct ath_hal *ah,
977222815Sadrian				struct ath_rx_status *rxs, uint64_t fulltsf,
978222815Sadrian				const char *buf, HAL_DFS_EVENT *event);
979224709Sadrian	HAL_BOOL  __ahdecl(*ah_isFastClockEnabled)(struct ath_hal *ah);
980222584Sadrian
981185377Ssam	/* Key Cache Functions */
982185377Ssam	uint32_t __ahdecl(*ah_getKeyCacheSize)(struct ath_hal*);
983185377Ssam	HAL_BOOL  __ahdecl(*ah_resetKeyCacheEntry)(struct ath_hal*, uint16_t);
984185377Ssam	HAL_BOOL  __ahdecl(*ah_isKeyCacheEntryValid)(struct ath_hal *,
985185377Ssam				uint16_t);
986185377Ssam	HAL_BOOL  __ahdecl(*ah_setKeyCacheEntry)(struct ath_hal*,
987185377Ssam				uint16_t, const HAL_KEYVAL *,
988185377Ssam				const uint8_t *, int);
989185377Ssam	HAL_BOOL  __ahdecl(*ah_setKeyCacheEntryMac)(struct ath_hal*,
990185377Ssam				uint16_t, const uint8_t *);
991185377Ssam
992185377Ssam	/* Power Management Functions */
993185377Ssam	HAL_BOOL  __ahdecl(*ah_setPowerMode)(struct ath_hal*,
994185377Ssam				HAL_POWER_MODE mode, int setChip);
995185377Ssam	HAL_POWER_MODE __ahdecl(*ah_getPowerMode)(struct ath_hal*);
996187831Ssam	int16_t   __ahdecl(*ah_getChanNoise)(struct ath_hal *,
997187831Ssam				const struct ieee80211_channel *);
998185377Ssam
999185377Ssam	/* Beacon Management Functions */
1000185377Ssam	void	  __ahdecl(*ah_setBeaconTimers)(struct ath_hal*,
1001185377Ssam				const HAL_BEACON_TIMERS *);
1002185377Ssam	/* NB: deprecated, use ah_setBeaconTimers instead */
1003185377Ssam	void	  __ahdecl(*ah_beaconInit)(struct ath_hal *,
1004185377Ssam				uint32_t nexttbtt, uint32_t intval);
1005185377Ssam	void	  __ahdecl(*ah_setStationBeaconTimers)(struct ath_hal*,
1006185377Ssam				const HAL_BEACON_STATE *);
1007185377Ssam	void	  __ahdecl(*ah_resetStationBeaconTimers)(struct ath_hal*);
1008225444Sadrian	uint64_t  __ahdecl(*ah_getNextTBTT)(struct ath_hal *);
1009185377Ssam
1010218066Sadrian	/* 802.11n Functions */
1011218066Sadrian	HAL_BOOL  __ahdecl(*ah_chainTxDesc)(struct ath_hal *,
1012218066Sadrian				struct ath_desc *, u_int, u_int, HAL_PKT_TYPE,
1013218066Sadrian				u_int, HAL_CIPHER, uint8_t, u_int, HAL_BOOL,
1014233895Sadrian				HAL_BOOL, HAL_BOOL);
1015218066Sadrian	HAL_BOOL  __ahdecl(*ah_setupFirstTxDesc)(struct ath_hal *,
1016218066Sadrian				struct ath_desc *, u_int, u_int, u_int,
1017218066Sadrian				u_int, u_int, u_int, u_int, u_int);
1018218066Sadrian	HAL_BOOL  __ahdecl(*ah_setupLastTxDesc)(struct ath_hal *,
1019218066Sadrian				struct ath_desc *, const struct ath_desc *);
1020218066Sadrian	void	  __ahdecl(*ah_set11nRateScenario)(struct ath_hal *,
1021218066Sadrian	    			struct ath_desc *, u_int, u_int,
1022218066Sadrian				HAL_11N_RATE_SERIES [], u_int, u_int);
1023226767Sadrian	void	  __ahdecl(*ah_set11nAggrFirst)(struct ath_hal *,
1024226767Sadrian				struct ath_desc *, u_int, u_int);
1025218066Sadrian	void	  __ahdecl(*ah_set11nAggrMiddle)(struct ath_hal *,
1026218066Sadrian	    			struct ath_desc *, u_int);
1027226767Sadrian	void	  __ahdecl(*ah_set11nAggrLast)(struct ath_hal *,
1028226767Sadrian				struct ath_desc *);
1029218066Sadrian	void	  __ahdecl(*ah_clr11nAggr)(struct ath_hal *,
1030218066Sadrian	    			struct ath_desc *);
1031218066Sadrian	void	  __ahdecl(*ah_set11nBurstDuration)(struct ath_hal *,
1032218066Sadrian	    			struct ath_desc *, u_int);
1033227374Sadrian	uint32_t  __ahdecl(*ah_get_mib_cycle_counts_pct) (struct ath_hal *,
1034227374Sadrian				uint32_t *, uint32_t *, uint32_t *, uint32_t *);
1035227374Sadrian
1036218066Sadrian	uint32_t  __ahdecl(*ah_get11nExtBusy)(struct ath_hal *);
1037218066Sadrian	void      __ahdecl(*ah_set11nMac2040)(struct ath_hal *,
1038218066Sadrian				HAL_HT_MACMODE);
1039218066Sadrian	HAL_HT_RXCLEAR __ahdecl(*ah_get11nRxClear)(struct ath_hal *ah);
1040218066Sadrian	void	  __ahdecl(*ah_set11nRxClear)(struct ath_hal *,
1041218066Sadrian	    			HAL_HT_RXCLEAR);
1042218066Sadrian
1043185377Ssam	/* Interrupt functions */
1044185377Ssam	HAL_BOOL  __ahdecl(*ah_isInterruptPending)(struct ath_hal*);
1045185377Ssam	HAL_BOOL  __ahdecl(*ah_getPendingInterrupts)(struct ath_hal*, HAL_INT*);
1046185377Ssam	HAL_INT	  __ahdecl(*ah_getInterrupts)(struct ath_hal*);
1047185377Ssam	HAL_INT	  __ahdecl(*ah_setInterrupts)(struct ath_hal*, HAL_INT);
1048185377Ssam};
1049185377Ssam
1050185377Ssam/*
1051185377Ssam * Check the PCI vendor ID and device ID against Atheros' values
1052185377Ssam * and return a printable description for any Atheros hardware.
1053185377Ssam * AH_NULL is returned if the ID's do not describe Atheros hardware.
1054185377Ssam */
1055185377Ssamextern	const char *__ahdecl ath_hal_probe(uint16_t vendorid, uint16_t devid);
1056185377Ssam
1057185377Ssam/*
1058185377Ssam * Attach the HAL for use with the specified device.  The device is
1059185377Ssam * defined by the PCI device ID.  The caller provides an opaque pointer
1060185377Ssam * to an upper-layer data structure (HAL_SOFTC) that is stored in the
1061185377Ssam * HAL state block for later use.  Hardware register accesses are done
1062185377Ssam * using the specified bus tag and handle.  On successful return a
1063185377Ssam * reference to a state block is returned that must be supplied in all
1064185377Ssam * subsequent HAL calls.  Storage associated with this reference is
1065185377Ssam * dynamically allocated and must be freed by calling the ah_detach
1066185377Ssam * method when the client is done.  If the attach operation fails a
1067185377Ssam * null (AH_NULL) reference will be returned and a status code will
1068185377Ssam * be returned if the status parameter is non-zero.
1069185377Ssam */
1070185377Ssamextern	struct ath_hal * __ahdecl ath_hal_attach(uint16_t devid, HAL_SOFTC,
1071217624Sadrian		HAL_BUS_TAG, HAL_BUS_HANDLE, uint16_t *eepromdata, HAL_STATUS* status);
1072185377Ssam
1073188968Ssamextern	const char *ath_hal_mac_name(struct ath_hal *);
1074188968Ssamextern	const char *ath_hal_rf_name(struct ath_hal *);
1075188968Ssam
1076185377Ssam/*
1077187831Ssam * Regulatory interfaces.  Drivers should use ath_hal_init_channels to
1078187831Ssam * request a set of channels for a particular country code and/or
1079187831Ssam * regulatory domain.  If CTRY_DEFAULT and SKU_NONE are specified then
1080187831Ssam * this list is constructed according to the contents of the EEPROM.
1081187831Ssam * ath_hal_getchannels acts similarly but does not alter the operating
1082187831Ssam * state; this can be used to collect information for a particular
1083187831Ssam * regulatory configuration.  Finally ath_hal_set_channels installs a
1084187831Ssam * channel list constructed outside the driver.  The HAL will adopt the
1085187831Ssam * channel list and setup internal state according to the specified
1086187831Ssam * regulatory configuration (e.g. conformance test limits).
1087185377Ssam *
1088187831Ssam * For all interfaces the channel list is returned in the supplied array.
1089187831Ssam * maxchans defines the maximum size of this array.  nchans contains the
1090187831Ssam * actual number of channels returned.  If a problem occurred then a
1091187831Ssam * status code != HAL_OK is returned.
1092185377Ssam */
1093187831Ssamstruct ieee80211_channel;
1094185377Ssam
1095185377Ssam/*
1096187831Ssam * Return a list of channels according to the specified regulatory.
1097185377Ssam */
1098187831Ssamextern	HAL_STATUS __ahdecl ath_hal_getchannels(struct ath_hal *,
1099187831Ssam    struct ieee80211_channel *chans, u_int maxchans, int *nchans,
1100187831Ssam    u_int modeSelect, HAL_CTRY_CODE cc, HAL_REG_DOMAIN regDmn,
1101187831Ssam    HAL_BOOL enableExtendedChannels);
1102185377Ssam
1103185377Ssam/*
1104187831Ssam * Return a list of channels and install it as the current operating
1105187831Ssam * regulatory list.
1106185377Ssam */
1107187831Ssamextern	HAL_STATUS __ahdecl ath_hal_init_channels(struct ath_hal *,
1108187831Ssam    struct ieee80211_channel *chans, u_int maxchans, int *nchans,
1109187831Ssam    u_int modeSelect, HAL_CTRY_CODE cc, HAL_REG_DOMAIN rd,
1110187831Ssam    HAL_BOOL enableExtendedChannels);
1111185377Ssam
1112185377Ssam/*
1113187831Ssam * Install the list of channels as the current operating regulatory
1114187831Ssam * and setup related state according to the country code and sku.
1115185377Ssam */
1116187831Ssamextern	HAL_STATUS __ahdecl ath_hal_set_channels(struct ath_hal *,
1117187831Ssam    struct ieee80211_channel *chans, int nchans,
1118187831Ssam    HAL_CTRY_CODE cc, HAL_REG_DOMAIN regDmn);
1119185377Ssam
1120185377Ssam/*
1121220443Sadrian * Fetch the ctl/ext noise floor values reported by a MIMO
1122220443Sadrian * radio. Returns 1 for valid results, 0 for invalid channel.
1123220443Sadrian */
1124220443Sadrianextern int __ahdecl ath_hal_get_mimo_chan_noise(struct ath_hal *ah,
1125220444Sadrian    const struct ieee80211_channel *chan, int16_t *nf_ctl,
1126220444Sadrian    int16_t *nf_ext);
1127220443Sadrian
1128220443Sadrian/*
1129187831Ssam * Calibrate noise floor data following a channel scan or similar.
1130187831Ssam * This must be called prior retrieving noise floor data.
1131185377Ssam */
1132187831Ssamextern	void __ahdecl ath_hal_process_noisefloor(struct ath_hal *ah);
1133185377Ssam
1134185377Ssam/*
1135187831Ssam * Return bit mask of wireless modes supported by the hardware.
1136185377Ssam */
1137187831Ssamextern	u_int __ahdecl ath_hal_getwirelessmodes(struct ath_hal*);
1138185377Ssam
1139185377Ssam/*
1140218011Sadrian * Calculate the packet TX time for a legacy or 11n frame
1141185377Ssam */
1142218011Sadrianextern uint32_t __ahdecl ath_hal_pkt_txtime(struct ath_hal *ah,
1143218011Sadrian    const HAL_RATE_TABLE *rates, uint32_t frameLen,
1144218011Sadrian    uint16_t rateix, HAL_BOOL isht40, HAL_BOOL shortPreamble);
1145218011Sadrian
1146218011Sadrian/*
1147218011Sadrian * Calculate the duration of an 11n frame.
1148218011Sadrian */
1149218011Sadrianextern uint32_t __ahdecl ath_computedur_ht(uint32_t frameLen, uint16_t rate,
1150218011Sadrian    int streams, HAL_BOOL isht40, HAL_BOOL isShortGI);
1151218011Sadrian
1152218011Sadrian/*
1153218011Sadrian * Calculate the transmit duration of a legacy frame.
1154218011Sadrian */
1155187831Ssamextern uint16_t __ahdecl ath_hal_computetxtime(struct ath_hal *,
1156187831Ssam		const HAL_RATE_TABLE *rates, uint32_t frameLen,
1157187831Ssam		uint16_t rateix, HAL_BOOL shortPreamble);
1158225444Sadrian
1159225444Sadrian/*
1160225444Sadrian * Adjust the TSF.
1161225444Sadrian */
1162225444Sadrianextern void __ahdecl ath_hal_adjusttsf(struct ath_hal *ah, int32_t tsfdelta);
1163225444Sadrian
1164225444Sadrian/*
1165225444Sadrian * Enable or disable CCA.
1166225444Sadrian */
1167225444Sadrianvoid __ahdecl ath_hal_setcca(struct ath_hal *ah, int ena);
1168225444Sadrian
1169225444Sadrian/*
1170225444Sadrian * Get CCA setting.
1171225444Sadrian */
1172225444Sadrianint __ahdecl ath_hal_getcca(struct ath_hal *ah);
1173225444Sadrian
1174230147Sadrian/*
1175230147Sadrian * Read EEPROM data from ah_eepromdata
1176230147Sadrian */
1177230147SadrianHAL_BOOL __ahdecl ath_hal_EepromDataRead(struct ath_hal *ah,
1178230147Sadrian		u_int off, uint16_t *data);
1179230147Sadrian
1180185377Ssam#endif /* _ATH_AH_H_ */
1181