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(struct hif_device *hifDevice, u32 *address, u32 *data);
125 int ar6000_WriteRegDiag(struct 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 struct 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
397 enum {
398 SME_DISCONNECTED,
399 SME_CONNECTING,
400 SME_CONNECTED
401 };
402 #endif /* ATH6K_CONFIG_CFG80211 */
403
404
405 struct ar_node_mapping {
406 u8 macAddress[6];
407 u8 epId;
408 u8 txPending;
409 };
410
411 struct ar_cookie {
412 unsigned long arc_bp[2]; /* Must be first field */
413 struct htc_packet HtcPkt; /* HTC packet wrapper */
414 struct ar_cookie *arc_list_next;
415 };
416
417 struct ar_hb_chlng_resp {
418 A_TIMER timer;
419 u32 frequency;
420 u32 seqNum;
421 bool outstanding;
422 u8 missCnt;
423 u8 missThres;
424 };
425
426 /* Per STA data, used in AP mode */
427 /*TODO: All this should move to OS independent dir */
428
429 #define STA_PWR_MGMT_MASK 0x1
430 #define STA_PWR_MGMT_SHIFT 0x0
431 #define STA_PWR_MGMT_AWAKE 0x0
432 #define STA_PWR_MGMT_SLEEP 0x1
433
434 #define STA_SET_PWR_SLEEP(sta) (sta->flags |= (STA_PWR_MGMT_MASK << STA_PWR_MGMT_SHIFT))
435 #define STA_CLR_PWR_SLEEP(sta) (sta->flags &= ~(STA_PWR_MGMT_MASK << STA_PWR_MGMT_SHIFT))
436 #define STA_IS_PWR_SLEEP(sta) ((sta->flags >> STA_PWR_MGMT_SHIFT) & STA_PWR_MGMT_MASK)
437
438 #define STA_PS_POLLED_MASK 0x1
439 #define STA_PS_POLLED_SHIFT 0x1
440 #define STA_SET_PS_POLLED(sta) (sta->flags |= (STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
441 #define STA_CLR_PS_POLLED(sta) (sta->flags &= ~(STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
442 #define STA_IS_PS_POLLED(sta) (sta->flags & (STA_PS_POLLED_MASK << STA_PS_POLLED_SHIFT))
443
444 typedef struct {
445 u16 flags;
446 u8 mac[ATH_MAC_LEN];
447 u8 aid;
448 u8 keymgmt;
449 u8 ucipher;
450 u8 auth;
451 u8 wpa_ie[IEEE80211_MAX_IE];
452 A_NETBUF_QUEUE_T psq; /* power save q */
453 A_MUTEX_T psqLock;
454 } sta_t;
455
456 typedef struct ar6_raw_htc {
457 HTC_ENDPOINT_ID arRaw2EpMapping[HTC_RAW_STREAM_NUM_MAX];
458 HTC_RAW_STREAM_ID arEp2RawMapping[ENDPOINT_MAX];
459 struct semaphore raw_htc_read_sem[HTC_RAW_STREAM_NUM_MAX];
460 struct semaphore raw_htc_write_sem[HTC_RAW_STREAM_NUM_MAX];
461 wait_queue_head_t raw_htc_read_queue[HTC_RAW_STREAM_NUM_MAX];
462 wait_queue_head_t raw_htc_write_queue[HTC_RAW_STREAM_NUM_MAX];
463 raw_htc_buffer raw_htc_read_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_READ_BUFFERS_NUM];
464 raw_htc_buffer raw_htc_write_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_WRITE_BUFFERS_NUM];
465 bool write_buffer_available[HTC_RAW_STREAM_NUM_MAX];
466 bool read_buffer_available[HTC_RAW_STREAM_NUM_MAX];
467 } AR_RAW_HTC_T;
468
469 struct ar6_softc {
470 struct net_device *arNetDev; /* net_device pointer */
471 void *arWmi;
472 int arTxPending[ENDPOINT_MAX];
473 int arTotalTxDataPending;
474 u8 arNumDataEndPts;
475 bool arWmiEnabled;
476 bool arWmiReady;
477 bool arConnected;
478 HTC_HANDLE arHtcTarget;
479 void *arHifDevice;
480 spinlock_t arLock;
481 struct semaphore arSem;
482 int arSsidLen;
483 u_char arSsid[32];
484 u8 arNextMode;
485 u8 arNetworkType;
486 u8 arDot11AuthMode;
487 u8 arAuthMode;
488 u8 arPairwiseCrypto;
489 u8 arPairwiseCryptoLen;
490 u8 arGroupCrypto;
491 u8 arGroupCryptoLen;
492 u8 arDefTxKeyIndex;
493 struct ar_wep_key arWepKeyList[WMI_MAX_KEY_INDEX + 1];
494 u8 arBssid[6];
495 u8 arReqBssid[6];
496 u16 arChannelHint;
497 u16 arBssChannel;
498 u16 arListenIntervalB;
499 u16 arListenIntervalT;
500 struct ar6000_version arVersion;
501 u32 arTargetType;
502 s8 arRssi;
503 u8 arTxPwr;
504 bool arTxPwrSet;
505 s32 arBitRate;
506 struct net_device_stats arNetStats;
507 struct iw_statistics arIwStats;
508 s8 arNumChannels;
509 u16 arChannelList[32];
510 u32 arRegCode;
511 bool statsUpdatePending;
512 TARGET_STATS arTargetStats;
513 s8 arMaxRetries;
514 u8 arPhyCapability;
515 #ifdef CONFIG_HOST_TCMD_SUPPORT
516 u8 tcmdRxReport;
517 u32 tcmdRxTotalPkt;
518 s32 tcmdRxRssi;
519 u32 tcmdPm;
520 u32 arTargetMode;
521 u32 tcmdRxcrcErrPkt;
522 u32 tcmdRxsecErrPkt;
523 u16 tcmdRateCnt[TCMD_MAX_RATES];
524 u16 tcmdRateCntShortGuard[TCMD_MAX_RATES];
525 #endif
526 AR6000_WLAN_STATE arWlanState;
527 struct ar_node_mapping arNodeMap[MAX_NODE_NUM];
528 u8 arIbssPsEnable;
529 u8 arNodeNum;
530 u8 arNexEpId;
531 struct ar_cookie *arCookieList;
532 u32 arCookieCount;
533 u32 arRateMask;
534 u8 arSkipScan;
535 u16 arBeaconInterval;
536 bool arConnectPending;
537 bool arWmmEnabled;
538 struct ar_hb_chlng_resp arHBChallengeResp;
539 u8 arKeepaliveConfigured;
540 u32 arMgmtFilter;
541 HTC_ENDPOINT_ID arAc2EpMapping[WMM_NUM_AC];
542 bool arAcStreamActive[WMM_NUM_AC];
543 u8 arAcStreamPriMap[WMM_NUM_AC];
544 u8 arHiAcStreamActivePri;
545 u8 arEp2AcMapping[ENDPOINT_MAX];
546 HTC_ENDPOINT_ID arControlEp;
547 #ifdef HTC_RAW_INTERFACE
548 AR_RAW_HTC_T *arRawHtc;
549 #endif
550 bool arNetQueueStopped;
551 bool arRawIfInit;
552 int arDeviceIndex;
553 struct common_credit_state_info arCreditStateInfo;
554 bool arWMIControlEpFull;
555 bool dbgLogFetchInProgress;
556 u8 log_buffer[DBGLOG_HOST_LOG_BUFFER_SIZE];
557 u32 log_cnt;
558 u32 dbglog_init_done;
559 u32 arConnectCtrlFlags;
560 #ifdef USER_KEYS
561 s32 user_savedkeys_stat;
562 u32 user_key_ctrl;
563 struct USER_SAVEDKEYS user_saved_keys;
564 #endif
565 USER_RSSI_THOLD rssi_map[12];
566 u8 arUserBssFilter;
567 u16 ap_profile_flag; /* AP mode */
568 WMI_AP_ACL g_acl; /* AP mode */
569 sta_t sta_list[AP_MAX_NUM_STA]; /* AP mode */
570 u8 sta_list_index; /* AP mode */
571 struct ieee80211req_key ap_mode_bkey; /* AP mode */
572 A_NETBUF_QUEUE_T mcastpsq; /* power save q for Mcast frames */
573 A_MUTEX_T mcastpsqLock;
574 bool DTIMExpired; /* flag to indicate DTIM expired */
575 u8 intra_bss; /* enable/disable intra bss data forward */
576 void *aggr_cntxt;
577 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
578 void *hcidev_info;
579 #endif
580 void *hcipal_info;
581 WMI_AP_MODE_STAT arAPStats;
582 u8 ap_hidden_ssid;
583 u8 ap_country_code[3];
584 u8 ap_wmode;
585 u8 ap_dtim_period;
586 u16 ap_beacon_interval;
587 u16 arRTS;
588 u16 arACS; /* AP mode - Auto Channel Selection */
589 struct htc_packet_queue amsdu_rx_buffer_queue;
590 bool bIsDestroyProgress; /* flag to indicate ar6k destroy is in progress */
591 A_TIMER disconnect_timer;
592 u8 rxMetaVersion;
593 #ifdef WAPI_ENABLE
594 u8 arWapiEnable;
595 #endif
596 WMI_BTCOEX_CONFIG_EVENT arBtcoexConfig;
597 WMI_BTCOEX_STATS_EVENT arBtcoexStats;
598 s32 (*exitCallback)(void *config); /* generic callback at AR6K exit */
599 struct hif_device_os_device_info osDevInfo;
600 #ifdef ATH6K_CONFIG_CFG80211
601 struct wireless_dev *wdev;
602 struct cfg80211_scan_request *scan_request;
603 struct ar_key keys[WMI_MAX_KEY_INDEX + 1];
604 u32 smeState;
605 #endif /* ATH6K_CONFIG_CFG80211 */
606 u16 arWlanPowerState;
607 bool arWlanOff;
608 #ifdef CONFIG_PM
609 u16 arWowState;
610 bool arBTOff;
611 bool arBTSharing;
612 u16 arSuspendConfig;
613 u16 arWlanOffConfig;
614 u16 arWow2Config;
615 #endif
616 u8 scan_triggered;
617 WMI_SCAN_PARAMS_CMD scParams;
618 #define AR_MCAST_FILTER_MAC_ADDR_SIZE 4
619 u8 mcast_filters[MAC_MAX_FILTERS_PER_LIST][AR_MCAST_FILTER_MAC_ADDR_SIZE];
620 u8 bdaddr[6];
621 bool scanSpecificSsid;
622 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
623 void *arApDev;
624 #endif
625 };
626
627 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
628 struct ar_virtual_interface {
629 struct net_device *arNetDev; /* net_device pointer */
630 struct ar6_softc *arDev; /* ar device pointer */
631 struct net_device *arStaNetDev; /* net_device pointer */
632 };
633 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
634
635 #ifdef ATH6K_CONFIG_CFG80211
ar6k_priv(struct net_device * dev)636 static inline void *ar6k_priv(struct net_device *dev)
637 {
638 return (wdev_priv(dev->ieee80211_ptr));
639 }
640 #else
641 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
ar6k_priv(struct net_device * dev)642 static inline void *ar6k_priv(struct net_device *dev)
643 {
644 extern struct net_device *arApNetDev;
645
646 if (arApNetDev == dev) {
647 /* return arDev saved in virtual interface context */
648 struct ar_virtual_interface *arVirDev;
649 arVirDev = netdev_priv(dev);
650 return arVirDev->arDev;
651 } else {
652 return netdev_priv(dev);
653 }
654 }
655 #else
656 #define ar6k_priv netdev_priv
657 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
658 #endif /* ATH6K_CONFIG_CFG80211 */
659
660 #define SET_HCI_BUS_TYPE(pHciDev, __bus, __type) do { \
661 (pHciDev)->bus = (__bus); \
662 (pHciDev)->dev_type = (__type); \
663 } while(0)
664
665 #define GET_INODE_FROM_FILEP(filp) \
666 (filp)->f_path.dentry->d_inode
667
668 #define arAc2EndpointID(ar,ac) (ar)->arAc2EpMapping[(ac)]
669 #define arSetAc2EndpointIDMap(ar,ac,ep) \
670 { (ar)->arAc2EpMapping[(ac)] = (ep); \
671 (ar)->arEp2AcMapping[(ep)] = (ac); }
672 #define arEndpoint2Ac(ar,ep) (ar)->arEp2AcMapping[(ep)]
673
674 #define arRawIfEnabled(ar) (ar)->arRawIfInit
675 #define arRawStream2EndpointID(ar,raw) (ar)->arRawHtc->arRaw2EpMapping[(raw)]
676 #define arSetRawStream2EndpointIDMap(ar,raw,ep) \
677 { (ar)->arRawHtc->arRaw2EpMapping[(raw)] = (ep); \
678 (ar)->arRawHtc->arEp2RawMapping[(ep)] = (raw); }
679 #define arEndpoint2RawStreamID(ar,ep) (ar)->arRawHtc->arEp2RawMapping[(ep)]
680
681 struct ar_giwscan_param {
682 char *current_ev;
683 char *end_buf;
684 u32 bytes_needed;
685 struct iw_request_info *info;
686 };
687
688 #define AR6000_STAT_INC(ar, stat) (ar->arNetStats.stat++)
689
690 #define AR6000_SPIN_LOCK(lock, param) do { \
691 if (irqs_disabled()) { \
692 AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("IRQs disabled:AR6000_LOCK\n")); \
693 } \
694 spin_lock_bh(lock); \
695 } while (0)
696
697 #define AR6000_SPIN_UNLOCK(lock, param) do { \
698 if (irqs_disabled()) { \
699 AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("IRQs disabled: AR6000_UNLOCK\n")); \
700 } \
701 spin_unlock_bh(lock); \
702 } while (0)
703
704 int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
705 int ar6000_ioctl_dispatcher(struct net_device *dev, struct ifreq *rq, int cmd);
706 void ar6000_gpio_init(void);
707 void ar6000_init_profile_info(struct ar6_softc *ar);
708 void ar6000_install_static_wep_keys(struct ar6_softc *ar);
709 int ar6000_init(struct net_device *dev);
710 int ar6000_dbglog_get_debug_logs(struct ar6_softc *ar);
711 void ar6000_TxDataCleanup(struct ar6_softc *ar);
712 int ar6000_acl_data_tx(struct sk_buff *skb, struct net_device *dev);
713 void ar6000_restart_endpoint(struct net_device *dev);
714 void ar6000_stop_endpoint(struct net_device *dev, bool keepprofile, bool getdbglogs);
715
716 #ifdef HTC_RAW_INTERFACE
717
718 #ifndef __user
719 #define __user
720 #endif
721
722 int ar6000_htc_raw_open(struct ar6_softc *ar);
723 int ar6000_htc_raw_close(struct ar6_softc *ar);
724 ssize_t ar6000_htc_raw_read(struct ar6_softc *ar,
725 HTC_RAW_STREAM_ID StreamID,
726 char __user *buffer, size_t count);
727 ssize_t ar6000_htc_raw_write(struct ar6_softc *ar,
728 HTC_RAW_STREAM_ID StreamID,
729 char __user *buffer, size_t count);
730
731 #endif /* HTC_RAW_INTERFACE */
732
733 /* AP mode */
734 /*TODO: These routines should be moved to a file that is common across OS */
735 sta_t *
736 ieee80211_find_conn(struct ar6_softc *ar, u8 *node_addr);
737
738 sta_t *
739 ieee80211_find_conn_for_aid(struct ar6_softc *ar, u8 aid);
740
741 u8 remove_sta(struct ar6_softc *ar, u8 *mac, u16 reason);
742
743 /* HCI support */
744
745 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
746 int ar6000_setup_hci(struct ar6_softc *ar);
747 void ar6000_cleanup_hci(struct ar6_softc *ar);
748 void ar6000_set_default_ar3kconfig(struct ar6_softc *ar, void *ar3kconfig);
749
750 /* HCI bridge testing */
751 int hci_test_send(struct ar6_softc *ar, struct sk_buff *skb);
752 #endif
753
754 ATH_DEBUG_DECLARE_EXTERN(htc);
755 ATH_DEBUG_DECLARE_EXTERN(wmi);
756 ATH_DEBUG_DECLARE_EXTERN(bmi);
757 ATH_DEBUG_DECLARE_EXTERN(hif);
758 ATH_DEBUG_DECLARE_EXTERN(wlan);
759 ATH_DEBUG_DECLARE_EXTERN(misc);
760
761 extern u8 bcast_mac[];
762 extern u8 null_mac[];
763
764 #ifdef __cplusplus
765 }
766 #endif
767
768 #endif /* _AR6000_H_ */
769