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