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