ath6kl: remove USER_KEYS define
[linux-2.6-block.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 #ifdef INIT_MODE_DRV_ENABLED
242 #define WLAN_INIT_MODE_DEFAULT     WLAN_INIT_MODE_DRV
243 #else
244 #define WLAN_INIT_MODE_DEFAULT     WLAN_INIT_MODE_USR
245 #endif /* INIT_MODE_DRV_ENABLED */
246
247 #define AR6K_PATCH_DOWNLOAD_ADDRESS(_param, _ver) do { \
248     if ((_ver) == AR6003_REV1_VERSION) { \
249         (_param) = AR6003_REV1_PATCH_DOWNLOAD_ADDRESS; \
250     } else if ((_ver) == AR6003_REV2_VERSION) { \
251         (_param) = AR6003_REV2_PATCH_DOWNLOAD_ADDRESS; \
252     } else { \
253        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
254        A_ASSERT(0); \
255     } \
256 } while (0)
257
258 #define AR6K_DATA_DOWNLOAD_ADDRESS(_param, _ver) do { \
259     if ((_ver) == AR6003_REV1_VERSION) { \
260         (_param) = AR6003_REV1_DATA_DOWNLOAD_ADDRESS; \
261     } else if ((_ver) == AR6003_REV2_VERSION) { \
262         (_param) = AR6003_REV2_DATA_DOWNLOAD_ADDRESS; \
263     } else { \
264        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
265        A_ASSERT(0); \
266     } \
267 } while (0)
268
269 #define AR6K_APP_START_OVERRIDE_ADDRESS(_param, _ver) do { \
270     if ((_ver) == AR6003_REV1_VERSION) { \
271         (_param) = AR6003_REV1_APP_START_OVERRIDE; \
272     } else if ((_ver) == AR6003_REV2_VERSION) { \
273         (_param) = AR6003_REV2_APP_START_OVERRIDE; \
274     } else { \
275        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
276        A_ASSERT(0); \
277     } \
278 } while (0)
279
280 /* AR6003 1.0 definitions */
281 #define AR6003_REV1_VERSION                 0x300002ba
282 #define AR6003_REV1_DATA_DOWNLOAD_ADDRESS   AR6003_REV1_OTP_DATA_ADDRESS
283 #define AR6003_REV1_PATCH_DOWNLOAD_ADDRESS  0x57ea6c
284 #define AR6003_REV1_OTP_FILE                "ath6k/AR6003/hw1.0/otp.bin.z77"
285 #define AR6003_REV1_FIRMWARE_FILE           "ath6k/AR6003/hw1.0/athwlan.bin.z77"
286 #define AR6003_REV1_TCMD_FIRMWARE_FILE      "ath6k/AR6003/hw1.0/athtcmd_ram.bin"
287 #define AR6003_REV1_ART_FIRMWARE_FILE       "ath6k/AR6003/hw1.0/device.bin"
288 #define AR6003_REV1_PATCH_FILE              "ath6k/AR6003/hw1.0/data.patch.bin"
289 #define AR6003_REV1_EPPING_FIRMWARE_FILE    "ath6k/AR6003/hw1.0/endpointping.bin"
290 #ifdef AR600x_SD31_XXX
291 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.SD31.bin"
292 #elif defined(AR600x_SD32_XXX)
293 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.SD32.bin"
294 #elif defined(AR600x_WB31_XXX)
295 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.WB31.bin"
296 #else
297 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.CUSTOM.bin"
298 #endif /* Board Data File */
299
300 /* AR6003 2.0 definitions */
301 #define AR6003_REV2_VERSION                 0x30000384 
302 #define AR6003_REV2_DATA_DOWNLOAD_ADDRESS   AR6003_REV2_OTP_DATA_ADDRESS
303 #define AR6003_REV2_PATCH_DOWNLOAD_ADDRESS  0x57e910
304 #define AR6003_REV2_OTP_FILE                "ath6k/AR6003/hw2.0/otp.bin.z77"
305 #define AR6003_REV2_FIRMWARE_FILE           "ath6k/AR6003/hw2.0/athwlan.bin.z77"
306 #define AR6003_REV2_TCMD_FIRMWARE_FILE      "ath6k/AR6003/hw2.0/athtcmd_ram.bin"
307 #define AR6003_REV2_ART_FIRMWARE_FILE       "ath6k/AR6003/hw2.0/device.bin"
308 #define AR6003_REV2_PATCH_FILE              "ath6k/AR6003/hw2.0/data.patch.bin"
309 #define AR6003_REV2_EPPING_FIRMWARE_FILE    "ath6k/AR6003/hw2.0/endpointping.bin"
310 #ifdef AR600x_SD31_XXX
311 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.SD31.bin"
312 #elif defined(AR600x_SD32_XXX)
313 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.SD32.bin"
314 #elif defined(AR600x_WB31_XXX)
315 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.WB31.bin"
316 #else
317 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.CUSTOM.bin"
318 #endif /* Board Data File */
319
320 /* Power states */
321 enum {
322     WLAN_PWR_CTRL_UP = 0,
323     WLAN_PWR_CTRL_CUT_PWR,
324     WLAN_PWR_CTRL_DEEP_SLEEP,
325     WLAN_PWR_CTRL_WOW,
326     WLAN_PWR_CTRL_DEEP_SLEEP_DISABLED
327 };
328
329 /* HTC RAW streams */
330 typedef enum _HTC_RAW_STREAM_ID {
331     HTC_RAW_STREAM_NOT_MAPPED = -1,
332     HTC_RAW_STREAM_0 = 0,
333     HTC_RAW_STREAM_1 = 1,
334     HTC_RAW_STREAM_2 = 2,
335     HTC_RAW_STREAM_3 = 3,
336     HTC_RAW_STREAM_NUM_MAX
337 } HTC_RAW_STREAM_ID;
338
339 #define RAW_HTC_READ_BUFFERS_NUM    4
340 #define RAW_HTC_WRITE_BUFFERS_NUM   4
341
342 #define HTC_RAW_BUFFER_SIZE  1664
343
344 typedef struct {
345     int currPtr;
346     int length;
347     unsigned char data[HTC_RAW_BUFFER_SIZE];
348     struct htc_packet    HTCPacket;
349 } raw_htc_buffer;
350
351 #ifdef CONFIG_HOST_TCMD_SUPPORT
352 /*
353  *  add TCMD_MODE besides wmi and bypasswmi
354  *  in TCMD_MODE, only few TCMD releated wmi commands
355  *  counld be hanlder
356  */
357 enum {
358     AR6000_WMI_MODE = 0,
359     AR6000_BYPASS_MODE,
360     AR6000_TCMD_MODE,
361     AR6000_WLAN_MODE
362 };
363 #endif /* CONFIG_HOST_TCMD_SUPPORT */
364
365 struct ar_wep_key {
366     u8 arKeyIndex;
367     u8 arKeyLen;
368     u8 arKey[64];
369 } ;
370
371 struct ar_key {
372     u8 key[WLAN_MAX_KEY_LEN];
373     u8 key_len;
374     u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
375     u8 seq_len;
376     u32 cipher;
377 };
378
379 enum {
380     SME_DISCONNECTED,
381     SME_CONNECTING,
382     SME_CONNECTED
383 };
384
385 struct ar_node_mapping {
386     u8 macAddress[6];
387     u8 epId;
388     u8 txPending;
389 };
390
391 struct ar_cookie {
392     unsigned long          arc_bp[2];    /* Must be first field */
393     struct htc_packet             HtcPkt;       /* HTC packet wrapper */
394     struct ar_cookie *arc_list_next;
395 };
396
397 struct ar_hb_chlng_resp {
398     A_TIMER                 timer;
399     u32 frequency;
400     u32 seqNum;
401     bool                  outstanding;
402     u8 missCnt;
403     u8 missThres;
404 };
405
406 /* Per STA data, used in AP mode */
407 /*TODO: All this should move to OS independent dir */
408
409 #define STA_PWR_MGMT_MASK 0x1
410 #define STA_PWR_MGMT_SHIFT 0x0
411 #define STA_PWR_MGMT_AWAKE 0x0
412 #define STA_PWR_MGMT_SLEEP 0x1
413
414 #define STA_SET_PWR_SLEEP(sta) (sta->flags |= (STA_PWR_MGMT_MASK << STA_PWR_MGMT_SHIFT))
415 #define STA_CLR_PWR_SLEEP(sta) (sta->flags &= ~(STA_PWR_MGMT_MASK << STA_PWR_MGMT_SHIFT))
416 #define STA_IS_PWR_SLEEP(sta) ((sta->flags >> STA_PWR_MGMT_SHIFT) & STA_PWR_MGMT_MASK)
417
418 #define STA_PS_POLLED_MASK 0x1
419 #define STA_PS_POLLED_SHIFT 0x1
420 #define STA_SET_PS_POLLED(sta) (sta->flags |= (STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
421 #define STA_CLR_PS_POLLED(sta) (sta->flags &= ~(STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
422 #define STA_IS_PS_POLLED(sta) (sta->flags & (STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
423
424 typedef struct {
425     u16 flags;
426     u8 mac[ATH_MAC_LEN];
427     u8 aid;
428     u8 keymgmt;
429     u8 ucipher;
430     u8 auth;
431     u8 wpa_ie[IEEE80211_MAX_IE];
432     A_NETBUF_QUEUE_T        psq;    /* power save q */
433     A_MUTEX_T               psqLock;
434 } sta_t;
435
436 typedef struct ar6_raw_htc {
437     HTC_ENDPOINT_ID         arRaw2EpMapping[HTC_RAW_STREAM_NUM_MAX];
438     HTC_RAW_STREAM_ID       arEp2RawMapping[ENDPOINT_MAX];
439     struct semaphore        raw_htc_read_sem[HTC_RAW_STREAM_NUM_MAX];
440     struct semaphore        raw_htc_write_sem[HTC_RAW_STREAM_NUM_MAX];
441     wait_queue_head_t       raw_htc_read_queue[HTC_RAW_STREAM_NUM_MAX];
442     wait_queue_head_t       raw_htc_write_queue[HTC_RAW_STREAM_NUM_MAX];
443     raw_htc_buffer          raw_htc_read_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_READ_BUFFERS_NUM];
444     raw_htc_buffer          raw_htc_write_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_WRITE_BUFFERS_NUM];
445     bool                  write_buffer_available[HTC_RAW_STREAM_NUM_MAX];
446     bool                  read_buffer_available[HTC_RAW_STREAM_NUM_MAX];
447 } AR_RAW_HTC_T;
448
449 struct ar6_softc {
450     struct net_device       *arNetDev;    /* net_device pointer */
451     void                    *arWmi;
452     int                     arTxPending[ENDPOINT_MAX];
453     int                     arTotalTxDataPending;
454     u8 arNumDataEndPts;
455     bool                  arWmiEnabled;
456     bool                  arWmiReady;
457     bool                  arConnected;
458     HTC_HANDLE              arHtcTarget;
459     void                    *arHifDevice;
460     spinlock_t              arLock;
461     struct semaphore        arSem;
462     int                     arSsidLen;
463     u_char                  arSsid[32];
464     u8 arNextMode;
465     u8 arNetworkType;
466     u8 arDot11AuthMode;
467     u8 arAuthMode;
468     u8 arPairwiseCrypto;
469     u8 arPairwiseCryptoLen;
470     u8 arGroupCrypto;
471     u8 arGroupCryptoLen;
472     u8 arDefTxKeyIndex;
473     struct ar_wep_key       arWepKeyList[WMI_MAX_KEY_INDEX + 1];
474     u8 arBssid[6];
475     u8 arReqBssid[6];
476     u16 arChannelHint;
477     u16 arBssChannel;
478     u16 arListenIntervalB;
479     u16 arListenIntervalT;
480     struct ar6000_version   arVersion;
481     u32 arTargetType;
482     s8 arRssi;
483     u8 arTxPwr;
484     bool                  arTxPwrSet;
485     s32 arBitRate;
486     struct net_device_stats arNetStats;
487     struct iw_statistics    arIwStats;
488     s8 arNumChannels;
489     u16 arChannelList[32];
490     u32 arRegCode;
491     bool                  statsUpdatePending;
492     TARGET_STATS            arTargetStats;
493     s8 arMaxRetries;
494     u8 arPhyCapability;
495 #ifdef CONFIG_HOST_TCMD_SUPPORT
496     u8 tcmdRxReport;
497     u32 tcmdRxTotalPkt;
498     s32 tcmdRxRssi;
499     u32 tcmdPm;
500     u32 arTargetMode;
501     u32 tcmdRxcrcErrPkt;
502     u32 tcmdRxsecErrPkt;
503     u16 tcmdRateCnt[TCMD_MAX_RATES];
504     u16 tcmdRateCntShortGuard[TCMD_MAX_RATES];
505 #endif
506     AR6000_WLAN_STATE       arWlanState;
507     struct ar_node_mapping  arNodeMap[MAX_NODE_NUM];
508     u8 arIbssPsEnable;
509     u8 arNodeNum;
510     u8 arNexEpId;
511     struct ar_cookie        *arCookieList;
512     u32 arCookieCount;
513     u32 arRateMask;
514     u8 arSkipScan;
515     u16 arBeaconInterval;
516     bool                  arConnectPending;
517     bool                  arWmmEnabled;
518     struct ar_hb_chlng_resp arHBChallengeResp;
519     u8 arKeepaliveConfigured;
520     u32 arMgmtFilter;
521     HTC_ENDPOINT_ID         arAc2EpMapping[WMM_NUM_AC];
522     bool                  arAcStreamActive[WMM_NUM_AC];
523     u8 arAcStreamPriMap[WMM_NUM_AC];
524     u8 arHiAcStreamActivePri;
525     u8 arEp2AcMapping[ENDPOINT_MAX];
526     HTC_ENDPOINT_ID         arControlEp;
527 #ifdef HTC_RAW_INTERFACE
528     AR_RAW_HTC_T            *arRawHtc;
529 #endif
530     bool                  arNetQueueStopped;
531     bool                  arRawIfInit;
532     int                     arDeviceIndex;
533     struct common_credit_state_info arCreditStateInfo;
534     bool                  arWMIControlEpFull;
535     bool                  dbgLogFetchInProgress;
536     u8                 log_buffer[DBGLOG_HOST_LOG_BUFFER_SIZE];
537     u32 log_cnt;
538     u32 dbglog_init_done;
539     u32 arConnectCtrlFlags;
540     s32 user_savedkeys_stat;
541     u32 user_key_ctrl;
542     struct USER_SAVEDKEYS   user_saved_keys;
543     USER_RSSI_THOLD rssi_map[12];
544     u8 arUserBssFilter;
545     u16 ap_profile_flag;    /* AP mode */
546     WMI_AP_ACL              g_acl;              /* AP mode */
547     sta_t                   sta_list[AP_MAX_NUM_STA]; /* AP mode */
548     u8 sta_list_index;     /* AP mode */
549     struct ieee80211req_key ap_mode_bkey;           /* AP mode */
550     A_NETBUF_QUEUE_T        mcastpsq;    /* power save q for Mcast frames */
551     A_MUTEX_T               mcastpsqLock;
552     bool                  DTIMExpired; /* flag to indicate DTIM expired */
553     u8 intra_bss;   /* enable/disable intra bss data forward */
554     void                    *aggr_cntxt;
555 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
556     void                    *hcidev_info;
557 #endif
558     WMI_AP_MODE_STAT        arAPStats;
559     u8 ap_hidden_ssid;
560     u8 ap_country_code[3];
561     u8 ap_wmode;
562     u8 ap_dtim_period;
563     u16 ap_beacon_interval;
564     u16 arRTS;
565     u16 arACS; /* AP mode - Auto Channel Selection */
566     struct htc_packet_queue        amsdu_rx_buffer_queue;
567     bool                  bIsDestroyProgress; /* flag to indicate ar6k destroy is in progress */
568     A_TIMER                 disconnect_timer;
569     u8 rxMetaVersion;
570 #ifdef WAPI_ENABLE
571     u8 arWapiEnable;
572 #endif
573         WMI_BTCOEX_CONFIG_EVENT arBtcoexConfig;
574         WMI_BTCOEX_STATS_EVENT  arBtcoexStats;
575     s32 (*exitCallback)(void *config);  /* generic callback at AR6K exit */
576     struct hif_device_os_device_info   osDevInfo;
577     struct wireless_dev *wdev;
578     struct cfg80211_scan_request    *scan_request;
579     struct ar_key   keys[WMI_MAX_KEY_INDEX + 1];
580     u32 smeState;
581     u16 arWlanPowerState;
582     bool                  arWlanOff;
583 #ifdef CONFIG_PM
584     u16 arWowState;
585     bool                  arBTOff;
586     bool                  arBTSharing;
587     u16 arSuspendConfig;
588     u16 arWlanOffConfig;
589     u16 arWow2Config;
590 #endif
591     u8 scan_triggered;
592     WMI_SCAN_PARAMS_CMD     scParams;
593 #define AR_MCAST_FILTER_MAC_ADDR_SIZE  4
594     u8 mcast_filters[MAC_MAX_FILTERS_PER_LIST][AR_MCAST_FILTER_MAC_ADDR_SIZE];
595     u8 bdaddr[6];
596     bool                  scanSpecificSsid;
597 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
598     void                    *arApDev;
599 #endif
600 };
601
602 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
603 struct ar_virtual_interface {
604     struct net_device       *arNetDev;    /* net_device pointer */
605     struct ar6_softc              *arDev;       /* ar device pointer */
606     struct net_device       *arStaNetDev; /* net_device pointer */
607 };
608 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
609
610 static inline void *ar6k_priv(struct net_device *dev)
611 {
612     return (wdev_priv(dev->ieee80211_ptr));
613 }
614
615 #define SET_HCI_BUS_TYPE(pHciDev, __bus, __type) do { \
616     (pHciDev)->bus = (__bus); \
617     (pHciDev)->dev_type = (__type); \
618 } while(0)
619
620 #define GET_INODE_FROM_FILEP(filp) \
621     (filp)->f_path.dentry->d_inode
622
623 #define arAc2EndpointID(ar,ac)          (ar)->arAc2EpMapping[(ac)]
624 #define arSetAc2EndpointIDMap(ar,ac,ep)  \
625 {  (ar)->arAc2EpMapping[(ac)] = (ep); \
626    (ar)->arEp2AcMapping[(ep)] = (ac); }
627 #define arEndpoint2Ac(ar,ep)           (ar)->arEp2AcMapping[(ep)]
628
629 #define arRawIfEnabled(ar) (ar)->arRawIfInit
630 #define arRawStream2EndpointID(ar,raw)          (ar)->arRawHtc->arRaw2EpMapping[(raw)]
631 #define arSetRawStream2EndpointIDMap(ar,raw,ep)  \
632 {  (ar)->arRawHtc->arRaw2EpMapping[(raw)] = (ep); \
633    (ar)->arRawHtc->arEp2RawMapping[(ep)] = (raw); }
634 #define arEndpoint2RawStreamID(ar,ep)           (ar)->arRawHtc->arEp2RawMapping[(ep)]
635
636 struct ar_giwscan_param {
637     char *current_ev;
638     char *end_buf;
639     u32 bytes_needed;
640     struct iw_request_info *info;
641 };
642
643 #define AR6000_STAT_INC(ar, stat)       (ar->arNetStats.stat++)
644
645 #define AR6000_SPIN_LOCK(lock, param)   do {                            \
646     if (irqs_disabled()) {                                              \
647         AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("IRQs disabled:AR6000_LOCK\n"));                 \
648     }                                                                   \
649     spin_lock_bh(lock);                                                 \
650 } while (0)
651
652 #define AR6000_SPIN_UNLOCK(lock, param) do {                            \
653     if (irqs_disabled()) {                                              \
654         AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("IRQs disabled: AR6000_UNLOCK\n"));              \
655     }                                                                   \
656     spin_unlock_bh(lock);                                               \
657 } while (0)
658
659 void ar6000_init_profile_info(struct ar6_softc *ar);
660 void ar6000_install_static_wep_keys(struct ar6_softc *ar);
661 int ar6000_init(struct net_device *dev);
662 int ar6000_dbglog_get_debug_logs(struct ar6_softc *ar);
663 void ar6000_TxDataCleanup(struct ar6_softc *ar);
664 int ar6000_acl_data_tx(struct sk_buff *skb, struct net_device *dev);
665 void ar6000_restart_endpoint(struct net_device *dev);
666 void ar6000_stop_endpoint(struct net_device *dev, bool keepprofile, bool getdbglogs);
667
668 #ifdef HTC_RAW_INTERFACE
669
670 #ifndef __user
671 #define __user
672 #endif
673
674 int ar6000_htc_raw_open(struct ar6_softc *ar);
675 int ar6000_htc_raw_close(struct ar6_softc *ar);
676 ssize_t ar6000_htc_raw_read(struct ar6_softc *ar,
677                             HTC_RAW_STREAM_ID StreamID,
678                             char __user *buffer, size_t count);
679 ssize_t ar6000_htc_raw_write(struct ar6_softc *ar,
680                              HTC_RAW_STREAM_ID StreamID,
681                              char __user *buffer, size_t count);
682
683 #endif /* HTC_RAW_INTERFACE */
684
685 /* AP mode */
686 /*TODO: These routines should be moved to a file that is common across OS */
687 sta_t *
688 ieee80211_find_conn(struct ar6_softc *ar, u8 *node_addr);
689
690 sta_t *
691 ieee80211_find_conn_for_aid(struct ar6_softc *ar, u8 aid);
692
693 u8 remove_sta(struct ar6_softc *ar, u8 *mac, u16 reason);
694
695 /* HCI support */
696
697 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
698 int ar6000_setup_hci(struct ar6_softc *ar);
699 void     ar6000_cleanup_hci(struct ar6_softc *ar);
700 void     ar6000_set_default_ar3kconfig(struct ar6_softc *ar, void *ar3kconfig);
701
702 /* HCI bridge testing */
703 int hci_test_send(struct ar6_softc *ar, struct sk_buff *skb);
704 #endif
705
706 ATH_DEBUG_DECLARE_EXTERN(htc);
707 ATH_DEBUG_DECLARE_EXTERN(wmi);
708 ATH_DEBUG_DECLARE_EXTERN(bmi);
709 ATH_DEBUG_DECLARE_EXTERN(hif);
710 ATH_DEBUG_DECLARE_EXTERN(wlan);
711 ATH_DEBUG_DECLARE_EXTERN(misc);
712
713 extern u8 bcast_mac[];
714 extern u8 null_mac[];
715
716 #ifdef __cplusplus
717 }
718 #endif
719
720 #endif /* _AR6000_H_ */