]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/ath/ah.h
Merge ath_hal 0.10.5.10 to head.
[FreeBSD/FreeBSD.git] / sys / contrib / dev / ath / ah.h
1 /*-
2  * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting, Atheros
3  * Communications, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the following conditions are met:
7  * 1. The materials contained herein are unmodified and are used
8  *    unmodified.
9  * 2. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following NO
11  *    ''WARRANTY'' disclaimer below (''Disclaimer''), without
12  *    modification.
13  * 3. Redistributions in binary form must reproduce at minimum a
14  *    disclaimer similar to the Disclaimer below and any redistribution
15  *    must be conditioned upon including a substantially similar
16  *    Disclaimer requirement for further binary redistribution.
17  * 4. Neither the names of the above-listed copyright holders nor the
18  *    names of any contributors may be used to endorse or promote
19  *    product derived from this software without specific prior written
20  *    permission.
21  *
22  * NO WARRANTY
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
26  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
28  * FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGES.
35  *
36  * $Id: //depot/sw/branches/sam_hal/ah.h#32 $
37  */
38
39 #ifndef _ATH_AH_H_
40 #define _ATH_AH_H_
41 /*
42  * Atheros Hardware Access Layer
43  *
44  * Clients of the HAL call ath_hal_attach to obtain a reference to an ath_hal
45  * structure for use with the device.  Hardware-related operations that
46  * follow must call back into the HAL through interface, supplying the
47  * reference as the first parameter.
48  */
49
50 /*
51  * Bus i/o type definitions.  We define a platform-independent
52  * set of types that are mapped to platform-dependent data for
53  * register read/write operations.  We use types that are large
54  * enough to hold a pointer; smaller data should fit and only
55  * require type coercion to work.  Larger data can be stored
56  * elsewhere and a reference passed for the bus tag and/or handle.
57  */
58 typedef void* HAL_SOFTC;                /* pointer to driver/OS state */
59 typedef void* HAL_BUS_TAG;              /* opaque bus i/o id tag */
60 typedef void* HAL_BUS_HANDLE;           /* opaque bus i/o handle */
61
62 #include "ah_osdep.h"
63
64 /*
65  * __ahdecl is analogous to _cdecl; it defines the calling
66  * convention used within the HAL.  For most systems this
67  * can just default to be empty and the compiler will (should)
68  * use _cdecl.  For systems where _cdecl is not compatible this
69  * must be defined.  See linux/ah_osdep.h for an example.
70  */
71 #ifndef __ahdecl
72 #define __ahdecl
73 #endif
74
75 /*
76  * Status codes that may be returned by the HAL.  Note that
77  * interfaces that return a status code set it only when an
78  * error occurs--i.e. you cannot check it for success.
79  */
80 typedef enum {
81         HAL_OK          = 0,    /* No error */
82         HAL_ENXIO       = 1,    /* No hardware present */
83         HAL_ENOMEM      = 2,    /* Memory allocation failed */
84         HAL_EIO         = 3,    /* Hardware didn't respond as expected */
85         HAL_EEMAGIC     = 4,    /* EEPROM magic number invalid */
86         HAL_EEVERSION   = 5,    /* EEPROM version invalid */
87         HAL_EELOCKED    = 6,    /* EEPROM unreadable */
88         HAL_EEBADSUM    = 7,    /* EEPROM checksum invalid */
89         HAL_EEREAD      = 8,    /* EEPROM read problem */
90         HAL_EEBADMAC    = 9,    /* EEPROM mac address invalid */
91         HAL_EESIZE      = 10,   /* EEPROM size not supported */
92         HAL_EEWRITE     = 11,   /* Attempt to change write-locked EEPROM */
93         HAL_EINVAL      = 12,   /* Invalid parameter to function */
94         HAL_ENOTSUPP    = 13,   /* Hardware revision not supported */
95         HAL_ESELFTEST   = 14,   /* Hardware self-test failed */
96         HAL_EINPROGRESS = 15,   /* Operation incomplete */
97 } HAL_STATUS;
98
99 typedef enum {
100         AH_FALSE = 0,           /* NB: lots of code assumes false is zero */
101         AH_TRUE  = 1,
102 } HAL_BOOL;
103
104 typedef enum {
105         HAL_CAP_REG_DMN         = 0,    /* current regulatory domain */
106         HAL_CAP_CIPHER          = 1,    /* hardware supports cipher */
107         HAL_CAP_TKIP_MIC        = 2,    /* handle TKIP MIC in hardware */
108         HAL_CAP_TKIP_SPLIT      = 3,    /* hardware TKIP uses split keys */
109         HAL_CAP_PHYCOUNTERS     = 4,    /* hardware PHY error counters */
110         HAL_CAP_DIVERSITY       = 5,    /* hardware supports fast diversity */
111         HAL_CAP_KEYCACHE_SIZE   = 6,    /* number of entries in key cache */
112         HAL_CAP_NUM_TXQUEUES    = 7,    /* number of hardware xmit queues */
113         HAL_CAP_VEOL            = 9,    /* hardware supports virtual EOL */
114         HAL_CAP_PSPOLL          = 10,   /* hardware has working PS-Poll support */
115         HAL_CAP_DIAG            = 11,   /* hardware diagnostic support */
116         HAL_CAP_COMPRESSION     = 12,   /* hardware supports compression */
117         HAL_CAP_BURST           = 13,   /* hardware supports packet bursting */
118         HAL_CAP_FASTFRAME       = 14,   /* hardware supoprts fast frames */
119         HAL_CAP_TXPOW           = 15,   /* global tx power limit  */
120         HAL_CAP_TPC             = 16,   /* per-packet tx power control  */
121         HAL_CAP_PHYDIAG         = 17,   /* hardware phy error diagnostic */
122         HAL_CAP_BSSIDMASK       = 18,   /* hardware supports bssid mask */
123         HAL_CAP_MCAST_KEYSRCH   = 19,   /* hardware has multicast key search */
124         HAL_CAP_TSF_ADJUST      = 20,   /* hardware has beacon tsf adjust */
125         HAL_CAP_XR              = 21,   /* hardware has XR support  */
126         HAL_CAP_WME_TKIPMIC     = 22,   /* hardware can support TKIP MIC when WMM is turned on */
127         HAL_CAP_CHAN_HALFRATE   = 23,   /* hardware can support half rate channels */
128         HAL_CAP_CHAN_QUARTERRATE = 24,  /* hardware can support quarter rate channels */
129         HAL_CAP_RFSILENT        = 25,   /* hardware has rfsilent support  */
130         HAL_CAP_TPC_ACK         = 26,   /* ack txpower with per-packet tpc */
131         HAL_CAP_TPC_CTS         = 27,   /* cts txpower with per-packet tpc */
132         HAL_CAP_11D             = 28,   /* 11d beacon support for changing cc */
133         HAL_CAP_INTMIT          = 29,   /* interference mitigation */
134         HAL_CAP_RXORN_FATAL     = 30,   /* HAL_INT_RXORN treated as fatal */
135         HAL_CAP_HT              = 31,   /* hardware can support HT */
136         HAL_CAP_NUMTXCHAIN      = 32,   /* # TX chains supported */
137         HAL_CAP_NUMRXCHAIN      = 33,   /* # RX chains supported */
138         HAL_CAP_RXTSTAMP_PREC   = 34,   /* rx desc tstamp precision (bits) */
139 } HAL_CAPABILITY_TYPE;
140
141 /* 
142  * "States" for setting the LED.  These correspond to
143  * the possible 802.11 operational states and there may
144  * be a many-to-one mapping between these states and the
145  * actual hardware state for the LED's (i.e. the hardware
146  * may have fewer states).
147  */
148 typedef enum {
149         HAL_LED_INIT    = 0,
150         HAL_LED_SCAN    = 1,
151         HAL_LED_AUTH    = 2,
152         HAL_LED_ASSOC   = 3,
153         HAL_LED_RUN     = 4
154 } HAL_LED_STATE;
155
156 /*
157  * Transmit queue types/numbers.  These are used to tag
158  * each transmit queue in the hardware and to identify a set
159  * of transmit queues for operations such as start/stop dma.
160  */
161 typedef enum {
162         HAL_TX_QUEUE_INACTIVE   = 0,            /* queue is inactive/unused */
163         HAL_TX_QUEUE_DATA       = 1,            /* data xmit q's */
164         HAL_TX_QUEUE_BEACON     = 2,            /* beacon xmit q */
165         HAL_TX_QUEUE_CAB        = 3,            /* "crap after beacon" xmit q */
166         HAL_TX_QUEUE_UAPSD      = 4,            /* u-apsd power save xmit q */
167 } HAL_TX_QUEUE;
168
169 #define HAL_NUM_TX_QUEUES       10              /* max possible # of queues */
170
171 /*
172  * Transmit queue subtype.  These map directly to
173  * WME Access Categories (except for UPSD).  Refer
174  * to Table 5 of the WME spec.
175  */
176 typedef enum {
177         HAL_WME_AC_BK   = 0,                    /* background access category */
178         HAL_WME_AC_BE   = 1,                    /* best effort access category*/
179         HAL_WME_AC_VI   = 2,                    /* video access category */
180         HAL_WME_AC_VO   = 3,                    /* voice access category */
181         HAL_WME_UPSD    = 4,                    /* uplink power save */
182         HAL_XR_DATA     = 5,                    /* uplink power save */
183 } HAL_TX_QUEUE_SUBTYPE;
184
185 /*
186  * Transmit queue flags that control various
187  * operational parameters.
188  */
189 typedef enum {
190         /*
191          * Per queue interrupt enables.  When set the associated
192          * interrupt may be delivered for packets sent through
193          * the queue.  Without these enabled no interrupts will
194          * be delivered for transmits through the queue.
195          */
196         HAL_TXQ_TXOKINT_ENABLE     = 0x0001,    /* enable TXOK interrupt */
197         HAL_TXQ_TXERRINT_ENABLE    = 0x0001,    /* enable TXERR interrupt */
198         HAL_TXQ_TXDESCINT_ENABLE   = 0x0002,    /* enable TXDESC interrupt */
199         HAL_TXQ_TXEOLINT_ENABLE    = 0x0004,    /* enable TXEOL interrupt */
200         HAL_TXQ_TXURNINT_ENABLE    = 0x0008,    /* enable TXURN interrupt */
201         /*
202          * Enable hardware compression for packets sent through
203          * the queue.  The compression buffer must be setup and
204          * packets must have a key entry marked in the tx descriptor.
205          */
206         HAL_TXQ_COMPRESSION_ENABLE  = 0x0010,   /* enable h/w compression */
207         /*
208          * Disable queue when veol is hit or ready time expires.
209          * By default the queue is disabled only on reaching the
210          * physical end of queue (i.e. a null link ptr in the
211          * descriptor chain).
212          */
213         HAL_TXQ_RDYTIME_EXP_POLICY_ENABLE = 0x0020,
214         /*
215          * Schedule frames on delivery of a DBA (DMA Beacon Alert)
216          * event.  Frames will be transmitted only when this timer
217          * fires, e.g to transmit a beacon in ap or adhoc modes.
218          */
219         HAL_TXQ_DBA_GATED           = 0x0040,   /* schedule based on DBA */
220         /*
221          * Each transmit queue has a counter that is incremented
222          * each time the queue is enabled and decremented when
223          * the list of frames to transmit is traversed (or when
224          * the ready time for the queue expires).  This counter
225          * must be non-zero for frames to be scheduled for
226          * transmission.  The following controls disable bumping
227          * this counter under certain conditions.  Typically this
228          * is used to gate frames based on the contents of another
229          * queue (e.g. CAB traffic may only follow a beacon frame).
230          * These are meaningful only when frames are scheduled
231          * with a non-ASAP policy (e.g. DBA-gated).
232          */
233         HAL_TXQ_CBR_DIS_QEMPTY      = 0x0080,   /* disable on this q empty */
234         HAL_TXQ_CBR_DIS_BEMPTY      = 0x0100,   /* disable on beacon q empty */
235
236         /*
237          * Fragment burst backoff policy.  Normally the no backoff
238          * is done after a successful transmission, the next fragment
239          * is sent at SIFS.  If this flag is set backoff is done
240          * after each fragment, regardless whether it was ack'd or
241          * not, after the backoff count reaches zero a normal channel
242          * access procedure is done before the next transmit (i.e.
243          * wait AIFS instead of SIFS).
244          */
245         HAL_TXQ_FRAG_BURST_BACKOFF_ENABLE = 0x00800000,
246         /*
247          * Disable post-tx backoff following each frame.
248          */
249         HAL_TXQ_BACKOFF_DISABLE     = 0x00010000, /* disable post backoff  */
250         /*
251          * DCU arbiter lockout control.  This controls how
252          * lower priority tx queues are handled with respect to
253          * to a specific queue when multiple queues have frames
254          * to send.  No lockout means lower priority queues arbitrate
255          * concurrently with this queue.  Intra-frame lockout
256          * means lower priority queues are locked out until the
257          * current frame transmits (e.g. including backoffs and bursting).
258          * Global lockout means nothing lower can arbitrary so
259          * long as there is traffic activity on this queue (frames,
260          * backoff, etc).
261          */
262         HAL_TXQ_ARB_LOCKOUT_INTRA   = 0x00020000, /* intra-frame lockout */
263         HAL_TXQ_ARB_LOCKOUT_GLOBAL  = 0x00040000, /* full lockout s */
264
265         HAL_TXQ_IGNORE_VIRTCOL      = 0x00080000, /* ignore virt collisions */
266         HAL_TXQ_SEQNUM_INC_DIS      = 0x00100000, /* disable seqnum increment */
267 } HAL_TX_QUEUE_FLAGS;
268
269 typedef struct {
270         u_int32_t       tqi_ver;                /* hal TXQ version */
271         HAL_TX_QUEUE_SUBTYPE tqi_subtype;       /* subtype if applicable */
272         HAL_TX_QUEUE_FLAGS tqi_qflags;          /* flags (see above) */
273         u_int32_t       tqi_priority;           /* (not used) */
274         u_int32_t       tqi_aifs;               /* aifs */
275         u_int32_t       tqi_cwmin;              /* cwMin */
276         u_int32_t       tqi_cwmax;              /* cwMax */
277         u_int16_t       tqi_shretry;            /* rts retry limit */
278         u_int16_t       tqi_lgretry;            /* long retry limit (not used)*/
279         u_int32_t       tqi_cbrPeriod;          /* CBR period (us) */
280         u_int32_t       tqi_cbrOverflowLimit;   /* threshold for CBROVF int */
281         u_int32_t       tqi_burstTime;          /* max burst duration (us) */
282         u_int32_t       tqi_readyTime;          /* frame schedule time (us) */
283         u_int32_t       tqi_compBuf;            /* comp buffer phys addr */
284 } HAL_TXQ_INFO;
285
286 #define HAL_TQI_NONVAL 0xffff
287
288 /* token to use for aifs, cwmin, cwmax */
289 #define HAL_TXQ_USEDEFAULT      ((u_int32_t) -1)
290
291 /* compression definitions */
292 #define HAL_COMP_BUF_MAX_SIZE           9216            /* 9K */
293 #define HAL_COMP_BUF_ALIGN_SIZE         512
294
295 /*
296  * Transmit packet types.  This belongs in ah_desc.h, but
297  * is here so we can give a proper type to various parameters
298  * (and not require everyone include the file).
299  *
300  * NB: These values are intentionally assigned for
301  *     direct use when setting up h/w descriptors.
302  */
303 typedef enum {
304         HAL_PKT_TYPE_NORMAL     = 0,
305         HAL_PKT_TYPE_ATIM       = 1,
306         HAL_PKT_TYPE_PSPOLL     = 2,
307         HAL_PKT_TYPE_BEACON     = 3,
308         HAL_PKT_TYPE_PROBE_RESP = 4,
309         HAL_PKT_TYPE_CHIRP      = 5,
310         HAL_PKT_TYPE_GRP_POLL   = 6,
311         HAL_PKT_TYPE_AMPDU      = 7,
312 } HAL_PKT_TYPE;
313
314 /* Rx Filter Frame Types */
315 typedef enum {
316         HAL_RX_FILTER_UCAST     = 0x00000001,   /* Allow unicast frames */
317         HAL_RX_FILTER_MCAST     = 0x00000002,   /* Allow multicast frames */
318         HAL_RX_FILTER_BCAST     = 0x00000004,   /* Allow broadcast frames */
319         HAL_RX_FILTER_CONTROL   = 0x00000008,   /* Allow control frames */
320         HAL_RX_FILTER_BEACON    = 0x00000010,   /* Allow beacon frames */
321         HAL_RX_FILTER_PROM      = 0x00000020,   /* Promiscuous mode */
322         HAL_RX_FILTER_XRPOLL    = 0x00000040,   /* Allow XR poll frmae */
323         HAL_RX_FILTER_PROBEREQ  = 0x00000080,   /* Allow probe request frames */
324         HAL_RX_FILTER_PHYERR    = 0x00000100,   /* Allow phy errors */
325         HAL_RX_FILTER_PHYRADAR  = 0x00000200,   /* Allow phy radar errors */
326         HAL_RX_FILTER_COMPBAR   = 0x00000400,   /* Allow compressed BAR */
327 } HAL_RX_FILTER;
328
329 typedef enum {
330         HAL_PM_AWAKE            = 0,
331         HAL_PM_FULL_SLEEP       = 1,
332         HAL_PM_NETWORK_SLEEP    = 2,
333         HAL_PM_UNDEFINED        = 3
334 } HAL_POWER_MODE;
335
336 /*
337  * NOTE WELL:
338  * These are mapped to take advantage of the common locations for many of
339  * the bits on all of the currently supported MAC chips. This is to make
340  * the ISR as efficient as possible, while still abstracting HW differences.
341  * When new hardware breaks this commonality this enumerated type, as well
342  * as the HAL functions using it, must be modified. All values are directly
343  * mapped unless commented otherwise.
344  */
345 typedef enum {
346         HAL_INT_RX      = 0x00000001,   /* Non-common mapping */
347         HAL_INT_RXDESC  = 0x00000002,
348         HAL_INT_RXNOFRM = 0x00000008,
349         HAL_INT_RXEOL   = 0x00000010,
350         HAL_INT_RXORN   = 0x00000020,
351         HAL_INT_TX      = 0x00000040,   /* Non-common mapping */
352         HAL_INT_TXDESC  = 0x00000080,
353         HAL_INT_TXURN   = 0x00000800,
354         HAL_INT_MIB     = 0x00001000,
355         HAL_INT_RXPHY   = 0x00004000,
356         HAL_INT_RXKCM   = 0x00008000,
357         HAL_INT_SWBA    = 0x00010000,
358         HAL_INT_BMISS   = 0x00040000,
359         HAL_INT_BNR     = 0x00100000,   /* Non-common mapping */
360         HAL_INT_TIM     = 0x00200000,   /* Non-common mapping */
361         HAL_INT_DTIM    = 0x00400000,   /* Non-common mapping */
362         HAL_INT_DTIMSYNC= 0x00800000,   /* Non-common mapping */
363         HAL_INT_GPIO    = 0x01000000,
364         HAL_INT_CABEND  = 0x02000000,   /* Non-common mapping */
365         HAL_INT_CST     = 0x10000000,   /* Non-common mapping */
366         HAL_INT_GTT     = 0x20000000,   /* Non-common mapping */
367         HAL_INT_FATAL   = 0x40000000,   /* Non-common mapping */
368 #define HAL_INT_GLOBAL  0x80000000      /* Set/clear IER */
369         HAL_INT_BMISC   = HAL_INT_TIM
370                         | HAL_INT_DTIM
371                         | HAL_INT_DTIMSYNC
372                         | HAL_INT_CABEND,
373
374         /* Interrupt bits that map directly to ISR/IMR bits */
375         HAL_INT_COMMON  = HAL_INT_RXNOFRM
376                         | HAL_INT_RXDESC
377                         | HAL_INT_RXEOL
378                         | HAL_INT_RXORN
379                         | HAL_INT_TXURN
380                         | HAL_INT_TXDESC
381                         | HAL_INT_MIB
382                         | HAL_INT_RXPHY
383                         | HAL_INT_RXKCM
384                         | HAL_INT_SWBA
385                         | HAL_INT_BMISS
386                         | HAL_INT_GPIO,
387 } HAL_INT;
388
389 typedef enum {
390         HAL_RFGAIN_INACTIVE             = 0,
391         HAL_RFGAIN_READ_REQUESTED       = 1,
392         HAL_RFGAIN_NEED_CHANGE          = 2
393 } HAL_RFGAIN;
394
395 /*
396  * Channels are specified by frequency.
397  */
398 typedef struct {
399         u_int32_t       channelFlags;   /* see below */
400         u_int16_t       channel;        /* setting in Mhz */
401         u_int8_t        privFlags;
402         int8_t          maxRegTxPower;  /* max regulatory tx power in dBm */
403         int8_t          maxTxPower;     /* max true tx power in 0.5 dBm */
404         int8_t          minTxPower;     /* min true tx power in 0.5 dBm */
405 } HAL_CHANNEL;
406
407 /* channelFlags */
408 #define CHANNEL_CW_INT  0x00002 /* CW interference detected on channel */
409 #define CHANNEL_TURBO   0x00010 /* Turbo Channel */
410 #define CHANNEL_CCK     0x00020 /* CCK channel */
411 #define CHANNEL_OFDM    0x00040 /* OFDM channel */
412 #define CHANNEL_2GHZ    0x00080 /* 2 GHz spectrum channel */
413 #define CHANNEL_5GHZ    0x00100 /* 5 GHz spectrum channel */
414 #define CHANNEL_PASSIVE 0x00200 /* Only passive scan allowed in the channel */
415 #define CHANNEL_DYN     0x00400 /* dynamic CCK-OFDM channel */
416 #define CHANNEL_XR      0x00800 /* XR channel */
417 #define CHANNEL_STURBO  0x02000 /* Static turbo, no 11a-only usage */
418 #define CHANNEL_HALF    0x04000 /* Half rate channel */
419 #define CHANNEL_QUARTER 0x08000 /* Quarter rate channel */
420 #define CHANNEL_HT20    0x10000 /* 11n 20MHZ channel */ 
421 #define CHANNEL_HT40PLUS 0x20000 /* 11n 40MHZ channel w/ ext chan above */
422 #define CHANNEL_HT40MINUS 0x40000 /* 11n 40MHZ channel w/ ext chan below */
423
424 /* privFlags */
425 #define CHANNEL_INTERFERENCE    0x01 /* Software use: channel interference 
426                                         used for as AR as well as RADAR 
427                                         interference detection */
428 #define CHANNEL_DFS             0x02 /* DFS required on channel */
429 #define CHANNEL_4MS_LIMIT       0x04 /* 4msec packet limit on this channel */
430 #define CHANNEL_DFS_CLEAR       0x08 /* if channel has been checked for DFS */
431
432 #define CHANNEL_A       (CHANNEL_5GHZ|CHANNEL_OFDM)
433 #define CHANNEL_B       (CHANNEL_2GHZ|CHANNEL_CCK)
434 #define CHANNEL_PUREG   (CHANNEL_2GHZ|CHANNEL_OFDM)
435 #ifdef notdef
436 #define CHANNEL_G       (CHANNEL_2GHZ|CHANNEL_DYN)
437 #else
438 #define CHANNEL_G       (CHANNEL_2GHZ|CHANNEL_OFDM)
439 #endif
440 #define CHANNEL_T       (CHANNEL_5GHZ|CHANNEL_OFDM|CHANNEL_TURBO)
441 #define CHANNEL_ST      (CHANNEL_T|CHANNEL_STURBO)
442 #define CHANNEL_108G    (CHANNEL_2GHZ|CHANNEL_OFDM|CHANNEL_TURBO)
443 #define CHANNEL_108A    CHANNEL_T
444 #define CHANNEL_X       (CHANNEL_5GHZ|CHANNEL_OFDM|CHANNEL_XR)
445 #define CHANNEL_G_HT20          (CHANNEL_G|CHANNEL_HT20)
446 #define CHANNEL_A_HT20          (CHANNEL_A|CHANNEL_HT20)
447 #define CHANNEL_G_HT40PLUS      (CHANNEL_G|CHANNEL_HT40PLUS)
448 #define CHANNEL_G_HT40MINUS     (CHANNEL_G|CHANNEL_HT40MINUS)
449 #define CHANNEL_A_HT40PLUS      (CHANNEL_A|CHANNEL_HT40PLUS)
450 #define CHANNEL_A_HT40MINUS     (CHANNEL_A|CHANNEL_HT40MINUS)
451 #define CHANNEL_ALL \
452         (CHANNEL_OFDM | CHANNEL_CCK| CHANNEL_2GHZ | CHANNEL_5GHZ | \
453          CHANNEL_TURBO | CHANNEL_HT20 | CHANNEL_HT40PLUS | CHANNEL_HT40MINUS)
454 #define CHANNEL_ALL_NOTURBO     (CHANNEL_ALL &~ CHANNEL_TURBO)
455
456 #define HAL_ANTENNA_MIN_MODE  0
457 #define HAL_ANTENNA_FIXED_A   1
458 #define HAL_ANTENNA_FIXED_B   2
459 #define HAL_ANTENNA_MAX_MODE  3
460
461 typedef struct {
462         u_int32_t       ackrcv_bad;
463         u_int32_t       rts_bad;
464         u_int32_t       rts_good;
465         u_int32_t       fcs_bad;
466         u_int32_t       beacons;
467 } HAL_MIB_STATS;
468
469 typedef u_int16_t HAL_CTRY_CODE;                /* country code */
470 typedef u_int16_t HAL_REG_DOMAIN;               /* regulatory domain code */
471
472 enum {
473         CTRY_DEBUG      = 0x1ff,                /* debug country code */
474         CTRY_DEFAULT    = 0                     /* default country code */
475 };
476
477 enum {
478         HAL_MODE_11A    = 0x001,                /* 11a channels */
479         HAL_MODE_TURBO  = 0x002,                /* 11a turbo-only channels */
480         HAL_MODE_11B    = 0x004,                /* 11b channels */
481         HAL_MODE_PUREG  = 0x008,                /* 11g channels (OFDM only) */
482 #ifdef notdef
483         HAL_MODE_11G    = 0x010,                /* 11g channels (OFDM/CCK) */
484 #else
485         HAL_MODE_11G    = 0x008,                /* XXX historical */
486 #endif
487         HAL_MODE_108G   = 0x020,                /* 11a+Turbo channels */
488         HAL_MODE_108A   = 0x040,                /* 11g+Turbo channels */
489         HAL_MODE_XR     = 0x100,                /* XR channels */
490         HAL_MODE_11A_HALF_RATE = 0x200,         /* 11A half rate channels */
491         HAL_MODE_11A_QUARTER_RATE = 0x400,      /* 11A quarter rate channels */
492         HAL_MODE_11NG_HT20      = 0x008000,
493         HAL_MODE_11NA_HT20      = 0x010000,
494         HAL_MODE_11NG_HT40PLUS  = 0x020000,
495         HAL_MODE_11NG_HT40MINUS = 0x040000,
496         HAL_MODE_11NA_HT40PLUS  = 0x080000,
497         HAL_MODE_11NA_HT40MINUS = 0x100000,
498         HAL_MODE_ALL    = 0xffffff
499 };
500
501 typedef struct {
502         int             rateCount;              /* NB: for proper padding */
503         u_int8_t        rateCodeToIndex[144];   /* back mapping */
504         struct {
505                 u_int8_t        valid;          /* valid for rate control use */
506                 u_int8_t        phy;            /* CCK/OFDM/XR */
507                 u_int32_t       rateKbps;       /* transfer rate in kbs */
508                 u_int8_t        rateCode;       /* rate for h/w descriptors */
509                 u_int8_t        shortPreamble;  /* mask for enabling short
510                                                  * preamble in CCK rate code */
511                 u_int8_t        dot11Rate;      /* value for supported rates
512                                                  * info element of MLME */
513                 u_int8_t        controlRate;    /* index of next lower basic
514                                                  * rate; used for dur. calcs */
515                 u_int16_t       lpAckDuration;  /* long preamble ACK duration */
516                 u_int16_t       spAckDuration;  /* short preamble ACK duration*/
517         } info[32];
518 } HAL_RATE_TABLE;
519
520 typedef struct {
521         u_int           rs_count;               /* number of valid entries */
522         u_int8_t        rs_rates[32];           /* rates */
523 } HAL_RATE_SET;
524
525 /*
526  * 802.11n specific structures and enums
527  */
528 typedef enum {
529         HAL_CHAINTYPE_TX        = 1,    /* Tx chain type */
530         HAL_CHAINTYPE_RX        = 2,    /* RX chain type */
531 } HAL_CHAIN_TYPE;
532
533 typedef struct {
534         u_int   Tries;
535         u_int   Rate;
536         u_int   PktDuration;
537         u_int   ChSel;
538         u_int   RateFlags;
539 #define HAL_RATESERIES_RTS_CTS          0x0001  /* use rts/cts w/this series */
540 #define HAL_RATESERIES_2040             0x0002  /* use ext channel for series */
541 #define HAL_RATESERIES_HALFGI           0x0004  /* use half-gi for series */
542 } HAL_11N_RATE_SERIES;
543
544 typedef enum {
545         HAL_HT_MACMODE_20       = 0,    /* 20 MHz operation */
546         HAL_HT_MACMODE_2040     = 1,    /* 20/40 MHz operation */
547 } HAL_HT_MACMODE;
548
549 typedef enum {
550         HAL_HT_PHYMODE_20       = 0,    /* 20 MHz operation */
551         HAL_HT_PHYMODE_2040     = 1,    /* 20/40 MHz operation */
552 } HAL_HT_PHYMODE;
553
554 typedef enum {
555         HAL_HT_EXTPROTSPACING_20 = 0,   /* 20 MHz spacing */
556         HAL_HT_EXTPROTSPACING_25 = 1,   /* 25 MHz spacing */
557 } HAL_HT_EXTPROTSPACING;
558
559
560 typedef enum {
561         HAL_RX_CLEAR_CTL_LOW    = 0x1,  /* force control channel to appear busy */
562         HAL_RX_CLEAR_EXT_LOW    = 0x2,  /* force extension channel to appear busy */
563 } HAL_HT_RXCLEAR;
564
565 /*
566  * Antenna switch control.  By default antenna selection
567  * enables multiple (2) antenna use.  To force use of the
568  * A or B antenna only specify a fixed setting.  Fixing
569  * the antenna will also disable any diversity support.
570  */
571 typedef enum {
572         HAL_ANT_VARIABLE = 0,                   /* variable by programming */
573         HAL_ANT_FIXED_A  = 1,                   /* fixed antenna A */
574         HAL_ANT_FIXED_B  = 2,                   /* fixed antenna B */
575 } HAL_ANT_SETTING;
576
577 typedef enum {
578         HAL_M_STA       = 1,                    /* infrastructure station */
579         HAL_M_IBSS      = 0,                    /* IBSS (adhoc) station */
580         HAL_M_HOSTAP    = 6,                    /* Software Access Point */
581         HAL_M_MONITOR   = 8                     /* Monitor mode */
582 } HAL_OPMODE;
583
584 typedef struct {
585         u_int8_t        kv_type;                /* one of HAL_CIPHER */
586         u_int8_t        kv_pad;
587         u_int16_t       kv_len;                 /* length in bits */
588         u_int8_t        kv_val[16];             /* enough for 128-bit keys */
589         u_int8_t        kv_mic[8];              /* TKIP MIC key */
590         u_int8_t        kv_txmic[8];            /* TKIP TX MIC key (optional) */
591 } HAL_KEYVAL;
592
593 typedef enum {
594         HAL_CIPHER_WEP          = 0,
595         HAL_CIPHER_AES_OCB      = 1,
596         HAL_CIPHER_AES_CCM      = 2,
597         HAL_CIPHER_CKIP         = 3,
598         HAL_CIPHER_TKIP         = 4,
599         HAL_CIPHER_CLR          = 5,            /* no encryption */
600
601         HAL_CIPHER_MIC          = 127           /* TKIP-MIC, not a cipher */
602 } HAL_CIPHER;
603
604 enum {
605         HAL_SLOT_TIME_6  = 6,                   /* NB: for turbo mode */
606         HAL_SLOT_TIME_9  = 9,
607         HAL_SLOT_TIME_20 = 20,
608 };
609
610 /*
611  * Per-station beacon timer state.  Note that the specified
612  * beacon interval (given in TU's) can also include flags
613  * to force a TSF reset and to enable the beacon xmit logic.
614  * If bs_cfpmaxduration is non-zero the hardware is setup to
615  * coexist with a PCF-capable AP.
616  */
617 typedef struct {
618         u_int32_t       bs_nexttbtt;            /* next beacon in TU */
619         u_int32_t       bs_nextdtim;            /* next DTIM in TU */
620         u_int32_t       bs_intval;              /* beacon interval+flags */
621 #define HAL_BEACON_PERIOD       0x0000ffff      /* beacon interval period */
622 #define HAL_BEACON_ENA          0x00800000      /* beacon xmit enable */
623 #define HAL_BEACON_RESET_TSF    0x01000000      /* clear TSF */
624         u_int32_t       bs_dtimperiod;
625         u_int16_t       bs_cfpperiod;           /* CFP period in TU */
626         u_int16_t       bs_cfpmaxduration;      /* max CFP duration in TU */
627         u_int32_t       bs_cfpnext;             /* next CFP in TU */
628         u_int16_t       bs_timoffset;           /* byte offset to TIM bitmap */
629         u_int16_t       bs_bmissthreshold;      /* beacon miss threshold */
630         u_int32_t       bs_sleepduration;       /* max sleep duration */
631 } HAL_BEACON_STATE;
632
633 /*
634  * Like HAL_BEACON_STATE but for non-station mode setup.
635  * NB: see above flag definitions for bt_intval. 
636  */
637 typedef struct {
638         u_int32_t       bt_intval;              /* beacon interval+flags */
639         u_int32_t       bt_nexttbtt;            /* next beacon in TU */
640         u_int32_t       bt_nextatim;            /* next ATIM in TU */
641         u_int32_t       bt_nextdba;             /* next DBA in 1/8th TU */
642         u_int32_t       bt_nextswba;            /* next SWBA in 1/8th TU */
643         u_int32_t       bt_flags;               /* timer enables */
644 #define HAL_BEACON_TBTT_EN      0x00000001
645 #define HAL_BEACON_DBA_EN       0x00000002
646 #define HAL_BEACON_SWBA_EN      0x00000004
647 } HAL_BEACON_TIMERS;
648
649 /*
650  * Per-node statistics maintained by the driver for use in
651  * optimizing signal quality and other operational aspects.
652  */
653 typedef struct {
654         u_int32_t       ns_avgbrssi;    /* average beacon rssi */
655         u_int32_t       ns_avgrssi;     /* average data rssi */
656         u_int32_t       ns_avgtxrssi;   /* average tx rssi */
657 } HAL_NODE_STATS;
658
659 #define HAL_RSSI_EP_MULTIPLIER  (1<<7)  /* pow2 to optimize out * and / */
660
661 struct ath_desc;
662 struct ath_tx_status;
663 struct ath_rx_status;
664
665 /*
666  * Hardware Access Layer (HAL) API.
667  *
668  * Clients of the HAL call ath_hal_attach to obtain a reference to an
669  * ath_hal structure for use with the device.  Hardware-related operations
670  * that follow must call back into the HAL through interface, supplying
671  * the reference as the first parameter.  Note that before using the
672  * reference returned by ath_hal_attach the caller should verify the
673  * ABI version number.
674  */
675 struct ath_hal {
676         u_int32_t       ah_magic;       /* consistency check magic number */
677         u_int32_t       ah_abi;         /* HAL ABI version */
678 #define HAL_ABI_VERSION 0x08060800      /* YYMMDDnn */
679         u_int16_t       ah_devid;       /* PCI device ID */
680         u_int16_t       ah_subvendorid; /* PCI subvendor ID */
681         HAL_SOFTC       ah_sc;          /* back pointer to driver/os state */
682         HAL_BUS_TAG     ah_st;          /* params for register r+w */
683         HAL_BUS_HANDLE  ah_sh;
684         HAL_CTRY_CODE   ah_countryCode;
685
686         u_int32_t       ah_macVersion;  /* MAC version id */
687         u_int16_t       ah_macRev;      /* MAC revision */
688         u_int16_t       ah_phyRev;      /* PHY revision */
689         /* NB: when only one radio is present the rev is in 5Ghz */
690         u_int16_t       ah_analog5GhzRev;/* 5GHz radio revision */
691         u_int16_t       ah_analog2GhzRev;/* 2GHz radio revision */
692
693         const HAL_RATE_TABLE *__ahdecl(*ah_getRateTable)(struct ath_hal *,
694                                 u_int mode);
695         void      __ahdecl(*ah_detach)(struct ath_hal*);
696
697         /* Reset functions */
698         HAL_BOOL  __ahdecl(*ah_reset)(struct ath_hal *, HAL_OPMODE,
699                                 HAL_CHANNEL *, HAL_BOOL bChannelChange,
700                                 HAL_STATUS *status);
701         HAL_BOOL  __ahdecl(*ah_phyDisable)(struct ath_hal *);
702         HAL_BOOL  __ahdecl(*ah_disable)(struct ath_hal *);
703         void      __ahdecl(*ah_setPCUConfig)(struct ath_hal *);
704         HAL_BOOL  __ahdecl(*ah_perCalibration)(struct ath_hal*, HAL_CHANNEL *, HAL_BOOL *);
705         HAL_BOOL  __ahdecl(*ah_setTxPowerLimit)(struct ath_hal *, u_int32_t);
706
707         /* DFS support */
708         HAL_BOOL  __ahdecl(*ah_radarWait)(struct ath_hal *, HAL_CHANNEL *);
709
710         /* Transmit functions */
711         HAL_BOOL  __ahdecl(*ah_updateTxTrigLevel)(struct ath_hal*,
712                                 HAL_BOOL incTrigLevel);
713         int       __ahdecl(*ah_setupTxQueue)(struct ath_hal *, HAL_TX_QUEUE,
714                                 const HAL_TXQ_INFO *qInfo);
715         HAL_BOOL  __ahdecl(*ah_setTxQueueProps)(struct ath_hal *, int q, 
716                                 const HAL_TXQ_INFO *qInfo);
717         HAL_BOOL  __ahdecl(*ah_getTxQueueProps)(struct ath_hal *, int q, 
718                                 HAL_TXQ_INFO *qInfo);
719         HAL_BOOL  __ahdecl(*ah_releaseTxQueue)(struct ath_hal *ah, u_int q);
720         HAL_BOOL  __ahdecl(*ah_resetTxQueue)(struct ath_hal *ah, u_int q);
721         u_int32_t __ahdecl(*ah_getTxDP)(struct ath_hal*, u_int);
722         HAL_BOOL  __ahdecl(*ah_setTxDP)(struct ath_hal*, u_int, u_int32_t txdp);
723         u_int32_t __ahdecl(*ah_numTxPending)(struct ath_hal *, u_int q);
724         HAL_BOOL  __ahdecl(*ah_startTxDma)(struct ath_hal*, u_int);
725         HAL_BOOL  __ahdecl(*ah_stopTxDma)(struct ath_hal*, u_int);
726         HAL_BOOL  __ahdecl(*ah_setupTxDesc)(struct ath_hal *, struct ath_desc *,
727                                 u_int pktLen, u_int hdrLen,
728                                 HAL_PKT_TYPE type, u_int txPower,
729                                 u_int txRate0, u_int txTries0,
730                                 u_int keyIx, u_int antMode, u_int flags,
731                                 u_int rtsctsRate, u_int rtsctsDuration,
732                                 u_int compicvLen, u_int compivLen,
733                                 u_int comp);
734         HAL_BOOL  __ahdecl(*ah_setupXTxDesc)(struct ath_hal *, struct ath_desc*,
735                                 u_int txRate1, u_int txTries1,
736                                 u_int txRate2, u_int txTries2,
737                                 u_int txRate3, u_int txTries3);
738         HAL_BOOL  __ahdecl(*ah_fillTxDesc)(struct ath_hal *, struct ath_desc *,
739                                 u_int segLen, HAL_BOOL firstSeg,
740                                 HAL_BOOL lastSeg, const struct ath_desc *);
741         HAL_STATUS __ahdecl(*ah_procTxDesc)(struct ath_hal *,
742                                 struct ath_desc *, struct ath_tx_status *);
743         void       __ahdecl(*ah_getTxIntrQueue)(struct ath_hal *, u_int32_t *);
744         void       __ahdecl(*ah_reqTxIntrDesc)(struct ath_hal *, struct ath_desc*);
745
746         /* Receive Functions */
747         u_int32_t __ahdecl(*ah_getRxDP)(struct ath_hal*);
748         void      __ahdecl(*ah_setRxDP)(struct ath_hal*, u_int32_t rxdp);
749         void      __ahdecl(*ah_enableReceive)(struct ath_hal*);
750         HAL_BOOL  __ahdecl(*ah_stopDmaReceive)(struct ath_hal*);
751         void      __ahdecl(*ah_startPcuReceive)(struct ath_hal*);
752         void      __ahdecl(*ah_stopPcuReceive)(struct ath_hal*);
753         void      __ahdecl(*ah_setMulticastFilter)(struct ath_hal*,
754                                 u_int32_t filter0, u_int32_t filter1);
755         HAL_BOOL  __ahdecl(*ah_setMulticastFilterIndex)(struct ath_hal*,
756                                 u_int32_t index);
757         HAL_BOOL  __ahdecl(*ah_clrMulticastFilterIndex)(struct ath_hal*,
758                                 u_int32_t index);
759         u_int32_t __ahdecl(*ah_getRxFilter)(struct ath_hal*);
760         void      __ahdecl(*ah_setRxFilter)(struct ath_hal*, u_int32_t);
761         HAL_BOOL  __ahdecl(*ah_setupRxDesc)(struct ath_hal *, struct ath_desc *,
762                                 u_int32_t size, u_int flags);
763         HAL_STATUS __ahdecl(*ah_procRxDesc)(struct ath_hal *,
764                                 struct ath_desc *, u_int32_t phyAddr,
765                                 struct ath_desc *next, u_int64_t tsf,
766                                 struct ath_rx_status *);
767         void      __ahdecl(*ah_rxMonitor)(struct ath_hal *,
768                                 const HAL_NODE_STATS *, HAL_CHANNEL *);
769         void      __ahdecl(*ah_procMibEvent)(struct ath_hal *,
770                                 const HAL_NODE_STATS *);
771
772         /* Misc Functions */
773         HAL_STATUS __ahdecl(*ah_getCapability)(struct ath_hal *,
774                                 HAL_CAPABILITY_TYPE, u_int32_t capability,
775                                 u_int32_t *result);
776         HAL_BOOL   __ahdecl(*ah_setCapability)(struct ath_hal *,
777                                 HAL_CAPABILITY_TYPE, u_int32_t capability,
778                                 u_int32_t setting, HAL_STATUS *);
779         HAL_BOOL   __ahdecl(*ah_getDiagState)(struct ath_hal *, int request,
780                                 const void *args, u_int32_t argsize,
781                                 void **result, u_int32_t *resultsize);
782         void      __ahdecl(*ah_getMacAddress)(struct ath_hal *, u_int8_t *);
783         HAL_BOOL  __ahdecl(*ah_setMacAddress)(struct ath_hal *, const u_int8_t*);
784         void      __ahdecl(*ah_getBssIdMask)(struct ath_hal *, u_int8_t *);
785         HAL_BOOL  __ahdecl(*ah_setBssIdMask)(struct ath_hal *, const u_int8_t*);
786         HAL_BOOL  __ahdecl(*ah_setRegulatoryDomain)(struct ath_hal*,
787                                 u_int16_t, HAL_STATUS *);
788         void      __ahdecl(*ah_setLedState)(struct ath_hal*, HAL_LED_STATE);
789         void      __ahdecl(*ah_writeAssocid)(struct ath_hal*,
790                                 const u_int8_t *bssid, u_int16_t assocId);
791         HAL_BOOL  __ahdecl(*ah_gpioCfgOutput)(struct ath_hal *, u_int32_t gpio);
792         HAL_BOOL  __ahdecl(*ah_gpioCfgInput)(struct ath_hal *, u_int32_t gpio);
793         u_int32_t __ahdecl(*ah_gpioGet)(struct ath_hal *, u_int32_t gpio);
794         HAL_BOOL  __ahdecl(*ah_gpioSet)(struct ath_hal *,
795                                 u_int32_t gpio, u_int32_t val);
796         void      __ahdecl(*ah_gpioSetIntr)(struct ath_hal*, u_int, u_int32_t);
797         u_int32_t __ahdecl(*ah_getTsf32)(struct ath_hal*);
798         u_int64_t __ahdecl(*ah_getTsf64)(struct ath_hal*);
799         void      __ahdecl(*ah_resetTsf)(struct ath_hal*);
800         HAL_BOOL  __ahdecl(*ah_detectCardPresent)(struct ath_hal*);
801         void      __ahdecl(*ah_updateMibCounters)(struct ath_hal*,
802                                 HAL_MIB_STATS*);
803         HAL_RFGAIN __ahdecl(*ah_getRfGain)(struct ath_hal*);
804         u_int     __ahdecl(*ah_getDefAntenna)(struct ath_hal*);
805         void      __ahdecl(*ah_setDefAntenna)(struct ath_hal*, u_int);
806         HAL_ANT_SETTING  __ahdecl(*ah_getAntennaSwitch)(struct ath_hal*);
807         HAL_BOOL  __ahdecl(*ah_setAntennaSwitch)(struct ath_hal*,
808                                 HAL_ANT_SETTING);
809         HAL_BOOL  __ahdecl(*ah_setSifsTime)(struct ath_hal*, u_int);
810         u_int     __ahdecl(*ah_getSifsTime)(struct ath_hal*);
811         HAL_BOOL  __ahdecl(*ah_setSlotTime)(struct ath_hal*, u_int);
812         u_int     __ahdecl(*ah_getSlotTime)(struct ath_hal*);
813         HAL_BOOL  __ahdecl(*ah_setAckTimeout)(struct ath_hal*, u_int);
814         u_int     __ahdecl(*ah_getAckTimeout)(struct ath_hal*);
815         HAL_BOOL  __ahdecl(*ah_setAckCTSRate)(struct ath_hal*, u_int);
816         u_int     __ahdecl(*ah_getAckCTSRate)(struct ath_hal*);
817         HAL_BOOL  __ahdecl(*ah_setCTSTimeout)(struct ath_hal*, u_int);
818         u_int     __ahdecl(*ah_getCTSTimeout)(struct ath_hal*);
819         HAL_BOOL  __ahdecl(*ah_setDecompMask)(struct ath_hal*, u_int16_t, int);
820         void      __ahdecl(*ah_setCoverageClass)(struct ath_hal*, u_int8_t, int);
821
822         /* Key Cache Functions */
823         u_int32_t __ahdecl(*ah_getKeyCacheSize)(struct ath_hal*);
824         HAL_BOOL  __ahdecl(*ah_resetKeyCacheEntry)(struct ath_hal*, u_int16_t);
825         HAL_BOOL  __ahdecl(*ah_isKeyCacheEntryValid)(struct ath_hal *,
826                                 u_int16_t);
827         HAL_BOOL  __ahdecl(*ah_setKeyCacheEntry)(struct ath_hal*,
828                                 u_int16_t, const HAL_KEYVAL *,
829                                 const u_int8_t *, int);
830         HAL_BOOL  __ahdecl(*ah_setKeyCacheEntryMac)(struct ath_hal*,
831                                 u_int16_t, const u_int8_t *);
832
833         /* Power Management Functions */
834         HAL_BOOL  __ahdecl(*ah_setPowerMode)(struct ath_hal*,
835                                 HAL_POWER_MODE mode, int setChip);
836         HAL_POWER_MODE __ahdecl(*ah_getPowerMode)(struct ath_hal*);
837         int16_t   __ahdecl(*ah_getChanNoise)(struct ath_hal *, HAL_CHANNEL *);
838
839         /* Beacon Management Functions */
840         void      __ahdecl(*ah_setBeaconTimers)(struct ath_hal*,
841                                 const HAL_BEACON_TIMERS *);
842         /* NB: deprecated, use ah_setBeaconTimers instead */
843         void      __ahdecl(*ah_beaconInit)(struct ath_hal *,
844                                 u_int32_t nexttbtt, u_int32_t intval);
845         void      __ahdecl(*ah_setStationBeaconTimers)(struct ath_hal*,
846                                 const HAL_BEACON_STATE *);
847         void      __ahdecl(*ah_resetStationBeaconTimers)(struct ath_hal*);
848
849         /* Interrupt functions */
850         HAL_BOOL  __ahdecl(*ah_isInterruptPending)(struct ath_hal*);
851         HAL_BOOL  __ahdecl(*ah_getPendingInterrupts)(struct ath_hal*, HAL_INT*);
852         HAL_INT   __ahdecl(*ah_getInterrupts)(struct ath_hal*);
853         HAL_INT   __ahdecl(*ah_setInterrupts)(struct ath_hal*, HAL_INT);
854 };
855
856 /* 
857  * Check the PCI vendor ID and device ID against Atheros' values
858  * and return a printable description for any Atheros hardware.
859  * AH_NULL is returned if the ID's do not describe Atheros hardware.
860  */
861 extern  const char *__ahdecl ath_hal_probe(u_int16_t vendorid, u_int16_t devid);
862
863 /*
864  * Attach the HAL for use with the specified device.  The device is
865  * defined by the PCI device ID.  The caller provides an opaque pointer
866  * to an upper-layer data structure (HAL_SOFTC) that is stored in the
867  * HAL state block for later use.  Hardware register accesses are done
868  * using the specified bus tag and handle.  On successful return a
869  * reference to a state block is returned that must be supplied in all
870  * subsequent HAL calls.  Storage associated with this reference is
871  * dynamically allocated and must be freed by calling the ah_detach
872  * method when the client is done.  If the attach operation fails a
873  * null (AH_NULL) reference will be returned and a status code will
874  * be returned if the status parameter is non-zero.
875  */
876 extern  struct ath_hal * __ahdecl ath_hal_attach(u_int16_t devid, HAL_SOFTC,
877                 HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS* status);
878
879 /*
880  * Set the Vendor ID for Vendor SKU's which can modify the
881  * channel properties returned by ath_hal_init_channels.
882  */
883 extern  HAL_BOOL __ahdecl ath_hal_setvendor(struct ath_hal *, u_int32_t );
884
885 /*
886  * Return a list of channels available for use with the hardware.
887  * The list is based on what the hardware is capable of, the specified
888  * country code, the modeSelect mask, and whether or not outdoor
889  * channels are to be permitted.
890  *
891  * The channel list is returned in the supplied array.  maxchans
892  * defines the maximum size of this array.  nchans contains the actual
893  * number of channels returned.  If a problem occurred or there were
894  * no channels that met the criteria then AH_FALSE is returned.
895  */
896 extern  HAL_BOOL __ahdecl ath_hal_init_channels(struct ath_hal *,
897                 HAL_CHANNEL *chans, u_int maxchans, u_int *nchans,
898                 u_int8_t *regclassids, u_int maxregids, u_int *nregids,
899                 HAL_CTRY_CODE cc, u_int modeSelect,
900                 HAL_BOOL enableOutdoor, HAL_BOOL enableExtendedChannels);
901
902 /*
903  * Calibrate noise floor data following a channel scan or similar.
904  * This must be called prior retrieving noise floor data.
905  */
906 extern  void __ahdecl ath_hal_process_noisefloor(struct ath_hal *ah);
907
908 /*
909  * Return bit mask of wireless modes supported by the hardware.
910  */
911 extern  u_int __ahdecl ath_hal_getwirelessmodes(struct ath_hal*, HAL_CTRY_CODE);
912
913 /*
914  * Calculate the transmit duration of a frame.
915  */
916 extern u_int16_t __ahdecl ath_hal_computetxtime(struct ath_hal *,
917                 const HAL_RATE_TABLE *rates, u_int32_t frameLen,
918                 u_int16_t rateix, HAL_BOOL shortPreamble);
919
920 /*
921  * Return if device is public safety.
922  */
923 extern HAL_BOOL __ahdecl ath_hal_ispublicsafetysku(struct ath_hal *);
924
925 /*
926  * Return if device is operating in 900 MHz band.
927  */
928 extern HAL_BOOL ath_hal_isgsmsku(struct ath_hal *);
929
930 /*
931  * Convert between IEEE channel number and channel frequency
932  * using the specified channel flags; e.g. CHANNEL_2GHZ.
933  */
934 extern  int __ahdecl ath_hal_mhz2ieee(struct ath_hal *, u_int mhz, u_int flags);
935
936 /*
937  * Return a version string for the HAL release.
938  */
939 extern  char ath_hal_version[];
940 /*
941  * Return a NULL-terminated array of build/configuration options.
942  */
943 extern  const char* ath_hal_buildopts[];
944 #endif /* _ATH_AH_H_ */