~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/staging/ath6kl/os/linux/include/ar6000_drv.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

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