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