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