ath6kl: use CONFIG_AR600x_WB31_XXX
[pandora-kernel.git] / drivers / staging / ath6kl / os / linux / include / ar6000_drv.h
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2004-2010 Atheros Communications Inc.
3 // All rights reserved.
4 //
5 // 
6 //
7 // Permission to use, copy, modify, and/or distribute this software for any
8 // purpose with or without fee is hereby granted, provided that the above
9 // copyright notice and this permission notice appear in all copies.
10 //
11 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 //
19 //
20 //
21 // Author(s): ="Atheros"
22 //------------------------------------------------------------------------------
23
24 #ifndef _AR6000_H_
25 #define _AR6000_H_
26
27 #include <linux/init.h>
28 #include <linux/sched.h>
29 #include <linux/spinlock.h>
30 #include <linux/if_ether.h>
31 #include <linux/etherdevice.h>
32 #include <net/iw_handler.h>
33 #include <linux/if_arp.h>
34 #include <linux/ip.h>
35 #include <linux/wireless.h>
36 #include <net/cfg80211.h>
37 #include <linux/module.h>
38 #include <asm/io.h>
39
40 #include <a_config.h>
41 #include <athdefs.h>
42 #include "a_types.h"
43 #include "a_osapi.h"
44 #include "htc_api.h"
45 #include "wmi.h"
46 #include "a_drv.h"
47 #include "bmi.h"
48 #include <ieee80211.h>
49 #include <ieee80211_ioctl.h>
50 #include <wlan_api.h>
51 #include <wmi_api.h>
52 #include "gpio_api.h"
53 #include "gpio.h"
54 #include "pkt_log.h"
55 #include "aggr_recv_api.h"
56 #include <host_version.h>
57 #include <linux/rtnetlink.h>
58 #include <linux/init.h>
59 #include <linux/moduleparam.h>
60 #include "ar6000_api.h"
61 #ifdef CONFIG_HOST_TCMD_SUPPORT
62 #include <testcmd.h>
63 #endif
64 #include <linux/firmware.h>
65
66 #include "targaddrs.h"
67 #include "dbglog_api.h"
68 #include "ar6000_diag.h"
69 #include "common_drv.h"
70 #include "roaming.h"
71 #include "hci_transport_api.h"
72 #define ATH_MODULE_NAME driver
73 #include "a_debug.h"
74 #include "hw/apb_map.h"
75 #include "hw/rtc_reg.h"
76 #include "hw/mbox_reg.h"
77 #include "hw/gpio_reg.h"
78
79 #define  ATH_DEBUG_DBG_LOG       ATH_DEBUG_MAKE_MODULE_MASK(0)
80 #define  ATH_DEBUG_WLAN_CONNECT  ATH_DEBUG_MAKE_MODULE_MASK(1)
81 #define  ATH_DEBUG_WLAN_SCAN     ATH_DEBUG_MAKE_MODULE_MASK(2)
82 #define  ATH_DEBUG_WLAN_TX       ATH_DEBUG_MAKE_MODULE_MASK(3)
83 #define  ATH_DEBUG_WLAN_RX       ATH_DEBUG_MAKE_MODULE_MASK(4)
84 #define  ATH_DEBUG_HTC_RAW       ATH_DEBUG_MAKE_MODULE_MASK(5)
85 #define  ATH_DEBUG_HCI_BRIDGE    ATH_DEBUG_MAKE_MODULE_MASK(6)
86 #define  ATH_DEBUG_HCI_RECV      ATH_DEBUG_MAKE_MODULE_MASK(7)
87 #define  ATH_DEBUG_HCI_SEND      ATH_DEBUG_MAKE_MODULE_MASK(8)
88 #define  ATH_DEBUG_HCI_DUMP      ATH_DEBUG_MAKE_MODULE_MASK(9)
89
90 #ifndef  __dev_put
91 #define  __dev_put(dev) dev_put(dev)
92 #endif
93
94
95 #define USER_SAVEDKEYS_STAT_INIT     0
96 #define USER_SAVEDKEYS_STAT_RUN      1
97
98 // TODO this needs to move into the AR_SOFTC struct
99 struct USER_SAVEDKEYS {
100     struct ieee80211req_key   ucast_ik;
101     struct ieee80211req_key   bcast_ik;
102     CRYPTO_TYPE               keyType;
103     bool                    keyOk;
104 };
105
106 #define DBG_INFO        0x00000001
107 #define DBG_ERROR       0x00000002
108 #define DBG_WARNING     0x00000004
109 #define DBG_SDIO        0x00000008
110 #define DBG_HIF         0x00000010
111 #define DBG_HTC         0x00000020
112 #define DBG_WMI         0x00000040
113 #define DBG_WMI2        0x00000080
114 #define DBG_DRIVER      0x00000100
115
116 #define DBG_DEFAULTS    (DBG_ERROR|DBG_WARNING)
117
118
119 int ar6000_ReadRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data);
120 int ar6000_WriteRegDiag(struct hif_device *hifDevice, u32 *address, u32 *data);
121
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125
126 #define MAX_AR6000                        1
127 #define AR6000_MAX_RX_BUFFERS             16
128 #define AR6000_BUFFER_SIZE                1664
129 #define AR6000_MAX_AMSDU_RX_BUFFERS       4
130 #define AR6000_AMSDU_REFILL_THRESHOLD     3
131 #define AR6000_AMSDU_BUFFER_SIZE          (WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH + 128)
132 #define AR6000_MAX_RX_MESSAGE_SIZE        (max(WMI_MAX_NORMAL_RX_DATA_FRAME_LENGTH,WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH))
133
134 #define AR6000_TX_TIMEOUT                 10
135 #define AR6000_ETH_ADDR_LEN               6
136 #define AR6000_MAX_ENDPOINTS              4
137 #define MAX_NODE_NUM                      15
138 /* MAX_HI_COOKIE_NUM are reserved for high priority traffic */
139 #define MAX_DEF_COOKIE_NUM                180
140 #define MAX_HI_COOKIE_NUM                 18 /* 10% of MAX_COOKIE_NUM */
141 #define MAX_COOKIE_NUM                    (MAX_DEF_COOKIE_NUM + MAX_HI_COOKIE_NUM)
142
143 /* MAX_DEFAULT_SEND_QUEUE_DEPTH is used to set the default queue depth for the
144  * WMM send queues.  If a queue exceeds this depth htc will query back to the
145  * OS specific layer by calling EpSendFull().  This gives the OS layer the
146  * opportunity to drop the packet if desired.  Therefore changing
147  * MAX_DEFAULT_SEND_QUEUE_DEPTH does not affect resource utilization but
148  * does impact the threshold used to identify if a packet should be
149  * dropped. */
150 #define MAX_DEFAULT_SEND_QUEUE_DEPTH      (MAX_DEF_COOKIE_NUM / WMM_NUM_AC)
151
152 #define AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT        1
153 #define AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT  1
154 #define A_DISCONNECT_TIMER_INTERVAL       10 * 1000
155 #define A_DEFAULT_LISTEN_INTERVAL         100
156 #define A_MAX_WOW_LISTEN_INTERVAL         1000
157
158 enum {
159     DRV_HB_CHALLENGE = 0,
160     APP_HB_CHALLENGE
161 };
162
163 enum {
164     WLAN_INIT_MODE_NONE = 0,
165     WLAN_INIT_MODE_USR,
166     WLAN_INIT_MODE_UDEV,
167     WLAN_INIT_MODE_DRV
168 };
169
170 /* Suspend - configuration */
171 enum {
172     WLAN_SUSPEND_CUT_PWR = 0,
173     WLAN_SUSPEND_DEEP_SLEEP,
174     WLAN_SUSPEND_WOW,
175     WLAN_SUSPEND_CUT_PWR_IF_BT_OFF
176 };
177
178 /* WiFi OFF - configuration */
179 enum {
180     WLAN_OFF_CUT_PWR = 0,
181     WLAN_OFF_DEEP_SLEEP,
182 };
183
184 /* WLAN low power state */
185 enum {
186     WLAN_POWER_STATE_ON = 0,
187     WLAN_POWER_STATE_CUT_PWR = 1,
188     WLAN_POWER_STATE_DEEP_SLEEP,
189     WLAN_POWER_STATE_WOW
190 };
191
192 /* WLAN WoW State */
193 enum {
194     WLAN_WOW_STATE_NONE = 0,
195     WLAN_WOW_STATE_SUSPENDED,
196     WLAN_WOW_STATE_SUSPENDING
197 };
198
199
200 typedef enum _AR6K_BIN_FILE {
201     AR6K_OTP_FILE,
202     AR6K_FIRMWARE_FILE,
203     AR6K_PATCH_FILE,
204     AR6K_BOARD_DATA_FILE,
205 } AR6K_BIN_FILE;
206
207 #ifdef SETUPHCI_ENABLED
208 #define SETUPHCI_DEFAULT           1
209 #else
210 #define SETUPHCI_DEFAULT           0
211 #endif /* SETUPHCI_ENABLED */
212
213 #ifdef SETUPBTDEV_ENABLED
214 #define SETUPBTDEV_DEFAULT         1
215 #else
216 #define SETUPBTDEV_DEFAULT         0
217 #endif /* SETUPBTDEV_ENABLED */
218
219 #ifdef ENABLEUARTPRINT_SET
220 #define ENABLEUARTPRINT_DEFAULT    1
221 #else
222 #define ENABLEUARTPRINT_DEFAULT    0
223 #endif /* ENABLEARTPRINT_SET */
224
225 #ifdef ATH6K_CONFIG_HIF_VIRTUAL_SCATTER
226 #define NOHIFSCATTERSUPPORT_DEFAULT    1
227 #else /* ATH6K_CONFIG_HIF_VIRTUAL_SCATTER */
228 #define NOHIFSCATTERSUPPORT_DEFAULT    0
229 #endif /* ATH6K_CONFIG_HIF_VIRTUAL_SCATTER */
230
231 #ifdef AR600x_BT_AR3001
232 #define AR3KHCIBAUD_DEFAULT        3000000
233 #define HCIUARTSCALE_DEFAULT       1
234 #define HCIUARTSTEP_DEFAULT        8937
235 #else
236 #define AR3KHCIBAUD_DEFAULT        0
237 #define HCIUARTSCALE_DEFAULT       0
238 #define HCIUARTSTEP_DEFAULT        0
239 #endif /* AR600x_BT_AR3001 */
240
241 #define WLAN_INIT_MODE_DEFAULT     WLAN_INIT_MODE_DRV
242
243 #define AR6K_PATCH_DOWNLOAD_ADDRESS(_param, _ver) do { \
244     if ((_ver) == AR6003_REV1_VERSION) { \
245         (_param) = AR6003_REV1_PATCH_DOWNLOAD_ADDRESS; \
246     } else if ((_ver) == AR6003_REV2_VERSION) { \
247         (_param) = AR6003_REV2_PATCH_DOWNLOAD_ADDRESS; \
248     } else { \
249        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
250        A_ASSERT(0); \
251     } \
252 } while (0)
253
254 #define AR6K_DATA_DOWNLOAD_ADDRESS(_param, _ver) do { \
255     if ((_ver) == AR6003_REV1_VERSION) { \
256         (_param) = AR6003_REV1_DATA_DOWNLOAD_ADDRESS; \
257     } else if ((_ver) == AR6003_REV2_VERSION) { \
258         (_param) = AR6003_REV2_DATA_DOWNLOAD_ADDRESS; \
259     } else { \
260        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
261        A_ASSERT(0); \
262     } \
263 } while (0)
264
265 #define AR6K_APP_START_OVERRIDE_ADDRESS(_param, _ver) do { \
266     if ((_ver) == AR6003_REV1_VERSION) { \
267         (_param) = AR6003_REV1_APP_START_OVERRIDE; \
268     } else if ((_ver) == AR6003_REV2_VERSION) { \
269         (_param) = AR6003_REV2_APP_START_OVERRIDE; \
270     } else { \
271        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
272        A_ASSERT(0); \
273     } \
274 } while (0)
275
276 /* AR6003 1.0 definitions */
277 #define AR6003_REV1_VERSION                 0x300002ba
278 #define AR6003_REV1_DATA_DOWNLOAD_ADDRESS   AR6003_REV1_OTP_DATA_ADDRESS
279 #define AR6003_REV1_PATCH_DOWNLOAD_ADDRESS  0x57ea6c
280 #define AR6003_REV1_OTP_FILE                "ath6k/AR6003/hw1.0/otp.bin.z77"
281 #define AR6003_REV1_FIRMWARE_FILE           "ath6k/AR6003/hw1.0/athwlan.bin.z77"
282 #define AR6003_REV1_TCMD_FIRMWARE_FILE      "ath6k/AR6003/hw1.0/athtcmd_ram.bin"
283 #define AR6003_REV1_ART_FIRMWARE_FILE       "ath6k/AR6003/hw1.0/device.bin"
284 #define AR6003_REV1_PATCH_FILE              "ath6k/AR6003/hw1.0/data.patch.bin"
285 #define AR6003_REV1_EPPING_FIRMWARE_FILE    "ath6k/AR6003/hw1.0/endpointping.bin"
286 #ifdef CONFIG_AR600x_SD31_XXX
287 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.SD31.bin"
288 #elif defined(AR600x_SD32_XXX)
289 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.SD32.bin"
290 #elif defined(CONFIG_AR600x_WB31_XXX)
291 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.WB31.bin"
292 #else
293 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.CUSTOM.bin"
294 #endif /* Board Data File */
295
296 /* AR6003 2.0 definitions */
297 #define AR6003_REV2_VERSION                 0x30000384 
298 #define AR6003_REV2_DATA_DOWNLOAD_ADDRESS   AR6003_REV2_OTP_DATA_ADDRESS
299 #define AR6003_REV2_PATCH_DOWNLOAD_ADDRESS  0x57e910
300 #define AR6003_REV2_OTP_FILE                "ath6k/AR6003/hw2.0/otp.bin.z77"
301 #define AR6003_REV2_FIRMWARE_FILE           "ath6k/AR6003/hw2.0/athwlan.bin.z77"
302 #define AR6003_REV2_TCMD_FIRMWARE_FILE      "ath6k/AR6003/hw2.0/athtcmd_ram.bin"
303 #define AR6003_REV2_ART_FIRMWARE_FILE       "ath6k/AR6003/hw2.0/device.bin"
304 #define AR6003_REV2_PATCH_FILE              "ath6k/AR6003/hw2.0/data.patch.bin"
305 #define AR6003_REV2_EPPING_FIRMWARE_FILE    "ath6k/AR6003/hw2.0/endpointping.bin"
306 #ifdef CONFIG_AR600x_SD31_XXX
307 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.SD31.bin"
308 #elif defined(AR600x_SD32_XXX)
309 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.SD32.bin"
310 #elif defined(CONFIG_AR600x_WB31_XXX)
311 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.WB31.bin"
312 #else
313 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.CUSTOM.bin"
314 #endif /* Board Data File */
315
316 /* Power states */
317 enum {
318     WLAN_PWR_CTRL_UP = 0,
319     WLAN_PWR_CTRL_CUT_PWR,
320     WLAN_PWR_CTRL_DEEP_SLEEP,
321     WLAN_PWR_CTRL_WOW,
322     WLAN_PWR_CTRL_DEEP_SLEEP_DISABLED
323 };
324
325 /* HTC RAW streams */
326 typedef enum _HTC_RAW_STREAM_ID {
327     HTC_RAW_STREAM_NOT_MAPPED = -1,
328     HTC_RAW_STREAM_0 = 0,
329     HTC_RAW_STREAM_1 = 1,
330     HTC_RAW_STREAM_2 = 2,
331     HTC_RAW_STREAM_3 = 3,
332     HTC_RAW_STREAM_NUM_MAX
333 } HTC_RAW_STREAM_ID;
334
335 #define RAW_HTC_READ_BUFFERS_NUM    4
336 #define RAW_HTC_WRITE_BUFFERS_NUM   4
337
338 #define HTC_RAW_BUFFER_SIZE  1664
339
340 typedef struct {
341     int currPtr;
342     int length;
343     unsigned char data[HTC_RAW_BUFFER_SIZE];
344     struct htc_packet    HTCPacket;
345 } raw_htc_buffer;
346
347 #ifdef CONFIG_HOST_TCMD_SUPPORT
348 /*
349  *  add TCMD_MODE besides wmi and bypasswmi
350  *  in TCMD_MODE, only few TCMD releated wmi commands
351  *  counld be hanlder
352  */
353 enum {
354     AR6000_WMI_MODE = 0,
355     AR6000_BYPASS_MODE,
356     AR6000_TCMD_MODE,
357     AR6000_WLAN_MODE
358 };
359 #endif /* CONFIG_HOST_TCMD_SUPPORT */
360
361 struct ar_wep_key {
362     u8 arKeyIndex;
363     u8 arKeyLen;
364     u8 arKey[64];
365 } ;
366
367 struct ar_key {
368     u8 key[WLAN_MAX_KEY_LEN];
369     u8 key_len;
370     u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
371     u8 seq_len;
372     u32 cipher;
373 };
374
375 enum {
376     SME_DISCONNECTED,
377     SME_CONNECTING,
378     SME_CONNECTED
379 };
380
381 struct ar_node_mapping {
382     u8 macAddress[6];
383     u8 epId;
384     u8 txPending;
385 };
386
387 struct ar_cookie {
388     unsigned long          arc_bp[2];    /* Must be first field */
389     struct htc_packet             HtcPkt;       /* HTC packet wrapper */
390     struct ar_cookie *arc_list_next;
391 };
392
393 struct ar_hb_chlng_resp {
394     A_TIMER                 timer;
395     u32 frequency;
396     u32 seqNum;
397     bool                  outstanding;
398     u8 missCnt;
399     u8 missThres;
400 };
401
402 /* Per STA data, used in AP mode */
403 /*TODO: All this should move to OS independent dir */
404
405 #define STA_PWR_MGMT_MASK 0x1
406 #define STA_PWR_MGMT_SHIFT 0x0
407 #define STA_PWR_MGMT_AWAKE 0x0
408 #define STA_PWR_MGMT_SLEEP 0x1
409
410 #define STA_SET_PWR_SLEEP(sta) (sta->flags |= (STA_PWR_MGMT_MASK << STA_PWR_MGMT_SHIFT))
411 #define STA_CLR_PWR_SLEEP(sta) (sta->flags &= ~(STA_PWR_MGMT_MASK << STA_PWR_MGMT_SHIFT))
412 #define STA_IS_PWR_SLEEP(sta) ((sta->flags >> STA_PWR_MGMT_SHIFT) & STA_PWR_MGMT_MASK)
413
414 #define STA_PS_POLLED_MASK 0x1
415 #define STA_PS_POLLED_SHIFT 0x1
416 #define STA_SET_PS_POLLED(sta) (sta->flags |= (STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
417 #define STA_CLR_PS_POLLED(sta) (sta->flags &= ~(STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
418 #define STA_IS_PS_POLLED(sta) (sta->flags & (STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
419
420 typedef struct {
421     u16 flags;
422     u8 mac[ATH_MAC_LEN];
423     u8 aid;
424     u8 keymgmt;
425     u8 ucipher;
426     u8 auth;
427     u8 wpa_ie[IEEE80211_MAX_IE];
428     A_NETBUF_QUEUE_T        psq;    /* power save q */
429     A_MUTEX_T               psqLock;
430 } sta_t;
431
432 typedef struct ar6_raw_htc {
433     HTC_ENDPOINT_ID         arRaw2EpMapping[HTC_RAW_STREAM_NUM_MAX];
434     HTC_RAW_STREAM_ID       arEp2RawMapping[ENDPOINT_MAX];
435     struct semaphore        raw_htc_read_sem[HTC_RAW_STREAM_NUM_MAX];
436     struct semaphore        raw_htc_write_sem[HTC_RAW_STREAM_NUM_MAX];
437     wait_queue_head_t       raw_htc_read_queue[HTC_RAW_STREAM_NUM_MAX];
438     wait_queue_head_t       raw_htc_write_queue[HTC_RAW_STREAM_NUM_MAX];
439     raw_htc_buffer          raw_htc_read_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_READ_BUFFERS_NUM];
440     raw_htc_buffer          raw_htc_write_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_WRITE_BUFFERS_NUM];
441     bool                  write_buffer_available[HTC_RAW_STREAM_NUM_MAX];
442     bool                  read_buffer_available[HTC_RAW_STREAM_NUM_MAX];
443 } AR_RAW_HTC_T;
444
445 struct ar6_softc {
446     struct net_device       *arNetDev;    /* net_device pointer */
447     void                    *arWmi;
448     int                     arTxPending[ENDPOINT_MAX];
449     int                     arTotalTxDataPending;
450     u8 arNumDataEndPts;
451     bool                  arWmiEnabled;
452     bool                  arWmiReady;
453     bool                  arConnected;
454     HTC_HANDLE              arHtcTarget;
455     void                    *arHifDevice;
456     spinlock_t              arLock;
457     struct semaphore        arSem;
458     int                     arSsidLen;
459     u_char                  arSsid[32];
460     u8 arNextMode;
461     u8 arNetworkType;
462     u8 arDot11AuthMode;
463     u8 arAuthMode;
464     u8 arPairwiseCrypto;
465     u8 arPairwiseCryptoLen;
466     u8 arGroupCrypto;
467     u8 arGroupCryptoLen;
468     u8 arDefTxKeyIndex;
469     struct ar_wep_key       arWepKeyList[WMI_MAX_KEY_INDEX + 1];
470     u8 arBssid[6];
471     u8 arReqBssid[6];
472     u16 arChannelHint;
473     u16 arBssChannel;
474     u16 arListenIntervalB;
475     u16 arListenIntervalT;
476     struct ar6000_version   arVersion;
477     u32 arTargetType;
478     s8 arRssi;
479     u8 arTxPwr;
480     bool                  arTxPwrSet;
481     s32 arBitRate;
482     struct net_device_stats arNetStats;
483     struct iw_statistics    arIwStats;
484     s8 arNumChannels;
485     u16 arChannelList[32];
486     u32 arRegCode;
487     bool                  statsUpdatePending;
488     TARGET_STATS            arTargetStats;
489     s8 arMaxRetries;
490     u8 arPhyCapability;
491 #ifdef CONFIG_HOST_TCMD_SUPPORT
492     u8 tcmdRxReport;
493     u32 tcmdRxTotalPkt;
494     s32 tcmdRxRssi;
495     u32 tcmdPm;
496     u32 arTargetMode;
497     u32 tcmdRxcrcErrPkt;
498     u32 tcmdRxsecErrPkt;
499     u16 tcmdRateCnt[TCMD_MAX_RATES];
500     u16 tcmdRateCntShortGuard[TCMD_MAX_RATES];
501 #endif
502     AR6000_WLAN_STATE       arWlanState;
503     struct ar_node_mapping  arNodeMap[MAX_NODE_NUM];
504     u8 arIbssPsEnable;
505     u8 arNodeNum;
506     u8 arNexEpId;
507     struct ar_cookie        *arCookieList;
508     u32 arCookieCount;
509     u32 arRateMask;
510     u8 arSkipScan;
511     u16 arBeaconInterval;
512     bool                  arConnectPending;
513     bool                  arWmmEnabled;
514     struct ar_hb_chlng_resp arHBChallengeResp;
515     u8 arKeepaliveConfigured;
516     u32 arMgmtFilter;
517     HTC_ENDPOINT_ID         arAc2EpMapping[WMM_NUM_AC];
518     bool                  arAcStreamActive[WMM_NUM_AC];
519     u8 arAcStreamPriMap[WMM_NUM_AC];
520     u8 arHiAcStreamActivePri;
521     u8 arEp2AcMapping[ENDPOINT_MAX];
522     HTC_ENDPOINT_ID         arControlEp;
523 #ifdef HTC_RAW_INTERFACE
524     AR_RAW_HTC_T            *arRawHtc;
525 #endif
526     bool                  arNetQueueStopped;
527     bool                  arRawIfInit;
528     int                     arDeviceIndex;
529     struct common_credit_state_info arCreditStateInfo;
530     bool                  arWMIControlEpFull;
531     bool                  dbgLogFetchInProgress;
532     u8                 log_buffer[DBGLOG_HOST_LOG_BUFFER_SIZE];
533     u32 log_cnt;
534     u32 dbglog_init_done;
535     u32 arConnectCtrlFlags;
536     s32 user_savedkeys_stat;
537     u32 user_key_ctrl;
538     struct USER_SAVEDKEYS   user_saved_keys;
539     USER_RSSI_THOLD rssi_map[12];
540     u8 arUserBssFilter;
541     u16 ap_profile_flag;    /* AP mode */
542     WMI_AP_ACL              g_acl;              /* AP mode */
543     sta_t                   sta_list[AP_MAX_NUM_STA]; /* AP mode */
544     u8 sta_list_index;     /* AP mode */
545     struct ieee80211req_key ap_mode_bkey;           /* AP mode */
546     A_NETBUF_QUEUE_T        mcastpsq;    /* power save q for Mcast frames */
547     A_MUTEX_T               mcastpsqLock;
548     bool                  DTIMExpired; /* flag to indicate DTIM expired */
549     u8 intra_bss;   /* enable/disable intra bss data forward */
550     void                    *aggr_cntxt;
551 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
552     void                    *hcidev_info;
553 #endif
554     WMI_AP_MODE_STAT        arAPStats;
555     u8 ap_hidden_ssid;
556     u8 ap_country_code[3];
557     u8 ap_wmode;
558     u8 ap_dtim_period;
559     u16 ap_beacon_interval;
560     u16 arRTS;
561     u16 arACS; /* AP mode - Auto Channel Selection */
562     struct htc_packet_queue        amsdu_rx_buffer_queue;
563     bool                  bIsDestroyProgress; /* flag to indicate ar6k destroy is in progress */
564     A_TIMER                 disconnect_timer;
565     u8 rxMetaVersion;
566 #ifdef WAPI_ENABLE
567     u8 arWapiEnable;
568 #endif
569         WMI_BTCOEX_CONFIG_EVENT arBtcoexConfig;
570         WMI_BTCOEX_STATS_EVENT  arBtcoexStats;
571     s32 (*exitCallback)(void *config);  /* generic callback at AR6K exit */
572     struct hif_device_os_device_info   osDevInfo;
573     struct wireless_dev *wdev;
574     struct cfg80211_scan_request    *scan_request;
575     struct ar_key   keys[WMI_MAX_KEY_INDEX + 1];
576     u32 smeState;
577     u16 arWlanPowerState;
578     bool                  arWlanOff;
579 #ifdef CONFIG_PM
580     u16 arWowState;
581     bool                  arBTOff;
582     bool                  arBTSharing;
583     u16 arSuspendConfig;
584     u16 arWlanOffConfig;
585     u16 arWow2Config;
586 #endif
587     u8 scan_triggered;
588     WMI_SCAN_PARAMS_CMD     scParams;
589 #define AR_MCAST_FILTER_MAC_ADDR_SIZE  4
590     u8 mcast_filters[MAC_MAX_FILTERS_PER_LIST][AR_MCAST_FILTER_MAC_ADDR_SIZE];
591     u8 bdaddr[6];
592     bool                  scanSpecificSsid;
593 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
594     void                    *arApDev;
595 #endif
596 };
597
598 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
599 struct ar_virtual_interface {
600     struct net_device       *arNetDev;    /* net_device pointer */
601     struct ar6_softc              *arDev;       /* ar device pointer */
602     struct net_device       *arStaNetDev; /* net_device pointer */
603 };
604 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
605
606 static inline void *ar6k_priv(struct net_device *dev)
607 {
608     return (wdev_priv(dev->ieee80211_ptr));
609 }
610
611 #define SET_HCI_BUS_TYPE(pHciDev, __bus, __type) do { \
612     (pHciDev)->bus = (__bus); \
613     (pHciDev)->dev_type = (__type); \
614 } while(0)
615
616 #define GET_INODE_FROM_FILEP(filp) \
617     (filp)->f_path.dentry->d_inode
618
619 #define arAc2EndpointID(ar,ac)          (ar)->arAc2EpMapping[(ac)]
620 #define arSetAc2EndpointIDMap(ar,ac,ep)  \
621 {  (ar)->arAc2EpMapping[(ac)] = (ep); \
622    (ar)->arEp2AcMapping[(ep)] = (ac); }
623 #define arEndpoint2Ac(ar,ep)           (ar)->arEp2AcMapping[(ep)]
624
625 #define arRawIfEnabled(ar) (ar)->arRawIfInit
626 #define arRawStream2EndpointID(ar,raw)          (ar)->arRawHtc->arRaw2EpMapping[(raw)]
627 #define arSetRawStream2EndpointIDMap(ar,raw,ep)  \
628 {  (ar)->arRawHtc->arRaw2EpMapping[(raw)] = (ep); \
629    (ar)->arRawHtc->arEp2RawMapping[(ep)] = (raw); }
630 #define arEndpoint2RawStreamID(ar,ep)           (ar)->arRawHtc->arEp2RawMapping[(ep)]
631
632 struct ar_giwscan_param {
633     char *current_ev;
634     char *end_buf;
635     u32 bytes_needed;
636     struct iw_request_info *info;
637 };
638
639 #define AR6000_STAT_INC(ar, stat)       (ar->arNetStats.stat++)
640
641 #define AR6000_SPIN_LOCK(lock, param)   do {                            \
642     if (irqs_disabled()) {                                              \
643         AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("IRQs disabled:AR6000_LOCK\n"));                 \
644     }                                                                   \
645     spin_lock_bh(lock);                                                 \
646 } while (0)
647
648 #define AR6000_SPIN_UNLOCK(lock, param) do {                            \
649     if (irqs_disabled()) {                                              \
650         AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("IRQs disabled: AR6000_UNLOCK\n"));              \
651     }                                                                   \
652     spin_unlock_bh(lock);                                               \
653 } while (0)
654
655 void ar6000_init_profile_info(struct ar6_softc *ar);
656 void ar6000_install_static_wep_keys(struct ar6_softc *ar);
657 int ar6000_init(struct net_device *dev);
658 int ar6000_dbglog_get_debug_logs(struct ar6_softc *ar);
659 void ar6000_TxDataCleanup(struct ar6_softc *ar);
660 int ar6000_acl_data_tx(struct sk_buff *skb, struct net_device *dev);
661 void ar6000_restart_endpoint(struct net_device *dev);
662 void ar6000_stop_endpoint(struct net_device *dev, bool keepprofile, bool getdbglogs);
663
664 #ifdef HTC_RAW_INTERFACE
665
666 #ifndef __user
667 #define __user
668 #endif
669
670 int ar6000_htc_raw_open(struct ar6_softc *ar);
671 int ar6000_htc_raw_close(struct ar6_softc *ar);
672 ssize_t ar6000_htc_raw_read(struct ar6_softc *ar,
673                             HTC_RAW_STREAM_ID StreamID,
674                             char __user *buffer, size_t count);
675 ssize_t ar6000_htc_raw_write(struct ar6_softc *ar,
676                              HTC_RAW_STREAM_ID StreamID,
677                              char __user *buffer, size_t count);
678
679 #endif /* HTC_RAW_INTERFACE */
680
681 /* AP mode */
682 /*TODO: These routines should be moved to a file that is common across OS */
683 sta_t *
684 ieee80211_find_conn(struct ar6_softc *ar, u8 *node_addr);
685
686 sta_t *
687 ieee80211_find_conn_for_aid(struct ar6_softc *ar, u8 aid);
688
689 u8 remove_sta(struct ar6_softc *ar, u8 *mac, u16 reason);
690
691 /* HCI support */
692
693 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
694 int ar6000_setup_hci(struct ar6_softc *ar);
695 void     ar6000_cleanup_hci(struct ar6_softc *ar);
696 void     ar6000_set_default_ar3kconfig(struct ar6_softc *ar, void *ar3kconfig);
697
698 /* HCI bridge testing */
699 int hci_test_send(struct ar6_softc *ar, struct sk_buff *skb);
700 #endif
701
702 ATH_DEBUG_DECLARE_EXTERN(htc);
703 ATH_DEBUG_DECLARE_EXTERN(wmi);
704 ATH_DEBUG_DECLARE_EXTERN(bmi);
705 ATH_DEBUG_DECLARE_EXTERN(hif);
706 ATH_DEBUG_DECLARE_EXTERN(wlan);
707 ATH_DEBUG_DECLARE_EXTERN(misc);
708
709 extern u8 bcast_mac[];
710 extern u8 null_mac[];
711
712 #ifdef __cplusplus
713 }
714 #endif
715
716 #endif /* _AR6000_H_ */