1 From 5421836ea607c6434d1c9734b2ad86df5e978460 Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Fri, 25 Jul 2008 22:21:24 +0100
4 Subject: [PATCH] atheros_2_0_function.patch
7 drivers/sdio/function/Kconfig | 11 +
8 drivers/sdio/function/Makefile | 1 +
9 drivers/sdio/function/wlan/Makefile | 4 +
10 drivers/sdio/function/wlan/ar6000/Makefile | 38 +
11 .../sdio/function/wlan/ar6000/ar6000/ar6000_drv.c | 3062 ++++++++++++++
12 .../sdio/function/wlan/ar6000/ar6000/ar6000_drv.h | 360 ++
13 .../function/wlan/ar6000/ar6000/ar6000_raw_if.c | 439 ++
14 .../function/wlan/ar6000/ar6000/ar6xapi_linux.h | 128 +
15 .../function/wlan/ar6000/ar6000/athdrv_linux.h | 993 +++++
16 .../function/wlan/ar6000/ar6000/athtypes_linux.h | 47 +
17 .../function/wlan/ar6000/ar6000/config_linux.h | 44 +
18 .../sdio/function/wlan/ar6000/ar6000/debug_linux.h | 86 +
19 drivers/sdio/function/wlan/ar6000/ar6000/ioctl.c | 2540 +++++++++++
20 drivers/sdio/function/wlan/ar6000/ar6000/netbuf.c | 225 +
21 .../sdio/function/wlan/ar6000/ar6000/osapi_linux.h | 319 ++
22 .../function/wlan/ar6000/ar6000/wireless_ext.c | 1946 +++++++++
23 drivers/sdio/function/wlan/ar6000/bmi/bmi.c | 657 +++
24 .../sdio/function/wlan/ar6000/bmi/bmi_internal.h | 45 +
25 drivers/sdio/function/wlan/ar6000/hif/hif.c | 818 ++++
26 .../sdio/function/wlan/ar6000/hif/hif_internal.h | 102 +
27 drivers/sdio/function/wlan/ar6000/htc/ar6k.c | 991 +++++
28 drivers/sdio/function/wlan/ar6000/htc/ar6k.h | 191 +
29 .../sdio/function/wlan/ar6000/htc/ar6k_events.c | 638 +++
30 drivers/sdio/function/wlan/ar6000/htc/htc.c | 507 +++
31 drivers/sdio/function/wlan/ar6000/htc/htc_debug.h | 65 +
32 .../sdio/function/wlan/ar6000/htc/htc_internal.h | 168 +
33 drivers/sdio/function/wlan/ar6000/htc/htc_recv.c | 703 ++++
34 drivers/sdio/function/wlan/ar6000/htc/htc_send.c | 541 +++
35 .../sdio/function/wlan/ar6000/htc/htc_services.c | 403 ++
36 .../function/wlan/ar6000/include/AR6001_regdump.h | 100 +
37 .../function/wlan/ar6000/include/AR6K_version.h | 36 +
38 .../wlan/ar6000/include/AR6K_version.h.NEW | 36 +
39 .../sdio/function/wlan/ar6000/include/AR6Khwreg.h | 147 +
40 .../sdio/function/wlan/ar6000/include/a_config.h | 27 +
41 .../sdio/function/wlan/ar6000/include/a_debug.h | 41 +
42 drivers/sdio/function/wlan/ar6000/include/a_drv.h | 28 +
43 .../sdio/function/wlan/ar6000/include/a_drv_api.h | 185 +
44 .../sdio/function/wlan/ar6000/include/a_osapi.h | 28 +
45 .../sdio/function/wlan/ar6000/include/a_types.h | 28 +
46 .../sdio/function/wlan/ar6000/include/ar6000_api.h | 29 +
47 .../function/wlan/ar6000/include/ar6000_diag.h | 38 +
48 .../sdio/function/wlan/ar6000/include/athdefs.h | 85 +
49 drivers/sdio/function/wlan/ar6000/include/athdrv.h | 32 +
50 .../sdio/function/wlan/ar6000/include/athendpack.h | 41 +
51 .../function/wlan/ar6000/include/athstartpack.h | 42 +
52 drivers/sdio/function/wlan/ar6000/include/bmi.h | 100 +
53 .../sdio/function/wlan/ar6000/include/bmi_msg.h | 199 +
54 .../sdio/function/wlan/ar6000/include/common_drv.h | 61 +
55 drivers/sdio/function/wlan/ar6000/include/dbglog.h | 107 +
56 .../sdio/function/wlan/ar6000/include/dbglog_api.h | 46 +
57 .../sdio/function/wlan/ar6000/include/dbglog_id.h | 307 ++
58 .../sdio/function/wlan/ar6000/include/dl_list.h | 114 +
59 .../sdio/function/wlan/ar6000/include/dset_api.h | 63 +
60 .../function/wlan/ar6000/include/dset_internal.h | 39 +
61 drivers/sdio/function/wlan/ar6000/include/dsetid.h | 110 +
62 drivers/sdio/function/wlan/ar6000/include/gpio.h | 34 +
63 .../sdio/function/wlan/ar6000/include/gpio_api.h | 57 +
64 drivers/sdio/function/wlan/ar6000/include/hif.h | 291 ++
65 .../function/wlan/ar6000/include/host_version.h | 49 +
66 drivers/sdio/function/wlan/ar6000/include/htc.h | 190 +
67 .../sdio/function/wlan/ar6000/include/htc_api.h | 436 ++
68 .../sdio/function/wlan/ar6000/include/htc_packet.h | 138 +
69 .../function/wlan/ar6000/include/htc_services.h | 37 +
70 .../sdio/function/wlan/ar6000/include/ieee80211.h | 342 ++
71 .../function/wlan/ar6000/include/ieee80211_ioctl.h | 163 +
72 .../function/wlan/ar6000/include/ieee80211_node.h | 77 +
73 .../sdio/function/wlan/ar6000/include/ini_dset.h | 40 +
74 drivers/sdio/function/wlan/ar6000/include/regDb.h | 19 +
75 .../sdio/function/wlan/ar6000/include/regdump.h | 33 +
76 .../sdio/function/wlan/ar6000/include/targaddrs.h | 158 +
77 .../sdio/function/wlan/ar6000/include/testcmd.h | 144 +
78 .../sdio/function/wlan/ar6000/include/wlan_api.h | 101 +
79 .../sdio/function/wlan/ar6000/include/wlan_dset.h | 20 +
80 drivers/sdio/function/wlan/ar6000/include/wmi.h | 1743 ++++++++
81 .../sdio/function/wlan/ar6000/include/wmi_api.h | 259 ++
82 drivers/sdio/function/wlan/ar6000/include/wmix.h | 233 +
83 .../sdio/function/wlan/ar6000/miscdrv/common_drv.c | 467 +++
84 .../function/wlan/ar6000/miscdrv/credit_dist.c | 346 ++
85 drivers/sdio/function/wlan/ar6000/wlan/wlan_node.c | 371 ++
86 .../function/wlan/ar6000/wlan/wlan_recv_beacon.c | 192 +
87 .../sdio/function/wlan/ar6000/wlan/wlan_utils.c | 59 +
88 drivers/sdio/function/wlan/ar6000/wmi/wmi.c | 3921 +++++++++++++++++
89 drivers/sdio/function/wlan/ar6000/wmi/wmi_doc.h | 4421 ++++++++++++++++++++
90 drivers/sdio/function/wlan/ar6000/wmi/wmi_host.h | 71 +
91 84 files changed, 32553 insertions(+), 0 deletions(-)
92 create mode 100644 drivers/sdio/function/Kconfig
93 create mode 100644 drivers/sdio/function/Makefile
94 create mode 100644 drivers/sdio/function/wlan/Makefile
95 create mode 100644 drivers/sdio/function/wlan/ar6000/Makefile
96 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
97 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.h
98 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/ar6000_raw_if.c
99 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/ar6xapi_linux.h
100 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/athdrv_linux.h
101 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/athtypes_linux.h
102 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/config_linux.h
103 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h
104 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/ioctl.c
105 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/netbuf.c
106 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/osapi_linux.h
107 create mode 100644 drivers/sdio/function/wlan/ar6000/ar6000/wireless_ext.c
108 create mode 100644 drivers/sdio/function/wlan/ar6000/bmi/bmi.c
109 create mode 100644 drivers/sdio/function/wlan/ar6000/bmi/bmi_internal.h
110 create mode 100644 drivers/sdio/function/wlan/ar6000/hif/hif.c
111 create mode 100644 drivers/sdio/function/wlan/ar6000/hif/hif_internal.h
112 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/ar6k.c
113 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/ar6k.h
114 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/ar6k_events.c
115 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/htc.c
116 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/htc_debug.h
117 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/htc_internal.h
118 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/htc_recv.c
119 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/htc_send.c
120 create mode 100644 drivers/sdio/function/wlan/ar6000/htc/htc_services.c
121 create mode 100644 drivers/sdio/function/wlan/ar6000/include/AR6001_regdump.h
122 create mode 100644 drivers/sdio/function/wlan/ar6000/include/AR6K_version.h
123 create mode 100644 drivers/sdio/function/wlan/ar6000/include/AR6K_version.h.NEW
124 create mode 100644 drivers/sdio/function/wlan/ar6000/include/AR6Khwreg.h
125 create mode 100644 drivers/sdio/function/wlan/ar6000/include/a_config.h
126 create mode 100644 drivers/sdio/function/wlan/ar6000/include/a_debug.h
127 create mode 100644 drivers/sdio/function/wlan/ar6000/include/a_drv.h
128 create mode 100644 drivers/sdio/function/wlan/ar6000/include/a_drv_api.h
129 create mode 100644 drivers/sdio/function/wlan/ar6000/include/a_osapi.h
130 create mode 100644 drivers/sdio/function/wlan/ar6000/include/a_types.h
131 create mode 100644 drivers/sdio/function/wlan/ar6000/include/ar6000_api.h
132 create mode 100644 drivers/sdio/function/wlan/ar6000/include/ar6000_diag.h
133 create mode 100644 drivers/sdio/function/wlan/ar6000/include/athdefs.h
134 create mode 100644 drivers/sdio/function/wlan/ar6000/include/athdrv.h
135 create mode 100644 drivers/sdio/function/wlan/ar6000/include/athendpack.h
136 create mode 100644 drivers/sdio/function/wlan/ar6000/include/athstartpack.h
137 create mode 100644 drivers/sdio/function/wlan/ar6000/include/bmi.h
138 create mode 100644 drivers/sdio/function/wlan/ar6000/include/bmi_msg.h
139 create mode 100644 drivers/sdio/function/wlan/ar6000/include/common_drv.h
140 create mode 100644 drivers/sdio/function/wlan/ar6000/include/dbglog.h
141 create mode 100644 drivers/sdio/function/wlan/ar6000/include/dbglog_api.h
142 create mode 100644 drivers/sdio/function/wlan/ar6000/include/dbglog_id.h
143 create mode 100644 drivers/sdio/function/wlan/ar6000/include/dl_list.h
144 create mode 100644 drivers/sdio/function/wlan/ar6000/include/dset_api.h
145 create mode 100644 drivers/sdio/function/wlan/ar6000/include/dset_internal.h
146 create mode 100644 drivers/sdio/function/wlan/ar6000/include/dsetid.h
147 create mode 100644 drivers/sdio/function/wlan/ar6000/include/gpio.h
148 create mode 100644 drivers/sdio/function/wlan/ar6000/include/gpio_api.h
149 create mode 100644 drivers/sdio/function/wlan/ar6000/include/hif.h
150 create mode 100644 drivers/sdio/function/wlan/ar6000/include/host_version.h
151 create mode 100644 drivers/sdio/function/wlan/ar6000/include/htc.h
152 create mode 100644 drivers/sdio/function/wlan/ar6000/include/htc_api.h
153 create mode 100644 drivers/sdio/function/wlan/ar6000/include/htc_packet.h
154 create mode 100644 drivers/sdio/function/wlan/ar6000/include/htc_services.h
155 create mode 100644 drivers/sdio/function/wlan/ar6000/include/ieee80211.h
156 create mode 100644 drivers/sdio/function/wlan/ar6000/include/ieee80211_ioctl.h
157 create mode 100644 drivers/sdio/function/wlan/ar6000/include/ieee80211_node.h
158 create mode 100644 drivers/sdio/function/wlan/ar6000/include/ini_dset.h
159 create mode 100644 drivers/sdio/function/wlan/ar6000/include/regDb.h
160 create mode 100644 drivers/sdio/function/wlan/ar6000/include/regdump.h
161 create mode 100644 drivers/sdio/function/wlan/ar6000/include/targaddrs.h
162 create mode 100644 drivers/sdio/function/wlan/ar6000/include/testcmd.h
163 create mode 100644 drivers/sdio/function/wlan/ar6000/include/wlan_api.h
164 create mode 100644 drivers/sdio/function/wlan/ar6000/include/wlan_dset.h
165 create mode 100644 drivers/sdio/function/wlan/ar6000/include/wmi.h
166 create mode 100644 drivers/sdio/function/wlan/ar6000/include/wmi_api.h
167 create mode 100644 drivers/sdio/function/wlan/ar6000/include/wmix.h
168 create mode 100644 drivers/sdio/function/wlan/ar6000/miscdrv/common_drv.c
169 create mode 100644 drivers/sdio/function/wlan/ar6000/miscdrv/credit_dist.c
170 create mode 100644 drivers/sdio/function/wlan/ar6000/wlan/wlan_node.c
171 create mode 100644 drivers/sdio/function/wlan/ar6000/wlan/wlan_recv_beacon.c
172 create mode 100644 drivers/sdio/function/wlan/ar6000/wlan/wlan_utils.c
173 create mode 100644 drivers/sdio/function/wlan/ar6000/wmi/wmi.c
174 create mode 100644 drivers/sdio/function/wlan/ar6000/wmi/wmi_doc.h
175 create mode 100644 drivers/sdio/function/wlan/ar6000/wmi/wmi_host.h
177 diff --git a/drivers/sdio/function/Kconfig b/drivers/sdio/function/Kconfig
179 index 0000000..9b46af3
181 +++ b/drivers/sdio/function/Kconfig
183 +#menu "SDIO function drivers"
185 +config SDIO_AR6000_WLAN
186 + tristate "ar6000 wireless networking over sdio"
188 + select WIRELESS_EXT
194 \ No newline at end of file
195 diff --git a/drivers/sdio/function/Makefile b/drivers/sdio/function/Makefile
197 index 0000000..4940d37
199 +++ b/drivers/sdio/function/Makefile
201 +obj-$(CONFIG_SDIO_AR6000_WLAN) += wlan/
202 \ No newline at end of file
203 diff --git a/drivers/sdio/function/wlan/Makefile b/drivers/sdio/function/wlan/Makefile
205 index 0000000..b1e61fc
207 +++ b/drivers/sdio/function/wlan/Makefile
210 +# SDIO wlan ar600 card function driver
212 +obj-$(CONFIG_SDIO_AR6000_WLAN) += ar6000/
213 \ No newline at end of file
214 diff --git a/drivers/sdio/function/wlan/ar6000/Makefile b/drivers/sdio/function/wlan/ar6000/Makefile
216 index 0000000..810dab6
218 +++ b/drivers/sdio/function/wlan/ar6000/Makefile
224 +EXTRA_CFLAGS += -I$(src)/include
226 +EXTRA_CFLAGS += -DLINUX -DDEBUG -D__KERNEL__ -DHTC_RAW_INTERFACE\
227 + -DTCMD -DSEND_EVENT_TO_APP -DUSER_KEYS \
229 + -DMULTIPLE_FRAMES_PER_INTERRUPT -DAR6000REV$(REV) \
230 + -DBLOCK_TX_PATH_FLAG \
233 +EXTRA_CFLAGS += -DKERNEL_2_6
235 +obj-$(CONFIG_SDIO_AR6000_WLAN) += ar6000.o
237 +ar6000-objs += htc/ar6k.o \
238 + htc/ar6k_events.o \
241 + htc/htc_services.o \
245 + ar6000/ar6000_drv.o \
246 + ar6000/ar6000_raw_if.o \
248 + ar6000/wireless_ext.o \
250 + miscdrv/common_drv.o \
251 + miscdrv/credit_dist.o \
254 + wlan/wlan_recv_beacon.o \
258 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
260 index 0000000..bb9ef55
262 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
266 + * Copyright (c) 2004-2007 Atheros Communications Inc.
267 + * All rights reserved.
270 + * This program is free software; you can redistribute it and/or modify
271 + * it under the terms of the GNU General Public License version 2 as
272 + * published by the Free Software Foundation;
274 + * Software distributed under the License is distributed on an "AS
275 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
276 + * implied. See the License for the specific language governing
277 + * rights and limitations under the License.
284 + * This driver is a pseudo ethernet driver to access the Atheros AR6000
287 +static const char athId[] __attribute__ ((unused)) = "$Id: //depot/sw/releases/olca2.0-GPL/host/os/linux/ar6000_drv.c#2 $";
289 +#include "ar6000_drv.h"
292 +MODULE_LICENSE("GPL and additional rights");
294 +#ifndef REORG_APTC_HEURISTICS
295 +#undef ADAPTIVE_POWER_THROUGHPUT_CONTROL
296 +#endif /* REORG_APTC_HEURISTICS */
298 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
299 +#define APTC_TRAFFIC_SAMPLING_INTERVAL 100 /* msec */
300 +#define APTC_UPPER_THROUGHPUT_THRESHOLD 3000 /* Kbps */
301 +#define APTC_LOWER_THROUGHPUT_THRESHOLD 2000 /* Kbps */
303 +typedef struct aptc_traffic_record {
304 + A_BOOL timerScheduled;
305 + struct timeval samplingTS;
306 + unsigned long bytesReceived;
307 + unsigned long bytesTransmitted;
308 +} APTC_TRAFFIC_RECORD;
311 +APTC_TRAFFIC_RECORD aptcTR;
312 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
315 +unsigned int bypasswmi = 0;
316 +unsigned int debuglevel = 0;
317 +int tspecCompliance = 1;
318 +unsigned int busspeedlow = 0;
319 +unsigned int onebitmode = 0;
320 +unsigned int skipflash = 0;
321 +unsigned int wmitimeout = 2;
322 +unsigned int wlanNodeCaching = 1;
323 +unsigned int enableuartprint = 0;
324 +unsigned int logWmiRawMsgs = 0;
325 +unsigned int enabletimerwar = 0;
326 +unsigned int mbox_yield_limit = 99;
327 +int reduce_credit_dribble = 1 + HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF;
328 +int allow_trace_signal = 0;
329 +#ifdef CONFIG_HOST_TCMD_SUPPORT
330 +unsigned int testmode =0;
333 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
334 +module_param(bmienable, int, 0644);
335 +module_param(bypasswmi, int, 0644);
336 +module_param(debuglevel, int, 0644);
337 +module_param(tspecCompliance, int, 0644);
338 +module_param(onebitmode, int, 0644);
339 +module_param(busspeedlow, int, 0644);
340 +module_param(skipflash, int, 0644);
341 +module_param(wmitimeout, int, 0644);
342 +module_param(wlanNodeCaching, int, 0644);
343 +module_param(logWmiRawMsgs, int, 0644);
344 +module_param(enableuartprint, int, 0644);
345 +module_param(enabletimerwar, int, 0644);
346 +module_param(mbox_yield_limit, int, 0644);
347 +module_param(reduce_credit_dribble, int, 0644);
348 +module_param(allow_trace_signal, int, 0644);
349 +#ifdef CONFIG_HOST_TCMD_SUPPORT
350 +module_param(testmode, int, 0644);
355 +/* for linux 2.4 and lower */
356 +MODULE_PARM(bmienable,"i");
357 +MODULE_PARM(bypasswmi,"i");
358 +MODULE_PARM(debuglevel, "i");
359 +MODULE_PARM(onebitmode,"i");
360 +MODULE_PARM(busspeedlow, "i");
361 +MODULE_PARM(skipflash, "i");
362 +MODULE_PARM(wmitimeout, "i");
363 +MODULE_PARM(wlanNodeCaching, "i");
364 +MODULE_PARM(enableuartprint,"i");
365 +MODULE_PARM(logWmiRawMsgs, "i");
366 +MODULE_PARM(enabletimerwar,"i");
367 +MODULE_PARM(mbox_yield_limit,"i");
368 +MODULE_PARM(reduce_credit_dribble,"i");
369 +MODULE_PARM(allow_trace_signal,"i");
370 +#ifdef CONFIG_HOST_TCMD_SUPPORT
371 +MODULE_PARM(testmode, "i");
375 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
376 +/* in 2.6.10 and later this is now a pointer to a uint */
377 +unsigned int _mboxnum = HTC_MAILBOX_NUM_MAX;
378 +#define mboxnum &_mboxnum
380 +unsigned int mboxnum = HTC_MAILBOX_NUM_MAX;
384 +A_UINT32 g_dbg_flags = DBG_DEFAULTS;
385 +unsigned int debugflags = 0;
386 +int debugdriver = 1;
387 +unsigned int debughtc = 128;
388 +unsigned int debugbmi = 1;
389 +unsigned int debughif = 2;
390 +unsigned int resetok = 1;
391 +unsigned int txcreditsavailable[HTC_MAILBOX_NUM_MAX] = {0};
392 +unsigned int txcreditsconsumed[HTC_MAILBOX_NUM_MAX] = {0};
393 +unsigned int txcreditintrenable[HTC_MAILBOX_NUM_MAX] = {0};
394 +unsigned int txcreditintrenableaggregate[HTC_MAILBOX_NUM_MAX] = {0};
396 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
397 +module_param(debugflags, int, 0644);
398 +module_param(debugdriver, int, 0644);
399 +module_param(debughtc, int, 0644);
400 +module_param(debugbmi, int, 0644);
401 +module_param(debughif, int, 0644);
402 +module_param(resetok, int, 0644);
403 +module_param_array(txcreditsavailable, int, mboxnum, 0644);
404 +module_param_array(txcreditsconsumed, int, mboxnum, 0644);
405 +module_param_array(txcreditintrenable, int, mboxnum, 0644);
406 +module_param_array(txcreditintrenableaggregate, int, mboxnum, 0644);
408 +/* linux 2.4 and lower */
409 +MODULE_PARM(debugflags,"i");
410 +MODULE_PARM(debugdriver, "i");
411 +MODULE_PARM(debughtc, "i");
412 +MODULE_PARM(debugbmi, "i");
413 +MODULE_PARM(debughif, "i");
414 +MODULE_PARM(resetok, "i");
415 +MODULE_PARM(txcreditsavailable, "0-3i");
416 +MODULE_PARM(txcreditsconsumed, "0-3i");
417 +MODULE_PARM(txcreditintrenable, "0-3i");
418 +MODULE_PARM(txcreditintrenableaggregate, "0-3i");
423 +unsigned int tx_attempt[HTC_MAILBOX_NUM_MAX] = {0};
424 +unsigned int tx_post[HTC_MAILBOX_NUM_MAX] = {0};
425 +unsigned int tx_complete[HTC_MAILBOX_NUM_MAX] = {0};
426 +unsigned int hifBusRequestNumMax = 40;
427 +unsigned int war23838_disabled = 0;
428 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
429 +unsigned int enableAPTCHeuristics = 1;
430 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
431 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
432 +module_param_array(tx_attempt, int, mboxnum, 0644);
433 +module_param_array(tx_post, int, mboxnum, 0644);
434 +module_param_array(tx_complete, int, mboxnum, 0644);
435 +module_param(hifBusRequestNumMax, int, 0644);
436 +module_param(war23838_disabled, int, 0644);
437 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
438 +module_param(enableAPTCHeuristics, int, 0644);
439 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
441 +MODULE_PARM(tx_attempt, "0-3i");
442 +MODULE_PARM(tx_post, "0-3i");
443 +MODULE_PARM(tx_complete, "0-3i");
444 +MODULE_PARM(hifBusRequestNumMax, "i");
445 +MODULE_PARM(war23838_disabled, "i");
446 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
447 +MODULE_PARM(enableAPTCHeuristics, "i");
448 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
451 +#ifdef BLOCK_TX_PATH_FLAG
453 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
454 +module_param(blocktx, int, 0644);
456 +MODULE_PARM(blocktx, "i");
458 +#endif /* BLOCK_TX_PATH_FLAG */
460 +// TODO move to arsoft_c
461 +USER_RSSI_THOLD rssi_map[12];
463 +int reconnect_flag = 0;
465 +DECLARE_WAIT_QUEUE_HEAD(ar6000_scan_queue);
467 +/* Function declarations */
468 +static int ar6000_init_module(void);
469 +static void ar6000_cleanup_module(void);
471 +int ar6000_init(struct net_device *dev);
472 +static int ar6000_open(struct net_device *dev);
473 +static int ar6000_close(struct net_device *dev);
474 +static void ar6000_init_control_info(AR_SOFTC_T *ar);
475 +static int ar6000_data_tx(struct sk_buff *skb, struct net_device *dev);
477 +static void ar6000_destroy(struct net_device *dev, unsigned int unregister);
478 +static void ar6000_detect_error(unsigned long ptr);
479 +static struct net_device_stats *ar6000_get_stats(struct net_device *dev);
480 +static struct iw_statistics *ar6000_get_iwstats(struct net_device * dev);
483 + * HTC service connection handlers
485 +static void ar6000_avail_ev(HTC_HANDLE HTCHandle);
487 +static void ar6000_unavail_ev(void *Instance);
489 +static void ar6000_target_failure(void *Instance, A_STATUS Status);
491 +static void ar6000_rx(void *Context, HTC_PACKET *pPacket);
493 +static void ar6000_rx_refill(void *Context,HTC_ENDPOINT_ID Endpoint);
495 +static void ar6000_tx_complete(void *Context, HTC_PACKET *pPacket);
497 +static void ar6000_tx_queue_full(void *Context, HTC_ENDPOINT_ID Endpoint);
503 +static struct net_device *ar6000_devices[MAX_AR6000];
504 +extern struct iw_handler_def ath_iw_handler_def;
505 +DECLARE_WAIT_QUEUE_HEAD(arEvent);
506 +static void ar6000_cookie_init(AR_SOFTC_T *ar);
507 +static void ar6000_cookie_cleanup(AR_SOFTC_T *ar);
508 +static void ar6000_free_cookie(AR_SOFTC_T *ar, struct ar_cookie * cookie);
509 +static struct ar_cookie *ar6000_alloc_cookie(AR_SOFTC_T *ar);
510 +static void ar6000_TxDataCleanup(AR_SOFTC_T *ar);
513 +static A_STATUS ar6000_reinstall_keys(AR_SOFTC_T *ar,A_UINT8 key_op_ctrl);
517 +static struct ar_cookie s_ar_cookie_mem[MAX_COOKIE_NUM];
519 +#define HOST_INTEREST_ITEM_ADDRESS(ar, item) \
520 +((ar->arTargetType == TARGET_TYPE_AR6001) ? \
521 + AR6001_HOST_INTEREST_ITEM_ADDRESS(item) : \
522 + AR6002_HOST_INTEREST_ITEM_ADDRESS(item))
525 +/* Debug log support */
528 + * Flag to govern whether the debug logs should be parsed in the kernel
529 + * or reported to the application.
531 +#define REPORT_DEBUG_LOGS_TO_APP
534 +ar6000_set_host_app_area(AR_SOFTC_T *ar)
536 + A_UINT32 address, data;
537 + struct host_app_area_s host_app_area;
539 + /* Fetch the address of the host_app_area_s instance in the host interest area */
540 + address = HOST_INTEREST_ITEM_ADDRESS(ar, hi_app_host_interest);
541 + if (ar6000_ReadRegDiag(ar->arHifDevice, &address, &data) != A_OK) {
545 + host_app_area.wmi_protocol_ver = WMI_PROTOCOL_VERSION;
546 + if (ar6000_WriteDataDiag(ar->arHifDevice, address,
547 + (A_UCHAR *)&host_app_area,
548 + sizeof(struct host_app_area_s)) != A_OK)
557 +dbglog_get_debug_hdr_ptr(AR_SOFTC_T *ar)
563 + address = HOST_INTEREST_ITEM_ADDRESS(ar, hi_dbglog_hdr);
564 + if ((status = ar6000_ReadDataDiag(ar->arHifDevice, address,
565 + (A_UCHAR *)¶m, 4)) != A_OK)
574 + * The dbglog module has been initialized. Its ok to access the relevant
575 + * data stuctures over the diagnostic window.
578 +ar6000_dbglog_init_done(AR_SOFTC_T *ar)
580 + ar->dbglog_init_done = TRUE;
584 +dbglog_get_debug_fragment(A_INT8 *datap, A_UINT32 len, A_UINT32 limit)
592 + count = fraglen = 0;
593 + buffer = (A_INT32 *)datap;
594 + length = (limit >> 2);
596 + if (len <= limit) {
599 + while (count < length) {
600 + numargs = DBGLOG_GET_NUMARGS(buffer[count]);
601 + fraglen = (count << 2);
602 + count += numargs + 1;
610 +dbglog_parse_debug_logs(A_INT8 *datap, A_UINT32 len)
614 + A_UINT32 timestamp;
621 + buffer = (A_INT32 *)datap;
622 + length = (len >> 2);
623 + while (count < length) {
624 + debugid = DBGLOG_GET_DBGID(buffer[count]);
625 + moduleid = DBGLOG_GET_MODULEID(buffer[count]);
626 + numargs = DBGLOG_GET_NUMARGS(buffer[count]);
627 + timestamp = DBGLOG_GET_TIMESTAMP(buffer[count]);
630 + AR_DEBUG_PRINTF("%d %d (%d)\n", moduleid, debugid, timestamp);
634 + AR_DEBUG_PRINTF("%d %d (%d): 0x%x\n", moduleid, debugid,
635 + timestamp, buffer[count+1]);
639 + AR_DEBUG_PRINTF("%d %d (%d): 0x%x, 0x%x\n", moduleid, debugid,
640 + timestamp, buffer[count+1], buffer[count+2]);
644 + AR_DEBUG_PRINTF("Invalid args: %d\n", numargs);
646 + count += numargs + 1;
651 +ar6000_dbglog_get_debug_logs(AR_SOFTC_T *ar)
653 + struct dbglog_hdr_s debug_hdr;
654 + struct dbglog_buf_s debug_buf;
659 + A_UINT32 debug_hdr_ptr;
661 + if (!ar->dbglog_init_done) return A_ERROR;
664 + AR6000_SPIN_LOCK(&ar->arLock, 0);
666 + if (ar->dbgLogFetchInProgress) {
667 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
671 + /* block out others */
672 + ar->dbgLogFetchInProgress = TRUE;
674 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
676 + debug_hdr_ptr = dbglog_get_debug_hdr_ptr(ar);
677 + printk("debug_hdr_ptr: 0x%x\n", debug_hdr_ptr);
679 + /* Get the contents of the ring buffer */
680 + if (debug_hdr_ptr) {
681 + address = debug_hdr_ptr;
682 + length = sizeof(struct dbglog_hdr_s);
683 + ar6000_ReadDataDiag(ar->arHifDevice, address,
684 + (A_UCHAR *)&debug_hdr, length);
685 + address = (A_UINT32)debug_hdr.dbuf;
686 + firstbuf = address;
687 + dropped = debug_hdr.dropped;
688 + length = sizeof(struct dbglog_buf_s);
689 + ar6000_ReadDataDiag(ar->arHifDevice, address,
690 + (A_UCHAR *)&debug_buf, length);
693 + address = (A_UINT32)debug_buf.buffer;
694 + length = debug_buf.length;
695 + if ((length) && (debug_buf.length <= debug_buf.bufsize)) {
696 + /* Rewind the index if it is about to overrun the buffer */
697 + if (ar->log_cnt > (DBGLOG_HOST_LOG_BUFFER_SIZE - length)) {
700 + if(A_OK != ar6000_ReadDataDiag(ar->arHifDevice, address,
701 + (A_UCHAR *)&ar->log_buffer[ar->log_cnt], length))
705 + ar6000_dbglog_event(ar, dropped, &ar->log_buffer[ar->log_cnt], length);
706 + ar->log_cnt += length;
708 + AR_DEBUG_PRINTF("Length: %d (Total size: %d)\n",
709 + debug_buf.length, debug_buf.bufsize);
712 + address = (A_UINT32)debug_buf.next;
713 + length = sizeof(struct dbglog_buf_s);
714 + if(A_OK != ar6000_ReadDataDiag(ar->arHifDevice, address,
715 + (A_UCHAR *)&debug_buf, length))
720 + } while (address != firstbuf);
723 + ar->dbgLogFetchInProgress = FALSE;
729 +ar6000_dbglog_event(AR_SOFTC_T *ar, A_UINT32 dropped,
730 + A_INT8 *buffer, A_UINT32 length)
732 +#ifdef REPORT_DEBUG_LOGS_TO_APP
733 + #define MAX_WIRELESS_EVENT_SIZE 252
735 + * Break it up into chunks of MAX_WIRELESS_EVENT_SIZE bytes of messages.
736 + * There seems to be a limitation on the length of message that could be
737 + * transmitted to the user app via this mechanism.
739 + A_UINT32 send, sent;
742 + send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
743 + MAX_WIRELESS_EVENT_SIZE);
745 + ar6000_send_event_to_app(ar, WMIX_DBGLOG_EVENTID, &buffer[sent], send);
747 + send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
748 + MAX_WIRELESS_EVENT_SIZE);
751 + AR_DEBUG_PRINTF("Dropped logs: 0x%x\nDebug info length: %d\n",
754 + /* Interpret the debug logs */
755 + dbglog_parse_debug_logs(buffer, length);
756 +#endif /* REPORT_DEBUG_LOGS_TO_APP */
762 +ar6000_init_module(void)
764 + static int probed = 0;
766 + HTC_INIT_INFO initInfo;
768 + A_MEMZERO(&initInfo,sizeof(initInfo));
769 + initInfo.AddInstance = ar6000_avail_ev;
770 + initInfo.DeleteInstance = ar6000_unavail_ev;
771 + initInfo.TargetFailure = ar6000_target_failure;
775 + /* Set the debug flags if specified at load time */
776 + if(debugflags != 0)
778 + g_dbg_flags = debugflags;
787 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
788 + memset(&aptcTR, 0, sizeof(APTC_TRAFFIC_RECORD));
789 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
791 +#ifdef CONFIG_HOST_GPIO_SUPPORT
792 + ar6000_gpio_init();
793 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
795 + status = HTCInit(&initInfo);
803 +ar6000_cleanup_module(void)
806 + struct net_device *ar6000_netdev;
808 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
809 + /* Delete the Adaptive Power Control timer */
810 + if (timer_pending(&aptcTimer)) {
811 + del_timer_sync(&aptcTimer);
813 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
815 + for (i=0; i < MAX_AR6000; i++) {
816 + if (ar6000_devices[i] != NULL) {
817 + ar6000_netdev = ar6000_devices[i];
818 + ar6000_devices[i] = NULL;
819 + ar6000_destroy(ar6000_netdev, 1);
823 + /* shutting down HTC will cause the HIF layer to detach from the
824 + * underlying bus driver which will cause the subsequent deletion of
825 + * all HIF and HTC instances */
828 + AR_DEBUG_PRINTF("ar6000_cleanup: success\n");
831 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
833 +aptcTimerHandler(unsigned long arg)
836 + A_UINT32 throughput;
840 + ar = (AR_SOFTC_T *)arg;
841 + A_ASSERT(ar != NULL);
842 + A_ASSERT(!timer_pending(&aptcTimer));
844 + AR6000_SPIN_LOCK(&ar->arLock, 0);
846 + /* Get the number of bytes transferred */
847 + numbytes = aptcTR.bytesTransmitted + aptcTR.bytesReceived;
848 + aptcTR.bytesTransmitted = aptcTR.bytesReceived = 0;
850 + /* Calculate and decide based on throughput thresholds */
851 + throughput = ((numbytes * 8)/APTC_TRAFFIC_SAMPLING_INTERVAL); /* Kbps */
852 + if (throughput < APTC_LOWER_THROUGHPUT_THRESHOLD) {
853 + /* Enable Sleep and delete the timer */
854 + A_ASSERT(ar->arWmiReady == TRUE);
855 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
856 + status = wmi_powermode_cmd(ar->arWmi, REC_POWER);
857 + AR6000_SPIN_LOCK(&ar->arLock, 0);
858 + A_ASSERT(status == A_OK);
859 + aptcTR.timerScheduled = FALSE;
861 + A_TIMEOUT_MS(&aptcTimer, APTC_TRAFFIC_SAMPLING_INTERVAL, 0);
864 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
866 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
870 +/* set HTC block size, assume BMI is already initialized */
871 +A_STATUS ar6000_SetHTCBlockSize(AR_SOFTC_T *ar)
874 + A_UINT32 blocksizes[HTC_MAILBOX_NUM_MAX];
877 + /* get the block sizes */
878 + status = HIFConfigureDevice(ar->arHifDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
879 + blocksizes, sizeof(blocksizes));
881 + if (A_FAILED(status)) {
882 + AR_DEBUG_PRINTF("Failed to get block size info from HIF layer...\n");
885 + /* note: we actually get the block size for mailbox 1, for SDIO the block
886 + * size on mailbox 0 is artificially set to 1 */
887 + /* must be a power of 2 */
888 + A_ASSERT((blocksizes[1] & (blocksizes[1] - 1)) == 0);
890 + /* set the host interest area for the block size */
891 + status = BMIWriteMemory(ar->arHifDevice,
892 + HOST_INTEREST_ITEM_ADDRESS(ar, hi_mbox_io_block_sz),
893 + (A_UCHAR *)&blocksizes[1],
896 + if (A_FAILED(status)) {
897 + AR_DEBUG_PRINTF("BMIWriteMemory for IO block size failed \n");
901 + AR_DEBUG_PRINTF("Block Size Set: %d (target address:0x%X)\n",
902 + blocksizes[1], HOST_INTEREST_ITEM_ADDRESS(ar, hi_mbox_io_block_sz));
904 + /* set the host interest area for the mbox ISR yield limit */
905 + status = BMIWriteMemory(ar->arHifDevice,
906 + HOST_INTEREST_ITEM_ADDRESS(ar, hi_mbox_isr_yield_limit),
907 + (A_UCHAR *)&mbox_yield_limit,
910 + if (A_FAILED(status)) {
911 + AR_DEBUG_PRINTF("BMIWriteMemory for yield limit failed \n");
921 + * HTC Event handlers
924 +ar6000_avail_ev(HTC_HANDLE HTCHandle)
927 + struct net_device *dev;
929 + int device_index = 0;
931 + AR_DEBUG_PRINTF("ar6000_available\n");
933 + for (i=0; i < MAX_AR6000; i++) {
934 + if (ar6000_devices[i] == NULL) {
939 + if (i == MAX_AR6000) {
940 + AR_DEBUG_PRINTF("ar6000_available: max devices reached\n");
944 + /* Save this. It gives a bit better readability especially since */
945 + /* we use another local "i" variable below. */
948 + A_ASSERT(HTCHandle != NULL);
950 + dev = alloc_etherdev(sizeof(AR_SOFTC_T));
952 + AR_DEBUG_PRINTF("ar6000_available: can't alloc etherdev\n");
958 + if (dev->priv == NULL) {
959 + printk(KERN_CRIT "ar6000_available: Could not allocate memory\n");
963 + A_MEMZERO(dev->priv, sizeof(AR_SOFTC_T));
965 + ar = (AR_SOFTC_T *)dev->priv;
966 + ar->arNetDev = dev;
967 + ar->arHtcTarget = HTCHandle;
968 + ar->arHifDevice = HTCGetHifDevice(HTCHandle);
969 + ar->arWlanState = WLAN_ENABLED;
970 + ar->arDeviceIndex = device_index;
972 + A_INIT_TIMER(&ar->arHBChallengeResp.timer, ar6000_detect_error, dev);
973 + ar->arHBChallengeResp.seqNum = 0;
974 + ar->arHBChallengeResp.outstanding = FALSE;
975 + ar->arHBChallengeResp.missCnt = 0;
976 + ar->arHBChallengeResp.frequency = AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT;
977 + ar->arHBChallengeResp.missThres = AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT;
979 + ar6000_init_control_info(ar);
980 + init_waitqueue_head(&arEvent);
981 + sema_init(&ar->arSem, 1);
983 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
984 + A_INIT_TIMER(&aptcTimer, aptcTimerHandler, ar);
985 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
988 + * If requested, perform some magic which requires no cooperation from
989 + * the Target. It causes the Target to ignore flash and execute to the
992 + * This is intended to support recovery from a corrupted flash on Targets
993 + * that support flash.
997 + ar6000_reset_device_skipflash(ar->arHifDevice);
1002 + struct bmi_target_info targ_info;
1004 + if (BMIGetTargetInfo(ar->arHifDevice, &targ_info) != A_OK) {
1008 + ar->arVersion.target_ver = targ_info.target_ver;
1009 + ar->arTargetType = targ_info.target_type;
1012 + if (enableuartprint) {
1015 + if (BMIWriteMemory(ar->arHifDevice,
1016 + HOST_INTEREST_ITEM_ADDRESS(ar, hi_serial_enable),
1017 + (A_UCHAR *)¶m,
1020 + AR_DEBUG_PRINTF("BMIWriteMemory for enableuartprint failed \n");
1023 + AR_DEBUG_PRINTF("Serial console prints enabled\n");
1025 +#ifdef CONFIG_HOST_TCMD_SUPPORT
1027 + ar->arTargetMode = AR6000_TCMD_MODE;
1029 + ar->arTargetMode = AR6000_WLAN_MODE;
1032 + if (enabletimerwar) {
1035 + if (BMIReadMemory(ar->arHifDevice,
1036 + HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1037 + (A_UCHAR *)¶m,
1040 + AR_DEBUG_PRINTF("BMIReadMemory for enabletimerwar failed \n");
1044 + param |= HI_OPTION_TIMER_WAR;
1046 + if (BMIWriteMemory(ar->arHifDevice,
1047 + HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1048 + (A_UCHAR *)¶m,
1051 + AR_DEBUG_PRINTF("BMIWriteMemory for enabletimerwar failed \n");
1054 + AR_DEBUG_PRINTF("Timer WAR enabled\n");
1058 + /* since BMIInit is called in the driver layer, we have to set the block
1059 + * size here for the target */
1061 + if (A_FAILED(ar6000_SetHTCBlockSize(ar))) {
1065 + spin_lock_init(&ar->arLock);
1067 + /* Don't install the init function if BMI is requested */
1070 + dev->init = ar6000_init;
1072 + AR_DEBUG_PRINTF(" BMI enabled \n");
1075 + dev->open = &ar6000_open;
1076 + dev->stop = &ar6000_close;
1077 + dev->hard_start_xmit = &ar6000_data_tx;
1078 + dev->get_stats = &ar6000_get_stats;
1080 + /* dev->tx_timeout = ar6000_tx_timeout; */
1081 + dev->do_ioctl = &ar6000_ioctl;
1082 + dev->watchdog_timeo = AR6000_TX_TIMEOUT;
1083 + ar6000_ioctl_iwsetup(&ath_iw_handler_def);
1084 + dev->wireless_handlers = &ath_iw_handler_def;
1085 + ath_iw_handler_def.get_wireless_stats = ar6000_get_iwstats; /*Displayed via proc fs */
1088 + * We need the OS to provide us with more headroom in order to
1089 + * perform dix to 802.3, WMI header encap, and the HTC header
1091 + dev->hard_header_len = ETH_HLEN + sizeof(ATH_LLC_SNAP_HDR) +
1092 + sizeof(WMI_DATA_HDR) + HTC_HEADER_LEN;
1094 + /* This runs the init function */
1095 + if (register_netdev(dev)) {
1096 + AR_DEBUG_PRINTF("ar6000_avail: register_netdev failed\n");
1097 + ar6000_destroy(dev, 0);
1101 + HTCSetInstance(ar->arHtcTarget, ar);
1103 + /* We only register the device in the global list if we succeed. */
1104 + /* If the device is in the global list, it will be destroyed */
1105 + /* when the module is unloaded. */
1106 + ar6000_devices[device_index] = dev;
1108 + AR_DEBUG_PRINTF("ar6000_avail: name=%s htcTarget=0x%x, dev=0x%x (%d), ar=0x%x\n",
1109 + dev->name, (A_UINT32)HTCHandle, (A_UINT32)dev, device_index,
1113 +static void ar6000_target_failure(void *Instance, A_STATUS Status)
1115 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Instance;
1116 + WMI_TARGET_ERROR_REPORT_EVENT errEvent;
1117 + static A_BOOL sip = FALSE;
1119 + if (Status != A_OK) {
1120 + if (timer_pending(&ar->arHBChallengeResp.timer)) {
1121 + A_UNTIMEOUT(&ar->arHBChallengeResp.timer);
1124 + /* try dumping target assertion information (if any) */
1125 + ar6000_dump_target_assert_info(ar->arHifDevice,ar->arTargetType);
1128 + * Fetch the logs from the target via the diagnostic
1131 + ar6000_dbglog_get_debug_logs(ar);
1133 + /* Report the error only once */
1136 + errEvent.errorVal = WMI_TARGET_COM_ERR |
1137 + WMI_TARGET_FATAL_ERR;
1138 + ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
1139 + (A_UINT8 *)&errEvent,
1140 + sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
1146 +ar6000_unavail_ev(void *Instance)
1148 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Instance;
1149 + /* NULL out it's entry in the global list */
1150 + ar6000_devices[ar->arDeviceIndex] = NULL;
1151 + ar6000_destroy(ar->arNetDev, 1);
1155 + * We need to differentiate between the surprise and planned removal of the
1156 + * device because of the following consideration:
1157 + * - In case of surprise removal, the hcd already frees up the pending
1158 + * for the device and hence there is no need to unregister the function
1159 + * driver inorder to get these requests. For planned removal, the function
1160 + * driver has to explictly unregister itself to have the hcd return all the
1161 + * pending requests before the data structures for the devices are freed up.
1162 + * Note that as per the current implementation, the function driver will
1163 + * end up releasing all the devices since there is no API to selectively
1164 + * release a particular device.
1165 + * - Certain commands issued to the target can be skipped for surprise
1166 + * removal since they will anyway not go through.
1169 +ar6000_destroy(struct net_device *dev, unsigned int unregister)
1173 + AR_DEBUG_PRINTF("+ar6000_destroy \n");
1175 + if((dev == NULL) || ((ar = netdev_priv(dev)) == NULL))
1177 + AR_DEBUG_PRINTF("%s(): Failed to get device structure.\n", __func__);
1181 + /* Stop the transmit queues */
1182 + netif_stop_queue(dev);
1184 + /* Disable the target and the interrupts associated with it */
1185 + if (ar->arWmiReady == TRUE)
1189 + if (ar->arConnected == TRUE || ar->arConnectPending == TRUE)
1191 + AR_DEBUG_PRINTF("%s(): Disconnect\n", __func__);
1192 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1193 + ar6000_init_profile_info(ar);
1194 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1195 + wmi_disconnect_cmd(ar->arWmi);
1198 + ar6000_dbglog_get_debug_logs(ar);
1199 + ar->arWmiReady = FALSE;
1200 + ar->arConnected = FALSE;
1201 + ar->arConnectPending = FALSE;
1202 + wmi_shutdown(ar->arWmi);
1203 + ar->arWmiEnabled = FALSE;
1205 + ar->arWlanState = WLAN_ENABLED;
1207 + ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
1208 + ar->user_key_ctrl = 0;
1212 + AR_DEBUG_PRINTF("%s(): WMI stopped\n", __func__);
1216 + AR_DEBUG_PRINTF("%s(): WMI not ready 0x%08x 0x%08x\n",
1217 + __func__, (unsigned int) ar, (unsigned int) ar->arWmi);
1219 + /* Shut down WMI if we have started it */
1220 + if(ar->arWmiEnabled == TRUE)
1222 + AR_DEBUG_PRINTF("%s(): Shut down WMI\n", __func__);
1223 + wmi_shutdown(ar->arWmi);
1224 + ar->arWmiEnabled = FALSE;
1230 + HTCStop(ar->arHtcTarget);
1232 + /* set the instance to NULL so we do not get called back on remove incase we
1233 + * we're explicity destroyed by module unload */
1234 + HTCSetInstance(ar->arHtcTarget, NULL);
1237 + /* try to reset the device if we can
1238 + * The driver may have been configure NOT to reset the target during
1239 + * a debug session */
1240 + AR_DEBUG_PRINTF(" Attempting to reset target on instance destroy.... \n");
1241 + ar6000_reset_device(ar->arHifDevice, ar->arTargetType);
1243 + AR_DEBUG_PRINTF(" Host does not want target reset. \n");
1246 + /* Done with cookies */
1247 + ar6000_cookie_cleanup(ar);
1252 + /* Clear the tx counters */
1253 + memset(tx_attempt, 0, sizeof(tx_attempt));
1254 + memset(tx_post, 0, sizeof(tx_post));
1255 + memset(tx_complete, 0, sizeof(tx_complete));
1258 + /* Free up the device data structure */
1260 + unregister_netdev(dev);
1261 +#ifndef free_netdev
1267 + AR_DEBUG_PRINTF("-ar6000_destroy \n");
1270 +static void ar6000_detect_error(unsigned long ptr)
1272 + struct net_device *dev = (struct net_device *)ptr;
1273 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
1274 + WMI_TARGET_ERROR_REPORT_EVENT errEvent;
1276 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1278 + if (ar->arHBChallengeResp.outstanding) {
1279 + ar->arHBChallengeResp.missCnt++;
1281 + ar->arHBChallengeResp.missCnt = 0;
1284 + if (ar->arHBChallengeResp.missCnt > ar->arHBChallengeResp.missThres) {
1285 + /* Send Error Detect event to the application layer and do not reschedule the error detection module timer */
1286 + ar->arHBChallengeResp.missCnt = 0;
1287 + ar->arHBChallengeResp.seqNum = 0;
1288 + errEvent.errorVal = WMI_TARGET_COM_ERR | WMI_TARGET_FATAL_ERR;
1289 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1290 + ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
1291 + (A_UINT8 *)&errEvent,
1292 + sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
1296 + /* Generate the sequence number for the next challenge */
1297 + ar->arHBChallengeResp.seqNum++;
1298 + ar->arHBChallengeResp.outstanding = TRUE;
1300 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1302 + /* Send the challenge on the control channel */
1303 + if (wmi_get_challenge_resp_cmd(ar->arWmi, ar->arHBChallengeResp.seqNum, DRV_HB_CHALLENGE) != A_OK) {
1304 + AR_DEBUG_PRINTF("Unable to send heart beat challenge\n");
1308 + /* Reschedule the timer for the next challenge */
1309 + A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
1312 +void ar6000_init_profile_info(AR_SOFTC_T *ar)
1314 + ar->arSsidLen = 0;
1315 + A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
1316 + ar->arNetworkType = INFRA_NETWORK;
1317 + ar->arDot11AuthMode = OPEN_AUTH;
1318 + ar->arAuthMode = NONE_AUTH;
1319 + ar->arPairwiseCrypto = NONE_CRYPT;
1320 + ar->arPairwiseCryptoLen = 0;
1321 + ar->arGroupCrypto = NONE_CRYPT;
1322 + ar->arGroupCryptoLen = 0;
1323 + A_MEMZERO(ar->arWepKeyList, sizeof(ar->arWepKeyList));
1324 + A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
1325 + A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));
1326 + ar->arBssChannel = 0;
1330 +ar6000_init_control_info(AR_SOFTC_T *ar)
1332 + ar->arWmiEnabled = FALSE;
1333 + ar6000_init_profile_info(ar);
1334 + ar->arDefTxKeyIndex = 0;
1335 + A_MEMZERO(ar->arWepKeyList, sizeof(ar->arWepKeyList));
1336 + ar->arChannelHint = 0;
1337 + ar->arListenInterval = MAX_LISTEN_INTERVAL;
1338 + ar->arVersion.host_ver = AR6K_SW_VERSION;
1341 + ar->arTxPwrSet = FALSE;
1342 + ar->arSkipScan = 0;
1343 + ar->arBeaconInterval = 0;
1344 + ar->arBitRate = 0;
1345 + ar->arMaxRetries = 0;
1346 + ar->arWmmEnabled = TRUE;
1350 +ar6000_open(struct net_device *dev)
1352 + /* Wake up the queues */
1353 + netif_wake_queue(dev);
1359 +ar6000_close(struct net_device *dev)
1361 + netif_stop_queue(dev);
1366 +/* connect to a service */
1367 +static A_STATUS ar6000_connectservice(AR_SOFTC_T *ar,
1368 + HTC_SERVICE_CONNECT_REQ *pConnect,
1369 + WMI_PRI_STREAM_ID WmiStreamID,
1373 + HTC_SERVICE_CONNECT_RESP response;
1377 + A_MEMZERO(&response,sizeof(response));
1379 + status = HTCConnectService(ar->arHtcTarget,
1383 + if (A_FAILED(status)) {
1384 + AR_DEBUG_PRINTF(" Failed to connect to %s service status:%d \n", pDesc, status);
1388 + if (WmiStreamID == WMI_NOT_MAPPED) {
1393 + /* set endpoint mapping for the WMI stream in the driver layer */
1394 + arSetWMIStream2EndpointIDMap(ar,WmiStreamID,response.Endpoint);
1401 +static void ar6000_TxDataCleanup(AR_SOFTC_T *ar)
1403 + /* flush all the data (non-control) streams
1404 + * we only flush packets that are tagged as data, we leave any control packets that
1405 + * were in the TX queues alone */
1406 + HTCFlushEndpoint(ar->arHtcTarget,
1407 + arWMIStream2EndpointID(ar,WMI_BEST_EFFORT_PRI),
1408 + AR6K_DATA_PKT_TAG);
1409 + HTCFlushEndpoint(ar->arHtcTarget,
1410 + arWMIStream2EndpointID(ar,WMI_LOW_PRI),
1411 + AR6K_DATA_PKT_TAG);
1412 + HTCFlushEndpoint(ar->arHtcTarget,
1413 + arWMIStream2EndpointID(ar,WMI_HIGH_PRI),
1414 + AR6K_DATA_PKT_TAG);
1415 + HTCFlushEndpoint(ar->arHtcTarget,
1416 + arWMIStream2EndpointID(ar,WMI_HIGHEST_PRI),
1417 + AR6K_DATA_PKT_TAG);
1420 +/* This function does one time initialization for the lifetime of the device */
1421 +int ar6000_init(struct net_device *dev)
1427 + if((ar = netdev_priv(dev)) == NULL)
1432 + /* Do we need to finish the BMI phase */
1433 + if(BMIDone(ar->arHifDevice) != A_OK)
1441 + if (ar->arVersion.host_ver != ar->arVersion.target_ver) {
1442 + A_PRINTF("WARNING: Host version 0x%x does not match Target "
1443 + " version 0x%x!\n",
1444 + ar->arVersion.host_ver, ar->arVersion.target_ver);
1448 + /* Indicate that WMI is enabled (although not ready yet) */
1449 + ar->arWmiEnabled = TRUE;
1450 + if ((ar->arWmi = wmi_init((void *) ar)) == NULL)
1452 + AR_DEBUG_PRINTF("%s() Failed to initialize WMI.\n", __func__);
1456 + AR_DEBUG_PRINTF("%s() Got WMI @ 0x%08x.\n", __func__,
1457 + (unsigned int) ar->arWmi);
1461 + HTC_SERVICE_CONNECT_REQ connect;
1463 + /* the reason we have to wait for the target here is that the driver layer
1464 + * has to init BMI in order to set the host block size,
1466 + status = HTCWaitTarget(ar->arHtcTarget);
1468 + if (A_FAILED(status)) {
1472 + A_MEMZERO(&connect,sizeof(connect));
1473 + /* meta data is unused for now */
1474 + connect.pMetaData = NULL;
1475 + connect.MetaDataLength = 0;
1476 + /* these fields are the same for all service endpoints */
1477 + connect.EpCallbacks.pContext = ar;
1478 + connect.EpCallbacks.EpTxComplete = ar6000_tx_complete;
1479 + connect.EpCallbacks.EpRecv = ar6000_rx;
1480 + connect.EpCallbacks.EpRecvRefill = ar6000_rx_refill;
1481 + connect.EpCallbacks.EpSendFull = ar6000_tx_queue_full;
1482 + /* set the max queue depth so that our ar6000_tx_queue_full handler gets called.
1483 + * Linux has the peculiarity of not providing flow control between the
1484 + * NIC and the network stack. There is no API to indicate that a TX packet
1485 + * was sent which could provide some back pressure to the network stack.
1486 + * Under linux you would have to wait till the network stack consumed all sk_buffs
1487 + * before any back-flow kicked in. Which isn't very friendly.
1488 + * So we have to manage this ourselves */
1489 + connect.MaxSendQueueDepth = 32;
1491 + /* connect to control service */
1492 + connect.ServiceID = WMI_CONTROL_SVC;
1493 + status = ar6000_connectservice(ar,
1497 + if (A_FAILED(status)) {
1501 + /* for the remaining data services set the connection flag to reduce dribbling,
1502 + * if configured to do so */
1503 + if (reduce_credit_dribble) {
1504 + connect.ConnectionFlags |= HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE;
1505 + /* the credit dribble trigger threshold is (reduce_credit_dribble - 1) for a value
1507 + connect.ConnectionFlags &= ~HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK;
1508 + connect.ConnectionFlags |=
1509 + ((A_UINT16)reduce_credit_dribble - 1) & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK;
1511 + /* connect to best-effort service */
1512 + connect.ServiceID = WMI_DATA_BE_SVC;
1514 + status = ar6000_connectservice(ar,
1516 + WMI_BEST_EFFORT_PRI,
1518 + if (A_FAILED(status)) {
1522 + /* connect to back-ground
1523 + * map this to WMI LOW_PRI */
1524 + connect.ServiceID = WMI_DATA_BK_SVC;
1525 + status = ar6000_connectservice(ar,
1529 + if (A_FAILED(status)) {
1533 + /* connect to Video service, map this to
1535 + connect.ServiceID = WMI_DATA_VI_SVC;
1536 + status = ar6000_connectservice(ar,
1540 + if (A_FAILED(status)) {
1544 + /* connect to VO service, this is currently not
1545 + * mapped to a WMI priority stream due to historical reasons.
1546 + * WMI originally defined 3 priorities over 3 mailboxes
1547 + * We can change this when WMI is reworked so that priorities are not
1548 + * dependent on mailboxes */
1549 + connect.ServiceID = WMI_DATA_VO_SVC;
1550 + status = ar6000_connectservice(ar,
1554 + if (A_FAILED(status)) {
1558 + A_ASSERT(arWMIStream2EndpointID(ar,WMI_CONTROL_PRI) != 0);
1559 + A_ASSERT(arWMIStream2EndpointID(ar,WMI_BEST_EFFORT_PRI) != 0);
1560 + A_ASSERT(arWMIStream2EndpointID(ar,WMI_LOW_PRI) != 0);
1561 + A_ASSERT(arWMIStream2EndpointID(ar,WMI_HIGH_PRI) != 0);
1562 + A_ASSERT(arWMIStream2EndpointID(ar,WMI_HIGHEST_PRI) != 0);
1565 + if (A_FAILED(status)) {
1570 + * give our connected endpoints some buffers
1572 + ar6000_rx_refill(ar, arWMIStream2EndpointID(ar,WMI_CONTROL_PRI));
1574 + ar6000_rx_refill(ar, arWMIStream2EndpointID(ar,WMI_BEST_EFFORT_PRI));
1577 + * We will post the receive buffers only for SPE testing and so we are
1578 + * making it conditional on the 'bypasswmi' flag.
1581 + ar6000_rx_refill(ar,arWMIStream2EndpointID(ar,WMI_LOW_PRI));
1582 + ar6000_rx_refill(ar,arWMIStream2EndpointID(ar,WMI_HIGH_PRI));
1585 + /* setup credit distribution */
1586 + ar6000_setup_credit_dist(ar->arHtcTarget, &ar->arCreditStateInfo);
1588 + /* Since cookies are used for HTC transports, they should be */
1589 + /* initialized prior to enabling HTC. */
1590 + ar6000_cookie_init(ar);
1593 + status = HTCStart(ar->arHtcTarget);
1595 + if (status != A_OK) {
1596 + if (ar->arWmiEnabled == TRUE) {
1597 + wmi_shutdown(ar->arWmi);
1598 + ar->arWmiEnabled = FALSE;
1601 + ar6000_cookie_cleanup(ar);
1606 + /* Wait for Wmi event to be ready */
1607 + timeleft = wait_event_interruptible_timeout(arEvent,
1608 + (ar->arWmiReady == TRUE), wmitimeout * HZ);
1610 + if(!timeleft || signal_pending(current))
1612 + AR_DEBUG_PRINTF("WMI is not ready or wait was interrupted\n");
1613 +#if defined(DWSIM) /* TBDXXX */
1614 + AR_DEBUG_PRINTF(".....but proceed anyway.\n");
1620 + AR_DEBUG_PRINTF("%s() WMI is ready\n", __func__);
1622 + /* Communicate the wmi protocol verision to the target */
1623 + if ((ar6000_set_host_app_area(ar)) != A_OK) {
1624 + AR_DEBUG_PRINTF("Unable to set the host app area\n");
1628 + ar->arNumDataEndPts = 1;
1635 +ar6000_bitrate_rx(void *devt, A_INT32 rateKbps)
1637 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
1639 + ar->arBitRate = rateKbps;
1640 + wake_up(&arEvent);
1644 +ar6000_ratemask_rx(void *devt, A_UINT16 ratemask)
1646 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
1648 + ar->arRateMask = ratemask;
1649 + wake_up(&arEvent);
1653 +ar6000_txPwr_rx(void *devt, A_UINT8 txPwr)
1655 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
1657 + ar->arTxPwr = txPwr;
1658 + wake_up(&arEvent);
1663 +ar6000_channelList_rx(void *devt, A_INT8 numChan, A_UINT16 *chanList)
1665 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
1667 + A_MEMCPY(ar->arChannelList, chanList, numChan * sizeof (A_UINT16));
1668 + ar->arNumChannels = numChan;
1670 + wake_up(&arEvent);
1674 +ar6000_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, A_UINT32 * mapNo)
1676 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
1678 + ATH_MAC_HDR *macHdr;
1679 + A_UINT32 i, eptMap;
1682 + datap = A_NETBUF_DATA(skb);
1683 + macHdr = (ATH_MAC_HDR *)(datap + sizeof(WMI_DATA_HDR));
1684 + if (IEEE80211_IS_MULTICAST(macHdr->dstMac)) {
1685 + return ENDPOINT_2;
1689 + for (i = 0; i < ar->arNodeNum; i ++) {
1690 + if (IEEE80211_ADDR_EQ(macHdr->dstMac, ar->arNodeMap[i].macAddress)) {
1692 + ar->arNodeMap[i].txPending ++;
1693 + return ar->arNodeMap[i].epId;
1696 + if ((eptMap == -1) && !ar->arNodeMap[i].txPending) {
1701 + if (eptMap == -1) {
1702 + eptMap = ar->arNodeNum;
1704 + A_ASSERT(ar->arNodeNum <= MAX_NODE_NUM);
1707 + A_MEMCPY(ar->arNodeMap[eptMap].macAddress, macHdr->dstMac, IEEE80211_ADDR_LEN);
1709 + for (i = ENDPOINT_2; i <= ENDPOINT_5; i ++) {
1710 + if (!ar->arTxPending[i]) {
1711 + ar->arNodeMap[eptMap].epId = i;
1714 + // No free endpoint is available, start redistribution on the inuse endpoints.
1715 + if (i == ENDPOINT_5) {
1716 + ar->arNodeMap[eptMap].epId = ar->arNexEpId;
1718 + if (ar->arNexEpId > ENDPOINT_5) {
1719 + ar->arNexEpId = ENDPOINT_2;
1724 + (*mapNo) = eptMap + 1;
1725 + ar->arNodeMap[eptMap].txPending ++;
1727 + return ar->arNodeMap[eptMap].epId;
1731 +static void ar6000_dump_skb(struct sk_buff *skb)
1734 + for (ch = A_NETBUF_DATA(skb);
1735 + (A_UINT32)ch < ((A_UINT32)A_NETBUF_DATA(skb) +
1736 + A_NETBUF_LEN(skb)); ch++)
1738 + AR_DEBUG_PRINTF("%2.2x ", *ch);
1740 + AR_DEBUG_PRINTF("\n");
1745 +ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
1747 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
1748 + WMI_PRI_STREAM_ID streamID = WMI_NOT_MAPPED;
1749 + A_UINT32 mapNo = 0;
1751 + struct ar_cookie *cookie;
1752 + A_BOOL checkAdHocPsMapping = FALSE;
1754 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)
1758 + AR_DEBUG2_PRINTF("ar6000_data_tx start - skb=0x%x, data=0x%x, len=0x%x\n",
1759 + (A_UINT32)skb, (A_UINT32)A_NETBUF_DATA(skb),
1760 + A_NETBUF_LEN(skb));
1761 +#ifdef CONFIG_HOST_TCMD_SUPPORT
1762 + /* TCMD doesnt support any data, free the buf and return */
1763 + if(ar->arTargetMode == AR6000_TCMD_MODE) {
1764 + A_NETBUF_FREE(skb);
1770 + if (ar->arWmiReady == FALSE && bypasswmi == 0) {
1774 +#ifdef BLOCK_TX_PATH_FLAG
1778 +#endif /* BLOCK_TX_PATH_FLAG */
1780 + if (ar->arWmiEnabled) {
1781 + if (A_NETBUF_HEADROOM(skb) < dev->hard_header_len) {
1782 + struct sk_buff *newbuf;
1784 + * We really should have gotten enough headroom but sometimes
1785 + * we still get packets with not enough headroom. Copy the packet.
1787 + len = A_NETBUF_LEN(skb);
1788 + newbuf = A_NETBUF_ALLOC(len);
1789 + if (newbuf == NULL) {
1792 + A_NETBUF_PUT(newbuf, len);
1793 + A_MEMCPY(A_NETBUF_DATA(newbuf), A_NETBUF_DATA(skb), len);
1794 + A_NETBUF_FREE(skb);
1796 + /* fall through and assemble header */
1799 + if (wmi_dix_2_dot3(ar->arWmi, skb) != A_OK) {
1800 + AR_DEBUG_PRINTF("ar6000_data_tx - wmi_dix_2_dot3 failed\n");
1804 + if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE) != A_OK) {
1805 + AR_DEBUG_PRINTF("ar6000_data_tx - wmi_data_hdr_add failed\n");
1809 + if ((ar->arNetworkType == ADHOC_NETWORK) &&
1810 + ar->arIbssPsEnable && ar->arConnected) {
1811 + /* flag to check adhoc mapping once we take the lock below: */
1812 + checkAdHocPsMapping = TRUE;
1815 + /* get the stream mapping */
1816 + if (ar->arWmmEnabled) {
1817 + streamID = wmi_get_stream_id(ar->arWmi,
1818 + wmi_implicit_create_pstream(ar->arWmi, skb, UPLINK_TRAFFIC, UNDEFINED_PRI));
1820 + streamID = WMI_BEST_EFFORT_PRI;
1825 + struct iphdr *ipHdr;
1827 + * the endpoint is directly based on the TOS field in the IP
1828 + * header **** only for testing ******
1830 + ipHdr = A_NETBUF_DATA(skb) + sizeof(ATH_MAC_HDR);
1831 + /* here we map the TOS field to an endpoint number, this is for
1832 + * the endpointping test application */
1833 + streamID = IP_TOS_TO_WMI_PRI(ipHdr->tos);
1838 + /* did we succeed ? */
1839 + if ((streamID == WMI_NOT_MAPPED) && !checkAdHocPsMapping) {
1840 + /* cleanup and exit */
1841 + A_NETBUF_FREE(skb);
1842 + AR6000_STAT_INC(ar, tx_dropped);
1843 + AR6000_STAT_INC(ar, tx_aborted_errors);
1849 + /* take the lock to protect driver data */
1850 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1854 + if (checkAdHocPsMapping) {
1855 + streamID = ar6000_ibss_map_epid(skb, dev, &mapNo);
1858 + A_ASSERT(streamID != WMI_NOT_MAPPED);
1860 + /* validate that the endpoint is connected */
1861 + if (arWMIStream2EndpointID(ar,streamID) == 0) {
1862 + AR_DEBUG_PRINTF("Stream %d is NOT mapped!\n",streamID);
1865 + /* allocate resource for this packet */
1866 + cookie = ar6000_alloc_cookie(ar);
1868 + if (cookie != NULL) {
1869 + /* update counts while the lock is held */
1870 + ar->arTxPending[streamID]++;
1871 + ar->arTotalTxDataPending++;
1876 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1878 + if (cookie != NULL) {
1879 + cookie->arc_bp[0] = (A_UINT32)skb;
1880 + cookie->arc_bp[1] = mapNo;
1881 + SET_HTC_PACKET_INFO_TX(&cookie->HtcPkt,
1883 + A_NETBUF_DATA(skb),
1884 + A_NETBUF_LEN(skb),
1885 + arWMIStream2EndpointID(ar,streamID),
1886 + AR6K_DATA_PKT_TAG);
1889 + if (debugdriver >= 3) {
1890 + ar6000_dump_skb(skb);
1893 + /* HTC interface is asynchronous, if this fails, cleanup will happen in
1894 + * the ar6000_tx_complete callback */
1895 + HTCSendPkt(ar->arHtcTarget, &cookie->HtcPkt);
1897 + /* no packet to send, cleanup */
1898 + A_NETBUF_FREE(skb);
1899 + AR6000_STAT_INC(ar, tx_dropped);
1900 + AR6000_STAT_INC(ar, tx_aborted_errors);
1906 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
1908 +tvsub(register struct timeval *out, register struct timeval *in)
1910 + if((out->tv_usec -= in->tv_usec) < 0) {
1912 + out->tv_usec += 1000000;
1914 + out->tv_sec -= in->tv_sec;
1918 +applyAPTCHeuristics(AR_SOFTC_T *ar)
1920 + A_UINT32 duration;
1921 + A_UINT32 numbytes;
1922 + A_UINT32 throughput;
1923 + struct timeval ts;
1926 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1928 + if ((enableAPTCHeuristics) && (!aptcTR.timerScheduled)) {
1929 + do_gettimeofday(&ts);
1930 + tvsub(&ts, &aptcTR.samplingTS);
1931 + duration = ts.tv_sec * 1000 + ts.tv_usec / 1000; /* ms */
1932 + numbytes = aptcTR.bytesTransmitted + aptcTR.bytesReceived;
1934 + if (duration > APTC_TRAFFIC_SAMPLING_INTERVAL) {
1935 + /* Initialize the time stamp and byte count */
1936 + aptcTR.bytesTransmitted = aptcTR.bytesReceived = 0;
1937 + do_gettimeofday(&aptcTR.samplingTS);
1939 + /* Calculate and decide based on throughput thresholds */
1940 + throughput = ((numbytes * 8) / duration);
1941 + if (throughput > APTC_UPPER_THROUGHPUT_THRESHOLD) {
1942 + /* Disable Sleep and schedule a timer */
1943 + A_ASSERT(ar->arWmiReady == TRUE);
1944 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1945 + status = wmi_powermode_cmd(ar->arWmi, MAX_PERF_POWER);
1946 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1947 + A_TIMEOUT_MS(&aptcTimer, APTC_TRAFFIC_SAMPLING_INTERVAL, 0);
1948 + aptcTR.timerScheduled = TRUE;
1953 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1955 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
1957 +static void ar6000_tx_queue_full(void *Context, HTC_ENDPOINT_ID Endpoint)
1959 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
1962 + if (Endpoint == arWMIStream2EndpointID(ar,WMI_CONTROL_PRI)) {
1964 + /* under normal WMI if this is getting full, then something is running rampant
1965 + * the host should not be exhausting the WMI queue with too many commands
1966 + * the only exception to this is during testing using endpointping */
1968 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1969 + /* set flag to handle subsequent messages */
1970 + ar->arWMIControlEpFull = TRUE;
1971 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1972 + AR_DEBUG_PRINTF("WMI Control Endpoint is FULL!!! \n");
1976 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1977 + ar->arNetQueueStopped = TRUE;
1978 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1979 + /* one of the data endpoints queues is getting full..need to stop network stack
1980 + * the queue will resume in ar6000_tx_complete() */
1981 + netif_stop_queue(ar->arNetDev);
1989 +ar6000_tx_complete(void *Context, HTC_PACKET *pPacket)
1991 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
1992 + void *cookie = (void *)pPacket->pPktContext;
1993 + struct sk_buff *skb = NULL;
1994 + A_UINT32 mapNo = 0;
1996 + struct ar_cookie * ar_cookie;
1997 + WMI_PRI_STREAM_ID streamID;
1998 + A_BOOL wakeEvent = FALSE;
2000 + status = pPacket->Status;
2001 + ar_cookie = (struct ar_cookie *)cookie;
2002 + skb = (struct sk_buff *)ar_cookie->arc_bp[0];
2003 + streamID = arEndpoint2WMIStreamID(ar,pPacket->Endpoint);
2004 + mapNo = ar_cookie->arc_bp[1];
2007 + A_ASSERT(pPacket->pBuffer == A_NETBUF_DATA(skb));
2009 + if (A_SUCCESS(status)) {
2010 + A_ASSERT(pPacket->ActualLength == A_NETBUF_LEN(skb));
2013 + AR_DEBUG2_PRINTF("ar6000_tx_complete skb=0x%x data=0x%x len=0x%x sid=%d ",
2014 + (A_UINT32)skb, (A_UINT32)pPacket->pBuffer,
2015 + pPacket->ActualLength,
2018 + /* lock the driver as we update internal state */
2019 + AR6000_SPIN_LOCK(&ar->arLock, 0);
2021 + ar->arTxPending[streamID]--;
2023 + if ((streamID != WMI_CONTROL_PRI) || bypasswmi) {
2024 + ar->arTotalTxDataPending--;
2027 + if (streamID == WMI_CONTROL_PRI)
2029 + if (ar->arWMIControlEpFull) {
2030 + /* since this packet completed, the WMI EP is no longer full */
2031 + ar->arWMIControlEpFull = FALSE;
2034 + if (ar->arTxPending[streamID] == 0) {
2039 + if (A_FAILED(status)) {
2040 + AR_DEBUG_PRINTF("%s() -TX ERROR, status: 0x%x\n", __func__,
2042 + AR6000_STAT_INC(ar, tx_errors);
2044 + AR_DEBUG2_PRINTF("OK\n");
2045 + AR6000_STAT_INC(ar, tx_packets);
2046 + ar->arNetStats.tx_bytes += A_NETBUF_LEN(skb);
2047 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
2048 + aptcTR.bytesTransmitted += a_netbuf_to_len(skb);
2049 + applyAPTCHeuristics(ar);
2050 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
2053 + // TODO this needs to be looked at
2054 + if ((ar->arNetworkType == ADHOC_NETWORK) && ar->arIbssPsEnable
2055 + && (streamID != WMI_CONTROL_PRI) && mapNo)
2058 + ar->arNodeMap[mapNo].txPending --;
2060 + if (!ar->arNodeMap[mapNo].txPending && (mapNo == (ar->arNodeNum - 1))) {
2062 + for (i = ar->arNodeNum; i > 0; i --) {
2063 + if (!ar->arNodeMap[i - 1].txPending) {
2064 + A_MEMZERO(&ar->arNodeMap[i - 1], sizeof(struct ar_node_mapping));
2073 + /* Freeing a cookie should not be contingent on either of */
2074 + /* these flags, just if we have a cookie or not. */
2075 + /* Can we even get here without a cookie? Fix later. */
2076 + if (ar->arWmiReady == TRUE || (bypasswmi))
2078 + ar6000_free_cookie(ar, cookie);
2081 + if (ar->arNetQueueStopped) {
2082 + ar->arNetQueueStopped = FALSE;
2085 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2087 + /* lock is released, we can freely call other kernel APIs */
2089 + /* this indirectly frees the HTC_PACKET */
2090 + A_NETBUF_FREE(skb);
2092 + if ((ar->arConnected == TRUE) || (bypasswmi)) {
2093 + if (status != A_ECANCELED) {
2094 + /* don't wake the queue if we are flushing, other wise it will just
2095 + * keep queueing packets, which will keep failing */
2096 + netif_wake_queue(ar->arNetDev);
2101 + wake_up(&arEvent);
2107 + * Receive event handler. This is called by HTC when a packet is received
2111 +ar6000_rx(void *Context, HTC_PACKET *pPacket)
2113 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
2114 + struct sk_buff *skb = (struct sk_buff *)pPacket->pPktContext;
2116 + A_STATUS status = pPacket->Status;
2117 + WMI_PRI_STREAM_ID streamID = arEndpoint2WMIStreamID(ar,pPacket->Endpoint);
2118 + HTC_ENDPOINT_ID ept = pPacket->Endpoint;
2120 + A_ASSERT((status != A_OK) || (pPacket->pBuffer == (A_NETBUF_DATA(skb) + HTC_HEADER_LEN)));
2122 + AR_DEBUG2_PRINTF("ar6000_rx ar=0x%x sid=%d, skb=0x%x, data=0x%x, len=0x%x ",
2123 + (A_UINT32)ar, streamID, (A_UINT32)skb, (A_UINT32)pPacket->pBuffer,
2124 + pPacket->ActualLength);
2125 + if (status != A_OK) {
2126 + AR_DEBUG2_PRINTF("ERR\n");
2128 + AR_DEBUG2_PRINTF("OK\n");
2131 + /* take lock to protect buffer counts
2132 + * and adaptive power throughput state */
2133 + AR6000_SPIN_LOCK(&ar->arLock, 0);
2135 + ar->arRxBuffers[streamID]--;
2137 + if (A_SUCCESS(status)) {
2138 + AR6000_STAT_INC(ar, rx_packets);
2139 + ar->arNetStats.rx_bytes += pPacket->ActualLength;
2140 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
2141 + aptcTR.bytesReceived += a_netbuf_to_len(skb);
2142 + applyAPTCHeuristics(ar);
2143 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
2145 + A_NETBUF_PUT(skb, pPacket->ActualLength + HTC_HEADER_LEN);
2146 + A_NETBUF_PULL(skb, HTC_HEADER_LEN);
2149 + if (debugdriver >= 2) {
2150 + ar6000_dump_skb(skb);
2155 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2157 + if (status != A_OK) {
2158 + AR6000_STAT_INC(ar, rx_errors);
2159 + A_NETBUF_FREE(skb);
2160 + } else if (ar->arWmiEnabled == TRUE) {
2161 + if (streamID == WMI_CONTROL_PRI) {
2163 + * this is a wmi control msg
2165 + wmi_control_rx(ar->arWmi, skb);
2167 + WMI_DATA_HDR *dhdr = (WMI_DATA_HDR *)A_NETBUF_DATA(skb);
2168 + if (WMI_DATA_HDR_IS_MSG_TYPE(dhdr, CNTL_MSGTYPE)) {
2170 + * this is a wmi control msg
2172 + /* strip off WMI hdr */
2173 + wmi_data_hdr_remove(ar->arWmi, skb);
2174 + wmi_control_rx(ar->arWmi, skb);
2177 + * this is a wmi data packet
2179 + minHdrLen = sizeof (WMI_DATA_HDR) + sizeof(ATH_MAC_HDR) +
2180 + sizeof(ATH_LLC_SNAP_HDR);
2182 + if ((pPacket->ActualLength < minHdrLen) ||
2183 + (pPacket->ActualLength > AR6000_BUFFER_SIZE))
2186 + * packet is too short or too long
2188 + AR_DEBUG_PRINTF("TOO SHORT or TOO LONG\n");
2189 + AR6000_STAT_INC(ar, rx_errors);
2190 + AR6000_STAT_INC(ar, rx_length_errors);
2191 + A_NETBUF_FREE(skb);
2193 + if (ar->arWmmEnabled) {
2194 + wmi_implicit_create_pstream(ar->arWmi, skb,
2195 + DNLINK_TRAFFIC, UNDEFINED_PRI);
2198 + /* Access RSSI values here */
2199 + AR_DEBUG_PRINTF("RSSI %d\n",
2200 + ((WMI_DATA_HDR *) A_NETBUF_DATA(skb))->rssi);
2202 + wmi_data_hdr_remove(ar->arWmi, skb);
2203 + wmi_dot3_2_dix(ar->arWmi, skb);
2205 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
2207 + * extra push and memcpy, for eth_type_trans() of 2.4 kernel
2208 + * will pull out hard_header_len bytes of the skb.
2210 + A_NETBUF_PUSH(skb, sizeof(WMI_DATA_HDR) + sizeof(ATH_LLC_SNAP_HDR) + HTC_HEADER_LEN);
2211 + A_MEMCPY(A_NETBUF_DATA(skb), A_NETBUF_DATA(skb) + sizeof(WMI_DATA_HDR) +
2212 + sizeof(ATH_LLC_SNAP_HDR) + HTC_HEADER_LEN, sizeof(ATH_MAC_HDR));
2214 + if ((ar->arNetDev->flags & IFF_UP) == IFF_UP)
2216 + skb->dev = ar->arNetDev;
2217 + skb->protocol = eth_type_trans(skb, ar->arNetDev);
2222 + A_NETBUF_FREE(skb);
2228 + if ((ar->arNetDev->flags & IFF_UP) == IFF_UP)
2230 + skb->dev = ar->arNetDev;
2231 + skb->protocol = eth_type_trans(skb, ar->arNetDev);
2236 + A_NETBUF_FREE(skb);
2240 + if (status != A_ECANCELED) {
2242 + * HTC provides A_ECANCELED status when it doesn't want to be refilled
2243 + * (probably due to a shutdown)
2245 + ar6000_rx_refill(Context, ept);
2252 +ar6000_rx_refill(void *Context, HTC_ENDPOINT_ID Endpoint)
2254 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
2257 + int buffersToRefill;
2258 + HTC_PACKET *pPacket;
2259 + WMI_PRI_STREAM_ID streamId = arEndpoint2WMIStreamID(ar,Endpoint);
2261 + buffersToRefill = (int)AR6000_MAX_RX_BUFFERS -
2262 + (int)ar->arRxBuffers[streamId];
2264 + if (buffersToRefill <= 0) {
2265 + /* fast return, nothing to fill */
2269 + AR_DEBUG2_PRINTF("ar6000_rx_refill: providing htc with %d buffers at eid=%d\n",
2270 + buffersToRefill, Endpoint);
2272 + for (RxBuffers = 0; RxBuffers < buffersToRefill; RxBuffers++) {
2273 + osBuf = A_NETBUF_ALLOC(AR6000_BUFFER_SIZE);
2274 + if (NULL == osBuf) {
2277 + /* the HTC packet wrapper is at the head of the reserved area
2279 + pPacket = (HTC_PACKET *)(A_NETBUF_HEAD(osBuf));
2280 + /* set re-fill info */
2281 + SET_HTC_PACKET_INFO_RX_REFILL(pPacket,osBuf,A_NETBUF_DATA(osBuf),AR6000_BUFFER_SIZE,Endpoint);
2282 + /* add this packet */
2283 + HTCAddReceivePkt(ar->arHtcTarget, pPacket);
2286 + /* update count */
2287 + AR6000_SPIN_LOCK(&ar->arLock, 0);
2288 + ar->arRxBuffers[streamId] += RxBuffers;
2289 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2292 +static struct net_device_stats *
2293 +ar6000_get_stats(struct net_device *dev)
2295 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
2296 + return &ar->arNetStats;
2299 +static struct iw_statistics *
2300 +ar6000_get_iwstats(struct net_device * dev)
2302 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
2303 + TARGET_STATS *pStats = &ar->arTargetStats;
2304 + struct iw_statistics * pIwStats = &ar->arIwStats;
2306 + if ((ar->arWmiReady == FALSE)
2308 + * The in_atomic function is used to determine if the scheduling is
2309 + * allowed in the current context or not. This was introduced in 2.6
2310 + * From what I have read on the differences between 2.4 and 2.6, the
2311 + * 2.4 kernel did not support preemption and so this check might not
2312 + * be required for 2.4 kernels.
2314 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
2319 + pIwStats->status = 0;
2320 + pIwStats->qual.qual = 0;
2321 + pIwStats->qual.level =0;
2322 + pIwStats->qual.noise = 0;
2323 + pIwStats->discard.code =0;
2324 + pIwStats->discard.retries=0;
2325 + pIwStats->miss.beacon =0;
2328 + if (down_interruptible(&ar->arSem)) {
2329 + pIwStats->status = 0;
2334 + ar->statsUpdatePending = TRUE;
2336 + if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
2338 + pIwStats->status = 0;
2342 + wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
2344 + if (signal_pending(current)) {
2345 + AR_DEBUG_PRINTF("ar6000 : WMI get stats timeout \n");
2347 + pIwStats->status = 0;
2350 + pIwStats->status = 1 ;
2351 + pIwStats->qual.qual = pStats->cs_aveBeacon_rssi;
2352 + pIwStats->qual.level =pStats->cs_aveBeacon_rssi + 161; /* noise is -95 dBm */
2353 + pIwStats->qual.noise = pStats->noise_floor_calibation;
2354 + pIwStats->discard.code = pStats->rx_decrypt_err;
2355 + pIwStats->discard.retries = pStats->tx_retry_cnt;
2356 + pIwStats->miss.beacon = pStats->cs_bmiss_cnt;
2362 +ar6000_ready_event(void *devt, A_UINT8 *datap, A_UINT8 phyCap)
2364 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
2365 + struct net_device *dev = ar->arNetDev;
2367 + ar->arWmiReady = TRUE;
2368 + wake_up(&arEvent);
2369 + A_MEMCPY(dev->dev_addr, datap, AR6000_ETH_ADDR_LEN);
2370 + AR_DEBUG_PRINTF("mac address = %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
2371 + dev->dev_addr[0], dev->dev_addr[1],
2372 + dev->dev_addr[2], dev->dev_addr[3],
2373 + dev->dev_addr[4], dev->dev_addr[5]);
2375 + ar->arPhyCapability = phyCap;
2379 +ar6000_iptos_to_userPriority(A_UINT8 *pkt)
2381 + struct iphdr *ipHdr = (struct iphdr *)pkt;
2382 + A_UINT8 userPriority;
2386 + * (Refer Pg 57 WMM-test-plan-v1.2)
2388 + * : DSCP(6-bits) ECN(2-bits)
2389 + * : DSCP - P2 P1 P0 X X X
2390 + * where (P2 P1 P0) form 802.1D
2392 + userPriority = ipHdr->tos >> 5;
2393 + return (userPriority & 0x7);
2397 +ar6000_connect_event(AR_SOFTC_T *ar, A_UINT16 channel, A_UINT8 *bssid,
2398 + A_UINT16 listenInterval, A_UINT16 beaconInterval,
2399 + NETWORK_TYPE networkType, A_UINT8 beaconIeLen,
2400 + A_UINT8 assocReqLen, A_UINT8 assocRespLen,
2401 + A_UINT8 *assocInfo)
2403 + union iwreq_data wrqu;
2404 + int i, beacon_ie_pos, assoc_resp_ie_pos, assoc_req_ie_pos;
2405 + static const char *tag1 = "ASSOCINFO(ReqIEs=";
2406 + static const char *tag2 = "ASSOCRESPIE=";
2407 + static const char *beaconIetag = "BEACONIE=";
2408 + char buf[WMI_CONTROL_MSG_MAX_LEN * 2 + sizeof(tag1)];
2410 + A_UINT8 key_op_ctrl;
2412 + A_MEMCPY(ar->arBssid, bssid, sizeof(ar->arBssid));
2413 + ar->arBssChannel = channel;
2415 + A_PRINTF("AR6000 connected event on freq %d ", channel);
2416 + A_PRINTF("with bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
2417 + " listenInterval=%d, beaconInterval = %d, beaconIeLen = %d assocReqLen=%d"
2418 + " assocRespLen =%d\n",
2419 + bssid[0], bssid[1], bssid[2],
2420 + bssid[3], bssid[4], bssid[5],
2421 + listenInterval, beaconInterval,
2422 + beaconIeLen, assocReqLen, assocRespLen);
2423 + if (networkType & ADHOC_NETWORK) {
2424 + if (networkType & ADHOC_CREATOR) {
2425 + A_PRINTF("Network: Adhoc (Creator)\n");
2427 + A_PRINTF("Network: Adhoc (Joiner)\n");
2430 + A_PRINTF("Network: Infrastructure\n");
2433 + if (beaconIeLen && (sizeof(buf) > (9 + beaconIeLen * 2))) {
2434 + AR_DEBUG_PRINTF("\nBeaconIEs= ");
2436 + beacon_ie_pos = 0;
2437 + A_MEMZERO(buf, sizeof(buf));
2438 + sprintf(buf, "%s", beaconIetag);
2440 + for (i = beacon_ie_pos; i < beacon_ie_pos + beaconIeLen; i++) {
2441 + AR_DEBUG_PRINTF("%2.2x ", assocInfo[i]);
2442 + sprintf(pos, "%2.2x", assocInfo[i]);
2445 + AR_DEBUG_PRINTF("\n");
2447 + A_MEMZERO(&wrqu, sizeof(wrqu));
2448 + wrqu.data.length = strlen(buf);
2449 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
2452 + if (assocRespLen && (sizeof(buf) > (12 + (assocRespLen * 2))))
2454 + assoc_resp_ie_pos = beaconIeLen + assocReqLen +
2455 + sizeof(A_UINT16) + /* capinfo*/
2456 + sizeof(A_UINT16) + /* status Code */
2457 + sizeof(A_UINT16) ; /* associd */
2458 + A_MEMZERO(buf, sizeof(buf));
2459 + sprintf(buf, "%s", tag2);
2461 + AR_DEBUG_PRINTF("\nAssocRespIEs= ");
2463 + * The Association Response Frame w.o. the WLAN header is delivered to
2464 + * the host, so skip over to the IEs
2466 + for (i = assoc_resp_ie_pos; i < assoc_resp_ie_pos + assocRespLen - 6; i++)
2468 + AR_DEBUG_PRINTF("%2.2x ", assocInfo[i]);
2469 + sprintf(pos, "%2.2x", assocInfo[i]);
2472 + AR_DEBUG_PRINTF("\n");
2474 + A_MEMZERO(&wrqu, sizeof(wrqu));
2475 + wrqu.data.length = strlen(buf);
2476 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
2479 + if (assocReqLen && (sizeof(buf) > (17 + (assocReqLen * 2)))) {
2481 + * assoc Request includes capability and listen interval. Skip these.
2483 + assoc_req_ie_pos = beaconIeLen +
2484 + sizeof(A_UINT16) + /* capinfo*/
2485 + sizeof(A_UINT16); /* listen interval */
2487 + A_MEMZERO(buf, sizeof(buf));
2488 + sprintf(buf, "%s", tag1);
2490 + AR_DEBUG_PRINTF("AssocReqIEs= ");
2491 + for (i = assoc_req_ie_pos; i < assoc_req_ie_pos + assocReqLen - 4; i++) {
2492 + AR_DEBUG_PRINTF("%2.2x ", assocInfo[i]);
2493 + sprintf(pos, "%2.2x", assocInfo[i]);
2496 + AR_DEBUG_PRINTF("\n");
2498 + A_MEMZERO(&wrqu, sizeof(wrqu));
2499 + wrqu.data.length = strlen(buf);
2500 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
2504 + if (ar->user_savedkeys_stat == USER_SAVEDKEYS_STAT_RUN &&
2505 + ar->user_saved_keys.keyOk == TRUE)
2508 + key_op_ctrl = KEY_OP_VALID_MASK & ~KEY_OP_INIT_TSC;
2509 + if (ar->user_key_ctrl & AR6000_USER_SETKEYS_RSC_UNCHANGED) {
2510 + key_op_ctrl &= ~KEY_OP_INIT_RSC;
2512 + key_op_ctrl |= KEY_OP_INIT_RSC;
2514 + ar6000_reinstall_keys(ar, key_op_ctrl);
2516 +#endif /* USER_KEYS */
2518 + /* flush data queues */
2519 + ar6000_TxDataCleanup(ar);
2521 + netif_wake_queue(ar->arNetDev);
2523 + if ((OPEN_AUTH == ar->arDot11AuthMode) &&
2524 + (NONE_AUTH == ar->arAuthMode) &&
2525 + (WEP_CRYPT == ar->arPairwiseCrypto))
2527 + if (!ar->arConnected) {
2528 + ar6000_install_static_wep_keys(ar);
2532 + ar->arConnected = TRUE;
2533 + ar->arConnectPending = FALSE;
2535 + reconnect_flag = 0;
2537 + A_MEMZERO(&wrqu, sizeof(wrqu));
2538 + A_MEMCPY(wrqu.addr.sa_data, bssid, IEEE80211_ADDR_LEN);
2539 + wrqu.addr.sa_family = ARPHRD_ETHER;
2540 + wireless_send_event(ar->arNetDev, SIOCGIWAP, &wrqu, NULL);
2541 + if ((ar->arNetworkType == ADHOC_NETWORK) && ar->arIbssPsEnable) {
2542 + A_MEMZERO(ar->arNodeMap, sizeof(ar->arNodeMap));
2543 + ar->arNodeNum = 0;
2544 + ar->arNexEpId = ENDPOINT_2;
2549 +void ar6000_set_numdataendpts(AR_SOFTC_T *ar, A_UINT32 num)
2551 + A_ASSERT(num <= (HTC_MAILBOX_NUM_MAX - 1));
2552 + ar->arNumDataEndPts = num;
2556 +ar6000_disconnect_event(AR_SOFTC_T *ar, A_UINT8 reason, A_UINT8 *bssid,
2557 + A_UINT8 assocRespLen, A_UINT8 *assocInfo, A_UINT16 protocolReasonStatus)
2561 + A_PRINTF("AR6000 disconnected");
2562 + if (bssid[0] || bssid[1] || bssid[2] || bssid[3] || bssid[4] || bssid[5]) {
2563 + A_PRINTF(" from %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",
2564 + bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);
2567 + AR_DEBUG_PRINTF("\nDisconnect Reason is %d", reason);
2568 + AR_DEBUG_PRINTF("\nProtocol Reason/Status Code is %d", protocolReasonStatus);
2569 + AR_DEBUG_PRINTF("\nAssocResp Frame = %s",
2570 + assocRespLen ? " " : "NULL");
2571 + for (i = 0; i < assocRespLen; i++) {
2572 + if (!(i % 0x10)) {
2573 + AR_DEBUG_PRINTF("\n");
2575 + AR_DEBUG_PRINTF("%2.2x ", assocInfo[i]);
2577 + AR_DEBUG_PRINTF("\n");
2579 + * If the event is due to disconnect cmd from the host, only they the target
2580 + * would stop trying to connect. Under any other condition, target would
2581 + * keep trying to connect.
2584 + if( reason == DISCONNECT_CMD)
2586 + ar->arConnectPending = FALSE;
2588 + ar->arConnectPending = TRUE;
2589 + if (((reason == ASSOC_FAILED) && (protocolReasonStatus == 0x11)) ||
2590 + ((reason == ASSOC_FAILED) && (protocolReasonStatus == 0x0) && (reconnect_flag == 1))) {
2591 + ar->arConnected = TRUE;
2595 + ar->arConnected = FALSE;
2597 + if( (reason != CSERV_DISCONNECT) || (reconnect_flag != 1) ) {
2598 + reconnect_flag = 0;
2602 + if (reason != CSERV_DISCONNECT)
2604 + ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
2605 + ar->user_key_ctrl = 0;
2607 +#endif /* USER_KEYS */
2609 + netif_stop_queue(ar->arNetDev);
2610 + A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));
2611 + ar->arBssChannel = 0;
2612 + ar->arBeaconInterval = 0;
2614 + ar6000_TxDataCleanup(ar);
2618 +ar6000_regDomain_event(AR_SOFTC_T *ar, A_UINT32 regCode)
2620 + A_PRINTF("AR6000 Reg Code = 0x%x\n", regCode);
2621 + ar->arRegCode = regCode;
2625 +ar6000_neighborReport_event(AR_SOFTC_T *ar, int numAps, WMI_NEIGHBOR_INFO *info)
2627 + static const char *tag = "PRE-AUTH";
2629 + union iwreq_data wrqu;
2632 + AR_DEBUG_PRINTF("AR6000 Neighbor Report Event\n");
2633 + for (i=0; i < numAps; info++, i++) {
2634 + AR_DEBUG_PRINTF("bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",
2635 + info->bssid[0], info->bssid[1], info->bssid[2],
2636 + info->bssid[3], info->bssid[4], info->bssid[5]);
2637 + if (info->bssFlags & WMI_PREAUTH_CAPABLE_BSS) {
2638 + AR_DEBUG_PRINTF("preauth-cap");
2640 + if (info->bssFlags & WMI_PMKID_VALID_BSS) {
2641 + AR_DEBUG_PRINTF(" pmkid-valid\n");
2642 + continue; /* we skip bss if the pmkid is already valid */
2644 + AR_DEBUG_PRINTF("\n");
2645 + snprintf(buf, sizeof(buf), "%s%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
2647 + info->bssid[0], info->bssid[1], info->bssid[2],
2648 + info->bssid[3], info->bssid[4], info->bssid[5],
2649 + i, info->bssFlags);
2650 + A_MEMZERO(&wrqu, sizeof(wrqu));
2651 + wrqu.data.length = strlen(buf);
2652 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
2657 +ar6000_tkip_micerr_event(AR_SOFTC_T *ar, A_UINT8 keyid, A_BOOL ismcast)
2659 + static const char *tag = "MLME-MICHAELMICFAILURE.indication";
2661 + union iwreq_data wrqu;
2663 + A_PRINTF("AR6000 TKIP MIC error received for keyid %d %scast\n",
2664 + keyid, ismcast ? "multi": "uni");
2665 + snprintf(buf, sizeof(buf), "%s(keyid=%d %scat)", tag, keyid,
2666 + ismcast ? "multi" : "uni");
2667 + memset(&wrqu, 0, sizeof(wrqu));
2668 + wrqu.data.length = strlen(buf);
2669 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
2673 +ar6000_scanComplete_event(AR_SOFTC_T *ar, A_STATUS status)
2675 + AR_DEBUG_PRINTF("AR6000 scan complete: %d\n", status);
2677 + ar->scan_complete = 1;
2678 + wake_up_interruptible(&ar6000_scan_queue);
2682 +ar6000_targetStats_event(AR_SOFTC_T *ar, WMI_TARGET_STATS *pTarget)
2684 + TARGET_STATS *pStats = &ar->arTargetStats;
2687 + A_PRINTF("AR6000 updating target stats\n");
2688 + pStats->tx_packets += pTarget->txrxStats.tx_stats.tx_packets;
2689 + pStats->tx_bytes += pTarget->txrxStats.tx_stats.tx_bytes;
2690 + pStats->tx_unicast_pkts += pTarget->txrxStats.tx_stats.tx_unicast_pkts;
2691 + pStats->tx_unicast_bytes += pTarget->txrxStats.tx_stats.tx_unicast_bytes;
2692 + pStats->tx_multicast_pkts += pTarget->txrxStats.tx_stats.tx_multicast_pkts;
2693 + pStats->tx_multicast_bytes += pTarget->txrxStats.tx_stats.tx_multicast_bytes;
2694 + pStats->tx_broadcast_pkts += pTarget->txrxStats.tx_stats.tx_broadcast_pkts;
2695 + pStats->tx_broadcast_bytes += pTarget->txrxStats.tx_stats.tx_broadcast_bytes;
2696 + pStats->tx_rts_success_cnt += pTarget->txrxStats.tx_stats.tx_rts_success_cnt;
2697 + for(ac = 0; ac < WMM_NUM_AC; ac++)
2698 + pStats->tx_packet_per_ac[ac] += pTarget->txrxStats.tx_stats.tx_packet_per_ac[ac];
2699 + pStats->tx_errors += pTarget->txrxStats.tx_stats.tx_errors;
2700 + pStats->tx_failed_cnt += pTarget->txrxStats.tx_stats.tx_failed_cnt;
2701 + pStats->tx_retry_cnt += pTarget->txrxStats.tx_stats.tx_retry_cnt;
2702 + pStats->tx_rts_fail_cnt += pTarget->txrxStats.tx_stats.tx_rts_fail_cnt;
2703 + pStats->tx_unicast_rate = wmi_get_rate(pTarget->txrxStats.tx_stats.tx_unicast_rate);
2705 + pStats->rx_packets += pTarget->txrxStats.rx_stats.rx_packets;
2706 + pStats->rx_bytes += pTarget->txrxStats.rx_stats.rx_bytes;
2707 + pStats->rx_unicast_pkts += pTarget->txrxStats.rx_stats.rx_unicast_pkts;
2708 + pStats->rx_unicast_bytes += pTarget->txrxStats.rx_stats.rx_unicast_bytes;
2709 + pStats->rx_multicast_pkts += pTarget->txrxStats.rx_stats.rx_multicast_pkts;
2710 + pStats->rx_multicast_bytes += pTarget->txrxStats.rx_stats.rx_multicast_bytes;
2711 + pStats->rx_broadcast_pkts += pTarget->txrxStats.rx_stats.rx_broadcast_pkts;
2712 + pStats->rx_broadcast_bytes += pTarget->txrxStats.rx_stats.rx_broadcast_bytes;
2713 + pStats->rx_fragment_pkt += pTarget->txrxStats.rx_stats.rx_fragment_pkt;
2714 + pStats->rx_errors += pTarget->txrxStats.rx_stats.rx_errors;
2715 + pStats->rx_crcerr += pTarget->txrxStats.rx_stats.rx_crcerr;
2716 + pStats->rx_key_cache_miss += pTarget->txrxStats.rx_stats.rx_key_cache_miss;
2717 + pStats->rx_decrypt_err += pTarget->txrxStats.rx_stats.rx_decrypt_err;
2718 + pStats->rx_duplicate_frames += pTarget->txrxStats.rx_stats.rx_duplicate_frames;
2719 + pStats->rx_unicast_rate = wmi_get_rate(pTarget->txrxStats.rx_stats.rx_unicast_rate);
2722 + pStats->tkip_local_mic_failure
2723 + += pTarget->txrxStats.tkipCcmpStats.tkip_local_mic_failure;
2724 + pStats->tkip_counter_measures_invoked
2725 + += pTarget->txrxStats.tkipCcmpStats.tkip_counter_measures_invoked;
2726 + pStats->tkip_replays += pTarget->txrxStats.tkipCcmpStats.tkip_replays;
2727 + pStats->tkip_format_errors += pTarget->txrxStats.tkipCcmpStats.tkip_format_errors;
2728 + pStats->ccmp_format_errors += pTarget->txrxStats.tkipCcmpStats.ccmp_format_errors;
2729 + pStats->ccmp_replays += pTarget->txrxStats.tkipCcmpStats.ccmp_replays;
2732 + pStats->power_save_failure_cnt += pTarget->pmStats.power_save_failure_cnt;
2733 + pStats->noise_floor_calibation = pTarget->noise_floor_calibation;
2735 + pStats->cs_bmiss_cnt += pTarget->cservStats.cs_bmiss_cnt;
2736 + pStats->cs_lowRssi_cnt += pTarget->cservStats.cs_lowRssi_cnt;
2737 + pStats->cs_connect_cnt += pTarget->cservStats.cs_connect_cnt;
2738 + pStats->cs_disconnect_cnt += pTarget->cservStats.cs_disconnect_cnt;
2739 + pStats->cs_aveBeacon_snr = pTarget->cservStats.cs_aveBeacon_snr;
2740 + pStats->cs_aveBeacon_rssi = pTarget->cservStats.cs_aveBeacon_rssi;
2741 + pStats->cs_lastRoam_msec = pTarget->cservStats.cs_lastRoam_msec;
2742 + pStats->cs_snr = pTarget->cservStats.cs_snr;
2743 + pStats->cs_rssi = pTarget->cservStats.cs_rssi;
2745 + pStats->lq_val = pTarget->lqVal;
2747 + pStats->wow_num_pkts_dropped += pTarget->wowStats.wow_num_pkts_dropped;
2748 + pStats->wow_num_host_pkt_wakeups += pTarget->wowStats.wow_num_host_pkt_wakeups;
2749 + pStats->wow_num_host_event_wakeups += pTarget->wowStats.wow_num_host_event_wakeups;
2750 + pStats->wow_num_events_discarded += pTarget->wowStats.wow_num_events_discarded;
2752 + ar->statsUpdatePending = FALSE;
2753 + wake_up(&arEvent);
2757 +ar6000_rssiThreshold_event(AR_SOFTC_T *ar, WMI_RSSI_THRESHOLD_VAL newThreshold, A_INT16 rssi)
2759 + USER_RSSI_THOLD userRssiThold;
2761 + userRssiThold.tag = rssi_map[newThreshold].tag;
2762 + userRssiThold.rssi = rssi;
2763 + AR_DEBUG2_PRINTF("rssi Threshold range = %d tag = %d rssi = %d\n", newThreshold, userRssiThold.tag, rssi);
2764 + ar6000_send_event_to_app(ar, WMI_RSSI_THRESHOLD_EVENTID,(A_UINT8 *)&userRssiThold, sizeof(USER_RSSI_THOLD));
2769 +ar6000_hbChallengeResp_event(AR_SOFTC_T *ar, A_UINT32 cookie, A_UINT32 source)
2771 + if (source == APP_HB_CHALLENGE) {
2772 + /* Report it to the app in case it wants a positive acknowledgement */
2773 + ar6000_send_event_to_app(ar, WMIX_HB_CHALLENGE_RESP_EVENTID,
2774 + (A_UINT8 *)&cookie, sizeof(cookie));
2776 + /* This would ignore the replys that come in after their due time */
2777 + if (cookie == ar->arHBChallengeResp.seqNum) {
2778 + ar->arHBChallengeResp.outstanding = FALSE;
2785 +ar6000_reportError_event(AR_SOFTC_T *ar, WMI_TARGET_ERROR_VAL errorVal)
2787 + char *errString[] = {
2788 + [WMI_TARGET_PM_ERR_FAIL] "WMI_TARGET_PM_ERR_FAIL",
2789 + [WMI_TARGET_KEY_NOT_FOUND] "WMI_TARGET_KEY_NOT_FOUND",
2790 + [WMI_TARGET_DECRYPTION_ERR] "WMI_TARGET_DECRYPTION_ERR",
2791 + [WMI_TARGET_BMISS] "WMI_TARGET_BMISS",
2792 + [WMI_PSDISABLE_NODE_JOIN] "WMI_PSDISABLE_NODE_JOIN"
2795 + A_PRINTF("AR6000 Error on Target. Error = 0x%x\n", errorVal);
2797 + /* One error is reported at a time, and errorval is a bitmask */
2798 + if(errorVal & (errorVal - 1))
2801 + A_PRINTF("AR6000 Error type = ");
2804 + case WMI_TARGET_PM_ERR_FAIL:
2805 + case WMI_TARGET_KEY_NOT_FOUND:
2806 + case WMI_TARGET_DECRYPTION_ERR:
2807 + case WMI_TARGET_BMISS:
2808 + case WMI_PSDISABLE_NODE_JOIN:
2809 + A_PRINTF("%s\n", errString[errorVal]);
2812 + A_PRINTF("INVALID\n");
2820 +ar6000_cac_event(AR_SOFTC_T *ar, A_UINT8 ac, A_UINT8 cacIndication,
2821 + A_UINT8 statusCode, A_UINT8 *tspecSuggestion)
2823 + WMM_TSPEC_IE *tspecIe;
2826 + * This is the TSPEC IE suggestion from AP.
2827 + * Suggestion provided by AP under some error
2828 + * cases, could be helpful for the host app.
2829 + * Check documentation.
2831 + tspecIe = (WMM_TSPEC_IE *)tspecSuggestion;
2834 + * What do we do, if we get TSPEC rejection? One thought
2835 + * that comes to mind is implictly delete the pstream...
2837 + A_PRINTF("AR6000 CAC notification. "
2838 + "AC = %d, cacIndication = 0x%x, statusCode = 0x%x\n",
2839 + ac, cacIndication, statusCode);
2842 +#define AR6000_PRINT_BSSID(_pBss) do { \
2843 + A_PRINTF("%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",\
2844 + (_pBss)[0],(_pBss)[1],(_pBss)[2],(_pBss)[3],\
2845 + (_pBss)[4],(_pBss)[5]); \
2849 +ar6000_roam_tbl_event(AR_SOFTC_T *ar, WMI_TARGET_ROAM_TBL *pTbl)
2853 + A_PRINTF("ROAM TABLE NO OF ENTRIES is %d ROAM MODE is %d\n",
2854 + pTbl->numEntries, pTbl->roamMode);
2855 + for (i= 0; i < pTbl->numEntries; i++) {
2856 + A_PRINTF("[%d]bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ", i,
2857 + pTbl->bssRoamInfo[i].bssid[0], pTbl->bssRoamInfo[i].bssid[1],
2858 + pTbl->bssRoamInfo[i].bssid[2],
2859 + pTbl->bssRoamInfo[i].bssid[3],
2860 + pTbl->bssRoamInfo[i].bssid[4],
2861 + pTbl->bssRoamInfo[i].bssid[5]);
2862 + A_PRINTF("RSSI %d RSSIDT %d LAST RSSI %d UTIL %d ROAM_UTIL %d"
2864 + pTbl->bssRoamInfo[i].rssi,
2865 + pTbl->bssRoamInfo[i].rssidt,
2866 + pTbl->bssRoamInfo[i].last_rssi,
2867 + pTbl->bssRoamInfo[i].util,
2868 + pTbl->bssRoamInfo[i].roam_util,
2869 + pTbl->bssRoamInfo[i].bias);
2874 +ar6000_wow_list_event(struct ar6_softc *ar, A_UINT8 num_filters, WMI_GET_WOW_LIST_REPLY *wow_reply)
2878 + /*Each event now contains exactly one filter, see bug 26613*/
2879 + A_PRINTF("WOW pattern %d of %d patterns\n", wow_reply->this_filter_num, wow_reply->num_filters);
2880 + A_PRINTF("wow mode = %s host mode = %s\n",
2881 + (wow_reply->wow_mode == 0? "disabled":"enabled"),
2882 + (wow_reply->host_mode == 1 ? "awake":"asleep"));
2885 + /*If there are no patterns, the reply will only contain generic
2886 + WoW information. Pattern information will exist only if there are
2887 + patterns present. Bug 26716*/
2889 + /* If this event contains pattern information, display it*/
2890 + if (wow_reply->this_filter_num) {
2892 + A_PRINTF("id=%d size=%d offset=%d\n",
2893 + wow_reply->wow_filters[i].wow_filter_id,
2894 + wow_reply->wow_filters[i].wow_filter_size,
2895 + wow_reply->wow_filters[i].wow_filter_offset);
2896 + A_PRINTF("wow pattern = ");
2897 + for (j=0; j< wow_reply->wow_filters[i].wow_filter_size; j++) {
2898 + A_PRINTF("%2.2x",wow_reply->wow_filters[i].wow_filter_pattern[j]);
2901 + A_PRINTF("\nwow mask = ");
2902 + for (j=0; j< wow_reply->wow_filters[i].wow_filter_size; j++) {
2903 + A_PRINTF("%2.2x",wow_reply->wow_filters[i].wow_filter_mask[j]);
2910 + * Report the Roaming related data collected on the target
2913 +ar6000_display_roam_time(WMI_TARGET_ROAM_TIME *p)
2915 + A_PRINTF("Disconnect Data : BSSID: ");
2916 + AR6000_PRINT_BSSID(p->disassoc_bssid);
2917 + A_PRINTF(" RSSI %d DISASSOC Time %d NO_TXRX_TIME %d\n",
2918 + p->disassoc_bss_rssi,p->disassoc_time,
2920 + A_PRINTF("Connect Data: BSSID: ");
2921 + AR6000_PRINT_BSSID(p->assoc_bssid);
2922 + A_PRINTF(" RSSI %d ASSOC Time %d TXRX_TIME %d\n",
2923 + p->assoc_bss_rssi,p->assoc_time,
2924 + p->allow_txrx_time);
2925 + A_PRINTF("Last Data Tx Time (b4 Disassoc) %d "\
2926 + "First Data Tx Time (after Assoc) %d\n",
2927 + p->last_data_txrx_time, p->first_data_txrx_time);
2931 +ar6000_roam_data_event(AR_SOFTC_T *ar, WMI_TARGET_ROAM_DATA *p)
2933 + switch (p->roamDataType) {
2934 + case ROAM_DATA_TIME:
2935 + ar6000_display_roam_time(&p->u.roamTime);
2943 +ar6000_bssInfo_event_rx(AR_SOFTC_T *ar, A_UINT8 *datap, int len)
2945 + struct sk_buff *skb;
2946 + WMI_BSS_INFO_HDR *bih = (WMI_BSS_INFO_HDR *)datap;
2949 + if (!ar->arMgmtFilter) {
2952 + if (((ar->arMgmtFilter & IEEE80211_FILTER_TYPE_BEACON) &&
2953 + (bih->frameType != BEACON_FTYPE)) ||
2954 + ((ar->arMgmtFilter & IEEE80211_FILTER_TYPE_PROBE_RESP) &&
2955 + (bih->frameType != PROBERESP_FTYPE)))
2960 + if ((skb = A_NETBUF_ALLOC_RAW(len)) != NULL) {
2962 + A_NETBUF_PUT(skb, len);
2963 + A_MEMCPY(A_NETBUF_DATA(skb), datap, len);
2964 + skb->dev = ar->arNetDev;
2965 + printk("MAC RAW...\n");
2966 +// skb->mac.raw = A_NETBUF_DATA(skb);
2967 + skb->ip_summed = CHECKSUM_NONE;
2968 + skb->pkt_type = PACKET_OTHERHOST;
2969 + skb->protocol = __constant_htons(0x0019);
2974 +A_UINT32 wmiSendCmdNum;
2977 +ar6000_control_tx(void *devt, void *osbuf, WMI_PRI_STREAM_ID streamID)
2979 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
2980 + A_STATUS status = A_OK;
2981 + struct ar_cookie *cookie = NULL;
2984 + /* take lock to protect ar6000_alloc_cookie() */
2985 + AR6000_SPIN_LOCK(&ar->arLock, 0);
2989 + AR_DEBUG2_PRINTF("ar_contrstatus = ol_tx: skb=0x%x, len=0x%x, sid=%d\n",
2990 + (A_UINT32)osbuf, A_NETBUF_LEN(osbuf), streamID);
2992 + if ((streamID == WMI_CONTROL_PRI) && (ar->arWMIControlEpFull)) {
2993 + /* control endpoint is full, don't allocate resources, we
2994 + * are just going to drop this packet */
2996 + AR_DEBUG_PRINTF(" WMI Control EP full, dropping packet : 0x%X, len:%d \n",
2997 + (A_UINT32)osbuf, A_NETBUF_LEN(osbuf));
2999 + cookie = ar6000_alloc_cookie(ar);
3002 + if (cookie == NULL) {
3003 + status = A_NO_MEMORY;
3007 + if(logWmiRawMsgs) {
3008 + A_PRINTF("WMI cmd send, msgNo %d :", wmiSendCmdNum);
3009 + for(i = 0; i < a_netbuf_to_len(osbuf); i++)
3010 + A_PRINTF("%x ", ((A_UINT8 *)a_netbuf_to_data(osbuf))[i]);
3018 + if (cookie != NULL) {
3019 + /* got a structure to send it out on */
3020 + ar->arTxPending[streamID]++;
3022 + if (streamID != WMI_CONTROL_PRI) {
3023 + ar->arTotalTxDataPending++;
3027 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3029 + if (cookie != NULL) {
3030 + cookie->arc_bp[0] = (A_UINT32)osbuf;
3031 + cookie->arc_bp[1] = 0;
3032 + SET_HTC_PACKET_INFO_TX(&cookie->HtcPkt,
3034 + A_NETBUF_DATA(osbuf),
3035 + A_NETBUF_LEN(osbuf),
3036 + arWMIStream2EndpointID(ar,streamID),
3037 + AR6K_CONTROL_PKT_TAG);
3038 + /* this interface is asynchronous, if there is an error, cleanup will happen in the
3039 + * TX completion callback */
3040 + HTCSendPkt(ar->arHtcTarget, &cookie->HtcPkt);
3047 +/* indicate tx activity or inactivity on a WMI stream */
3048 +void ar6000_indicate_tx_activity(void *devt, A_UINT8 TrafficClass, A_BOOL Active)
3050 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
3051 + WMI_PRI_STREAM_ID streamid;
3053 + if (ar->arWmiEnabled) {
3054 + streamid = wmi_get_stream_id(ar->arWmi, TrafficClass);
3056 + /* for mbox ping testing, the traffic class is mapped directly as a stream ID,
3057 + * see handling of AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE in ioctl.c */
3058 + streamid = (WMI_PRI_STREAM_ID)TrafficClass;
3061 + /* notify HTC, this may cause credit distribution changes */
3063 + HTCIndicateActivityChange(ar->arHtcTarget,
3064 + arWMIStream2EndpointID(ar,streamid),
3069 +module_init(ar6000_init_module);
3070 +module_exit(ar6000_cleanup_module);
3072 +/* Init cookie queue */
3074 +ar6000_cookie_init(AR_SOFTC_T *ar)
3078 + ar->arCookieList = NULL;
3079 + A_MEMZERO(s_ar_cookie_mem, sizeof(s_ar_cookie_mem));
3081 + for (i = 0; i < MAX_COOKIE_NUM; i++) {
3082 + ar6000_free_cookie(ar, &s_ar_cookie_mem[i]);
3086 +/* cleanup cookie queue */
3088 +ar6000_cookie_cleanup(AR_SOFTC_T *ar)
3090 + /* It is gone .... */
3091 + ar->arCookieList = NULL;
3094 +/* Init cookie queue */
3096 +ar6000_free_cookie(AR_SOFTC_T *ar, struct ar_cookie * cookie)
3098 + /* Insert first */
3099 + A_ASSERT(ar != NULL);
3100 + A_ASSERT(cookie != NULL);
3101 + cookie->arc_list_next = ar->arCookieList;
3102 + ar->arCookieList = cookie;
3105 +/* cleanup cookie queue */
3106 +static struct ar_cookie *
3107 +ar6000_alloc_cookie(AR_SOFTC_T *ar)
3109 + struct ar_cookie *cookie;
3111 + cookie = ar->arCookieList;
3112 + if(cookie != NULL)
3114 + ar->arCookieList = cookie->arc_list_next;
3120 +#ifdef SEND_EVENT_TO_APP
3122 + * This function is used to send event which come from taget to
3123 + * the application. The buf which send to application is include
3124 + * the event ID and event content.
3126 +#define EVENT_ID_LEN 2
3127 +void ar6000_send_event_to_app(AR_SOFTC_T *ar, A_UINT16 eventId,
3128 + A_UINT8 *datap, int len)
3131 +#if (WIRELESS_EXT >= 15)
3133 +/* note: IWEVCUSTOM only exists in wireless extensions after version 15 */
3137 + union iwreq_data wrqu;
3139 + size = len + EVENT_ID_LEN;
3141 + if (size > IW_CUSTOM_MAX) {
3142 + AR_DEBUG_PRINTF("WMI event ID : 0x%4.4X, len = %d too big for IWEVCUSTOM (max=%d) \n",
3143 + eventId, size, IW_CUSTOM_MAX);
3147 + buf = A_MALLOC_NOWAIT(size);
3148 + A_MEMZERO(buf, size);
3149 + A_MEMCPY(buf, &eventId, EVENT_ID_LEN);
3150 + A_MEMCPY(buf+EVENT_ID_LEN, datap, len);
3152 + //AR_DEBUG_PRINTF("event ID = %d,len = %d\n",*(A_UINT16*)buf, size);
3153 + A_MEMZERO(&wrqu, sizeof(wrqu));
3154 + wrqu.data.length = size;
3155 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
3166 +ar6000_tx_retry_err_event(void *devt)
3168 + AR_DEBUG2_PRINTF("Tx retries reach maximum!\n");
3172 +ar6000_snrThresholdEvent_rx(void *devt, WMI_SNR_THRESHOLD_VAL newThreshold, A_UINT8 snr)
3174 + AR_DEBUG2_PRINTF("snr threshold range %d, snr %d\n", newThreshold, snr);
3178 +ar6000_lqThresholdEvent_rx(void *devt, WMI_LQ_THRESHOLD_VAL newThreshold, A_UINT8 lq)
3180 + AR_DEBUG2_PRINTF("lq threshold range %d, lq %d\n", newThreshold, lq);
3186 +a_copy_to_user(void *to, const void *from, A_UINT32 n)
3188 + return(copy_to_user(to, from, n));
3192 +a_copy_from_user(void *to, const void *from, A_UINT32 n)
3194 + return(copy_from_user(to, from, n));
3199 +ar6000_get_driver_cfg(struct net_device *dev,
3200 + A_UINT16 cfgParam,
3208 + case AR6000_DRIVER_CFG_GET_WLANNODECACHING:
3209 + *((A_UINT32 *)result) = wlanNodeCaching;
3211 + case AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS:
3212 + *((A_UINT32 *)result) = logWmiRawMsgs;
3223 +ar6000_keepalive_rx(void *devt, A_UINT8 configured)
3225 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
3227 + ar->arKeepaliveConfigured = configured;
3228 + wake_up(&arEvent);
3232 +ar6000_pmkid_list_event(void *devt, A_UINT8 numPMKID, WMI_PMKID *pmkidList)
3236 + A_PRINTF("Number of Cached PMKIDs is %d\n", numPMKID);
3238 + for (i = 0; i < numPMKID; i++) {
3239 + A_PRINTF("\nPMKID %d ", i);
3240 + for (j = 0; j < WMI_PMKID_LEN; j++) {
3241 + A_PRINTF("%2.2x", pmkidList->pmkid[j]);
3250 +ar6000_reinstall_keys(AR_SOFTC_T *ar, A_UINT8 key_op_ctrl)
3252 + A_STATUS status = A_OK;
3253 + struct ieee80211req_key *uik = &ar->user_saved_keys.ucast_ik;
3254 + struct ieee80211req_key *bik = &ar->user_saved_keys.bcast_ik;
3255 + CRYPTO_TYPE keyType = ar->user_saved_keys.keyType;
3257 + if (IEEE80211_CIPHER_CCKM_KRK != uik->ik_type) {
3258 + if (NONE_CRYPT == keyType) {
3259 + goto _reinstall_keys_out;
3262 + if (uik->ik_keylen) {
3263 + status = wmi_addKey_cmd(ar->arWmi, uik->ik_keyix,
3264 + ar->user_saved_keys.keyType, PAIRWISE_USAGE,
3265 + uik->ik_keylen, (A_UINT8 *)&uik->ik_keyrsc,
3266 + uik->ik_keydata, key_op_ctrl, SYNC_BEFORE_WMIFLAG);
3270 + status = wmi_add_krk_cmd(ar->arWmi, uik->ik_keydata);
3273 + if (IEEE80211_CIPHER_CCKM_KRK != bik->ik_type) {
3274 + if (NONE_CRYPT == keyType) {
3275 + goto _reinstall_keys_out;
3278 + if (bik->ik_keylen) {
3279 + status = wmi_addKey_cmd(ar->arWmi, bik->ik_keyix,
3280 + ar->user_saved_keys.keyType, GROUP_USAGE,
3281 + bik->ik_keylen, (A_UINT8 *)&bik->ik_keyrsc,
3282 + bik->ik_keydata, key_op_ctrl, NO_SYNC_WMIFLAG);
3285 + status = wmi_add_krk_cmd(ar->arWmi, bik->ik_keydata);
3288 +_reinstall_keys_out:
3289 + ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
3290 + ar->user_key_ctrl = 0;
3294 +#endif /* USER_KEYS */
3298 +ar6000_dset_open_req(
3301 + A_UINT32 targHandle,
3302 + A_UINT32 targReplyFn,
3303 + A_UINT32 targReplyArg)
3310 + A_UINT32 access_cookie)
3316 +ar6000_dset_data_req(
3318 + A_UINT32 accessCookie,
3322 + A_UINT32 targReplyFn,
3323 + A_UINT32 targReplyArg)
3326 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.h b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.h
3327 new file mode 100644
3328 index 0000000..c7b6ec4
3330 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.h
3334 + * Copyright (c) 2004-2007 Atheros Communications Inc.
3335 + * All rights reserved.
3338 + * This program is free software; you can redistribute it and/or modify
3339 + * it under the terms of the GNU General Public License version 2 as
3340 + * published by the Free Software Foundation;
3342 + * Software distributed under the License is distributed on an "AS
3343 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
3344 + * implied. See the License for the specific language governing
3345 + * rights and limitations under the License.
3354 +#include <linux/version.h>
3357 +#include <linux/autoconf.h>
3358 +#include <linux/init.h>
3359 +#include <linux/kernel.h>
3360 +#include <linux/spinlock.h>
3361 +#include <linux/skbuff.h>
3362 +#include <linux/if_ether.h>
3363 +#include <linux/netdevice.h>
3364 +#include <linux/etherdevice.h>
3365 +#include <net/iw_handler.h>
3366 +#include <linux/if_arp.h>
3367 +#include <linux/ip.h>
3368 +#include <asm/semaphore.h>
3369 +#include <linux/wireless.h>
3370 +#include <linux/module.h>
3371 +#include <asm/io.h>
3373 +#include <a_config.h>
3374 +#include <athdefs.h>
3375 +#include "a_types.h"
3376 +#include "a_osapi.h"
3377 +#include "htc_api.h"
3381 +#include <ieee80211.h>
3382 +#include <ieee80211_ioctl.h>
3383 +#include <wlan_api.h>
3384 +#include <wmi_api.h>
3385 +#include "gpio_api.h"
3387 +#include <host_version.h>
3388 +#include <linux/rtnetlink.h>
3389 +#include <linux/init.h>
3390 +#include <linux/moduleparam.h>
3391 +#include "AR6Khwreg.h"
3392 +#include "ar6000_api.h"
3393 +#ifdef CONFIG_HOST_TCMD_SUPPORT
3394 +#include <testcmd.h>
3397 +#include "targaddrs.h"
3398 +#include "dbglog_api.h"
3399 +#include "ar6000_diag.h"
3400 +#include "common_drv.h"
3403 +#define __dev_put(dev) dev_put(dev)
3408 +#define USER_SAVEDKEYS_STAT_INIT 0
3409 +#define USER_SAVEDKEYS_STAT_RUN 1
3411 +// TODO this needs to move into the AR_SOFTC struct
3412 +struct USER_SAVEDKEYS {
3413 + struct ieee80211req_key ucast_ik;
3414 + struct ieee80211req_key bcast_ik;
3415 + CRYPTO_TYPE keyType;
3420 +#define DBG_INFO 0x00000001
3421 +#define DBG_ERROR 0x00000002
3422 +#define DBG_WARNING 0x00000004
3423 +#define DBG_SDIO 0x00000008
3424 +#define DBG_HIF 0x00000010
3425 +#define DBG_HTC 0x00000020
3426 +#define DBG_WMI 0x00000040
3427 +#define DBG_WMI2 0x00000080
3428 +#define DBG_DRIVER 0x00000100
3430 +#define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING)
3434 +#define AR_DEBUG_PRINTF(args...) if (debugdriver) A_PRINTF(args);
3435 +#define AR_DEBUG2_PRINTF(args...) if (debugdriver >= 2) A_PRINTF(args);
3436 +extern int debugdriver;
3438 +#define AR_DEBUG_PRINTF(args...)
3439 +#define AR_DEBUG2_PRINTF(args...)
3442 +A_STATUS ar6000_ReadRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
3443 +A_STATUS ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
3449 +#define MAX_AR6000 1
3450 +#define AR6000_MAX_RX_BUFFERS 16
3451 +#define AR6000_BUFFER_SIZE 1664
3452 +#define AR6000_TX_TIMEOUT 10
3453 +#define AR6000_ETH_ADDR_LEN 6
3454 +#define AR6000_MAX_ENDPOINTS 4
3455 +#define MAX_NODE_NUM 15
3456 +#define MAX_COOKIE_NUM 150
3457 +#define AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT 1
3458 +#define AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT 1
3461 + DRV_HB_CHALLENGE = 0,
3465 +/* HTC RAW streams */
3466 +typedef enum _HTC_RAW_STREAM_ID {
3467 + HTC_RAW_STREAM_NOT_MAPPED = -1,
3468 + HTC_RAW_STREAM_0 = 0,
3469 + HTC_RAW_STREAM_1 = 1,
3470 + HTC_RAW_STREAM_2 = 2,
3471 + HTC_RAW_STREAM_3 = 3,
3472 + HTC_RAW_STREAM_NUM_MAX
3473 +} HTC_RAW_STREAM_ID;
3475 +#define RAW_HTC_READ_BUFFERS_NUM 4
3476 +#define RAW_HTC_WRITE_BUFFERS_NUM 4
3481 + unsigned char data[AR6000_BUFFER_SIZE];
3482 + HTC_PACKET HTCPacket;
3485 +#ifdef CONFIG_HOST_TCMD_SUPPORT
3487 + * add TCMD_MODE besides wmi and bypasswmi
3488 + * in TCMD_MODE, only few TCMD releated wmi commands
3489 + * counld be hanlder
3492 + AR6000_WMI_MODE = 0,
3493 + AR6000_BYPASS_MODE,
3497 +#endif /* CONFIG_HOST_TCMD_SUPPORT */
3499 +struct ar_wep_key {
3500 + A_UINT8 arKeyIndex;
3502 + A_UINT8 arKey[64];
3505 +struct ar_node_mapping {
3506 + A_UINT8 macAddress[6];
3508 + A_UINT8 txPending;
3512 + A_UINT32 arc_bp[2]; /* Must be first field */
3513 + HTC_PACKET HtcPkt; /* HTC packet wrapper */
3514 + struct ar_cookie *arc_list_next;
3517 +struct ar_hb_chlng_resp {
3519 + A_UINT32 frequency;
3521 + A_BOOL outstanding;
3523 + A_UINT8 missThres;
3526 +typedef struct ar6_softc {
3527 + struct net_device *arNetDev; /* net_device pointer */
3529 + int arTxPending[WMI_PRI_MAX_COUNT];
3530 + int arTotalTxDataPending;
3531 + A_UINT8 arNumDataEndPts;
3532 + A_BOOL arWmiEnabled;
3533 + A_BOOL arWmiReady;
3534 + A_BOOL arConnected;
3535 + HTC_HANDLE arHtcTarget;
3536 + void *arHifDevice;
3537 + spinlock_t arLock;
3538 + struct semaphore arSem;
3539 + int arRxBuffers[WMI_PRI_MAX_COUNT];
3541 + u_char arSsid[32];
3542 + A_UINT8 arNetworkType;
3543 + A_UINT8 arDot11AuthMode;
3544 + A_UINT8 arAuthMode;
3545 + A_UINT8 arPairwiseCrypto;
3546 + A_UINT8 arPairwiseCryptoLen;
3547 + A_UINT8 arGroupCrypto;
3548 + A_UINT8 arGroupCryptoLen;
3549 + A_UINT8 arDefTxKeyIndex;
3550 + struct ar_wep_key arWepKeyList[WMI_MAX_KEY_INDEX + 1];
3551 + A_UINT8 arBssid[6];
3552 + A_UINT8 arReqBssid[6];
3553 + A_UINT16 arChannelHint;
3554 + A_UINT16 arBssChannel;
3555 + A_UINT16 arListenInterval;
3556 + struct ar6000_version arVersion;
3557 + A_UINT32 arTargetType;
3560 + A_BOOL arTxPwrSet;
3561 + A_INT32 arBitRate;
3562 + struct net_device_stats arNetStats;
3563 + struct iw_statistics arIwStats;
3564 + A_INT8 arNumChannels;
3565 + A_UINT16 arChannelList[32];
3566 + A_UINT32 arRegCode;
3567 + A_BOOL statsUpdatePending;
3568 + TARGET_STATS arTargetStats;
3569 + A_INT8 arMaxRetries;
3570 + A_UINT8 arPhyCapability;
3571 +#ifdef CONFIG_HOST_TCMD_SUPPORT
3572 + A_UINT8 tcmdRxReport;
3573 + A_UINT32 tcmdRxTotalPkt;
3574 + A_INT32 tcmdRxRssi;
3576 + A_UINT32 arTargetMode;
3578 + AR6000_WLAN_STATE arWlanState;
3579 + struct ar_node_mapping arNodeMap[MAX_NODE_NUM];
3580 + A_UINT8 arIbssPsEnable;
3581 + A_UINT8 arNodeNum;
3582 + A_UINT8 arNexEpId;
3583 + struct ar_cookie *arCookieList;
3584 + A_UINT16 arRateMask;
3585 + A_UINT8 arSkipScan;
3586 + A_UINT16 arBeaconInterval;
3587 + A_BOOL arConnectPending;
3588 + A_BOOL arWmmEnabled;
3589 + struct ar_hb_chlng_resp arHBChallengeResp;
3590 + A_UINT8 arKeepaliveConfigured;
3591 + A_UINT32 arMgmtFilter;
3592 + HTC_ENDPOINT_ID arWmi2EpMapping[WMI_PRI_MAX_COUNT];
3593 + WMI_PRI_STREAM_ID arEp2WmiMapping[ENDPOINT_MAX];
3594 +#ifdef HTC_RAW_INTERFACE
3595 + HTC_ENDPOINT_ID arRaw2EpMapping[HTC_RAW_STREAM_NUM_MAX];
3596 + HTC_RAW_STREAM_ID arEp2RawMapping[ENDPOINT_MAX];
3597 + struct semaphore raw_htc_read_sem[HTC_RAW_STREAM_NUM_MAX];
3598 + struct semaphore raw_htc_write_sem[HTC_RAW_STREAM_NUM_MAX];
3599 + wait_queue_head_t raw_htc_read_queue[HTC_RAW_STREAM_NUM_MAX];
3600 + wait_queue_head_t raw_htc_write_queue[HTC_RAW_STREAM_NUM_MAX];
3601 + raw_htc_buffer raw_htc_read_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_READ_BUFFERS_NUM];
3602 + raw_htc_buffer raw_htc_write_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_WRITE_BUFFERS_NUM];
3603 + A_BOOL write_buffer_available[HTC_RAW_STREAM_NUM_MAX];
3604 + A_BOOL read_buffer_available[HTC_RAW_STREAM_NUM_MAX];
3606 + A_BOOL arNetQueueStopped;
3607 + A_BOOL arRawIfInit;
3608 + int arDeviceIndex;
3609 + COMMON_CREDIT_STATE_INFO arCreditStateInfo;
3610 + A_BOOL arWMIControlEpFull;
3611 + A_BOOL dbgLogFetchInProgress;
3612 + A_UCHAR log_buffer[DBGLOG_HOST_LOG_BUFFER_SIZE];
3614 + A_UINT32 dbglog_init_done;
3615 + A_UINT32 arConnectCtrlFlags;
3616 + A_UINT32 scan_complete;
3618 + A_INT32 user_savedkeys_stat;
3619 + A_UINT32 user_key_ctrl;
3620 + struct USER_SAVEDKEYS user_saved_keys;
3625 +#define arWMIStream2EndpointID(ar,wmi) (ar)->arWmi2EpMapping[(wmi)]
3626 +#define arSetWMIStream2EndpointIDMap(ar,wmi,ep) \
3627 +{ (ar)->arWmi2EpMapping[(wmi)] = (ep); \
3628 + (ar)->arEp2WmiMapping[(ep)] = (wmi); }
3629 +#define arEndpoint2WMIStreamID(ar,ep) (ar)->arEp2WmiMapping[(ep)]
3631 +#define arRawIfEnabled(ar) (ar)->arRawIfInit
3632 +#define arRawStream2EndpointID(ar,raw) (ar)->arRaw2EpMapping[(raw)]
3633 +#define arSetRawStream2EndpointIDMap(ar,raw,ep) \
3634 +{ (ar)->arRaw2EpMapping[(raw)] = (ep); \
3635 + (ar)->arEp2RawMapping[(ep)] = (raw); }
3636 +#define arEndpoint2RawStreamID(ar,ep) (ar)->arEp2RawMapping[(ep)]
3638 +struct ar_giwscan_param {
3644 +#define AR6000_STAT_INC(ar, stat) (ar->arNetStats.stat++)
3646 +#define AR6000_SPIN_LOCK(lock, param) do { \
3647 + if (irqs_disabled()) { \
3648 + AR_DEBUG_PRINTF("IRQs disabled:AR6000_LOCK\n"); \
3650 + spin_lock_bh(lock); \
3653 +#define AR6000_SPIN_UNLOCK(lock, param) do { \
3654 + if (irqs_disabled()) { \
3655 + AR_DEBUG_PRINTF("IRQs disabled: AR6000_UNLOCK\n"); \
3657 + spin_unlock_bh(lock); \
3660 +int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
3661 +int ar6000_ioctl_dispatcher(struct net_device *dev, struct ifreq *rq, int cmd);
3662 +void ar6000_ioctl_iwsetup(struct iw_handler_def *def);
3663 +void ar6000_gpio_init(void);
3664 +void ar6000_init_profile_info(AR_SOFTC_T *ar);
3665 +void ar6000_install_static_wep_keys(AR_SOFTC_T *ar);
3666 +int ar6000_init(struct net_device *dev);
3667 +int ar6000_dbglog_get_debug_logs(AR_SOFTC_T *ar);
3668 +A_STATUS ar6000_SetHTCBlockSize(AR_SOFTC_T *ar);
3670 +#ifdef HTC_RAW_INTERFACE
3676 +int ar6000_htc_raw_open(AR_SOFTC_T *ar);
3677 +int ar6000_htc_raw_close(AR_SOFTC_T *ar);
3678 +ssize_t ar6000_htc_raw_read(AR_SOFTC_T *ar,
3679 + HTC_RAW_STREAM_ID StreamID,
3680 + char __user *buffer, size_t count);
3681 +ssize_t ar6000_htc_raw_write(AR_SOFTC_T *ar,
3682 + HTC_RAW_STREAM_ID StreamID,
3683 + char __user *buffer, size_t count);
3685 +#endif /* HTC_RAW_INTERFACE */
3691 +#endif /* _AR6000_H_ */
3692 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_raw_if.c b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_raw_if.c
3693 new file mode 100644
3694 index 0000000..746cb2b
3696 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_raw_if.c
3700 + * Copyright (c) 2004-2007 Atheros Communications Inc.
3701 + * All rights reserved.
3704 + * This program is free software; you can redistribute it and/or modify
3705 + * it under the terms of the GNU General Public License version 2 as
3706 + * published by the Free Software Foundation;
3708 + * Software distributed under the License is distributed on an "AS
3709 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
3710 + * implied. See the License for the specific language governing
3711 + * rights and limitations under the License.
3717 +#include "ar6000_drv.h"
3719 +#ifdef HTC_RAW_INTERFACE
3722 +ar6000_htc_raw_read_cb(void *Context, HTC_PACKET *pPacket)
3724 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
3725 + raw_htc_buffer *busy;
3726 + HTC_RAW_STREAM_ID streamID;
3728 + busy = (raw_htc_buffer *)pPacket->pPktContext;
3729 + A_ASSERT(busy != NULL);
3731 + if (pPacket->Status == A_ECANCELED) {
3733 + * HTC provides A_ECANCELED status when it doesn't want to be refilled
3734 + * (probably due to a shutdown)
3739 + streamID = arEndpoint2RawStreamID(ar,pPacket->Endpoint);
3740 + A_ASSERT(streamID != HTC_RAW_STREAM_NOT_MAPPED);
3743 + if (down_trylock(&ar->raw_htc_read_sem[streamID])) {
3745 + if (down_interruptible(&ar->raw_htc_read_sem[streamID])) {
3747 + AR_DEBUG2_PRINTF("Unable to down the semaphore\n");
3750 + A_ASSERT((pPacket->Status != A_OK) ||
3751 + (pPacket->pBuffer == (busy->data + HTC_HEADER_LEN)));
3753 + busy->length = pPacket->ActualLength + HTC_HEADER_LEN;
3754 + busy->currPtr = HTC_HEADER_LEN;
3755 + ar->read_buffer_available[streamID] = TRUE;
3756 + //AR_DEBUG_PRINTF("raw read cb: 0x%X 0x%X \n", busy->currPtr,busy->length);
3757 + up(&ar->raw_htc_read_sem[streamID]);
3759 + /* Signal the waiting process */
3760 + AR_DEBUG2_PRINTF("Waking up the StreamID(%d) read process\n", streamID);
3761 + wake_up_interruptible(&ar->raw_htc_read_queue[streamID]);
3765 +ar6000_htc_raw_write_cb(void *Context, HTC_PACKET *pPacket)
3767 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
3768 + raw_htc_buffer *free;
3769 + HTC_RAW_STREAM_ID streamID;
3771 + free = (raw_htc_buffer *)pPacket->pPktContext;
3772 + A_ASSERT(free != NULL);
3774 + if (pPacket->Status == A_ECANCELED) {
3776 + * HTC provides A_ECANCELED status when it doesn't want to be refilled
3777 + * (probably due to a shutdown)
3782 + streamID = arEndpoint2RawStreamID(ar,pPacket->Endpoint);
3783 + A_ASSERT(streamID != HTC_RAW_STREAM_NOT_MAPPED);
3786 + if (down_trylock(&ar->raw_htc_write_sem[streamID])) {
3788 + if (down_interruptible(&ar->raw_htc_write_sem[streamID])) {
3790 + AR_DEBUG2_PRINTF("Unable to down the semaphore\n");
3793 + A_ASSERT(pPacket->pBuffer == (free->data + HTC_HEADER_LEN));
3796 + ar->write_buffer_available[streamID] = TRUE;
3797 + up(&ar->raw_htc_write_sem[streamID]);
3799 + /* Signal the waiting process */
3800 + AR_DEBUG2_PRINTF("Waking up the StreamID(%d) write process\n", streamID);
3801 + wake_up_interruptible(&ar->raw_htc_write_queue[streamID]);
3804 +/* connect to a service */
3805 +static A_STATUS ar6000_connect_raw_service(AR_SOFTC_T *ar,
3806 + HTC_RAW_STREAM_ID StreamID)
3809 + HTC_SERVICE_CONNECT_RESP response;
3811 + HTC_SERVICE_CONNECT_REQ connect;
3815 + A_MEMZERO(&connect,sizeof(connect));
3816 + /* pass the stream ID as meta data to the RAW streams service */
3817 + streamNo = (A_UINT8)StreamID;
3818 + connect.pMetaData = &streamNo;
3819 + connect.MetaDataLength = sizeof(A_UINT8);
3820 + /* these fields are the same for all endpoints */
3821 + connect.EpCallbacks.pContext = ar;
3822 + connect.EpCallbacks.EpTxComplete = ar6000_htc_raw_write_cb;
3823 + connect.EpCallbacks.EpRecv = ar6000_htc_raw_read_cb;
3824 + /* simple interface, we don't need these optional callbacks */
3825 + connect.EpCallbacks.EpRecvRefill = NULL;
3826 + connect.EpCallbacks.EpSendFull = NULL;
3827 + connect.MaxSendQueueDepth = RAW_HTC_WRITE_BUFFERS_NUM;
3829 + /* connect to the raw streams service, we may be able to get 1 or more
3830 + * connections, depending on WHAT is running on the target */
3831 + connect.ServiceID = HTC_RAW_STREAMS_SVC;
3833 + A_MEMZERO(&response,sizeof(response));
3835 + /* try to connect to the raw stream, it is okay if this fails with
3836 + * status HTC_SERVICE_NO_MORE_EP */
3837 + status = HTCConnectService(ar->arHtcTarget,
3841 + if (A_FAILED(status)) {
3842 + if (response.ConnectRespCode == HTC_SERVICE_NO_MORE_EP) {
3843 + AR_DEBUG_PRINTF("HTC RAW , No more streams allowed \n");
3849 + /* set endpoint mapping for the RAW HTC streams */
3850 + arSetRawStream2EndpointIDMap(ar,StreamID,response.Endpoint);
3852 + AR_DEBUG_PRINTF("HTC RAW : stream ID: %d, endpoint: %d\n",
3853 + StreamID, arRawStream2EndpointID(ar,StreamID));
3860 +int ar6000_htc_raw_open(AR_SOFTC_T *ar)
3863 + int streamID, endPt, count2;
3864 + raw_htc_buffer *buffer;
3865 + HTC_SERVICE_ID servicepriority;
3867 + A_ASSERT(ar->arHtcTarget != NULL);
3869 + /* wait for target */
3870 + status = HTCWaitTarget(ar->arHtcTarget);
3872 + if (A_FAILED(status)) {
3873 + AR_DEBUG_PRINTF("HTCWaitTarget failed (%d)\n", status);
3877 + for (endPt = 0; endPt < ENDPOINT_MAX; endPt++) {
3878 + ar->arEp2RawMapping[endPt] = HTC_RAW_STREAM_NOT_MAPPED;
3881 + for (streamID = HTC_RAW_STREAM_0; streamID < HTC_RAW_STREAM_NUM_MAX; streamID++) {
3882 + /* Initialize the data structures */
3883 + init_MUTEX(&ar->raw_htc_read_sem[streamID]);
3884 + init_MUTEX(&ar->raw_htc_write_sem[streamID]);
3885 + init_waitqueue_head(&ar->raw_htc_read_queue[streamID]);
3886 + init_waitqueue_head(&ar->raw_htc_write_queue[streamID]);
3888 + /* try to connect to the raw service */
3889 + status = ar6000_connect_raw_service(ar,streamID);
3891 + if (A_FAILED(status)) {
3895 + if (arRawStream2EndpointID(ar,streamID) == 0) {
3899 + for (count2 = 0; count2 < RAW_HTC_READ_BUFFERS_NUM; count2 ++) {
3900 + /* Initialize the receive buffers */
3901 + buffer = &ar->raw_htc_write_buffer[streamID][count2];
3902 + memset(buffer, 0, sizeof(raw_htc_buffer));
3903 + buffer = &ar->raw_htc_read_buffer[streamID][count2];
3904 + memset(buffer, 0, sizeof(raw_htc_buffer));
3906 + SET_HTC_PACKET_INFO_RX_REFILL(&buffer->HTCPacket,
3909 + AR6000_BUFFER_SIZE,
3910 + arRawStream2EndpointID(ar,streamID));
3912 + /* Queue buffers to HTC for receive */
3913 + if ((status = HTCAddReceivePkt(ar->arHtcTarget, &buffer->HTCPacket)) != A_OK)
3920 + for (count2 = 0; count2 < RAW_HTC_WRITE_BUFFERS_NUM; count2 ++) {
3921 + /* Initialize the receive buffers */
3922 + buffer = &ar->raw_htc_write_buffer[streamID][count2];
3923 + memset(buffer, 0, sizeof(raw_htc_buffer));
3926 + ar->read_buffer_available[streamID] = FALSE;
3927 + ar->write_buffer_available[streamID] = TRUE;
3930 + if (A_FAILED(status)) {
3934 + AR_DEBUG_PRINTF("HTC RAW, number of streams the target supports: %d \n", streamID);
3936 + servicepriority = HTC_RAW_STREAMS_SVC; /* only 1 */
3938 + /* set callbacks and priority list */
3939 + HTCSetCreditDistribution(ar->arHtcTarget,
3941 + NULL, /* use default */
3942 + NULL, /* use default */
3946 + /* Start the HTC component */
3947 + if ((status = HTCStart(ar->arHtcTarget)) != A_OK) {
3952 + (ar)->arRawIfInit = TRUE;
3957 +int ar6000_htc_raw_close(AR_SOFTC_T *ar)
3959 + A_PRINTF("ar6000_htc_raw_close called \n");
3960 + HTCStop(ar->arHtcTarget);
3962 + /* reset the device */
3963 + ar6000_reset_device(ar->arHifDevice, ar->arTargetType);
3964 + /* Initialize the BMI component */
3971 +get_filled_buffer(AR_SOFTC_T *ar, HTC_RAW_STREAM_ID StreamID)
3974 + raw_htc_buffer *busy;
3976 + /* Check for data */
3977 + for (count = 0; count < RAW_HTC_READ_BUFFERS_NUM; count ++) {
3978 + busy = &ar->raw_htc_read_buffer[StreamID][count];
3979 + if (busy->length) {
3983 + if (busy->length) {
3984 + ar->read_buffer_available[StreamID] = TRUE;
3986 + ar->read_buffer_available[StreamID] = FALSE;
3992 +ssize_t ar6000_htc_raw_read(AR_SOFTC_T *ar, HTC_RAW_STREAM_ID StreamID,
3993 + char __user *buffer, size_t length)
3996 + raw_htc_buffer *busy;
3998 + if (arRawStream2EndpointID(ar,StreamID) == 0) {
3999 + AR_DEBUG_PRINTF("StreamID(%d) not connected! \n", StreamID);
4003 + if (down_interruptible(&ar->raw_htc_read_sem[StreamID])) {
4004 + return -ERESTARTSYS;
4007 + busy = get_filled_buffer(ar,StreamID);
4008 + while (!ar->read_buffer_available[StreamID]) {
4009 + up(&ar->raw_htc_read_sem[StreamID]);
4011 + /* Wait for the data */
4012 + AR_DEBUG2_PRINTF("Sleeping StreamID(%d) read process\n", StreamID);
4013 + if (wait_event_interruptible(ar->raw_htc_read_queue[StreamID],
4014 + ar->read_buffer_available[StreamID]))
4018 + if (down_interruptible(&ar->raw_htc_read_sem[StreamID])) {
4019 + return -ERESTARTSYS;
4021 + busy = get_filled_buffer(ar,StreamID);
4024 + /* Read the data */
4025 + readPtr = busy->currPtr;
4026 + if (length > busy->length - HTC_HEADER_LEN) {
4027 + length = busy->length - HTC_HEADER_LEN;
4029 + if (copy_to_user(buffer, &busy->data[readPtr], length)) {
4030 + up(&ar->raw_htc_read_sem[StreamID]);
4034 + busy->currPtr += length;
4036 + //AR_DEBUG_PRINTF("raw read ioctl: currPTR : 0x%X 0x%X \n", busy->currPtr,busy->length);
4038 + if (busy->currPtr == busy->length)
4040 + busy->currPtr = 0;
4042 + HTC_PACKET_RESET_RX(&busy->HTCPacket);
4043 + //AR_DEBUG_PRINTF("raw read ioctl: ep for packet:%d \n", busy->HTCPacket.Endpoint);
4044 + HTCAddReceivePkt(ar->arHtcTarget, &busy->HTCPacket);
4046 + ar->read_buffer_available[StreamID] = FALSE;
4047 + up(&ar->raw_htc_read_sem[StreamID]);
4052 +static raw_htc_buffer *
4053 +get_free_buffer(AR_SOFTC_T *ar, HTC_ENDPOINT_ID StreamID)
4056 + raw_htc_buffer *free;
4059 + for (count = 0; count < RAW_HTC_WRITE_BUFFERS_NUM; count ++) {
4060 + free = &ar->raw_htc_write_buffer[StreamID][count];
4061 + if (free->length == 0) {
4065 + if (!free->length) {
4066 + ar->write_buffer_available[StreamID] = TRUE;
4068 + ar->write_buffer_available[StreamID] = FALSE;
4074 +ssize_t ar6000_htc_raw_write(AR_SOFTC_T *ar, HTC_RAW_STREAM_ID StreamID,
4075 + char __user *buffer, size_t length)
4078 + raw_htc_buffer *free;
4080 + if (arRawStream2EndpointID(ar,StreamID) == 0) {
4081 + AR_DEBUG_PRINTF("StreamID(%d) not connected! \n", StreamID);
4085 + if (down_interruptible(&ar->raw_htc_write_sem[StreamID])) {
4086 + return -ERESTARTSYS;
4089 + /* Search for a free buffer */
4090 + free = get_free_buffer(ar,StreamID);
4092 + /* Check if there is space to write else wait */
4093 + while (!ar->write_buffer_available[StreamID]) {
4094 + up(&ar->raw_htc_write_sem[StreamID]);
4096 + /* Wait for buffer to become free */
4097 + AR_DEBUG2_PRINTF("Sleeping StreamID(%d) write process\n", StreamID);
4098 + if (wait_event_interruptible(ar->raw_htc_write_queue[StreamID],
4099 + ar->write_buffer_available[StreamID]))
4103 + if (down_interruptible(&ar->raw_htc_write_sem[StreamID])) {
4104 + return -ERESTARTSYS;
4106 + free = get_free_buffer(ar,StreamID);
4109 + /* Send the data */
4110 + writePtr = HTC_HEADER_LEN;
4111 + if (length > (AR6000_BUFFER_SIZE - HTC_HEADER_LEN)) {
4112 + length = AR6000_BUFFER_SIZE - HTC_HEADER_LEN;
4115 + if (copy_from_user(&free->data[writePtr], buffer, length)) {
4116 + up(&ar->raw_htc_read_sem[StreamID]);
4120 + free->length = length;
4122 + SET_HTC_PACKET_INFO_TX(&free->HTCPacket,
4124 + &free->data[writePtr],
4126 + arRawStream2EndpointID(ar,StreamID),
4127 + AR6K_DATA_PKT_TAG);
4129 + HTCSendPkt(ar->arHtcTarget,&free->HTCPacket);
4131 + ar->write_buffer_available[StreamID] = FALSE;
4132 + up(&ar->raw_htc_write_sem[StreamID]);
4136 +#endif /* HTC_RAW_INTERFACE */
4137 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/ar6xapi_linux.h b/drivers/sdio/function/wlan/ar6000/ar6000/ar6xapi_linux.h
4138 new file mode 100644
4139 index 0000000..b8e6e09
4141 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6xapi_linux.h
4143 +#ifndef _AR6XAPI_LINUX_H
4144 +#define _AR6XAPI_LINUX_H
4147 + * Copyright (c) 2004-2007 Atheros Communications Inc.
4148 + * All rights reserved.
4151 + * This program is free software; you can redistribute it and/or modify
4152 + * it under the terms of the GNU General Public License version 2 as
4153 + * published by the Free Software Foundation;
4155 + * Software distributed under the License is distributed on an "AS
4156 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
4157 + * implied. See the License for the specific language governing
4158 + * rights and limitations under the License.
4170 +void ar6000_ready_event(void *devt, A_UINT8 *datap, A_UINT8 phyCap);
4171 +A_UINT8 ar6000_iptos_to_userPriority(A_UINT8 *pkt);
4172 +A_STATUS ar6000_control_tx(void *devt, void *osbuf, WMI_PRI_STREAM_ID streamID);
4173 +void ar6000_connect_event(struct ar6_softc *ar, A_UINT16 channel,
4174 + A_UINT8 *bssid, A_UINT16 listenInterval,
4175 + A_UINT16 beaconInterval, NETWORK_TYPE networkType,
4176 + A_UINT8 beaconIeLen, A_UINT8 assocReqLen,
4177 + A_UINT8 assocRespLen,A_UINT8 *assocInfo);
4178 +void ar6000_disconnect_event(struct ar6_softc *ar, A_UINT8 reason,
4179 + A_UINT8 *bssid, A_UINT8 assocRespLen,
4180 + A_UINT8 *assocInfo, A_UINT16 protocolReasonStatus);
4181 +void ar6000_tkip_micerr_event(struct ar6_softc *ar, A_UINT8 keyid,
4183 +void ar6000_bitrate_rx(void *devt, A_INT32 rateKbps);
4184 +void ar6000_channelList_rx(void *devt, A_INT8 numChan, A_UINT16 *chanList);
4185 +void ar6000_regDomain_event(struct ar6_softc *ar, A_UINT32 regCode);
4186 +void ar6000_txPwr_rx(void *devt, A_UINT8 txPwr);
4187 +void ar6000_keepalive_rx(void *devt, A_UINT8 configured);
4188 +void ar6000_neighborReport_event(struct ar6_softc *ar, int numAps,
4189 + WMI_NEIGHBOR_INFO *info);
4190 +void ar6000_set_numdataendpts(struct ar6_softc *ar, A_UINT32 num);
4191 +void ar6000_scanComplete_event(struct ar6_softc *ar, A_STATUS status);
4192 +void ar6000_targetStats_event(struct ar6_softc *ar, WMI_TARGET_STATS *pStats);
4193 +void ar6000_rssiThreshold_event(struct ar6_softc *ar,
4194 + WMI_RSSI_THRESHOLD_VAL newThreshold,
4196 +void ar6000_reportError_event(struct ar6_softc *, WMI_TARGET_ERROR_VAL errorVal);
4197 +void ar6000_cac_event(struct ar6_softc *ar, A_UINT8 ac, A_UINT8 cac_indication,
4198 + A_UINT8 statusCode, A_UINT8 *tspecSuggestion);
4199 +void ar6000_hbChallengeResp_event(struct ar6_softc *, A_UINT32 cookie, A_UINT32 source);
4201 +ar6000_roam_tbl_event(struct ar6_softc *ar, WMI_TARGET_ROAM_TBL *pTbl);
4204 +ar6000_roam_data_event(struct ar6_softc *ar, WMI_TARGET_ROAM_DATA *p);
4207 +ar6000_wow_list_event(struct ar6_softc *ar, A_UINT8 num_filters,
4208 + WMI_GET_WOW_LIST_REPLY *wow_reply);
4210 +void ar6000_pmkid_list_event(void *devt, A_UINT8 numPMKID,
4211 + WMI_PMKID *pmkidList);
4213 +void ar6000_gpio_intr_rx(A_UINT32 intr_mask, A_UINT32 input_values);
4214 +void ar6000_gpio_data_rx(A_UINT32 reg_id, A_UINT32 value);
4215 +void ar6000_gpio_ack_rx(void);
4217 +void ar6000_dbglog_init_done(struct ar6_softc *ar);
4219 +#ifdef SEND_EVENT_TO_APP
4220 +void ar6000_send_event_to_app(struct ar6_softc *ar, A_UINT16 eventId, A_UINT8 *datap, int len);
4223 +#ifdef CONFIG_HOST_TCMD_SUPPORT
4224 +void ar6000_tcmd_rx_report_event(void *devt, A_UINT8 * results, int len);
4227 +void ar6000_tx_retry_err_event(void *devt);
4229 +void ar6000_snrThresholdEvent_rx(void *devt,
4230 + WMI_SNR_THRESHOLD_VAL newThreshold,
4233 +void ar6000_lqThresholdEvent_rx(void *devt, WMI_LQ_THRESHOLD_VAL range, A_UINT8 lqVal);
4236 +void ar6000_ratemask_rx(void *devt, A_UINT16 ratemask);
4238 +A_STATUS ar6000_get_driver_cfg(struct net_device *dev,
4239 + A_UINT16 cfgParam,
4241 +void ar6000_bssInfo_event_rx(struct ar6_softc *ar, A_UINT8 *data, int len);
4243 +void ar6000_dbglog_event(struct ar6_softc *ar, A_UINT32 dropped,
4244 + A_INT8 *buffer, A_UINT32 length);
4246 +int ar6000_dbglog_get_debug_logs(struct ar6_softc *ar);
4248 +void ar6000_indicate_tx_activity(void *devt, A_UINT8 trafficClass, A_BOOL Active);
4250 +void ar6000_dset_open_req(void *devt,
4252 + A_UINT32 targ_handle,
4253 + A_UINT32 targ_reply_fn,
4254 + A_UINT32 targ_reply_arg);
4255 +void ar6000_dset_close(void *devt, A_UINT32 access_cookie);
4256 +void ar6000_dset_data_req(void *devt,
4257 + A_UINT32 access_cookie,
4260 + A_UINT32 targ_buf,
4261 + A_UINT32 targ_reply_fn,
4262 + A_UINT32 targ_reply_arg);
4271 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/athdrv_linux.h b/drivers/sdio/function/wlan/ar6000/ar6000/athdrv_linux.h
4272 new file mode 100644
4273 index 0000000..9c3e449
4275 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/athdrv_linux.h
4278 + * Copyright (c) 2004-2006 Atheros Communications Inc.
4279 + * All rights reserved.
4283 + * This program is free software; you can redistribute it and/or modify
4284 + * it under the terms of the GNU General Public License version 2 as
4285 + * published by the Free Software Foundation;
4287 + * Software distributed under the License is distributed on an "AS
4288 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
4289 + * implied. See the License for the specific language governing
4290 + * rights and limitations under the License.
4296 +#ifndef _ATHDRV_LINUX_H
4297 +#define _ATHDRV_LINUX_H
4305 + * There are two types of ioctl's here: Standard ioctls and
4306 + * eXtended ioctls. All extended ioctls (XIOCTL) are multiplexed
4307 + * off of the single ioctl command, AR6000_IOCTL_EXTENDED. The
4308 + * arguments for every XIOCTL starts with a 32-bit command word
4309 + * that is used to select which extended ioctl is in use. After
4310 + * the command word are command-specific arguments.
4313 +/* Linux standard Wireless Extensions, private ioctl interfaces */
4314 +#define IEEE80211_IOCTL_SETPARAM (SIOCIWFIRSTPRIV+0)
4315 +#define IEEE80211_IOCTL_GETPARAM (SIOCIWFIRSTPRIV+1)
4316 +#define IEEE80211_IOCTL_SETKEY (SIOCIWFIRSTPRIV+2)
4317 +#define IEEE80211_IOCTL_SETWMMPARAMS (SIOCIWFIRSTPRIV+3)
4318 +#define IEEE80211_IOCTL_DELKEY (SIOCIWFIRSTPRIV+4)
4319 +#define IEEE80211_IOCTL_GETWMMPARAMS (SIOCIWFIRSTPRIV+5)
4320 +#define IEEE80211_IOCTL_SETOPTIE (SIOCIWFIRSTPRIV+6)
4321 +#define IEEE80211_IOCTL_SETMLME (SIOCIWFIRSTPRIV+7)
4322 +//#define IEEE80211_IOCTL_GETOPTIE (SIOCIWFIRSTPRIV+7)
4323 +#define IEEE80211_IOCTL_ADDPMKID (SIOCIWFIRSTPRIV+8)
4324 +//#define IEEE80211_IOCTL_SETAUTHALG (SIOCIWFIRSTPRIV+10)
4325 +#define IEEE80211_IOCTL_LASTONE (SIOCIWFIRSTPRIV+9)
4329 +/* ====WMI Ioctls==== */
4332 + * Many ioctls simply provide WMI services to application code:
4333 + * an application makes such an ioctl call with a set of arguments
4334 + * that are packaged into the corresponding WMI message, and sent
4338 +#define AR6000_IOCTL_WMI_GETREV (SIOCIWFIRSTPRIV+10)
4341 + * ar6000_version *revision
4344 +#define AR6000_IOCTL_WMI_SETPWR (SIOCIWFIRSTPRIV+11)
4347 + * WMI_POWER_MODE_CMD pwrModeCmd (see include/wmi.h)
4348 + * uses: WMI_SET_POWER_MODE_CMDID
4351 +#define AR6000_IOCTL_WMI_SETSCAN (SIOCIWFIRSTPRIV+12)
4354 + * WMI_SCAN_PARAMS_CMD scanParams (see include/wmi.h)
4355 + * uses: WMI_SET_SCAN_PARAMS_CMDID
4358 +#define AR6000_IOCTL_WMI_SETLISTENINT (SIOCIWFIRSTPRIV+13)
4361 + * UINT32 listenInterval
4362 + * uses: WMI_SET_LISTEN_INT_CMDID
4365 +#define AR6000_IOCTL_WMI_SETBSSFILTER (SIOCIWFIRSTPRIV+14)
4368 + * WMI_BSS_FILTER filter (see include/wmi.h)
4369 + * uses: WMI_SET_BSS_FILTER_CMDID
4372 +#define AR6000_IOCTL_WMI_SET_CHANNELPARAMS (SIOCIWFIRSTPRIV+16)
4375 + * WMI_CHANNEL_PARAMS_CMD chParams
4376 + * uses: WMI_SET_CHANNEL_PARAMS_CMDID
4379 +#define AR6000_IOCTL_WMI_SET_PROBEDSSID (SIOCIWFIRSTPRIV+17)
4382 + * WMI_PROBED_SSID_CMD probedSsids (see include/wmi.h)
4383 + * uses: WMI_SETPROBED_SSID_CMDID
4386 +#define AR6000_IOCTL_WMI_SET_PMPARAMS (SIOCIWFIRSTPRIV+18)
4389 + * WMI_POWER_PARAMS_CMD powerParams (see include/wmi.h)
4390 + * uses: WMI_SET_POWER_PARAMS_CMDID
4393 +#define AR6000_IOCTL_WMI_SET_BADAP (SIOCIWFIRSTPRIV+19)
4396 + * WMI_ADD_BAD_AP_CMD badAPs (see include/wmi.h)
4397 + * uses: WMI_ADD_BAD_AP_CMDID
4400 +#define AR6000_IOCTL_WMI_GET_QOS_QUEUE (SIOCIWFIRSTPRIV+20)
4403 + * ar6000_queuereq queueRequest (see below)
4406 +#define AR6000_IOCTL_WMI_CREATE_QOS (SIOCIWFIRSTPRIV+21)
4409 + * WMI_CREATE_PSTREAM createPstreamCmd (see include/wmi.h)
4410 + * uses: WMI_CREATE_PSTREAM_CMDID
4413 +#define AR6000_IOCTL_WMI_DELETE_QOS (SIOCIWFIRSTPRIV+22)
4416 + * WMI_DELETE_PSTREAM_CMD deletePstreamCmd (see include/wmi.h)
4417 + * uses: WMI_DELETE_PSTREAM_CMDID
4420 +#define AR6000_IOCTL_WMI_SET_SNRTHRESHOLD (SIOCIWFIRSTPRIV+23)
4423 + * WMI_SNR_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h)
4424 + * uses: WMI_SNR_THRESHOLD_PARAMS_CMDID
4427 +#define AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK (SIOCIWFIRSTPRIV+24)
4430 + * WMI_TARGET_ERROR_REPORT_BITMASK errorReportBitMask (see include/wmi.h)
4431 + * uses: WMI_TARGET_ERROR_REPORT_BITMASK_CMDID
4434 +#define AR6000_IOCTL_WMI_GET_TARGET_STATS (SIOCIWFIRSTPRIV+25)
4437 + * TARGET_STATS *targetStats (see below)
4438 + * uses: WMI_GET_STATISTICS_CMDID
4441 +#define AR6000_IOCTL_WMI_SET_ASSOC_INFO (SIOCIWFIRSTPRIV+26)
4444 + * WMI_SET_ASSOC_INFO_CMD setAssocInfoCmd
4445 + * uses: WMI_SET_ASSOC_INFO_CMDID
4448 +#define AR6000_IOCTL_WMI_SET_ACCESS_PARAMS (SIOCIWFIRSTPRIV+27)
4451 + * WMI_SET_ACCESS_PARAMS_CMD setAccessParams (see include/wmi.h)
4452 + * uses: WMI_SET_ACCESS_PARAMS_CMDID
4455 +#define AR6000_IOCTL_WMI_SET_BMISS_TIME (SIOCIWFIRSTPRIV+28)
4458 + * UINT32 beaconMissTime
4459 + * uses: WMI_SET_BMISS_TIME_CMDID
4462 +#define AR6000_IOCTL_WMI_SET_DISC_TIMEOUT (SIOCIWFIRSTPRIV+29)
4465 + * WMI_DISC_TIMEOUT_CMD disconnectTimeoutCmd (see include/wmi.h)
4466 + * uses: WMI_SET_DISC_TIMEOUT_CMDID
4469 +#define AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS (SIOCIWFIRSTPRIV+30)
4472 + * WMI_IBSS_PM_CAPS_CMD ibssPowerMgmtCapsCmd
4473 + * uses: WMI_SET_IBSS_PM_CAPS_CMDID
4477 + * There is a very small space available for driver-private
4478 + * wireless ioctls. In order to circumvent this limitation,
4479 + * we multiplex a bunch of ioctls (XIOCTLs) on top of a
4480 + * single AR6000_IOCTL_EXTENDED ioctl.
4482 +#define AR6000_IOCTL_EXTENDED (SIOCIWFIRSTPRIV+31)
4485 +/* ====BMI Extended Ioctls==== */
4487 +#define AR6000_XIOCTL_BMI_DONE 1
4490 + * UINT32 cmd (AR6000_XIOCTL_BMI_DONE)
4494 +#define AR6000_XIOCTL_BMI_READ_MEMORY 2
4499 + * UINT32 cmd (AR6000_XIOCTL_BMI_READ_MEMORY)
4503 + * char results[length]
4505 + * uses: BMI_READ_MEMORY
4508 +#define AR6000_XIOCTL_BMI_WRITE_MEMORY 3
4511 + * UINT32 cmd (AR6000_XIOCTL_BMI_WRITE_MEMORY)
4514 + * char data[length]
4515 + * uses: BMI_WRITE_MEMORY
4518 +#define AR6000_XIOCTL_BMI_EXECUTE 4
4521 + * UINT32 cmd (AR6000_XIOCTL_BMI_EXECUTE)
4522 + * UINT32 TargetAddress
4523 + * UINT32 parameter
4524 + * uses: BMI_EXECUTE
4527 +#define AR6000_XIOCTL_BMI_SET_APP_START 5
4530 + * UINT32 cmd (AR6000_XIOCTL_BMI_SET_APP_START)
4531 + * UINT32 TargetAddress
4532 + * uses: BMI_SET_APP_START
4535 +#define AR6000_XIOCTL_BMI_READ_SOC_REGISTER 6
4540 + * UINT32 cmd (AR6000_XIOCTL_BMI_READ_SOC_REGISTER)
4541 + * UINT32 TargetAddress, 32-bit aligned
4545 + * uses: BMI_READ_SOC_REGISTER
4548 +#define AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER 7
4552 + * UINT32 cmd (AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER)
4553 + * UINT32 TargetAddress, 32-bit aligned
4556 + * uses: BMI_WRITE_SOC_REGISTER
4559 +#define AR6000_XIOCTL_BMI_TEST 8
4562 + * UINT32 cmd (AR6000_XIOCTL_BMI_TEST)
4570 +/* Historical Host-side DataSet support */
4571 +#define AR6000_XIOCTL_UNUSED9 9
4572 +#define AR6000_XIOCTL_UNUSED10 10
4573 +#define AR6000_XIOCTL_UNUSED11 11
4575 +/* ====Misc Extended Ioctls==== */
4577 +#define AR6000_XIOCTL_FORCE_TARGET_RESET 12
4580 + * UINT32 cmd (AR6000_XIOCTL_FORCE_TARGET_RESET)
4584 +#ifdef HTC_RAW_INTERFACE
4585 +/* HTC Raw Interface Ioctls */
4586 +#define AR6000_XIOCTL_HTC_RAW_OPEN 13
4589 + * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_OPEN)
4592 +#define AR6000_XIOCTL_HTC_RAW_CLOSE 14
4595 + * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_CLOSE)
4598 +#define AR6000_XIOCTL_HTC_RAW_READ 15
4603 + * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_READ)
4604 + * UINT32 mailboxID
4611 +#define AR6000_XIOCTL_HTC_RAW_WRITE 16
4614 + * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_WRITE)
4615 + * UINT32 mailboxID
4617 + * char buffer[length]
4619 +#endif /* HTC_RAW_INTERFACE */
4621 +#define AR6000_XIOCTL_CHECK_TARGET_READY 17
4624 + * UINT32 cmd (AR6000_XIOCTL_CHECK_TARGET_READY)
4629 +/* ====GPIO (General Purpose I/O) Extended Ioctls==== */
4631 +#define AR6000_XIOCTL_GPIO_OUTPUT_SET 18
4634 + * UINT32 cmd (AR6000_XIOCTL_GPIO_OUTPUT_SET)
4635 + * ar6000_gpio_output_set_cmd_s (see below)
4636 + * uses: WMIX_GPIO_OUTPUT_SET_CMDID
4639 +#define AR6000_XIOCTL_GPIO_INPUT_GET 19
4642 + * UINT32 cmd (AR6000_XIOCTL_GPIO_INPUT_GET)
4643 + * uses: WMIX_GPIO_INPUT_GET_CMDID
4646 +#define AR6000_XIOCTL_GPIO_REGISTER_SET 20
4649 + * UINT32 cmd (AR6000_XIOCTL_GPIO_REGISTER_SET)
4650 + * ar6000_gpio_register_cmd_s (see below)
4651 + * uses: WMIX_GPIO_REGISTER_SET_CMDID
4654 +#define AR6000_XIOCTL_GPIO_REGISTER_GET 21
4657 + * UINT32 cmd (AR6000_XIOCTL_GPIO_REGISTER_GET)
4658 + * ar6000_gpio_register_cmd_s (see below)
4659 + * uses: WMIX_GPIO_REGISTER_GET_CMDID
4662 +#define AR6000_XIOCTL_GPIO_INTR_ACK 22
4665 + * UINT32 cmd (AR6000_XIOCTL_GPIO_INTR_ACK)
4666 + * ar6000_cpio_intr_ack_cmd_s (see below)
4667 + * uses: WMIX_GPIO_INTR_ACK_CMDID
4670 +#define AR6000_XIOCTL_GPIO_INTR_WAIT 23
4673 + * UINT32 cmd (AR6000_XIOCTL_GPIO_INTR_WAIT)
4678 +/* ====more wireless commands==== */
4680 +#define AR6000_XIOCTL_SET_ADHOC_BSSID 24
4683 + * UINT32 cmd (AR6000_XIOCTL_SET_ADHOC_BSSID)
4684 + * WMI_SET_ADHOC_BSSID_CMD setAdHocBssidCmd (see include/wmi.h)
4687 +#define AR6000_XIOCTL_SET_OPT_MODE 25
4690 + * UINT32 cmd (AR6000_XIOCTL_SET_OPT_MODE)
4691 + * WMI_SET_OPT_MODE_CMD setOptModeCmd (see include/wmi.h)
4692 + * uses: WMI_SET_OPT_MODE_CMDID
4695 +#define AR6000_XIOCTL_OPT_SEND_FRAME 26
4698 + * UINT32 cmd (AR6000_XIOCTL_OPT_SEND_FRAME)
4699 + * WMI_OPT_TX_FRAME_CMD optTxFrameCmd (see include/wmi.h)
4700 + * uses: WMI_OPT_TX_FRAME_CMDID
4703 +#define AR6000_XIOCTL_SET_ADHOC_BEACON_INTVAL 27
4706 + * UINT32 cmd (AR6000_XIOCTL_SET_ADHOC_BEACON_INTVAL)
4707 + * WMI_BEACON_INT_CMD beaconIntCmd (see include/wmi.h)
4708 + * uses: WMI_SET_BEACON_INT_CMDID
4712 +#define IEEE80211_IOCTL_SETAUTHALG 28
4715 +#define AR6000_XIOCTL_SET_VOICE_PKT_SIZE 29
4718 + * UINT32 cmd (AR6000_XIOCTL_SET_VOICE_PKT_SIZE)
4719 + * WMI_SET_VOICE_PKT_SIZE_CMD setVoicePktSizeCmd (see include/wmi.h)
4720 + * uses: WMI_SET_VOICE_PKT_SIZE_CMDID
4724 +#define AR6000_XIOCTL_SET_MAX_SP 30
4727 + * UINT32 cmd (AR6000_XIOCTL_SET_MAX_SP)
4728 + * WMI_SET_MAX_SP_LEN_CMD maxSPLen(see include/wmi.h)
4729 + * uses: WMI_SET_MAX_SP_LEN_CMDID
4732 +#define AR6000_XIOCTL_WMI_GET_ROAM_TBL 31
4734 +#define AR6000_XIOCTL_WMI_SET_ROAM_CTRL 32
4736 +#define AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS 33
4741 + * UINT32 cmd (AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS)
4742 + * WMI_SET_POWERSAVE_TIMERS_CMD powerSaveTimers(see include/wmi.h)
4743 + * WMI_SET_POWERSAVE_TIMERS_CMDID
4746 +#define AR6000_XIOCTRL_WMI_GET_POWER_MODE 34
4749 + * UINT32 cmd (AR6000_XIOCTRL_WMI_GET_POWER_MODE)
4752 +#define AR6000_XIOCTRL_WMI_SET_WLAN_STATE 35
4756 +} AR6000_WLAN_STATE;
4762 +#define AR6000_XIOCTL_WMI_GET_ROAM_DATA 36
4764 +#define AR6000_XIOCTL_WMI_SETRETRYLIMITS 37
4767 + * WMI_SET_RETRY_LIMITS_CMD ibssSetRetryLimitsCmd
4768 + * uses: WMI_SET_RETRY_LIMITS_CMDID
4771 +#ifdef CONFIG_HOST_TCMD_SUPPORT
4772 +/* ====extended commands for radio test ==== */
4774 +#define AR6000_XIOCTL_TCMD_CONT_TX 38
4777 + * UINT32 cmd (AR6000_XIOCTL_TCMD_CONT_TX)
4778 + * WMI_TCMD_CONT_TX_CMD contTxCmd (see include/wmi.h)
4779 + * uses: WMI_TCMD_CONT_TX_CMDID
4782 +#define AR6000_XIOCTL_TCMD_CONT_RX 39
4785 + * UINT32 cmd (AR6000_XIOCTL_TCMD_CONT_RX)
4786 + * WMI_TCMD_CONT_RX_CMD rxCmd (see include/wmi.h)
4787 + * uses: WMI_TCMD_CONT_RX_CMDID
4790 +#define AR6000_XIOCTL_TCMD_PM 40
4793 + * UINT32 cmd (AR6000_XIOCTL_TCMD_PM)
4794 + * WMI_TCMD_PM_CMD pmCmd (see include/wmi.h)
4795 + * uses: WMI_TCMD_PM_CMDID
4798 +#endif /* CONFIG_HOST_TCMD_SUPPORT */
4800 +#define AR6000_XIOCTL_WMI_STARTSCAN 41
4803 + * UINT32 cmd (AR6000_XIOCTL_WMI_STARTSCAN)
4805 + * UINT8 scanConnected
4806 + * A_BOOL forceFgScan
4807 + * uses: WMI_START_SCAN_CMDID
4810 +#define AR6000_XIOCTL_WMI_SETFIXRATES 42
4812 +#define AR6000_XIOCTL_WMI_GETFIXRATES 43
4815 +#define AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD 44
4818 + * WMI_RSSI_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h)
4819 + * uses: WMI_RSSI_THRESHOLD_PARAMS_CMDID
4822 +#define AR6000_XIOCTL_WMI_CLR_RSSISNR 45
4825 + * WMI_CLR_RSSISNR_CMD thresholdParams (see include/wmi.h)
4826 + * uses: WMI_CLR_RSSISNR_CMDID
4829 +#define AR6000_XIOCTL_WMI_SET_LQTHRESHOLD 46
4832 + * WMI_LQ_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h)
4833 + * uses: WMI_LQ_THRESHOLD_PARAMS_CMDID
4836 +#define AR6000_XIOCTL_WMI_SET_RTS 47
4839 + * WMI_SET_RTS_MODE_CMD (see include/wmi.h)
4840 + * uses: WMI_SET_RTS_MODE_CMDID
4843 +#define AR6000_XIOCTL_WMI_SET_LPREAMBLE 48
4845 +#define AR6000_XIOCTL_WMI_SET_AUTHMODE 49
4848 + * UINT32 cmd (AR6000_XIOCTL_WMI_SET_AUTHMODE)
4850 + * uses: WMI_SET_RECONNECT_AUTH_MODE_CMDID
4853 +#define AR6000_XIOCTL_WMI_SET_REASSOCMODE 50
4857 + * UINT32 cmd (AR6000_XIOCTL_WMI_SET_WMM)
4859 + * uses: WMI_SET_WMM_CMDID
4861 +#define AR6000_XIOCTL_WMI_SET_WMM 51
4865 + * UINT32 cmd (AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS)
4866 + * UINT32 frequency
4869 +#define AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS 52
4873 + * UINT32 cmd (AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP)
4876 +#define AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP 53
4880 + * UINT32 cmd (AR6000_XIOCTL_WMI_GET_RD)
4881 + * UINT32 regDomain
4883 +#define AR6000_XIOCTL_WMI_GET_RD 54
4885 +#define AR6000_XIOCTL_DIAG_READ 55
4887 +#define AR6000_XIOCTL_DIAG_WRITE 56
4890 + * arguments cmd (AR6000_XIOCTL_SET_TXOP)
4891 + * WMI_TXOP_CFG txopEnable
4893 +#define AR6000_XIOCTL_WMI_SET_TXOP 57
4898 + * UINT32 cmd (AR6000_XIOCTL_USER_SETKEYS)
4899 + * UINT32 keyOpCtrl
4900 + * uses AR6000_USER_SETKEYS_INFO
4902 +#define AR6000_XIOCTL_USER_SETKEYS 58
4903 +#endif /* USER_KEYS */
4905 +#define AR6000_XIOCTL_WMI_SET_KEEPALIVE 59
4908 + * UINT8 cmd (AR6000_XIOCTL_WMI_SET_KEEPALIVE)
4909 + * UINT8 keepaliveInterval
4910 + * uses: WMI_SET_KEEPALIVE_CMDID
4913 +#define AR6000_XIOCTL_WMI_GET_KEEPALIVE 60
4916 + * UINT8 cmd (AR6000_XIOCTL_WMI_GET_KEEPALIVE)
4917 + * UINT8 keepaliveInterval
4918 + * A_BOOL configured
4919 + * uses: WMI_GET_KEEPALIVE_CMDID
4922 +/* ====ROM Patching Extended Ioctls==== */
4924 +#define AR6000_XIOCTL_BMI_ROMPATCH_INSTALL 61
4929 + * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_INSTALL)
4930 + * UINT32 ROM Address
4931 + * UINT32 RAM Address
4932 + * UINT32 number of bytes
4933 + * UINT32 activate? (0 or 1)
4935 + * A_UINT32 resulting rompatch ID
4937 + * uses: BMI_ROMPATCH_INSTALL
4940 +#define AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL 62
4944 + * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL)
4945 + * UINT32 rompatch ID
4947 + * uses: BMI_ROMPATCH_UNINSTALL
4950 +#define AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE 63
4954 + * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE)
4955 + * UINT32 rompatch count
4956 + * UINT32 rompatch IDs[rompatch count]
4958 + * uses: BMI_ROMPATCH_ACTIVATE
4961 +#define AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE 64
4965 + * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE)
4966 + * UINT32 rompatch count
4967 + * UINT32 rompatch IDs[rompatch count]
4969 + * uses: BMI_ROMPATCH_DEACTIVATE
4972 +#define AR6000_XIOCTL_WMI_SET_APPIE 65
4976 + * UINT32 cmd (AR6000_XIOCTL_WMI_SET_APPIE)
4977 + * UINT32 app_frmtype;
4978 + * UINT32 app_buflen;
4979 + * UINT8 app_buf[];
4982 +#define AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER 66
4985 + * A_UINT32 filter_type;
4988 +#define AR6000_XIOCTL_DBGLOG_CFG_MODULE 67
4990 +#define AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS 68
4992 +#define AR6000_XIOCTL_WMI_SET_WSC_STATUS 70
4995 + * A_UINT32 wsc_status;
4996 + * (WSC_REG_INACTIVE or WSC_REG_ACTIVE)
5002 + * A_UINT8 streamType;
5005 + * uses: WMI_SET_BT_STATUS_CMDID
5007 +#define AR6000_XIOCTL_WMI_SET_BT_STATUS 71
5012 + * A_UINT8 paramType;
5014 + * A_UINT8 noSCOPkts;
5015 + * BT_PARAMS_A2DP a2dpParams;
5016 + * BT_COEX_REGS regs;
5019 + * uses: WMI_SET_BT_PARAM_CMDID
5021 +#define AR6000_XIOCTL_WMI_SET_BT_PARAMS 72
5023 +#define AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE 73
5024 +#define AR6000_XIOCTL_WMI_SET_WOW_MODE 74
5025 +#define AR6000_XIOCTL_WMI_GET_WOW_LIST 75
5026 +#define AR6000_XIOCTL_WMI_ADD_WOW_PATTERN 76
5027 +#define AR6000_XIOCTL_WMI_DEL_WOW_PATTERN 77
5031 +#define AR6000_XIOCTL_TARGET_INFO 78
5034 + * UINT32 cmd (AR6000_XIOCTL_TARGET_INFO)
5035 + * A_UINT32 TargetVersion (returned)
5036 + * A_UINT32 TargetType (returned)
5037 + * (See also bmi_msg.h target_ver and target_type)
5040 +#define AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE 79
5046 +#define AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE 80
5048 + * This ioctl is used to emulate traffic activity
5049 + * timeouts. Activity/inactivity will trigger the driver
5050 + * to re-balance credits.
5053 + * ar6000_traffic_activity_change
5056 +#define AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS 81
5058 + * This ioctl is used to set the connect control flags
5061 + * A_UINT32 connectCtrlFlags
5064 +#define AR6000_XIOCTL_WMI_SET_AKMP_PARAMS 82
5066 + * This IOCTL sets any Authentication,Key Management and Protection
5067 + * related parameters. This is used along with the information set in
5068 + * Connect Command.
5069 + * Currently this enables Multiple PMKIDs to an AP.
5073 + * A_UINT32 akmpInfo;
5075 + * uses: WMI_SET_AKMP_PARAMS_CMD
5078 +#define AR6000_XIOCTL_WMI_GET_PMKID_LIST 83
5080 +#define AR6000_XIOCTL_WMI_SET_PMKID_LIST 84
5082 + * This IOCTL is used to set a list of PMKIDs. This list of
5083 + * PMKIDs is used in the [Re]AssocReq Frame. This list is used
5084 + * only if the MultiPMKID option is enabled via the
5085 + * AR6000_XIOCTL_WMI_SET_AKMP_PARAMS IOCTL.
5089 + * A_UINT32 numPMKID;
5090 + * WMI_PMKID pmkidList[WMI_MAX_PMKID_CACHE];
5092 + * uses: WMI_SET_PMKIDLIST_CMD
5095 +/* Historical DSETPATCH support for INI patches */
5096 +#define AR6000_XIOCTL_UNUSED90 90
5100 +/* used by AR6000_IOCTL_WMI_GETREV */
5101 +struct ar6000_version {
5102 + A_UINT32 host_ver;
5103 + A_UINT32 target_ver;
5106 +/* used by AR6000_IOCTL_WMI_GET_QOS_QUEUE */
5107 +struct ar6000_queuereq {
5108 + A_UINT8 trafficClass;
5109 + A_UINT16 activeTsids;
5112 +/* used by AR6000_IOCTL_WMI_GET_TARGET_STATS */
5113 +typedef struct targetStats_t {
5114 + A_UINT64 tx_packets;
5115 + A_UINT64 tx_bytes;
5116 + A_UINT64 tx_unicast_pkts;
5117 + A_UINT64 tx_unicast_bytes;
5118 + A_UINT64 tx_multicast_pkts;
5119 + A_UINT64 tx_multicast_bytes;
5120 + A_UINT64 tx_broadcast_pkts;
5121 + A_UINT64 tx_broadcast_bytes;
5122 + A_UINT64 tx_rts_success_cnt;
5123 + A_UINT64 tx_packet_per_ac[4];
5125 + A_UINT64 tx_errors;
5126 + A_UINT64 tx_failed_cnt;
5127 + A_UINT64 tx_retry_cnt;
5128 + A_UINT64 tx_rts_fail_cnt;
5129 + A_INT32 tx_unicast_rate;
5130 + A_UINT64 rx_packets;
5131 + A_UINT64 rx_bytes;
5132 + A_UINT64 rx_unicast_pkts;
5133 + A_UINT64 rx_unicast_bytes;
5134 + A_UINT64 rx_multicast_pkts;
5135 + A_UINT64 rx_multicast_bytes;
5136 + A_UINT64 rx_broadcast_pkts;
5137 + A_UINT64 rx_broadcast_bytes;
5138 + A_UINT64 rx_fragment_pkt;
5140 + A_UINT64 rx_errors;
5141 + A_UINT64 rx_crcerr;
5142 + A_UINT64 rx_key_cache_miss;
5143 + A_UINT64 rx_decrypt_err;
5144 + A_UINT64 rx_duplicate_frames;
5145 + A_INT32 rx_unicast_rate;
5147 + A_UINT64 tkip_local_mic_failure;
5148 + A_UINT64 tkip_counter_measures_invoked;
5149 + A_UINT64 tkip_replays;
5150 + A_UINT64 tkip_format_errors;
5151 + A_UINT64 ccmp_format_errors;
5152 + A_UINT64 ccmp_replays;
5154 + A_UINT64 power_save_failure_cnt;
5155 + A_INT16 noise_floor_calibation;
5157 + A_UINT64 cs_bmiss_cnt;
5158 + A_UINT64 cs_lowRssi_cnt;
5159 + A_UINT64 cs_connect_cnt;
5160 + A_UINT64 cs_disconnect_cnt;
5161 + A_UINT8 cs_aveBeacon_snr;
5162 + A_INT16 cs_aveBeacon_rssi;
5163 + A_UINT8 cs_lastRoam_msec;
5169 + A_UINT32 wow_num_pkts_dropped;
5170 + A_UINT8 wow_num_host_pkt_wakeups;
5171 + A_UINT8 wow_num_host_event_wakeups;
5172 + A_UINT16 wow_num_events_discarded;
5176 +typedef struct targetStats_cmd_t {
5177 + TARGET_STATS targetStats;
5179 +} TARGET_STATS_CMD;
5181 +/* used by AR6000_XIOCTL_USER_SETKEYS */
5184 + * Setting this bit to 1 doesnot initialize the RSC on the firmware
5186 +#define AR6000_XIOCTL_USER_SETKEYS_RSC_CTRL 1
5187 +#define AR6000_USER_SETKEYS_RSC_UNCHANGED 0x00000002
5190 + A_UINT32 keyOpCtrl; /* Bit Map of Key Mgmt Ctrl Flags */
5191 +} AR6000_USER_SETKEYS_INFO;
5194 +/* used by AR6000_XIOCTL_GPIO_OUTPUT_SET */
5195 +struct ar6000_gpio_output_set_cmd_s {
5196 + A_UINT32 set_mask;
5197 + A_UINT32 clear_mask;
5198 + A_UINT32 enable_mask;
5199 + A_UINT32 disable_mask;
5203 + * used by AR6000_XIOCTL_GPIO_REGISTER_GET and AR6000_XIOCTL_GPIO_REGISTER_SET
5205 +struct ar6000_gpio_register_cmd_s {
5206 + A_UINT32 gpioreg_id;
5210 +/* used by AR6000_XIOCTL_GPIO_INTR_ACK */
5211 +struct ar6000_gpio_intr_ack_cmd_s {
5212 + A_UINT32 ack_mask;
5215 +/* used by AR6000_XIOCTL_GPIO_INTR_WAIT */
5216 +struct ar6000_gpio_intr_wait_cmd_s {
5217 + A_UINT32 intr_mask;
5218 + A_UINT32 input_values;
5221 +/* used by the AR6000_XIOCTL_DBGLOG_CFG_MODULE */
5222 +typedef struct ar6000_dbglog_module_config_s {
5228 +} DBGLOG_MODULE_CONFIG;
5230 +typedef struct user_rssi_thold_t {
5235 +typedef struct user_rssi_params_t {
5237 + A_UINT32 pollTime;
5238 + USER_RSSI_THOLD tholds[12];
5239 +} USER_RSSI_PARAMS;
5242 + * Host driver may have some config parameters. Typically, these
5243 + * config params are one time config parameters. These could
5244 + * correspond to any of the underlying modules. Host driver exposes
5245 + * an api for the underlying modules to get this config.
5247 +#define AR6000_DRIVER_CFG_BASE 0x8000
5249 +/* Should driver perform wlan node caching? */
5250 +#define AR6000_DRIVER_CFG_GET_WLANNODECACHING 0x8001
5251 +/*Should we log raw WMI msgs */
5252 +#define AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS 0x8002
5254 +/* used by AR6000_XIOCTL_DIAG_READ & AR6000_XIOCTL_DIAG_WRITE */
5255 +struct ar6000_diag_window_cmd_s {
5256 + unsigned int addr;
5257 + unsigned int value;
5261 +struct ar6000_traffic_activity_change {
5262 + A_UINT32 StreamID; /* stream ID to indicate activity change */
5263 + A_UINT32 Active; /* active (1) or inactive (0) */
5270 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/athtypes_linux.h b/drivers/sdio/function/wlan/ar6000/ar6000/athtypes_linux.h
5271 new file mode 100644
5272 index 0000000..3e91de3
5274 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/athtypes_linux.h
5277 + * $Id: //depot/sw/releases/olca2.0-GPL/host/os/linux/include/athtypes_linux.h#1 $
5279 + * This file contains the definitions of the basic atheros data types.
5280 + * It is used to map the data types in atheros files to a platform specific
5283 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
5286 + * This program is free software; you can redistribute it and/or modify
5287 + * it under the terms of the GNU General Public License version 2 as
5288 + * published by the Free Software Foundation;
5290 + * Software distributed under the License is distributed on an "AS
5291 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
5292 + * implied. See the License for the specific language governing
5293 + * rights and limitations under the License.
5299 +#ifndef _ATHTYPES_LINUX_H_
5300 +#define _ATHTYPES_LINUX_H_
5303 +#include <linux/types.h>
5306 +typedef int8_t A_INT8;
5307 +typedef int16_t A_INT16;
5308 +typedef int32_t A_INT32;
5309 +typedef int64_t A_INT64;
5311 +typedef u_int8_t A_UINT8;
5312 +typedef u_int16_t A_UINT16;
5313 +typedef u_int32_t A_UINT32;
5314 +typedef u_int64_t A_UINT64;
5316 +typedef int A_BOOL;
5317 +typedef char A_CHAR;
5318 +typedef unsigned char A_UCHAR;
5319 +typedef unsigned long A_ATH_TIMER;
5322 +#endif /* _ATHTYPES_LINUX_H_ */
5323 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/config_linux.h b/drivers/sdio/function/wlan/ar6000/ar6000/config_linux.h
5324 new file mode 100644
5325 index 0000000..11a691d
5327 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/config_linux.h
5330 + * Copyright (c) 2004-2007 Atheros Communications Inc.
5331 + * All rights reserved.
5334 + * This program is free software; you can redistribute it and/or modify
5335 + * it under the terms of the GNU General Public License version 2 as
5336 + * published by the Free Software Foundation;
5338 + * Software distributed under the License is distributed on an "AS
5339 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
5340 + * implied. See the License for the specific language governing
5341 + * rights and limitations under the License.
5347 +#ifndef _CONFIG_LINUX_H_
5348 +#define _CONFIG_LINUX_H_
5355 + * Host-side GPIO support is optional.
5356 + * If run-time access to GPIO pins is not required, then
5357 + * this should be changed to #undef.
5359 +#define CONFIG_HOST_GPIO_SUPPORT
5362 + * Host side Test Command support
5364 +#define CONFIG_HOST_TCMD_SUPPORT
5366 +#define USE_4BYTE_REGISTER_ACCESS
5373 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h b/drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h
5374 new file mode 100644
5375 index 0000000..e62e960
5377 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h
5380 + * Copyright (c) 2004-2006 Atheros Communications Inc.
5381 + * All rights reserved.
5384 + * This program is free software; you can redistribute it and/or modify
5385 + * it under the terms of the GNU General Public License version 2 as
5386 + * published by the Free Software Foundation;
5388 + * Software distributed under the License is distributed on an "AS
5389 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
5390 + * implied. See the License for the specific language governing
5391 + * rights and limitations under the License.
5397 +#ifndef _DEBUG_LINUX_H_
5398 +#define _DEBUG_LINUX_H_
5400 +#define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING)
5402 +extern A_UINT32 g_dbg_flags;
5404 +#define DBGFMT "%s() : "
5405 +#define DBGARG __func__
5406 +#define DBGFN A_PRINTF
5408 +/* ------- Debug related stuff ------- */
5410 + ATH_DEBUG_SEND = 0x0001,
5411 + ATH_DEBUG_RECV = 0x0002,
5412 + ATH_DEBUG_SYNC = 0x0004,
5413 + ATH_DEBUG_DUMP = 0x0008,
5414 + ATH_DEBUG_IRQ = 0x0010,
5415 + ATH_DEBUG_TRC = 0x0020,
5416 + ATH_DEBUG_WARN = 0x0040,
5417 + ATH_DEBUG_ERR = 0x0080,
5418 + ATH_LOG_INF = 0x0100,
5419 + ATH_DEBUG_BMI = 0x0110,
5420 + ATH_DEBUG_WMI = 0x0120,
5421 + ATH_DEBUG_HIF = 0x0140,
5422 + ATH_DEBUG_HTC = 0x0180,
5423 + ATH_DEBUG_WLAN = 0x1000,
5424 + ATH_LOG_ERR = 0x1010,
5425 + ATH_DEBUG_ANY = 0xFFFF,
5430 +#define A_DPRINTF(f, a) \
5431 + if(g_dbg_flags & (f)) \
5437 +// TODO FIX usage of A_PRINTF!
5438 +#define AR_DEBUG_LVL_CHECK(lvl) (debughtc & (lvl))
5439 +#define AR_DEBUG_PRINTBUF(buffer, length, desc) do { \
5440 + if (debughtc & ATH_DEBUG_DUMP) { \
5441 + DebugDumpBytes(buffer, length,desc); \
5444 +#define PRINTX_ARG(arg...) arg
5445 +#define AR_DEBUG_PRINTF(flags, args) do { \
5446 + if (debughtc & (flags)) { \
5447 + A_PRINTF(KERN_ALERT PRINTX_ARG args); \
5450 +#define AR_DEBUG_ASSERT(test) do { \
5452 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Debug Assert Caught, File %s, Line: %d, Test:%s \n",__FILE__, __LINE__,#test)); \
5455 +extern int debughtc;
5457 +#define AR_DEBUG_PRINTF(flags, args)
5458 +#define AR_DEBUG_PRINTBUF(buffer, length)
5459 +#define AR_DEBUG_ASSERT(test)
5460 +#define AR_DEBUG_LVL_CHECK(lvl) 0
5461 +#define A_DPRINTF(f, a)
5464 +#endif /* _DEBUG_LINUX_H_ */
5465 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/ioctl.c b/drivers/sdio/function/wlan/ar6000/ar6000/ioctl.c
5466 new file mode 100644
5467 index 0000000..eb712b4
5469 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ioctl.c
5473 + * Copyright (c) 2004-2007 Atheros Communications Inc.
5474 + * All rights reserved.
5477 + * This program is free software; you can redistribute it and/or modify
5478 + * it under the terms of the GNU General Public License version 2 as
5479 + * published by the Free Software Foundation;
5481 + * Software distributed under the License is distributed on an "AS
5482 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
5483 + * implied. See the License for the specific language governing
5484 + * rights and limitations under the License.
5490 +#include "ar6000_drv.h"
5492 +static A_UINT8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5493 +static A_UINT8 null_mac[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
5494 +extern USER_RSSI_THOLD rssi_map[12];
5495 +extern unsigned int wmitimeout;
5496 +extern A_WAITQUEUE_HEAD arEvent;
5497 +extern int tspecCompliance;
5498 +extern int bmienable;
5499 +extern int bypasswmi;
5502 +ar6000_ioctl_get_roam_tbl(struct net_device *dev, struct ifreq *rq)
5504 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5506 + if (ar->arWmiReady == FALSE) {
5510 + if(wmi_get_roam_tbl_cmd(ar->arWmi) != A_OK) {
5518 +ar6000_ioctl_get_roam_data(struct net_device *dev, struct ifreq *rq)
5520 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5522 + if (ar->arWmiReady == FALSE) {
5527 + /* currently assume only roam times are required */
5528 + if(wmi_get_roam_data_cmd(ar->arWmi, ROAM_DATA_TIME) != A_OK) {
5537 +ar6000_ioctl_set_roam_ctrl(struct net_device *dev, char *userdata)
5539 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5540 + WMI_SET_ROAM_CTRL_CMD cmd;
5541 + A_UINT8 size = sizeof(cmd);
5543 + if (ar->arWmiReady == FALSE) {
5548 + if (copy_from_user(&cmd, userdata, size)) {
5552 + if (cmd.roamCtrlType == WMI_SET_HOST_BIAS) {
5553 + if (cmd.info.bssBiasInfo.numBss > 1) {
5554 + size += (cmd.info.bssBiasInfo.numBss - 1) * sizeof(WMI_BSS_BIAS);
5558 + if (copy_from_user(&cmd, userdata, size)) {
5562 + if(wmi_set_roam_ctrl_cmd(ar->arWmi, &cmd, size) != A_OK) {
5570 +ar6000_ioctl_set_powersave_timers(struct net_device *dev, char *userdata)
5572 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5573 + WMI_POWERSAVE_TIMERS_POLICY_CMD cmd;
5574 + A_UINT8 size = sizeof(cmd);
5576 + if (ar->arWmiReady == FALSE) {
5580 + if (copy_from_user(&cmd, userdata, size)) {
5584 + if (copy_from_user(&cmd, userdata, size)) {
5588 + if(wmi_set_powersave_timers_cmd(ar->arWmi, &cmd, size) != A_OK) {
5596 +ar6000_ioctl_set_wmm(struct net_device *dev, struct ifreq *rq)
5598 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5599 + WMI_SET_WMM_CMD cmd;
5602 + if ((dev->flags & IFF_UP) != IFF_UP) {
5605 + if (ar->arWmiReady == FALSE) {
5609 + if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
5615 + if (cmd.status == WMI_WMM_ENABLED) {
5616 + ar->arWmmEnabled = TRUE;
5618 + ar->arWmmEnabled = FALSE;
5621 + ret = wmi_set_wmm_cmd(ar->arWmi, cmd.status);
5637 +ar6000_ioctl_set_txop(struct net_device *dev, struct ifreq *rq)
5639 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5640 + WMI_SET_WMM_TXOP_CMD cmd;
5643 + if ((dev->flags & IFF_UP) != IFF_UP) {
5646 + if (ar->arWmiReady == FALSE) {
5650 + if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
5656 + ret = wmi_set_wmm_txop(ar->arWmi, cmd.txopEnable);
5672 +ar6000_ioctl_get_rd(struct net_device *dev, struct ifreq *rq)
5674 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5677 + if ((dev->flags & IFF_UP) != IFF_UP || ar->arWmiReady == FALSE) {
5681 + if(copy_to_user((char *)((unsigned int*)rq->ifr_data + 1),
5682 + &ar->arRegCode, sizeof(ar->arRegCode)))
5689 +/* Get power mode command */
5691 +ar6000_ioctl_get_power_mode(struct net_device *dev, struct ifreq *rq)
5693 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5694 + WMI_POWER_MODE_CMD power_mode;
5697 + if (ar->arWmiReady == FALSE) {
5701 + power_mode.powerMode = wmi_get_power_mode_cmd(ar->arWmi);
5702 + if (copy_to_user(rq->ifr_data, &power_mode, sizeof(WMI_POWER_MODE_CMD))) {
5711 +ar6000_ioctl_set_channelParams(struct net_device *dev, struct ifreq *rq)
5713 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5714 + WMI_CHANNEL_PARAMS_CMD cmd, *cmdp;
5717 + if (ar->arWmiReady == FALSE) {
5722 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5726 + if (cmd.numChannels > 1) {
5727 + cmdp = A_MALLOC(130);
5728 + if (copy_from_user(cmdp, rq->ifr_data,
5730 + ((cmd.numChannels - 1) * sizeof(A_UINT16))))
5739 + if ((ar->arPhyCapability == WMI_11G_CAPABILITY) &&
5740 + ((cmdp->phyMode == WMI_11A_MODE) || (cmdp->phyMode == WMI_11AG_MODE)))
5746 + (wmi_set_channelParams_cmd(ar->arWmi, cmdp->scanParam, cmdp->phyMode,
5747 + cmdp->numChannels, cmdp->channelList)
5753 + if (cmd.numChannels > 1) {
5761 +ar6000_ioctl_set_snr_threshold(struct net_device *dev, struct ifreq *rq)
5764 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5765 + WMI_SNR_THRESHOLD_PARAMS_CMD cmd;
5768 + if (ar->arWmiReady == FALSE) {
5772 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5776 + if( wmi_set_snr_threshold_params(ar->arWmi, &cmd) != A_OK ) {
5784 +ar6000_ioctl_set_rssi_threshold(struct net_device *dev, struct ifreq *rq)
5786 +#define SWAP_THOLD(thold1, thold2) do { \
5787 + USER_RSSI_THOLD tmpThold; \
5788 + tmpThold.tag = thold1.tag; \
5789 + tmpThold.rssi = thold1.rssi; \
5790 + thold1.tag = thold2.tag; \
5791 + thold1.rssi = thold2.rssi; \
5792 + thold2.tag = tmpThold.tag; \
5793 + thold2.rssi = tmpThold.rssi; \
5796 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5797 + WMI_RSSI_THRESHOLD_PARAMS_CMD cmd;
5798 + USER_RSSI_PARAMS rssiParams;
5803 + if (ar->arWmiReady == FALSE) {
5807 + if (copy_from_user((char *)&rssiParams, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(USER_RSSI_PARAMS))) {
5810 + cmd.weight = rssiParams.weight;
5811 + cmd.pollTime = rssiParams.pollTime;
5813 + A_MEMCPY(rssi_map, &rssiParams.tholds, sizeof(rssi_map));
5815 + * only 6 elements, so use bubble sorting, in ascending order
5817 + for (i = 5; i > 0; i--) {
5818 + for (j = 0; j < i; j++) { /* above tholds */
5819 + if (rssi_map[j+1].rssi < rssi_map[j].rssi) {
5820 + SWAP_THOLD(rssi_map[j+1], rssi_map[j]);
5821 + } else if (rssi_map[j+1].rssi == rssi_map[j].rssi) {
5826 + for (i = 11; i > 6; i--) {
5827 + for (j = 6; j < i; j++) { /* below tholds */
5828 + if (rssi_map[j+1].rssi < rssi_map[j].rssi) {
5829 + SWAP_THOLD(rssi_map[j+1], rssi_map[j]);
5830 + } else if (rssi_map[j+1].rssi == rssi_map[j].rssi) {
5837 + for (i = 0; i < 12; i++) {
5838 + AR_DEBUG2_PRINTF("thold[%d].tag: %d, thold[%d].rssi: %d \n",
5839 + i, rssi_map[i].tag, i, rssi_map[i].rssi);
5842 + cmd.thresholdAbove1_Val = rssi_map[0].rssi;
5843 + cmd.thresholdAbove2_Val = rssi_map[1].rssi;
5844 + cmd.thresholdAbove3_Val = rssi_map[2].rssi;
5845 + cmd.thresholdAbove4_Val = rssi_map[3].rssi;
5846 + cmd.thresholdAbove5_Val = rssi_map[4].rssi;
5847 + cmd.thresholdAbove6_Val = rssi_map[5].rssi;
5848 + cmd.thresholdBelow1_Val = rssi_map[6].rssi;
5849 + cmd.thresholdBelow2_Val = rssi_map[7].rssi;
5850 + cmd.thresholdBelow3_Val = rssi_map[8].rssi;
5851 + cmd.thresholdBelow4_Val = rssi_map[9].rssi;
5852 + cmd.thresholdBelow5_Val = rssi_map[10].rssi;
5853 + cmd.thresholdBelow6_Val = rssi_map[11].rssi;
5855 + if( wmi_set_rssi_threshold_params(ar->arWmi, &cmd) != A_OK ) {
5863 +ar6000_ioctl_set_lq_threshold(struct net_device *dev, struct ifreq *rq)
5866 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5867 + WMI_LQ_THRESHOLD_PARAMS_CMD cmd;
5870 + if (ar->arWmiReady == FALSE) {
5874 + if (copy_from_user(&cmd, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(cmd))) {
5878 + if( wmi_set_lq_threshold_params(ar->arWmi, &cmd) != A_OK ) {
5887 +ar6000_ioctl_set_probedSsid(struct net_device *dev, struct ifreq *rq)
5889 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5890 + WMI_PROBED_SSID_CMD cmd;
5893 + if (ar->arWmiReady == FALSE) {
5897 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5901 + if (wmi_probedSsid_cmd(ar->arWmi, cmd.entryIndex, cmd.flag, cmd.ssidLength,
5902 + cmd.ssid) != A_OK)
5911 +ar6000_ioctl_set_badAp(struct net_device *dev, struct ifreq *rq)
5913 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5914 + WMI_ADD_BAD_AP_CMD cmd;
5917 + if (ar->arWmiReady == FALSE) {
5922 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5926 + if (cmd.badApIndex > WMI_MAX_BAD_AP_INDEX) {
5930 + if (A_MEMCMP(cmd.bssid, null_mac, AR6000_ETH_ADDR_LEN) == 0) {
5932 + * This is a delete badAP.
5934 + if (wmi_deleteBadAp_cmd(ar->arWmi, cmd.badApIndex) != A_OK) {
5938 + if (wmi_addBadAp_cmd(ar->arWmi, cmd.badApIndex, cmd.bssid) != A_OK) {
5947 +ar6000_ioctl_create_qos(struct net_device *dev, struct ifreq *rq)
5949 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5950 + WMI_CREATE_PSTREAM_CMD cmd;
5953 + if (ar->arWmiReady == FALSE) {
5958 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5962 + ret = wmi_verify_tspec_params(&cmd, tspecCompliance);
5964 + ret = wmi_create_pstream_cmd(ar->arWmi, &cmd);
5980 +ar6000_ioctl_delete_qos(struct net_device *dev, struct ifreq *rq)
5982 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5983 + WMI_DELETE_PSTREAM_CMD cmd;
5986 + if (ar->arWmiReady == FALSE) {
5990 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5994 + ret = wmi_delete_pstream_cmd(ar->arWmi, cmd.trafficClass, cmd.tsid);
6010 +ar6000_ioctl_get_qos_queue(struct net_device *dev, struct ifreq *rq)
6012 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6013 + struct ar6000_queuereq qreq;
6016 + if (ar->arWmiReady == FALSE) {
6020 + if( copy_from_user(&qreq, rq->ifr_data,
6021 + sizeof(struct ar6000_queuereq)))
6024 + qreq.activeTsids = wmi_get_mapped_qos_queue(ar->arWmi, qreq.trafficClass);
6026 + if (copy_to_user(rq->ifr_data, &qreq,
6027 + sizeof(struct ar6000_queuereq)))
6035 +#ifdef CONFIG_HOST_TCMD_SUPPORT
6037 +ar6000_ioctl_tcmd_get_rx_report(struct net_device *dev,
6038 + struct ifreq *rq, A_UINT8 *data, A_UINT32 len)
6040 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6044 + if (ar->arWmiReady == FALSE) {
6048 + if (down_interruptible(&ar->arSem)) {
6049 + return -ERESTARTSYS;
6051 + ar->tcmdRxReport = 0;
6052 + if (wmi_test_cmd(ar->arWmi, data, len) != A_OK) {
6057 + wait_event_interruptible_timeout(arEvent, ar->tcmdRxReport != 0, wmitimeout * HZ);
6059 + if (signal_pending(current)) {
6063 + buf[0] = ar->tcmdRxTotalPkt;
6064 + buf[1] = ar->tcmdRxRssi;
6065 + if (!ret && copy_to_user(rq->ifr_data, buf, sizeof(buf))) {
6075 +ar6000_tcmd_rx_report_event(void *devt, A_UINT8 * results, int len)
6077 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
6078 + TCMD_CONT_RX * rx_rep = (TCMD_CONT_RX *)results;
6080 + ar->tcmdRxTotalPkt = rx_rep->u.report.totalPkt;
6081 + ar->tcmdRxRssi = rx_rep->u.report.rssiInDBm;
6082 + ar->tcmdRxReport = 1;
6084 + wake_up(&arEvent);
6086 +#endif /* CONFIG_HOST_TCMD_SUPPORT*/
6089 +ar6000_ioctl_set_error_report_bitmask(struct net_device *dev, struct ifreq *rq)
6091 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6092 + WMI_TARGET_ERROR_REPORT_BITMASK cmd;
6095 + if (ar->arWmiReady == FALSE) {
6099 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
6103 + ret = wmi_set_error_report_bitmask(ar->arWmi, cmd.bitmask);
6105 + return (ret==0 ? ret : -EINVAL);
6109 +ar6000_clear_target_stats(struct net_device *dev)
6111 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6112 + TARGET_STATS *pStats = &ar->arTargetStats;
6115 + if (ar->arWmiReady == FALSE) {
6118 + AR6000_SPIN_LOCK(&ar->arLock, 0);
6119 + A_MEMZERO(pStats, sizeof(TARGET_STATS));
6120 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
6125 +ar6000_ioctl_get_target_stats(struct net_device *dev, struct ifreq *rq)
6127 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6128 + TARGET_STATS_CMD cmd;
6129 + TARGET_STATS *pStats = &ar->arTargetStats;
6132 + if (ar->arWmiReady == FALSE) {
6135 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
6138 + if (down_interruptible(&ar->arSem)) {
6139 + return -ERESTARTSYS;
6142 + ar->statsUpdatePending = TRUE;
6144 + if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
6149 + wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
6151 + if (signal_pending(current)) {
6155 + if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
6159 + if (cmd.clearStats == 1) {
6160 + ret = ar6000_clear_target_stats(dev);
6169 +ar6000_ioctl_set_access_params(struct net_device *dev, struct ifreq *rq)
6171 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6172 + WMI_SET_ACCESS_PARAMS_CMD cmd;
6175 + if (ar->arWmiReady == FALSE) {
6179 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
6183 + if (wmi_set_access_params_cmd(ar->arWmi, cmd.txop, cmd.eCWmin, cmd.eCWmax,
6184 + cmd.aifsn) == A_OK)
6195 +ar6000_ioctl_set_disconnect_timeout(struct net_device *dev, struct ifreq *rq)
6197 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6198 + WMI_DISC_TIMEOUT_CMD cmd;
6201 + if (ar->arWmiReady == FALSE) {
6205 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
6209 + if (wmi_disctimeout_cmd(ar->arWmi, cmd.disconnectTimeout) == A_OK)
6220 +ar6000_xioctl_set_voice_pkt_size(struct net_device *dev, char * userdata)
6222 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6223 + WMI_SET_VOICE_PKT_SIZE_CMD cmd;
6226 + if (ar->arWmiReady == FALSE) {
6230 + if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
6234 + if (wmi_set_voice_pkt_size_cmd(ar->arWmi, cmd.voicePktSize) == A_OK)
6246 +ar6000_xioctl_set_max_sp_len(struct net_device *dev, char * userdata)
6248 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6249 + WMI_SET_MAX_SP_LEN_CMD cmd;
6252 + if (ar->arWmiReady == FALSE) {
6256 + if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
6260 + if (wmi_set_max_sp_len_cmd(ar->arWmi, cmd.maxSPLen) == A_OK)
6272 +ar6000_xioctl_set_bt_status_cmd(struct net_device *dev, char * userdata)
6274 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6275 + WMI_SET_BT_STATUS_CMD cmd;
6278 + if (ar->arWmiReady == FALSE) {
6282 + if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
6286 + if (wmi_set_bt_status_cmd(ar->arWmi, cmd.streamType, cmd.status) == A_OK)
6297 +ar6000_xioctl_set_bt_params_cmd(struct net_device *dev, char * userdata)
6299 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6300 + WMI_SET_BT_PARAMS_CMD cmd;
6303 + if (ar->arWmiReady == FALSE) {
6307 + if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
6311 + if (wmi_set_bt_params_cmd(ar->arWmi, &cmd) == A_OK)
6321 +#ifdef CONFIG_HOST_GPIO_SUPPORT
6322 +struct ar6000_gpio_intr_wait_cmd_s gpio_intr_results;
6323 +/* gpio_reg_results and gpio_data_available are protected by arSem */
6324 +static struct ar6000_gpio_register_cmd_s gpio_reg_results;
6325 +static A_BOOL gpio_data_available; /* Requested GPIO data available */
6326 +static A_BOOL gpio_intr_available; /* GPIO interrupt info available */
6327 +static A_BOOL gpio_ack_received; /* GPIO ack was received */
6329 +/* Host-side initialization for General Purpose I/O support */
6330 +void ar6000_gpio_init(void)
6332 + gpio_intr_available = FALSE;
6333 + gpio_data_available = FALSE;
6334 + gpio_ack_received = FALSE;
6338 + * Called when a GPIO interrupt is received from the Target.
6339 + * intr_values shows which GPIO pins have interrupted.
6340 + * input_values shows a recent value of GPIO pins.
6343 +ar6000_gpio_intr_rx(A_UINT32 intr_mask, A_UINT32 input_values)
6345 + gpio_intr_results.intr_mask = intr_mask;
6346 + gpio_intr_results.input_values = input_values;
6347 + *((volatile A_BOOL *)&gpio_intr_available) = TRUE;
6348 + wake_up(&arEvent);
6352 + * This is called when a response is received from the Target
6353 + * for a previous or ar6000_gpio_input_get or ar6000_gpio_register_get
6357 +ar6000_gpio_data_rx(A_UINT32 reg_id, A_UINT32 value)
6359 + gpio_reg_results.gpioreg_id = reg_id;
6360 + gpio_reg_results.value = value;
6361 + *((volatile A_BOOL *)&gpio_data_available) = TRUE;
6362 + wake_up(&arEvent);
6366 + * This is called when an acknowledgement is received from the Target
6367 + * for a previous or ar6000_gpio_output_set or ar6000_gpio_register_set
6371 +ar6000_gpio_ack_rx(void)
6373 + gpio_ack_received = TRUE;
6374 + wake_up(&arEvent);
6378 +ar6000_gpio_output_set(struct net_device *dev,
6379 + A_UINT32 set_mask,
6380 + A_UINT32 clear_mask,
6381 + A_UINT32 enable_mask,
6382 + A_UINT32 disable_mask)
6384 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6386 + gpio_ack_received = FALSE;
6387 + return wmi_gpio_output_set(ar->arWmi,
6388 + set_mask, clear_mask, enable_mask, disable_mask);
6392 +ar6000_gpio_input_get(struct net_device *dev)
6394 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6396 + *((volatile A_BOOL *)&gpio_data_available) = FALSE;
6397 + return wmi_gpio_input_get(ar->arWmi);
6401 +ar6000_gpio_register_set(struct net_device *dev,
6402 + A_UINT32 gpioreg_id,
6405 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6407 + gpio_ack_received = FALSE;
6408 + return wmi_gpio_register_set(ar->arWmi, gpioreg_id, value);
6412 +ar6000_gpio_register_get(struct net_device *dev,
6413 + A_UINT32 gpioreg_id)
6415 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6417 + *((volatile A_BOOL *)&gpio_data_available) = FALSE;
6418 + return wmi_gpio_register_get(ar->arWmi, gpioreg_id);
6422 +ar6000_gpio_intr_ack(struct net_device *dev,
6423 + A_UINT32 ack_mask)
6425 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6427 + gpio_intr_available = FALSE;
6428 + return wmi_gpio_intr_ack(ar->arWmi, ack_mask);
6430 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
6432 +int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
6434 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6435 + HIF_DEVICE *hifDevice = ar->arHifDevice;
6436 + int ret, param, param2;
6437 + unsigned int address = 0;
6438 + unsigned int length = 0;
6439 + unsigned char *buffer;
6441 + A_UINT32 connectCtrlFlags;
6444 + static WMI_SCAN_PARAMS_CMD scParams = {0, 0, 0, 0, 0,
6445 + WMI_SHORTSCANRATIO_DEFAULT,
6446 + DEFAULT_SCAN_CTRL_FLAGS,
6448 + WMI_SET_AKMP_PARAMS_CMD akmpParams;
6449 + WMI_SET_PMKID_LIST_CMD pmkidInfo;
6451 + if (cmd == AR6000_IOCTL_EXTENDED)
6454 + * This allows for many more wireless ioctls than would otherwise
6455 + * be available. Applications embed the actual ioctl command in
6456 + * the first word of the parameter block, and use the command
6457 + * AR6000_IOCTL_EXTENDED_CMD on the ioctl call.
6459 + get_user(cmd, (int *)rq->ifr_data);
6460 + userdata = (char *)(((unsigned int *)rq->ifr_data)+1);
6464 + userdata = (char *)rq->ifr_data;
6467 + if ((ar->arWlanState == WLAN_DISABLED) &&
6468 + ((cmd != AR6000_XIOCTRL_WMI_SET_WLAN_STATE) &&
6469 + (cmd != AR6000_XIOCTL_DIAG_READ) &&
6470 + (cmd != AR6000_XIOCTL_DIAG_WRITE)))
6478 +#ifdef CONFIG_HOST_TCMD_SUPPORT
6479 + case AR6000_XIOCTL_TCMD_CONT_TX:
6481 + TCMD_CONT_TX txCmd;
6483 + if (ar->tcmdPm == TCMD_PM_SLEEP) {
6484 + A_PRINTF("Can NOT send tx tcmd when target is asleep! \n");
6488 + if(copy_from_user(&txCmd, userdata, sizeof(TCMD_CONT_TX)))
6490 + wmi_test_cmd(ar->arWmi,(A_UINT8 *)&txCmd, sizeof(TCMD_CONT_TX));
6493 + case AR6000_XIOCTL_TCMD_CONT_RX:
6495 + TCMD_CONT_RX rxCmd;
6497 + if (ar->tcmdPm == TCMD_PM_SLEEP) {
6498 + A_PRINTF("Can NOT send rx tcmd when target is asleep! \n");
6501 + if(copy_from_user(&rxCmd, userdata, sizeof(TCMD_CONT_RX)))
6505 + case TCMD_CONT_RX_PROMIS:
6506 + case TCMD_CONT_RX_FILTER:
6507 + case TCMD_CONT_RX_SETMAC:
6508 + wmi_test_cmd(ar->arWmi,(A_UINT8 *)&rxCmd,
6509 + sizeof(TCMD_CONT_RX));
6511 + case TCMD_CONT_RX_REPORT:
6512 + ar6000_ioctl_tcmd_get_rx_report(dev, rq,
6513 + (A_UINT8 *)&rxCmd, sizeof(TCMD_CONT_RX));
6516 + A_PRINTF("Unknown Cont Rx mode: %d\n",rxCmd.act);
6521 + case AR6000_XIOCTL_TCMD_PM:
6525 + if(copy_from_user(&pmCmd, userdata, sizeof(TCMD_PM)))
6527 + ar->tcmdPm = pmCmd.mode;
6528 + wmi_test_cmd(ar->arWmi, (A_UINT8*)&pmCmd, sizeof(TCMD_PM));
6531 +#endif /* CONFIG_HOST_TCMD_SUPPORT */
6533 + case AR6000_XIOCTL_BMI_DONE:
6536 + ret = ar6000_init(dev);
6540 + ret = BMIDone(hifDevice);
6544 + case AR6000_XIOCTL_BMI_READ_MEMORY:
6545 + get_user(address, (unsigned int *)userdata);
6546 + get_user(length, (unsigned int *)userdata + 1);
6547 + AR_DEBUG_PRINTF("Read Memory (address: 0x%x, length: %d)\n",
6549 + if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
6550 + A_MEMZERO(buffer, length);
6551 + ret = BMIReadMemory(hifDevice, address, buffer, length);
6552 + if (copy_to_user(rq->ifr_data, buffer, length)) {
6561 + case AR6000_XIOCTL_BMI_WRITE_MEMORY:
6562 + get_user(address, (unsigned int *)userdata);
6563 + get_user(length, (unsigned int *)userdata + 1);
6564 + AR_DEBUG_PRINTF("Write Memory (address: 0x%x, length: %d)\n",
6566 + if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
6567 + A_MEMZERO(buffer, length);
6568 + if (copy_from_user(buffer, &userdata[sizeof(address) +
6569 + sizeof(length)], length))
6573 + ret = BMIWriteMemory(hifDevice, address, buffer, length);
6581 + case AR6000_XIOCTL_BMI_TEST:
6582 + AR_DEBUG_PRINTF("No longer supported\n");
6583 + ret = -EOPNOTSUPP;
6586 + case AR6000_XIOCTL_BMI_EXECUTE:
6587 + get_user(address, (unsigned int *)userdata);
6588 + get_user(param, (unsigned int *)userdata + 1);
6589 + AR_DEBUG_PRINTF("Execute (address: 0x%x, param: %d)\n",
6591 + ret = BMIExecute(hifDevice, address, ¶m);
6592 + put_user(param, (unsigned int *)rq->ifr_data); /* return value */
6595 + case AR6000_XIOCTL_BMI_SET_APP_START:
6596 + get_user(address, (unsigned int *)userdata);
6597 + AR_DEBUG_PRINTF("Set App Start (address: 0x%x)\n", address);
6598 + ret = BMISetAppStart(hifDevice, address);
6601 + case AR6000_XIOCTL_BMI_READ_SOC_REGISTER:
6602 + get_user(address, (unsigned int *)userdata);
6603 + ret = BMIReadSOCRegister(hifDevice, address, ¶m);
6604 + put_user(param, (unsigned int *)rq->ifr_data); /* return value */
6607 + case AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER:
6608 + get_user(address, (unsigned int *)userdata);
6609 + get_user(param, (unsigned int *)userdata + 1);
6610 + ret = BMIWriteSOCRegister(hifDevice, address, param);
6613 +#ifdef HTC_RAW_INTERFACE
6614 + case AR6000_XIOCTL_HTC_RAW_OPEN:
6616 + if (!arRawIfEnabled(ar)) {
6617 + /* make sure block size is set in case the target was reset since last
6618 + * BMI phase (i.e. flashup downloads) */
6619 + ret = ar6000_SetHTCBlockSize(ar);
6620 + if (A_FAILED(ret)) {
6623 + /* Terminate the BMI phase */
6624 + ret = BMIDone(hifDevice);
6625 + if (ret == A_OK) {
6626 + ret = ar6000_htc_raw_open(ar);
6631 + case AR6000_XIOCTL_HTC_RAW_CLOSE:
6632 + if (arRawIfEnabled(ar)) {
6633 + ret = ar6000_htc_raw_close(ar);
6634 + arRawIfEnabled(ar) = FALSE;
6640 + case AR6000_XIOCTL_HTC_RAW_READ:
6641 + if (arRawIfEnabled(ar)) {
6642 + unsigned int streamID;
6643 + get_user(streamID, (unsigned int *)userdata);
6644 + get_user(length, (unsigned int *)userdata + 1);
6645 + buffer = rq->ifr_data + sizeof(length);
6646 + ret = ar6000_htc_raw_read(ar, (HTC_RAW_STREAM_ID)streamID,
6648 + put_user(ret, (unsigned int *)rq->ifr_data);
6654 + case AR6000_XIOCTL_HTC_RAW_WRITE:
6655 + if (arRawIfEnabled(ar)) {
6656 + unsigned int streamID;
6657 + get_user(streamID, (unsigned int *)userdata);
6658 + get_user(length, (unsigned int *)userdata + 1);
6659 + buffer = userdata + sizeof(streamID) + sizeof(length);
6660 + ret = ar6000_htc_raw_write(ar, (HTC_RAW_STREAM_ID)streamID,
6662 + put_user(ret, (unsigned int *)rq->ifr_data);
6667 +#endif /* HTC_RAW_INTERFACE */
6669 + case AR6000_IOCTL_WMI_GETREV:
6671 + if (copy_to_user(rq->ifr_data, &ar->arVersion,
6672 + sizeof(ar->arVersion)))
6678 + case AR6000_IOCTL_WMI_SETPWR:
6680 + WMI_POWER_MODE_CMD pwrModeCmd;
6682 + if (ar->arWmiReady == FALSE) {
6684 + } else if (copy_from_user(&pwrModeCmd, userdata,
6685 + sizeof(pwrModeCmd)))
6689 + if (wmi_powermode_cmd(ar->arWmi, pwrModeCmd.powerMode)
6697 + case AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS:
6699 + WMI_IBSS_PM_CAPS_CMD ibssPmCaps;
6701 + if (ar->arWmiReady == FALSE) {
6703 + } else if (copy_from_user(&ibssPmCaps, userdata,
6704 + sizeof(ibssPmCaps)))
6708 + if (wmi_ibsspmcaps_cmd(ar->arWmi, ibssPmCaps.power_saving, ibssPmCaps.ttl,
6709 + ibssPmCaps.atim_windows, ibssPmCaps.timeout_value) != A_OK)
6713 + AR6000_SPIN_LOCK(&ar->arLock, 0);
6714 + ar->arIbssPsEnable = ibssPmCaps.power_saving;
6715 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
6719 + case AR6000_IOCTL_WMI_SET_PMPARAMS:
6721 + WMI_POWER_PARAMS_CMD pmParams;
6723 + if (ar->arWmiReady == FALSE) {
6725 + } else if (copy_from_user(&pmParams, userdata,
6726 + sizeof(pmParams)))
6730 + if (wmi_pmparams_cmd(ar->arWmi, pmParams.idle_period,
6731 + pmParams.pspoll_number,
6732 + pmParams.dtim_policy) != A_OK)
6739 + case AR6000_IOCTL_WMI_SETSCAN:
6741 + if (ar->arWmiReady == FALSE) {
6743 + } else if (copy_from_user(&scParams, userdata,
6744 + sizeof(scParams)))
6748 + if (CAN_SCAN_IN_CONNECT(scParams.scanCtrlFlags)) {
6749 + ar->arSkipScan = FALSE;
6751 + ar->arSkipScan = TRUE;
6754 + if (wmi_scanparams_cmd(ar->arWmi, scParams.fg_start_period,
6755 + scParams.fg_end_period,
6756 + scParams.bg_period,
6757 + scParams.minact_chdwell_time,
6758 + scParams.maxact_chdwell_time,
6759 + scParams.pas_chdwell_time,
6760 + scParams.shortScanRatio,
6761 + scParams.scanCtrlFlags,
6762 + scParams.max_dfsch_act_time) != A_OK)
6769 + case AR6000_IOCTL_WMI_SETLISTENINT:
6771 + WMI_LISTEN_INT_CMD listenCmd;
6773 + if (ar->arWmiReady == FALSE) {
6775 + } else if (copy_from_user(&listenCmd, userdata,
6776 + sizeof(listenCmd)))
6780 + if (wmi_listeninterval_cmd(ar->arWmi, listenCmd.listenInterval, listenCmd.numBeacons) != A_OK) {
6783 + AR6000_SPIN_LOCK(&ar->arLock, 0);
6784 + ar->arListenInterval = param;
6785 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
6791 + case AR6000_IOCTL_WMI_SET_BMISS_TIME:
6793 + WMI_BMISS_TIME_CMD bmissCmd;
6795 + if (ar->arWmiReady == FALSE) {
6797 + } else if (copy_from_user(&bmissCmd, userdata,
6798 + sizeof(bmissCmd)))
6802 + if (wmi_bmisstime_cmd(ar->arWmi, bmissCmd.bmissTime, bmissCmd.numBeacons) != A_OK) {
6808 + case AR6000_IOCTL_WMI_SETBSSFILTER:
6810 + if (ar->arWmiReady == FALSE) {
6814 + get_user(param, (unsigned char *)userdata);
6815 + get_user(param2, (unsigned int *)(userdata + 1));
6816 + printk("SETBSSFILTER: filter 0x%x, mask: 0x%x\n", param, param2);
6817 + if (wmi_bssfilter_cmd(ar->arWmi, param, param2) != A_OK) {
6823 + case AR6000_IOCTL_WMI_SET_SNRTHRESHOLD:
6825 + ret = ar6000_ioctl_set_snr_threshold(dev, rq);
6828 + case AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD:
6830 + ret = ar6000_ioctl_set_rssi_threshold(dev, rq);
6833 + case AR6000_XIOCTL_WMI_CLR_RSSISNR:
6835 + if (ar->arWmiReady == FALSE) {
6838 + ret = wmi_clr_rssi_snr(ar->arWmi);
6841 + case AR6000_XIOCTL_WMI_SET_LQTHRESHOLD:
6843 + ret = ar6000_ioctl_set_lq_threshold(dev, rq);
6846 + case AR6000_XIOCTL_WMI_SET_LPREAMBLE:
6848 + WMI_SET_LPREAMBLE_CMD setLpreambleCmd;
6850 + if (ar->arWmiReady == FALSE) {
6852 + } else if (copy_from_user(&setLpreambleCmd, userdata,
6853 + sizeof(setLpreambleCmd)))
6857 + if (wmi_set_lpreamble_cmd(ar->arWmi, setLpreambleCmd.status)
6866 + case AR6000_XIOCTL_WMI_SET_RTS:
6868 + WMI_SET_RTS_CMD rtsCmd;
6870 + if (ar->arWmiReady == FALSE) {
6872 + } else if (copy_from_user(&rtsCmd, userdata,
6877 + if (wmi_set_rts_cmd(ar->arWmi, rtsCmd.threshold)
6886 + case AR6000_XIOCTL_WMI_SET_WMM:
6888 + ret = ar6000_ioctl_set_wmm(dev, rq);
6891 + case AR6000_XIOCTL_WMI_SET_TXOP:
6893 + ret = ar6000_ioctl_set_txop(dev, rq);
6896 + case AR6000_XIOCTL_WMI_GET_RD:
6898 + ret = ar6000_ioctl_get_rd(dev, rq);
6901 + case AR6000_IOCTL_WMI_SET_CHANNELPARAMS:
6903 + ret = ar6000_ioctl_set_channelParams(dev, rq);
6906 + case AR6000_IOCTL_WMI_SET_PROBEDSSID:
6908 + ret = ar6000_ioctl_set_probedSsid(dev, rq);
6911 + case AR6000_IOCTL_WMI_SET_BADAP:
6913 + ret = ar6000_ioctl_set_badAp(dev, rq);
6916 + case AR6000_IOCTL_WMI_CREATE_QOS:
6918 + ret = ar6000_ioctl_create_qos(dev, rq);
6921 + case AR6000_IOCTL_WMI_DELETE_QOS:
6923 + ret = ar6000_ioctl_delete_qos(dev, rq);
6926 + case AR6000_IOCTL_WMI_GET_QOS_QUEUE:
6928 + ret = ar6000_ioctl_get_qos_queue(dev, rq);
6931 + case AR6000_IOCTL_WMI_GET_TARGET_STATS:
6933 + ret = ar6000_ioctl_get_target_stats(dev, rq);
6936 + case AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK:
6938 + ret = ar6000_ioctl_set_error_report_bitmask(dev, rq);
6941 + case AR6000_IOCTL_WMI_SET_ASSOC_INFO:
6943 + WMI_SET_ASSOC_INFO_CMD cmd;
6944 + A_UINT8 assocInfo[WMI_MAX_ASSOC_INFO_LEN];
6946 + if (ar->arWmiReady == FALSE) {
6949 + get_user(cmd.ieType, userdata);
6950 + if (cmd.ieType >= WMI_MAX_ASSOC_INFO_TYPE) {
6953 + get_user(cmd.bufferSize, userdata + 1);
6954 + if (cmd.bufferSize > WMI_MAX_ASSOC_INFO_LEN) {
6958 + if (copy_from_user(assocInfo, userdata + 2,
6963 + if (wmi_associnfo_cmd(ar->arWmi, cmd.ieType,
6965 + assocInfo) != A_OK)
6974 + case AR6000_IOCTL_WMI_SET_ACCESS_PARAMS:
6976 + ret = ar6000_ioctl_set_access_params(dev, rq);
6979 + case AR6000_IOCTL_WMI_SET_DISC_TIMEOUT:
6981 + ret = ar6000_ioctl_set_disconnect_timeout(dev, rq);
6984 + case AR6000_XIOCTL_FORCE_TARGET_RESET:
6986 + if (ar->arHtcTarget)
6988 +// HTCForceReset(htcTarget);
6992 + AR_DEBUG_PRINTF("ar6000_ioctl cannot attempt reset.\n");
6996 + case AR6000_XIOCTL_TARGET_INFO:
6997 + case AR6000_XIOCTL_CHECK_TARGET_READY: /* backwards compatibility */
6999 + /* If we made it to here, then the Target exists and is ready. */
7001 + if (cmd == AR6000_XIOCTL_TARGET_INFO) {
7002 + if (copy_to_user((A_UINT32 *)rq->ifr_data, &ar->arVersion.target_ver,
7003 + sizeof(ar->arVersion.target_ver)))
7007 + if (copy_to_user(((A_UINT32 *)rq->ifr_data)+1, &ar->arTargetType,
7008 + sizeof(ar->arTargetType)))
7015 + case AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS:
7017 + WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD hbparam;
7019 + if (copy_from_user(&hbparam, userdata, sizeof(hbparam)))
7023 + AR6000_SPIN_LOCK(&ar->arLock, 0);
7024 + /* Start a cyclic timer with the parameters provided. */
7025 + if (hbparam.frequency) {
7026 + ar->arHBChallengeResp.frequency = hbparam.frequency;
7028 + if (hbparam.threshold) {
7029 + ar->arHBChallengeResp.missThres = hbparam.threshold;
7032 + /* Delete the pending timer and start a new one */
7033 + if (timer_pending(&ar->arHBChallengeResp.timer)) {
7034 + A_UNTIMEOUT(&ar->arHBChallengeResp.timer);
7036 + A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
7037 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7041 + case AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP:
7045 + if (copy_from_user(&cookie, userdata, sizeof(cookie))) {
7049 + /* Send the challenge on the control channel */
7050 + if (wmi_get_challenge_resp_cmd(ar->arWmi, cookie, APP_HB_CHALLENGE) != A_OK) {
7056 + case AR6000_XIOCTL_USER_SETKEYS:
7059 + ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_RUN;
7061 + if (copy_from_user(&ar->user_key_ctrl, userdata,
7062 + sizeof(ar->user_key_ctrl)))
7067 + A_PRINTF("ar6000 USER set key %x\n", ar->user_key_ctrl);
7070 +#endif /* USER_KEYS */
7072 +#ifdef CONFIG_HOST_GPIO_SUPPORT
7073 + case AR6000_XIOCTL_GPIO_OUTPUT_SET:
7075 + struct ar6000_gpio_output_set_cmd_s gpio_output_set_cmd;
7077 + if (ar->arWmiReady == FALSE) {
7080 + if (down_interruptible(&ar->arSem)) {
7081 + return -ERESTARTSYS;
7084 + if (copy_from_user(&gpio_output_set_cmd, userdata,
7085 + sizeof(gpio_output_set_cmd)))
7089 + ret = ar6000_gpio_output_set(dev,
7090 + gpio_output_set_cmd.set_mask,
7091 + gpio_output_set_cmd.clear_mask,
7092 + gpio_output_set_cmd.enable_mask,
7093 + gpio_output_set_cmd.disable_mask);
7094 + if (ret != A_OK) {
7101 + case AR6000_XIOCTL_GPIO_INPUT_GET:
7103 + if (ar->arWmiReady == FALSE) {
7106 + if (down_interruptible(&ar->arSem)) {
7107 + return -ERESTARTSYS;
7110 + ret = ar6000_gpio_input_get(dev);
7111 + if (ret != A_OK) {
7116 + /* Wait for Target to respond. */
7117 + wait_event_interruptible(arEvent, gpio_data_available);
7118 + if (signal_pending(current)) {
7121 + A_ASSERT(gpio_reg_results.gpioreg_id == GPIO_ID_NONE);
7123 + if (copy_to_user(userdata, &gpio_reg_results.value,
7124 + sizeof(gpio_reg_results.value)))
7132 + case AR6000_XIOCTL_GPIO_REGISTER_SET:
7134 + struct ar6000_gpio_register_cmd_s gpio_register_cmd;
7136 + if (ar->arWmiReady == FALSE) {
7139 + if (down_interruptible(&ar->arSem)) {
7140 + return -ERESTARTSYS;
7143 + if (copy_from_user(&gpio_register_cmd, userdata,
7144 + sizeof(gpio_register_cmd)))
7148 + ret = ar6000_gpio_register_set(dev,
7149 + gpio_register_cmd.gpioreg_id,
7150 + gpio_register_cmd.value);
7151 + if (ret != A_OK) {
7155 + /* Wait for acknowledgement from Target */
7156 + wait_event_interruptible(arEvent, gpio_ack_received);
7157 + if (signal_pending(current)) {
7164 + case AR6000_XIOCTL_GPIO_REGISTER_GET:
7166 + struct ar6000_gpio_register_cmd_s gpio_register_cmd;
7168 + if (ar->arWmiReady == FALSE) {
7171 + if (down_interruptible(&ar->arSem)) {
7172 + return -ERESTARTSYS;
7175 + if (copy_from_user(&gpio_register_cmd, userdata,
7176 + sizeof(gpio_register_cmd)))
7180 + ret = ar6000_gpio_register_get(dev, gpio_register_cmd.gpioreg_id);
7181 + if (ret != A_OK) {
7186 + /* Wait for Target to respond. */
7187 + wait_event_interruptible(arEvent, gpio_data_available);
7188 + if (signal_pending(current)) {
7191 + A_ASSERT(gpio_register_cmd.gpioreg_id == gpio_reg_results.gpioreg_id);
7192 + if (copy_to_user(userdata, &gpio_reg_results,
7193 + sizeof(gpio_reg_results)))
7202 + case AR6000_XIOCTL_GPIO_INTR_ACK:
7204 + struct ar6000_gpio_intr_ack_cmd_s gpio_intr_ack_cmd;
7206 + if (ar->arWmiReady == FALSE) {
7209 + if (down_interruptible(&ar->arSem)) {
7210 + return -ERESTARTSYS;
7213 + if (copy_from_user(&gpio_intr_ack_cmd, userdata,
7214 + sizeof(gpio_intr_ack_cmd)))
7218 + ret = ar6000_gpio_intr_ack(dev, gpio_intr_ack_cmd.ack_mask);
7219 + if (ret != A_OK) {
7226 + case AR6000_XIOCTL_GPIO_INTR_WAIT:
7228 + /* Wait for Target to report an interrupt. */
7231 + wait_event_interruptible(arEvent, gpio_intr_available);
7235 + if (signal_pending(current)) {
7238 + if (copy_to_user(userdata, &gpio_intr_results,
7239 + sizeof(gpio_intr_results)))
7246 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
7248 + case AR6000_XIOCTL_DBGLOG_CFG_MODULE:
7250 + struct ar6000_dbglog_module_config_s config;
7252 + if (copy_from_user(&config, userdata, sizeof(config))) {
7256 + /* Send the challenge on the control channel */
7257 + if (wmi_config_debug_module_cmd(ar->arWmi, config.mmask,
7258 + config.tsr, config.rep,
7259 + config.size, config.valid) != A_OK)
7266 + case AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS:
7268 + /* Send the challenge on the control channel */
7269 + if (ar6000_dbglog_get_debug_logs(ar) != A_OK)
7276 + case AR6000_XIOCTL_SET_ADHOC_BSSID:
7278 + WMI_SET_ADHOC_BSSID_CMD adhocBssid;
7280 + if (ar->arWmiReady == FALSE) {
7282 + } else if (copy_from_user(&adhocBssid, userdata,
7283 + sizeof(adhocBssid)))
7286 + } else if (A_MEMCMP(adhocBssid.bssid, bcast_mac,
7287 + AR6000_ETH_ADDR_LEN) == 0)
7292 + A_MEMCPY(ar->arReqBssid, adhocBssid.bssid, sizeof(ar->arReqBssid));
7297 + case AR6000_XIOCTL_SET_OPT_MODE:
7299 + WMI_SET_OPT_MODE_CMD optModeCmd;
7300 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
7302 + if (ar->arWmiReady == FALSE) {
7304 + } else if (copy_from_user(&optModeCmd, userdata,
7305 + sizeof(optModeCmd)))
7308 + } else if (ar->arConnected && optModeCmd.optMode == SPECIAL_ON) {
7311 + } else if (wmi_set_opt_mode_cmd(ar->arWmi, optModeCmd.optMode)
7319 + case AR6000_XIOCTL_OPT_SEND_FRAME:
7321 + WMI_OPT_TX_FRAME_CMD optTxFrmCmd;
7322 + A_UINT8 data[MAX_OPT_DATA_LEN];
7324 + if (ar->arWmiReady == FALSE) {
7326 + } else if (copy_from_user(&optTxFrmCmd, userdata,
7327 + sizeof(optTxFrmCmd)))
7330 + } else if (copy_from_user(data,
7331 + userdata+sizeof(WMI_OPT_TX_FRAME_CMD)-1,
7332 + optTxFrmCmd.optIEDataLen))
7336 + ret = wmi_opt_tx_frame_cmd(ar->arWmi,
7337 + optTxFrmCmd.frmType,
7338 + optTxFrmCmd.dstAddr,
7339 + optTxFrmCmd.bssid,
7340 + optTxFrmCmd.optIEDataLen,
7346 + case AR6000_XIOCTL_WMI_SETRETRYLIMITS:
7348 + WMI_SET_RETRY_LIMITS_CMD setRetryParams;
7350 + if (ar->arWmiReady == FALSE) {
7352 + } else if (copy_from_user(&setRetryParams, userdata,
7353 + sizeof(setRetryParams)))
7357 + if (wmi_set_retry_limits_cmd(ar->arWmi, setRetryParams.frameType,
7358 + setRetryParams.trafficClass,
7359 + setRetryParams.maxRetries,
7360 + setRetryParams.enableNotify) != A_OK)
7364 + AR6000_SPIN_LOCK(&ar->arLock, 0);
7365 + ar->arMaxRetries = setRetryParams.maxRetries;
7366 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7371 + case AR6000_XIOCTL_SET_ADHOC_BEACON_INTVAL:
7373 + WMI_BEACON_INT_CMD bIntvlCmd;
7375 + if (ar->arWmiReady == FALSE) {
7377 + } else if (copy_from_user(&bIntvlCmd, userdata,
7378 + sizeof(bIntvlCmd)))
7381 + } else if (wmi_set_adhoc_bconIntvl_cmd(ar->arWmi, bIntvlCmd.beaconInterval)
7388 + case IEEE80211_IOCTL_SETAUTHALG:
7390 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
7391 + struct ieee80211req_authalg req;
7393 + if (ar->arWmiReady == FALSE) {
7395 + } else if (copy_from_user(&req, userdata,
7396 + sizeof(struct ieee80211req_authalg)))
7399 + } else if (req.auth_alg == AUTH_ALG_OPEN_SYSTEM) {
7400 + ar->arDot11AuthMode = OPEN_AUTH;
7401 + ar->arPairwiseCrypto = NONE_CRYPT;
7402 + ar->arGroupCrypto = NONE_CRYPT;
7403 + } else if (req.auth_alg == AUTH_ALG_LEAP) {
7404 + ar->arDot11AuthMode = LEAP_AUTH;
7411 + case AR6000_XIOCTL_SET_VOICE_PKT_SIZE:
7412 + ret = ar6000_xioctl_set_voice_pkt_size(dev, userdata);
7415 + case AR6000_XIOCTL_SET_MAX_SP:
7416 + ret = ar6000_xioctl_set_max_sp_len(dev, userdata);
7419 + case AR6000_XIOCTL_WMI_GET_ROAM_TBL:
7420 + ret = ar6000_ioctl_get_roam_tbl(dev, rq);
7422 + case AR6000_XIOCTL_WMI_SET_ROAM_CTRL:
7423 + ret = ar6000_ioctl_set_roam_ctrl(dev, userdata);
7425 + case AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS:
7426 + ret = ar6000_ioctl_set_powersave_timers(dev, userdata);
7428 + case AR6000_XIOCTRL_WMI_GET_POWER_MODE:
7429 + ret = ar6000_ioctl_get_power_mode(dev, rq);
7431 + case AR6000_XIOCTRL_WMI_SET_WLAN_STATE:
7432 + get_user(ar->arWlanState, (unsigned int *)userdata);
7433 + if (ar->arWmiReady == FALSE) {
7438 + if (ar->arWlanState == WLAN_ENABLED) {
7439 + /* Enable foreground scanning */
7440 + if (wmi_scanparams_cmd(ar->arWmi, scParams.fg_start_period,
7441 + scParams.fg_end_period,
7442 + scParams.bg_period,
7443 + scParams.minact_chdwell_time,
7444 + scParams.maxact_chdwell_time,
7445 + scParams.pas_chdwell_time,
7446 + scParams.shortScanRatio,
7447 + scParams.scanCtrlFlags,
7448 + scParams.max_dfsch_act_time) != A_OK)
7452 + if (ar->arSsidLen) {
7453 + ar->arConnectPending = TRUE;
7454 + if (wmi_connect_cmd(ar->arWmi, ar->arNetworkType,
7455 + ar->arDot11AuthMode, ar->arAuthMode,
7456 + ar->arPairwiseCrypto,
7457 + ar->arPairwiseCryptoLen,
7458 + ar->arGroupCrypto, ar->arGroupCryptoLen,
7459 + ar->arSsidLen, ar->arSsid,
7460 + ar->arReqBssid, ar->arChannelHint,
7461 + ar->arConnectCtrlFlags) != A_OK)
7464 + ar->arConnectPending = FALSE;
7468 + /* Disconnect from the AP and disable foreground scanning */
7469 + AR6000_SPIN_LOCK(&ar->arLock, 0);
7470 + if (ar->arConnected == TRUE || ar->arConnectPending == TRUE) {
7471 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7472 + wmi_disconnect_cmd(ar->arWmi);
7474 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7477 + if (wmi_scanparams_cmd(ar->arWmi, 0xFFFF, 0, 0, 0, 0, 0, 0, 0xFF, 0) != A_OK)
7483 + case AR6000_XIOCTL_WMI_GET_ROAM_DATA:
7484 + ret = ar6000_ioctl_get_roam_data(dev, rq);
7486 + case AR6000_XIOCTL_WMI_SET_BT_STATUS:
7487 + ret = ar6000_xioctl_set_bt_status_cmd(dev, userdata);
7489 + case AR6000_XIOCTL_WMI_SET_BT_PARAMS:
7490 + ret = ar6000_xioctl_set_bt_params_cmd(dev, userdata);
7492 + case AR6000_XIOCTL_WMI_STARTSCAN:
7494 + WMI_START_SCAN_CMD setStartScanCmd;
7496 + if (ar->arWmiReady == FALSE) {
7498 + } else if (copy_from_user(&setStartScanCmd, userdata,
7499 + sizeof(setStartScanCmd)))
7503 + if (wmi_startscan_cmd(ar->arWmi, setStartScanCmd.scanType,
7504 + setStartScanCmd.forceFgScan,
7505 + setStartScanCmd.isLegacy,
7506 + setStartScanCmd.homeDwellTime,
7507 + setStartScanCmd.forceScanInterval) != A_OK)
7514 + case AR6000_XIOCTL_WMI_SETFIXRATES:
7516 + WMI_FIX_RATES_CMD setFixRatesCmd;
7517 + A_STATUS returnStatus;
7519 + if (ar->arWmiReady == FALSE) {
7521 + } else if (copy_from_user(&setFixRatesCmd, userdata,
7522 + sizeof(setFixRatesCmd)))
7526 + returnStatus = wmi_set_fixrates_cmd(ar->arWmi, setFixRatesCmd.fixRateMask);
7527 + if (returnStatus == A_EINVAL)
7531 + else if(returnStatus != A_OK) {
7538 + case AR6000_XIOCTL_WMI_GETFIXRATES:
7540 + WMI_FIX_RATES_CMD getFixRatesCmd;
7541 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
7544 + if (ar->arWmiReady == FALSE) {
7548 + if (down_interruptible(&ar->arSem)) {
7549 + return -ERESTARTSYS;
7551 + /* Used copy_from_user/copy_to_user to access user space data */
7552 + if (copy_from_user(&getFixRatesCmd, userdata, sizeof(getFixRatesCmd))) {
7555 + ar->arRateMask = 0xFFFF;
7557 + if (wmi_get_ratemask_cmd(ar->arWmi) != A_OK) {
7562 + wait_event_interruptible_timeout(arEvent, ar->arRateMask != 0xFFFF, wmitimeout * HZ);
7564 + if (signal_pending(current)) {
7569 + getFixRatesCmd.fixRateMask = ar->arRateMask;
7572 + if(copy_to_user(userdata, &getFixRatesCmd, sizeof(getFixRatesCmd))) {
7580 + case AR6000_XIOCTL_WMI_SET_AUTHMODE:
7582 + WMI_SET_AUTH_MODE_CMD setAuthMode;
7584 + if (ar->arWmiReady == FALSE) {
7586 + } else if (copy_from_user(&setAuthMode, userdata,
7587 + sizeof(setAuthMode)))
7591 + if (wmi_set_authmode_cmd(ar->arWmi, setAuthMode.mode) != A_OK)
7598 + case AR6000_XIOCTL_WMI_SET_REASSOCMODE:
7600 + WMI_SET_REASSOC_MODE_CMD setReassocMode;
7602 + if (ar->arWmiReady == FALSE) {
7604 + } else if (copy_from_user(&setReassocMode, userdata,
7605 + sizeof(setReassocMode)))
7609 + if (wmi_set_reassocmode_cmd(ar->arWmi, setReassocMode.mode) != A_OK)
7616 + case AR6000_XIOCTL_DIAG_READ:
7618 + A_UINT32 addr, data;
7619 + get_user(addr, (unsigned int *)userdata);
7620 + if (ar6000_ReadRegDiag(ar->arHifDevice, &addr, &data) != A_OK) {
7623 + put_user(data, (unsigned int *)userdata + 1);
7626 + case AR6000_XIOCTL_DIAG_WRITE:
7628 + A_UINT32 addr, data;
7629 + get_user(addr, (unsigned int *)userdata);
7630 + get_user(data, (unsigned int *)userdata + 1);
7631 + if (ar6000_WriteRegDiag(ar->arHifDevice, &addr, &data) != A_OK) {
7636 + case AR6000_XIOCTL_WMI_SET_KEEPALIVE:
7638 + WMI_SET_KEEPALIVE_CMD setKeepAlive;
7639 + if (ar->arWmiReady == FALSE) {
7641 + } else if (copy_from_user(&setKeepAlive, userdata,
7642 + sizeof(setKeepAlive))){
7645 + if (wmi_set_keepalive_cmd(ar->arWmi, setKeepAlive.keepaliveInterval) != A_OK) {
7651 + case AR6000_XIOCTL_WMI_GET_KEEPALIVE:
7653 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
7654 + WMI_GET_KEEPALIVE_CMD getKeepAlive;
7656 + if (ar->arWmiReady == FALSE) {
7659 + if (down_interruptible(&ar->arSem)) {
7660 + return -ERESTARTSYS;
7662 + if (copy_from_user(&getKeepAlive, userdata,sizeof(getKeepAlive))) {
7665 + getKeepAlive.keepaliveInterval = wmi_get_keepalive_cmd(ar->arWmi);
7666 + ar->arKeepaliveConfigured = 0xFF;
7667 + if (wmi_get_keepalive_configured(ar->arWmi) != A_OK){
7671 + wait_event_interruptible_timeout(arEvent, ar->arKeepaliveConfigured != 0xFF, wmitimeout * HZ);
7672 + if (signal_pending(current)) {
7677 + getKeepAlive.configured = ar->arKeepaliveConfigured;
7679 + if (copy_to_user(userdata, &getKeepAlive, sizeof(getKeepAlive))) {
7686 + case AR6000_XIOCTL_WMI_SET_APPIE:
7688 + WMI_SET_APPIE_CMD appIEcmd;
7689 + A_UINT8 appIeInfo[IEEE80211_APPIE_FRAME_MAX_LEN];
7690 + A_UINT32 fType,ieLen;
7692 + if (ar->arWmiReady == FALSE) {
7695 + get_user(fType, (A_UINT32 *)userdata);
7696 + appIEcmd.mgmtFrmType = fType;
7697 + if (appIEcmd.mgmtFrmType >= IEEE80211_APPIE_NUM_OF_FRAME) {
7700 + get_user(ieLen, (A_UINT32 *)(userdata + 4));
7701 + appIEcmd.ieLen = ieLen;
7702 + if (appIEcmd.ieLen > IEEE80211_APPIE_FRAME_MAX_LEN) {
7706 + if (copy_from_user(appIeInfo, userdata + 8, appIEcmd.ieLen)) {
7709 + if (wmi_set_appie_cmd(ar->arWmi, appIEcmd.mgmtFrmType,
7710 + appIEcmd.ieLen, appIeInfo) != A_OK)
7718 + case AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER:
7720 + WMI_BSS_FILTER_CMD cmd;
7721 + A_UINT32 filterType;
7723 + if (copy_from_user(&filterType, userdata, sizeof(A_UINT32)))
7727 + if (filterType & (IEEE80211_FILTER_TYPE_BEACON |
7728 + IEEE80211_FILTER_TYPE_PROBE_RESP))
7730 + cmd.bssFilter = ALL_BSS_FILTER;
7732 + cmd.bssFilter = NONE_BSS_FILTER;
7734 + if (wmi_bssfilter_cmd(ar->arWmi, cmd.bssFilter, 0) != A_OK) {
7738 + AR6000_SPIN_LOCK(&ar->arLock, 0);
7739 + ar->arMgmtFilter = filterType;
7740 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7743 + case AR6000_XIOCTL_WMI_SET_WSC_STATUS:
7745 + A_UINT32 wsc_status;
7747 + if (copy_from_user(&wsc_status, userdata, sizeof(A_UINT32)))
7751 + if (wmi_set_wsc_status_cmd(ar->arWmi, wsc_status) != A_OK) {
7756 + case AR6000_XIOCTL_BMI_ROMPATCH_INSTALL:
7758 + A_UINT32 ROM_addr;
7759 + A_UINT32 RAM_addr;
7761 + A_UINT32 do_activate;
7762 + A_UINT32 rompatch_id;
7764 + get_user(ROM_addr, (A_UINT32 *)userdata);
7765 + get_user(RAM_addr, (A_UINT32 *)userdata + 1);
7766 + get_user(nbytes, (A_UINT32 *)userdata + 2);
7767 + get_user(do_activate, (A_UINT32 *)userdata + 3);
7768 + AR_DEBUG_PRINTF("Install rompatch from ROM: 0x%x to RAM: 0x%x length: %d\n",
7769 + ROM_addr, RAM_addr, nbytes);
7770 + ret = BMIrompatchInstall(hifDevice, ROM_addr, RAM_addr,
7771 + nbytes, do_activate, &rompatch_id);
7772 + if (ret == A_OK) {
7773 + put_user(rompatch_id, (unsigned int *)rq->ifr_data); /* return value */
7778 + case AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL:
7780 + A_UINT32 rompatch_id;
7782 + get_user(rompatch_id, (A_UINT32 *)userdata);
7783 + AR_DEBUG_PRINTF("UNinstall rompatch_id %d\n", rompatch_id);
7784 + ret = BMIrompatchUninstall(hifDevice, rompatch_id);
7788 + case AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE:
7789 + case AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE:
7791 + A_UINT32 rompatch_count;
7793 + get_user(rompatch_count, (A_UINT32 *)userdata);
7794 + AR_DEBUG_PRINTF("Change rompatch activation count=%d\n", rompatch_count);
7795 + length = sizeof(A_UINT32) * rompatch_count;
7796 + if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
7797 + A_MEMZERO(buffer, length);
7798 + if (copy_from_user(buffer, &userdata[sizeof(rompatch_count)], length))
7802 + if (cmd == AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE) {
7803 + ret = BMIrompatchActivate(hifDevice, rompatch_count, (A_UINT32 *)buffer);
7805 + ret = BMIrompatchDeactivate(hifDevice, rompatch_count, (A_UINT32 *)buffer);
7816 + case AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE:
7818 + WMI_SET_HOST_SLEEP_MODE_CMD setHostSleepMode;
7820 + if (ar->arWmiReady == FALSE) {
7822 + } else if (copy_from_user(&setHostSleepMode, userdata,
7823 + sizeof(setHostSleepMode)))
7827 + if (wmi_set_host_sleep_mode_cmd(ar->arWmi,
7828 + &setHostSleepMode) != A_OK)
7835 + case AR6000_XIOCTL_WMI_SET_WOW_MODE:
7837 + WMI_SET_WOW_MODE_CMD setWowMode;
7839 + if (ar->arWmiReady == FALSE) {
7841 + } else if (copy_from_user(&setWowMode, userdata,
7842 + sizeof(setWowMode)))
7846 + if (wmi_set_wow_mode_cmd(ar->arWmi,
7847 + &setWowMode) != A_OK)
7854 + case AR6000_XIOCTL_WMI_GET_WOW_LIST:
7856 + WMI_GET_WOW_LIST_CMD getWowList;
7858 + if (ar->arWmiReady == FALSE) {
7860 + } else if (copy_from_user(&getWowList, userdata,
7861 + sizeof(getWowList)))
7865 + if (wmi_get_wow_list_cmd(ar->arWmi,
7866 + &getWowList) != A_OK)
7873 + case AR6000_XIOCTL_WMI_ADD_WOW_PATTERN:
7875 +#define WOW_PATTERN_SIZE 64
7876 +#define WOW_MASK_SIZE 64
7878 + WMI_ADD_WOW_PATTERN_CMD cmd;
7879 + A_UINT8 mask_data[WOW_PATTERN_SIZE]={0};
7880 + A_UINT8 pattern_data[WOW_PATTERN_SIZE]={0};
7882 + if (ar->arWmiReady == FALSE) {
7886 + if(copy_from_user(&cmd, userdata,
7887 + sizeof(WMI_ADD_WOW_PATTERN_CMD)))
7889 + if (copy_from_user(pattern_data,
7891 + cmd.filter_size)){
7895 + if (copy_from_user(mask_data,
7896 + (userdata + 3 + cmd.filter_size),
7897 + cmd.filter_size)){
7901 + if (wmi_add_wow_pattern_cmd(ar->arWmi,
7902 + &cmd, pattern_data, mask_data, cmd.filter_size) != A_OK){
7907 +#undef WOW_PATTERN_SIZE
7908 +#undef WOW_MASK_SIZE
7911 + case AR6000_XIOCTL_WMI_DEL_WOW_PATTERN:
7913 + WMI_DEL_WOW_PATTERN_CMD delWowPattern;
7915 + if (ar->arWmiReady == FALSE) {
7917 + } else if (copy_from_user(&delWowPattern, userdata,
7918 + sizeof(delWowPattern)))
7922 + if (wmi_del_wow_pattern_cmd(ar->arWmi,
7923 + &delWowPattern) != A_OK)
7930 + case AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE:
7931 + if (ar->arHtcTarget != NULL) {
7932 + HTCDumpCreditStates(ar->arHtcTarget);
7935 + case AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE:
7936 + if (ar->arHtcTarget != NULL) {
7937 + struct ar6000_traffic_activity_change data;
7939 + if (copy_from_user(&data, userdata, sizeof(data)))
7943 + /* note, this is used for testing (mbox ping testing), indicate activity
7944 + * change using the stream ID as the traffic class */
7945 + ar6000_indicate_tx_activity(ar,
7946 + (A_UINT8)data.StreamID,
7947 + data.Active ? TRUE : FALSE);
7950 + case AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS:
7951 + if (ar->arWmiReady == FALSE) {
7953 + } else if (copy_from_user(&connectCtrlFlags, userdata,
7954 + sizeof(connectCtrlFlags)))
7958 + ar->arConnectCtrlFlags = connectCtrlFlags;
7961 + case AR6000_XIOCTL_WMI_SET_AKMP_PARAMS:
7962 + if (ar->arWmiReady == FALSE) {
7964 + } else if (copy_from_user(&akmpParams, userdata,
7965 + sizeof(WMI_SET_AKMP_PARAMS_CMD)))
7969 + if (wmi_set_akmp_params_cmd(ar->arWmi, &akmpParams) != A_OK) {
7974 + case AR6000_XIOCTL_WMI_SET_PMKID_LIST:
7975 + if (ar->arWmiReady == FALSE) {
7978 + if (copy_from_user(&pmkidInfo.numPMKID, userdata,
7979 + sizeof(pmkidInfo.numPMKID)))
7984 + if (copy_from_user(&pmkidInfo.pmkidList,
7985 + userdata + sizeof(pmkidInfo.numPMKID),
7986 + pmkidInfo.numPMKID * sizeof(WMI_PMKID)))
7991 + if (wmi_set_pmkid_list_cmd(ar->arWmi, &pmkidInfo) != A_OK) {
7996 + case AR6000_XIOCTL_WMI_GET_PMKID_LIST:
7997 + if (ar->arWmiReady == FALSE) {
8000 + if (wmi_get_pmkid_list_cmd(ar->arWmi) != A_OK) {
8006 + ret = -EOPNOTSUPP;
8011 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/netbuf.c b/drivers/sdio/function/wlan/ar6000/ar6000/netbuf.c
8012 new file mode 100644
8013 index 0000000..97b273b
8015 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/netbuf.c
8020 + * Copyright (c) 2004-2007 Atheros Communications Inc.
8021 + * All rights reserved.
8024 + * This program is free software; you can redistribute it and/or modify
8025 + * it under the terms of the GNU General Public License version 2 as
8026 + * published by the Free Software Foundation;
8028 + * Software distributed under the License is distributed on an "AS
8029 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8030 + * implied. See the License for the specific language governing
8031 + * rights and limitations under the License.
8036 +#include <linux/kernel.h>
8037 +#include <linux/skbuff.h>
8038 +#include <a_config.h>
8039 +#include "athdefs.h"
8040 +#include "a_types.h"
8041 +#include "a_osapi.h"
8042 +#include "htc_packet.h"
8044 +#define AR6000_DATA_OFFSET 64
8046 +void a_netbuf_enqueue(A_NETBUF_QUEUE_T *q, void *pkt)
8048 + skb_queue_tail((struct sk_buff_head *) q, (struct sk_buff *) pkt);
8051 +void a_netbuf_prequeue(A_NETBUF_QUEUE_T *q, void *pkt)
8053 + skb_queue_head((struct sk_buff_head *) q, (struct sk_buff *) pkt);
8056 +void *a_netbuf_dequeue(A_NETBUF_QUEUE_T *q)
8058 + return((void *) skb_dequeue((struct sk_buff_head *) q));
8061 +int a_netbuf_queue_size(A_NETBUF_QUEUE_T *q)
8063 + return(skb_queue_len((struct sk_buff_head *) q));
8066 +int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q)
8068 + return(skb_queue_empty((struct sk_buff_head *) q));
8071 +void a_netbuf_queue_init(A_NETBUF_QUEUE_T *q)
8073 + skb_queue_head_init((struct sk_buff_head *) q);
8077 +a_netbuf_alloc(int size)
8079 + struct sk_buff *skb;
8080 + skb = dev_alloc_skb(AR6000_DATA_OFFSET + sizeof(HTC_PACKET) + size);
8081 + skb_reserve(skb, AR6000_DATA_OFFSET + sizeof(HTC_PACKET));
8082 + return ((void *)skb);
8086 + * Allocate an SKB w.o. any encapsulation requirement.
8089 +a_netbuf_alloc_raw(int size)
8091 + struct sk_buff *skb;
8093 + skb = dev_alloc_skb(size);
8095 + return ((void *)skb);
8099 +a_netbuf_free(void *bufPtr)
8101 + struct sk_buff *skb = (struct sk_buff *)bufPtr;
8103 + dev_kfree_skb(skb);
8107 +a_netbuf_to_len(void *bufPtr)
8109 + return (((struct sk_buff *)bufPtr)->len);
8113 +a_netbuf_to_data(void *bufPtr)
8115 + return (((struct sk_buff *)bufPtr)->data);
8119 + * Add len # of bytes to the beginning of the network buffer
8120 + * pointed to by bufPtr
8123 +a_netbuf_push(void *bufPtr, A_INT32 len)
8125 + skb_push((struct sk_buff *)bufPtr, len);
8131 + * Add len # of bytes to the beginning of the network buffer
8132 + * pointed to by bufPtr and also fill with data
8135 +a_netbuf_push_data(void *bufPtr, char *srcPtr, A_INT32 len)
8137 + skb_push((struct sk_buff *) bufPtr, len);
8138 + A_MEMCPY(((struct sk_buff *)bufPtr)->data, srcPtr, len);
8144 + * Add len # of bytes to the end of the network buffer
8145 + * pointed to by bufPtr
8148 +a_netbuf_put(void *bufPtr, A_INT32 len)
8150 + skb_put((struct sk_buff *)bufPtr, len);
8156 + * Add len # of bytes to the end of the network buffer
8157 + * pointed to by bufPtr and also fill with data
8160 +a_netbuf_put_data(void *bufPtr, char *srcPtr, A_INT32 len)
8162 + char *start = ((struct sk_buff *)bufPtr)->data +
8163 + ((struct sk_buff *)bufPtr)->len;
8164 + skb_put((struct sk_buff *)bufPtr, len);
8165 + A_MEMCPY(start, srcPtr, len);
8172 + * Trim the network buffer pointed to by bufPtr to len # of bytes
8175 +a_netbuf_setlen(void *bufPtr, A_INT32 len)
8177 + skb_trim((struct sk_buff *)bufPtr, len);
8183 + * Chop of len # of bytes from the end of the buffer.
8186 +a_netbuf_trim(void *bufPtr, A_INT32 len)
8188 + skb_trim((struct sk_buff *)bufPtr, ((struct sk_buff *)bufPtr)->len - len);
8194 + * Chop of len # of bytes from the end of the buffer and return the data.
8197 +a_netbuf_trim_data(void *bufPtr, char *dstPtr, A_INT32 len)
8199 + char *start = ((struct sk_buff *)bufPtr)->data +
8200 + (((struct sk_buff *)bufPtr)->len - len);
8202 + A_MEMCPY(dstPtr, start, len);
8203 + skb_trim((struct sk_buff *)bufPtr, ((struct sk_buff *)bufPtr)->len - len);
8210 + * Returns the number of bytes available to a a_netbuf_push()
8213 +a_netbuf_headroom(void *bufPtr)
8215 + return (skb_headroom((struct sk_buff *)bufPtr));
8219 + * Removes specified number of bytes from the beginning of the buffer
8222 +a_netbuf_pull(void *bufPtr, A_INT32 len)
8224 + skb_pull((struct sk_buff *)bufPtr, len);
8230 + * Removes specified number of bytes from the beginning of the buffer
8231 + * and return the data
8234 +a_netbuf_pull_data(void *bufPtr, char *dstPtr, A_INT32 len)
8236 + A_MEMCPY(dstPtr, ((struct sk_buff *)bufPtr)->data, len);
8237 + skb_pull((struct sk_buff *)bufPtr, len);
8242 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/osapi_linux.h b/drivers/sdio/function/wlan/ar6000/ar6000/osapi_linux.h
8243 new file mode 100644
8244 index 0000000..5b64212
8246 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/osapi_linux.h
8249 + * $Id: //depot/sw/releases/olca2.0-GPL/host/os/linux/include/osapi_linux.h#1 $
8251 + * This file contains the definitions of the basic atheros data types.
8252 + * It is used to map the data types in atheros files to a platform specific
8255 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
8258 + * This program is free software; you can redistribute it and/or modify
8259 + * it under the terms of the GNU General Public License version 2 as
8260 + * published by the Free Software Foundation;
8262 + * Software distributed under the License is distributed on an "AS
8263 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8264 + * implied. See the License for the specific language governing
8265 + * rights and limitations under the License.
8271 +#ifndef _OSAPI_LINUX_H_
8272 +#define _OSAPI_LINUX_H_
8276 +#include <linux/version.h>
8277 +#include <linux/types.h>
8278 +#include <linux/kernel.h>
8279 +#include <linux/string.h>
8280 +#include <linux/skbuff.h>
8281 +#include <linux/netdevice.h>
8282 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
8283 +#include <linux/jiffies.h>
8285 +#include <linux/timer.h>
8286 +#include <linux/delay.h>
8287 +#include <linux/wait.h>
8289 +#include <asm/arch/irq.h>
8290 +#include <asm/irq.h>
8294 +#define __ATTRIB_PACK __attribute__ ((packed))
8295 +#define __ATTRIB_PRINTF __attribute__ ((format (printf, 1, 2)))
8296 +#define __ATTRIB_NORETURN __attribute__ ((noreturn))
8298 +#define INLINE __inline__
8300 +#else /* Not GCC */
8301 +#define __ATTRIB_PACK
8302 +#define __ATTRIB_PRINTF
8303 +#define __ATTRIB_NORETURN
8305 +#define INLINE __inline
8307 +#endif /* End __GNUC__ */
8310 +#define POSTPACK __ATTRIB_PACK
8315 +#define A_BE2CPU8(x) ntohb(x)
8316 +#define A_BE2CPU16(x) ntohs(x)
8317 +#define A_BE2CPU32(x) ntohl(x)
8319 +#define A_LE2CPU8(x) (x)
8320 +#define A_LE2CPU16(x) (x)
8321 +#define A_LE2CPU32(x) (x)
8323 +#define A_CPU2BE8(x) htonb(x)
8324 +#define A_CPU2BE16(x) htons(x)
8325 +#define A_CPU2BE32(x) htonl(x)
8327 +#define A_MEMCPY(dst, src, len) memcpy((A_UINT8 *)(dst), (src), (len))
8328 +#define A_MEMZERO(addr, len) memset(addr, 0, len)
8329 +#define A_MEMCMP(addr1, addr2, len) memcmp((addr1), (addr2), (len))
8330 +#define A_MALLOC(size) kmalloc((size), GFP_KERNEL)
8331 +#define A_MALLOC_NOWAIT(size) kmalloc((size), GFP_ATOMIC)
8332 +#define A_FREE(addr) kfree(addr)
8333 +#define A_PRINTF(args...) printk(args)
8335 +/* Mutual Exclusion */
8336 +typedef spinlock_t A_MUTEX_T;
8337 +#define A_MUTEX_INIT(mutex) spin_lock_init(mutex)
8338 +#define A_MUTEX_LOCK(mutex) spin_lock_bh(mutex)
8339 +#define A_MUTEX_UNLOCK(mutex) spin_unlock_bh(mutex)
8340 +#define A_IS_MUTEX_VALID(mutex) TRUE /* okay to return true, since A_MUTEX_DELETE does nothing */
8341 +#define A_MUTEX_DELETE(mutex) /* spin locks are not kernel resources so nothing to free.. */
8343 +/* Get current time in ms adding a constant offset (in ms) */
8344 +#define A_GET_MS(offset) \
8345 + (jiffies + ((offset) / 1000) * HZ)
8350 +#define A_MDELAY(msecs) mdelay(msecs)
8351 +typedef struct timer_list A_TIMER;
8353 +#define A_INIT_TIMER(pTimer, pFunction, pArg) do { \
8354 + init_timer(pTimer); \
8355 + (pTimer)->function = (pFunction); \
8356 + (pTimer)->data = (unsigned long)(pArg); \
8360 + * Start a Timer that elapses after 'periodMSec' milli-seconds
8361 + * Support is provided for a one-shot timer. The 'repeatFlag' is
8364 +#define A_TIMEOUT_MS(pTimer, periodMSec, repeatFlag) do { \
8365 + if (repeatFlag) { \
8366 + printk("\n" __FILE__ ":%d: Timer Repeat requested\n",__LINE__); \
8367 + panic("Timer Repeat"); \
8369 + mod_timer((pTimer), jiffies + HZ * (periodMSec) / 1000); \
8373 + * Cancel the Timer.
8375 +#define A_UNTIMEOUT(pTimer) do { \
8376 + del_timer((pTimer)); \
8379 +#define A_DELETE_TIMER(pTimer) do { \
8383 + * Wait Queue related functions
8385 +typedef wait_queue_head_t A_WAITQUEUE_HEAD;
8386 +#define A_INIT_WAITQUEUE_HEAD(head) init_waitqueue_head(head)
8387 +#ifndef wait_event_interruptible_timeout
8388 +#define __wait_event_interruptible_timeout(wq, condition, ret) \
8390 + wait_queue_t __wait; \
8391 + init_waitqueue_entry(&__wait, current); \
8393 + add_wait_queue(&wq, &__wait); \
8395 + set_current_state(TASK_INTERRUPTIBLE); \
8398 + if (!signal_pending(current)) { \
8399 + ret = schedule_timeout(ret); \
8404 + ret = -ERESTARTSYS; \
8407 + current->state = TASK_RUNNING; \
8408 + remove_wait_queue(&wq, &__wait); \
8411 +#define wait_event_interruptible_timeout(wq, condition, timeout) \
8413 + long __ret = timeout; \
8414 + if (!(condition)) \
8415 + __wait_event_interruptible_timeout(wq, condition, __ret); \
8418 +#endif /* wait_event_interruptible_timeout */
8420 +#define A_WAIT_EVENT_INTERRUPTIBLE_TIMEOUT(head, condition, timeout) do { \
8421 + wait_event_interruptible_timeout(head, condition, timeout); \
8424 +#define A_WAKE_UP(head) wake_up(head)
8427 +#define A_ASSERT(expr) \
8429 + printk(KERN_ALERT "\n" __FILE__ ":%d: Assertion " #expr " failed!\n",__LINE__); \
8434 +#define A_ASSERT(expr)
8438 + * Initialization of the network buffer subsystem
8440 +#define A_NETBUF_INIT()
8443 + * Network buffer queue support
8445 +typedef struct sk_buff_head A_NETBUF_QUEUE_T;
8447 +#define A_NETBUF_QUEUE_INIT(q) \
8448 + a_netbuf_queue_init(q)
8450 +#define A_NETBUF_ENQUEUE(q, pkt) \
8451 + a_netbuf_enqueue((q), (pkt))
8452 +#define A_NETBUF_PREQUEUE(q, pkt) \
8453 + a_netbuf_prequeue((q), (pkt))
8454 +#define A_NETBUF_DEQUEUE(q) \
8455 + (a_netbuf_dequeue(q))
8456 +#define A_NETBUF_QUEUE_SIZE(q) \
8457 + a_netbuf_queue_size(q)
8458 +#define A_NETBUF_QUEUE_EMPTY(q) \
8459 + a_netbuf_queue_empty(q)
8462 + * Network buffer support
8464 +#define A_NETBUF_ALLOC(size) \
8465 + a_netbuf_alloc(size)
8466 +#define A_NETBUF_ALLOC_RAW(size) \
8467 + a_netbuf_alloc_raw(size)
8468 +#define A_NETBUF_FREE(bufPtr) \
8469 + a_netbuf_free(bufPtr)
8470 +#define A_NETBUF_DATA(bufPtr) \
8471 + a_netbuf_to_data(bufPtr)
8472 +#define A_NETBUF_LEN(bufPtr) \
8473 + a_netbuf_to_len(bufPtr)
8474 +#define A_NETBUF_PUSH(bufPtr, len) \
8475 + a_netbuf_push(bufPtr, len)
8476 +#define A_NETBUF_PUT(bufPtr, len) \
8477 + a_netbuf_put(bufPtr, len)
8478 +#define A_NETBUF_TRIM(bufPtr,len) \
8479 + a_netbuf_trim(bufPtr, len)
8480 +#define A_NETBUF_PULL(bufPtr, len) \
8481 + a_netbuf_pull(bufPtr, len)
8482 +#define A_NETBUF_HEADROOM(bufPtr)\
8483 + a_netbuf_headroom(bufPtr)
8484 +#define A_NETBUF_SETLEN(bufPtr,len) \
8485 + a_netbuf_setlen(bufPtr, len)
8487 +/* Add data to end of a buffer */
8488 +#define A_NETBUF_PUT_DATA(bufPtr, srcPtr, len) \
8489 + a_netbuf_put_data(bufPtr, srcPtr, len)
8491 +/* Add data to start of the buffer */
8492 +#define A_NETBUF_PUSH_DATA(bufPtr, srcPtr, len) \
8493 + a_netbuf_push_data(bufPtr, srcPtr, len)
8495 +/* Remove data at start of the buffer */
8496 +#define A_NETBUF_PULL_DATA(bufPtr, dstPtr, len) \
8497 + a_netbuf_pull_data(bufPtr, dstPtr, len)
8499 +/* Remove data from the end of the buffer */
8500 +#define A_NETBUF_TRIM_DATA(bufPtr, dstPtr, len) \
8501 + a_netbuf_trim_data(bufPtr, dstPtr, len)
8503 +/* View data as "size" contiguous bytes of type "t" */
8504 +#define A_NETBUF_VIEW_DATA(bufPtr, t, size) \
8505 + (t )( ((struct skbuf *)(bufPtr))->data)
8507 +/* return the beginning of the headroom for the buffer */
8508 +#define A_NETBUF_HEAD(bufPtr) \
8509 + ((((struct sk_buff *)(bufPtr))->head))
8512 + * OS specific network buffer access routines
8514 +void *a_netbuf_alloc(int size);
8515 +void *a_netbuf_alloc_raw(int size);
8516 +void a_netbuf_free(void *bufPtr);
8517 +void *a_netbuf_to_data(void *bufPtr);
8518 +A_UINT32 a_netbuf_to_len(void *bufPtr);
8519 +A_STATUS a_netbuf_push(void *bufPtr, A_INT32 len);
8520 +A_STATUS a_netbuf_push_data(void *bufPtr, char *srcPtr, A_INT32 len);
8521 +A_STATUS a_netbuf_put(void *bufPtr, A_INT32 len);
8522 +A_STATUS a_netbuf_put_data(void *bufPtr, char *srcPtr, A_INT32 len);
8523 +A_STATUS a_netbuf_pull(void *bufPtr, A_INT32 len);
8524 +A_STATUS a_netbuf_pull_data(void *bufPtr, char *dstPtr, A_INT32 len);
8525 +A_STATUS a_netbuf_trim(void *bufPtr, A_INT32 len);
8526 +A_STATUS a_netbuf_trim_data(void *bufPtr, char *dstPtr, A_INT32 len);
8527 +A_STATUS a_netbuf_setlen(void *bufPtr, A_INT32 len);
8528 +A_INT32 a_netbuf_headroom(void *bufPtr);
8529 +void a_netbuf_enqueue(A_NETBUF_QUEUE_T *q, void *pkt);
8530 +void a_netbuf_prequeue(A_NETBUF_QUEUE_T *q, void *pkt);
8531 +void *a_netbuf_dequeue(A_NETBUF_QUEUE_T *q);
8532 +int a_netbuf_queue_size(A_NETBUF_QUEUE_T *q);
8533 +int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q);
8534 +int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q);
8535 +void a_netbuf_queue_init(A_NETBUF_QUEUE_T *q);
8538 + * Kernel v.s User space functions
8540 +A_UINT32 a_copy_to_user(void *to, const void *from, A_UINT32 n);
8541 +A_UINT32 a_copy_from_user(void *to, const void *from, A_UINT32 n);
8543 +#else /* __KERNEL__ */
8546 +#define __ATTRIB_PACK __attribute__ ((packed))
8547 +#define __ATTRIB_PRINTF __attribute__ ((format (printf, 1, 2)))
8548 +#define __ATTRIB_NORETURN __attribute__ ((noreturn))
8550 +#define INLINE __inline__
8552 +#else /* Not GCC */
8553 +#define __ATTRIB_PACK
8554 +#define __ATTRIB_PRINTF
8555 +#define __ATTRIB_NORETURN
8557 +#define INLINE __inline
8559 +#endif /* End __GNUC__ */
8562 +#define POSTPACK __ATTRIB_PACK
8564 +#endif /* __KERNEL__ */
8566 +#endif /* _OSAPI_LINUX_H_ */
8567 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/wireless_ext.c b/drivers/sdio/function/wlan/ar6000/ar6000/wireless_ext.c
8568 new file mode 100644
8569 index 0000000..d775e4d
8571 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/wireless_ext.c
8575 + * Copyright (c) 2004-2007 Atheros Communications Inc.
8576 + * All rights reserved.
8579 + * This program is free software; you can redistribute it and/or modify
8580 + * it under the terms of the GNU General Public License version 2 as
8581 + * published by the Free Software Foundation;
8583 + * Software distributed under the License is distributed on an "AS
8584 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8585 + * implied. See the License for the specific language governing
8586 + * rights and limitations under the License.
8592 +#include "ar6000_drv.h"
8594 +static A_UINT8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
8595 +static void ar6000_set_quality(struct iw_quality *iq, A_INT8 rssi);
8596 +extern unsigned int wmitimeout;
8597 +extern A_WAITQUEUE_HEAD arEvent;
8598 +extern wait_queue_head_t ar6000_scan_queue;
8601 + * Encode a WPA or RSN information element as a custom
8602 + * element using the hostap format.
8605 +encode_ie(void *buf, size_t bufsize,
8606 + const u_int8_t *ie, size_t ielen,
8607 + const char *leader, size_t leader_len)
8612 + if (bufsize < leader_len)
8615 + memcpy(p, leader, leader_len);
8616 + bufsize -= leader_len;
8618 + for (i = 0; i < ielen && bufsize > 2; i++)
8619 + p += sprintf(p, "%02x", ie[i]);
8620 + return (i == ielen ? p - (u_int8_t *)buf : 0);
8624 +ar6000_scan_node(void *arg, bss_t *ni)
8626 + struct iw_event iwe;
8627 +#if WIRELESS_EXT > 14
8628 + char buf[64*2 + 30];
8630 + struct ar_giwscan_param *param;
8631 + A_CHAR *current_ev;
8633 + struct ieee80211_common_ie *cie;
8635 + param = (struct ar_giwscan_param *)arg;
8637 + if (param->current_ev >= param->end_buf) {
8640 + if ((param->firstPass == TRUE) &&
8641 + ((ni->ni_cie.ie_wpa == NULL) && (ni->ni_cie.ie_rsn == NULL))) {
8643 + * Only forward wpa bss's in first pass
8648 + if ((param->firstPass == FALSE) &&
8649 + ((ni->ni_cie.ie_wpa != NULL) || (ni->ni_cie.ie_rsn != NULL))) {
8651 + * Only forward non-wpa bss's in 2nd pass
8656 + current_ev = param->current_ev;
8657 + end_buf = param->end_buf;
8659 + cie = &ni->ni_cie;
8661 + A_MEMZERO(&iwe, sizeof(iwe));
8662 + iwe.cmd = SIOCGIWAP;
8663 + iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
8664 + A_MEMCPY(iwe.u.ap_addr.sa_data, ni->ni_macaddr, 6);
8665 + current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
8668 + A_MEMZERO(&iwe, sizeof(iwe));
8669 + iwe.cmd = SIOCGIWESSID;
8670 + iwe.u.data.flags = 1;
8671 + iwe.u.data.length = cie->ie_ssid[1];
8672 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
8673 + &cie->ie_ssid[2]);
8675 + if (cie->ie_capInfo & (IEEE80211_CAPINFO_ESS|IEEE80211_CAPINFO_IBSS)) {
8676 + A_MEMZERO(&iwe, sizeof(iwe));
8677 + iwe.cmd = SIOCGIWMODE;
8678 + iwe.u.mode = cie->ie_capInfo & IEEE80211_CAPINFO_ESS ?
8679 + IW_MODE_MASTER : IW_MODE_ADHOC;
8680 + current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
8684 + A_MEMZERO(&iwe, sizeof(iwe));
8685 + iwe.cmd = SIOCGIWFREQ;
8686 + iwe.u.freq.m = cie->ie_chan * 100000;
8688 + current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
8691 + A_MEMZERO(&iwe, sizeof(iwe));
8692 + iwe.cmd = IWEVQUAL;
8693 + ar6000_set_quality(&iwe.u.qual, ni->ni_snr);
8694 + current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
8697 + A_MEMZERO(&iwe, sizeof(iwe));
8698 + iwe.cmd = SIOCGIWENCODE;
8699 + if (cie->ie_capInfo & IEEE80211_CAPINFO_PRIVACY) {
8700 + iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
8702 + iwe.u.data.flags = IW_ENCODE_DISABLED;
8704 + iwe.u.data.length = 0;
8705 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
8707 + A_MEMZERO(&iwe, sizeof(iwe));
8708 + iwe.cmd = IWEVCUSTOM;
8709 + snprintf(buf, sizeof(buf), "bcn_int=%d", cie->ie_beaconInt);
8710 + iwe.u.data.length = strlen(buf);
8711 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
8713 + if (cie->ie_wpa != NULL) {
8714 + static const char wpa_leader[] = "wpa_ie=";
8716 + A_MEMZERO(&iwe, sizeof(iwe));
8717 + iwe.cmd = IWEVCUSTOM;
8718 + iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_wpa,
8720 + wpa_leader, sizeof(wpa_leader)-1);
8722 + if (iwe.u.data.length != 0) {
8723 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
8727 + if (cie->ie_rsn != NULL && cie->ie_rsn[0] == IEEE80211_ELEMID_RSN) {
8728 + static const char rsn_leader[] = "rsn_ie=";
8730 + A_MEMZERO(&iwe, sizeof(iwe));
8731 + iwe.cmd = IWEVCUSTOM;
8732 + iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_rsn,
8734 + rsn_leader, sizeof(rsn_leader)-1);
8736 + if (iwe.u.data.length != 0) {
8737 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
8741 + if (cie->ie_wmm != NULL) {
8742 + static const char wmm_leader[] = "wmm_ie=";
8744 + A_MEMZERO(&iwe, sizeof(iwe));
8745 + iwe.cmd = IWEVCUSTOM;
8746 + iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_wmm,
8748 + wmm_leader, sizeof(wmm_leader)-1);
8749 + if (iwe.u.data.length != 0) {
8750 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
8754 + if (cie->ie_ath != NULL) {
8755 + static const char ath_leader[] = "ath_ie=";
8757 + A_MEMZERO(&iwe, sizeof(iwe));
8758 + iwe.cmd = IWEVCUSTOM;
8759 + iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_ath,
8761 + ath_leader, sizeof(ath_leader)-1);
8762 + if (iwe.u.data.length != 0) {
8763 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
8767 + param->current_ev = current_ev;
8771 +ar6000_ioctl_giwscan(struct net_device *dev,
8772 + struct iw_request_info *info,
8773 + struct iw_point *data, char *extra)
8775 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
8776 + struct ar_giwscan_param param;
8779 + if (ar->arWlanState == WLAN_DISABLED) {
8783 + if (ar->arWmiReady == FALSE) {
8787 + param.current_ev = extra;
8788 + param.end_buf = extra + IW_SCAN_MAX_DATA;
8789 + param.firstPass = TRUE;
8792 + * Do two passes to insure WPA scan candidates
8793 + * are sorted to the front. This is a hack to deal with
8794 + * the wireless extensions capping scan results at
8795 + * IW_SCAN_MAX_DATA bytes. In densely populated environments
8796 + * it's easy to overflow this buffer (especially with WPA/RSN
8797 + * information elements). Note this sorting hack does not
8798 + * guarantee we won't overflow anyway.
8800 + for (i = 0; i < 2; i++) {
8802 + * Translate data to WE format.
8804 + wmi_iterate_nodes(ar->arWmi, ar6000_scan_node, ¶m);
8805 + param.firstPass = FALSE;
8806 + if (param.current_ev >= param.end_buf) {
8807 + data->length = param.current_ev - extra;
8812 + if(!(data->length = param.current_ev - extra)) {
8813 + printk("%s(): data length %d\n", __FUNCTION__, data->length);
8819 +extern int reconnect_flag;
8822 +ar6000_ioctl_siwessid(struct net_device *dev,
8823 + struct iw_request_info *info,
8824 + struct iw_point *data, char *ssid)
8826 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
8828 + A_UINT8 arNetworkType;
8830 + if (ar->arWlanState == WLAN_DISABLED) {
8834 + if (ar->arWmiReady == FALSE) {
8839 + * iwconfig passes a null terminated string with length including this
8840 + * so we need to account for this
8842 + if (data->flags && (!data->length || (data->length == 1) ||
8843 + ((data->length - 1) > sizeof(ar->arSsid))))
8850 + /* Added for bug 25178, return an IOCTL error instead of target returning
8851 + Illegal parameter error when either the BSSID or channel is missing
8852 + and we cannot scan during connect.
8854 + if (data->flags) {
8855 + if (ar->arSkipScan == TRUE &&
8856 + (ar->arChannelHint == 0 ||
8857 + (!ar->arReqBssid[0] && !ar->arReqBssid[1] && !ar->arReqBssid[2] &&
8858 + !ar->arReqBssid[3] && !ar->arReqBssid[4] && !ar->arReqBssid[5])))
8864 + if (down_interruptible(&ar->arSem)) {
8865 + return -ERESTARTSYS;
8868 + if (ar->arTxPending[WMI_CONTROL_PRI]) {
8870 + * sleep until the command queue drains
8872 + wait_event_interruptible_timeout(arEvent,
8873 + ar->arTxPending[WMI_CONTROL_PRI] == 0, wmitimeout * HZ);
8874 + if (signal_pending(current)) {
8879 + if (!data->flags) {
8880 + arNetworkType = ar->arNetworkType;
8881 + ar6000_init_profile_info(ar);
8882 + ar->arNetworkType = arNetworkType;
8885 + if ((ar->arSsidLen) || (!data->flags))
8887 + if ((!data->flags) ||
8888 + (A_MEMCMP(ar->arSsid, ssid, ar->arSsidLen) != 0) ||
8889 + (ar->arSsidLen != (data->length)))
8892 + * SSID set previously or essid off has been issued.
8894 + * Disconnect Command is issued in two cases after wmi is ready
8895 + * (1) ssid is different from the previous setting
8896 + * (2) essid off has been issued
8899 + if (ar->arWmiReady == TRUE) {
8900 + reconnect_flag = 0;
8901 + status = wmi_disconnect_cmd(ar->arWmi);
8902 + A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
8903 + ar->arSsidLen = 0;
8904 + if (ar->arSkipScan == FALSE) {
8905 + A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
8907 + if (!data->flags) {
8918 + * SSID is same, so we assume profile hasn't changed.
8919 + * If the interface is up and wmi is ready, we issue
8920 + * a reconnect cmd. Issue a reconnect only we are already
8923 + if((ar->arConnected == TRUE) && (ar->arWmiReady == TRUE))
8925 + reconnect_flag = TRUE;
8926 + status = wmi_reconnect_cmd(ar->arWmi,ar->arReqBssid,
8927 + ar->arChannelHint);
8929 + if (status != A_OK) {
8936 + * Dont return if connect is pending.
8938 + if(!(ar->arConnectPending)) {
8946 + ar->arSsidLen = data->length;
8947 + A_MEMCPY(ar->arSsid, ssid, ar->arSsidLen);
8949 + /* The ssid length check prevents second "essid off" from the user,
8950 + to be treated as a connect cmd. The second "essid off" is ignored.
8952 + if((ar->arWmiReady == TRUE) && (ar->arSsidLen > 0) )
8954 + AR6000_SPIN_LOCK(&ar->arLock, 0);
8955 + if (SHARED_AUTH == ar->arDot11AuthMode) {
8956 + ar6000_install_static_wep_keys(ar);
8958 + AR_DEBUG_PRINTF("Connect called with authmode %d dot11 auth %d"\
8959 + " PW crypto %d PW crypto Len %d GRP crypto %d"\
8960 + " GRP crypto Len %d\n",
8961 + ar->arAuthMode, ar->arDot11AuthMode,
8962 + ar->arPairwiseCrypto, ar->arPairwiseCryptoLen,
8963 + ar->arGroupCrypto, ar->arGroupCryptoLen);
8964 + reconnect_flag = 0;
8965 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
8966 + status = wmi_connect_cmd(ar->arWmi, ar->arNetworkType,
8967 + ar->arDot11AuthMode, ar->arAuthMode,
8968 + ar->arPairwiseCrypto, ar->arPairwiseCryptoLen,
8969 + ar->arGroupCrypto,ar->arGroupCryptoLen,
8970 + ar->arSsidLen, ar->arSsid,
8971 + ar->arReqBssid, ar->arChannelHint,
8972 + ar->arConnectCtrlFlags);
8977 + if (status != A_OK) {
8980 + ar->arConnectPending = TRUE;
8989 +ar6000_ioctl_giwessid(struct net_device *dev,
8990 + struct iw_request_info *info,
8991 + struct iw_point *data, char *essid)
8993 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
8995 + if (ar->arWlanState == WLAN_DISABLED) {
8999 + if (!ar->arSsidLen) {
9004 + data->length = ar->arSsidLen;
9005 + A_MEMCPY(essid, ar->arSsid, ar->arSsidLen);
9011 +void ar6000_install_static_wep_keys(AR_SOFTC_T *ar)
9016 + for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) {
9017 + if (ar->arWepKeyList[index].arKeyLen) {
9018 + keyUsage = GROUP_USAGE;
9019 + if (index == ar->arDefTxKeyIndex) {
9020 + keyUsage |= TX_USAGE;
9022 + wmi_addKey_cmd(ar->arWmi,
9026 + ar->arWepKeyList[index].arKeyLen,
9028 + ar->arWepKeyList[index].arKey, KEY_OP_INIT_VAL,
9035 +ar6000_ioctl_delkey(struct net_device *dev, struct iw_request_info *info,
9036 + void *w, char *extra)
9042 +ar6000_ioctl_setmlme(struct net_device *dev, struct iw_request_info *info,
9043 + void *w, char *extra)
9045 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9046 + struct ieee80211req_mlme *mlme = (struct ieee80211req_mlme *)extra;
9048 + if ((ar->arWmiReady == FALSE) || (ar->arConnected != TRUE))
9051 + switch (mlme->im_op) {
9052 + case IEEE80211_MLME_DISASSOC:
9053 + case IEEE80211_MLME_DEAUTH:
9054 + /* Not Supported */
9064 +ar6000_ioctl_setwmmparams(struct net_device *dev, struct iw_request_info *info,
9065 + void *w, char *extra)
9067 + return -EIO; /* for now */
9071 +ar6000_ioctl_getwmmparams(struct net_device *dev, struct iw_request_info *info,
9072 + void *w, char *extra)
9074 + return -EIO; /* for now */
9077 +int ar6000_ioctl_setoptie(struct net_device *dev, struct iw_request_info *info,
9078 + struct iw_point *data, char *extra)
9080 + /* The target generates the WPA/RSN IE */
9085 +ar6000_ioctl_setauthalg(struct net_device *dev, struct iw_request_info *info,
9086 + void *w, char *extra)
9088 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9089 + struct ieee80211req_authalg *req = (struct ieee80211req_authalg *)extra;
9093 + AR6000_SPIN_LOCK(&ar->arLock, 0);
9095 + if (req->auth_alg == AUTH_ALG_OPEN_SYSTEM) {
9096 + ar->arDot11AuthMode = OPEN_AUTH;
9097 + } else if (req->auth_alg == AUTH_ALG_LEAP) {
9098 + ar->arDot11AuthMode = LEAP_AUTH;
9099 + ar->arPairwiseCrypto = WEP_CRYPT;
9100 + ar->arGroupCrypto = WEP_CRYPT;
9105 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
9110 +ar6000_ioctl_addpmkid(struct net_device *dev, struct iw_request_info *info,
9111 + void *w, char *extra)
9113 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9114 + struct ieee80211req_addpmkid *req = (struct ieee80211req_addpmkid *)extra;
9117 + if (ar->arWlanState == WLAN_DISABLED) {
9121 + AR_DEBUG_PRINTF("Add pmkid for %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x en=%d\n",
9122 + req->pi_bssid[0], req->pi_bssid[1], req->pi_bssid[2],
9123 + req->pi_bssid[3], req->pi_bssid[4], req->pi_bssid[5],
9126 + status = wmi_setPmkid_cmd(ar->arWmi, req->pi_bssid, req->pi_pmkid,
9129 + if (status != A_OK) {
9140 +ar6000_ioctl_siwrate(struct net_device *dev,
9141 + struct iw_request_info *info,
9142 + struct iw_param *rrq, char *extra)
9144 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9148 + kbps = rrq->value / 1000; /* rrq->value is in bps */
9150 + kbps = -1; /* -1 indicates auto rate */
9152 + if(kbps != -1 && wmi_validate_bitrate(ar->arWmi, kbps) == A_EINVAL)
9154 + AR_DEBUG_PRINTF("BitRate is not Valid %d\n", kbps);
9157 + ar->arBitRate = kbps;
9158 + if(ar->arWmiReady == TRUE)
9160 + if (wmi_set_bitrate_cmd(ar->arWmi, kbps) != A_OK) {
9171 +ar6000_ioctl_giwrate(struct net_device *dev,
9172 + struct iw_request_info *info,
9173 + struct iw_param *rrq, char *extra)
9175 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9178 + if (down_interruptible(&ar->arSem)) {
9179 + return -ERESTARTSYS;
9181 + if(ar->arWmiReady == TRUE)
9183 + ar->arBitRate = 0xFFFF;
9184 + if (wmi_get_bitrate_cmd(ar->arWmi) != A_OK) {
9188 + wait_event_interruptible_timeout(arEvent, ar->arBitRate != 0xFFFF, wmitimeout * HZ);
9189 + if (signal_pending(current)) {
9193 + /* If the interface is down or wmi is not ready or the target is not
9194 + connected - return the value stored in the device structure */
9196 + if (ar->arBitRate == -1) {
9197 + rrq->fixed = TRUE;
9200 + rrq->value = ar->arBitRate * 1000;
9213 +ar6000_ioctl_siwtxpow(struct net_device *dev,
9214 + struct iw_request_info *info,
9215 + struct iw_param *rrq, char *extra)
9217 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9220 + if (ar->arWlanState == WLAN_DISABLED) {
9224 + if (rrq->disabled) {
9225 + return -EOPNOTSUPP;
9229 + if (rrq->flags != IW_TXPOW_DBM) {
9230 + return -EOPNOTSUPP;
9232 + ar->arTxPwr= dbM = rrq->value;
9233 + ar->arTxPwrSet = TRUE;
9235 + ar->arTxPwr = dbM = 0;
9236 + ar->arTxPwrSet = FALSE;
9238 + if(ar->arWmiReady == TRUE)
9240 + AR_DEBUG_PRINTF("Set tx pwr cmd %d dbM\n", dbM);
9241 + wmi_set_txPwr_cmd(ar->arWmi, dbM);
9250 +ar6000_ioctl_giwtxpow(struct net_device *dev,
9251 + struct iw_request_info *info,
9252 + struct iw_param *rrq, char *extra)
9254 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9257 + if (ar->arWlanState == WLAN_DISABLED) {
9261 + if (down_interruptible(&ar->arSem)) {
9262 + return -ERESTARTSYS;
9264 + if((ar->arWmiReady == TRUE) && (ar->arConnected == TRUE))
9268 + if (wmi_get_txPwr_cmd(ar->arWmi) != A_OK) {
9273 + wait_event_interruptible_timeout(arEvent, ar->arTxPwr != 0, wmitimeout * HZ);
9275 + if (signal_pending(current)) {
9279 + /* If the interace is down or wmi is not ready or target is not connected
9280 + then return value stored in the device structure */
9283 + if (ar->arTxPwrSet == TRUE) {
9284 + rrq->fixed = TRUE;
9286 + rrq->value = ar->arTxPwr;
9287 + rrq->flags = IW_TXPOW_DBM;
9297 + * since iwconfig only provides us with one max retry value, we use it
9298 + * to apply to data frames of the BE traffic class.
9301 +ar6000_ioctl_siwretry(struct net_device *dev,
9302 + struct iw_request_info *info,
9303 + struct iw_param *rrq, char *extra)
9305 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9307 + if (ar->arWlanState == WLAN_DISABLED) {
9311 + if (rrq->disabled) {
9312 + return -EOPNOTSUPP;
9315 + if ((rrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) {
9316 + return -EOPNOTSUPP;
9319 + if ( !(rrq->value >= WMI_MIN_RETRIES) || !(rrq->value <= WMI_MAX_RETRIES)) {
9322 + if(ar->arWmiReady == TRUE)
9324 + if (wmi_set_retry_limits_cmd(ar->arWmi, DATA_FRAMETYPE, WMM_AC_BE,
9325 + rrq->value, 0) != A_OK){
9329 + ar->arMaxRetries = rrq->value;
9337 +ar6000_ioctl_giwretry(struct net_device *dev,
9338 + struct iw_request_info *info,
9339 + struct iw_param *rrq, char *extra)
9341 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9343 + if (ar->arWlanState == WLAN_DISABLED) {
9347 + rrq->disabled = 0;
9348 + switch (rrq->flags & IW_RETRY_TYPE) {
9349 + case IW_RETRY_LIFETIME:
9350 + return -EOPNOTSUPP;
9352 + case IW_RETRY_LIMIT:
9353 + rrq->flags = IW_RETRY_LIMIT;
9354 + switch (rrq->flags & IW_RETRY_MODIFIER) {
9355 + case IW_RETRY_MIN:
9356 + rrq->flags |= IW_RETRY_MIN;
9357 + rrq->value = WMI_MIN_RETRIES;
9359 + case IW_RETRY_MAX:
9360 + rrq->flags |= IW_RETRY_MAX;
9361 + rrq->value = ar->arMaxRetries;
9373 +ar6000_ioctl_siwencode(struct net_device *dev,
9374 + struct iw_request_info *info,
9375 + struct iw_point *erq, char *keybuf)
9377 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9379 + A_INT32 auth = ar->arDot11AuthMode;
9381 + * Static WEP Keys should be configured before setting the SSID
9383 + if (ar->arSsidLen) {
9387 + if (ar->arWlanState == WLAN_DISABLED) {
9391 + index = erq->flags & IW_ENCODE_INDEX;
9393 + if (index && (((index - 1) < WMI_MIN_KEY_INDEX) ||
9394 + ((index - 1) > WMI_MAX_KEY_INDEX)))
9399 + if (erq->flags & IW_ENCODE_DISABLED) {
9401 + * Encryption disabled
9405 + * If key index was specified then clear the specified key
9408 + A_MEMZERO(ar->arWepKeyList[index].arKey,
9409 + sizeof(ar->arWepKeyList[index].arKey));
9410 + ar->arWepKeyList[index].arKeyLen = 0;
9412 + ar->arDot11AuthMode = OPEN_AUTH;
9413 + ar->arPairwiseCrypto = NONE_CRYPT;
9414 + ar->arGroupCrypto = NONE_CRYPT;
9415 + ar->arAuthMode = NONE_AUTH;
9418 + * Enabling WEP encryption
9421 + index--; /* keyindex is off base 1 in iwconfig */
9424 + if (erq->flags & IW_ENCODE_OPEN) {
9426 + } else if (erq->flags & IW_ENCODE_RESTRICTED) {
9427 + auth = SHARED_AUTH;
9430 + if (erq->length) {
9431 + if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(erq->length)) {
9435 + A_MEMZERO(ar->arWepKeyList[index].arKey,
9436 + sizeof(ar->arWepKeyList[index].arKey));
9437 + A_MEMCPY(ar->arWepKeyList[index].arKey, keybuf, erq->length);
9438 + ar->arWepKeyList[index].arKeyLen = erq->length;
9440 + if (ar->arWepKeyList[index].arKeyLen == 0) {
9443 + ar->arDefTxKeyIndex = index;
9446 + ar->arPairwiseCrypto = WEP_CRYPT;
9447 + ar->arGroupCrypto = WEP_CRYPT;
9448 + ar->arDot11AuthMode = auth;
9449 + ar->arAuthMode = NONE_AUTH;
9453 + * profile has changed. Erase ssid to signal change
9455 + A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
9461 +ar6000_ioctl_giwencode(struct net_device *dev,
9462 + struct iw_request_info *info,
9463 + struct iw_point *erq, char *key)
9465 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9467 + struct ar_wep_key *wk;
9469 + if (ar->arWlanState == WLAN_DISABLED) {
9473 + if (ar->arPairwiseCrypto == NONE_CRYPT) {
9475 + erq->flags = IW_ENCODE_DISABLED;
9477 + /* get the keyIndex */
9478 + keyIndex = erq->flags & IW_ENCODE_INDEX;
9479 + if (0 == keyIndex) {
9480 + keyIndex = ar->arDefTxKeyIndex;
9481 + } else if ((keyIndex - 1 < WMI_MIN_KEY_INDEX) ||
9482 + (keyIndex - 1 > WMI_MAX_KEY_INDEX))
9484 + keyIndex = WMI_MIN_KEY_INDEX;
9488 + erq->flags = keyIndex + 1;
9489 + erq->flags |= IW_ENCODE_ENABLED;
9490 + wk = &ar->arWepKeyList[keyIndex];
9491 + if (erq->length > wk->arKeyLen) {
9492 + erq->length = wk->arKeyLen;
9494 + if (wk->arKeyLen) {
9495 + A_MEMCPY(key, wk->arKey, erq->length);
9497 + if (ar->arDot11AuthMode == OPEN_AUTH) {
9498 + erq->flags |= IW_ENCODE_OPEN;
9499 + } else if (ar->arDot11AuthMode == SHARED_AUTH) {
9500 + erq->flags |= IW_ENCODE_RESTRICTED;
9507 +static int ar6000_ioctl_siwpower(struct net_device *dev,
9508 + struct iw_request_info *info,
9509 + union iwreq_data *wrqu, char *extra)
9511 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9512 + WMI_POWER_MODE power_mode;
9514 + if (wrqu->power.disabled)
9515 + power_mode = MAX_PERF_POWER;
9517 + power_mode = REC_POWER;
9519 + if (wmi_powermode_cmd(ar->arWmi, power_mode) < 0)
9525 +static int ar6000_ioctl_giwpower(struct net_device *dev,
9526 + struct iw_request_info *info,
9527 + union iwreq_data *wrqu, char *extra)
9529 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9531 + return wmi_get_power_mode_cmd(ar->arWmi);
9534 +static int ar6000_ioctl_siwgenie(struct net_device *dev,
9535 + struct iw_request_info *info,
9536 + struct iw_point *dwrq,
9539 + /* The target does that for us */
9543 +static int ar6000_ioctl_giwgenie(struct net_device *dev,
9544 + struct iw_request_info *info,
9545 + struct iw_point *dwrq,
9551 +static int ar6000_ioctl_siwauth(struct net_device *dev,
9552 + struct iw_request_info *info,
9553 + struct iw_param *param,
9556 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9559 + switch (param->flags & IW_AUTH_INDEX) {
9560 + case IW_AUTH_WPA_VERSION:
9561 + if (param->value & IW_AUTH_WPA_VERSION_DISABLED) {
9562 + ar->arAuthMode = NONE_AUTH;
9564 + if (param->value & IW_AUTH_WPA_VERSION_WPA) {
9565 + ar->arAuthMode = WPA_AUTH;
9567 + if (param->value & IW_AUTH_WPA_VERSION_WPA2) {
9568 + ar->arAuthMode = WPA2_AUTH;
9573 + case IW_AUTH_CIPHER_PAIRWISE:
9574 + if (param->value & IW_AUTH_CIPHER_NONE) {
9575 + ar->arPairwiseCrypto = NONE_CRYPT;
9577 + if (param->value & IW_AUTH_CIPHER_WEP40) {
9578 + ar->arPairwiseCrypto = WEP_CRYPT;
9580 + if (param->value & IW_AUTH_CIPHER_TKIP) {
9581 + ar->arPairwiseCrypto = TKIP_CRYPT;
9583 + if (param->value & IW_AUTH_CIPHER_CCMP) {
9584 + ar->arPairwiseCrypto = AES_CRYPT;
9589 + case IW_AUTH_CIPHER_GROUP:
9590 + if (param->value & IW_AUTH_CIPHER_NONE) {
9591 + ar->arGroupCrypto = NONE_CRYPT;
9593 + if (param->value & IW_AUTH_CIPHER_WEP40) {
9594 + ar->arGroupCrypto = WEP_CRYPT;
9596 + if (param->value & IW_AUTH_CIPHER_TKIP) {
9597 + ar->arGroupCrypto = TKIP_CRYPT;
9599 + if (param->value & IW_AUTH_CIPHER_CCMP) {
9600 + ar->arGroupCrypto = AES_CRYPT;
9605 + case IW_AUTH_KEY_MGMT:
9606 + if (param->value & IW_AUTH_KEY_MGMT_PSK) {
9607 + if (ar->arAuthMode == WPA_AUTH) {
9608 + ar->arAuthMode = WPA_PSK_AUTH;
9609 + } else if (ar->arAuthMode == WPA2_AUTH) {
9610 + ar->arAuthMode = WPA2_PSK_AUTH;
9617 + case IW_AUTH_TKIP_COUNTERMEASURES:
9618 + if (ar->arWmiReady == FALSE) {
9621 + wmi_set_tkip_countermeasures_cmd(ar->arWmi, param->value);
9624 + case IW_AUTH_DROP_UNENCRYPTED:
9627 + case IW_AUTH_80211_AUTH_ALG:
9628 + if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
9629 + ar->arDot11AuthMode = OPEN_AUTH;
9631 + if (param->value & IW_AUTH_ALG_SHARED_KEY) {
9632 + ar->arDot11AuthMode = SHARED_AUTH;
9634 + if (param->value & IW_AUTH_ALG_LEAP) {
9635 + ar->arDot11AuthMode = LEAP_AUTH;
9636 + ar->arPairwiseCrypto = WEP_CRYPT;
9637 + ar->arGroupCrypto = WEP_CRYPT;
9643 + case IW_AUTH_WPA_ENABLED:
9647 + case IW_AUTH_RX_UNENCRYPTED_EAPOL:
9650 + case IW_AUTH_PRIVACY_INVOKED:
9654 + printk("%s(): Unknown flag 0x%x\n", __FUNCTION__, param->flags);
9655 + return -EOPNOTSUPP;
9659 + memset(ar->arSsid, 0, sizeof(ar->arSsid));
9664 +static int ar6000_ioctl_giwauth(struct net_device *dev,
9665 + struct iw_request_info *info,
9666 + struct iw_param *dwrq,
9672 +static int ar6000_ioctl_siwencodeext(struct net_device *dev,
9673 + struct iw_request_info *info,
9674 + union iwreq_data *wrqu,
9677 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9678 + struct iw_point *encoding = &wrqu->encoding;
9679 + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
9680 + int alg = ext->alg, idx;
9682 + if (ar->arWlanState == WLAN_DISABLED) {
9686 + /* Determine and validate the key index */
9687 + idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
9689 + if (idx < 0 || idx > 3)
9693 + if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
9694 + struct ieee80211req_key ik;
9695 + KEY_USAGE key_usage;
9696 + CRYPTO_TYPE key_type = NONE_CRYPT;
9699 + ar->user_saved_keys.keyOk = FALSE;
9701 + if (alg == IW_ENCODE_ALG_TKIP) {
9702 + key_type = TKIP_CRYPT;
9703 + ik.ik_type = IEEE80211_CIPHER_TKIP;
9705 + key_type = AES_CRYPT;
9706 + ik.ik_type = IEEE80211_CIPHER_AES_CCM;
9709 + ik.ik_keyix = idx;
9710 + ik.ik_keylen = ext->key_len;
9711 + ik.ik_flags = IEEE80211_KEY_RECV;
9712 + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
9713 + ik.ik_flags |= IEEE80211_KEY_XMIT
9714 + | IEEE80211_KEY_DEFAULT;
9717 + if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
9718 + memcpy(&ik.ik_keyrsc, ext->rx_seq, 8);
9721 + memcpy(ik.ik_keydata, ext->key, ext->key_len);
9723 + ar->user_saved_keys.keyType = key_type;
9724 + if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
9725 + key_usage = GROUP_USAGE;
9726 + memset(ik.ik_macaddr, 0, ETH_ALEN);
9727 + memcpy(&ar->user_saved_keys.bcast_ik, &ik,
9728 + sizeof(struct ieee80211req_key));
9730 + key_usage = PAIRWISE_USAGE;
9731 + memcpy(ik.ik_macaddr, ext->addr.sa_data, ETH_ALEN);
9732 + memcpy(&ar->user_saved_keys.ucast_ik, &ik,
9733 + sizeof(struct ieee80211req_key));
9736 + status = wmi_addKey_cmd(ar->arWmi, ik.ik_keyix, key_type,
9737 + key_usage, ik.ik_keylen,
9738 + (A_UINT8 *)&ik.ik_keyrsc,
9740 + KEY_OP_INIT_VAL, SYNC_BEFORE_WMIFLAG);
9745 + ar->user_saved_keys.keyOk = TRUE;
9750 + /* WEP falls back to SIWENCODE */
9751 + return -EOPNOTSUPP;
9758 +static int ar6000_ioctl_giwencodeext(struct net_device *dev,
9759 + struct iw_request_info *info,
9760 + struct iw_point *dwrq,
9768 +ar6000_ioctl_setparam(struct net_device *dev,
9769 + struct iw_request_info *info,
9770 + void *erq, char *extra)
9772 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9773 + int *i = (int *)extra;
9777 + A_BOOL profChanged = FALSE;
9779 + if (ar->arWlanState == WLAN_DISABLED) {
9784 + case IEEE80211_PARAM_WPA:
9786 + case WPA_MODE_WPA1:
9787 + ar->arAuthMode = WPA_AUTH;
9788 + profChanged = TRUE;
9790 + case WPA_MODE_WPA2:
9791 + ar->arAuthMode = WPA2_AUTH;
9792 + profChanged = TRUE;
9794 + case WPA_MODE_NONE:
9795 + ar->arAuthMode = NONE_AUTH;
9796 + profChanged = TRUE;
9799 + printk("IEEE80211_PARAM_WPA: Unknown value %d\n", value);
9802 + case IEEE80211_PARAM_AUTHMODE:
9804 + case IEEE80211_AUTH_WPA_PSK:
9805 + if (WPA_AUTH == ar->arAuthMode) {
9806 + ar->arAuthMode = WPA_PSK_AUTH;
9807 + profChanged = TRUE;
9808 + } else if (WPA2_AUTH == ar->arAuthMode) {
9809 + ar->arAuthMode = WPA2_PSK_AUTH;
9810 + profChanged = TRUE;
9812 + AR_DEBUG_PRINTF("Error - Setting PSK mode when WPA "\
9813 + "param was set to %d\n",
9818 + case IEEE80211_AUTH_WPA_CCKM:
9819 + if (WPA2_AUTH == ar->arAuthMode) {
9820 + ar->arAuthMode = WPA2_AUTH_CCKM;
9822 + ar->arAuthMode = WPA_AUTH_CCKM;
9829 + case IEEE80211_PARAM_UCASTCIPHER:
9831 + case IEEE80211_CIPHER_AES_CCM:
9832 + ar->arPairwiseCrypto = AES_CRYPT;
9833 + profChanged = TRUE;
9835 + case IEEE80211_CIPHER_TKIP:
9836 + ar->arPairwiseCrypto = TKIP_CRYPT;
9837 + profChanged = TRUE;
9839 + case IEEE80211_CIPHER_WEP:
9840 + ar->arPairwiseCrypto = WEP_CRYPT;
9841 + profChanged = TRUE;
9843 + case IEEE80211_CIPHER_NONE:
9844 + ar->arPairwiseCrypto = NONE_CRYPT;
9845 + profChanged = TRUE;
9849 + case IEEE80211_PARAM_UCASTKEYLEN:
9850 + if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
9853 + ar->arPairwiseCryptoLen = value;
9856 + case IEEE80211_PARAM_MCASTCIPHER:
9858 + case IEEE80211_CIPHER_AES_CCM:
9859 + ar->arGroupCrypto = AES_CRYPT;
9860 + profChanged = TRUE;
9862 + case IEEE80211_CIPHER_TKIP:
9863 + ar->arGroupCrypto = TKIP_CRYPT;
9864 + profChanged = TRUE;
9866 + case IEEE80211_CIPHER_WEP:
9867 + ar->arGroupCrypto = WEP_CRYPT;
9868 + profChanged = TRUE;
9870 + case IEEE80211_CIPHER_NONE:
9871 + ar->arGroupCrypto = NONE_CRYPT;
9872 + profChanged = TRUE;
9876 + case IEEE80211_PARAM_MCASTKEYLEN:
9877 + if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
9880 + ar->arGroupCryptoLen = value;
9883 + case IEEE80211_PARAM_COUNTERMEASURES:
9884 + if (ar->arWmiReady == FALSE) {
9887 + wmi_set_tkip_countermeasures_cmd(ar->arWmi, value);
9893 + if (profChanged == TRUE) {
9895 + * profile has changed. Erase ssid to signal change
9897 + A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
9904 +ar6000_ioctl_getparam(struct net_device *dev, struct iw_request_info *info,
9905 + void *w, char *extra)
9907 + return -EIO; /* for now */
9911 +ar6000_ioctl_setkey(struct net_device *dev, struct iw_request_info *info,
9912 + void *w, char *extra)
9914 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9915 + struct ieee80211req_key *ik = (struct ieee80211req_key *)extra;
9916 + KEY_USAGE keyUsage;
9918 + CRYPTO_TYPE keyType = NONE_CRYPT;
9920 + if (ar->arWlanState == WLAN_DISABLED) {
9924 + ar->user_saved_keys.keyOk = FALSE;
9926 + if ( 0 == memcmp(ik->ik_macaddr, "\x00\x00\x00\x00\x00\x00",
9927 + IEEE80211_ADDR_LEN)) {
9928 + keyUsage = GROUP_USAGE;
9929 + A_MEMCPY(&ar->user_saved_keys.bcast_ik, ik,
9930 + sizeof(struct ieee80211req_key));
9932 + keyUsage = PAIRWISE_USAGE;
9933 + A_MEMCPY(&ar->user_saved_keys.ucast_ik, ik,
9934 + sizeof(struct ieee80211req_key));
9937 + switch (ik->ik_type) {
9938 + case IEEE80211_CIPHER_WEP:
9939 + keyType = WEP_CRYPT;
9941 + case IEEE80211_CIPHER_TKIP:
9942 + keyType = TKIP_CRYPT;
9944 + case IEEE80211_CIPHER_AES_CCM:
9945 + keyType = AES_CRYPT;
9950 + ar->user_saved_keys.keyType = keyType;
9952 + if (IEEE80211_CIPHER_CCKM_KRK != ik->ik_type) {
9953 + if (NONE_CRYPT == keyType) {
9957 + status = wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, keyType, keyUsage,
9958 + ik->ik_keylen, (A_UINT8 *)&ik->ik_keyrsc,
9959 + ik->ik_keydata, KEY_OP_INIT_VAL,
9960 + SYNC_BEFORE_WMIFLAG);
9962 + if (status != A_OK) {
9966 + status = wmi_add_krk_cmd(ar->arWmi, ik->ik_keydata);
9969 + ar->user_saved_keys.keyOk = TRUE;
9979 +ar6000_ioctl_giwname(struct net_device *dev,
9980 + struct iw_request_info *info,
9981 + char *name, char *extra)
9983 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9985 + if (ar->arWlanState == WLAN_DISABLED) {
9989 + switch (ar->arPhyCapability) {
9990 + case (WMI_11A_CAPABILITY):
9991 + strncpy(name, "AR6000 802.11a", IFNAMSIZ);
9993 + case (WMI_11G_CAPABILITY):
9994 + strncpy(name, "AR6000 802.11g", IFNAMSIZ);
9996 + case (WMI_11AG_CAPABILITY):
9997 + strncpy(name, "AR6000 802.11ag", IFNAMSIZ);
10000 + strncpy(name, "AR6000 802.11", IFNAMSIZ);
10011 +ar6000_ioctl_siwfreq(struct net_device *dev,
10012 + struct iw_request_info *info,
10013 + struct iw_freq *freq, char *extra)
10015 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10017 + if (ar->arWlanState == WLAN_DISABLED) {
10022 + * We support limiting the channels via wmiconfig.
10024 + * We use this command to configure the channel hint for the connect cmd
10025 + * so it is possible the target will end up connecting to a different
10028 + if (freq->e > 1) {
10030 + } else if (freq->e == 1) {
10031 + ar->arChannelHint = freq->m / 100000;
10033 + ar->arChannelHint = wlan_ieee2freq(freq->m);
10036 + A_PRINTF("channel hint set to %d\n", ar->arChannelHint);
10044 +ar6000_ioctl_giwfreq(struct net_device *dev,
10045 + struct iw_request_info *info,
10046 + struct iw_freq *freq, char *extra)
10048 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10050 + if (ar->arWlanState == WLAN_DISABLED) {
10054 + if (ar->arConnected != TRUE) {
10058 + freq->m = ar->arBssChannel * 100000;
10068 +ar6000_ioctl_siwmode(struct net_device *dev,
10069 + struct iw_request_info *info,
10070 + __u32 *mode, char *extra)
10072 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10074 + if (ar->arWlanState == WLAN_DISABLED) {
10079 + case IW_MODE_INFRA:
10080 + ar->arNetworkType = INFRA_NETWORK;
10082 + case IW_MODE_ADHOC:
10083 + ar->arNetworkType = ADHOC_NETWORK;
10096 +ar6000_ioctl_giwmode(struct net_device *dev,
10097 + struct iw_request_info *info,
10098 + __u32 *mode, char *extra)
10100 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10102 + if (ar->arWlanState == WLAN_DISABLED) {
10106 + switch (ar->arNetworkType) {
10107 + case INFRA_NETWORK:
10108 + *mode = IW_MODE_INFRA;
10110 + case ADHOC_NETWORK:
10111 + *mode = IW_MODE_ADHOC;
10123 +ar6000_ioctl_siwsens(struct net_device *dev,
10124 + struct iw_request_info *info,
10125 + struct iw_param *sens, char *extra)
10134 +ar6000_ioctl_giwsens(struct net_device *dev,
10135 + struct iw_request_info *info,
10136 + struct iw_param *sens, char *extra)
10148 +ar6000_ioctl_giwrange(struct net_device *dev,
10149 + struct iw_request_info *info,
10150 + struct iw_point *data, char *extra)
10152 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10153 + struct iw_range *range = (struct iw_range *) extra;
10156 + if (ar->arWmiReady == FALSE) {
10160 + if (ar->arWlanState == WLAN_DISABLED) {
10164 + if (down_interruptible(&ar->arSem)) {
10165 + return -ERESTARTSYS;
10167 + ar->arNumChannels = -1;
10168 + A_MEMZERO(ar->arChannelList, sizeof (ar->arChannelList));
10170 + if (wmi_get_channelList_cmd(ar->arWmi) != A_OK) {
10175 + wait_event_interruptible_timeout(arEvent, ar->arNumChannels != -1, wmitimeout * HZ);
10177 + if (signal_pending(current)) {
10182 + data->length = sizeof(struct iw_range);
10183 + A_MEMZERO(range, sizeof(struct iw_range));
10185 + range->txpower_capa = 0;
10187 + range->min_pmp = 1 * 1024;
10188 + range->max_pmp = 65535 * 1024;
10189 + range->min_pmt = 1 * 1024;
10190 + range->max_pmt = 1000 * 1024;
10191 + range->pmp_flags = IW_POWER_PERIOD;
10192 + range->pmt_flags = IW_POWER_TIMEOUT;
10193 + range->pm_capa = 0;
10195 + range->we_version_compiled = WIRELESS_EXT;
10196 + range->we_version_source = 13;
10198 + range->retry_capa = IW_RETRY_LIMIT;
10199 + range->retry_flags = IW_RETRY_LIMIT;
10200 + range->min_retry = 0;
10201 + range->max_retry = 255;
10203 + range->num_frequency = range->num_channels = ar->arNumChannels;
10204 + for (i = 0; i < ar->arNumChannels; i++) {
10205 + range->freq[i].i = wlan_freq2ieee(ar->arChannelList[i]);
10206 + range->freq[i].m = ar->arChannelList[i] * 100000;
10207 + range->freq[i].e = 1;
10209 + * Linux supports max of 32 channels, bail out once you
10212 + if (i == IW_MAX_FREQUENCIES) {
10217 + /* Max quality is max field value minus noise floor */
10218 + range->max_qual.qual = 0xff - 161;
10221 + * In order to use dBm measurements, 'level' must be lower
10222 + * than any possible measurement (see iw_print_stats() in
10223 + * wireless tools). It's unclear how this is meant to be
10224 + * done, but setting zero in these values forces dBm and
10225 + * the actual numbers are not used.
10227 + range->max_qual.level = 0;
10228 + range->max_qual.noise = 0;
10230 + range->sensitivity = 3;
10232 + range->max_encoding_tokens = 4;
10233 + /* XXX query driver to find out supported key sizes */
10234 + range->num_encoding_sizes = 3;
10235 + range->encoding_size[0] = 5; /* 40-bit */
10236 + range->encoding_size[1] = 13; /* 104-bit */
10237 + range->encoding_size[2] = 16; /* 128-bit */
10239 + range->num_bitrates = 0;
10241 + /* estimated maximum TCP throughput values (bps) */
10242 + range->throughput = 22000000;
10244 + range->min_rts = 0;
10245 + range->max_rts = 2347;
10246 + range->min_frag = 256;
10247 + range->max_frag = 2346;
10257 + * This ioctl is used to set the desired bssid for the connect command.
10260 +ar6000_ioctl_siwap(struct net_device *dev,
10261 + struct iw_request_info *info,
10262 + struct sockaddr *ap_addr, char *extra)
10264 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10266 + if (ar->arWlanState == WLAN_DISABLED) {
10270 + if (ap_addr->sa_family != ARPHRD_ETHER) {
10274 + if (A_MEMCMP(&ap_addr->sa_data, bcast_mac, AR6000_ETH_ADDR_LEN) == 0) {
10275 + A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
10277 + A_MEMCPY(ar->arReqBssid, &ap_addr->sa_data, sizeof(ar->arReqBssid));
10287 +ar6000_ioctl_giwap(struct net_device *dev,
10288 + struct iw_request_info *info,
10289 + struct sockaddr *ap_addr, char *extra)
10291 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10293 + if (ar->arWlanState == WLAN_DISABLED) {
10297 + if (ar->arConnected != TRUE) {
10301 + A_MEMCPY(&ap_addr->sa_data, ar->arBssid, sizeof(ar->arBssid));
10302 + ap_addr->sa_family = ARPHRD_ETHER;
10311 +ar6000_ioctl_iwaplist(struct net_device *dev,
10312 + struct iw_request_info *info,
10313 + struct iw_point *data, char *extra)
10315 + return -EIO; /* for now */
10322 +ar6000_ioctl_siwscan(struct net_device *dev,
10323 + struct iw_request_info *info,
10324 + struct iw_point *data, char *extra)
10326 +#define ACT_DWELLTIME_DEFAULT 105
10327 +#define HOME_TXDRAIN_TIME 100
10328 +#define SCAN_INT HOME_TXDRAIN_TIME + ACT_DWELLTIME_DEFAULT
10329 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10332 + if (ar->arWmiReady == FALSE) {
10336 + if (ar->arWlanState == WLAN_DISABLED) {
10340 + /* We ask for everything from the target */
10341 + if (wmi_bssfilter_cmd(ar->arWmi, ALL_BSS_FILTER, 0) != A_OK) {
10342 + printk("Couldn't set filtering\n");
10346 + if (wmi_startscan_cmd(ar->arWmi, WMI_LONG_SCAN, FALSE, FALSE, \
10347 + HOME_TXDRAIN_TIME, SCAN_INT) != A_OK) {
10351 + ar->scan_complete = 0;
10352 + wait_event_interruptible_timeout(ar6000_scan_queue, ar->scan_complete,
10355 + if (wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0) != A_OK) {
10356 + printk("Couldn't set filtering\n");
10361 +#undef ACT_DWELLTIME_DEFAULT
10362 +#undef HOME_TXDRAIN_TIME
10368 + * Units are in db above the noise floor. That means the
10369 + * rssi values reported in the tx/rx descriptors in the
10370 + * driver are the SNR expressed in db.
10372 + * If you assume that the noise floor is -95, which is an
10373 + * excellent assumption 99.5 % of the time, then you can
10374 + * derive the absolute signal level (i.e. -95 + rssi).
10375 + * There are some other slight factors to take into account
10376 + * depending on whether the rssi measurement is from 11b,
10377 + * 11g, or 11a. These differences are at most 2db and
10378 + * can be documented.
10380 + * NB: various calculations are based on the orinoco/wavelan
10381 + * drivers for compatibility
10384 +ar6000_set_quality(struct iw_quality *iq, A_INT8 rssi)
10392 + /* NB: max is 94 because noise is hardcoded to 161 */
10393 + if (iq->qual > 94)
10396 + iq->noise = 161; /* -95dBm */
10397 + iq->level = iq->noise + iq->qual;
10402 +/* Structures to export the Wireless Handlers */
10403 +static const iw_handler ath_handlers[] = {
10404 + (iw_handler) NULL, /* SIOCSIWCOMMIT */
10405 + (iw_handler) ar6000_ioctl_giwname, /* SIOCGIWNAME */
10406 + (iw_handler) NULL, /* SIOCSIWNWID */
10407 + (iw_handler) NULL, /* SIOCGIWNWID */
10408 + (iw_handler) ar6000_ioctl_siwfreq, /* SIOCSIWFREQ */
10409 + (iw_handler) ar6000_ioctl_giwfreq, /* SIOCGIWFREQ */
10410 + (iw_handler) ar6000_ioctl_siwmode, /* SIOCSIWMODE */
10411 + (iw_handler) ar6000_ioctl_giwmode, /* SIOCGIWMODE */
10412 + (iw_handler) ar6000_ioctl_siwsens, /* SIOCSIWSENS */
10413 + (iw_handler) ar6000_ioctl_giwsens, /* SIOCGIWSENS */
10414 + (iw_handler) NULL /* not _used */, /* SIOCSIWRANGE */
10415 + (iw_handler) ar6000_ioctl_giwrange, /* SIOCGIWRANGE */
10416 + (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
10417 + (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
10418 + (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
10419 + (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
10420 + (iw_handler) NULL, /* SIOCSIWSPY */
10421 + (iw_handler) NULL, /* SIOCGIWSPY */
10422 + (iw_handler) NULL, /* SIOCSIWTHRSPY */
10423 + (iw_handler) NULL, /* SIOCGIWTHRSPY */
10424 + (iw_handler) ar6000_ioctl_siwap, /* SIOCSIWAP */
10425 + (iw_handler) ar6000_ioctl_giwap, /* SIOCGIWAP */
10426 + (iw_handler) NULL, /* -- hole -- */
10427 + (iw_handler) ar6000_ioctl_iwaplist, /* SIOCGIWAPLIST */
10428 + (iw_handler) ar6000_ioctl_siwscan, /* SIOCSIWSCAN */
10429 + (iw_handler) ar6000_ioctl_giwscan, /* SIOCGIWSCAN */
10430 + (iw_handler) ar6000_ioctl_siwessid, /* SIOCSIWESSID */
10431 + (iw_handler) ar6000_ioctl_giwessid, /* SIOCGIWESSID */
10432 + (iw_handler) NULL, /* SIOCSIWNICKN */
10433 + (iw_handler) NULL, /* SIOCGIWNICKN */
10434 + (iw_handler) NULL, /* -- hole -- */
10435 + (iw_handler) NULL, /* -- hole -- */
10436 + (iw_handler) ar6000_ioctl_siwrate, /* SIOCSIWRATE */
10437 + (iw_handler) ar6000_ioctl_giwrate, /* SIOCGIWRATE */
10438 + (iw_handler) NULL, /* SIOCSIWRTS */
10439 + (iw_handler) NULL, /* SIOCGIWRTS */
10440 + (iw_handler) NULL, /* SIOCSIWFRAG */
10441 + (iw_handler) NULL, /* SIOCGIWFRAG */
10442 + (iw_handler) ar6000_ioctl_siwtxpow, /* SIOCSIWTXPOW */
10443 + (iw_handler) ar6000_ioctl_giwtxpow, /* SIOCGIWTXPOW */
10444 + (iw_handler) ar6000_ioctl_siwretry, /* SIOCSIWRETRY */
10445 + (iw_handler) ar6000_ioctl_giwretry, /* SIOCGIWRETRY */
10446 + (iw_handler) ar6000_ioctl_siwencode, /* SIOCSIWENCODE */
10447 + (iw_handler) ar6000_ioctl_giwencode, /* SIOCGIWENCODE */
10448 + (iw_handler) ar6000_ioctl_siwpower, /* SIOCSIWPOWER */
10449 + (iw_handler) ar6000_ioctl_giwpower, /* SIOCGIWPOWER */
10450 + (iw_handler) NULL, /* -- hole -- */
10451 + (iw_handler) NULL, /* -- hole -- */
10452 + (iw_handler) ar6000_ioctl_siwgenie, /* SIOCSIWGENIE */
10453 + (iw_handler) ar6000_ioctl_giwgenie, /* SIOCGIWGENIE */
10454 + (iw_handler) ar6000_ioctl_siwauth, /* SIOCSIWAUTH */
10455 + (iw_handler) ar6000_ioctl_giwauth, /* SIOCGIWAUTH */
10456 + (iw_handler) ar6000_ioctl_siwencodeext,/* SIOCSIWENCODEEXT */
10457 + (iw_handler) ar6000_ioctl_giwencodeext,/* SIOCGIWENCODEEXT */
10458 + (iw_handler) NULL, /* SIOCSIWPMKSA */
10461 +static const iw_handler ath_priv_handlers[] = {
10462 + (iw_handler) ar6000_ioctl_setparam, /* SIOCWFIRSTPRIV+0 */
10463 + (iw_handler) ar6000_ioctl_getparam, /* SIOCWFIRSTPRIV+1 */
10464 + (iw_handler) ar6000_ioctl_setkey, /* SIOCWFIRSTPRIV+2 */
10465 + (iw_handler) ar6000_ioctl_setwmmparams, /* SIOCWFIRSTPRIV+3 */
10466 + (iw_handler) ar6000_ioctl_delkey, /* SIOCWFIRSTPRIV+4 */
10467 + (iw_handler) ar6000_ioctl_getwmmparams, /* SIOCWFIRSTPRIV+5 */
10468 + (iw_handler) ar6000_ioctl_setoptie, /* SIOCWFIRSTPRIV+6 */
10469 + (iw_handler) ar6000_ioctl_setmlme, /* SIOCWFIRSTPRIV+7 */
10470 + (iw_handler) ar6000_ioctl_addpmkid, /* SIOCWFIRSTPRIV+8 */
10473 +#define IW_PRIV_TYPE_KEY \
10474 + (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_key))
10475 +#define IW_PRIV_TYPE_DELKEY \
10476 + (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_del_key))
10477 +#define IW_PRIV_TYPE_MLME \
10478 + (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_mlme))
10479 +#define IW_PRIV_TYPE_ADDPMKID \
10480 + (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_addpmkid))
10482 +static const struct iw_priv_args ar6000_priv_args[] = {
10483 + { IEEE80211_IOCTL_SETKEY,
10484 + IW_PRIV_TYPE_KEY | IW_PRIV_SIZE_FIXED, 0, "setkey"},
10485 + { IEEE80211_IOCTL_DELKEY,
10486 + IW_PRIV_TYPE_DELKEY | IW_PRIV_SIZE_FIXED, 0, "delkey"},
10487 + { IEEE80211_IOCTL_SETPARAM,
10488 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam"},
10489 + { IEEE80211_IOCTL_GETPARAM,
10490 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10491 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam"},
10492 + { IEEE80211_IOCTL_SETWMMPARAMS,
10493 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 4, 0, "setwmmparams"},
10494 + { IEEE80211_IOCTL_GETWMMPARAMS,
10495 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10496 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwmmparams"},
10497 + { IEEE80211_IOCTL_SETOPTIE,
10498 + IW_PRIV_TYPE_BYTE, 0, "setie"},
10499 + { IEEE80211_IOCTL_SETMLME,
10500 + IW_PRIV_TYPE_MLME, 0, "setmlme"},
10501 + { IEEE80211_IOCTL_ADDPMKID,
10502 + IW_PRIV_TYPE_ADDPMKID | IW_PRIV_SIZE_FIXED, 0, "addpmkid"},
10505 +void ar6000_ioctl_iwsetup(struct iw_handler_def *def)
10507 + def->private_args = (struct iw_priv_args *)ar6000_priv_args;
10508 + def->num_private_args = ARRAY_SIZE(ar6000_priv_args);
10511 +struct iw_handler_def ath_iw_handler_def = {
10512 + .standard = (iw_handler *)ath_handlers,
10513 + .num_standard = ARRAY_SIZE(ath_handlers),
10514 + .private = (iw_handler *)ath_priv_handlers,
10515 + .num_private = ARRAY_SIZE(ath_priv_handlers),
10519 diff --git a/drivers/sdio/function/wlan/ar6000/bmi/bmi.c b/drivers/sdio/function/wlan/ar6000/bmi/bmi.c
10520 new file mode 100644
10521 index 0000000..d7b610c
10523 +++ b/drivers/sdio/function/wlan/ar6000/bmi/bmi.c
10526 + * Copyright (c) 2004-2007 Atheros Communications Inc.
10527 + * All rights reserved.
10530 + * This program is free software; you can redistribute it and/or modify
10531 + * it under the terms of the GNU General Public License version 2 as
10532 + * published by the Free Software Foundation;
10534 + * Software distributed under the License is distributed on an "AS
10535 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10536 + * implied. See the License for the specific language governing
10537 + * rights and limitations under the License.
10545 +#include "htc_api.h"
10546 +#include "bmi_internal.h"
10549 +Although we had envisioned BMI to run on top of HTC, this is not what the
10550 +final implementation boiled down to on dragon. Its a part of BSP and does
10551 +not use the HTC protocol either. On the host side, however, we were still
10552 +living with the original idea. I think the time has come to accept the truth
10553 +and separate it from HTC which has been carrying BMI's burden all this while.
10554 +It shall make HTC state machine relatively simpler
10557 +/* APIs visible to the driver */
10565 +BMIDone(HIF_DEVICE *device)
10571 + AR_DEBUG_PRINTF (ATH_DEBUG_BMI, ("BMIDone skipped\n"));
10575 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Enter (device: 0x%p)\n", device));
10579 + status = bmiBufferSend(device, (A_UCHAR *)&cid, sizeof(cid));
10580 + if (status != A_OK) {
10581 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10584 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Exit\n"));
10590 +BMIGetTargetInfo(HIF_DEVICE *device, struct bmi_target_info *targ_info)
10596 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10600 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Enter (device: 0x%p)\n", device));
10601 + cid = BMI_GET_TARGET_INFO;
10603 + status = bmiBufferSend(device, (A_UCHAR *)&cid, sizeof(cid));
10604 + if (status != A_OK) {
10605 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10609 + status = bmiBufferReceive(device, (A_UCHAR *)&targ_info->target_ver,
10610 + sizeof(targ_info->target_ver));
10611 + if (status != A_OK) {
10612 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Version from the device\n"));
10616 + if (targ_info->target_ver == TARGET_VERSION_SENTINAL) {
10617 + /* Determine how many bytes are in the Target's targ_info */
10618 + status = bmiBufferReceive(device, (A_UCHAR *)&targ_info->target_info_byte_count,
10619 + sizeof(targ_info->target_info_byte_count));
10620 + if (status != A_OK) {
10621 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Info Byte Count from the device\n"));
10626 + * The Target's targ_info doesn't match the Host's targ_info.
10627 + * We need to do some backwards compatibility work to make this OK.
10629 + A_ASSERT(targ_info->target_info_byte_count == sizeof(*targ_info));
10631 + /* Read the remainder of the targ_info */
10632 + status = bmiBufferReceive(device,
10633 + ((A_UCHAR *)targ_info)+sizeof(targ_info->target_info_byte_count),
10634 + sizeof(*targ_info)-sizeof(targ_info->target_info_byte_count));
10635 + if (status != A_OK) {
10636 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Info (%d bytes) from the device\n",
10637 + targ_info->target_info_byte_count));
10642 + * Target must be an AR6001 whose firmware does not
10643 + * support BMI_GET_TARGET_INFO. Construct the data
10644 + * that it would have sent.
10646 + targ_info->target_info_byte_count = sizeof(targ_info);
10647 + targ_info->target_type = TARGET_TYPE_AR6001;
10650 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Exit (ver: 0x%x type: 0x%x)\n",
10651 + targ_info->target_ver, targ_info->target_type));
10652 + printk("BMI Get Target Info: Exit (ver: 0x%x type: 0x%x)\n",
10653 + targ_info->target_ver, targ_info->target_type);
10659 +BMIReadMemory(HIF_DEVICE *device,
10660 + A_UINT32 address,
10667 + A_UINT32 remaining, rxlen;
10668 + static A_UCHAR data[BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)];
10669 + memset (&data, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length));
10672 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10676 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10677 + ("BMI Read Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n",
10678 + device, address, length));
10680 + cid = BMI_READ_MEMORY;
10682 + remaining = length;
10684 + while (remaining)
10686 + rxlen = (remaining < BMI_DATASZ_MAX) ? remaining : BMI_DATASZ_MAX;
10688 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
10689 + offset += sizeof(cid);
10690 + A_MEMCPY(&data[offset], &address, sizeof(address));
10691 + offset += sizeof(address);
10692 + A_MEMCPY(&data[offset], &rxlen, sizeof(rxlen));
10693 + offset += sizeof(length);
10695 + status = bmiBufferSend(device, data, offset);
10696 + if (status != A_OK) {
10697 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10700 + status = bmiBufferReceive(device, data, rxlen);
10701 + if (status != A_OK) {
10702 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n"));
10705 + A_MEMCPY(&buffer[length - remaining], data, rxlen);
10706 + remaining -= rxlen; address += rxlen;
10709 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Exit\n"));
10714 +BMIWriteMemory(HIF_DEVICE *device,
10715 + A_UINT32 address,
10722 + A_UINT32 remaining, txlen;
10723 + const A_UINT32 header = sizeof(cid) + sizeof(address) + sizeof(length);
10724 + static A_UCHAR data[BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)];
10725 + memset (&data, 0, header);
10728 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10732 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10733 + ("BMI Write Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n",
10734 + device, address, length));
10736 + cid = BMI_WRITE_MEMORY;
10738 + remaining = length;
10739 + while (remaining)
10741 + txlen = (remaining < (BMI_DATASZ_MAX - header)) ?
10742 + remaining : (BMI_DATASZ_MAX - header);
10744 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
10745 + offset += sizeof(cid);
10746 + A_MEMCPY(&data[offset], &address, sizeof(address));
10747 + offset += sizeof(address);
10748 + A_MEMCPY(&data[offset], &txlen, sizeof(txlen));
10749 + offset += sizeof(txlen);
10750 + A_MEMCPY(&data[offset], &buffer[length - remaining], txlen);
10752 + status = bmiBufferSend(device, data, offset);
10753 + if (status != A_OK) {
10754 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10757 + remaining -= txlen; address += txlen;
10760 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Write Memory: Exit\n"));
10766 +BMIExecute(HIF_DEVICE *device,
10767 + A_UINT32 address,
10773 + static A_UCHAR data[sizeof(cid) + sizeof(address) + sizeof(*param)];
10774 + memset (&data, 0, sizeof(cid) + sizeof(address) + sizeof(*param));
10777 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10781 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10782 + ("BMI Execute: Enter (device: 0x%p, address: 0x%x, param: %d)\n",
10783 + device, address, *param));
10785 + cid = BMI_EXECUTE;
10788 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
10789 + offset += sizeof(cid);
10790 + A_MEMCPY(&data[offset], &address, sizeof(address));
10791 + offset += sizeof(address);
10792 + A_MEMCPY(&data[offset], param, sizeof(*param));
10793 + offset += sizeof(*param);
10794 + status = bmiBufferSend(device, data, offset);
10795 + if (status != A_OK) {
10796 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10800 + status = bmiBufferReceive(device, data, sizeof(*param));
10801 + if (status != A_OK) {
10802 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n"));
10806 + A_MEMCPY(param, data, sizeof(*param));
10808 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Exit (param: %d)\n", *param));
10813 +BMISetAppStart(HIF_DEVICE *device,
10814 + A_UINT32 address)
10819 + static A_UCHAR data[sizeof(cid) + sizeof(address)];
10820 + memset (&data, 0, sizeof(cid) + sizeof(address));
10823 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10827 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10828 + ("BMI Set App Start: Enter (device: 0x%p, address: 0x%x)\n",
10829 + device, address));
10831 + cid = BMI_SET_APP_START;
10834 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
10835 + offset += sizeof(cid);
10836 + A_MEMCPY(&data[offset], &address, sizeof(address));
10837 + offset += sizeof(address);
10838 + status = bmiBufferSend(device, data, offset);
10839 + if (status != A_OK) {
10840 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10844 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Set App Start: Exit\n"));
10849 +BMIReadSOCRegister(HIF_DEVICE *device,
10850 + A_UINT32 address,
10856 + static A_UCHAR data[sizeof(cid) + sizeof(address)];
10857 + memset (&data, 0, sizeof(cid) + sizeof(address));
10860 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10864 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10865 + ("BMI Read SOC Register: Enter (device: 0x%p, address: 0x%x)\n",
10866 + device, address));
10868 + cid = BMI_READ_SOC_REGISTER;
10871 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
10872 + offset += sizeof(cid);
10873 + A_MEMCPY(&data[offset], &address, sizeof(address));
10874 + offset += sizeof(address);
10876 + status = bmiBufferSend(device, data, offset);
10877 + if (status != A_OK) {
10878 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10882 + status = bmiBufferReceive(device, data, sizeof(*param));
10883 + if (status != A_OK) {
10884 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n"));
10887 + A_MEMCPY(param, data, sizeof(*param));
10889 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Exit (value: %d)\n", *param));
10894 +BMIWriteSOCRegister(HIF_DEVICE *device,
10895 + A_UINT32 address,
10901 + static A_UCHAR data[sizeof(cid) + sizeof(address) + sizeof(param)];
10903 + memset (&data, 0, sizeof(cid) + sizeof(address) + sizeof(param));
10906 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10910 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10911 + ("BMI Write SOC Register: Enter (device: 0x%p, address: 0x%x, param: %d)\n",
10912 + device, address, param));
10914 + cid = BMI_WRITE_SOC_REGISTER;
10917 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
10918 + offset += sizeof(cid);
10919 + A_MEMCPY(&data[offset], &address, sizeof(address));
10920 + offset += sizeof(address);
10921 + A_MEMCPY(&data[offset], ¶m, sizeof(param));
10922 + offset += sizeof(param);
10923 + status = bmiBufferSend(device, data, offset);
10924 + if (status != A_OK) {
10925 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10929 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Exit\n"));
10934 +BMIrompatchInstall(HIF_DEVICE *device,
10935 + A_UINT32 ROM_addr,
10936 + A_UINT32 RAM_addr,
10938 + A_UINT32 do_activate,
10939 + A_UINT32 *rompatch_id)
10944 + static A_UCHAR data[sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) +
10945 + sizeof(nbytes) + sizeof(do_activate)];
10947 + memset (&data, 0, sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) +
10948 + sizeof(nbytes) + sizeof(do_activate));
10951 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10955 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10956 + ("BMI rompatch Install: Enter (device: 0x%p, ROMaddr: 0x%x, RAMaddr: 0x%x length: %d activate: %d)\n",
10957 + device, ROM_addr, RAM_addr, nbytes, do_activate));
10959 + cid = BMI_ROMPATCH_INSTALL;
10962 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
10963 + offset += sizeof(cid);
10964 + A_MEMCPY(&data[offset], &ROM_addr, sizeof(ROM_addr));
10965 + offset += sizeof(ROM_addr);
10966 + A_MEMCPY(&data[offset], &RAM_addr, sizeof(RAM_addr));
10967 + offset += sizeof(RAM_addr);
10968 + A_MEMCPY(&data[offset], &nbytes, sizeof(nbytes));
10969 + offset += sizeof(nbytes);
10970 + A_MEMCPY(&data[offset], &do_activate, sizeof(do_activate));
10971 + offset += sizeof(do_activate);
10972 + status = bmiBufferSend(device, data, offset);
10973 + if (status != A_OK) {
10974 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
10978 + status = bmiBufferReceive(device, (A_UCHAR *)rompatch_id, sizeof(*rompatch_id));
10979 + if (status != A_OK) {
10980 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n"));
10984 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Install: (rompatch_id=%d)\n", *rompatch_id));
10989 +BMIrompatchUninstall(HIF_DEVICE *device,
10990 + A_UINT32 rompatch_id)
10995 + static A_UCHAR data[sizeof(cid) + sizeof(rompatch_id)];
10996 + memset (&data, 0, sizeof(cid) + sizeof(rompatch_id));
10999 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
11003 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
11004 + ("BMI rompatch Uninstall: Enter (device: 0x%p, rompatch_id: %d)\n",
11005 + device, rompatch_id));
11007 + cid = BMI_ROMPATCH_UNINSTALL;
11010 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
11011 + offset += sizeof(cid);
11012 + A_MEMCPY(&data[offset], &rompatch_id, sizeof(rompatch_id));
11013 + offset += sizeof(rompatch_id);
11014 + status = bmiBufferSend(device, data, offset);
11015 + if (status != A_OK) {
11016 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
11020 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch UNinstall: (rompatch_id=0x%x)\n", rompatch_id));
11025 +_BMIrompatchChangeActivation(HIF_DEVICE *device,
11026 + A_UINT32 rompatch_count,
11027 + A_UINT32 *rompatch_list,
11028 + A_UINT32 do_activate)
11033 + static A_UCHAR data[BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count)];
11036 + memset (&data, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count));
11039 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
11043 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
11044 + ("BMI Change rompatch Activation: Enter (device: 0x%p, count: %d)\n",
11045 + device, rompatch_count));
11047 + cid = do_activate ? BMI_ROMPATCH_ACTIVATE : BMI_ROMPATCH_DEACTIVATE;
11050 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
11051 + offset += sizeof(cid);
11052 + A_MEMCPY(&data[offset], &rompatch_count, sizeof(rompatch_count));
11053 + offset += sizeof(rompatch_count);
11054 + length = rompatch_count * sizeof(*rompatch_list);
11055 + A_MEMCPY(&data[offset], rompatch_list, length);
11056 + offset += length;
11057 + status = bmiBufferSend(device, data, offset);
11058 + if (status != A_OK) {
11059 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n"));
11063 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Exit\n"));
11069 +BMIrompatchActivate(HIF_DEVICE *device,
11070 + A_UINT32 rompatch_count,
11071 + A_UINT32 *rompatch_list)
11073 + return _BMIrompatchChangeActivation(device, rompatch_count, rompatch_list, 1);
11077 +BMIrompatchDeactivate(HIF_DEVICE *device,
11078 + A_UINT32 rompatch_count,
11079 + A_UINT32 *rompatch_list)
11081 + return _BMIrompatchChangeActivation(device, rompatch_count, rompatch_list, 0);
11084 +/* BMI Access routines */
11086 +bmiBufferSend(HIF_DEVICE *device,
11091 + A_UINT32 timeout;
11092 + A_UINT32 address;
11093 + static A_UINT32 cmdCredits;
11094 + A_UINT32 mboxAddress[HTC_MAILBOX_NUM_MAX];
11096 + HIFConfigureDevice(device, HIF_DEVICE_GET_MBOX_ADDR,
11097 + &mboxAddress, sizeof(mboxAddress));
11100 + timeout = BMI_COMMUNICATION_TIMEOUT;
11102 + while(timeout-- && !cmdCredits) {
11103 + /* Read the counter register to get the command credits */
11104 + address = COUNT_DEC_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 4;
11105 + /* hit the credit counter with a 4-byte access, the first byte read will hit the counter and cause
11106 + * a decrement, while the remaining 3 bytes has no effect. The rationale behind this is to
11107 + * make all HIF accesses 4-byte aligned */
11108 + status = HIFReadWrite(device, address, (A_UINT8 *)&cmdCredits, 4,
11109 + HIF_RD_SYNC_BYTE_INC, NULL);
11110 + if (status != A_OK) {
11111 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to decrement the command credit count register\n"));
11114 + /* the counter is only 8=bits, ignore anything in the upper 3 bytes */
11115 + cmdCredits &= 0xFF;
11118 + if (cmdCredits) {
11119 + address = mboxAddress[ENDPOINT1];
11120 + status = HIFReadWrite(device, address, buffer, length,
11121 + HIF_WR_SYNC_BYTE_INC, NULL);
11122 + if (status != A_OK) {
11123 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to send the BMI data to the device\n"));
11127 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Communication timeout\n"));
11135 +bmiBufferReceive(HIF_DEVICE *device,
11140 + A_UINT32 address;
11141 + A_UINT32 timeout;
11142 + static A_UINT32 cmdCredits;
11143 + A_UINT32 mboxAddress[HTC_MAILBOX_NUM_MAX];
11145 + HIFConfigureDevice(device, HIF_DEVICE_GET_MBOX_ADDR,
11146 + &mboxAddress, sizeof(mboxAddress));
11149 + timeout = BMI_COMMUNICATION_TIMEOUT;
11150 + while(timeout-- && !cmdCredits) {
11151 + /* Read the counter register to get the command credits */
11152 + address = COUNT_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 1;
11153 + /* read the counter using a 4-byte read. Since the counter is NOT auto-decrementing,
11154 + * we can read this counter multiple times using a non-incrementing address mode.
11155 + * The rationale here is to make all HIF accesses a multiple of 4 bytes */
11156 + status = HIFReadWrite(device, address, (A_UINT8 *)&cmdCredits, sizeof(cmdCredits),
11157 + HIF_RD_SYNC_BYTE_FIX, NULL);
11158 + if (status != A_OK) {
11159 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read the command credit count register\n"));
11162 + /* we did a 4-byte read to the same count register so mask off upper bytes */
11163 + cmdCredits &= 0xFF;
11164 + status = A_ERROR;
11167 + if (cmdCredits) {
11168 + address = mboxAddress[ENDPOINT1];
11169 + status = HIFReadWrite(device, address, buffer, length,
11170 + HIF_RD_SYNC_BYTE_INC, NULL);
11171 + if (status != A_OK) {
11172 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read the BMI data from the device\n"));
11176 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Communication timeout\n"));
11182 diff --git a/drivers/sdio/function/wlan/ar6000/bmi/bmi_internal.h b/drivers/sdio/function/wlan/ar6000/bmi/bmi_internal.h
11183 new file mode 100644
11184 index 0000000..1e21354
11186 +++ b/drivers/sdio/function/wlan/ar6000/bmi/bmi_internal.h
11188 +#ifndef BMI_INTERNAL_H
11189 +#define BMI_INTERNAL_H
11192 + * Copyright (c) 2004-2007 Atheros Communications Inc.
11193 + * All rights reserved.
11196 + * This program is free software; you can redistribute it and/or modify
11197 + * it under the terms of the GNU General Public License version 2 as
11198 + * published by the Free Software Foundation;
11200 + * Software distributed under the License is distributed on an "AS
11201 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11202 + * implied. See the License for the specific language governing
11203 + * rights and limitations under the License.
11209 +#include "a_config.h"
11210 +#include "athdefs.h"
11211 +#include "a_types.h"
11212 +#include "a_osapi.h"
11213 +#include "a_debug.h"
11214 +#include "AR6Khwreg.h"
11215 +#include "bmi_msg.h"
11217 +#define BMI_COMMUNICATION_TIMEOUT 100000
11219 +/* ------ Global Variable Declarations ------- */
11223 +bmiBufferSend(HIF_DEVICE *device,
11225 + A_UINT32 length);
11228 +bmiBufferReceive(HIF_DEVICE *device,
11230 + A_UINT32 length);
11233 diff --git a/drivers/sdio/function/wlan/ar6000/hif/hif.c b/drivers/sdio/function/wlan/ar6000/hif/hif.c
11234 new file mode 100644
11235 index 0000000..f5a0986
11237 +++ b/drivers/sdio/function/wlan/ar6000/hif/hif.c
11242 + * @abstract: HIF layer reference implementation for Atheros SDIO stack
11244 + * @notice: Copyright (c) 2004-2006 Atheros Communications Inc.
11247 + * This program is free software; you can redistribute it and/or modify
11248 + * it under the terms of the GNU General Public License version 2 as
11249 + * published by the Free Software Foundation;
11251 + * Software distributed under the License is distributed on an "AS
11252 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11253 + * implied. See the License for the specific language governing
11254 + * rights and limitations under the License.
11260 +#include "hif_internal.h"
11262 +/* ------ Static Variables ------ */
11264 +/* ------ Global Variable Declarations ------- */
11265 +SD_PNP_INFO Ids[] = {
11267 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6001_BASE | 0xB,
11268 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11269 + .SDIO_FunctionClass = FUNCTION_CLASS,
11270 + .SDIO_FunctionNo = 1
11273 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6001_BASE | 0xA,
11274 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11275 + .SDIO_FunctionClass = FUNCTION_CLASS,
11276 + .SDIO_FunctionNo = 1
11279 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6001_BASE | 0x9,
11280 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11281 + .SDIO_FunctionClass = FUNCTION_CLASS,
11282 + .SDIO_FunctionNo = 1
11285 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6001_BASE | 0x8,
11286 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11287 + .SDIO_FunctionClass = FUNCTION_CLASS,
11288 + .SDIO_FunctionNo = 1
11291 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6002_BASE | 0x0,
11292 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11293 + .SDIO_FunctionClass = FUNCTION_CLASS,
11294 + .SDIO_FunctionNo = 1
11297 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6002_BASE | 0x1,
11298 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11299 + .SDIO_FunctionClass = FUNCTION_CLASS,
11300 + .SDIO_FunctionNo = 1
11303 + } //list is null termintaed
11306 +TARGET_FUNCTION_CONTEXT FunctionContext = {
11307 + .function.Version = CT_SDIO_STACK_VERSION_CODE,
11308 + .function.pName = "sdio_wlan",
11309 + .function.MaxDevices = 1,
11310 + .function.NumDevices = 0,
11311 + .function.pIds = Ids,
11312 + .function.pProbe = hifDeviceInserted,
11313 + .function.pRemove = hifDeviceRemoved,
11314 + .function.pSuspend = NULL,
11315 + .function.pResume = NULL,
11316 + .function.pWake = NULL,
11317 + .function.pContext = &FunctionContext,
11320 +HIF_DEVICE hifDevice[HIF_MAX_DEVICES];
11321 +HTC_CALLBACKS htcCallbacks;
11322 +BUS_REQUEST busRequest[BUS_REQUEST_MAX_NUM];
11323 +static BUS_REQUEST *s_busRequestFreeQueue = NULL;
11324 +OS_CRITICALSECTION lock;
11325 +extern A_UINT32 onebitmode;
11326 +extern A_UINT32 busspeedlow;
11327 +extern A_UINT32 debughif;
11330 +#define ATH_DEBUG_ERROR 1
11331 +#define ATH_DEBUG_WARN 2
11332 +#define ATH_DEBUG_TRACE 3
11333 +#define _AR_DEBUG_PRINTX_ARG(arg...) arg
11334 +#define AR_DEBUG_PRINTF(lvl, args)\
11335 + {if (lvl <= debughif)\
11336 + A_PRINTF(KERN_ALERT _AR_DEBUG_PRINTX_ARG args);\
11339 +#define AR_DEBUG_PRINTF(lvl, args)
11342 +static BUS_REQUEST *hifAllocateBusRequest(void);
11343 +static void hifFreeBusRequest(BUS_REQUEST *busrequest);
11344 +static THREAD_RETURN insert_helper_func(POSKERNEL_HELPER pHelper);
11345 +static void ResetAllCards(void);
11347 +/* ------ Functions ------ */
11348 +int HIFInit(HTC_CALLBACKS *callbacks)
11350 + SDIO_STATUS status;
11351 + DBG_ASSERT(callbacks != NULL);
11353 + /* Store the callback and event handlers */
11354 + htcCallbacks.deviceInsertedHandler = callbacks->deviceInsertedHandler;
11355 + htcCallbacks.deviceRemovedHandler = callbacks->deviceRemovedHandler;
11356 + htcCallbacks.deviceSuspendHandler = callbacks->deviceSuspendHandler;
11357 + htcCallbacks.deviceResumeHandler = callbacks->deviceResumeHandler;
11358 + htcCallbacks.deviceWakeupHandler = callbacks->deviceWakeupHandler;
11359 + htcCallbacks.rwCompletionHandler = callbacks->rwCompletionHandler;
11360 + htcCallbacks.dsrHandler = callbacks->dsrHandler;
11362 + CriticalSectionInit(&lock);
11364 + /* Register with bus driver core */
11365 + status = SDIO_RegisterFunction(&FunctionContext.function);
11366 + DBG_ASSERT(SDIO_SUCCESS(status));
11372 +HIFReadWrite(HIF_DEVICE *device,
11373 + A_UINT32 address,
11376 + A_UINT32 request,
11384 + SDREQUEST *sdrequest;
11385 + SDIO_STATUS sdiostatus;
11386 + BUS_REQUEST *busrequest;
11387 + A_STATUS status = A_OK;
11389 + DBG_ASSERT(device != NULL);
11390 + DBG_ASSERT(device->handle != NULL);
11392 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Device: %p\n", device));
11395 + busrequest = hifAllocateBusRequest();
11396 + if (busrequest == NULL) {
11397 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("HIF Unable to allocate bus request\n"));
11398 + status = A_NO_RESOURCE;
11402 + sdrequest = busrequest->request;
11403 + busrequest->context = context;
11405 + sdrequest->pDataBuffer = buffer;
11406 + if (request & HIF_SYNCHRONOUS) {
11407 + sdrequest->Flags = SDREQ_FLAGS_RESP_SDIO_R5 | SDREQ_FLAGS_DATA_TRANS;
11408 + sdrequest->pCompleteContext = NULL;
11409 + sdrequest->pCompletion = NULL;
11410 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Execution mode: Synchronous\n"));
11411 + } else if (request & HIF_ASYNCHRONOUS) {
11412 + sdrequest->Flags = SDREQ_FLAGS_RESP_SDIO_R5 | SDREQ_FLAGS_DATA_TRANS |
11413 + SDREQ_FLAGS_TRANS_ASYNC;
11414 + sdrequest->pCompleteContext = busrequest;
11415 + sdrequest->pCompletion = hifRWCompletionHandler;
11416 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Execution mode: Asynchronous\n"));
11418 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11419 + ("Invalid execution mode: 0x%08x\n", request));
11420 + status = A_EINVAL;
11424 + if (request & HIF_EXTENDED_IO) {
11425 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Command type: CMD53\n"));
11426 + sdrequest->Command = CMD53;
11428 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11429 + ("Invalid command type: 0x%08x\n", request));
11430 + status = A_EINVAL;
11434 + if (request & HIF_BLOCK_BASIS) {
11435 + mode = CMD53_BLOCK_BASIS;
11436 + sdrequest->BlockLen = HIF_MBOX_BLOCK_SIZE;
11437 + sdrequest->BlockCount = length / HIF_MBOX_BLOCK_SIZE;
11438 + count = sdrequest->BlockCount;
11439 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11440 + ("Block mode (BlockLen: %d, BlockCount: %d)\n",
11441 + sdrequest->BlockLen, sdrequest->BlockCount));
11442 + } else if (request & HIF_BYTE_BASIS) {
11443 + mode = CMD53_BYTE_BASIS;
11444 + sdrequest->BlockLen = length;
11445 + sdrequest->BlockCount = 1;
11446 + count = sdrequest->BlockLen;
11447 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11448 + ("Byte mode (BlockLen: %d, BlockCount: %d)\n",
11449 + sdrequest->BlockLen, sdrequest->BlockCount));
11451 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11452 + ("Invalid data mode: 0x%08x\n", request));
11453 + status = A_EINVAL;
11458 + /* useful for checking register accesses */
11459 + if (length & 0x3) {
11460 + A_PRINTF(KERN_ALERT"HIF (%s) is not a multiple of 4 bytes, addr:0x%X, len:%d\n",
11461 + request & HIF_WRITE ? "write":"read", address, length);
11465 + if ((address >= HIF_MBOX_START_ADDR(0)) &&
11466 + (address <= HIF_MBOX_END_ADDR(3)))
11469 + DBG_ASSERT(length <= HIF_MBOX_WIDTH);
11472 + * Mailbox write. Adjust the address so that the last byte
11473 + * falls on the EOM address.
11475 + address += (HIF_MBOX_WIDTH - length);
11480 + if (request & HIF_WRITE) {
11481 + rw = CMD53_WRITE;
11482 + sdrequest->Flags |= SDREQ_FLAGS_DATA_WRITE;
11483 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Direction: Write\n"));
11484 + } else if (request & HIF_READ) {
11486 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Direction: Read\n"));
11488 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11489 + ("Invalid direction: 0x%08x\n", request));
11490 + status = A_EINVAL;
11494 + if (request & HIF_FIXED_ADDRESS) {
11495 + opcode = CMD53_FIXED_ADDRESS;
11496 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Address mode: Fixed\n"));
11497 + } else if (request & HIF_INCREMENTAL_ADDRESS) {
11498 + opcode = CMD53_INCR_ADDRESS;
11499 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Address mode: Incremental\n"));
11501 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11502 + ("Invalid address mode: 0x%08x\n", request));
11503 + status = A_EINVAL;
11507 + funcNo = SDDEVICE_GET_SDIO_FUNCNO(device->handle);
11508 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Function number: %d\n", funcNo));
11509 + SDIO_SET_CMD53_ARG(sdrequest->Argument, rw, funcNo,
11510 + mode, opcode, address, count);
11512 + /* Send the command out */
11513 + sdiostatus = SDDEVICE_CALL_REQUEST_FUNC(device->handle, sdrequest);
11515 + if (!SDIO_SUCCESS(sdiostatus)) {
11516 + status = A_ERROR;
11521 + if (A_FAILED(status) || (request & HIF_SYNCHRONOUS)) {
11522 + if (busrequest != NULL) {
11523 + hifFreeBusRequest(busrequest);
11527 + if (A_FAILED(status) && (request & HIF_ASYNCHRONOUS)) {
11528 + /* call back async handler on failure */
11529 + htcCallbacks.rwCompletionHandler(context, status);
11536 +HIFConfigureDevice(HIF_DEVICE *device, HIF_DEVICE_CONFIG_OPCODE opcode,
11537 + void *config, A_UINT32 configLen)
11542 + case HIF_DEVICE_GET_MBOX_BLOCK_SIZE:
11543 + ((A_UINT32 *)config)[0] = HIF_MBOX0_BLOCK_SIZE;
11544 + ((A_UINT32 *)config)[1] = HIF_MBOX1_BLOCK_SIZE;
11545 + ((A_UINT32 *)config)[2] = HIF_MBOX2_BLOCK_SIZE;
11546 + ((A_UINT32 *)config)[3] = HIF_MBOX3_BLOCK_SIZE;
11549 + case HIF_DEVICE_GET_MBOX_ADDR:
11550 + for (count = 0; count < 4; count ++) {
11551 + ((A_UINT32 *)config)[count] = HIF_MBOX_START_ADDR(count);
11554 + case HIF_DEVICE_GET_IRQ_PROC_MODE:
11555 + /* the SDIO stack allows the interrupts to be processed either way, ASYNC or SYNC */
11556 + *((HIF_DEVICE_IRQ_PROCESSING_MODE *)config) = HIF_DEVICE_IRQ_ASYNC_SYNC;
11559 + AR_DEBUG_PRINTF(ATH_DEBUG_WARN,
11560 + ("Unsupported configuration opcode: %d\n", opcode));
11568 +HIFShutDownDevice(HIF_DEVICE *device)
11572 + SDIO_STATUS status;
11573 + SDCONFIG_BUS_MODE_DATA busSettings;
11574 + SDCONFIG_FUNC_ENABLE_DISABLE_DATA fData;
11576 + if (device != NULL) {
11577 + DBG_ASSERT(device->handle != NULL);
11579 + /* Remove the allocated current if any */
11580 + status = SDLIB_IssueConfig(device->handle,
11581 + SDCONFIG_FUNC_FREE_SLOT_CURRENT, NULL, 0);
11582 + DBG_ASSERT(SDIO_SUCCESS(status));
11584 + /* Disable the card */
11585 + fData.EnableFlags = SDCONFIG_DISABLE_FUNC;
11586 + fData.TimeOut = 1;
11587 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_FUNC_ENABLE_DISABLE,
11588 + &fData, sizeof(fData));
11589 + DBG_ASSERT(SDIO_SUCCESS(status));
11591 + /* Perform a soft I/O reset */
11592 + data = SDIO_IO_RESET;
11593 + status = SDLIB_IssueCMD52(device->handle, 0, SDIO_IO_ABORT_REG,
11595 + DBG_ASSERT(SDIO_SUCCESS(status));
11598 + * WAR - Codetelligence driver does not seem to shutdown correctly in 1
11599 + * bit mode. By default it configures the HC in the 4 bit. Its later in
11600 + * our driver that we switch to 1 bit mode. If we try to shutdown, the
11601 + * driver hangs so we revert to 4 bit mode, to be transparent to the
11602 + * underlying bus driver.
11604 + if (onebitmode) {
11605 + ZERO_OBJECT(busSettings);
11606 + busSettings.BusModeFlags = SDDEVICE_GET_BUSMODE_FLAGS(device->handle);
11607 + SDCONFIG_SET_BUS_WIDTH(busSettings.BusModeFlags,
11608 + SDCONFIG_BUS_WIDTH_4_BIT);
11610 + /* Issue config request to change the bus width to 4 bit */
11611 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_BUS_MODE_CTRL,
11613 + sizeof(SDCONFIG_BUS_MODE_DATA));
11614 + DBG_ASSERT(SDIO_SUCCESS(status));
11617 + /* Free the bus requests */
11618 + for (count = 0; count < BUS_REQUEST_MAX_NUM; count ++) {
11619 + SDDeviceFreeRequest(device->handle, busRequest[count].request);
11621 + /* Clean up the queue */
11622 + s_busRequestFreeQueue = NULL;
11624 + /* since we are unloading the driver anyways, reset all cards in case the SDIO card
11625 + * is externally powered and we are unloading the SDIO stack. This avoids the problem when
11626 + * the SDIO stack is reloaded and attempts are made to re-enumerate a card that is already
11629 + /* Unregister with bus driver core */
11630 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11631 + ("Unregistering with the bus driver\n"));
11632 + status = SDIO_UnregisterFunction(&FunctionContext.function);
11633 + DBG_ASSERT(SDIO_SUCCESS(status));
11638 +hifRWCompletionHandler(SDREQUEST *request)
11642 + BUS_REQUEST *busrequest;
11644 + if (SDIO_SUCCESS(request->Status)) {
11647 + status = A_ERROR;
11650 + DBG_ASSERT(status == A_OK);
11651 + busrequest = (BUS_REQUEST *) request->pCompleteContext;
11652 + context = (void *) busrequest->context;
11653 + /* free the request before calling the callback, in case the
11654 + * callback submits another request, this guarantees that
11655 + * there is at least 1 free request available everytime the callback
11657 + hifFreeBusRequest(busrequest);
11658 + htcCallbacks.rwCompletionHandler(context, status);
11662 +hifIRQHandler(void *context)
11665 + HIF_DEVICE *device;
11667 + device = (HIF_DEVICE *)context;
11668 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Device: %p\n", device));
11669 + status = htcCallbacks.dsrHandler(device->htc_handle);
11670 + DBG_ASSERT(status == A_OK);
11674 +hifDeviceInserted(SDFUNCTION *function, SDDEVICE *handle)
11679 + HIF_DEVICE *device;
11680 + SDIO_STATUS status;
11681 + A_UINT16 maxBlocks;
11682 + A_UINT16 maxBlockSize;
11683 + SDCONFIG_BUS_MODE_DATA busSettings;
11684 + SDCONFIG_FUNC_ENABLE_DISABLE_DATA fData;
11685 + TARGET_FUNCTION_CONTEXT *functionContext;
11686 + SDCONFIG_FUNC_SLOT_CURRENT_DATA slotCurrent;
11687 + SD_BUSCLOCK_RATE currentBusClock;
11689 + DBG_ASSERT(function != NULL);
11690 + DBG_ASSERT(handle != NULL);
11692 + device = addHifDevice(handle);
11693 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Device: %p\n", device));
11694 + functionContext = (TARGET_FUNCTION_CONTEXT *)function->pContext;
11697 + * Issue commands to get the manufacturer ID and stuff and compare it
11698 + * against the rev Id derived from the ID registered during the
11699 + * initialization process. Report the device only in the case there
11700 + * is a match. In the case od SDIO, the bus driver has already queried
11701 + * these details so we just need to use their data structures to get the
11702 + * relevant values. Infact, the driver has already matched it against
11703 + * the Ids that we registered with it so we dont need to the step here.
11706 + /* Configure the SDIO Bus Width */
11707 + if (onebitmode) {
11708 + data = SDIO_BUS_WIDTH_1_BIT;
11709 + status = SDLIB_IssueCMD52(handle, 0, SDIO_BUS_IF_REG, &data, 1, 1);
11710 + if (!SDIO_SUCCESS(status)) {
11711 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11712 + ("Unable to set the bus width to 1 bit\n"));
11717 + /* Get current bus flags */
11718 + ZERO_OBJECT(busSettings);
11720 + busSettings.BusModeFlags = SDDEVICE_GET_BUSMODE_FLAGS(handle);
11721 + if (onebitmode) {
11722 + SDCONFIG_SET_BUS_WIDTH(busSettings.BusModeFlags,
11723 + SDCONFIG_BUS_WIDTH_1_BIT);
11726 + /* get the current operating clock, the bus driver sets us up based
11727 + * on what our CIS reports and what the host controller can handle
11728 + * we can use this to determine whether we want to drop our clock rate
11730 + currentBusClock = SDDEVICE_GET_OPER_CLOCK(handle);
11731 + busSettings.ClockRate = currentBusClock;
11733 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11734 + ("HIF currently running at: %d \n",currentBusClock));
11736 + /* see if HIF wants to run at a lower clock speed, we may already be
11737 + * at that lower clock speed */
11738 + if (currentBusClock > (SDIO_CLOCK_FREQUENCY_DEFAULT >> busspeedlow)) {
11739 + busSettings.ClockRate = SDIO_CLOCK_FREQUENCY_DEFAULT >> busspeedlow;
11740 + AR_DEBUG_PRINTF(ATH_DEBUG_WARN,
11741 + ("HIF overriding clock to %d \n",busSettings.ClockRate));
11744 + /* Issue config request to override clock rate */
11745 + status = SDLIB_IssueConfig(handle, SDCONFIG_FUNC_CHANGE_BUS_MODE, &busSettings,
11746 + sizeof(SDCONFIG_BUS_MODE_DATA));
11747 + if (!SDIO_SUCCESS(status)) {
11748 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11749 + ("Unable to configure the host clock\n"));
11752 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11753 + ("Configured clock: %d, Maximum clock: %d\n",
11754 + busSettings.ActualClockRate,
11755 + SDDEVICE_GET_MAX_CLOCK(handle)));
11759 + * Check if the target supports block mode. This result of this check
11760 + * can be used to implement the HIFReadWrite API.
11762 + if (SDDEVICE_GET_SDIO_FUNC_MAXBLKSIZE(handle)) {
11763 + /* Limit block size to operational block limit or card function
11765 + maxBlockSize = min(SDDEVICE_GET_OPER_BLOCK_LEN(handle),
11766 + SDDEVICE_GET_SDIO_FUNC_MAXBLKSIZE(handle));
11768 + /* check if the card support multi-block transfers */
11769 + if (!(SDDEVICE_GET_SDIOCARD_CAPS(handle) & SDIO_CAPS_MULTI_BLOCK)) {
11770 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Byte basis only\n"));
11772 + /* Limit block size to max byte basis */
11773 + maxBlockSize = min(maxBlockSize,
11774 + (A_UINT16)SDIO_MAX_LENGTH_BYTE_BASIS);
11777 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Multi-block capable\n"));
11778 + maxBlocks = SDDEVICE_GET_OPER_BLOCKS(handle);
11779 + status = SDLIB_SetFunctionBlockSize(handle, HIF_MBOX_BLOCK_SIZE);
11780 + if (!SDIO_SUCCESS(status)) {
11781 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11782 + ("Failed to set block size. Err:%d\n", status));
11787 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11788 + ("Bytes Per Block: %d bytes, Block Count:%d \n",
11789 + maxBlockSize, maxBlocks));
11791 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11792 + ("Function does not support Block Mode!\n"));
11796 + /* Allocate the slot current */
11797 + status = SDLIB_GetDefaultOpCurrent(handle, &slotCurrent.SlotCurrent);
11798 + if (SDIO_SUCCESS(status)) {
11799 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Allocating Slot current: %d mA\n",
11800 + slotCurrent.SlotCurrent));
11801 + status = SDLIB_IssueConfig(handle, SDCONFIG_FUNC_ALLOC_SLOT_CURRENT,
11802 + &slotCurrent, sizeof(slotCurrent));
11803 + if (!SDIO_SUCCESS(status)) {
11804 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11805 + ("Failed to allocate slot current %d\n", status));
11810 + /* Enable the dragon function */
11813 + fData.TimeOut = 1;
11814 + fData.EnableFlags = SDCONFIG_ENABLE_FUNC;
11815 + while ((count++ < SDWLAN_ENABLE_DISABLE_TIMEOUT) && !enabled)
11817 + /* Enable dragon */
11818 + status = SDLIB_IssueConfig(handle, SDCONFIG_FUNC_ENABLE_DISABLE,
11819 + &fData, sizeof(fData));
11820 + if (!SDIO_SUCCESS(status)) {
11821 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11822 + ("Attempting to enable the card again\n"));
11826 + /* Mark the status as enabled */
11830 + /* Check if we were succesful in enabling the target */
11832 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11833 + ("Failed to communicate with the target\n"));
11837 + /* Allocate the bus requests to be used later */
11838 + A_MEMZERO(busRequest, sizeof(busRequest));
11839 + for (count = 0; count < BUS_REQUEST_MAX_NUM; count ++) {
11840 + if ((busRequest[count].request = SDDeviceAllocRequest(handle)) == NULL){
11841 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("Unable to allocate memory\n"));
11842 + /* TODO: Free the memory that has already been allocated */
11845 + hifFreeBusRequest(&busRequest[count]);
11847 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11848 + ("0x%08x = busRequest[%d].request = 0x%08x\n",
11849 + (unsigned int) &busRequest[count], count,
11850 + (unsigned int) busRequest[count].request));
11853 + /* Schedule a worker to handle device inserted, this is a temporary workaround
11854 + * to fix a deadlock if the device fails to intialize in the insertion handler
11855 + * The failure causes the instance to shutdown the HIF layer and unregister the
11856 + * function driver within the busdriver probe context which can deadlock
11858 + * NOTE: we cannot use the default work queue because that would block
11859 + * SD bus request processing for all synchronous I/O. We must use a kernel
11860 + * thread that is creating using the helper library.
11863 + if (SDIO_SUCCESS(SDLIB_OSCreateHelper(&device->insert_helper,
11864 + insert_helper_func,
11866 + device->helper_started = TRUE;
11872 +static THREAD_RETURN insert_helper_func(POSKERNEL_HELPER pHelper)
11876 + * Adding a wait of around a second before we issue the very first
11877 + * command to dragon. During the process of loading/unloading the
11878 + * driver repeatedly it was observed that we get a data timeout
11879 + * while accessing function 1 registers in the chip. The theory at
11880 + * this point is that some initialization delay in dragon is
11881 + * causing the SDIO state in dragon core to be not ready even after
11882 + * the ready bit indicates that function 1 is ready. Accomodating
11883 + * for this behavior by adding some delay in the driver before it
11884 + * issues the first command after switching on dragon. Need to
11885 + * investigate this a bit more - TODO
11890 + if ((htcCallbacks.deviceInsertedHandler(SD_GET_OS_HELPER_CONTEXT(pHelper))) != A_OK) {
11891 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Device rejected\n"));
11898 +HIFAckInterrupt(HIF_DEVICE *device)
11900 + SDIO_STATUS status;
11901 + DBG_ASSERT(device != NULL);
11902 + DBG_ASSERT(device->handle != NULL);
11904 + /* Acknowledge our function IRQ */
11905 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_FUNC_ACK_IRQ,
11907 + DBG_ASSERT(SDIO_SUCCESS(status));
11911 +HIFUnMaskInterrupt(HIF_DEVICE *device)
11913 + SDIO_STATUS status;
11915 + DBG_ASSERT(device != NULL);
11916 + DBG_ASSERT(device->handle != NULL);
11918 + /* Register the IRQ Handler */
11919 + SDDEVICE_SET_IRQ_HANDLER(device->handle, hifIRQHandler, device);
11921 + /* Unmask our function IRQ */
11922 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_FUNC_UNMASK_IRQ,
11924 + DBG_ASSERT(SDIO_SUCCESS(status));
11927 +void HIFMaskInterrupt(HIF_DEVICE *device)
11929 + SDIO_STATUS status;
11930 + DBG_ASSERT(device != NULL);
11931 + DBG_ASSERT(device->handle != NULL);
11933 + /* Mask our function IRQ */
11934 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_FUNC_MASK_IRQ,
11936 + DBG_ASSERT(SDIO_SUCCESS(status));
11938 + /* Unregister the IRQ Handler */
11939 + SDDEVICE_SET_IRQ_HANDLER(device->handle, NULL, NULL);
11942 +static BUS_REQUEST *hifAllocateBusRequest(void)
11944 + BUS_REQUEST *busrequest;
11946 + /* Acquire lock */
11947 + CriticalSectionAcquire(&lock);
11949 + /* Remove first in list */
11950 + if((busrequest = s_busRequestFreeQueue) != NULL)
11952 + s_busRequestFreeQueue = busrequest->next;
11955 + /* Release lock */
11956 + CriticalSectionRelease(&lock);
11958 + return busrequest;
11962 +hifFreeBusRequest(BUS_REQUEST *busrequest)
11964 + DBG_ASSERT(busrequest != NULL);
11966 + /* Acquire lock */
11967 + CriticalSectionAcquire(&lock);
11969 + /* Insert first in list */
11970 + busrequest->next = s_busRequestFreeQueue;
11971 + s_busRequestFreeQueue = busrequest;
11973 + /* Release lock */
11974 + CriticalSectionRelease(&lock);
11978 +hifDeviceRemoved(SDFUNCTION *function, SDDEVICE *handle)
11981 + HIF_DEVICE *device;
11982 + DBG_ASSERT(function != NULL);
11983 + DBG_ASSERT(handle != NULL);
11985 + device = getHifDevice(handle);
11986 + status = htcCallbacks.deviceRemovedHandler(device->htc_handle, A_OK);
11988 + /* cleanup the helper thread */
11989 + if (device->helper_started) {
11990 + SDLIB_OSDeleteHelper(&device->insert_helper);
11991 + device->helper_started = FALSE;
11994 + delHifDevice(handle);
11995 + DBG_ASSERT(status == A_OK);
11999 +addHifDevice(SDDEVICE *handle)
12001 + DBG_ASSERT(handle != NULL);
12002 + hifDevice[0].handle = handle;
12003 + return &hifDevice[0];
12007 +getHifDevice(SDDEVICE *handle)
12009 + DBG_ASSERT(handle != NULL);
12010 + return &hifDevice[0];
12014 +delHifDevice(SDDEVICE *handle)
12016 + DBG_ASSERT(handle != NULL);
12017 + hifDevice[0].handle = NULL;
12020 +static void ResetAllCards(void)
12023 + SDIO_STATUS status;
12026 + data = SDIO_IO_RESET;
12028 + /* set the I/O CARD reset bit:
12029 + * NOTE: we are exploiting a "feature" of the SDIO core that resets the core when you
12030 + * set the RES bit in the SDIO_IO_ABORT register. This bit however "normally" resets the
12031 + * I/O functions leaving the SDIO core in the same state (as per SDIO spec).
12032 + * In this design, this reset can be used to reset the SDIO core itself */
12033 + for (i = 0; i < HIF_MAX_DEVICES; i++) {
12034 + if (hifDevice[i].handle != NULL) {
12035 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
12036 + ("Issuing I/O Card reset for instance: %d \n",i));
12037 + /* set the I/O Card reset bit */
12038 + status = SDLIB_IssueCMD52(hifDevice[i].handle,
12039 + 0, /* function 0 space */
12040 + SDIO_IO_ABORT_REG,
12043 + TRUE); /* write */
12049 +void HIFSetHandle(void *hif_handle, void *handle)
12051 + HIF_DEVICE *device = (HIF_DEVICE *) hif_handle;
12053 + device->htc_handle = handle;
12057 diff --git a/drivers/sdio/function/wlan/ar6000/hif/hif_internal.h b/drivers/sdio/function/wlan/ar6000/hif/hif_internal.h
12058 new file mode 100644
12059 index 0000000..d8fc101
12061 +++ b/drivers/sdio/function/wlan/ar6000/hif/hif_internal.h
12064 + * @file: hif_internal.h
12066 + * @abstract: internal header file for hif layer
12068 + * @notice: Copyright (c) 2004-2006 Atheros Communications Inc.
12071 + * This program is free software; you can redistribute it and/or modify
12072 + * it under the terms of the GNU General Public License version 2 as
12073 + * published by the Free Software Foundation;
12075 + * Software distributed under the License is distributed on an "AS
12076 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
12077 + * implied. See the License for the specific language governing
12078 + * rights and limitations under the License.
12084 +#include <linux/sdio/ctsystem.h>
12085 +#include <linux/sdio/sdio_busdriver.h>
12086 +#include <linux/sdio/_sdio_defs.h>
12087 +#include <linux/sdio/sdio_lib.h>
12088 +#include "a_config.h"
12089 +#include "athdefs.h"
12090 +#include "a_types.h"
12091 +#include "a_osapi.h"
12094 +#define MANUFACTURER_ID_AR6001_BASE 0x100
12095 +#define MANUFACTURER_ID_AR6002_BASE 0x200
12096 +#define FUNCTION_CLASS 0x0
12097 +#define MANUFACTURER_CODE 0x271
12099 +#define BUS_REQUEST_MAX_NUM 64
12101 +#define SDIO_CLOCK_FREQUENCY_DEFAULT 25000000
12102 +#define SDWLAN_ENABLE_DISABLE_TIMEOUT 20
12103 +#define FLAGS_CARD_ENAB 0x02
12104 +#define FLAGS_CARD_IRQ_UNMSK 0x04
12106 +#define HIF_MBOX_BLOCK_SIZE 128
12107 +#define HIF_MBOX_BASE_ADDR 0x800
12108 +#define HIF_MBOX_WIDTH 0x800
12109 +#define HIF_MBOX0_BLOCK_SIZE 1
12110 +#define HIF_MBOX1_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE
12111 +#define HIF_MBOX2_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE
12112 +#define HIF_MBOX3_BLOCK_SIZE HIF_MBOX_BLOCK_SIZE
12114 +#define HIF_MBOX_START_ADDR(mbox) \
12115 + HIF_MBOX_BASE_ADDR + mbox * HIF_MBOX_WIDTH
12117 +#define HIF_MBOX_END_ADDR(mbox) \
12118 + HIF_MBOX_START_ADDR(mbox) + HIF_MBOX_WIDTH - 1
12120 +struct hif_device {
12121 + SDDEVICE *handle;
12122 + void *htc_handle;
12123 + OSKERNEL_HELPER insert_helper;
12124 + BOOL helper_started;
12127 +typedef struct target_function_context {
12128 + SDFUNCTION function; /* function description of the bus driver */
12129 + OS_SEMAPHORE instanceSem; /* instance lock. Unused */
12130 + SDLIST instanceList; /* list of instances. Unused */
12131 +} TARGET_FUNCTION_CONTEXT;
12133 +typedef struct bus_request {
12134 + struct bus_request *next;
12135 + SDREQUEST *request;
12140 +hifDeviceInserted(SDFUNCTION *function, SDDEVICE *device);
12143 +hifDeviceRemoved(SDFUNCTION *function, SDDEVICE *device);
12146 +hifAllocateDeviceRequest(SDDEVICE *device);
12149 +hifFreeDeviceRequest(SDREQUEST *request);
12152 +hifRWCompletionHandler(SDREQUEST *request);
12155 +hifIRQHandler(void *context);
12158 +addHifDevice(SDDEVICE *handle);
12161 +getHifDevice(SDDEVICE *handle);
12164 +delHifDevice(SDDEVICE *handle);
12165 diff --git a/drivers/sdio/function/wlan/ar6000/htc/ar6k.c b/drivers/sdio/function/wlan/ar6000/htc/ar6k.c
12166 new file mode 100644
12167 index 0000000..0fd671a
12169 +++ b/drivers/sdio/function/wlan/ar6000/htc/ar6k.c
12172 + * AR6K device layer that handles register level I/O
12174 + * Copyright (c) 2007 Atheros Communications Inc.
12175 + * All rights reserved.
12178 + * This program is free software; you can redistribute it and/or modify
12179 + * it under the terms of the GNU General Public License version 2 as
12180 + * published by the Free Software Foundation;
12182 + * Software distributed under the License is distributed on an "AS
12183 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
12184 + * implied. See the License for the specific language governing
12185 + * rights and limitations under the License.
12190 +#include "a_config.h"
12191 +#include "athdefs.h"
12192 +#include "a_types.h"
12193 +#include "AR6Khwreg.h"
12194 +#include "a_osapi.h"
12195 +#include "a_debug.h"
12197 +#include "htc_packet.h"
12200 +#define MAILBOX_FOR_BLOCK_SIZE 1
12202 +extern A_UINT32 resetok;
12204 +static A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev);
12205 +static A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev);
12207 +#define LOCK_AR6K(p) A_MUTEX_LOCK(&(p)->Lock);
12208 +#define UNLOCK_AR6K(p) A_MUTEX_UNLOCK(&(p)->Lock);
12210 +void AR6KFreeIOPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket)
12213 + HTC_PACKET_ENQUEUE(&pDev->RegisterIOList,pPacket);
12214 + UNLOCK_AR6K(pDev);
12217 +HTC_PACKET *AR6KAllocIOPacket(AR6K_DEVICE *pDev)
12219 + HTC_PACKET *pPacket;
12222 + pPacket = HTC_PACKET_DEQUEUE(&pDev->RegisterIOList);
12223 + UNLOCK_AR6K(pDev);
12228 +A_STATUS DevSetup(AR6K_DEVICE *pDev)
12230 + A_UINT32 mailboxaddrs[AR6K_MAILBOXES];
12231 + A_UINT32 blocksizes[AR6K_MAILBOXES];
12232 + A_STATUS status = A_OK;
12235 + AR_DEBUG_ASSERT(AR6K_IRQ_PROC_REGS_SIZE == 16);
12236 + AR_DEBUG_ASSERT(AR6K_IRQ_ENABLE_REGS_SIZE == 4);
12239 + /* give a handle to HIF for this target */
12240 + HIFSetHandle(pDev->HIFDevice, (void *)pDev);
12241 + /* initialize our free list of IO packets */
12242 + INIT_HTC_PACKET_QUEUE(&pDev->RegisterIOList);
12243 + A_MUTEX_INIT(&pDev->Lock);
12245 + /* get the addresses for all 4 mailboxes */
12246 + status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR,
12247 + mailboxaddrs, sizeof(mailboxaddrs));
12249 + if (status != A_OK) {
12250 + AR_DEBUG_ASSERT(FALSE);
12254 + /* carve up register I/O packets (these are for ASYNC register I/O ) */
12255 + for (i = 0; i < AR6K_MAX_REG_IO_BUFFERS; i++) {
12256 + HTC_PACKET *pIOPacket;
12257 + pIOPacket = &pDev->RegIOBuffers[i].HtcPacket;
12258 + SET_HTC_PACKET_INFO_RX_REFILL(pIOPacket,
12260 + pDev->RegIOBuffers[i].Buffer,
12261 + AR6K_REG_IO_BUFFER_SIZE,
12262 + 0); /* don't care */
12263 + AR6KFreeIOPacket(pDev,pIOPacket);
12266 + /* get the address of the mailbox we are using */
12267 + pDev->MailboxAddress = mailboxaddrs[HTC_MAILBOX];
12269 + /* get the block sizes */
12270 + status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
12271 + blocksizes, sizeof(blocksizes));
12273 + if (status != A_OK) {
12274 + AR_DEBUG_ASSERT(FALSE);
12278 + /* note: we actually get the block size of a mailbox other than 0, for SDIO the block
12279 + * size on mailbox 0 is artificially set to 1. So we use the block size that is set
12280 + * for the other 3 mailboxes */
12281 + pDev->BlockSize = blocksizes[MAILBOX_FOR_BLOCK_SIZE];
12282 + /* must be a power of 2 */
12283 + AR_DEBUG_ASSERT((pDev->BlockSize & (pDev->BlockSize - 1)) == 0);
12285 + /* assemble mask, used for padding to a block */
12286 + pDev->BlockMask = pDev->BlockSize - 1;
12288 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("BlockSize: %d, MailboxAddress:0x%X \n",
12289 + pDev->BlockSize, pDev->MailboxAddress));
12291 + pDev->GetPendingEventsFunc = NULL;
12292 + /* see if the HIF layer implements the get pending events function */
12293 + HIFConfigureDevice(pDev->HIFDevice,
12294 + HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
12295 + &pDev->GetPendingEventsFunc,
12296 + sizeof(pDev->GetPendingEventsFunc));
12298 + /* assume we can process HIF interrupt events asynchronously */
12299 + pDev->HifIRQProcessingMode = HIF_DEVICE_IRQ_ASYNC_SYNC;
12301 + /* see if the HIF layer overrides this assumption */
12302 + HIFConfigureDevice(pDev->HIFDevice,
12303 + HIF_DEVICE_GET_IRQ_PROC_MODE,
12304 + &pDev->HifIRQProcessingMode,
12305 + sizeof(pDev->HifIRQProcessingMode));
12307 + switch (pDev->HifIRQProcessingMode) {
12308 + case HIF_DEVICE_IRQ_SYNC_ONLY:
12309 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("HIF Interrupt processing is SYNC ONLY\n"));
12311 + case HIF_DEVICE_IRQ_ASYNC_SYNC:
12312 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("HIF Interrupt processing is ASYNC and SYNC\n"));
12315 + AR_DEBUG_ASSERT(FALSE);
12318 + pDev->HifMaskUmaskRecvEvent = NULL;
12320 + /* see if the HIF layer implements the mask/unmask recv events function */
12321 + HIFConfigureDevice(pDev->HIFDevice,
12322 + HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
12323 + &pDev->HifMaskUmaskRecvEvent,
12324 + sizeof(pDev->HifMaskUmaskRecvEvent));
12326 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("HIF special overrides : 0x%X , 0x%X\n",
12327 + (A_UINT32)pDev->GetPendingEventsFunc, (A_UINT32)pDev->HifMaskUmaskRecvEvent));
12329 + status = DevDisableInterrupts(pDev);
12333 + if (A_FAILED(status)) {
12334 + /* make sure handle is cleared */
12335 + HIFSetHandle(pDev->HIFDevice, NULL);
12342 +static A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev)
12345 + AR6K_IRQ_ENABLE_REGISTERS regs;
12349 + /* Enable all the interrupts except for the dragon interrupt */
12350 + pDev->IrqEnableRegisters.int_status_enable = INT_STATUS_ENABLE_ERROR_SET(0x01) |
12351 + INT_STATUS_ENABLE_CPU_SET(0x01) |
12352 + INT_STATUS_ENABLE_COUNTER_SET(0x01);
12354 + if (NULL == pDev->GetPendingEventsFunc) {
12355 + pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_MBOX_DATA_SET(0x01);
12357 + /* The HIF layer provided us with a pending events function which means that
12358 + * the detection of pending mbox messages is handled in the HIF layer.
12359 + * This is the case for the SPI2 interface.
12360 + * In the normal case we enable MBOX interrupts, for the case
12361 + * with HIFs that offer this mechanism, we keep these interrupts
12363 + pDev->IrqEnableRegisters.int_status_enable &= ~INT_STATUS_ENABLE_MBOX_DATA_SET(0x01);
12367 + /* Set up the CPU Interrupt Status Register */
12368 + pDev->IrqEnableRegisters.cpu_int_status_enable = CPU_INT_STATUS_ENABLE_BIT_SET(0x00);
12370 + /* Set up the Error Interrupt Status Register */
12371 + pDev->IrqEnableRegisters.error_status_enable =
12372 + ERROR_STATUS_ENABLE_RX_UNDERFLOW_SET(0x01) |
12373 + ERROR_STATUS_ENABLE_TX_OVERFLOW_SET(0x01);
12375 + /* Set up the Counter Interrupt Status Register (only for debug interrupt to catch fatal errors) */
12376 + pDev->IrqEnableRegisters.counter_int_status_enable =
12377 + COUNTER_INT_STATUS_ENABLE_BIT_SET(AR6K_TARGET_DEBUG_INTR_MASK);
12379 + /* copy into our temp area */
12380 + A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE);
12382 + UNLOCK_AR6K(pDev);
12384 + /* always synchronous */
12385 + status = HIFReadWrite(pDev->HIFDevice,
12386 + INT_STATUS_ENABLE_ADDRESS,
12387 + ®s.int_status_enable,
12388 + AR6K_IRQ_ENABLE_REGS_SIZE,
12389 + HIF_WR_SYNC_BYTE_INC,
12392 + if (status != A_OK) {
12393 + /* Can't write it for some reason */
12394 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
12395 + ("Failed to update interrupt control registers err: %d\n", status));
12402 +static A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev)
12404 + AR6K_IRQ_ENABLE_REGISTERS regs;
12407 + /* Disable all interrupts */
12408 + pDev->IrqEnableRegisters.int_status_enable = 0;
12409 + pDev->IrqEnableRegisters.cpu_int_status_enable = 0;
12410 + pDev->IrqEnableRegisters.error_status_enable = 0;
12411 + pDev->IrqEnableRegisters.counter_int_status_enable = 0;
12412 + /* copy into our temp area */
12413 + A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE);
12415 + UNLOCK_AR6K(pDev);
12417 + /* always synchronous */
12418 + return HIFReadWrite(pDev->HIFDevice,
12419 + INT_STATUS_ENABLE_ADDRESS,
12420 + ®s.int_status_enable,
12421 + AR6K_IRQ_ENABLE_REGS_SIZE,
12422 + HIF_WR_SYNC_BYTE_INC,
12426 +/* enable device interrupts */
12427 +A_STATUS DevUnmaskInterrupts(AR6K_DEVICE *pDev)
12429 + /* Unmask the host controller interrupts */
12430 + HIFUnMaskInterrupt(pDev->HIFDevice);
12432 + return DevEnableInterrupts(pDev);
12435 +/* disable all device interrupts */
12436 +A_STATUS DevMaskInterrupts(AR6K_DEVICE *pDev)
12440 + status = DevDisableInterrupts(pDev);
12442 + if (A_SUCCESS(status)) {
12443 + /* Disable the interrupt at the HIF layer */
12444 + HIFMaskInterrupt(pDev->HIFDevice);
12450 +/* callback when our fetch to enable/disable completes */
12451 +static void DevDoEnableDisableRecvAsyncHandler(void *Context, HTC_PACKET *pPacket)
12453 + AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context;
12455 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevDoEnableDisableRecvAsyncHandler: (dev: 0x%X)\n", (A_UINT32)pDev));
12457 + if (A_FAILED(pPacket->Status)) {
12458 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
12459 + (" Failed to disable receiver, status:%d \n", pPacket->Status));
12461 + /* free this IO packet */
12462 + AR6KFreeIOPacket(pDev,pPacket);
12463 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevDoEnableDisableRecvAsyncHandler \n"));
12466 +/* disable packet reception (used in case the host runs out of buffers)
12467 + * this is the "override" method when the HIF reports another methods to
12468 + * disable recv events */
12469 +static A_STATUS DevDoEnableDisableRecvOverride(AR6K_DEVICE *pDev, A_BOOL EnableRecv, A_BOOL AsyncMode)
12471 + A_STATUS status = A_OK;
12472 + HTC_PACKET *pIOPacket = NULL;
12474 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("DevDoEnableDisableRecvOverride: Enable:%d Mode:%d\n",
12475 + EnableRecv,AsyncMode));
12481 + pIOPacket = AR6KAllocIOPacket(pDev);
12483 + if (NULL == pIOPacket) {
12484 + status = A_NO_MEMORY;
12485 + AR_DEBUG_ASSERT(FALSE);
12489 + /* stick in our completion routine when the I/O operation completes */
12490 + pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler;
12491 + pIOPacket->pContext = pDev;
12493 + /* call the HIF layer override and do this asynchronously */
12494 + status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice,
12495 + EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV,
12500 + /* if we get here we are doing it synchronously */
12501 + status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice,
12502 + EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV,
12507 + if (A_FAILED(status) && (pIOPacket != NULL)) {
12508 + AR6KFreeIOPacket(pDev,pIOPacket);
12514 +/* disable packet reception (used in case the host runs out of buffers)
12515 + * this is the "normal" method using the interrupt enable registers through
12516 + * the host I/F */
12517 +static A_STATUS DevDoEnableDisableRecvNormal(AR6K_DEVICE *pDev, A_BOOL EnableRecv, A_BOOL AsyncMode)
12519 + A_STATUS status = A_OK;
12520 + HTC_PACKET *pIOPacket = NULL;
12521 + AR6K_IRQ_ENABLE_REGISTERS regs;
12523 + /* take the lock to protect interrupt enable shadows */
12526 + if (EnableRecv) {
12527 + pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_MBOX_DATA_SET(0x01);
12529 + pDev->IrqEnableRegisters.int_status_enable &= ~INT_STATUS_ENABLE_MBOX_DATA_SET(0x01);
12532 + /* copy into our temp area */
12533 + A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE);
12534 + UNLOCK_AR6K(pDev);
12540 + pIOPacket = AR6KAllocIOPacket(pDev);
12542 + if (NULL == pIOPacket) {
12543 + status = A_NO_MEMORY;
12544 + AR_DEBUG_ASSERT(FALSE);
12548 + /* copy values to write to our async I/O buffer */
12549 + A_MEMCPY(pIOPacket->pBuffer,®s,AR6K_IRQ_ENABLE_REGS_SIZE);
12551 + /* stick in our completion routine when the I/O operation completes */
12552 + pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler;
12553 + pIOPacket->pContext = pDev;
12555 + /* write it out asynchronously */
12556 + HIFReadWrite(pDev->HIFDevice,
12557 + INT_STATUS_ENABLE_ADDRESS,
12558 + pIOPacket->pBuffer,
12559 + AR6K_IRQ_ENABLE_REGS_SIZE,
12560 + HIF_WR_ASYNC_BYTE_INC,
12565 + /* if we get here we are doing it synchronously */
12567 + status = HIFReadWrite(pDev->HIFDevice,
12568 + INT_STATUS_ENABLE_ADDRESS,
12569 + ®s.int_status_enable,
12570 + AR6K_IRQ_ENABLE_REGS_SIZE,
12571 + HIF_WR_SYNC_BYTE_INC,
12576 + if (A_FAILED(status) && (pIOPacket != NULL)) {
12577 + AR6KFreeIOPacket(pDev,pIOPacket);
12584 +A_STATUS DevStopRecv(AR6K_DEVICE *pDev, A_BOOL AsyncMode)
12586 + if (NULL == pDev->HifMaskUmaskRecvEvent) {
12587 + return DevDoEnableDisableRecvNormal(pDev,FALSE,AsyncMode);
12589 + return DevDoEnableDisableRecvOverride(pDev,FALSE,AsyncMode);
12593 +A_STATUS DevEnableRecv(AR6K_DEVICE *pDev, A_BOOL AsyncMode)
12595 + if (NULL == pDev->HifMaskUmaskRecvEvent) {
12596 + return DevDoEnableDisableRecvNormal(pDev,TRUE,AsyncMode);
12598 + return DevDoEnableDisableRecvOverride(pDev,TRUE,AsyncMode);
12602 +void DevDumpRegisters(AR6K_IRQ_PROC_REGISTERS *pIrqProcRegs,
12603 + AR6K_IRQ_ENABLE_REGISTERS *pIrqEnableRegs)
12606 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP, ("\n<------- Register Table -------->\n"));
12608 + if (pIrqProcRegs != NULL) {
12609 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12610 + ("Int Status: 0x%x\n",pIrqProcRegs->host_int_status));
12611 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12612 + ("CPU Int Status: 0x%x\n",pIrqProcRegs->cpu_int_status));
12613 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12614 + ("Error Int Status: 0x%x\n",pIrqProcRegs->error_int_status));
12615 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12616 + ("Counter Int Status: 0x%x\n",pIrqProcRegs->counter_int_status));
12617 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12618 + ("Mbox Frame: 0x%x\n",pIrqProcRegs->mbox_frame));
12619 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12620 + ("Rx Lookahead Valid: 0x%x\n",pIrqProcRegs->rx_lookahead_valid));
12621 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12622 + ("Rx Lookahead 0: 0x%x\n",pIrqProcRegs->rx_lookahead[0]));
12623 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12624 + ("Rx Lookahead 1: 0x%x\n",pIrqProcRegs->rx_lookahead[1]));
12627 + if (pIrqEnableRegs != NULL) {
12628 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12629 + ("Int Status Enable: 0x%x\n",pIrqEnableRegs->int_status_enable));
12630 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP,
12631 + ("Counter Int Status Enable: 0x%x\n",pIrqEnableRegs->counter_int_status_enable));
12632 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP, ("<------------------------------->\n"));
12637 +#ifdef MBOXHW_UNIT_TEST
12640 +/* This is a mailbox hardware unit test that must be called in a schedulable context
12641 + * This test is very simple, it will send a list of buffers with a counting pattern
12642 + * and the target will invert the data and send the message back
12644 + * the unit test has the following constraints:
12646 + * The target has at least 8 buffers of 256 bytes each. The host will send
12647 + * the following pattern of buffers in rapid succession :
12649 + * 1 buffer - 128 bytes
12650 + * 1 buffer - 256 bytes
12651 + * 1 buffer - 512 bytes
12652 + * 1 buffer - 1024 bytes
12654 + * The host will send the buffers to one mailbox and wait for buffers to be reflected
12655 + * back from the same mailbox. The target sends the buffers FIFO order.
12656 + * Once the final buffer has been received for a mailbox, the next mailbox is tested.
12659 + * Note: To simplifythe test , we assume that the chosen buffer sizes
12660 + * will fall on a nice block pad
12662 + * It is expected that higher-order tests will be written to stress the mailboxes using
12663 + * a message-based protocol (with some performance timming) that can create more
12664 + * randomness in the packets sent over mailboxes.
12668 +#define A_ROUND_UP_PWR2(x, align) (((int) (x) + ((align)-1)) & ~((align)-1))
12670 +#define BUFFER_BLOCK_PAD 128
12673 +#define BUFFER1 128
12674 +#define BUFFER2 256
12675 +#define BUFFER3 512
12676 +#define BUFFER4 1024
12680 +#define BUFFER1 80
12681 +#define BUFFER2 200
12682 +#define BUFFER3 444
12683 +#define BUFFER4 800
12686 +#define TOTAL_BYTES (A_ROUND_UP_PWR2(BUFFER1,BUFFER_BLOCK_PAD) + \
12687 + A_ROUND_UP_PWR2(BUFFER2,BUFFER_BLOCK_PAD) + \
12688 + A_ROUND_UP_PWR2(BUFFER3,BUFFER_BLOCK_PAD) + \
12689 + A_ROUND_UP_PWR2(BUFFER4,BUFFER_BLOCK_PAD) )
12691 +#define TEST_BYTES (BUFFER1 + BUFFER2 + BUFFER3 + BUFFER4)
12693 +#define TEST_CREDITS_RECV_TIMEOUT 100
12695 +static A_UINT8 g_Buffer[TOTAL_BYTES];
12696 +static A_UINT32 g_MailboxAddrs[AR6K_MAILBOXES];
12697 +static A_UINT32 g_BlockSizes[AR6K_MAILBOXES];
12699 +#define BUFFER_PROC_LIST_DEPTH 4
12701 +typedef struct _BUFFER_PROC_LIST{
12702 + A_UINT8 *pBuffer;
12704 +}BUFFER_PROC_LIST;
12707 +#define PUSH_BUFF_PROC_ENTRY(pList,len,pCurrpos) \
12709 + (pList)->pBuffer = (pCurrpos); \
12710 + (pList)->length = (len); \
12711 + (pCurrpos) += (len); \
12715 +/* a simple and crude way to send different "message" sizes */
12716 +static void AssembleBufferList(BUFFER_PROC_LIST *pList)
12718 + A_UINT8 *pBuffer = g_Buffer;
12720 +#if BUFFER_PROC_LIST_DEPTH < 4
12721 +#error "Buffer processing list depth is not deep enough!!"
12724 + PUSH_BUFF_PROC_ENTRY(pList,BUFFER1,pBuffer);
12725 + PUSH_BUFF_PROC_ENTRY(pList,BUFFER2,pBuffer);
12726 + PUSH_BUFF_PROC_ENTRY(pList,BUFFER3,pBuffer);
12727 + PUSH_BUFF_PROC_ENTRY(pList,BUFFER4,pBuffer);
12731 +#define FILL_ZERO TRUE
12732 +#define FILL_COUNTING FALSE
12733 +static void InitBuffers(A_BOOL Zero)
12735 + A_UINT16 *pBuffer16 = (A_UINT16 *)g_Buffer;
12738 + /* fill buffer with 16 bit counting pattern or zeros */
12739 + for (i = 0; i < (TOTAL_BYTES / 2) ; i++) {
12741 + pBuffer16[i] = (A_UINT16)i;
12743 + pBuffer16[i] = 0;
12749 +static A_BOOL CheckOneBuffer(A_UINT16 *pBuffer16, int Length)
12752 + A_UINT16 startCount;
12753 + A_BOOL success = TRUE;
12755 + /* get the starting count */
12756 + startCount = pBuffer16[0];
12757 + /* invert it, this is the expected value */
12758 + startCount = ~startCount;
12759 + /* scan the buffer and verify */
12760 + for (i = 0; i < (Length / 2) ; i++,startCount++) {
12761 + /* target will invert all the data */
12762 + if ((A_UINT16)pBuffer16[i] != (A_UINT16)~startCount) {
12764 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Invalid Data Got:0x%X, Expecting:0x%X (offset:%d, total:%d) \n",
12765 + pBuffer16[i], ((A_UINT16)~startCount), i, Length));
12766 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("0x%X 0x%X 0x%X 0x%X \n",
12767 + pBuffer16[i], pBuffer16[i + 1], pBuffer16[i + 2],pBuffer16[i+3]));
12775 +static A_BOOL CheckBuffers(void)
12778 + A_BOOL success = TRUE;
12779 + BUFFER_PROC_LIST checkList[BUFFER_PROC_LIST_DEPTH];
12781 + /* assemble the list */
12782 + AssembleBufferList(checkList);
12784 + /* scan the buffers and verify */
12785 + for (i = 0; i < BUFFER_PROC_LIST_DEPTH ; i++) {
12786 + success = CheckOneBuffer((A_UINT16 *)checkList[i].pBuffer, checkList[i].length);
12788 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Buffer : 0x%X, Length:%d failed verify \n",
12789 + (A_UINT32)checkList[i].pBuffer, checkList[i].length));
12797 + /* find the end marker for the last buffer we will be sending */
12798 +static A_UINT16 GetEndMarker(void)
12800 + A_UINT8 *pBuffer;
12801 + BUFFER_PROC_LIST checkList[BUFFER_PROC_LIST_DEPTH];
12803 + /* fill up buffers with the normal counting pattern */
12804 + InitBuffers(FILL_COUNTING);
12806 + /* assemble the list we will be sending down */
12807 + AssembleBufferList(checkList);
12808 + /* point to the last 2 bytes of the last buffer */
12809 + pBuffer = &(checkList[BUFFER_PROC_LIST_DEPTH - 1].pBuffer[(checkList[BUFFER_PROC_LIST_DEPTH - 1].length) - 2]);
12811 + /* the last count in the last buffer is the marker */
12812 + return (A_UINT16)pBuffer[0] | ((A_UINT16)pBuffer[1] << 8);
12815 +#define ATH_PRINT_OUT_ZONE ATH_DEBUG_ERR
12817 +/* send the ordered buffers to the target */
12818 +static A_STATUS SendBuffers(AR6K_DEVICE *pDev, int mbox)
12820 + A_STATUS status = A_OK;
12821 + A_UINT32 request = HIF_WR_SYNC_BLOCK_INC;
12822 + BUFFER_PROC_LIST sendList[BUFFER_PROC_LIST_DEPTH];
12824 + int totalBytes = 0;
12825 + int paddedLength;
12826 + int totalwPadding = 0;
12828 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Sending buffers on mailbox : %d \n",mbox));
12830 + /* fill buffer with counting pattern */
12831 + InitBuffers(FILL_COUNTING);
12833 + /* assemble the order in which we send */
12834 + AssembleBufferList(sendList);
12836 + for (i = 0; i < BUFFER_PROC_LIST_DEPTH; i++) {
12838 + /* we are doing block transfers, so we need to pad everything to a block size */
12839 + paddedLength = (sendList[i].length + (g_BlockSizes[mbox] - 1)) &
12840 + (~(g_BlockSizes[mbox] - 1));
12842 + /* send each buffer synchronously */
12843 + status = HIFReadWrite(pDev->HIFDevice,
12844 + g_MailboxAddrs[mbox],
12845 + sendList[i].pBuffer,
12849 + if (status != A_OK) {
12852 + totalBytes += sendList[i].length;
12853 + totalwPadding += paddedLength;
12856 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Sent %d bytes (%d padded bytes) to mailbox : %d \n",totalBytes,totalwPadding,mbox));
12861 +/* poll the mailbox credit counter until we get a credit or timeout */
12862 +static A_STATUS GetCredits(AR6K_DEVICE *pDev, int mbox, int *pCredits)
12864 + A_STATUS status = A_OK;
12865 + int timeout = TEST_CREDITS_RECV_TIMEOUT;
12866 + A_UINT8 credits = 0;
12867 + A_UINT32 address;
12871 + /* Read the counter register to get credits, this auto-decrements */
12872 + address = COUNT_DEC_ADDRESS + (AR6K_MAILBOXES + mbox) * 4;
12873 + status = HIFReadWrite(pDev->HIFDevice, address, &credits, sizeof(credits),
12874 + HIF_RD_SYNC_BYTE_FIX, NULL);
12875 + if (status != A_OK) {
12876 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
12877 + ("Unable to decrement the command credit count register (mbox=%d)\n",mbox));
12878 + status = A_ERROR;
12888 + if (timeout <= 0) {
12889 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
12890 + (" Timeout reading credit registers (mbox=%d, address:0x%X) \n",mbox,address));
12891 + status = A_ERROR;
12895 + /* delay a little, target may not be ready */
12900 + if (status == A_OK) {
12901 + *pCredits = credits;
12908 +/* wait for the buffers to come back */
12909 +static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox)
12911 + A_STATUS status = A_OK;
12912 + A_UINT32 request = HIF_RD_SYNC_BLOCK_INC;
12913 + BUFFER_PROC_LIST recvList[BUFFER_PROC_LIST_DEPTH];
12917 + int totalBytes = 0;
12918 + int paddedLength;
12919 + int totalwPadding = 0;
12921 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Waiting for buffers on mailbox : %d \n",mbox));
12923 + /* zero the buffers */
12924 + InitBuffers(FILL_ZERO);
12926 + /* assemble the order in which we should receive */
12927 + AssembleBufferList(recvList);
12931 + while (curBuffer < BUFFER_PROC_LIST_DEPTH) {
12933 + /* get number of buffers that have been completed, this blocks
12934 + * until we get at least 1 credit or it times out */
12935 + status = GetCredits(pDev, mbox, &credits);
12937 + if (status != A_OK) {
12941 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Got %d messages on mailbox : %d \n",credits, mbox));
12943 + /* get all the buffers that are sitting on the queue */
12944 + for (i = 0; i < credits; i++) {
12945 + AR_DEBUG_ASSERT(curBuffer < BUFFER_PROC_LIST_DEPTH);
12946 + /* recv the current buffer synchronously, the buffers should come back in
12947 + * order... with padding applied by the target */
12948 + paddedLength = (recvList[curBuffer].length + (g_BlockSizes[mbox] - 1)) &
12949 + (~(g_BlockSizes[mbox] - 1));
12951 + status = HIFReadWrite(pDev->HIFDevice,
12952 + g_MailboxAddrs[mbox],
12953 + recvList[curBuffer].pBuffer,
12957 + if (status != A_OK) {
12958 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to read %d bytes on mailbox:%d : address:0x%X \n",
12959 + recvList[curBuffer].length, mbox, g_MailboxAddrs[mbox]));
12963 + totalwPadding += paddedLength;
12964 + totalBytes += recvList[curBuffer].length;
12968 + if (status != A_OK) {
12971 + /* go back and get some more */
12975 + if (totalBytes != TEST_BYTES) {
12976 + AR_DEBUG_ASSERT(FALSE);
12978 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Got all buffers on mbox:%d total recv :%d (w/Padding : %d) \n",
12979 + mbox, totalBytes, totalwPadding));
12987 +static A_STATUS DoOneMboxHWTest(AR6K_DEVICE *pDev, int mbox)
12992 + /* send out buffers */
12993 + status = SendBuffers(pDev,mbox);
12995 + if (status != A_OK) {
12996 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Sending buffers Failed : %d mbox:%d\n",status,mbox));
13000 + /* go get them, this will block */
13001 + status = RecvBuffers(pDev, mbox);
13003 + if (status != A_OK) {
13004 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Recv buffers Failed : %d mbox:%d\n",status,mbox));
13008 + /* check the returned data patterns */
13009 + if (!CheckBuffers()) {
13010 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Buffer Verify Failed : mbox:%d\n",mbox));
13011 + status = A_ERROR;
13015 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" Send/Recv success! mailbox : %d \n",mbox));
13022 +/* here is where the test starts */
13023 +A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev)
13028 + A_UINT8 params[4];
13034 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest START - \n"));
13037 + /* get the addresses for all 4 mailboxes */
13038 + status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR,
13039 + g_MailboxAddrs, sizeof(g_MailboxAddrs));
13041 + if (status != A_OK) {
13042 + AR_DEBUG_ASSERT(FALSE);
13046 + /* get the block sizes */
13047 + status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
13048 + g_BlockSizes, sizeof(g_BlockSizes));
13050 + if (status != A_OK) {
13051 + AR_DEBUG_ASSERT(FALSE);
13055 + /* note, the HIF layer usually reports mbox 0 to have a block size of
13056 + * 1, but our test wants to run in block-mode for all mailboxes, so we treat all mailboxes
13058 + g_BlockSizes[0] = g_BlockSizes[1];
13059 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Block Size to use: %d \n",g_BlockSizes[0]));
13061 + if (g_BlockSizes[1] > BUFFER_BLOCK_PAD) {
13062 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("%d Block size is too large for buffer pad %d\n",
13063 + g_BlockSizes[1], BUFFER_BLOCK_PAD));
13067 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Waiting for target.... \n"));
13069 + /* the target lets us know it is ready by giving us 1 credit on
13071 + status = GetCredits(pDev, 0, &credits);
13073 + if (status != A_OK) {
13074 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait for target ready \n"));
13078 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Target is ready ...\n"));
13080 + /* read the first 4 scratch registers */
13081 + status = HIFReadWrite(pDev->HIFDevice,
13085 + HIF_RD_SYNC_BYTE_INC,
13088 + if (status != A_OK) {
13089 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait get parameters \n"));
13093 + numBufs = params[0];
13094 + bufferSize = (int)(((A_UINT16)params[2] << 8) | (A_UINT16)params[1]);
13096 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE,
13097 + ("Target parameters: bufs per mailbox:%d, buffer size:%d bytes (total space: %d, minimum required space (w/padding): %d) \n",
13098 + numBufs, bufferSize, (numBufs * bufferSize), TOTAL_BYTES));
13100 + if ((numBufs * bufferSize) < TOTAL_BYTES) {
13101 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Not Enough buffer space to run test! need:%d, got:%d \n",
13102 + TOTAL_BYTES, (numBufs*bufferSize)));
13103 + status = A_ERROR;
13107 + temp = GetEndMarker();
13109 + status = HIFReadWrite(pDev->HIFDevice,
13110 + SCRATCH_ADDRESS + 4,
13111 + (A_UINT8 *)&temp,
13113 + HIF_WR_SYNC_BYTE_INC,
13116 + if (status != A_OK) {
13117 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write end marker \n"));
13121 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("End Marker: 0x%X \n",temp));
13123 + temp = (A_UINT16)g_BlockSizes[1];
13124 + /* convert to a mask */
13126 + status = HIFReadWrite(pDev->HIFDevice,
13127 + SCRATCH_ADDRESS + 6,
13128 + (A_UINT8 *)&temp,
13130 + HIF_WR_SYNC_BYTE_INC,
13133 + if (status != A_OK) {
13134 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write block mask \n"));
13138 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Set Block Mask: 0x%X \n",temp));
13140 + /* execute the test on each mailbox */
13141 + for (i = 0; i < AR6K_MAILBOXES; i++) {
13142 + status = DoOneMboxHWTest(pDev, i);
13143 + if (status != A_OK) {
13150 + if (status == A_OK) {
13151 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - SUCCESS! - \n"));
13153 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - FAILED! - \n"));
13155 + /* don't let HTC_Start continue, the target is actually not running any HTC code */
13162 diff --git a/drivers/sdio/function/wlan/ar6000/htc/ar6k.h b/drivers/sdio/function/wlan/ar6000/htc/ar6k.h
13163 new file mode 100644
13164 index 0000000..301ab34
13166 +++ b/drivers/sdio/function/wlan/ar6000/htc/ar6k.h
13170 + * Copyright (c) 2007 Atheros Communications Inc.
13171 + * All rights reserved.
13174 + * This program is free software; you can redistribute it and/or modify
13175 + * it under the terms of the GNU General Public License version 2 as
13176 + * published by the Free Software Foundation;
13178 + * Software distributed under the License is distributed on an "AS
13179 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13180 + * implied. See the License for the specific language governing
13181 + * rights and limitations under the License.
13190 +#define AR6K_MAILBOXES 4
13192 +/* HTC runs over mailbox 0 */
13193 +#define HTC_MAILBOX 0
13195 +#define AR6K_TARGET_DEBUG_INTR_MASK 0x01
13197 +#define OTHER_INTS_ENABLED (INT_STATUS_ENABLE_ERROR_MASK | \
13198 + INT_STATUS_ENABLE_CPU_MASK | \
13199 + INT_STATUS_ENABLE_COUNTER_MASK)
13201 +//#define MBOXHW_UNIT_TEST 1
13203 +#include "athstartpack.h"
13204 +typedef PREPACK struct _AR6K_IRQ_PROC_REGISTERS {
13205 + A_UINT8 host_int_status;
13206 + A_UINT8 cpu_int_status;
13207 + A_UINT8 error_int_status;
13208 + A_UINT8 counter_int_status;
13209 + A_UINT8 mbox_frame;
13210 + A_UINT8 rx_lookahead_valid;
13212 + A_UINT32 rx_lookahead[2];
13213 +} POSTPACK AR6K_IRQ_PROC_REGISTERS;
13215 +#define AR6K_IRQ_PROC_REGS_SIZE sizeof(AR6K_IRQ_PROC_REGISTERS)
13219 +typedef PREPACK struct _AR6K_IRQ_ENABLE_REGISTERS {
13220 + A_UINT8 int_status_enable;
13221 + A_UINT8 cpu_int_status_enable;
13222 + A_UINT8 error_status_enable;
13223 + A_UINT8 counter_int_status_enable;
13224 +} POSTPACK AR6K_IRQ_ENABLE_REGISTERS;
13226 +#include "athendpack.h"
13228 +#define AR6K_IRQ_ENABLE_REGS_SIZE sizeof(AR6K_IRQ_ENABLE_REGISTERS)
13230 +#define AR6K_REG_IO_BUFFER_SIZE 32
13231 +#define AR6K_MAX_REG_IO_BUFFERS 8
13233 +/* buffers for ASYNC I/O */
13234 +typedef struct AR6K_ASYNC_REG_IO_BUFFER {
13235 + HTC_PACKET HtcPacket; /* we use an HTC packet as a wrapper for our async register-based I/O */
13236 + A_UINT8 Buffer[AR6K_REG_IO_BUFFER_SIZE];
13237 +} AR6K_ASYNC_REG_IO_BUFFER;
13239 +typedef struct _AR6K_DEVICE {
13241 + AR6K_IRQ_PROC_REGISTERS IrqProcRegisters;
13242 + AR6K_IRQ_ENABLE_REGISTERS IrqEnableRegisters;
13244 + A_UINT32 BlockSize;
13245 + A_UINT32 BlockMask;
13246 + A_UINT32 MailboxAddress;
13247 + HIF_PENDING_EVENTS_FUNC GetPendingEventsFunc;
13248 + void *HTCContext;
13249 + HTC_PACKET_QUEUE RegisterIOList;
13250 + AR6K_ASYNC_REG_IO_BUFFER RegIOBuffers[AR6K_MAX_REG_IO_BUFFERS];
13251 + void (*TargetFailureCallback)(void *Context);
13252 + A_STATUS (*MessagePendingCallback)(void *Context, A_UINT32 LookAhead, A_BOOL *pAsyncProc);
13253 + HIF_DEVICE_IRQ_PROCESSING_MODE HifIRQProcessingMode;
13254 + HIF_MASK_UNMASK_RECV_EVENT HifMaskUmaskRecvEvent;
13257 +#define IS_DEV_IRQ_PROCESSING_ASYNC_ALLOWED(pDev) ((pDev)->HifIRQProcessingMode != HIF_DEVICE_IRQ_SYNC_ONLY)
13259 +A_STATUS DevSetup(AR6K_DEVICE *pDev);
13260 +A_STATUS DevUnmaskInterrupts(AR6K_DEVICE *pDev);
13261 +A_STATUS DevMaskInterrupts(AR6K_DEVICE *pDev);
13262 +A_STATUS DevPollMboxMsgRecv(AR6K_DEVICE *pDev,
13263 + A_UINT32 *pLookAhead,
13265 +A_STATUS DevRWCompletionHandler(void *context, A_STATUS status);
13266 +A_STATUS DevDsrHandler(void *context);
13267 +A_STATUS DevCheckPendingRecvMsgsAsync(void *context);
13268 +void DevDumpRegisters(AR6K_IRQ_PROC_REGISTERS *pIrqProcRegs,
13269 + AR6K_IRQ_ENABLE_REGISTERS *pIrqEnableRegs);
13271 +#define DEV_STOP_RECV_ASYNC TRUE
13272 +#define DEV_STOP_RECV_SYNC FALSE
13273 +#define DEV_ENABLE_RECV_ASYNC TRUE
13274 +#define DEV_ENABLE_RECV_SYNC FALSE
13275 +A_STATUS DevStopRecv(AR6K_DEVICE *pDev, A_BOOL ASyncMode);
13276 +A_STATUS DevEnableRecv(AR6K_DEVICE *pDev, A_BOOL ASyncMode);
13278 +static INLINE A_STATUS DevSendPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 SendLength) {
13279 + A_UINT32 paddedLength;
13280 + A_BOOL sync = (pPacket->Completion == NULL) ? TRUE : FALSE;
13283 + /* adjust the length to be a multiple of block size if appropriate */
13284 + paddedLength = (SendLength + (pDev->BlockMask)) &
13285 + (~(pDev->BlockMask));
13286 +#if 0 // BufferLength may not be set in , fix this...
13287 + if (paddedLength > pPacket->BufferLength) {
13288 + AR_DEBUG_ASSERT(FALSE);
13289 + if (pPacket->Completion != NULL) {
13290 + COMPLETE_HTC_PACKET(pPacket,A_EINVAL);
13295 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,
13296 + ("DevSendPacket, Padded Length: %d Mbox:0x%X (mode:%s)\n",
13298 + pDev->MailboxAddress,
13299 + sync ? "SYNC" : "ASYNC"));
13301 + status = HIFReadWrite(pDev->HIFDevice,
13302 + pDev->MailboxAddress,
13303 + pPacket->pBuffer,
13304 + paddedLength, /* the padded length */
13305 + sync ? HIF_WR_SYNC_BLOCK_INC : HIF_WR_ASYNC_BLOCK_INC,
13306 + sync ? NULL : pPacket); /* pass the packet as the context to the HIF request */
13309 + pPacket->Status = status;
13315 +static INLINE A_STATUS DevRecvPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 RecvLength) {
13316 + A_UINT32 paddedLength;
13318 + A_BOOL sync = (pPacket->Completion == NULL) ? TRUE : FALSE;
13320 + /* adjust the length to be a multiple of block size if appropriate */
13321 + paddedLength = (RecvLength + (pDev->BlockMask)) &
13322 + (~(pDev->BlockMask));
13323 + if (paddedLength > pPacket->BufferLength) {
13324 + AR_DEBUG_ASSERT(FALSE);
13325 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
13326 + ("DevRecvPacket, Not enough space for padlen:%d recvlen:%d bufferlen:%d \n",
13327 + paddedLength,RecvLength,pPacket->BufferLength));
13328 + if (pPacket->Completion != NULL) {
13329 + COMPLETE_HTC_PACKET(pPacket,A_EINVAL);
13334 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
13335 + ("DevRecvPacket, Padded Length: %d Mbox:0x%X (mode:%s)\n",
13337 + pDev->MailboxAddress,
13338 + sync ? "SYNC" : "ASYNC"));
13340 + status = HIFReadWrite(pDev->HIFDevice,
13341 + pDev->MailboxAddress,
13342 + pPacket->pBuffer,
13344 + sync ? HIF_RD_SYNC_BLOCK_INC : HIF_RD_ASYNC_BLOCK_INC,
13345 + sync ? NULL : pPacket); /* pass the packet as the context to the HIF request */
13348 + pPacket->Status = status;
13354 +#ifdef MBOXHW_UNIT_TEST
13355 +A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev);
13358 +#endif /*AR6K_H_*/
13359 diff --git a/drivers/sdio/function/wlan/ar6000/htc/ar6k_events.c b/drivers/sdio/function/wlan/ar6000/htc/ar6k_events.c
13360 new file mode 100644
13361 index 0000000..fbbcd51
13363 +++ b/drivers/sdio/function/wlan/ar6000/htc/ar6k_events.c
13366 + * AR6K Driver layer event handling (i.e. interrupts, message polling)
13368 + * Copyright (c) 2007 Atheros Communications Inc.
13369 + * All rights reserved.
13372 + * This program is free software; you can redistribute it and/or modify
13373 + * it under the terms of the GNU General Public License version 2 as
13374 + * published by the Free Software Foundation;
13376 + * Software distributed under the License is distributed on an "AS
13377 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13378 + * implied. See the License for the specific language governing
13379 + * rights and limitations under the License.
13384 +#include "a_config.h"
13385 +#include "athdefs.h"
13386 +#include "a_types.h"
13387 +#include "AR6Khwreg.h"
13388 +#include "a_osapi.h"
13389 +#include "a_debug.h"
13391 +#include "htc_packet.h"
13394 +extern void AR6KFreeIOPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket);
13395 +extern HTC_PACKET *AR6KAllocIOPacket(AR6K_DEVICE *pDev);
13397 +static A_STATUS DevServiceDebugInterrupt(AR6K_DEVICE *pDev);
13399 +#define DELAY_PER_INTERVAL_MS 10 /* 10 MS delay per polling interval */
13401 +/* completion routine for ALL HIF layer async I/O */
13402 +A_STATUS DevRWCompletionHandler(void *context, A_STATUS status)
13404 + HTC_PACKET *pPacket = (HTC_PACKET *)context;
13406 + COMPLETE_HTC_PACKET(pPacket,status);
13411 +/* mailbox recv message polling */
13412 +A_STATUS DevPollMboxMsgRecv(AR6K_DEVICE *pDev,
13413 + A_UINT32 *pLookAhead,
13416 + A_STATUS status = A_OK;
13417 + int timeout = TimeoutMS/DELAY_PER_INTERVAL_MS;
13419 + AR_DEBUG_ASSERT(timeout > 0);
13421 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+DevPollMboxMsgRecv \n"));
13425 + if (pDev->GetPendingEventsFunc != NULL)
13428 + HIF_PENDING_EVENTS_INFO events;
13430 + /* the HIF layer uses a special mechanism to get events, do this
13431 + * synchronously */
13432 + status = pDev->GetPendingEventsFunc(pDev->HIFDevice,
13435 + if (A_FAILED(status))
13437 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to get pending events \n"));
13441 + if (events.Events & HIF_RECV_MSG_AVAIL)
13443 + /* there is a message available, the lookahead should be valid now */
13444 + *pLookAhead = events.LookAhead;
13452 + /* this is the standard HIF way.... */
13453 + /* load the register table */
13454 + status = HIFReadWrite(pDev->HIFDevice,
13455 + HOST_INT_STATUS_ADDRESS,
13456 + (A_UINT8 *)&pDev->IrqProcRegisters,
13457 + AR6K_IRQ_PROC_REGS_SIZE,
13458 + HIF_RD_SYNC_BYTE_INC,
13461 + if (A_FAILED(status))
13463 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to read register table \n"));
13467 + /* check for MBOX data and valid lookahead */
13468 + if (pDev->IrqProcRegisters.host_int_status & (1 << HTC_MAILBOX))
13470 + if (pDev->IrqProcRegisters.rx_lookahead_valid & (1 << HTC_MAILBOX))
13472 + /* mailbox has a message and the look ahead is valid */
13473 + *pLookAhead = pDev->IrqProcRegisters.rx_lookahead[HTC_MAILBOX];
13482 + if (timeout <= 0)
13484 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" Timeout waiting for recv message \n"));
13485 + status = A_ERROR;
13487 + /* check if the target asserted */
13488 + if ( pDev->IrqProcRegisters.counter_int_status & AR6K_TARGET_DEBUG_INTR_MASK) {
13489 + /* target signaled an assert, process this pending interrupt
13490 + * this will call the target failure handler */
13491 + DevServiceDebugInterrupt(pDev);
13497 + /* delay a little */
13498 + A_MDELAY(DELAY_PER_INTERVAL_MS);
13499 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" Retry Mbox Poll : %d \n",timeout));
13502 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-DevPollMboxMsgRecv \n"));
13507 +static A_STATUS DevServiceCPUInterrupt(AR6K_DEVICE *pDev)
13510 + A_UINT8 cpu_int_status;
13511 + A_UINT8 regBuffer[4];
13513 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("CPU Interrupt\n"));
13514 + cpu_int_status = pDev->IrqProcRegisters.cpu_int_status &
13515 + pDev->IrqEnableRegisters.cpu_int_status_enable;
13516 + AR_DEBUG_ASSERT(cpu_int_status);
13517 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,
13518 + ("Valid interrupt source(s) in CPU_INT_STATUS: 0x%x\n",
13519 + cpu_int_status));
13521 + /* Clear the interrupt */
13522 + pDev->IrqProcRegisters.cpu_int_status &= ~cpu_int_status; /* W1C */
13524 + /* set up the register transfer buffer to hit the register 4 times , this is done
13525 + * to make the access 4-byte aligned to mitigate issues with host bus interconnects that
13526 + * restrict bus transfer lengths to be a multiple of 4-bytes */
13528 + /* set W1C value to clear the interrupt, this hits the register first */
13529 + regBuffer[0] = cpu_int_status;
13530 + /* the remaining 4 values are set to zero which have no-effect */
13531 + regBuffer[1] = 0;
13532 + regBuffer[2] = 0;
13533 + regBuffer[3] = 0;
13535 + status = HIFReadWrite(pDev->HIFDevice,
13536 + CPU_INT_STATUS_ADDRESS,
13539 + HIF_WR_SYNC_BYTE_FIX,
13542 + AR_DEBUG_ASSERT(status == A_OK);
13547 +static A_STATUS DevServiceErrorInterrupt(AR6K_DEVICE *pDev)
13550 + A_UINT8 error_int_status;
13551 + A_UINT8 regBuffer[4];
13553 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Error Interrupt\n"));
13554 + error_int_status = pDev->IrqProcRegisters.error_int_status & 0x0F;
13555 + AR_DEBUG_ASSERT(error_int_status);
13556 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,
13557 + ("Valid interrupt source(s) in ERROR_INT_STATUS: 0x%x\n",
13558 + error_int_status));
13560 + if (ERROR_INT_STATUS_WAKEUP_GET(error_int_status)) {
13562 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Error : Wakeup\n"));
13565 + if (ERROR_INT_STATUS_RX_UNDERFLOW_GET(error_int_status)) {
13566 + /* Rx Underflow */
13567 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Error : Rx Underflow\n"));
13570 + if (ERROR_INT_STATUS_TX_OVERFLOW_GET(error_int_status)) {
13571 + /* Tx Overflow */
13572 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Error : Tx Overflow\n"));
13575 + /* Clear the interrupt */
13576 + pDev->IrqProcRegisters.error_int_status &= ~error_int_status; /* W1C */
13578 + /* set up the register transfer buffer to hit the register 4 times , this is done
13579 + * to make the access 4-byte aligned to mitigate issues with host bus interconnects that
13580 + * restrict bus transfer lengths to be a multiple of 4-bytes */
13582 + /* set W1C value to clear the interrupt, this hits the register first */
13583 + regBuffer[0] = error_int_status;
13584 + /* the remaining 4 values are set to zero which have no-effect */
13585 + regBuffer[1] = 0;
13586 + regBuffer[2] = 0;
13587 + regBuffer[3] = 0;
13589 + status = HIFReadWrite(pDev->HIFDevice,
13590 + ERROR_INT_STATUS_ADDRESS,
13593 + HIF_WR_SYNC_BYTE_FIX,
13596 + AR_DEBUG_ASSERT(status == A_OK);
13600 +static A_STATUS DevServiceDebugInterrupt(AR6K_DEVICE *pDev)
13605 + /* Send a target failure event to the application */
13606 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Target debug interrupt\n"));
13608 + if (pDev->TargetFailureCallback != NULL) {
13609 + pDev->TargetFailureCallback(pDev->HTCContext);
13612 + /* clear the interrupt , the debug error interrupt is
13614 + /* read counter to clear interrupt */
13615 + status = HIFReadWrite(pDev->HIFDevice,
13616 + COUNT_DEC_ADDRESS,
13617 + (A_UINT8 *)&dummy,
13619 + HIF_RD_SYNC_BYTE_INC,
13622 + AR_DEBUG_ASSERT(status == A_OK);
13626 +static A_STATUS DevServiceCounterInterrupt(AR6K_DEVICE *pDev)
13628 + A_UINT8 counter_int_status;
13630 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Counter Interrupt\n"));
13632 + counter_int_status = pDev->IrqProcRegisters.counter_int_status &
13633 + pDev->IrqEnableRegisters.counter_int_status_enable;
13635 + AR_DEBUG_ASSERT(counter_int_status);
13636 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,
13637 + ("Valid interrupt source(s) in COUNTER_INT_STATUS: 0x%x\n",
13638 + counter_int_status));
13640 + /* Check if the debug interrupt is pending */
13641 + if (counter_int_status & AR6K_TARGET_DEBUG_INTR_MASK) {
13642 + return DevServiceDebugInterrupt(pDev);
13648 +/* callback when our fetch to get interrupt status registers completes */
13649 +static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket)
13651 + AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context;
13652 + A_UINT32 lookAhead = 0;
13653 + A_BOOL otherInts = FALSE;
13655 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevGetEventAsyncHandler: (dev: 0x%X)\n", (A_UINT32)pDev));
13659 + if (A_FAILED(pPacket->Status)) {
13660 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
13661 + (" GetEvents I/O request failed, status:%d \n", pPacket->Status));
13662 + /* bail out, don't unmask HIF interrupt */
13666 + if (pDev->GetPendingEventsFunc != NULL) {
13667 + /* the HIF layer collected the information for us */
13668 + HIF_PENDING_EVENTS_INFO *pEvents = (HIF_PENDING_EVENTS_INFO *)pPacket->pBuffer;
13669 + if (pEvents->Events & HIF_RECV_MSG_AVAIL) {
13670 + lookAhead = pEvents->LookAhead;
13671 + if (0 == lookAhead) {
13672 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" DevGetEventAsyncHandler1, lookAhead is zero! \n"));
13675 + if (pEvents->Events & HIF_OTHER_EVENTS) {
13676 + otherInts = TRUE;
13679 + /* standard interrupt table handling.... */
13680 + AR6K_IRQ_PROC_REGISTERS *pReg = (AR6K_IRQ_PROC_REGISTERS *)pPacket->pBuffer;
13681 + A_UINT8 host_int_status;
13683 + host_int_status = pReg->host_int_status & pDev->IrqEnableRegisters.int_status_enable;
13685 + if (host_int_status & (1 << HTC_MAILBOX)) {
13686 + host_int_status &= ~(1 << HTC_MAILBOX);
13687 + if (pReg->rx_lookahead_valid & (1 << HTC_MAILBOX)) {
13688 + /* mailbox has a message and the look ahead is valid */
13689 + lookAhead = pReg->rx_lookahead[HTC_MAILBOX];
13690 + if (0 == lookAhead) {
13691 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" DevGetEventAsyncHandler2, lookAhead is zero! \n"));
13696 + if (host_int_status) {
13697 + /* there are other interrupts to handle */
13698 + otherInts = TRUE;
13702 + if (otherInts || (lookAhead == 0)) {
13703 + /* if there are other interrupts to process, we cannot do this in the async handler so
13704 + * ack the interrupt which will cause our sync handler to run again
13705 + * if however there are no more messages, we can now ack the interrupt */
13706 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,
13707 + (" Acking interrupt from DevGetEventAsyncHandler (otherints:%d, lookahead:0x%X)\n",
13708 + otherInts, lookAhead));
13709 + HIFAckInterrupt(pDev->HIFDevice);
13711 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,
13712 + (" DevGetEventAsyncHandler : detected another message, lookahead :0x%X \n",
13714 + /* lookahead is non-zero and there are no other interrupts to service,
13715 + * go get the next message */
13716 + pDev->MessagePendingCallback(pDev->HTCContext, lookAhead, NULL);
13721 + /* free this IO packet */
13722 + AR6KFreeIOPacket(pDev,pPacket);
13723 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevGetEventAsyncHandler \n"));
13726 +/* called by the HTC layer when it wants us to check if the device has any more pending
13727 + * recv messages, this starts off a series of async requests to read interrupt registers */
13728 +A_STATUS DevCheckPendingRecvMsgsAsync(void *context)
13730 + AR6K_DEVICE *pDev = (AR6K_DEVICE *)context;
13731 + A_STATUS status = A_OK;
13732 + HTC_PACKET *pIOPacket;
13734 + /* this is called in an ASYNC only context, we may NOT block, sleep or call any apis that can
13735 + * cause us to switch contexts */
13737 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevCheckPendingRecvMsgsAsync: (dev: 0x%X)\n", (A_UINT32)pDev));
13741 + if (HIF_DEVICE_IRQ_SYNC_ONLY == pDev->HifIRQProcessingMode) {
13742 + /* break the async processing chain right here, no need to continue.
13743 + * The DevDsrHandler() will handle things in a loop when things are driven
13744 + * synchronously */
13747 + /* first allocate one of our HTC packets we created for async I/O
13748 + * we reuse HTC packet definitions so that we can use the completion mechanism
13749 + * in DevRWCompletionHandler() */
13750 + pIOPacket = AR6KAllocIOPacket(pDev);
13752 + if (NULL == pIOPacket) {
13753 + /* there should be only 1 asynchronous request out at a time to read these registers
13754 + * so this should actually never happen */
13755 + status = A_NO_MEMORY;
13756 + AR_DEBUG_ASSERT(FALSE);
13760 + /* stick in our completion routine when the I/O operation completes */
13761 + pIOPacket->Completion = DevGetEventAsyncHandler;
13762 + pIOPacket->pContext = pDev;
13764 + if (pDev->GetPendingEventsFunc) {
13765 + /* HIF layer has it's own mechanism, pass the IO to it.. */
13766 + status = pDev->GetPendingEventsFunc(pDev->HIFDevice,
13767 + (HIF_PENDING_EVENTS_INFO *)pIOPacket->pBuffer,
13771 + /* standard way, read the interrupt register table asynchronously again */
13772 + status = HIFReadWrite(pDev->HIFDevice,
13773 + HOST_INT_STATUS_ADDRESS,
13774 + pIOPacket->pBuffer,
13775 + AR6K_IRQ_PROC_REGS_SIZE,
13776 + HIF_RD_ASYNC_BYTE_INC,
13780 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,(" Async IO issued to get interrupt status...\n"));
13783 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevCheckPendingRecvMsgsAsync \n"));
13788 +/* process pending interrupts synchronously */
13789 +static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pASyncProcessing)
13791 + A_STATUS status = A_OK;
13792 + A_UINT8 host_int_status = 0;
13793 + A_UINT32 lookAhead = 0;
13795 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+ProcessPendingIRQs: (dev: 0x%X)\n", (A_UINT32)pDev));
13797 + /*** NOTE: the HIF implementation guarantees that the context of this call allows
13798 + * us to perform SYNCHRONOUS I/O, that is we can block, sleep or call any API that
13799 + * can block or switch thread/task ontexts.
13800 + * This is a fully schedulable context.
13804 + if (pDev->GetPendingEventsFunc != NULL) {
13805 + HIF_PENDING_EVENTS_INFO events;
13807 + /* the HIF layer uses a special mechanism to get events
13808 + * get this synchronously */
13809 + status = pDev->GetPendingEventsFunc(pDev->HIFDevice,
13813 + if (A_FAILED(status)) {
13817 + if (events.Events & HIF_RECV_MSG_AVAIL) {
13818 + lookAhead = events.LookAhead;
13819 + if (0 == lookAhead) {
13820 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" ProcessPendingIRQs1 lookAhead is zero! \n"));
13824 + if (!(events.Events & HIF_OTHER_EVENTS) ||
13825 + !(pDev->IrqEnableRegisters.int_status_enable & OTHER_INTS_ENABLED)) {
13826 + /* no need to read the register table, no other interesting interrupts.
13827 + * Some interfaces (like SPI) can shadow interrupt sources without
13828 + * requiring the host to do a full table read */
13832 + /* otherwise fall through and read the register table */
13836 + * Read the first 28 bytes of the HTC register table. This will yield us
13837 + * the value of different int status registers and the lookahead
13839 + * length = sizeof(int_status) + sizeof(cpu_int_status) +
13840 + * sizeof(error_int_status) + sizeof(counter_int_status) +
13841 + * sizeof(mbox_frame) + sizeof(rx_lookahead_valid) +
13842 + * sizeof(hole) + sizeof(rx_lookahead) +
13843 + * sizeof(int_status_enable) + sizeof(cpu_int_status_enable) +
13844 + * sizeof(error_status_enable) +
13845 + * sizeof(counter_int_status_enable);
13848 + status = HIFReadWrite(pDev->HIFDevice,
13849 + HOST_INT_STATUS_ADDRESS,
13850 + (A_UINT8 *)&pDev->IrqProcRegisters,
13851 + AR6K_IRQ_PROC_REGS_SIZE,
13852 + HIF_RD_SYNC_BYTE_INC,
13855 + if (A_FAILED(status)) {
13859 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_IRQ)) {
13860 + DevDumpRegisters(&pDev->IrqProcRegisters,
13861 + &pDev->IrqEnableRegisters);
13864 + /* Update only those registers that are enabled */
13865 + host_int_status = pDev->IrqProcRegisters.host_int_status &
13866 + pDev->IrqEnableRegisters.int_status_enable;
13868 + if (NULL == pDev->GetPendingEventsFunc) {
13869 + /* only look at mailbox status if the HIF layer did not provide this function,
13870 + * on some HIF interfaces reading the RX lookahead is not valid to do */
13871 + if (host_int_status & (1 << HTC_MAILBOX)) {
13872 + /* mask out pending mailbox value, we use "lookAhead" as the real flag for
13873 + * mailbox processing below */
13874 + host_int_status &= ~(1 << HTC_MAILBOX);
13875 + if (pDev->IrqProcRegisters.rx_lookahead_valid & (1 << HTC_MAILBOX)) {
13876 + /* mailbox has a message and the look ahead is valid */
13877 + lookAhead = pDev->IrqProcRegisters.rx_lookahead[HTC_MAILBOX];
13878 + if (0 == lookAhead) {
13879 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" ProcessPendingIRQs2, lookAhead is zero! \n"));
13884 + /* not valid to check if the HIF has another mechanism for reading mailbox pending status*/
13885 + host_int_status &= ~(1 << HTC_MAILBOX);
13893 + /* did the interrupt status fetches succeed? */
13894 + if (A_FAILED(status)) {
13898 + if ((0 == host_int_status) && (0 == lookAhead)) {
13899 + /* nothing to process, the caller can use this to break out of a loop */
13904 + if (lookAhead != 0) {
13905 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("Pending mailbox message, LookAhead: 0x%X\n",lookAhead));
13906 + /* Mailbox Interrupt, the HTC layer may issue async requests to empty the
13908 + * When emptying the recv mailbox we use the async handler above called from the
13909 + * completion routine of the callers read request. This can improve performance
13910 + * by reducing context switching when we rapidly pull packets */
13911 + status = pDev->MessagePendingCallback(pDev->HTCContext, lookAhead, pASyncProcessing);
13912 + if (A_FAILED(status)) {
13917 + /* now handle the rest of them */
13918 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,
13919 + (" Valid interrupt source(s) for OTHER interrupts: 0x%x\n",
13920 + host_int_status));
13922 + if (HOST_INT_STATUS_CPU_GET(host_int_status)) {
13923 + /* CPU Interrupt */
13924 + status = DevServiceCPUInterrupt(pDev);
13925 + if (A_FAILED(status)){
13930 + if (HOST_INT_STATUS_ERROR_GET(host_int_status)) {
13931 + /* Error Interrupt */
13932 + status = DevServiceErrorInterrupt(pDev);
13933 + if (A_FAILED(status)){
13938 + if (HOST_INT_STATUS_COUNTER_GET(host_int_status)) {
13939 + /* Counter Interrupt */
13940 + status = DevServiceCounterInterrupt(pDev);
13941 + if (A_FAILED(status)){
13948 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-ProcessPendingIRQs: (done:%d, async:%d) status=%d \n",
13949 + *pDone, *pASyncProcessing, status));
13955 +/* Synchronousinterrupt handler, this handler kicks off all interrupt processing.*/
13956 +A_STATUS DevDsrHandler(void *context)
13958 + AR6K_DEVICE *pDev = (AR6K_DEVICE *)context;
13959 + A_STATUS status = A_OK;
13960 + A_BOOL done = FALSE;
13961 + A_BOOL asyncProc = FALSE;
13963 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevDsrHandler: (dev: 0x%X)\n", (A_UINT32)pDev));
13967 + status = ProcessPendingIRQs(pDev, &done, &asyncProc);
13968 + if (A_FAILED(status)) {
13972 + if (HIF_DEVICE_IRQ_SYNC_ONLY == pDev->HifIRQProcessingMode) {
13973 + /* the HIF layer does not allow async IRQ processing, override the asyncProc flag */
13974 + asyncProc = FALSE;
13975 + /* this will cause us to re-enter ProcessPendingIRQ() and re-read interrupt status registers.
13976 + * this has a nice side effect of blocking us until all async read requests are completed.
13977 + * This behavior is required on some HIF implementations that do not allow ASYNC
13978 + * processing in interrupt handlers (like Windows CE) */
13982 + /* the function performed some async I/O for performance, we
13983 + need to exit the ISR immediately, the check below will prevent the interrupt from being
13984 + Ack'd while we handle it asynchronously */
13990 + if (A_SUCCESS(status) && !asyncProc) {
13991 + /* Ack the interrupt only if :
13992 + * 1. we did not get any errors in processing interrupts
13993 + * 2. there are no outstanding async processing requests */
13994 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,(" Acking interrupt from DevDsrHandler \n"));
13995 + HIFAckInterrupt(pDev->HIFDevice);
13998 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevDsrHandler \n"));
14003 diff --git a/drivers/sdio/function/wlan/ar6000/htc/htc.c b/drivers/sdio/function/wlan/ar6000/htc/htc.c
14004 new file mode 100644
14005 index 0000000..b5e691b
14007 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc.c
14011 + * Copyright (c) 2007 Atheros Communications Inc.
14012 + * All rights reserved.
14015 + * This program is free software; you can redistribute it and/or modify
14016 + * it under the terms of the GNU General Public License version 2 as
14017 + * published by the Free Software Foundation;
14019 + * Software distributed under the License is distributed on an "AS
14020 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14021 + * implied. See the License for the specific language governing
14022 + * rights and limitations under the License.
14028 +#include "htc_internal.h"
14031 +static HTC_INIT_INFO HTCInitInfo = {NULL,NULL,NULL};
14032 +static A_BOOL HTCInitialized = FALSE;
14034 +static A_STATUS HTCTargetInsertedHandler(void *hif_handle);
14035 +static A_STATUS HTCTargetRemovedHandler(void *handle, A_STATUS status);
14036 +static void HTCReportFailure(void *Context);
14038 +/* Initializes the HTC layer */
14039 +A_STATUS HTCInit(HTC_INIT_INFO *pInitInfo)
14041 + HTC_CALLBACKS htcCallbacks;
14043 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Enter\n"));
14044 + if (HTCInitialized) {
14045 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Exit\n"));
14049 + A_MEMCPY(&HTCInitInfo,pInitInfo,sizeof(HTC_INIT_INFO));
14051 + A_MEMZERO(&htcCallbacks, sizeof(HTC_CALLBACKS));
14053 + /* setup HIF layer callbacks */
14054 + htcCallbacks.deviceInsertedHandler = HTCTargetInsertedHandler;
14055 + htcCallbacks.deviceRemovedHandler = HTCTargetRemovedHandler;
14056 + /* the device layer handles these */
14057 + htcCallbacks.rwCompletionHandler = DevRWCompletionHandler;
14058 + htcCallbacks.dsrHandler = DevDsrHandler;
14059 + HIFInit(&htcCallbacks);
14060 + HTCInitialized = TRUE;
14062 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Exit\n"));
14066 +void HTCFreeControlBuffer(HTC_TARGET *target, HTC_PACKET *pPacket, HTC_PACKET_QUEUE *pList)
14068 + LOCK_HTC(target);
14069 + HTC_PACKET_ENQUEUE(pList,pPacket);
14070 + UNLOCK_HTC(target);
14073 +HTC_PACKET *HTCAllocControlBuffer(HTC_TARGET *target, HTC_PACKET_QUEUE *pList)
14075 + HTC_PACKET *pPacket;
14077 + LOCK_HTC(target);
14078 + pPacket = HTC_PACKET_DEQUEUE(pList);
14079 + UNLOCK_HTC(target);
14084 +/* cleanup the HTC instance */
14085 +static void HTCCleanup(HTC_TARGET *target)
14087 + if (A_IS_MUTEX_VALID(&target->HTCLock)) {
14088 + A_MUTEX_DELETE(&target->HTCLock);
14091 + if (A_IS_MUTEX_VALID(&target->HTCRxLock)) {
14092 + A_MUTEX_DELETE(&target->HTCRxLock);
14095 + if (A_IS_MUTEX_VALID(&target->HTCTxLock)) {
14096 + A_MUTEX_DELETE(&target->HTCTxLock);
14098 + /* free our instance */
14102 +/* registered target arrival callback from the HIF layer */
14103 +static A_STATUS HTCTargetInsertedHandler(void *hif_handle)
14105 + HTC_TARGET *target = NULL;
14109 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("htcTargetInserted - Enter\n"));
14113 + /* allocate target memory */
14114 + if ((target = (HTC_TARGET *)A_MALLOC(sizeof(HTC_TARGET))) == NULL) {
14115 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to allocate memory\n"));
14116 + status = A_ERROR;
14120 + A_MEMZERO(target, sizeof(HTC_TARGET));
14121 + A_MUTEX_INIT(&target->HTCLock);
14122 + A_MUTEX_INIT(&target->HTCRxLock);
14123 + A_MUTEX_INIT(&target->HTCTxLock);
14124 + INIT_HTC_PACKET_QUEUE(&target->ControlBufferTXFreeList);
14125 + INIT_HTC_PACKET_QUEUE(&target->ControlBufferRXFreeList);
14127 + /* give device layer the hif device handle */
14128 + target->Device.HIFDevice = hif_handle;
14129 + /* give the device layer our context (for event processing)
14130 + * the device layer will register it's own context with HIF
14131 + * so we need to set this so we can fetch it in the target remove handler */
14132 + target->Device.HTCContext = target;
14133 + /* set device layer target failure callback */
14134 + target->Device.TargetFailureCallback = HTCReportFailure;
14135 + /* set device layer recv message pending callback */
14136 + target->Device.MessagePendingCallback = HTCRecvMessagePendingHandler;
14137 + target->EpWaitingForBuffers = ENDPOINT_MAX;
14139 + /* setup device layer */
14140 + status = DevSetup(&target->Device);
14142 + if (A_FAILED(status)) {
14146 + /* carve up buffers/packets for control messages */
14147 + for (i = 0; i < NUM_CONTROL_RX_BUFFERS; i++) {
14148 + HTC_PACKET *pControlPacket;
14149 + pControlPacket = &target->HTCControlBuffers[i].HtcPacket;
14150 + SET_HTC_PACKET_INFO_RX_REFILL(pControlPacket,
14152 + target->HTCControlBuffers[i].Buffer,
14153 + HTC_CONTROL_BUFFER_SIZE,
14155 + HTC_FREE_CONTROL_RX(target,pControlPacket);
14158 + for (;i < NUM_CONTROL_BUFFERS;i++) {
14159 + HTC_PACKET *pControlPacket;
14160 + pControlPacket = &target->HTCControlBuffers[i].HtcPacket;
14161 + INIT_HTC_PACKET_INFO(pControlPacket,
14162 + target->HTCControlBuffers[i].Buffer,
14163 + HTC_CONTROL_BUFFER_SIZE);
14164 + HTC_FREE_CONTROL_TX(target,pControlPacket);
14169 + if (A_SUCCESS(status)) {
14170 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, (" calling AddInstance callback \n"));
14171 + /* announce ourselves */
14172 + HTCInitInfo.AddInstance((HTC_HANDLE)target);
14174 + if (target != NULL) {
14175 + HTCCleanup(target);
14179 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("htcTargetInserted - Exit\n"));
14184 +/* registered removal callback from the HIF layer */
14185 +static A_STATUS HTCTargetRemovedHandler(void *handle, A_STATUS status)
14187 + HTC_TARGET *target;
14189 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCTargetRemovedHandler handle:0x%X \n",(A_UINT32)handle));
14191 + if (NULL == handle) {
14192 + /* this could be NULL in the event that target initialization failed */
14196 + target = ((AR6K_DEVICE *)handle)->HTCContext;
14198 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, (" removing target:0x%X instance:0x%X ... \n",
14199 + (A_UINT32)target, (A_UINT32)target->pInstanceContext));
14201 + if (target->pInstanceContext != NULL) {
14202 + /* let upper layer know, it needs to call HTCStop() */
14203 + HTCInitInfo.DeleteInstance(target->pInstanceContext);
14206 + HIFShutDownDevice(target->Device.HIFDevice);
14208 + HTCCleanup(target);
14209 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCTargetRemovedHandler \n"));
14213 +/* get the low level HIF device for the caller , the caller may wish to do low level
14214 + * HIF requests */
14215 +void *HTCGetHifDevice(HTC_HANDLE HTCHandle)
14217 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14218 + return target->Device.HIFDevice;
14221 +/* set the instance block for this HTC handle, so that on removal, the blob can be
14222 + * returned to the caller */
14223 +void HTCSetInstance(HTC_HANDLE HTCHandle, void *Instance)
14225 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14227 + target->pInstanceContext = Instance;
14230 +/* wait for the target to arrive (sends HTC Ready message)
14231 + * this operation is fully synchronous and the message is polled for */
14232 +A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle)
14234 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14236 + HTC_PACKET *pPacket = NULL;
14237 + HTC_READY_MSG *pRdyMsg;
14238 + HTC_SERVICE_CONNECT_REQ connect;
14239 + HTC_SERVICE_CONNECT_RESP resp;
14241 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Enter (target:0x%X) \n", (A_UINT32)target));
14245 +#ifdef MBOXHW_UNIT_TEST
14247 + status = DoMboxHWTest(&target->Device);
14249 + if (status != A_OK) {
14255 + /* we should be getting 1 control message that the target is ready */
14256 + status = HTCWaitforControlMessage(target, &pPacket);
14258 + if (A_FAILED(status)) {
14259 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" Target Not Available!!\n"));
14263 + /* we controlled the buffer creation so it has to be properly aligned */
14264 + pRdyMsg = (HTC_READY_MSG *)pPacket->pBuffer;
14266 + if ((pRdyMsg->MessageID != HTC_MSG_READY_ID) ||
14267 + (pPacket->ActualLength < sizeof(HTC_READY_MSG))) {
14268 + /* this message is not valid */
14269 + AR_DEBUG_ASSERT(FALSE);
14270 + status = A_EPROTO;
14274 + if (pRdyMsg->CreditCount == 0 || pRdyMsg->CreditSize == 0) {
14275 + /* this message is not valid */
14276 + AR_DEBUG_ASSERT(FALSE);
14277 + status = A_EPROTO;
14281 + target->TargetCredits = pRdyMsg->CreditCount;
14282 + target->TargetCreditSize = pRdyMsg->CreditSize;
14284 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, (" Target Ready: credits: %d credit size: %d\n",
14285 + target->TargetCredits, target->TargetCreditSize));
14287 + /* setup our pseudo HTC control endpoint connection */
14288 + A_MEMZERO(&connect,sizeof(connect));
14289 + A_MEMZERO(&resp,sizeof(resp));
14290 + connect.EpCallbacks.pContext = target;
14291 + connect.EpCallbacks.EpTxComplete = HTCControlTxComplete;
14292 + connect.EpCallbacks.EpRecv = HTCControlRecv;
14293 + connect.EpCallbacks.EpRecvRefill = NULL; /* not needed */
14294 + connect.EpCallbacks.EpSendFull = NULL; /* not nedded */
14295 + connect.MaxSendQueueDepth = NUM_CONTROL_BUFFERS;
14296 + connect.ServiceID = HTC_CTRL_RSVD_SVC;
14298 + /* connect fake service */
14299 + status = HTCConnectService((HTC_HANDLE)target,
14303 + if (!A_FAILED(status)) {
14309 + if (pPacket != NULL) {
14310 + HTC_FREE_CONTROL_RX(target,pPacket);
14313 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Exit\n"));
14320 +/* Start HTC, enable interrupts and let the target know host has finished setup */
14321 +A_STATUS HTCStart(HTC_HANDLE HTCHandle)
14323 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14324 + HTC_PACKET *pPacket;
14327 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Enter\n"));
14329 + /* now that we are starting, push control receive buffers into the
14330 + * HTC control endpoint */
14333 + pPacket = HTC_ALLOC_CONTROL_RX(target);
14334 + if (NULL == pPacket) {
14337 + HTCAddReceivePkt((HTC_HANDLE)target,pPacket);
14342 + AR_DEBUG_ASSERT(target->InitCredits != NULL);
14343 + AR_DEBUG_ASSERT(target->EpCreditDistributionListHead != NULL);
14344 + AR_DEBUG_ASSERT(target->EpCreditDistributionListHead->pNext != NULL);
14346 + /* call init credits callback to do the distribution ,
14347 + * NOTE: the first entry in the distribution list is ENDPOINT_0, so
14348 + * we pass the start of the list after this one. */
14349 + target->InitCredits(target->pCredDistContext,
14350 + target->EpCreditDistributionListHead->pNext,
14351 + target->TargetCredits);
14353 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_TRC)) {
14354 + DumpCreditDistStates(target);
14357 + /* the caller is done connecting to services, so we can indicate to the
14358 + * target that the setup phase is complete */
14359 + status = HTCSendSetupComplete(target);
14361 + if (A_FAILED(status)) {
14365 + /* unmask interrupts */
14366 + status = DevUnmaskInterrupts(&target->Device);
14368 + if (A_FAILED(status)) {
14374 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Exit\n"));
14379 +/* stop HTC communications, i.e. stop interrupt reception, and flush all queued buffers */
14380 +void HTCStop(HTC_HANDLE HTCHandle)
14382 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14383 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCStop \n"));
14385 + /* mark that we are shutting down .. */
14386 + target->HTCStateFlags |= HTC_STATE_STOPPING;
14388 + /* Masking interrupts is a synchronous operation, when this function returns
14389 + * all pending HIF I/O has completed, we can safely flush the queues */
14390 + DevMaskInterrupts(&target->Device);
14392 + /* flush all send packets */
14393 + HTCFlushSendPkts(target);
14394 + /* flush all recv buffers */
14395 + HTCFlushRecvBuffers(target);
14397 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCStop \n"));
14400 +/* undo what was done in HTCInit() */
14401 +void HTCShutDown(void)
14403 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCShutDown: \n"));
14404 + HTCInitialized = FALSE;
14405 + /* undo HTCInit */
14406 + HIFShutDownDevice(NULL);
14407 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCShutDown: \n"));
14410 +void HTCDumpCreditStates(HTC_HANDLE HTCHandle)
14412 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14414 + LOCK_HTC_TX(target);
14416 + DumpCreditDistStates(target);
14418 + UNLOCK_HTC_TX(target);
14421 +/* report a target failure from the device, this is a callback from the device layer
14422 + * which uses a mechanism to report errors from the target (i.e. special interrupts) */
14423 +static void HTCReportFailure(void *Context)
14425 + HTC_TARGET *target = (HTC_TARGET *)Context;
14427 + target->TargetFailure = TRUE;
14429 + if ((target->pInstanceContext != NULL) && (HTCInitInfo.TargetFailure != NULL)) {
14430 + /* let upper layer know, it needs to call HTCStop() */
14431 + HTCInitInfo.TargetFailure(target->pInstanceContext, A_ERROR);
14435 +void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescription)
14437 + A_CHAR stream[60];
14439 + A_UINT16 offset, count;
14441 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("<---------Dumping %d Bytes : %s ------>\n", length, pDescription));
14445 + for(i = 0; i < length; i++) {
14446 + sprintf(stream + offset, "%2.2X ", buffer[i]);
14450 + if(count == 16) {
14453 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("[H]: %s\n", stream));
14454 + A_MEMZERO(stream, 60);
14458 + if(offset != 0) {
14459 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("[H]: %s\n", stream));
14462 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("<------------------------------------------------->\n"));
14465 +A_BOOL HTCGetEndpointStatistics(HTC_HANDLE HTCHandle,
14466 + HTC_ENDPOINT_ID Endpoint,
14467 + HTC_ENDPOINT_STAT_ACTION Action,
14468 + HTC_ENDPOINT_STATS *pStats)
14471 +#ifdef HTC_EP_STAT_PROFILING
14472 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14473 + A_BOOL clearStats = FALSE;
14474 + A_BOOL sample = FALSE;
14476 + switch (Action) {
14477 + case HTC_EP_STAT_SAMPLE :
14480 + case HTC_EP_STAT_SAMPLE_AND_CLEAR :
14482 + clearStats = TRUE;
14484 + case HTC_EP_STAT_CLEAR :
14485 + clearStats = TRUE;
14491 + A_ASSERT(Endpoint < ENDPOINT_MAX);
14493 + /* lock out TX and RX while we sample and/or clear */
14494 + LOCK_HTC_TX(target);
14495 + LOCK_HTC_RX(target);
14498 + A_ASSERT(pStats != NULL);
14499 + /* return the stats to the caller */
14500 + A_MEMCPY(pStats, &target->EndPoint[Endpoint].EndPointStats, sizeof(HTC_ENDPOINT_STATS));
14503 + if (clearStats) {
14504 + /* reset stats */
14505 + A_MEMZERO(&target->EndPoint[Endpoint].EndPointStats, sizeof(HTC_ENDPOINT_STATS));
14508 + UNLOCK_HTC_RX(target);
14509 + UNLOCK_HTC_TX(target);
14516 diff --git a/drivers/sdio/function/wlan/ar6000/htc/htc_debug.h b/drivers/sdio/function/wlan/ar6000/htc/htc_debug.h
14517 new file mode 100644
14518 index 0000000..08080be
14520 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_debug.h
14522 +#ifndef HTC_DEBUG_H_
14523 +#define HTC_DEBUG_H_
14526 + * Copyright (c) 2004-2007 Atheros Communications Inc.
14527 + * All rights reserved.
14530 + * This program is free software; you can redistribute it and/or modify
14531 + * it under the terms of the GNU General Public License version 2 as
14532 + * published by the Free Software Foundation;
14534 + * Software distributed under the License is distributed on an "AS
14535 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14536 + * implied. See the License for the specific language governing
14537 + * rights and limitations under the License.
14543 +/* ------- Debug related stuff ------- */
14545 + ATH_DEBUG_SEND = 0x0001,
14546 + ATH_DEBUG_RECV = 0x0002,
14547 + ATH_DEBUG_SYNC = 0x0004,
14548 + ATH_DEBUG_DUMP = 0x0008,
14549 + ATH_DEBUG_IRQ = 0x0010,
14550 + ATH_DEBUG_TRC = 0x0020,
14551 + ATH_DEBUG_WARN = 0x0040,
14552 + ATH_DEBUG_ERR = 0x0080,
14553 + ATH_DEBUG_ANY = 0xFFFF,
14558 +// TODO FIX usage of A_PRINTF!
14559 +#define AR_DEBUG_LVL_CHECK(lvl) (debughtc & (lvl))
14560 +#define AR_DEBUG_PRINTBUF(buffer, length, desc) do { \
14561 + if (debughtc & ATH_DEBUG_DUMP) { \
14562 + DebugDumpBytes(buffer, length,desc); \
14565 +#define PRINTX_ARG(arg...) arg
14566 +#define AR_DEBUG_PRINTF(flags, args) do { \
14567 + if (debughtc & (flags)) { \
14568 + A_PRINTF(KERN_ALERT PRINTX_ARG args); \
14571 +#define AR_DEBUG_ASSERT(test) do { \
14573 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Debug Assert Caught, File %s, Line: %d, Test:%s \n",__FILE__, __LINE__,#test)); \
14576 +extern int debughtc;
14578 +#define AR_DEBUG_PRINTF(flags, args)
14579 +#define AR_DEBUG_PRINTBUF(buffer, length, desc)
14580 +#define AR_DEBUG_ASSERT(test)
14581 +#define AR_DEBUG_LVL_CHECK(lvl) 0
14584 +void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescription);
14586 +#endif /*HTC_DEBUG_H_*/
14587 diff --git a/drivers/sdio/function/wlan/ar6000/htc/htc_internal.h b/drivers/sdio/function/wlan/ar6000/htc/htc_internal.h
14588 new file mode 100644
14589 index 0000000..ebb8ac1
14591 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_internal.h
14595 + * Copyright (c) 2007 Atheros Communications Inc.
14596 + * All rights reserved.
14599 + * This program is free software; you can redistribute it and/or modify
14600 + * it under the terms of the GNU General Public License version 2 as
14601 + * published by the Free Software Foundation;
14603 + * Software distributed under the License is distributed on an "AS
14604 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14605 + * implied. See the License for the specific language governing
14606 + * rights and limitations under the License.
14612 +#ifndef _HTC_INTERNAL_H_
14613 +#define _HTC_INTERNAL_H_
14615 +/* for debugging, uncomment this to capture the last frame header, on frame header
14616 + * processing errors, the last frame header is dump for comparison */
14617 +//#define HTC_CAPTURE_LAST_FRAME
14619 +//#define HTC_EP_STAT_PROFILING
14621 +#ifdef __cplusplus
14623 +#endif /* __cplusplus */
14625 +/* Header files */
14626 +#include "a_config.h"
14627 +#include "athdefs.h"
14628 +#include "a_types.h"
14629 +#include "a_osapi.h"
14630 +#include "a_debug.h"
14632 +#include "htc_api.h"
14633 +#include "bmi_msg.h"
14637 +/* HTC operational parameters */
14638 +#define HTC_TARGET_RESPONSE_TIMEOUT 2000 /* in ms */
14639 +#define HTC_TARGET_DEBUG_INTR_MASK 0x01
14640 +#define HTC_TARGET_CREDIT_INTR_MASK 0xF0
14642 +typedef struct _HTC_ENDPOINT {
14643 + HTC_SERVICE_ID ServiceID; /* service ID this endpoint is bound to
14644 + non-zero value means this endpoint is in use */
14645 + HTC_PACKET_QUEUE TxQueue; /* HTC frame buffer TX queue */
14646 + HTC_PACKET_QUEUE RxBuffers; /* HTC frame buffer RX list */
14647 + HTC_ENDPOINT_CREDIT_DIST CreditDist; /* credit distribution structure (exposed to driver layer) */
14648 + HTC_EP_CALLBACKS EpCallBacks; /* callbacks associated with this endpoint */
14649 + int MaxTxQueueDepth; /* max depth of the TX queue before we need to
14650 + call driver's full handler */
14651 + int CurrentTxQueueDepth; /* current TX queue depth */
14652 + int MaxMsgLength; /* max length of endpoint message */
14653 +#ifdef HTC_EP_STAT_PROFILING
14654 + HTC_ENDPOINT_STATS EndPointStats; /* endpoint statistics */
14658 +#ifdef HTC_EP_STAT_PROFILING
14659 +#define INC_HTC_EP_STAT(p,stat,count) (p)->EndPointStats.stat += (count);
14661 +#define INC_HTC_EP_STAT(p,stat,count)
14664 +#define HTC_SERVICE_TX_PACKET_TAG HTC_TX_PACKET_TAG_INTERNAL
14666 +#define NUM_CONTROL_BUFFERS 8
14667 +#define NUM_CONTROL_TX_BUFFERS 2
14668 +#define NUM_CONTROL_RX_BUFFERS (NUM_CONTROL_BUFFERS - NUM_CONTROL_TX_BUFFERS)
14670 +#define HTC_CONTROL_BUFFER_SIZE (HTC_MAX_CONTROL_MESSAGE_LENGTH + HTC_HDR_LENGTH)
14672 +typedef struct HTC_CONTROL_BUFFER {
14673 + HTC_PACKET HtcPacket;
14674 + A_UINT8 Buffer[HTC_CONTROL_BUFFER_SIZE];
14675 +} HTC_CONTROL_BUFFER;
14677 +/* our HTC target state */
14678 +typedef struct _HTC_TARGET {
14679 + HTC_ENDPOINT EndPoint[ENDPOINT_MAX];
14680 + HTC_CONTROL_BUFFER HTCControlBuffers[NUM_CONTROL_BUFFERS];
14681 + HTC_ENDPOINT_CREDIT_DIST *EpCreditDistributionListHead;
14682 + HTC_PACKET_QUEUE ControlBufferTXFreeList;
14683 + HTC_PACKET_QUEUE ControlBufferRXFreeList;
14684 + HTC_CREDIT_DIST_CALLBACK DistributeCredits;
14685 + HTC_CREDIT_INIT_CALLBACK InitCredits;
14686 + void *pCredDistContext;
14687 + int TargetCredits;
14688 + int TargetCreditSize;
14689 + A_MUTEX_T HTCLock;
14690 + A_MUTEX_T HTCRxLock;
14691 + A_MUTEX_T HTCTxLock;
14692 + AR6K_DEVICE Device; /* AR6K - specific state */
14693 + A_UINT32 HTCStateFlags;
14694 + HTC_ENDPOINT_ID EpWaitingForBuffers;
14695 + A_BOOL TargetFailure;
14696 + void *pInstanceContext;
14697 +#define HTC_STATE_WAIT_BUFFERS (1 << 0)
14698 +#define HTC_STATE_STOPPING (1 << 1)
14699 +#ifdef HTC_CAPTURE_LAST_FRAME
14700 + HTC_FRAME_HDR LastFrameHdr; /* useful for debugging */
14701 + A_UINT8 LastTrailer[256];
14702 + A_UINT8 LastTrailerLength;
14706 +#define HTC_STOPPING(t) ((t)->HTCStateFlags & HTC_STATE_STOPPING)
14707 +#define LOCK_HTC(t) A_MUTEX_LOCK(&(t)->HTCLock);
14708 +#define UNLOCK_HTC(t) A_MUTEX_UNLOCK(&(t)->HTCLock);
14709 +#define LOCK_HTC_RX(t) A_MUTEX_LOCK(&(t)->HTCRxLock);
14710 +#define UNLOCK_HTC_RX(t) A_MUTEX_UNLOCK(&(t)->HTCRxLock);
14711 +#define LOCK_HTC_TX(t) A_MUTEX_LOCK(&(t)->HTCTxLock);
14712 +#define UNLOCK_HTC_TX(t) A_MUTEX_UNLOCK(&(t)->HTCTxLock);
14714 +#define GET_HTC_TARGET_FROM_HANDLE(hnd) ((HTC_TARGET *)(hnd))
14715 +#define HTC_RECYCLE_RX_PKT(target,p) \
14717 + HTC_PACKET_RESET_RX(pPacket); \
14718 + HTCAddReceivePkt((HTC_HANDLE)(target),(p)); \
14721 +/* internal HTC functions */
14722 +void HTCControlTxComplete(void *Context, HTC_PACKET *pPacket);
14723 +void HTCControlRecv(void *Context, HTC_PACKET *pPacket);
14724 +A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPacket);
14725 +HTC_PACKET *HTCAllocControlBuffer(HTC_TARGET *target, HTC_PACKET_QUEUE *pList);
14726 +void HTCFreeControlBuffer(HTC_TARGET *target, HTC_PACKET *pPacket, HTC_PACKET_QUEUE *pList);
14727 +A_STATUS HTCIssueSend(HTC_TARGET *target, HTC_PACKET *pPacket, A_UINT8 Flags);
14728 +A_STATUS HTCIssueRecv(HTC_TARGET *target, HTC_PACKET *pPacket);
14729 +void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket);
14730 +A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 LookAhead, A_BOOL *pAsyncProc);
14731 +void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint);
14732 +A_STATUS HTCSendSetupComplete(HTC_TARGET *target);
14733 +void HTCFlushRecvBuffers(HTC_TARGET *target);
14734 +void HTCFlushSendPkts(HTC_TARGET *target);
14735 +void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist);
14736 +void DumpCreditDistStates(HTC_TARGET *target);
14737 +void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescription);
14739 +static INLINE HTC_PACKET *HTC_ALLOC_CONTROL_TX(HTC_TARGET *target) {
14740 + HTC_PACKET *pPacket = HTCAllocControlBuffer(target,&target->ControlBufferTXFreeList);
14741 + if (pPacket != NULL) {
14742 + /* set payload pointer area with some headroom */
14743 + pPacket->pBuffer = pPacket->pBufferStart + HTC_HDR_LENGTH;
14748 +#define HTC_FREE_CONTROL_TX(t,p) HTCFreeControlBuffer((t),(p),&(t)->ControlBufferTXFreeList)
14749 +#define HTC_ALLOC_CONTROL_RX(t) HTCAllocControlBuffer((t),&(t)->ControlBufferRXFreeList)
14750 +#define HTC_FREE_CONTROL_RX(t,p) \
14752 + HTC_PACKET_RESET_RX(p); \
14753 + HTCFreeControlBuffer((t),(p),&(t)->ControlBufferRXFreeList); \
14756 +#ifdef __cplusplus
14760 +#endif /* _HTC_INTERNAL_H_ */
14761 diff --git a/drivers/sdio/function/wlan/ar6000/htc/htc_recv.c b/drivers/sdio/function/wlan/ar6000/htc/htc_recv.c
14762 new file mode 100644
14763 index 0000000..4be2b08
14765 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_recv.c
14769 + * Copyright (c) 2007 Atheros Communications Inc.
14770 + * All rights reserved.
14773 + * This program is free software; you can redistribute it and/or modify
14774 + * it under the terms of the GNU General Public License version 2 as
14775 + * published by the Free Software Foundation;
14777 + * Software distributed under the License is distributed on an "AS
14778 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14779 + * implied. See the License for the specific language governing
14780 + * rights and limitations under the License.
14786 +#include "htc_internal.h"
14788 +#define HTCIssueRecv(t, p) \
14789 + DevRecvPacket(&(t)->Device, \
14791 + (p)->ActualLength)
14793 +#define DO_RCV_COMPLETION(t,p,e) \
14795 + if ((p)->ActualLength > 0) { \
14796 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" completing packet 0x%X (%d bytes) on ep : %d \n", \
14797 + (A_UINT32)(p), (p)->ActualLength, (p)->Endpoint)); \
14798 + (e)->EpCallBacks.EpRecv((e)->EpCallBacks.pContext, \
14801 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" recycling empty packet \n")); \
14802 + HTC_RECYCLE_RX_PKT((t), (p)); \
14806 +#ifdef HTC_EP_STAT_PROFILING
14807 +#define HTC_RX_STAT_PROFILE(t,ep,lookAhead) \
14809 + LOCK_HTC_RX((t)); \
14810 + INC_HTC_EP_STAT((ep), RxReceived, 1); \
14811 + if ((lookAhead) != 0) { \
14812 + INC_HTC_EP_STAT((ep), RxLookAheads, 1); \
14814 + UNLOCK_HTC_RX((t)); \
14817 +#define HTC_RX_STAT_PROFILE(t,ep,lookAhead)
14820 +static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target,
14821 + A_UINT8 *pBuffer,
14823 + A_UINT32 *pNextLookAhead,
14824 + HTC_ENDPOINT_ID FromEndpoint)
14826 + HTC_RECORD_HDR *pRecord;
14827 + A_UINT8 *pRecordBuf;
14828 + HTC_LOOKAHEAD_REPORT *pLookAhead;
14829 + A_UINT8 *pOrigBuffer;
14833 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCProcessTrailer (length:%d) \n", Length));
14835 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) {
14836 + AR_DEBUG_PRINTBUF(pBuffer,Length,"Recv Trailer");
14839 + pOrigBuffer = pBuffer;
14840 + origLength = Length;
14843 + while (Length > 0) {
14845 + if (Length < sizeof(HTC_RECORD_HDR)) {
14846 + status = A_EPROTO;
14849 + /* these are byte aligned structs */
14850 + pRecord = (HTC_RECORD_HDR *)pBuffer;
14851 + Length -= sizeof(HTC_RECORD_HDR);
14852 + pBuffer += sizeof(HTC_RECORD_HDR);
14854 + if (pRecord->Length > Length) {
14855 + /* no room left in buffer for record */
14856 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
14857 + (" invalid record length: %d (id:%d) buffer has: %d bytes left \n",
14858 + pRecord->Length, pRecord->RecordID, Length));
14859 + status = A_EPROTO;
14862 + /* start of record follows the header */
14863 + pRecordBuf = pBuffer;
14865 + switch (pRecord->RecordID) {
14866 + case HTC_RECORD_CREDITS:
14867 + AR_DEBUG_ASSERT(pRecord->Length >= sizeof(HTC_CREDIT_REPORT));
14868 + HTCProcessCreditRpt(target,
14869 + (HTC_CREDIT_REPORT *)pRecordBuf,
14870 + pRecord->Length / (sizeof(HTC_CREDIT_REPORT)),
14873 + case HTC_RECORD_LOOKAHEAD:
14874 + AR_DEBUG_ASSERT(pRecord->Length >= sizeof(HTC_LOOKAHEAD_REPORT));
14875 + pLookAhead = (HTC_LOOKAHEAD_REPORT *)pRecordBuf;
14876 + if ((pLookAhead->PreValid == ((~pLookAhead->PostValid) & 0xFF)) &&
14877 + (pNextLookAhead != NULL)) {
14879 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
14880 + (" LookAhead Report Found (pre valid:0x%X, post valid:0x%X) \n",
14881 + pLookAhead->PreValid,
14882 + pLookAhead->PostValid));
14884 + /* look ahead bytes are valid, copy them over */
14885 + ((A_UINT8 *)pNextLookAhead)[0] = pLookAhead->LookAhead[0];
14886 + ((A_UINT8 *)pNextLookAhead)[1] = pLookAhead->LookAhead[1];
14887 + ((A_UINT8 *)pNextLookAhead)[2] = pLookAhead->LookAhead[2];
14888 + ((A_UINT8 *)pNextLookAhead)[3] = pLookAhead->LookAhead[3];
14890 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) {
14891 + DebugDumpBytes((A_UINT8 *)pNextLookAhead,4,"Next Look Ahead");
14896 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" unhandled record: id:%d length:%d \n",
14897 + pRecord->RecordID, pRecord->Length));
14901 + if (A_FAILED(status)) {
14905 + /* advance buffer past this record for next time around */
14906 + pBuffer += pRecord->Length;
14907 + Length -= pRecord->Length;
14910 + if (A_FAILED(status)) {
14911 + DebugDumpBytes(pOrigBuffer,origLength,"BAD Recv Trailer");
14914 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCProcessTrailer \n"));
14919 +/* process a received message (i.e. strip off header, process any trailer data)
14920 + * note : locks must be released when this function is called */
14921 +static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, HTC_PACKET *pPacket, A_UINT32 *pNextLookAhead)
14925 + A_STATUS status = A_OK;
14926 + A_UINT16 payloadLen;
14927 + A_UINT32 lookAhead;
14929 + pBuf = pPacket->pBuffer;
14931 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCProcessRecvHeader \n"));
14933 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) {
14934 + AR_DEBUG_PRINTBUF(pBuf,pPacket->ActualLength,"HTC Recv PKT");
14938 + /* note, we cannot assume the alignment of pBuffer, so we use the safe macros to
14939 + * retrieve 16 bit fields */
14940 + payloadLen = A_GET_UINT16_FIELD(pBuf, HTC_FRAME_HDR, PayloadLen);
14942 + ((A_UINT8 *)&lookAhead)[0] = pBuf[0];
14943 + ((A_UINT8 *)&lookAhead)[1] = pBuf[1];
14944 + ((A_UINT8 *)&lookAhead)[2] = pBuf[2];
14945 + ((A_UINT8 *)&lookAhead)[3] = pBuf[3];
14947 + if (lookAhead != pPacket->HTCReserved) {
14948 + /* somehow the lookahead that gave us the full read length did not
14949 + * reflect the actual header in the pending message */
14950 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
14951 + ("HTCProcessRecvHeader, lookahead mismatch! \n"));
14952 + DebugDumpBytes((A_UINT8 *)&pPacket->HTCReserved,4,"Expected Message LookAhead");
14953 + DebugDumpBytes(pBuf,sizeof(HTC_FRAME_HDR),"Current Frame Header");
14954 +#ifdef HTC_CAPTURE_LAST_FRAME
14955 + DebugDumpBytes((A_UINT8 *)&target->LastFrameHdr,sizeof(HTC_FRAME_HDR),"Last Frame Header");
14956 + if (target->LastTrailerLength != 0) {
14957 + DebugDumpBytes(target->LastTrailer,
14958 + target->LastTrailerLength,
14962 + status = A_EPROTO;
14967 + temp = A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, Flags);
14969 + if (temp & HTC_FLAGS_RECV_TRAILER) {
14970 + /* this packet has a trailer */
14972 + /* extract the trailer length in control byte 0 */
14973 + temp = A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, ControlBytes[0]);
14975 + if ((temp < sizeof(HTC_RECORD_HDR)) || (temp > payloadLen)) {
14976 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
14977 + ("HTCProcessRecvHeader, invalid header (payloadlength should be :%d, CB[0] is:%d) \n",
14978 + payloadLen, temp));
14979 + status = A_EPROTO;
14983 + /* process trailer data that follows HDR + application payload */
14984 + status = HTCProcessTrailer(target,
14985 + (pBuf + HTC_HDR_LENGTH + payloadLen - temp),
14988 + pPacket->Endpoint);
14990 + if (A_FAILED(status)) {
14994 +#ifdef HTC_CAPTURE_LAST_FRAME
14995 + A_MEMCPY(target->LastTrailer, (pBuf + HTC_HDR_LENGTH + payloadLen - temp), temp);
14996 + target->LastTrailerLength = temp;
14998 + /* trim length by trailer bytes */
14999 + pPacket->ActualLength -= temp;
15001 +#ifdef HTC_CAPTURE_LAST_FRAME
15003 + target->LastTrailerLength = 0;
15007 + /* if we get to this point, the packet is good */
15008 + /* remove header and adjust length */
15009 + pPacket->pBuffer += HTC_HDR_LENGTH;
15010 + pPacket->ActualLength -= HTC_HDR_LENGTH;
15014 + if (A_FAILED(status)) {
15015 + /* dump the whole packet */
15016 + DebugDumpBytes(pBuf,pPacket->ActualLength,"BAD HTC Recv PKT");
15018 +#ifdef HTC_CAPTURE_LAST_FRAME
15019 + A_MEMCPY(&target->LastFrameHdr,pBuf,sizeof(HTC_FRAME_HDR));
15021 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) {
15022 + if (pPacket->ActualLength > 0) {
15023 + AR_DEBUG_PRINTBUF(pPacket->pBuffer,pPacket->ActualLength,"HTC - Application Msg");
15028 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCProcessRecvHeader \n"));
15032 +/* asynchronous completion handler for recv packet fetching, when the device layer
15033 + * completes a read request, it will call this completion handler */
15034 +void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket)
15036 + HTC_TARGET *target = (HTC_TARGET *)Context;
15037 + HTC_ENDPOINT *pEndpoint;
15038 + A_UINT32 nextLookAhead = 0;
15041 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCRecvCompleteHandler (status:%d, ep:%d) \n",
15042 + pPacket->Status, pPacket->Endpoint));
15044 + AR_DEBUG_ASSERT(pPacket->Endpoint < ENDPOINT_MAX);
15045 + pEndpoint = &target->EndPoint[pPacket->Endpoint];
15046 + pPacket->Completion = NULL;
15048 + /* get completion status */
15049 + status = pPacket->Status;
15052 + if (A_FAILED(status)) {
15053 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTCRecvCompleteHandler: request failed (status:%d, ep:%d) \n",
15054 + pPacket->Status, pPacket->Endpoint));
15057 + /* process the header for any trailer data */
15058 + status = HTCProcessRecvHeader(target,pPacket,&nextLookAhead);
15060 + if (A_FAILED(status)) {
15063 + /* was there a lookahead for the next packet? */
15064 + if (nextLookAhead != 0) {
15065 + A_STATUS nextStatus;
15066 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
15067 + ("HTCRecvCompleteHandler - next look ahead was non-zero : 0x%X \n",
15069 + /* we have another packet, get the next packet fetch started (pipelined) before
15070 + * we call into the endpoint's callback, this will start another async request */
15071 + nextStatus = HTCRecvMessagePendingHandler(target,nextLookAhead,NULL);
15072 + if (A_EPROTO == nextStatus) {
15073 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15074 + ("Next look ahead from recv header was INVALID\n"));
15075 + DebugDumpBytes((A_UINT8 *)&nextLookAhead,
15077 + "BAD lookahead from lookahead report");
15080 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
15081 + ("HTCRecvCompleteHandler - rechecking for more messages...\n"));
15082 + /* if we did not get anything on the look-ahead,
15083 + * call device layer to asynchronously re-check for messages. If we can keep the async
15084 + * processing going we get better performance. If there is a pending message we will keep processing
15085 + * messages asynchronously which should pipeline things nicely */
15086 + DevCheckPendingRecvMsgsAsync(&target->Device);
15089 + HTC_RX_STAT_PROFILE(target,pEndpoint,nextLookAhead);
15090 + DO_RCV_COMPLETION(target,pPacket,pEndpoint);
15094 + if (A_FAILED(status)) {
15095 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15096 + ("HTCRecvCompleteHandler , message fetch failed (status = %d) \n",
15098 + /* recyle this packet */
15099 + HTC_RECYCLE_RX_PKT(target, pPacket);
15102 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCRecvCompleteHandler\n"));
15105 +/* synchronously wait for a control message from the target,
15106 + * This function is used at initialization time ONLY. At init messages
15107 + * on ENDPOINT 0 are expected. */
15108 +A_STATUS HTCWaitforControlMessage(HTC_TARGET *target, HTC_PACKET **ppControlPacket)
15111 + A_UINT32 lookAhead;
15112 + HTC_PACKET *pPacket = NULL;
15113 + HTC_FRAME_HDR *pHdr;
15115 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCWaitforControlMessage \n"));
15119 + *ppControlPacket = NULL;
15121 + /* call the polling function to see if we have a message */
15122 + status = DevPollMboxMsgRecv(&target->Device,
15124 + HTC_TARGET_RESPONSE_TIMEOUT);
15126 + if (A_FAILED(status)) {
15130 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
15131 + ("HTCWaitforControlMessage : lookAhead : 0x%X \n", lookAhead));
15133 + /* check the lookahead */
15134 + pHdr = (HTC_FRAME_HDR *)&lookAhead;
15136 + if (pHdr->EndpointID != ENDPOINT_0) {
15137 + /* unexpected endpoint number, should be zero */
15138 + AR_DEBUG_ASSERT(FALSE);
15139 + status = A_EPROTO;
15143 + if (A_FAILED(status)) {
15144 + /* bad message */
15145 + AR_DEBUG_ASSERT(FALSE);
15146 + status = A_EPROTO;
15150 + pPacket = HTC_ALLOC_CONTROL_RX(target);
15152 + if (pPacket == NULL) {
15153 + AR_DEBUG_ASSERT(FALSE);
15154 + status = A_NO_MEMORY;
15158 + pPacket->HTCReserved = lookAhead;
15159 + pPacket->ActualLength = pHdr->PayloadLen + HTC_HDR_LENGTH;
15161 + if (pPacket->ActualLength > pPacket->BufferLength) {
15162 + AR_DEBUG_ASSERT(FALSE);
15163 + status = A_EPROTO;
15167 + /* we want synchronous operation */
15168 + pPacket->Completion = NULL;
15170 + /* get the message from the device, this will block */
15171 + status = HTCIssueRecv(target, pPacket);
15173 + if (A_FAILED(status)) {
15177 + /* process receive header */
15178 + status = HTCProcessRecvHeader(target,pPacket,NULL);
15180 + pPacket->Status = status;
15182 + if (A_FAILED(status)) {
15183 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15184 + ("HTCWaitforControlMessage, HTCProcessRecvHeader failed (status = %d) \n",
15189 + /* give the caller this control message packet, they are responsible to free */
15190 + *ppControlPacket = pPacket;
15194 + if (A_FAILED(status)) {
15195 + if (pPacket != NULL) {
15196 + /* cleanup buffer on error */
15197 + HTC_FREE_CONTROL_RX(target,pPacket);
15201 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCWaitforControlMessage \n"));
15206 +/* callback when device layer or lookahead report parsing detects a pending message */
15207 +A_STATUS HTCRecvMessagePendingHandler(void *Context, A_UINT32 LookAhead, A_BOOL *pAsyncProc)
15209 + HTC_TARGET *target = (HTC_TARGET *)Context;
15210 + A_STATUS status = A_OK;
15211 + HTC_PACKET *pPacket = NULL;
15212 + HTC_FRAME_HDR *pHdr;
15213 + HTC_ENDPOINT *pEndpoint;
15214 + A_BOOL asyncProc = FALSE;
15216 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCRecvMessagePendingHandler LookAhead:0x%X \n",LookAhead));
15218 + if (IS_DEV_IRQ_PROCESSING_ASYNC_ALLOWED(&target->Device)) {
15219 + /* We use async mode to get the packets if the device layer supports it.
15220 + * The device layer interfaces with HIF in which HIF may have restrictions on
15221 + * how interrupts are processed */
15222 + asyncProc = TRUE;
15225 + if (pAsyncProc != NULL) {
15226 + /* indicate to caller how we decided to process this */
15227 + *pAsyncProc = asyncProc;
15232 + pHdr = (HTC_FRAME_HDR *)&LookAhead;
15234 + if (pHdr->EndpointID >= ENDPOINT_MAX) {
15235 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Invalid Endpoint in look-ahead: %d \n",pHdr->EndpointID));
15236 + /* invalid endpoint */
15237 + status = A_EPROTO;
15241 + if (pHdr->PayloadLen > HTC_MAX_PAYLOAD_LENGTH) {
15242 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Payload length %d exceeds max HTC : %d !\n",
15243 + pHdr->PayloadLen, HTC_MAX_PAYLOAD_LENGTH));
15244 + status = A_EPROTO;
15248 + pEndpoint = &target->EndPoint[pHdr->EndpointID];
15250 + if (0 == pEndpoint->ServiceID) {
15251 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Endpoint %d is not connected !\n",pHdr->EndpointID));
15252 + /* endpoint isn't even connected */
15253 + status = A_EPROTO;
15257 + /* lock RX to get a buffer */
15258 + LOCK_HTC_RX(target);
15260 + /* get a packet from the endpoint recv queue */
15261 + pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->RxBuffers);
15263 + if (NULL == pPacket) {
15264 + /* check for refill handler */
15265 + if (pEndpoint->EpCallBacks.EpRecvRefill != NULL) {
15266 + UNLOCK_HTC_RX(target);
15267 + /* call the re-fill handler */
15268 + pEndpoint->EpCallBacks.EpRecvRefill(pEndpoint->EpCallBacks.pContext,
15269 + pHdr->EndpointID);
15270 + LOCK_HTC_RX(target);
15271 + /* check if we have more buffers */
15272 + pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->RxBuffers);
15273 + /* fall through */
15277 + if (NULL == pPacket) {
15278 + /* this is not an error, we simply need to mark that we are waiting for buffers.*/
15279 + target->HTCStateFlags |= HTC_STATE_WAIT_BUFFERS;
15280 + target->EpWaitingForBuffers = pHdr->EndpointID;
15281 + status = A_NO_MEMORY;
15284 + UNLOCK_HTC_RX(target);
15286 + if (A_FAILED(status)) {
15291 + AR_DEBUG_ASSERT(pPacket->Endpoint == pHdr->EndpointID);
15293 + /* make sure this message can fit in the endpoint buffer */
15294 + if ((pHdr->PayloadLen + HTC_HDR_LENGTH) > pPacket->BufferLength) {
15295 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15296 + ("Payload Length Error : header reports payload of: %d, endpoint buffer size: %d \n",
15297 + pHdr->PayloadLen, pPacket->BufferLength));
15298 + status = A_EPROTO;
15302 + pPacket->HTCReserved = LookAhead; /* set expected look ahead */
15303 + /* set the amount of data to fetch */
15304 + pPacket->ActualLength = pHdr->PayloadLen + HTC_HDR_LENGTH;
15307 + /* we use async mode to get the packet if the device layer supports it
15308 + * set our callback and context */
15309 + pPacket->Completion = HTCRecvCompleteHandler;
15310 + pPacket->pContext = target;
15312 + /* fully synchronous */
15313 + pPacket->Completion = NULL;
15316 + /* go fetch the packet */
15317 + status = HTCIssueRecv(target, pPacket);
15319 + if (A_FAILED(status)) {
15324 + /* we did this asynchronously so we can get out of the loop, the asynch processing
15325 + * creates a chain of requests to continue processing pending messages in the
15326 + * context of callbacks */
15330 + /* in the sync case, we process the packet, check lookaheads and then repeat */
15333 + status = HTCProcessRecvHeader(target,pPacket,&LookAhead);
15335 + if (A_FAILED(status)) {
15339 + HTC_RX_STAT_PROFILE(target,pEndpoint,LookAhead);
15340 + DO_RCV_COMPLETION(target,pPacket,pEndpoint);
15344 + if (0 == LookAhead) {
15350 + if (A_NO_MEMORY == status) {
15351 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15352 + (" Endpoint :%d has no buffers, blocking receiver to prevent overrun.. \n",
15353 + pHdr->EndpointID));
15354 + /* try to stop receive at the device layer */
15355 + DevStopRecv(&target->Device, asyncProc ? DEV_STOP_RECV_ASYNC : DEV_STOP_RECV_SYNC);
15357 + } else if (A_FAILED(status)) {
15358 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15359 + ("Failed to get pending message : LookAhead Value: 0x%X (status = %d) \n",
15360 + LookAhead, status));
15361 + if (pPacket != NULL) {
15362 + /* clean up packet on error */
15363 + HTC_RECYCLE_RX_PKT(target, pPacket);
15367 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCRecvMessagePendingHandler \n"));
15372 +/* Makes a buffer available to the HTC module */
15373 +A_STATUS HTCAddReceivePkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket)
15375 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
15376 + HTC_ENDPOINT *pEndpoint;
15377 + A_BOOL unblockRecv = FALSE;
15378 + A_STATUS status = A_OK;
15380 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,
15381 + ("+- HTCAddReceivePkt: endPointId: %d, buffer: 0x%X, length: %d\n",
15382 + pPacket->Endpoint, (A_UINT32)pPacket->pBuffer, pPacket->BufferLength));
15386 + if (HTC_STOPPING(target)) {
15387 + status = A_ECANCELED;
15391 + AR_DEBUG_ASSERT(pPacket->Endpoint < ENDPOINT_MAX);
15393 + pEndpoint = &target->EndPoint[pPacket->Endpoint];
15395 + LOCK_HTC_RX(target);
15397 + /* store receive packet */
15398 + HTC_PACKET_ENQUEUE(&pEndpoint->RxBuffers, pPacket);
15400 + /* check if we are blocked waiting for a new buffer */
15401 + if (target->HTCStateFlags & HTC_STATE_WAIT_BUFFERS) {
15402 + if (target->EpWaitingForBuffers == pPacket->Endpoint) {
15403 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" receiver was blocked on ep:%d, unblocking.. \n",
15404 + target->EpWaitingForBuffers));
15405 + target->HTCStateFlags &= ~HTC_STATE_WAIT_BUFFERS;
15406 + target->EpWaitingForBuffers = ENDPOINT_MAX;
15407 + unblockRecv = TRUE;
15411 + UNLOCK_HTC_RX(target);
15413 + if (unblockRecv && !HTC_STOPPING(target)) {
15414 + /* TODO : implement a buffer threshold count? */
15415 + DevEnableRecv(&target->Device,DEV_ENABLE_RECV_SYNC);
15423 +static void HTCFlushEndpointRX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint)
15425 + HTC_PACKET *pPacket;
15427 + LOCK_HTC_RX(target);
15430 + pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->RxBuffers);
15431 + if (NULL == pPacket) {
15434 + UNLOCK_HTC_RX(target);
15435 + pPacket->Status = A_ECANCELED;
15436 + pPacket->ActualLength = 0;
15437 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" Flushing RX packet:0x%X, length:%d, ep:%d \n",
15438 + (A_UINT32)pPacket, pPacket->BufferLength, pPacket->Endpoint));
15439 + /* give the packet back */
15440 + pEndpoint->EpCallBacks.EpRecv(pEndpoint->EpCallBacks.pContext,
15442 + LOCK_HTC_RX(target);
15445 + UNLOCK_HTC_RX(target);
15450 +void HTCFlushRecvBuffers(HTC_TARGET *target)
15452 + HTC_ENDPOINT *pEndpoint;
15455 + /* NOTE: no need to flush endpoint 0, these buffers were
15456 + * allocated as part of the HTC struct */
15457 + for (i = ENDPOINT_1; i < ENDPOINT_MAX; i++) {
15458 + pEndpoint = &target->EndPoint[i];
15459 + if (pEndpoint->ServiceID == 0) {
15460 + /* not in use.. */
15463 + HTCFlushEndpointRX(target,pEndpoint);
15470 diff --git a/drivers/sdio/function/wlan/ar6000/htc/htc_send.c b/drivers/sdio/function/wlan/ar6000/htc/htc_send.c
15471 new file mode 100644
15472 index 0000000..7792dd6
15474 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_send.c
15478 + * Copyright (c) 2007 Atheros Communications Inc.
15479 + * All rights reserved.
15482 + * This program is free software; you can redistribute it and/or modify
15483 + * it under the terms of the GNU General Public License version 2 as
15484 + * published by the Free Software Foundation;
15486 + * Software distributed under the License is distributed on an "AS
15487 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15488 + * implied. See the License for the specific language governing
15489 + * rights and limitations under the License.
15495 +#include "htc_internal.h"
15497 +#define DO_EP_TX_COMPLETION(ep,p) \
15499 + (p)->Completion = NULL; \
15500 + (ep)->EpCallBacks.EpTxComplete((ep)->EpCallBacks.pContext,(p)); \
15504 +/* call the distribute credits callback with the distribution */
15505 +#define DO_DISTRIBUTION(t,reason,description,pList) \
15507 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, \
15508 + (" calling distribute function (%s) (dfn:0x%X, ctxt:0x%X, dist:0x%X) \n", \
15510 + (A_UINT32)(t)->DistributeCredits, \
15511 + (A_UINT32)(t)->pCredDistContext, \
15512 + (A_UINT32)pList)); \
15513 + (t)->DistributeCredits((t)->pCredDistContext, \
15518 +/* our internal send packet completion handler when packets are submited to the AR6K device
15520 +static void HTCSendPktCompletionHandler(void *Context, HTC_PACKET *pPacket)
15522 + HTC_TARGET *target = (HTC_TARGET *)Context;
15523 + HTC_ENDPOINT *pEndpoint = &target->EndPoint[pPacket->Endpoint];
15526 + if (A_FAILED(pPacket->Status)) {
15527 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15528 + ("HTCSendPktCompletionHandler: request failed (status:%d, ep:%d) \n",
15529 + pPacket->Status, pPacket->Endpoint));
15531 + /* first, fixup the head room we allocated */
15532 + pPacket->pBuffer += HTC_HDR_LENGTH;
15533 + /* do completion */
15534 + DO_EP_TX_COMPLETION(pEndpoint,pPacket);
15537 +A_STATUS HTCIssueSend(HTC_TARGET *target, HTC_PACKET *pPacket, A_UINT8 SendFlags)
15540 + A_UINT8 *pHdrBuf;
15541 + A_BOOL sync = FALSE;
15543 + /* caller always provides headrooom */
15544 + pPacket->pBuffer -= HTC_HDR_LENGTH;
15545 + pHdrBuf = pPacket->pBuffer;
15546 + /* setup frame header */
15547 + A_SET_UINT16_FIELD(pHdrBuf,HTC_FRAME_HDR,PayloadLen,(A_UINT16)pPacket->ActualLength);
15548 + A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,Flags,SendFlags);
15549 + A_SET_UINT8_FIELD(pHdrBuf,HTC_FRAME_HDR,EndpointID, (A_UINT8)pPacket->Endpoint);
15551 + if (pPacket->Completion == NULL) {
15552 + /* mark that this request was synchronously issued */
15556 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,
15557 + ("+-HTCIssueSend: transmit length : %d (%s) \n",
15558 + pPacket->ActualLength + HTC_HDR_LENGTH,
15559 + sync ? "SYNC" : "ASYNC" ));
15561 + /* send message to device */
15562 + status = DevSendPacket(&target->Device,
15564 + pPacket->ActualLength + HTC_HDR_LENGTH);
15567 + /* use local sync variable. If this was issued asynchronously, pPacket is no longer
15568 + * safe to access. */
15569 + pPacket->pBuffer += HTC_HDR_LENGTH;
15572 + /* if this request was asynchronous, the packet completion routine will be invoked by
15573 + * the device layer when the HIF layer completes the request */
15578 +/* try to send the current packet or a packet at the head of the TX queue,
15579 + * if there are no credits, the packet remains in the queue.
15580 + * this function always succeeds and returns a flag if the TX queue for
15581 + * the endpoint has hit the set limit */
15582 +static A_BOOL HTCTrySend(HTC_TARGET *target,
15583 + HTC_ENDPOINT *pEndpoint,
15584 + HTC_PACKET *pPacketToSend)
15586 + HTC_PACKET *pPacket;
15587 + int creditsRequired;
15589 + A_UINT8 sendFlags;
15590 + A_BOOL epFull = FALSE;
15592 + LOCK_HTC_TX(target);
15594 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HTCTrySend (pPkt:0x%X)\n",(A_UINT32)pPacketToSend));
15596 + if (pPacketToSend != NULL) {
15597 + /* caller supplied us a packet to queue to the tail of the HTC TX queue before
15598 + * we check the tx queue */
15599 + HTC_PACKET_ENQUEUE(&pEndpoint->TxQueue,pPacketToSend);
15600 + pEndpoint->CurrentTxQueueDepth++;
15603 + /* now drain the TX queue for transmission as long as we have enough
15608 + if (HTC_QUEUE_EMPTY(&pEndpoint->TxQueue)) {
15609 + /* nothing in the queue */
15615 + /* get packet at head, but don't remove it */
15616 + pPacket = HTC_GET_PKT_AT_HEAD(&pEndpoint->TxQueue);
15617 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" Got head packet:0x%X , Queue Depth: %d\n",
15618 + (A_UINT32)pPacket, pEndpoint->CurrentTxQueueDepth));
15620 + /* figure out how many credits this message requires */
15621 + creditsRequired = (pPacket->ActualLength + HTC_HDR_LENGTH) / target->TargetCreditSize;
15622 + remainder = (pPacket->ActualLength + HTC_HDR_LENGTH) % target->TargetCreditSize;
15625 + creditsRequired++;
15628 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" Creds Required:%d Got:%d\n",
15629 + creditsRequired, pEndpoint->CreditDist.TxCredits));
15631 + if (pEndpoint->CreditDist.TxCredits < creditsRequired) {
15633 + /* not enough credits */
15635 + if (pPacket->Endpoint == ENDPOINT_0) {
15636 + /* leave it in the queue */
15639 + /* invoke the registered distribution function only if this is not
15640 + * endpoint 0, we let the driver layer provide more credits if it can.
15641 + * We pass the credit distribution list starting at the endpoint in question
15644 + /* set how many credits we need */
15645 + pEndpoint->CreditDist.TxCreditsSeek =
15646 + creditsRequired - pEndpoint->CreditDist.TxCredits;
15647 + DO_DISTRIBUTION(target,
15648 + HTC_CREDIT_DIST_SEEK_CREDITS,
15650 + &pEndpoint->CreditDist);
15652 + pEndpoint->CreditDist.TxCreditsSeek = 0;
15654 + if (pEndpoint->CreditDist.TxCredits < creditsRequired) {
15655 + /* still not enough credits to send, leave packet in the queue */
15656 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,
15657 + (" Not enough credits for ep %d leaving packet in queue..\n",
15658 + pPacket->Endpoint));
15664 + pEndpoint->CreditDist.TxCredits -= creditsRequired;
15665 + INC_HTC_EP_STAT(pEndpoint, TxCreditsConsummed, creditsRequired);
15667 + /* check if we need credits */
15668 + if (pEndpoint->CreditDist.TxCredits < pEndpoint->CreditDist.TxCreditsPerMaxMsg) {
15669 + sendFlags |= HTC_FLAGS_NEED_CREDIT_UPDATE;
15670 + INC_HTC_EP_STAT(pEndpoint, TxCreditLowIndications, 1);
15671 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" Host Needs Credits \n"));
15674 + /* now we can fully dequeue */
15675 + pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->TxQueue);
15676 + pEndpoint->CurrentTxQueueDepth--;
15678 + INC_HTC_EP_STAT(pEndpoint, TxIssued, 1);
15680 + UNLOCK_HTC_TX(target);
15682 + HTCIssueSend(target, pPacket, sendFlags);
15684 + LOCK_HTC_TX(target);
15686 + /* go back and check for more messages */
15689 + if (pEndpoint->CurrentTxQueueDepth >= pEndpoint->MaxTxQueueDepth) {
15690 + /* let caller know that this endpoint has reached the maximum depth */
15694 + UNLOCK_HTC_TX(target);
15696 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HTCTrySend: \n"));
15700 +/* HTC API - HTCSendPkt */
15701 +A_STATUS HTCSendPkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket)
15703 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
15704 + HTC_ENDPOINT *pEndpoint;
15705 + HTC_ENDPOINT_ID ep;
15706 + A_STATUS status = A_OK;
15708 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,
15709 + ("+HTCSendPkt: Enter endPointId: %d, buffer: 0x%X, length: %d \n",
15710 + pPacket->Endpoint, (A_UINT32)pPacket->pBuffer, pPacket->ActualLength));
15712 + ep = pPacket->Endpoint;
15713 + AR_DEBUG_ASSERT(ep < ENDPOINT_MAX);
15714 + pEndpoint = &target->EndPoint[ep];
15718 + if (HTC_STOPPING(target)) {
15719 + status = A_ECANCELED;
15720 + pPacket->Status = status;
15721 + DO_EP_TX_COMPLETION(pEndpoint,pPacket);
15724 + /* everything sent through this interface is asynchronous */
15725 + /* fill in HTC completion routines */
15726 + pPacket->Completion = HTCSendPktCompletionHandler;
15727 + pPacket->pContext = target;
15729 + if (HTCTrySend(target, pEndpoint, pPacket)) {
15730 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Endpoint %d, TX queue is full, Depth:%d, Max:%d \n",
15731 + ep, pEndpoint->CurrentTxQueueDepth, pEndpoint->MaxTxQueueDepth));
15732 + /* queue is now full, let caller know */
15733 + if (pEndpoint->EpCallBacks.EpSendFull != NULL) {
15734 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Calling driver's send full callback.... \n"));
15735 + pEndpoint->EpCallBacks.EpSendFull(pEndpoint->EpCallBacks.pContext,
15740 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCSendPkt \n"));
15747 +/* check TX queues to drain because of credit distribution update */
15748 +static INLINE void HTCCheckEndpointTxQueues(HTC_TARGET *target)
15750 + HTC_ENDPOINT *pEndpoint;
15751 + HTC_ENDPOINT_CREDIT_DIST *pDistItem;
15753 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCCheckEndpointTxQueues \n"));
15754 + pDistItem = target->EpCreditDistributionListHead;
15756 + /* run through the credit distribution list to see
15757 + * if there are packets queued
15758 + * NOTE: no locks need to be taken since the distribution list
15759 + * is not dynamic (cannot be re-ordered) and we are not modifying any state */
15760 + while (pDistItem != NULL) {
15761 + pEndpoint = (HTC_ENDPOINT *)pDistItem->pHTCReserved;
15763 + if (pEndpoint->CurrentTxQueueDepth > 0) {
15764 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Ep %d has %d credits and %d Packets in TX Queue \n",
15765 + pDistItem->Endpoint, pEndpoint->CreditDist.TxCredits, pEndpoint->CurrentTxQueueDepth));
15766 + /* try to start the stalled queue, this list is ordered by priority.
15767 + * Highest priority queue get's processed first, if there are credits available the
15768 + * highest priority queue will get a chance to reclaim credits from lower priority
15770 + HTCTrySend(target, pEndpoint, NULL);
15773 + pDistItem = pDistItem->pNext;
15776 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCCheckEndpointTxQueues \n"));
15779 +/* process credit reports and call distribution function */
15780 +void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint)
15783 + HTC_ENDPOINT *pEndpoint;
15784 + int totalCredits = 0;
15785 + A_BOOL doDist = FALSE;
15787 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCProcessCreditRpt, Credit Report Entries:%d \n", NumEntries));
15789 + /* lock out TX while we update credits */
15790 + LOCK_HTC_TX(target);
15792 + for (i = 0; i < NumEntries; i++, pRpt++) {
15793 + if (pRpt->EndpointID >= ENDPOINT_MAX) {
15794 + AR_DEBUG_ASSERT(FALSE);
15798 + pEndpoint = &target->EndPoint[pRpt->EndpointID];
15800 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Endpoint %d got %d credits \n",
15801 + pRpt->EndpointID, pRpt->Credits));
15804 +#ifdef HTC_EP_STAT_PROFILING
15806 + INC_HTC_EP_STAT(pEndpoint, TxCreditRpts, 1);
15807 + INC_HTC_EP_STAT(pEndpoint, TxCreditsReturned, pRpt->Credits);
15809 + if (FromEndpoint == pRpt->EndpointID) {
15810 + /* this credit report arrived on the same endpoint indicating it arrived in an RX
15812 + INC_HTC_EP_STAT(pEndpoint, TxCreditsFromRx, pRpt->Credits);
15813 + INC_HTC_EP_STAT(pEndpoint, TxCreditRptsFromRx, 1);
15814 + } else if (FromEndpoint == ENDPOINT_0) {
15815 + /* this credit arrived on endpoint 0 as a NULL message */
15816 + INC_HTC_EP_STAT(pEndpoint, TxCreditsFromEp0, pRpt->Credits);
15817 + INC_HTC_EP_STAT(pEndpoint, TxCreditRptsFromEp0, 1);
15819 + /* arrived on another endpoint */
15820 + INC_HTC_EP_STAT(pEndpoint, TxCreditsFromOther, pRpt->Credits);
15821 + INC_HTC_EP_STAT(pEndpoint, TxCreditRptsFromOther, 1);
15826 + if (ENDPOINT_0 == pRpt->EndpointID) {
15827 + /* always give endpoint 0 credits back */
15828 + pEndpoint->CreditDist.TxCredits += pRpt->Credits;
15830 + /* for all other endpoints, update credits to distribute, the distribution function
15831 + * will handle giving out credits back to the endpoints */
15832 + pEndpoint->CreditDist.TxCreditsToDist += pRpt->Credits;
15833 + /* flag that we have to do the distribution */
15837 + totalCredits += pRpt->Credits;
15840 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Report indicated %d credits to distribute \n", totalCredits));
15843 + /* this was a credit return based on a completed send operations
15844 + * note, this is done with the lock held */
15845 + DO_DISTRIBUTION(target,
15846 + HTC_CREDIT_DIST_SEND_COMPLETE,
15848 + target->EpCreditDistributionListHead->pNext);
15851 + UNLOCK_HTC_TX(target);
15853 + if (totalCredits) {
15854 + HTCCheckEndpointTxQueues(target);
15857 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCProcessCreditRpt \n"));
15860 +/* flush endpoint TX queue */
15861 +static void HTCFlushEndpointTX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_TX_TAG Tag)
15863 + HTC_PACKET *pPacket;
15864 + HTC_PACKET_QUEUE discardQueue;
15866 + /* initialize the discard queue */
15867 + INIT_HTC_PACKET_QUEUE(&discardQueue);
15869 + LOCK_HTC_TX(target);
15871 + /* interate from the front of the TX queue and flush out packets */
15872 + ITERATE_OVER_LIST_ALLOW_REMOVE(&pEndpoint->TxQueue, pPacket, HTC_PACKET, ListLink) {
15874 + /* check for removal */
15875 + if ((HTC_TX_PACKET_TAG_ALL == Tag) || (Tag == pPacket->PktInfo.AsTx.Tag)) {
15876 + /* remove from queue */
15877 + HTC_PACKET_REMOVE(pPacket);
15878 + /* add it to the discard pile */
15879 + HTC_PACKET_ENQUEUE(&discardQueue, pPacket);
15880 + pEndpoint->CurrentTxQueueDepth--;
15885 + UNLOCK_HTC_TX(target);
15887 + /* empty the discard queue */
15889 + pPacket = HTC_PACKET_DEQUEUE(&discardQueue);
15890 + if (NULL == pPacket) {
15893 + pPacket->Status = A_ECANCELED;
15894 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, (" Flushing TX packet:0x%X, length:%d, ep:%d tag:0x%X \n",
15895 + (A_UINT32)pPacket, pPacket->ActualLength, pPacket->Endpoint, pPacket->PktInfo.AsTx.Tag));
15896 + DO_EP_TX_COMPLETION(pEndpoint,pPacket);
15901 +void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist)
15903 + HTC_ENDPOINT *pEndpoint = (HTC_ENDPOINT *)pEPDist->pHTCReserved;
15905 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("--- EP : %d ServiceID: 0x%X --------------\n",
15906 + pEPDist->Endpoint, pEPDist->ServiceID));
15907 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" this:0x%X next:0x%X prev:0x%X\n",
15908 + (A_UINT32)pEPDist, (A_UINT32)pEPDist->pNext, (A_UINT32)pEPDist->pPrev));
15909 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" DistFlags : 0x%X \n", pEPDist->DistFlags));
15910 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsNorm : %d \n", pEPDist->TxCreditsNorm));
15911 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsMin : %d \n", pEPDist->TxCreditsMin));
15912 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCredits : %d \n", pEPDist->TxCredits));
15913 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsAssigned : %d \n", pEPDist->TxCreditsAssigned));
15914 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsSeek : %d \n", pEPDist->TxCreditsSeek));
15915 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditSize : %d \n", pEPDist->TxCreditSize));
15916 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsPerMaxMsg : %d \n", pEPDist->TxCreditsPerMaxMsg));
15917 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxCreditsToDist : %d \n", pEPDist->TxCreditsToDist));
15918 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (" TxQueueDepth : %d \n", pEndpoint->CurrentTxQueueDepth));
15919 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("----------------------------------------------------\n"));
15922 +void DumpCreditDistStates(HTC_TARGET *target)
15924 + HTC_ENDPOINT_CREDIT_DIST *pEPList = target->EpCreditDistributionListHead;
15926 + while (pEPList != NULL) {
15927 + DumpCreditDist(pEPList);
15928 + pEPList = pEPList->pNext;
15931 + if (target->DistributeCredits != NULL) {
15932 + DO_DISTRIBUTION(target,
15933 + HTC_DUMP_CREDIT_STATE,
15939 +/* flush all send packets from all endpoint queues */
15940 +void HTCFlushSendPkts(HTC_TARGET *target)
15942 + HTC_ENDPOINT *pEndpoint;
15945 + DumpCreditDistStates(target);
15947 + for (i = ENDPOINT_0; i < ENDPOINT_MAX; i++) {
15948 + pEndpoint = &target->EndPoint[i];
15949 + if (pEndpoint->ServiceID == 0) {
15950 + /* not in use.. */
15953 + HTCFlushEndpointTX(target,pEndpoint,HTC_TX_PACKET_TAG_ALL);
15959 +/* HTC API to flush an endpoint's TX queue*/
15960 +void HTCFlushEndpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, HTC_TX_TAG Tag)
15962 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
15963 + HTC_ENDPOINT *pEndpoint = &target->EndPoint[Endpoint];
15965 + if (pEndpoint->ServiceID == 0) {
15966 + AR_DEBUG_ASSERT(FALSE);
15967 + /* not in use.. */
15971 + HTCFlushEndpointTX(target, pEndpoint, Tag);
15974 +/* HTC API to indicate activity to the credit distribution function */
15975 +void HTCIndicateActivityChange(HTC_HANDLE HTCHandle,
15976 + HTC_ENDPOINT_ID Endpoint,
15979 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
15980 + HTC_ENDPOINT *pEndpoint = &target->EndPoint[Endpoint];
15981 + A_BOOL doDist = FALSE;
15983 + if (pEndpoint->ServiceID == 0) {
15984 + AR_DEBUG_ASSERT(FALSE);
15985 + /* not in use.. */
15989 + LOCK_HTC_TX(target);
15992 + if (!(pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE)) {
15993 + /* mark active now */
15994 + pEndpoint->CreditDist.DistFlags |= HTC_EP_ACTIVE;
15998 + if (pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE) {
15999 + /* mark inactive now */
16000 + pEndpoint->CreditDist.DistFlags &= ~HTC_EP_ACTIVE;
16006 + /* do distribution again based on activity change
16007 + * note, this is done with the lock held */
16008 + DO_DISTRIBUTION(target,
16009 + HTC_CREDIT_DIST_ACTIVITY_CHANGE,
16010 + "Activity Change",
16011 + target->EpCreditDistributionListHead->pNext);
16014 + UNLOCK_HTC_TX(target);
16017 diff --git a/drivers/sdio/function/wlan/ar6000/htc/htc_services.c b/drivers/sdio/function/wlan/ar6000/htc/htc_services.c
16018 new file mode 100644
16019 index 0000000..e5d50d1
16021 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_services.c
16025 + * Copyright (c) 2007 Atheros Communications Inc.
16026 + * All rights reserved.
16029 + * This program is free software; you can redistribute it and/or modify
16030 + * it under the terms of the GNU General Public License version 2 as
16031 + * published by the Free Software Foundation;
16033 + * Software distributed under the License is distributed on an "AS
16034 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16035 + * implied. See the License for the specific language governing
16036 + * rights and limitations under the License.
16042 +#include "htc_internal.h"
16044 +void HTCControlTxComplete(void *Context, HTC_PACKET *pPacket)
16046 + /* not implemented
16047 + * we do not send control TX frames during normal runtime, only during setup */
16048 + AR_DEBUG_ASSERT(FALSE);
16051 + /* callback when a control message arrives on this endpoint */
16052 +void HTCControlRecv(void *Context, HTC_PACKET *pPacket)
16054 + AR_DEBUG_ASSERT(pPacket->Endpoint == ENDPOINT_0);
16056 + /* the only control messages we are expecting are NULL messages (credit resports), which should
16057 + * never get here */
16058 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
16059 + ("HTCControlRecv, got message with length:%d \n",
16060 + pPacket->ActualLength + HTC_HDR_LENGTH));
16062 + /* dump header and message */
16063 + DebugDumpBytes(pPacket->pBuffer - HTC_HDR_LENGTH,
16064 + pPacket->ActualLength + HTC_HDR_LENGTH,
16065 + "Unexpected ENDPOINT 0 Message");
16067 + HTC_RECYCLE_RX_PKT((HTC_TARGET*)Context,pPacket);
16070 +A_STATUS HTCSendSetupComplete(HTC_TARGET *target)
16072 + HTC_PACKET *pSendPacket = NULL;
16074 + HTC_SETUP_COMPLETE_MSG *pSetupComplete;
16077 + /* allocate a packet to send to the target */
16078 + pSendPacket = HTC_ALLOC_CONTROL_TX(target);
16080 + if (NULL == pSendPacket) {
16081 + status = A_NO_MEMORY;
16085 + /* assemble setup complete message */
16086 + pSetupComplete = (HTC_SETUP_COMPLETE_MSG *)pSendPacket->pBuffer;
16087 + A_MEMZERO(pSetupComplete,sizeof(HTC_SETUP_COMPLETE_MSG));
16088 + pSetupComplete->MessageID = HTC_MSG_SETUP_COMPLETE_ID;
16090 + SET_HTC_PACKET_INFO_TX(pSendPacket,
16092 + (A_UINT8 *)pSetupComplete,
16093 + sizeof(HTC_SETUP_COMPLETE_MSG),
16095 + HTC_SERVICE_TX_PACKET_TAG);
16097 + /* we want synchronous operation */
16098 + pSendPacket->Completion = NULL;
16099 + /* send the message */
16100 + status = HTCIssueSend(target,pSendPacket,0);
16104 + if (pSendPacket != NULL) {
16105 + HTC_FREE_CONTROL_TX(target,pSendPacket);
16112 +A_STATUS HTCConnectService(HTC_HANDLE HTCHandle,
16113 + HTC_SERVICE_CONNECT_REQ *pConnectReq,
16114 + HTC_SERVICE_CONNECT_RESP *pConnectResp)
16116 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
16117 + A_STATUS status = A_OK;
16118 + HTC_PACKET *pRecvPacket = NULL;
16119 + HTC_PACKET *pSendPacket = NULL;
16120 + HTC_CONNECT_SERVICE_RESPONSE_MSG *pResponseMsg;
16121 + HTC_CONNECT_SERVICE_MSG *pConnectMsg;
16122 + HTC_ENDPOINT_ID assignedEndpoint = ENDPOINT_MAX;
16123 + HTC_ENDPOINT *pEndpoint;
16124 + int maxMsgSize = 0;
16126 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCConnectService, target:0x%X SvcID:0x%X \n",
16127 + (A_UINT32)target, pConnectReq->ServiceID));
16131 + AR_DEBUG_ASSERT(pConnectReq->ServiceID != 0);
16133 + if (HTC_CTRL_RSVD_SVC == pConnectReq->ServiceID) {
16134 + /* special case for pseudo control service */
16135 + assignedEndpoint = ENDPOINT_0;
16136 + maxMsgSize = HTC_MAX_CONTROL_MESSAGE_LENGTH;
16138 + /* allocate a packet to send to the target */
16139 + pSendPacket = HTC_ALLOC_CONTROL_TX(target);
16141 + if (NULL == pSendPacket) {
16142 + AR_DEBUG_ASSERT(FALSE);
16143 + status = A_NO_MEMORY;
16146 + /* assemble connect service message */
16147 + pConnectMsg = (HTC_CONNECT_SERVICE_MSG *)pSendPacket->pBuffer;
16148 + AR_DEBUG_ASSERT(pConnectMsg != NULL);
16149 + A_MEMZERO(pConnectMsg,sizeof(HTC_CONNECT_SERVICE_MSG));
16150 + pConnectMsg->MessageID = HTC_MSG_CONNECT_SERVICE_ID;
16151 + pConnectMsg->ServiceID = pConnectReq->ServiceID;
16152 + pConnectMsg->ConnectionFlags = pConnectReq->ConnectionFlags;
16153 + /* check caller if it wants to transfer meta data */
16154 + if ((pConnectReq->pMetaData != NULL) &&
16155 + (pConnectReq->MetaDataLength <= HTC_SERVICE_META_DATA_MAX_LENGTH)) {
16156 + /* copy meta data into message buffer (after header ) */
16157 + A_MEMCPY((A_UINT8 *)pConnectMsg + sizeof(HTC_CONNECT_SERVICE_MSG),
16158 + pConnectReq->pMetaData,
16159 + pConnectReq->MetaDataLength);
16160 + pConnectMsg->ServiceMetaLength = pConnectReq->MetaDataLength;
16163 + SET_HTC_PACKET_INFO_TX(pSendPacket,
16165 + (A_UINT8 *)pConnectMsg,
16166 + sizeof(HTC_CONNECT_SERVICE_MSG) + pConnectMsg->ServiceMetaLength,
16168 + HTC_SERVICE_TX_PACKET_TAG);
16170 + /* we want synchronous operation */
16171 + pSendPacket->Completion = NULL;
16173 + status = HTCIssueSend(target,pSendPacket,0);
16175 + if (A_FAILED(status)) {
16179 + /* wait for response */
16180 + status = HTCWaitforControlMessage(target, &pRecvPacket);
16182 + if (A_FAILED(status)) {
16185 + /* we controlled the buffer creation so it has to be properly aligned */
16186 + pResponseMsg = (HTC_CONNECT_SERVICE_RESPONSE_MSG *)pRecvPacket->pBuffer;
16188 + if ((pResponseMsg->MessageID != HTC_MSG_CONNECT_SERVICE_RESPONSE_ID) ||
16189 + (pRecvPacket->ActualLength < sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG))) {
16190 + /* this message is not valid */
16191 + AR_DEBUG_ASSERT(FALSE);
16192 + status = A_EPROTO;
16196 + pConnectResp->ConnectRespCode = pResponseMsg->Status;
16197 + /* check response status */
16198 + if (pResponseMsg->Status != HTC_SERVICE_SUCCESS) {
16199 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
16200 + (" Target failed service 0x%X connect request (status:%d)\n",
16201 + pResponseMsg->ServiceID, pResponseMsg->Status));
16202 + status = A_EPROTO;
16206 + assignedEndpoint = pResponseMsg->EndpointID;
16207 + maxMsgSize = pResponseMsg->MaxMsgSize;
16209 + if ((pConnectResp->pMetaData != NULL) &&
16210 + (pResponseMsg->ServiceMetaLength > 0) &&
16211 + (pResponseMsg->ServiceMetaLength <= HTC_SERVICE_META_DATA_MAX_LENGTH)) {
16212 + /* caller supplied a buffer and the target responded with data */
16213 + int copyLength = min((int)pConnectResp->BufferLength, (int)pResponseMsg->ServiceMetaLength);
16214 + /* copy the meta data */
16215 + A_MEMCPY(pConnectResp->pMetaData,
16216 + ((A_UINT8 *)pResponseMsg) + sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG),
16218 + pConnectResp->ActualLength = copyLength;
16223 + /* the rest of these are parameter checks so set the error status */
16224 + status = A_EPROTO;
16226 + if (assignedEndpoint >= ENDPOINT_MAX) {
16227 + AR_DEBUG_ASSERT(FALSE);
16231 + if (0 == maxMsgSize) {
16232 + AR_DEBUG_ASSERT(FALSE);
16236 + pEndpoint = &target->EndPoint[assignedEndpoint];
16238 + if (pEndpoint->ServiceID != 0) {
16239 + /* endpoint already in use! */
16240 + AR_DEBUG_ASSERT(FALSE);
16244 + /* return assigned endpoint to caller */
16245 + pConnectResp->Endpoint = assignedEndpoint;
16246 + pConnectResp->MaxMsgLength = maxMsgSize;
16248 + /* setup the endpoint */
16249 + pEndpoint->ServiceID = pConnectReq->ServiceID; /* this marks the endpoint in use */
16250 + pEndpoint->MaxTxQueueDepth = pConnectReq->MaxSendQueueDepth;
16251 + pEndpoint->MaxMsgLength = maxMsgSize;
16252 + /* copy all the callbacks */
16253 + pEndpoint->EpCallBacks = pConnectReq->EpCallbacks;
16254 + INIT_HTC_PACKET_QUEUE(&pEndpoint->RxBuffers);
16255 + INIT_HTC_PACKET_QUEUE(&pEndpoint->TxQueue);
16256 + /* set the credit distribution info for this endpoint, this information is
16257 + * passed back to the credit distribution callback function */
16258 + pEndpoint->CreditDist.ServiceID = pConnectReq->ServiceID;
16259 + pEndpoint->CreditDist.pHTCReserved = pEndpoint;
16260 + pEndpoint->CreditDist.Endpoint = assignedEndpoint;
16261 + pEndpoint->CreditDist.TxCreditSize = target->TargetCreditSize;
16262 + pEndpoint->CreditDist.TxCreditsPerMaxMsg = maxMsgSize / target->TargetCreditSize;
16264 + if (0 == pEndpoint->CreditDist.TxCreditsPerMaxMsg) {
16265 + pEndpoint->CreditDist.TxCreditsPerMaxMsg = 1;
16272 + if (pSendPacket != NULL) {
16273 + HTC_FREE_CONTROL_TX(target,pSendPacket);
16276 + if (pRecvPacket != NULL) {
16277 + HTC_FREE_CONTROL_RX(target,pRecvPacket);
16280 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCConnectService \n"));
16285 +static void AddToEndpointDistList(HTC_TARGET *target, HTC_ENDPOINT_CREDIT_DIST *pEpDist)
16287 + HTC_ENDPOINT_CREDIT_DIST *pCurEntry,*pLastEntry;
16289 + if (NULL == target->EpCreditDistributionListHead) {
16290 + target->EpCreditDistributionListHead = pEpDist;
16291 + pEpDist->pNext = NULL;
16292 + pEpDist->pPrev = NULL;
16296 + /* queue to the end of the list, this does not have to be very
16297 + * fast since this list is built at startup time */
16298 + pCurEntry = target->EpCreditDistributionListHead;
16300 + while (pCurEntry) {
16301 + pLastEntry = pCurEntry;
16302 + pCurEntry = pCurEntry->pNext;
16305 + pLastEntry->pNext = pEpDist;
16306 + pEpDist->pPrev = pLastEntry;
16307 + pEpDist->pNext = NULL;
16312 +/* default credit init callback */
16313 +static void HTCDefaultCreditInit(void *Context,
16314 + HTC_ENDPOINT_CREDIT_DIST *pEPList,
16315 + int TotalCredits)
16317 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
16318 + int totalEps = 0;
16319 + int creditsPerEndpoint;
16321 + pCurEpDist = pEPList;
16322 + /* first run through the list and figure out how many endpoints we are dealing with */
16323 + while (pCurEpDist != NULL) {
16324 + pCurEpDist = pCurEpDist->pNext;
16328 + /* even distribution */
16329 + creditsPerEndpoint = TotalCredits/totalEps;
16331 + pCurEpDist = pEPList;
16332 + /* run through the list and set minimum and normal credits and
16333 + * provide the endpoint with some credits to start */
16334 + while (pCurEpDist != NULL) {
16336 + if (creditsPerEndpoint < pCurEpDist->TxCreditsPerMaxMsg) {
16337 + /* too many endpoints and not enough credits */
16338 + AR_DEBUG_ASSERT(FALSE);
16341 + /* our minimum is set for at least 1 max message */
16342 + pCurEpDist->TxCreditsMin = pCurEpDist->TxCreditsPerMaxMsg;
16343 + /* this value is ignored by our credit alg, since we do
16344 + * not dynamically adjust credits, this is the policy of
16345 + * the "default" credit distribution, something simple and easy */
16346 + pCurEpDist->TxCreditsNorm = 0xFFFF;
16347 + /* give the endpoint minimum credits */
16348 + pCurEpDist->TxCredits = creditsPerEndpoint;
16349 + pCurEpDist->TxCreditsAssigned = creditsPerEndpoint;
16350 + pCurEpDist = pCurEpDist->pNext;
16355 +/* default credit distribution callback, NOTE, this callback holds the TX lock */
16356 +void HTCDefaultCreditDist(void *Context,
16357 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList,
16358 + HTC_CREDIT_DIST_REASON Reason)
16360 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
16362 + if (Reason == HTC_CREDIT_DIST_SEND_COMPLETE) {
16363 + pCurEpDist = pEPDistList;
16364 + /* simple distribution */
16365 + while (pCurEpDist != NULL) {
16366 + if (pCurEpDist->TxCreditsToDist > 0) {
16367 + /* just give the endpoint back the credits */
16368 + pCurEpDist->TxCredits += pCurEpDist->TxCreditsToDist;
16369 + pCurEpDist->TxCreditsToDist = 0;
16371 + pCurEpDist = pCurEpDist->pNext;
16375 + /* note we do not need to handle the other reason codes as this is a very
16376 + * simple distribution scheme, no need to seek for more credits or handle inactivity */
16379 +void HTCSetCreditDistribution(HTC_HANDLE HTCHandle,
16380 + void *pCreditDistContext,
16381 + HTC_CREDIT_DIST_CALLBACK CreditDistFunc,
16382 + HTC_CREDIT_INIT_CALLBACK CreditInitFunc,
16383 + HTC_SERVICE_ID ServicePriorityOrder[],
16386 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
16390 + if (CreditInitFunc != NULL) {
16391 + /* caller has supplied their own distribution functions */
16392 + target->InitCredits = CreditInitFunc;
16393 + AR_DEBUG_ASSERT(CreditDistFunc != NULL);
16394 + target->DistributeCredits = CreditDistFunc;
16395 + target->pCredDistContext = pCreditDistContext;
16397 + /* caller wants HTC to do distribution */
16398 + /* if caller wants service to handle distributions then
16399 + * it must set both of these to NULL! */
16400 + AR_DEBUG_ASSERT(CreditDistFunc == NULL);
16401 + target->InitCredits = HTCDefaultCreditInit;
16402 + target->DistributeCredits = HTCDefaultCreditDist;
16403 + target->pCredDistContext = target;
16406 + /* always add HTC control endpoint first, we only expose the list after the
16407 + * first one, this is added for TX queue checking */
16408 + AddToEndpointDistList(target, &target->EndPoint[ENDPOINT_0].CreditDist);
16410 + /* build the list of credit distribution structures in priority order
16411 + * supplied by the caller, these will follow endpoint 0 */
16412 + for (i = 0; i < ListLength; i++) {
16413 + /* match services with endpoints and add the endpoints to the distribution list
16414 + * in FIFO order */
16415 + for (ep = ENDPOINT_1; ep < ENDPOINT_MAX; ep++) {
16416 + if (target->EndPoint[ep].ServiceID == ServicePriorityOrder[i]) {
16417 + /* queue this one to the list */
16418 + AddToEndpointDistList(target, &target->EndPoint[ep].CreditDist);
16422 + AR_DEBUG_ASSERT(ep < ENDPOINT_MAX);
16426 diff --git a/drivers/sdio/function/wlan/ar6000/include/AR6001_regdump.h b/drivers/sdio/function/wlan/ar6000/include/AR6001_regdump.h
16427 new file mode 100644
16428 index 0000000..c1bcade
16430 +++ b/drivers/sdio/function/wlan/ar6000/include/AR6001_regdump.h
16433 + * Copyright (c) 2006 Atheros Communications Inc.
16434 + * All rights reserved.
16436 + * $ATH_LICENSE_HOSTSDK0_C$
16440 +#ifndef __AR6000_REGDUMP_H__
16441 +#define __AR6000_REGDUMP_H__
16443 +#if !defined(__ASSEMBLER__)
16445 + * Target CPU state at the time of failure is reflected
16446 + * in a register dump, which the Host can fetch through
16447 + * the diagnostic window.
16450 +struct MIPS_exception_frame_s {
16451 + A_UINT32 pc; /* Program Counter */
16452 + A_UINT32 at; /* MIPS General Purpose registers */
16483 + A_UINT32 cause; /* Selected coprocessor regs */
16486 +typedef struct MIPS_exception_frame_s CPU_exception_frame_t;
16491 + * Offsets into MIPS_exception_frame structure, for use in assembler code
16492 + * MUST MATCH C STRUCTURE ABOVE
16526 +#define RD_cause 32
16527 +#define RD_status 33
16529 +#define RD_SIZE (34*4) /* Space for this number of words */
16531 +#endif /* __AR6000_REGDUMP_H__ */
16532 diff --git a/drivers/sdio/function/wlan/ar6000/include/AR6K_version.h b/drivers/sdio/function/wlan/ar6000/include/AR6K_version.h
16533 new file mode 100644
16534 index 0000000..d5b2a20
16536 +++ b/drivers/sdio/function/wlan/ar6000/include/AR6K_version.h
16538 +#define __VER_MAJOR_ 2
16539 +#define __VER_MINOR_ 0
16540 +#define __VER_PATCH_ 0
16544 + * Copyright (c) 2004-2007 Atheros Communications Inc.
16545 + * All rights reserved.
16547 + * $ATH_LICENSE_HOSTSDK0_C$
16549 + * The makear6ksdk script (used for release builds) modifies the following line.
16551 +#define __BUILD_NUMBER_ 18
16554 +/* Format of the version number. */
16555 +#define VER_MAJOR_BIT_OFFSET 28
16556 +#define VER_MINOR_BIT_OFFSET 24
16557 +#define VER_PATCH_BIT_OFFSET 16
16558 +#define VER_BUILD_NUM_BIT_OFFSET 0
16562 + * The version has the following format:
16563 + * Bits 28-31: Major version
16564 + * Bits 24-27: Minor version
16565 + * Bits 16-23: Patch version
16566 + * Bits 0-15: Build number (automatically generated during build process )
16567 + * E.g. Build 1.1.3.7 would be represented as 0x11030007.
16569 + * DO NOT split the following macro into multiple lines as this may confuse the build scripts.
16571 +#define AR6K_SW_VERSION ( ( __VER_MAJOR_ << VER_MAJOR_BIT_OFFSET ) + ( __VER_MINOR_ << VER_MINOR_BIT_OFFSET ) + ( __VER_PATCH_ << VER_PATCH_BIT_OFFSET ) + ( __BUILD_NUMBER_ << VER_BUILD_NUM_BIT_OFFSET ) )
16574 diff --git a/drivers/sdio/function/wlan/ar6000/include/AR6K_version.h.NEW b/drivers/sdio/function/wlan/ar6000/include/AR6K_version.h.NEW
16575 new file mode 100644
16576 index 0000000..d5b2a20
16578 +++ b/drivers/sdio/function/wlan/ar6000/include/AR6K_version.h.NEW
16580 +#define __VER_MAJOR_ 2
16581 +#define __VER_MINOR_ 0
16582 +#define __VER_PATCH_ 0
16586 + * Copyright (c) 2004-2007 Atheros Communications Inc.
16587 + * All rights reserved.
16589 + * $ATH_LICENSE_HOSTSDK0_C$
16591 + * The makear6ksdk script (used for release builds) modifies the following line.
16593 +#define __BUILD_NUMBER_ 18
16596 +/* Format of the version number. */
16597 +#define VER_MAJOR_BIT_OFFSET 28
16598 +#define VER_MINOR_BIT_OFFSET 24
16599 +#define VER_PATCH_BIT_OFFSET 16
16600 +#define VER_BUILD_NUM_BIT_OFFSET 0
16604 + * The version has the following format:
16605 + * Bits 28-31: Major version
16606 + * Bits 24-27: Minor version
16607 + * Bits 16-23: Patch version
16608 + * Bits 0-15: Build number (automatically generated during build process )
16609 + * E.g. Build 1.1.3.7 would be represented as 0x11030007.
16611 + * DO NOT split the following macro into multiple lines as this may confuse the build scripts.
16613 +#define AR6K_SW_VERSION ( ( __VER_MAJOR_ << VER_MAJOR_BIT_OFFSET ) + ( __VER_MINOR_ << VER_MINOR_BIT_OFFSET ) + ( __VER_PATCH_ << VER_PATCH_BIT_OFFSET ) + ( __BUILD_NUMBER_ << VER_BUILD_NUM_BIT_OFFSET ) )
16616 diff --git a/drivers/sdio/function/wlan/ar6000/include/AR6Khwreg.h b/drivers/sdio/function/wlan/ar6000/include/AR6Khwreg.h
16617 new file mode 100644
16618 index 0000000..ecfdf20
16620 +++ b/drivers/sdio/function/wlan/ar6000/include/AR6Khwreg.h
16623 + * Copyright (c) 2004-2007 Atheros Communications Inc.
16624 + * All rights reserved.
16626 + * $ATH_LICENSE_HOSTSDK0_C$
16628 + * This file contains the definitions for AR6001 registers
16629 + * that may be directly manipulated by Host software.
16632 +#ifndef __AR6KHWREG_H__
16633 +#define __AR6KHWREG_H__
16635 +#ifdef __cplusplus
16639 +/* Host registers */
16640 +#define HOST_INT_STATUS_ADDRESS 0x00000400
16641 +#define CPU_INT_STATUS_ADDRESS 0x00000401
16642 +#define ERROR_INT_STATUS_ADDRESS 0x00000402
16643 +#define INT_STATUS_ENABLE_ADDRESS 0x00000418
16644 +#define CPU_INT_STATUS_ENABLE_ADDRESS 0x00000419
16645 +#define COUNT_ADDRESS 0x00000420
16646 +#define COUNT_DEC_ADDRESS 0x00000440
16647 +#define WINDOW_DATA_ADDRESS 0x00000474
16648 +#define WINDOW_WRITE_ADDR_ADDRESS 0x00000478
16649 +#define WINDOW_READ_ADDR_ADDRESS 0x0000047c
16651 +/* Target addresses */
16652 +#define RESET_CONTROL_ADDRESS 0x0c000000
16653 +#define MC_REMAP_VALID_ADDRESS 0x0c004080
16654 +#define MC_REMAP_SIZE_ADDRESS 0x0c004100
16655 +#define MC_REMAP_COMPARE_ADDRESS 0x0c004180
16656 +#define MC_REMAP_TARGET_ADDRESS 0x0c004200
16657 +#define LOCAL_COUNT_ADDRESS 0x0c014080
16658 +#define LOCAL_SCRATCH_ADDRESS 0x0c0140c0
16661 +#define INT_STATUS_ENABLE_ERROR_MSB 7
16662 +#define INT_STATUS_ENABLE_ERROR_LSB 7
16663 +#define INT_STATUS_ENABLE_ERROR_MASK 0x00000080
16664 +#define INT_STATUS_ENABLE_ERROR_GET(x) (((x) & INT_STATUS_ENABLE_ERROR_MASK) >> INT_STATUS_ENABLE_ERROR_LSB)
16665 +#define INT_STATUS_ENABLE_ERROR_SET(x) (((x) << INT_STATUS_ENABLE_ERROR_LSB) & INT_STATUS_ENABLE_ERROR_MASK)
16667 +#define INT_STATUS_ENABLE_CPU_MSB 6
16668 +#define INT_STATUS_ENABLE_CPU_LSB 6
16669 +#define INT_STATUS_ENABLE_CPU_MASK 0x00000040
16670 +#define INT_STATUS_ENABLE_CPU_GET(x) (((x) & INT_STATUS_ENABLE_CPU_MASK) >> INT_STATUS_ENABLE_CPU_LSB)
16671 +#define INT_STATUS_ENABLE_CPU_SET(x) (((x) << INT_STATUS_ENABLE_CPU_LSB) & INT_STATUS_ENABLE_CPU_MASK)
16673 +#define INT_STATUS_ENABLE_COUNTER_MSB 4
16674 +#define INT_STATUS_ENABLE_COUNTER_LSB 4
16675 +#define INT_STATUS_ENABLE_COUNTER_MASK 0x00000010
16676 +#define INT_STATUS_ENABLE_COUNTER_GET(x) (((x) & INT_STATUS_ENABLE_COUNTER_MASK) >> INT_STATUS_ENABLE_COUNTER_LSB)
16677 +#define INT_STATUS_ENABLE_COUNTER_SET(x) (((x) << INT_STATUS_ENABLE_COUNTER_LSB) & INT_STATUS_ENABLE_COUNTER_MASK)
16679 +#define INT_STATUS_ENABLE_MBOX_DATA_MSB 3
16680 +#define INT_STATUS_ENABLE_MBOX_DATA_LSB 0
16681 +#define INT_STATUS_ENABLE_MBOX_DATA_MASK 0x0000000f
16682 +#define INT_STATUS_ENABLE_MBOX_DATA_GET(x) (((x) & INT_STATUS_ENABLE_MBOX_DATA_MASK) >> INT_STATUS_ENABLE_MBOX_DATA_LSB)
16683 +#define INT_STATUS_ENABLE_MBOX_DATA_SET(x) (((x) << INT_STATUS_ENABLE_MBOX_DATA_LSB) & INT_STATUS_ENABLE_MBOX_DATA_MASK)
16685 +#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_MSB 1
16686 +#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB 1
16687 +#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x00000002
16688 +#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_GET(x) (((x) & ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK) >> ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB)
16689 +#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_SET(x) (((x) << ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB) & ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK)
16691 +#define ERROR_STATUS_ENABLE_TX_OVERFLOW_MSB 0
16692 +#define ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB 0
16693 +#define ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK 0x00000001
16694 +#define ERROR_STATUS_ENABLE_TX_OVERFLOW_GET(x) (((x) & ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK) >> ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB)
16695 +#define ERROR_STATUS_ENABLE_TX_OVERFLOW_SET(x) (((x) << ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB) & ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK)
16698 +#define CPU_INT_STATUS_ENABLE_BIT_MSB 7
16699 +#define CPU_INT_STATUS_ENABLE_BIT_LSB 0
16700 +#define CPU_INT_STATUS_ENABLE_BIT_MASK 0x000000ff
16701 +#define CPU_INT_STATUS_ENABLE_BIT_GET(x) (((x) & CPU_INT_STATUS_ENABLE_BIT_MASK) >> CPU_INT_STATUS_ENABLE_BIT_LSB)
16702 +#define CPU_INT_STATUS_ENABLE_BIT_SET(x) (((x) << CPU_INT_STATUS_ENABLE_BIT_LSB) & CPU_INT_STATUS_ENABLE_BIT_MASK)
16704 +#define COUNTER_INT_STATUS_ENABLE_BIT_MSB 7
16705 +#define COUNTER_INT_STATUS_ENABLE_BIT_LSB 0
16706 +#define COUNTER_INT_STATUS_ENABLE_BIT_MASK 0x000000ff
16707 +#define COUNTER_INT_STATUS_ENABLE_BIT_GET(x) (((x) & COUNTER_INT_STATUS_ENABLE_BIT_MASK) >> COUNTER_INT_STATUS_ENABLE_BIT_LSB)
16708 +#define COUNTER_INT_STATUS_ENABLE_BIT_SET(x) (((x) << COUNTER_INT_STATUS_ENABLE_BIT_LSB) & COUNTER_INT_STATUS_ENABLE_BIT_MASK)
16710 +#define ERROR_INT_STATUS_WAKEUP_MSB 2
16711 +#define ERROR_INT_STATUS_WAKEUP_LSB 2
16712 +#define ERROR_INT_STATUS_WAKEUP_MASK 0x00000004
16713 +#define ERROR_INT_STATUS_WAKEUP_GET(x) (((x) & ERROR_INT_STATUS_WAKEUP_MASK) >> ERROR_INT_STATUS_WAKEUP_LSB)
16714 +#define ERROR_INT_STATUS_WAKEUP_SET(x) (((x) << ERROR_INT_STATUS_WAKEUP_LSB) & ERROR_INT_STATUS_WAKEUP_MASK)
16716 +#define ERROR_INT_STATUS_RX_UNDERFLOW_MSB 1
16717 +#define ERROR_INT_STATUS_RX_UNDERFLOW_LSB 1
16718 +#define ERROR_INT_STATUS_RX_UNDERFLOW_MASK 0x00000002
16719 +#define ERROR_INT_STATUS_RX_UNDERFLOW_GET(x) (((x) & ERROR_INT_STATUS_RX_UNDERFLOW_MASK) >> ERROR_INT_STATUS_RX_UNDERFLOW_LSB)
16720 +#define ERROR_INT_STATUS_RX_UNDERFLOW_SET(x) (((x) << ERROR_INT_STATUS_RX_UNDERFLOW_LSB) & ERROR_INT_STATUS_RX_UNDERFLOW_MASK)
16722 +#define ERROR_INT_STATUS_TX_OVERFLOW_MSB 0
16723 +#define ERROR_INT_STATUS_TX_OVERFLOW_LSB 0
16724 +#define ERROR_INT_STATUS_TX_OVERFLOW_MASK 0x00000001
16725 +#define ERROR_INT_STATUS_TX_OVERFLOW_GET(x) (((x) & ERROR_INT_STATUS_TX_OVERFLOW_MASK) >> ERROR_INT_STATUS_TX_OVERFLOW_LSB)
16726 +#define ERROR_INT_STATUS_TX_OVERFLOW_SET(x) (((x) << ERROR_INT_STATUS_TX_OVERFLOW_LSB) & ERROR_INT_STATUS_TX_OVERFLOW_MASK)
16728 +#define HOST_INT_STATUS_ERROR_MSB 7
16729 +#define HOST_INT_STATUS_ERROR_LSB 7
16730 +#define HOST_INT_STATUS_ERROR_MASK 0x00000080
16731 +#define HOST_INT_STATUS_ERROR_GET(x) (((x) & HOST_INT_STATUS_ERROR_MASK) >> HOST_INT_STATUS_ERROR_LSB)
16732 +#define HOST_INT_STATUS_ERROR_SET(x) (((x) << HOST_INT_STATUS_ERROR_LSB) & HOST_INT_STATUS_ERROR_MASK)
16734 +#define HOST_INT_STATUS_CPU_MSB 6
16735 +#define HOST_INT_STATUS_CPU_LSB 6
16736 +#define HOST_INT_STATUS_CPU_MASK 0x00000040
16737 +#define HOST_INT_STATUS_CPU_GET(x) (((x) & HOST_INT_STATUS_CPU_MASK) >> HOST_INT_STATUS_CPU_LSB)
16738 +#define HOST_INT_STATUS_CPU_SET(x) (((x) << HOST_INT_STATUS_CPU_LSB) & HOST_INT_STATUS_CPU_MASK)
16740 +#define HOST_INT_STATUS_COUNTER_MSB 4
16741 +#define HOST_INT_STATUS_COUNTER_LSB 4
16742 +#define HOST_INT_STATUS_COUNTER_MASK 0x00000010
16743 +#define HOST_INT_STATUS_COUNTER_GET(x) (((x) & HOST_INT_STATUS_COUNTER_MASK) >> HOST_INT_STATUS_COUNTER_LSB)
16744 +#define HOST_INT_STATUS_COUNTER_SET(x) (((x) << HOST_INT_STATUS_COUNTER_LSB) & HOST_INT_STATUS_COUNTER_MASK)
16746 +#define RESET_CONTROL_WARM_RST_MSB 7
16747 +#define RESET_CONTROL_WARM_RST_LSB 7
16748 +#define RESET_CONTROL_WARM_RST_MASK 0x00000080
16749 +#define RESET_CONTROL_WARM_RST_GET(x) (((x) & RESET_CONTROL_WARM_RST_MASK) >> RESET_CONTROL_WARM_RST_LSB)
16750 +#define RESET_CONTROL_WARM_RST_SET(x) (((x) << RESET_CONTROL_WARM_RST_LSB) & RESET_CONTROL_WARM_RST_MASK)
16752 +#define RESET_CONTROL_COLD_RST_MSB 8
16753 +#define RESET_CONTROL_COLD_RST_LSB 8
16754 +#define RESET_CONTROL_COLD_RST_MASK 0x00000100
16755 +#define RESET_CONTROL_COLD_RST_GET(x) (((x) & RESET_CONTROL_COLD_RST_MASK) >> RESET_CONTROL_COLD_RST_LSB)
16756 +#define RESET_CONTROL_COLD_RST_SET(x) (((x) << RESET_CONTROL_COLD_RST_LSB) & RESET_CONTROL_COLD_RST_MASK)
16758 +#define RESET_CAUSE_LAST_MSB 2
16759 +#define RESET_CAUSE_LAST_LSB 0
16760 +#define RESET_CAUSE_LAST_MASK 0x00000007
16761 +#define RESET_CAUSE_LAST_GET(x) (((x) & RESET_CAUSE_LAST_MASK) >> RESET_CAUSE_LAST_LSB)
16762 +#define RESET_CAUSE_LAST_SET(x) (((x) << RESET_CAUSE_LAST_LSB) & RESET_CAUSE_LAST_MASK)
16764 +#ifdef __cplusplus
16768 +#endif /* __AR6KHWREG_H__ */
16769 diff --git a/drivers/sdio/function/wlan/ar6000/include/a_config.h b/drivers/sdio/function/wlan/ar6000/include/a_config.h
16770 new file mode 100644
16771 index 0000000..627b298
16773 +++ b/drivers/sdio/function/wlan/ar6000/include/a_config.h
16775 +#ifndef _A_CONFIG_H_
16776 +#define _A_CONFIG_H_
16778 + * Copyright (c) 2004-2005 Atheros Communications Inc.
16779 + * All rights reserved.
16782 + * This program is free software; you can redistribute it and/or modify
16783 + * it under the terms of the GNU General Public License version 2 as
16784 + * published by the Free Software Foundation;
16786 + * Software distributed under the License is distributed on an "AS
16787 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16788 + * implied. See the License for the specific language governing
16789 + * rights and limitations under the License.
16796 + * This file contains software configuration options that enables
16797 + * specific software "features"
16799 +#include "../ar6000/config_linux.h"
16802 diff --git a/drivers/sdio/function/wlan/ar6000/include/a_debug.h b/drivers/sdio/function/wlan/ar6000/include/a_debug.h
16803 new file mode 100644
16804 index 0000000..4b0b351
16806 +++ b/drivers/sdio/function/wlan/ar6000/include/a_debug.h
16808 +#ifndef _A_DEBUG_H_
16809 +#define _A_DEBUG_H_
16811 + * Copyright (c) 2004-2006 Atheros Communications Inc.
16812 + * All rights reserved.
16814 + * Copyright (c) 2004-2007 Atheros Communications Inc.
16815 + * All rights reserved.
16818 + * This program is free software; you can redistribute it and/or modify
16819 + * it under the terms of the GNU General Public License version 2 as
16820 + * published by the Free Software Foundation;
16822 + * Software distributed under the License is distributed on an "AS
16823 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16824 + * implied. See the License for the specific language governing
16825 + * rights and limitations under the License.
16831 +#include <a_types.h>
16832 +#include <a_osapi.h>
16834 +#define DBG_INFO 0x00000001
16835 +#define DBG_ERROR 0x00000002
16836 +#define DBG_WARNING 0x00000004
16837 +#define DBG_SDIO 0x00000008
16838 +#define DBG_HIF 0x00000010
16839 +#define DBG_HTC 0x00000020
16840 +#define DBG_WMI 0x00000040
16841 +#define DBG_WMI2 0x00000080
16842 +#define DBG_DRIVER 0x00000100
16844 +#define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING)
16846 +#include "../ar6000/debug_linux.h"
16849 diff --git a/drivers/sdio/function/wlan/ar6000/include/a_drv.h b/drivers/sdio/function/wlan/ar6000/include/a_drv.h
16850 new file mode 100644
16851 index 0000000..07e52d1
16853 +++ b/drivers/sdio/function/wlan/ar6000/include/a_drv.h
16858 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/a_drv.h#1 $
16860 + * This file contains the definitions of the basic atheros data types.
16861 + * It is used to map the data types in atheros files to a platform specific
16864 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
16867 + * This program is free software; you can redistribute it and/or modify
16868 + * it under the terms of the GNU General Public License version 2 as
16869 + * published by the Free Software Foundation;
16871 + * Software distributed under the License is distributed on an "AS
16872 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16873 + * implied. See the License for the specific language governing
16874 + * rights and limitations under the License.
16880 +#include "../ar6000/athdrv_linux.h"
16882 +#endif /* _ADRV_H_ */
16883 diff --git a/drivers/sdio/function/wlan/ar6000/include/a_drv_api.h b/drivers/sdio/function/wlan/ar6000/include/a_drv_api.h
16884 new file mode 100644
16885 index 0000000..7531726
16887 +++ b/drivers/sdio/function/wlan/ar6000/include/a_drv_api.h
16889 +#ifndef _A_DRV_API_H_
16890 +#define _A_DRV_API_H_
16892 + * Copyright (c) 2004-2006 Atheros Communications Inc.
16893 + * All rights reserved.
16896 + * This program is free software; you can redistribute it and/or modify
16897 + * it under the terms of the GNU General Public License version 2 as
16898 + * published by the Free Software Foundation;
16900 + * Software distributed under the License is distributed on an "AS
16901 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16902 + * implied. See the License for the specific language governing
16903 + * rights and limitations under the License.
16909 +#ifdef __cplusplus
16913 +/****************************************************************************/
16914 +/****************************************************************************/
16916 +/** WMI related hooks **/
16918 +/****************************************************************************/
16919 +/****************************************************************************/
16921 +#include <ar6000_api.h>
16923 +#define A_WMI_CHANNELLIST_RX(devt, numChan, chanList) \
16924 + ar6000_channelList_rx((devt), (numChan), (chanList))
16926 +#define A_WMI_SET_NUMDATAENDPTS(devt, num) \
16927 + ar6000_set_numdataendpts((devt), (num))
16929 +#define A_WMI_CONTROL_TX(devt, osbuf, streamID) \
16930 + ar6000_control_tx((devt), (osbuf), (streamID))
16932 +#define A_WMI_TARGETSTATS_EVENT(devt, pStats) \
16933 + ar6000_targetStats_event((devt), (pStats))
16935 +#define A_WMI_SCANCOMPLETE_EVENT(devt, status) \
16936 + ar6000_scanComplete_event((devt), (status))
16938 +#ifdef CONFIG_HOST_DSET_SUPPORT
16940 +#define A_WMI_DSET_DATA_REQ(devt, access_cookie, offset, length, targ_buf, targ_reply_fn, targ_reply_arg) \
16941 + ar6000_dset_data_req((devt), (access_cookie), (offset), (length), (targ_buf), (targ_reply_fn), (targ_reply_arg))
16943 +#define A_WMI_DSET_CLOSE(devt, access_cookie) \
16944 + ar6000_dset_close((devt), (access_cookie))
16948 +#define A_WMI_DSET_OPEN_REQ(devt, id, targ_handle, targ_reply_fn, targ_reply_arg) \
16949 + ar6000_dset_open_req((devt), (id), (targ_handle), (targ_reply_fn), (targ_reply_arg))
16951 +#define A_WMI_CONNECT_EVENT(devt, channel, bssid, listenInterval, beaconInterval, networkType, beaconIeLen, assocReqLen, assocRespLen, assocInfo) \
16952 + ar6000_connect_event((devt), (channel), (bssid), (listenInterval), (beaconInterval), (networkType), (beaconIeLen), (assocReqLen), (assocRespLen), (assocInfo))
16954 +#define A_WMI_REGDOMAIN_EVENT(devt, regCode) \
16955 + ar6000_regDomain_event((devt), (regCode))
16957 +#define A_WMI_NEIGHBORREPORT_EVENT(devt, numAps, info) \
16958 + ar6000_neighborReport_event((devt), (numAps), (info))
16960 +#define A_WMI_DISCONNECT_EVENT(devt, reason, bssid, assocRespLen, assocInfo, protocolReasonStatus) \
16961 + ar6000_disconnect_event((devt), (reason), (bssid), (assocRespLen), (assocInfo), (protocolReasonStatus))
16963 +#define A_WMI_TKIP_MICERR_EVENT(devt, keyid, ismcast) \
16964 + ar6000_tkip_micerr_event((devt), (keyid), (ismcast))
16966 +#define A_WMI_BITRATE_RX(devt, rateKbps) \
16967 + ar6000_bitrate_rx((devt), (rateKbps))
16969 +#define A_WMI_TXPWR_RX(devt, txPwr) \
16970 + ar6000_txPwr_rx((devt), (txPwr))
16972 +#define A_WMI_READY_EVENT(devt, datap, phyCap) \
16973 + ar6000_ready_event((devt), (datap), (phyCap))
16975 +#define A_WMI_DBGLOG_INIT_DONE(ar) \
16976 + ar6000_dbglog_init_done(ar);
16978 +#define A_WMI_RSSI_THRESHOLD_EVENT(devt, newThreshold, rssi) \
16979 + ar6000_rssiThreshold_event((devt), (newThreshold), (rssi))
16981 +#define A_WMI_REPORT_ERROR_EVENT(devt, errorVal) \
16982 + ar6000_reportError_event((devt), (errorVal))
16984 +#define A_WMI_ROAM_TABLE_EVENT(devt, pTbl) \
16985 + ar6000_roam_tbl_event((devt), (pTbl))
16987 +#define A_WMI_ROAM_DATA_EVENT(devt, p) \
16988 + ar6000_roam_data_event((devt), (p))
16990 +#define A_WMI_WOW_LIST_EVENT(devt, num_filters, wow_filters) \
16991 + ar6000_wow_list_event((devt), (num_filters), (wow_filters))
16993 +#define A_WMI_CAC_EVENT(devt, ac, cac_indication, statusCode, tspecSuggestion) \
16994 + ar6000_cac_event((devt), (ac), (cac_indication), (statusCode), (tspecSuggestion))
16996 +#define A_WMI_IPTOS_TO_USERPRIORITY(pkt) \
16997 + ar6000_iptos_to_userPriority((pkt))
16999 +#define A_WMI_PMKID_LIST_EVENT(devt, num_pmkid, pmkid_list) \
17000 + ar6000_pmkid_list_event((devt), (num_pmkid), (pmkid_list))
17002 +#ifdef CONFIG_HOST_GPIO_SUPPORT
17004 +#define A_WMI_GPIO_INTR_RX(intr_mask, input_values) \
17005 + ar6000_gpio_intr_rx((intr_mask), (input_values))
17007 +#define A_WMI_GPIO_DATA_RX(reg_id, value) \
17008 + ar6000_gpio_data_rx((reg_id), (value))
17010 +#define A_WMI_GPIO_ACK_RX() \
17011 + ar6000_gpio_ack_rx()
17015 +#ifdef SEND_EVENT_TO_APP
17017 +#define A_WMI_SEND_EVENT_TO_APP(ar, eventId, datap, len) \
17018 + ar6000_send_event_to_app((ar), (eventId), (datap), (len))
17022 +#define A_WMI_SEND_EVENT_TO_APP(ar, eventId, datap, len)
17026 +#ifdef CONFIG_HOST_TCMD_SUPPORT
17027 +#define A_WMI_TCMD_RX_REPORT_EVENT(devt, results, len) \
17028 + ar6000_tcmd_rx_report_event((devt), (results), (len))
17031 +#define A_WMI_HBCHALLENGERESP_EVENT(devt, cookie, source) \
17032 + ar6000_hbChallengeResp_event((devt), (cookie), (source))
17034 +#define A_WMI_TX_RETRY_ERR_EVENT(devt) \
17035 + ar6000_tx_retry_err_event((devt))
17037 +#define A_WMI_SNR_THRESHOLD_EVENT_RX(devt, newThreshold, snr) \
17038 + ar6000_snrThresholdEvent_rx((devt), (newThreshold), (snr))
17040 +#define A_WMI_LQ_THRESHOLD_EVENT_RX(devt, range, lqVal) \
17041 + ar6000_lqThresholdEvent_rx((devt), (range), (lqVal))
17043 +#define A_WMI_RATEMASK_RX(devt, ratemask) \
17044 + ar6000_ratemask_rx((devt), (ratemask))
17046 +#define A_WMI_KEEPALIVE_RX(devt, configured) \
17047 + ar6000_keepalive_rx((devt), (configured))
17049 +#define A_WMI_BSSINFO_EVENT_RX(ar, datp, len) \
17050 + ar6000_bssInfo_event_rx((ar), (datap), (len))
17052 +#define A_WMI_DBGLOG_EVENT(ar, dropped, buffer, length) \
17053 + ar6000_dbglog_event((ar), (dropped), (buffer), (length));
17055 +#define A_WMI_STREAM_TX_ACTIVE(devt,trafficClass) \
17056 + ar6000_indicate_tx_activity((devt),(trafficClass), TRUE)
17058 +#define A_WMI_STREAM_TX_INACTIVE(devt,trafficClass) \
17059 + ar6000_indicate_tx_activity((devt),(trafficClass), FALSE)
17061 +/****************************************************************************/
17062 +/****************************************************************************/
17064 +/** HTC related hooks **/
17066 +/****************************************************************************/
17067 +/****************************************************************************/
17069 +#ifdef __cplusplus
17074 diff --git a/drivers/sdio/function/wlan/ar6000/include/a_osapi.h b/drivers/sdio/function/wlan/ar6000/include/a_osapi.h
17075 new file mode 100644
17076 index 0000000..7d60867
17078 +++ b/drivers/sdio/function/wlan/ar6000/include/a_osapi.h
17080 +#ifndef _A_OSAPI_H_
17081 +#define _A_OSAPI_H_
17083 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/a_osapi.h#1 $
17085 + * This file contains the definitions of the basic atheros data types.
17086 + * It is used to map the data types in atheros files to a platform specific
17089 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
17092 + * This program is free software; you can redistribute it and/or modify
17093 + * it under the terms of the GNU General Public License version 2 as
17094 + * published by the Free Software Foundation;
17096 + * Software distributed under the License is distributed on an "AS
17097 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17098 + * implied. See the License for the specific language governing
17099 + * rights and limitations under the License.
17105 +#include "../ar6000/osapi_linux.h"
17107 +#endif /* _OSAPI_H_ */
17108 diff --git a/drivers/sdio/function/wlan/ar6000/include/a_types.h b/drivers/sdio/function/wlan/ar6000/include/a_types.h
17109 new file mode 100644
17110 index 0000000..e2ed090
17112 +++ b/drivers/sdio/function/wlan/ar6000/include/a_types.h
17114 +#ifndef _A_TYPES_H_
17115 +#define _A_TYPES_H_
17117 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/a_types.h#1 $
17119 + * This file contains the definitions of the basic atheros data types.
17120 + * It is used to map the data types in atheros files to a platform specific
17123 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
17126 + * This program is free software; you can redistribute it and/or modify
17127 + * it under the terms of the GNU General Public License version 2 as
17128 + * published by the Free Software Foundation;
17130 + * Software distributed under the License is distributed on an "AS
17131 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17132 + * implied. See the License for the specific language governing
17133 + * rights and limitations under the License.
17139 +#include "../ar6000/athtypes_linux.h"
17141 +#endif /* _ATHTYPES_H_ */
17142 diff --git a/drivers/sdio/function/wlan/ar6000/include/ar6000_api.h b/drivers/sdio/function/wlan/ar6000/include/ar6000_api.h
17143 new file mode 100644
17144 index 0000000..abe5de7
17146 +++ b/drivers/sdio/function/wlan/ar6000/include/ar6000_api.h
17148 +#ifndef _AR6000_API_H_
17149 +#define _AR6000_API_H_
17151 + * Copyright (c) 2004-2005 Atheros Communications Inc.
17152 + * All rights reserved.
17154 + * This file contains the API to access the OS dependent atheros host driver
17155 + * by the WMI or WLAN generic modules.
17157 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/ar6000_api.h#1 $
17160 + * This program is free software; you can redistribute it and/or modify
17161 + * it under the terms of the GNU General Public License version 2 as
17162 + * published by the Free Software Foundation;
17164 + * Software distributed under the License is distributed on an "AS
17165 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17166 + * implied. See the License for the specific language governing
17167 + * rights and limitations under the License.
17173 +#include "../ar6000/ar6xapi_linux.h"
17175 +#endif /* _AR6000_API_H */
17177 diff --git a/drivers/sdio/function/wlan/ar6000/include/ar6000_diag.h b/drivers/sdio/function/wlan/ar6000/include/ar6000_diag.h
17178 new file mode 100644
17179 index 0000000..2df131d
17181 +++ b/drivers/sdio/function/wlan/ar6000/include/ar6000_diag.h
17185 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17186 + * All rights reserved.
17189 + * This program is free software; you can redistribute it and/or modify
17190 + * it under the terms of the GNU General Public License version 2 as
17191 + * published by the Free Software Foundation;
17193 + * Software distributed under the License is distributed on an "AS
17194 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17195 + * implied. See the License for the specific language governing
17196 + * rights and limitations under the License.
17202 +#ifndef AR6000_DIAG_H_
17203 +#define AR6000_DIAG_H_
17207 +ar6000_ReadRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
17210 +ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
17213 +ar6000_ReadDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address,
17214 + A_UCHAR *data, A_UINT32 length);
17217 +ar6000_WriteDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address,
17218 + A_UCHAR *data, A_UINT32 length);
17220 +#endif /*AR6000_DIAG_H_*/
17221 diff --git a/drivers/sdio/function/wlan/ar6000/include/athdefs.h b/drivers/sdio/function/wlan/ar6000/include/athdefs.h
17222 new file mode 100644
17223 index 0000000..c28c871
17225 +++ b/drivers/sdio/function/wlan/ar6000/include/athdefs.h
17227 +#ifndef __ATHDEFS_H__
17228 +#define __ATHDEFS_H__
17231 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17232 + * All rights reserved.
17234 + * $ATH_LICENSE_HOSTSDK0_C$
17236 + * This file contains definitions that may be used across both
17237 + * Host and Target software. Nothing here is module-dependent
17238 + * or platform-dependent.
17242 + * Generic error codes that can be used by hw, sta, ap, sim, dk
17243 + * and any other environments. Since these are enums, feel free to
17244 + * add any more codes that you need.
17248 + A_ERROR = -1, /* Generic error return */
17249 + A_OK = 0, /* success */
17250 + /* Following values start at 1 */
17251 + A_DEVICE_NOT_FOUND, /* not able to find PCI device */
17252 + A_NO_MEMORY, /* not able to allocate memory, not available */
17253 + A_MEMORY_NOT_AVAIL, /* memory region is not free for mapping */
17254 + A_NO_FREE_DESC, /* no free descriptors available */
17255 + A_BAD_ADDRESS, /* address does not match descriptor */
17256 + A_WIN_DRIVER_ERROR, /* used in NT_HW version, if problem at init */
17257 + A_REGS_NOT_MAPPED, /* registers not correctly mapped */
17258 + A_EPERM, /* Not superuser */
17259 + A_EACCES, /* Access denied */
17260 + A_ENOENT, /* No such entry, search failed, etc. */
17261 + A_EEXIST, /* The object already exists (can't create) */
17262 + A_EFAULT, /* Bad address fault */
17263 + A_EBUSY, /* Object is busy */
17264 + A_EINVAL, /* Invalid parameter */
17265 + A_EMSGSIZE, /* Inappropriate message buffer length */
17266 + A_ECANCELED, /* Operation canceled */
17267 + A_ENOTSUP, /* Operation not supported */
17268 + A_ECOMM, /* Communication error on send */
17269 + A_EPROTO, /* Protocol error */
17270 + A_ENODEV, /* No such device */
17271 + A_EDEVNOTUP, /* device is not UP */
17272 + A_NO_RESOURCE, /* No resources for requested operation */
17273 + A_HARDWARE, /* Hardware failure */
17274 + A_PENDING, /* Asynchronous routine; will send up results la
17275 +ter (typically in callback) */
17276 + A_EBADCHANNEL, /* The channel cannot be used */
17277 + A_DECRYPT_ERROR, /* Decryption error */
17278 + A_PHY_ERROR, /* RX PHY error */
17279 + A_CONSUMED /* Object was consumed */
17282 +#define A_SUCCESS(x) (x == A_OK)
17283 +#define A_FAILED(x) (!A_SUCCESS(x))
17294 + * The following definition is WLAN specific definition
17297 + MODE_11A = 0, /* 11a Mode */
17298 + MODE_11G = 1, /* 11g + 11b Mode */
17299 + MODE_11B = 2, /* 11b Mode */
17300 + MODE_11GONLY = 3, /* 11g only Mode */
17301 + MODE_UNKNOWN = 4,
17306 + WLAN_11A_CAPABILITY = 1,
17307 + WLAN_11G_CAPABILITY = 2,
17308 + WLAN_11AG_CAPABILITY = 3,
17311 +#endif /* __ATHDEFS_H__ */
17312 diff --git a/drivers/sdio/function/wlan/ar6000/include/athdrv.h b/drivers/sdio/function/wlan/ar6000/include/athdrv.h
17313 new file mode 100644
17314 index 0000000..19da97e
17316 +++ b/drivers/sdio/function/wlan/ar6000/include/athdrv.h
17319 + * Copyright (c) 2004-2006 Atheros Communications Inc.
17320 + * All rights reserved.
17324 + * This program is free software; you can redistribute it and/or modify
17325 + * it under the terms of the GNU General Public License version 2 as
17326 + * published by the Free Software Foundation;
17328 + * Software distributed under the License is distributed on an "AS
17329 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17330 + * implied. See the License for the specific language governing
17331 + * rights and limitations under the License.
17337 +#ifndef _ATHDRV_H_
17338 +#define _ATHDRV_H_
17340 +#ifdef __cplusplus
17345 +#ifdef __cplusplus
17349 +#endif /* _ATHDRV_H_ */
17350 diff --git a/drivers/sdio/function/wlan/ar6000/include/athendpack.h b/drivers/sdio/function/wlan/ar6000/include/athendpack.h
17351 new file mode 100644
17352 index 0000000..42921ae
17354 +++ b/drivers/sdio/function/wlan/ar6000/include/athendpack.h
17356 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17357 + * @file: athendpack.h
17359 + * @abstract: end compiler-specific structure packing
17361 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17362 + * All rights reserved.
17365 + * This program is free software; you can redistribute it and/or modify
17366 + * it under the terms of the GNU General Public License version 2 as
17367 + * published by the Free Software Foundation;
17369 + * Software distributed under the License is distributed on an "AS
17370 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17371 + * implied. See the License for the specific language governing
17372 + * rights and limitations under the License.
17378 +#endif /* VXWORKS */
17381 +#endif /* LINUX */
17387 +#include "integrity/athendpack_integrity.h"
17388 +#endif /* INTEGRITY */
17391 +#endif /* NUCLEUS */
17394 +#include "../os/wince/include/athendpack_wince.h"
17395 +#endif /* WINCE */
17397 diff --git a/drivers/sdio/function/wlan/ar6000/include/athstartpack.h b/drivers/sdio/function/wlan/ar6000/include/athstartpack.h
17398 new file mode 100644
17399 index 0000000..6632cc2
17401 +++ b/drivers/sdio/function/wlan/ar6000/include/athstartpack.h
17403 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17404 + * @file: athstartpack.h
17406 + * @abstract: start compiler-specific structure packing
17408 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17409 + * All rights reserved.
17412 + * This program is free software; you can redistribute it and/or modify
17413 + * it under the terms of the GNU General Public License version 2 as
17414 + * published by the Free Software Foundation;
17416 + * Software distributed under the License is distributed on an "AS
17417 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17418 + * implied. See the License for the specific language governing
17419 + * rights and limitations under the License.
17426 +#endif /* VXWORKS */
17429 +#endif /* LINUX */
17435 +#include "integrity/athstartpack_integrity.h"
17436 +#endif /* INTEGRITY */
17439 +#endif /* NUCLEUS */
17442 +#include "../os/wince/include/athstartpack_wince.h"
17443 +#endif /* WINCE */
17445 diff --git a/drivers/sdio/function/wlan/ar6000/include/bmi.h b/drivers/sdio/function/wlan/ar6000/include/bmi.h
17446 new file mode 100644
17447 index 0000000..2eb7134
17449 +++ b/drivers/sdio/function/wlan/ar6000/include/bmi.h
17454 + * Copyright (c) 2004-2005 Atheros Communications Inc.
17455 + * All rights reserved.
17458 + * This program is free software; you can redistribute it and/or modify
17459 + * it under the terms of the GNU General Public License version 2 as
17460 + * published by the Free Software Foundation;
17462 + * Software distributed under the License is distributed on an "AS
17463 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17464 + * implied. See the License for the specific language governing
17465 + * rights and limitations under the License.
17469 + * BMI declarations and prototypes
17472 +#ifdef __cplusplus
17474 +#endif /* __cplusplus */
17476 +/* Header files */
17477 +#include "a_config.h"
17478 +#include "athdefs.h"
17479 +#include "a_types.h"
17481 +#include "a_osapi.h"
17482 +#include "bmi_msg.h"
17488 +BMIDone(HIF_DEVICE *device);
17491 +BMIGetTargetInfo(HIF_DEVICE *device, struct bmi_target_info *targ_info);
17494 +BMIReadMemory(HIF_DEVICE *device,
17495 + A_UINT32 address,
17497 + A_UINT32 length);
17500 +BMIWriteMemory(HIF_DEVICE *device,
17501 + A_UINT32 address,
17503 + A_UINT32 length);
17506 +BMIExecute(HIF_DEVICE *device,
17507 + A_UINT32 address,
17508 + A_UINT32 *param);
17511 +BMISetAppStart(HIF_DEVICE *device,
17512 + A_UINT32 address);
17515 +BMIReadSOCRegister(HIF_DEVICE *device,
17516 + A_UINT32 address,
17517 + A_UINT32 *param);
17520 +BMIWriteSOCRegister(HIF_DEVICE *device,
17521 + A_UINT32 address,
17525 +BMIrompatchInstall(HIF_DEVICE *device,
17526 + A_UINT32 ROM_addr,
17527 + A_UINT32 RAM_addr,
17529 + A_UINT32 do_activate,
17530 + A_UINT32 *patch_id);
17533 +BMIrompatchUninstall(HIF_DEVICE *device,
17534 + A_UINT32 rompatch_id);
17537 +BMIrompatchActivate(HIF_DEVICE *device,
17538 + A_UINT32 rompatch_count,
17539 + A_UINT32 *rompatch_list);
17542 +BMIrompatchDeactivate(HIF_DEVICE *device,
17543 + A_UINT32 rompatch_count,
17544 + A_UINT32 *rompatch_list);
17546 +#ifdef __cplusplus
17550 +#endif /* _BMI_H_ */
17551 diff --git a/drivers/sdio/function/wlan/ar6000/include/bmi_msg.h b/drivers/sdio/function/wlan/ar6000/include/bmi_msg.h
17552 new file mode 100644
17553 index 0000000..7c91ef4
17555 +++ b/drivers/sdio/function/wlan/ar6000/include/bmi_msg.h
17557 +#ifndef __BMI_MSG_H__
17558 +#define __BMI_MSG_H__
17561 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17562 + * All rights reserved.
17565 + * This program is free software; you can redistribute it and/or modify
17566 + * it under the terms of the GNU General Public License version 2 as
17567 + * published by the Free Software Foundation;
17569 + * Software distributed under the License is distributed on an "AS
17570 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17571 + * implied. See the License for the specific language governing
17572 + * rights and limitations under the License.
17579 + * Bootloader Messaging Interface (BMI)
17581 + * BMI is a very simple messaging interface used during initialization
17582 + * to read memory, write memory, execute code, and to define an
17583 + * application entry PC.
17585 + * It is used to download an application to AR6K, to provide
17586 + * patches to code that is already resident on AR6K, and generally
17587 + * to examine and modify state. The Host has an opportunity to use
17588 + * BMI only once during bootup. Once the Host issues a BMI_DONE
17589 + * command, this opportunity ends.
17591 + * The Host writes BMI requests to mailbox0, and reads BMI responses
17592 + * from mailbox0. BMI requests all begin with a command
17593 + * (see below for specific commands), and are followed by
17594 + * command-specific data.
17597 + * The Host can only issue a command once the Target gives it a
17598 + * "BMI Command Credit", using AR6K Counter #4. As soon as the
17599 + * Target has completed a command, it issues another BMI Command
17600 + * Credit (so the Host can issue the next command).
17602 + * BMI handles all required Target-side cache flushing.
17606 +/* Maximum data size used for BMI transfers */
17607 +#define BMI_DATASZ_MAX 32
17609 +/* BMI Commands */
17611 +#define BMI_NO_COMMAND 0
17613 +#define BMI_DONE 1
17615 + * Semantics: Host is done using BMI
17616 + * Request format:
17617 + * A_UINT32 command (BMI_DONE)
17618 + * Response format: none
17621 +#define BMI_READ_MEMORY 2
17623 + * Semantics: Host reads AR6K memory
17624 + * Request format:
17625 + * A_UINT32 command (BMI_READ_MEMORY)
17626 + * A_UINT32 address
17627 + * A_UINT32 length, at most BMI_DATASZ_MAX
17628 + * Response format:
17629 + * A_UINT8 data[length]
17632 +#define BMI_WRITE_MEMORY 3
17634 + * Semantics: Host writes AR6K memory
17635 + * Request format:
17636 + * A_UINT32 command (BMI_WRITE_MEMORY)
17637 + * A_UINT32 address
17638 + * A_UINT32 length, at most BMI_DATASZ_MAX
17639 + * A_UINT8 data[length]
17640 + * Response format: none
17643 +#define BMI_EXECUTE 4
17645 + * Semantics: Causes AR6K to execute code
17646 + * Request format:
17647 + * A_UINT32 command (BMI_EXECUTE)
17648 + * A_UINT32 address
17649 + * A_UINT32 parameter
17650 + * Response format:
17651 + * A_UINT32 return value
17654 +#define BMI_SET_APP_START 5
17656 + * Semantics: Set Target application starting address
17657 + * Request format:
17658 + * A_UINT32 command (BMI_SET_APP_START)
17659 + * A_UINT32 address
17660 + * Response format: none
17663 +#define BMI_READ_SOC_REGISTER 6
17665 + * Semantics: Read a 32-bit Target SOC register.
17666 + * Request format:
17667 + * A_UINT32 command (BMI_READ_REGISTER)
17668 + * A_UINT32 address
17669 + * Response format:
17673 +#define BMI_WRITE_SOC_REGISTER 7
17675 + * Semantics: Write a 32-bit Target SOC register.
17676 + * Request format:
17677 + * A_UINT32 command (BMI_WRITE_REGISTER)
17678 + * A_UINT32 address
17681 + * Response format: none
17684 +#define BMI_GET_TARGET_ID 8
17685 +#define BMI_GET_TARGET_INFO 8
17687 + * Semantics: Fetch the 4-byte Target information
17688 + * Request format:
17689 + * A_UINT32 command (BMI_GET_TARGET_ID/INFO)
17690 + * Response format1 (old firmware):
17691 + * A_UINT32 TargetVersionID
17692 + * Response format2 (newer firmware):
17693 + * A_UINT32 TARGET_VERSION_SENTINAL
17694 + * struct bmi_target_info;
17697 +struct bmi_target_info {
17698 + A_UINT32 target_info_byte_count; /* size of this structure */
17699 + A_UINT32 target_ver; /* Target Version ID */
17700 + A_UINT32 target_type; /* Target type */
17702 +#define TARGET_VERSION_SENTINAL 0xffffffff
17703 +#define TARGET_TYPE_AR6001 1
17704 +#define TARGET_TYPE_AR6002 2
17707 +#define BMI_ROMPATCH_INSTALL 9
17709 + * Semantics: Install a ROM Patch.
17710 + * Request format:
17711 + * A_UINT32 command (BMI_ROMPATCH_INSTALL)
17712 + * A_UINT32 Target ROM Address
17713 + * A_UINT32 Target RAM Address
17714 + * A_UINT32 Size, in bytes
17715 + * A_UINT32 Activate? 1-->activate;
17716 + * 0-->install but do not activate
17717 + * Response format:
17718 + * A_UINT32 PatchID
17721 +#define BMI_ROMPATCH_UNINSTALL 10
17723 + * Semantics: Uninstall a previously-installed ROM Patch,
17724 + * automatically deactivating, if necessary.
17725 + * Request format:
17726 + * A_UINT32 command (BMI_ROMPATCH_UNINSTALL)
17727 + * A_UINT32 PatchID
17729 + * Response format: none
17732 +#define BMI_ROMPATCH_ACTIVATE 11
17734 + * Semantics: Activate a list of previously-installed ROM Patches.
17735 + * Request format:
17736 + * A_UINT32 command (BMI_ROMPATCH_ACTIVATE)
17737 + * A_UINT32 rompatch_count
17738 + * A_UINT32 PatchID[rompatch_count]
17740 + * Response format: none
17743 +#define BMI_ROMPATCH_DEACTIVATE 12
17745 + * Semantics: Deactivate a list of active ROM Patches.
17746 + * Request format:
17747 + * A_UINT32 command (BMI_ROMPATCH_DEACTIVATE)
17748 + * A_UINT32 rompatch_count
17749 + * A_UINT32 PatchID[rompatch_count]
17751 + * Response format: none
17755 +#endif /* __BMI_MSG_H__ */
17756 diff --git a/drivers/sdio/function/wlan/ar6000/include/common_drv.h b/drivers/sdio/function/wlan/ar6000/include/common_drv.h
17757 new file mode 100644
17758 index 0000000..1bdc3da
17760 +++ b/drivers/sdio/function/wlan/ar6000/include/common_drv.h
17764 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17765 + * All rights reserved.
17768 + * This program is free software; you can redistribute it and/or modify
17769 + * it under the terms of the GNU General Public License version 2 as
17770 + * published by the Free Software Foundation;
17772 + * Software distributed under the License is distributed on an "AS
17773 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17774 + * implied. See the License for the specific language governing
17775 + * rights and limitations under the License.
17782 +#ifndef COMMON_DRV_H_
17783 +#define COMMON_DRV_H_
17786 +#include "htc_packet.h"
17790 +/* structure that is the state information for the default credit distribution callback
17791 + * drivers should instantiate (zero-init as well) this structure in their driver instance
17792 + * and pass it as a context to the HTC credit distribution functions */
17793 +typedef struct _COMMON_CREDIT_STATE_INFO {
17794 + int TotalAvailableCredits; /* total credits in the system at startup */
17795 + int CurrentFreeCredits; /* credits available in the pool that have not been
17796 + given out to endpoints */
17797 + HTC_ENDPOINT_CREDIT_DIST *pLowestPriEpDist; /* pointer to the lowest priority endpoint dist struct */
17798 +} COMMON_CREDIT_STATE_INFO;
17801 +/* HTC TX packet tagging definitions */
17802 +#define AR6K_CONTROL_PKT_TAG HTC_TX_PACKET_TAG_USER_DEFINED
17803 +#define AR6K_DATA_PKT_TAG (AR6K_CONTROL_PKT_TAG + 1)
17805 +#ifdef __cplusplus
17809 +/* OS-independent APIs */
17810 +A_STATUS ar6000_setup_credit_dist(HTC_HANDLE HTCHandle, COMMON_CREDIT_STATE_INFO *pCredInfo);
17811 +A_STATUS ar6000_ReadRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
17812 +A_STATUS ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
17813 +A_STATUS ar6000_ReadDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address, A_UCHAR *data, A_UINT32 length);
17814 +A_STATUS ar6000_reset_device(HIF_DEVICE *hifDevice, A_UINT32 TargetType);
17815 +void ar6000_dump_target_assert_info(HIF_DEVICE *hifDevice, A_UINT32 TargetType);
17816 +A_STATUS ar6000_reset_device_skipflash(HIF_DEVICE *hifDevice);
17818 +#ifdef __cplusplus
17822 +#endif /*COMMON_DRV_H_*/
17823 diff --git a/drivers/sdio/function/wlan/ar6000/include/dbglog.h b/drivers/sdio/function/wlan/ar6000/include/dbglog.h
17824 new file mode 100644
17825 index 0000000..3d1e528
17827 +++ b/drivers/sdio/function/wlan/ar6000/include/dbglog.h
17830 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17831 + * All rights reserved.
17833 + * $ATH_LICENSE_HOSTSDK0_C$
17835 + * This file contains the definitions and data structures associated with
17836 + * the log based debug mechanism.
17840 +#ifndef _DBGLOG_H_
17841 +#define _DBGLOG_H_
17843 +#ifdef __cplusplus
17847 +#define DBGLOG_TIMESTAMP_OFFSET 0
17848 +#define DBGLOG_TIMESTAMP_MASK 0x0000FFFF /* Bit 0-15. Contains bit
17849 + 8-23 of the LF0 timer */
17850 +#define DBGLOG_DBGID_OFFSET 16
17851 +#define DBGLOG_DBGID_MASK 0x03FF0000 /* Bit 16-25 */
17852 +#define DBGLOG_DBGID_NUM_MAX 256 /* Upper limit is width of mask */
17854 +#define DBGLOG_MODULEID_OFFSET 26
17855 +#define DBGLOG_MODULEID_MASK 0x3C000000 /* Bit 26-29 */
17856 +#define DBGLOG_MODULEID_NUM_MAX 16 /* Upper limit is width of mask */
17859 + * Please ensure that the definition of any new module intrduced is captured
17860 + * between the DBGLOG_MODULEID_START and DBGLOG_MODULEID_END defines. The
17861 + * structure is required for the parser to correctly pick up the values for
17862 + * different modules.
17864 +#define DBGLOG_MODULEID_START
17865 +#define DBGLOG_MODULEID_INF 0
17866 +#define DBGLOG_MODULEID_WMI 1
17867 +#define DBGLOG_MODULEID_CSERV 2
17868 +#define DBGLOG_MODULEID_PM 3
17869 +#define DBGLOG_MODULEID_TXRX_MGMTBUF 4
17870 +#define DBGLOG_MODULEID_TXRX_TXBUF 5
17871 +#define DBGLOG_MODULEID_TXRX_RXBUF 6
17872 +#define DBGLOG_MODULEID_WOW 7
17873 +#define DBGLOG_MODULEID_WHAL 8
17874 +#define DBGLOG_MODULEID_END
17876 +#define DBGLOG_NUM_ARGS_OFFSET 30
17877 +#define DBGLOG_NUM_ARGS_MASK 0xC0000000 /* Bit 30-31 */
17878 +#define DBGLOG_NUM_ARGS_MAX 2 /* Upper limit is width of mask */
17880 +#define DBGLOG_MODULE_LOG_ENABLE_OFFSET 0
17881 +#define DBGLOG_MODULE_LOG_ENABLE_MASK 0x0000FFFF
17883 +#define DBGLOG_REPORTING_ENABLED_OFFSET 16
17884 +#define DBGLOG_REPORTING_ENABLED_MASK 0x00010000
17886 +#define DBGLOG_TIMESTAMP_RESOLUTION_OFFSET 17
17887 +#define DBGLOG_TIMESTAMP_RESOLUTION_MASK 0x000E0000
17889 +#define DBGLOG_REPORT_SIZE_OFFSET 20
17890 +#define DBGLOG_REPORT_SIZE_MASK 0x3FF00000
17892 +#define DBGLOG_LOG_BUFFER_SIZE 1500
17893 +#define DBGLOG_DBGID_DEFINITION_LEN_MAX 64
17895 +struct dbglog_buf_s {
17896 + struct dbglog_buf_s *next;
17898 + A_UINT32 bufsize;
17904 +struct dbglog_hdr_s {
17905 + struct dbglog_buf_s *dbuf;
17906 + A_UINT32 dropped;
17909 +struct dbglog_config_s {
17910 + A_UINT32 cfgvalid; /* Mask with valid config bits */
17912 + /* TODO: Take care of endianness */
17914 + A_UINT32 mmask:16; /* Mask of modules with logging on */
17915 + A_UINT32 rep:1; /* Reporting enabled or not */
17916 + A_UINT32 tsr:3; /* Time stamp resolution. Def: 1 ms */
17917 + A_UINT32 size:10; /* Report size in number of messages */
17918 + A_UINT32 reserved:2;
17925 +#define cfgmmask u.dbglog_config.mmask
17926 +#define cfgrep u.dbglog_config.rep
17927 +#define cfgtsr u.dbglog_config.tsr
17928 +#define cfgsize u.dbglog_config.size
17929 +#define cfgvalue u.value
17931 +#ifdef __cplusplus
17935 +#endif /* _DBGLOG_H_ */
17936 diff --git a/drivers/sdio/function/wlan/ar6000/include/dbglog_api.h b/drivers/sdio/function/wlan/ar6000/include/dbglog_api.h
17937 new file mode 100644
17938 index 0000000..06c8102
17940 +++ b/drivers/sdio/function/wlan/ar6000/include/dbglog_api.h
17942 +#ifndef _DBGLOG_API_H_
17943 +#define _DBGLOG_API_H_
17945 + * Copyright (c) 2004-2006 Atheros Communications Inc.
17946 + * All rights reserved.
17949 + * This program is free software; you can redistribute it and/or modify
17950 + * it under the terms of the GNU General Public License version 2 as
17951 + * published by the Free Software Foundation;
17953 + * Software distributed under the License is distributed on an "AS
17954 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17955 + * implied. See the License for the specific language governing
17956 + * rights and limitations under the License.
17960 + * This file contains host side debug primitives.
17963 +#ifdef __cplusplus
17967 +#include "dbglog.h"
17969 +#define DBGLOG_HOST_LOG_BUFFER_SIZE DBGLOG_LOG_BUFFER_SIZE
17971 +#define DBGLOG_GET_DBGID(arg) \
17972 + ((arg & DBGLOG_DBGID_MASK) >> DBGLOG_DBGID_OFFSET)
17974 +#define DBGLOG_GET_MODULEID(arg) \
17975 + ((arg & DBGLOG_MODULEID_MASK) >> DBGLOG_MODULEID_OFFSET)
17977 +#define DBGLOG_GET_NUMARGS(arg) \
17978 + ((arg & DBGLOG_NUM_ARGS_MASK) >> DBGLOG_NUM_ARGS_OFFSET)
17980 +#define DBGLOG_GET_TIMESTAMP(arg) \
17981 + ((arg & DBGLOG_TIMESTAMP_MASK) >> DBGLOG_TIMESTAMP_OFFSET)
17983 +#ifdef __cplusplus
17987 +#endif /* _DBGLOG_API_H_ */
17988 diff --git a/drivers/sdio/function/wlan/ar6000/include/dbglog_id.h b/drivers/sdio/function/wlan/ar6000/include/dbglog_id.h
17989 new file mode 100644
17990 index 0000000..ce22b16
17992 +++ b/drivers/sdio/function/wlan/ar6000/include/dbglog_id.h
17996 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17997 + * All rights reserved.
17999 + * $ATH_LICENSE_HOSTSDK0_C$
18001 + * This file contains the definitions of the debug identifiers for different
18006 +#ifndef _DBGLOG_ID_H_
18007 +#define _DBGLOG_ID_H_
18009 +#ifdef __cplusplus
18014 + * The nomenclature for the debug identifiers is MODULE_DESCRIPTION.
18015 + * Please ensure that the definition of any new debugid introduced is captured
18016 + * between the <MODULE>_DBGID_DEFINITION_START and
18017 + * <MODULE>_DBGID_DEFINITION_END defines. The structure is required for the
18018 + * parser to correctly pick up the values for different debug identifiers.
18021 +/* INF debug identifier definitions */
18022 +#define INF_DBGID_DEFINITION_START
18023 +#define INF_ASSERTION_FAILED 1
18024 +#define INF_TARGET_ID 2
18025 +#define INF_DBGID_DEFINITION_END
18027 +/* WMI debug identifier definitions */
18028 +#define WMI_DBGID_DEFINITION_START
18029 +#define WMI_CMD_RX_XTND_PKT_TOO_SHORT 1
18030 +#define WMI_EXTENDED_CMD_NOT_HANDLED 2
18031 +#define WMI_CMD_RX_PKT_TOO_SHORT 3
18032 +#define WMI_CALLING_WMI_EXTENSION_FN 4
18033 +#define WMI_CMD_NOT_HANDLED 5
18034 +#define WMI_IN_SYNC 6
18035 +#define WMI_TARGET_WMI_SYNC_CMD 7
18036 +#define WMI_SET_SNR_THRESHOLD_PARAMS 8
18037 +#define WMI_SET_RSSI_THRESHOLD_PARAMS 9
18038 +#define WMI_SET_LQ_TRESHOLD_PARAMS 10
18039 +#define WMI_TARGET_CREATE_PSTREAM_CMD 11
18040 +#define WMI_WI_DTM_INUSE 12
18041 +#define WMI_TARGET_DELETE_PSTREAM_CMD 13
18042 +#define WMI_TARGET_IMPLICIT_DELETE_PSTREAM_CMD 14
18043 +#define WMI_TARGET_GET_BIT_RATE_CMD 15
18044 +#define WMI_GET_RATE_MASK_CMD_FIX_RATE_MASK_IS 16
18045 +#define WMI_TARGET_GET_AVAILABLE_CHANNELS_CMD 17
18046 +#define WMI_TARGET_GET_TX_PWR_CMD 18
18047 +#define WMI_FREE_EVBUF_WMIBUF 19
18048 +#define WMI_FREE_EVBUF_DATABUF 20
18049 +#define WMI_FREE_EVBUF_BADFLAG 21
18050 +#define WMI_HTC_RX_ERROR_DATA_PACKET 22
18051 +#define WMI_HTC_RX_SYNC_PAUSING_FOR_MBOX 23
18052 +#define WMI_INCORRECT_WMI_DATA_HDR_DROPPING_PKT 24
18053 +#define WMI_SENDING_READY_EVENT 25
18054 +#define WMI_SETPOWER_MDOE_TO_MAXPERF 26
18055 +#define WMI_SETPOWER_MDOE_TO_REC 27
18056 +#define WMI_BSSINFO_EVENT_FROM 28
18057 +#define WMI_TARGET_GET_STATS_CMD 29
18058 +#define WMI_SENDING_SCAN_COMPLETE_EVENT 30
18059 +#define WMI_SENDING_RSSI_INDB_THRESHOLD_EVENT 31
18060 +#define WMI_SENDING_RSSI_INDBM_THRESHOLD_EVENT 32
18061 +#define WMI_SENDING_LINK_QUALITY_THRESHOLD_EVENT 33
18062 +#define WMI_SENDING_ERROR_REPORT_EVENT 34
18063 +#define WMI_SENDING_CAC_EVENT 35
18064 +#define WMI_TARGET_GET_ROAM_TABLE_CMD 36
18065 +#define WMI_TARGET_GET_ROAM_DATA_CMD 37
18066 +#define WMI_SENDING_GPIO_INTR_EVENT 38
18067 +#define WMI_SENDING_GPIO_ACK_EVENT 39
18068 +#define WMI_SENDING_GPIO_DATA_EVENT 40
18069 +#define WMI_CMD_RX 41
18070 +#define WMI_CMD_RX_XTND 42
18071 +#define WMI_EVENT_SEND 43
18072 +#define WMI_EVENT_SEND_XTND 44
18073 +#define WMI_DBGID_DEFINITION_END
18075 +/* CSERV debug identifier definitions */
18076 +#define CSERV_DBGID_DEFINITION_START
18077 +#define CSERV_BEGIN_SCAN1 1
18078 +#define CSERV_BEGIN_SCAN2 2
18079 +#define CSERV_END_SCAN1 3
18080 +#define CSERV_END_SCAN2 4
18081 +#define CSERV_CHAN_SCAN_START 5
18082 +#define CSERV_CHAN_SCAN_STOP 6
18083 +#define CSERV_CHANNEL_OPPPORTUNITY 7
18084 +#define CSERV_NC_TIMEOUT 8
18085 +#define CSERV_BACK_HOME 10
18086 +#define CSERV_CHMGR_CH_CALLBACK1 11
18087 +#define CSERV_CHMGR_CH_CALLBACK2 12
18088 +#define CSERV_CHMGR_CH_CALLBACK3 13
18089 +#define CSERV_SET_SCAN_PARAMS1 14
18090 +#define CSERV_SET_SCAN_PARAMS2 15
18091 +#define CSERV_SET_SCAN_PARAMS3 16
18092 +#define CSERV_SET_SCAN_PARAMS4 17
18093 +#define CSERV_ABORT_SCAN 18
18094 +#define CSERV_NEWSTATE 19
18095 +#define CSERV_MINCHMGR_OP_END 20
18096 +#define CSERV_CHMGR_OP_END 21
18097 +#define CSERV_DISCONNECT_TIMEOUT 22
18098 +#define CSERV_ROAM_TIMEOUT 23
18099 +#define CSERV_FORCE_SCAN1 24
18100 +#define CSERV_FORCE_SCAN2 25
18101 +#define CSERV_FORCE_SCAN3 26
18102 +#define CSERV_UTIL_TIMEOUT 27
18103 +#define CSERV_RSSIPOLLER 28
18104 +#define CSERV_RETRY_CONNECT_TIMEOUT 29
18105 +#define CSERV_RSSIINDBMPOLLER 30
18106 +#define CSERV_BGSCAN_ENABLE 31
18107 +#define CSERV_BGSCAN_DISABLE 32
18108 +#define CSERV_WLAN_START_SCAN_CMD1 33
18109 +#define CSERV_WLAN_START_SCAN_CMD2 34
18110 +#define CSERV_WLAN_START_SCAN_CMD3 35
18111 +#define CSERV_START_SCAN_CMD 36
18112 +#define CSERV_START_FORCE_SCAN 37
18113 +#define CSERV_NEXT_CHAN 38
18114 +#define CSERV_SET_REGCODE 39
18115 +#define CSERV_START_ADHOC 40
18116 +#define CSERV_ADHOC_AT_HOME 41
18117 +#define CSERV_OPT_AT_HOME 42
18118 +#define CSERV_WLAN_CONNECT_CMD 43
18119 +#define CSERV_WLAN_RECONNECT_CMD 44
18120 +#define CSERV_WLAN_DISCONNECT_CMD 45
18121 +#define CSERV_BSS_CHANGE_CHANNEL 46
18122 +#define CSERV_BEACON_RX 47
18123 +#define CSERV_KEEPALIVE_CHECK 48
18124 +#define CSERV_RC_BEGIN_SCAN 49
18125 +#define CSERV_RC_SCAN_START 50
18126 +#define CSERV_RC_SCAN_STOP 51
18127 +#define CSERV_RC_NEXT 52
18128 +#define CSERV_RC_SCAN_END 53
18129 +#define CSERV_PROBE_CALLBACK 54
18130 +#define CSERV_ROAM1 55
18131 +#define CSERV_ROAM2 56
18132 +#define CSERV_ROAM3 57
18133 +#define CSERV_CONNECT_EVENT 58
18134 +#define CSERV_DISCONNECT_EVENT 59
18135 +#define CSERV_BMISS_HANDLER1 60
18136 +#define CSERV_BMISS_HANDLER2 61
18137 +#define CSERV_BMISS_HANDLER3 62
18138 +#define CSERV_LOWRSSI_HANDLER 63
18139 +#define CSERV_WLAN_SET_PMKID_CMD 64
18140 +#define CSERV_RECONNECT_REQUEST 65
18141 +#define CSERV_KEYSPLUMBED_EVENT 66
18142 +#define CSERV_NEW_REG 67
18143 +#define CSERV_SET_RSSI_THOLD 68
18144 +#define CSERV_RSSITHRESHOLDCHECK 69
18145 +#define CSERV_RSSIINDBMTHRESHOLDCHECK 70
18146 +#define CSERV_WLAN_SET_OPT_CMD1 71
18147 +#define CSERV_WLAN_SET_OPT_CMD2 72
18148 +#define CSERV_WLAN_SET_OPT_CMD3 73
18149 +#define CSERV_WLAN_SET_OPT_CMD4 74
18150 +#define CSERV_SCAN_CONNECT_STOP 75
18151 +#define CSERV_BMISS_HANDLER4 76
18152 +#define CSERV_INITIALIZE_TIMER 77
18153 +#define CSERV_ARM_TIMER 78
18154 +#define CSERV_DISARM_TIMER 79
18155 +#define CSERV_UNINITIALIZE_TIMER 80
18156 +#define CSERV_DISCONNECT_EVENT2 81
18157 +#define CSERV_SCAN_CONNECT_START 82
18158 +#define CSERV_BSSINFO_MEMORY_ALLOC_FAILED 83
18159 +#define CSERV_SET_SCAN_PARAMS5 84
18160 +#define CSERV_DBGID_DEFINITION_END
18162 +/* TXRX debug identifier definitions */
18163 +#define TXRX_TXBUF_DBGID_DEFINITION_START
18164 +#define TXRX_TXBUF_ALLOCATE_BUF 1
18165 +#define TXRX_TXBUF_QUEUE_BUF_TO_MBOX 2
18166 +#define TXRX_TXBUF_QUEUE_BUF_TO_TXQ 3
18167 +#define TXRX_TXBUF_TXQ_DEPTH 4
18168 +#define TXRX_TXBUF_IBSS_QUEUE_TO_SFQ 5
18169 +#define TXRX_TXBUF_IBSS_QUEUE_TO_TXQ_FRM_SFQ 6
18170 +#define TXRX_TXBUF_INITIALIZE_TIMER 7
18171 +#define TXRX_TXBUF_ARM_TIMER 8
18172 +#define TXRX_TXBUF_DISARM_TIMER 9
18173 +#define TXRX_TXBUF_UNINITIALIZE_TIMER 10
18174 +#define TXRX_TXBUF_DBGID_DEFINITION_END
18176 +#define TXRX_RXBUF_DBGID_DEFINITION_START
18177 +#define TXRX_RXBUF_ALLOCATE_BUF 1
18178 +#define TXRX_RXBUF_QUEUE_TO_HOST 2
18179 +#define TXRX_RXBUF_QUEUE_TO_WLAN 3
18180 +#define TXRX_RXBUF_ZERO_LEN_BUF 4
18181 +#define TXRX_RXBUF_QUEUE_TO_HOST_LASTBUF_IN_RXCHAIN 5
18182 +#define TXRX_RXBUF_LASTBUF_IN_RXCHAIN_ZEROBUF 6
18183 +#define TXRX_RXBUF_QUEUE_EMPTY_QUEUE_TO_WLAN 7
18184 +#define TXRX_RXBUF_SEND_TO_RECV_MGMT 8
18185 +#define TXRX_RXBUF_SEND_TO_IEEE_LAYER 9
18186 +#define TXRX_RXBUF_DBGID_DEFINITION_END
18188 +#define TXRX_MGMTBUF_DBGID_DEFINITION_START
18189 +#define TXRX_MGMTBUF_ALLOCATE_BUF 1
18190 +#define TXRX_MGMTBUF_ALLOCATE_SM_BUF 2
18191 +#define TXRX_MGMTBUF_ALLOCATE_RMBUF 3
18192 +#define TXRX_MGMTBUF_GET_BUF 4
18193 +#define TXRX_MGMTBUF_GET_SM_BUF 5
18194 +#define TXRX_MGMTBUF_QUEUE_BUF_TO_TXQ 6
18195 +#define TXRX_MGMTBUF_REAPED_BUF 7
18196 +#define TXRX_MGMTBUF_REAPED_SM_BUF 8
18197 +#define TXRX_MGMTBUF_WAIT_FOR_TXQ_DRAIN 9
18198 +#define TXRX_MGMTBUF_WAIT_FOR_TXQ_SFQ_DRAIN 10
18199 +#define TXRX_MGMTBUF_ENQUEUE_INTO_SFQ 11
18200 +#define TXRX_MGMTBUF_DEQUEUE_FROM_SFQ 12
18201 +#define TXRX_MGMTBUF_PAUSE_TXQ 13
18202 +#define TXRX_MGMTBUF_RESUME_TXQ 14
18203 +#define TXRX_MGMTBUF_WAIT_FORTXQ_DRAIN_TIMEOUT 15
18204 +#define TXRX_MGMTBUF_DRAINQ 16
18205 +#define TXRX_MGMTBUF_INDICATE_Q_DRAINED 17
18206 +#define TXRX_MGMTBUF_DBGID_DEFINITION_END
18208 +/* PM (Power Module) debug identifier definitions */
18209 +#define PM_DBGID_DEFINITION_START
18211 +#define PM_ENABLE 2
18212 +#define PM_SET_STATE 3
18213 +#define PM_SET_POWERMODE 4
18214 +#define PM_CONN_NOTIFY 5
18215 +#define PM_REF_COUNT_NEGATIVE 6
18216 +#define PM_APSD_ENABLE 7
18217 +#define PM_UPDATE_APSD_STATE 8
18218 +#define PM_CHAN_OP_REQ 9
18219 +#define PM_SET_MY_BEACON_POLICY 10
18220 +#define PM_SET_ALL_BEACON_POLICY 11
18221 +#define PM_SET_PM_PARAMS1 12
18222 +#define PM_SET_PM_PARAMS2 13
18223 +#define PM_ADHOC_SET_PM_CAPS_FAIL 14
18224 +#define PM_ADHOC_UNKNOWN_IBSS_ATTRIB_ID 15
18225 +#define PM_DBGID_DEFINITION_END
18227 +/* Wake on Wireless debug identifier definitions */
18228 +#define WOW_DBGID_DEFINITION_START
18229 +#define WOW_INIT 1
18230 +#define WOW_GET_CONFIG_DSET 2
18231 +#define WOW_NO_CONFIG_DSET 3
18232 +#define WOW_INVALID_CONFIG_DSET 4
18233 +#define WOW_USE_DEFAULT_CONFIG 5
18234 +#define WOW_SETUP_GPIO 6
18235 +#define WOW_INIT_DONE 7
18236 +#define WOW_SET_GPIO_PIN 8
18237 +#define WOW_CLEAR_GPIO_PIN 9
18238 +#define WOW_SET_WOW_MODE_CMD 10
18239 +#define WOW_SET_HOST_MODE_CMD 11
18240 +#define WOW_ADD_WOW_PATTERN_CMD 12
18241 +#define WOW_NEW_WOW_PATTERN_AT_INDEX 13
18242 +#define WOW_DEL_WOW_PATTERN_CMD 14
18243 +#define WOW_LIST_CONTAINS_PATTERNS 15
18244 +#define WOW_GET_WOW_LIST_CMD 16
18245 +#define WOW_INVALID_FILTER_ID 17
18246 +#define WOW_INVALID_FILTER_LISTID 18
18247 +#define WOW_NO_VALID_FILTER_AT_ID 19
18248 +#define WOW_NO_VALID_LIST_AT_ID 20
18249 +#define WOW_NUM_PATTERNS_EXCEEDED 21
18250 +#define WOW_NUM_LISTS_EXCEEDED 22
18251 +#define WOW_GET_WOW_STATS 23
18252 +#define WOW_CLEAR_WOW_STATS 24
18253 +#define WOW_WAKEUP_HOST 25
18254 +#define WOW_EVENT_WAKEUP_HOST 26
18255 +#define WOW_EVENT_DISCARD 27
18256 +#define WOW_PATTERN_MATCH 28
18257 +#define WOW_PATTERN_NOT_MATCH 29
18258 +#define WOW_PATTERN_NOT_MATCH_OFFSET 30
18259 +#define WOW_DISABLED_HOST_ASLEEP 31
18260 +#define WOW_ENABLED_HOST_ASLEEP_NO_PATTERNS 32
18261 +#define WOW_ENABLED_HOST_ASLEEP_NO_MATCH_FOUND 33
18262 +#define WOW_DBGID_DEFINITION_END
18264 +/* WHAL debug identifier definitions */
18265 +#define WHAL_DBGID_DEFINITION_START
18266 +#define WHAL_ERROR_ANI_CONTROL 1
18267 +#define WHAL_ERROR_CHIP_TEST1 2
18268 +#define WHAL_ERROR_CHIP_TEST2 3
18269 +#define WHAL_ERROR_EEPROM_CHECKSUM 4
18270 +#define WHAL_ERROR_EEPROM_MACADDR 5
18271 +#define WHAL_ERROR_INTERRUPT_HIU 6
18272 +#define WHAL_ERROR_KEYCACHE_RESET 7
18273 +#define WHAL_ERROR_KEYCACHE_SET 8
18274 +#define WHAL_ERROR_KEYCACHE_TYPE 9
18275 +#define WHAL_ERROR_KEYCACHE_TKIPENTRY 10
18276 +#define WHAL_ERROR_KEYCACHE_WEPLENGTH 11
18277 +#define WHAL_ERROR_PHY_INVALID_CHANNEL 12
18278 +#define WHAL_ERROR_POWER_AWAKE 13
18279 +#define WHAL_ERROR_POWER_SET 14
18280 +#define WHAL_ERROR_RECV_STOPDMA 15
18281 +#define WHAL_ERROR_RECV_STOPPCU 16
18282 +#define WHAL_ERROR_RESET_CHANNF1 17
18283 +#define WHAL_ERROR_RESET_CHANNF2 18
18284 +#define WHAL_ERROR_RESET_PM 19
18285 +#define WHAL_ERROR_RESET_OFFSETCAL 20
18286 +#define WHAL_ERROR_RESET_RFGRANT 21
18287 +#define WHAL_ERROR_RESET_RXFRAME 22
18288 +#define WHAL_ERROR_RESET_STOPDMA 23
18289 +#define WHAL_ERROR_RESET_RECOVER 24
18290 +#define WHAL_ERROR_XMIT_COMPUTE 25
18291 +#define WHAL_ERROR_XMIT_NOQUEUE 26
18292 +#define WHAL_ERROR_XMIT_ACTIVEQUEUE 27
18293 +#define WHAL_ERROR_XMIT_BADTYPE 28
18294 +#define WHAL_DBGID_DEFINITION_END
18296 +#ifdef __cplusplus
18300 +#endif /* _DBGLOG_ID_H_ */
18301 diff --git a/drivers/sdio/function/wlan/ar6000/include/dl_list.h b/drivers/sdio/function/wlan/ar6000/include/dl_list.h
18302 new file mode 100644
18303 index 0000000..4b9c581
18305 +++ b/drivers/sdio/function/wlan/ar6000/include/dl_list.h
18309 + * Double-link list definitions (adapted from Atheros SDIO stack)
18311 + * Copyright (c) 2007 Atheros Communications Inc.
18312 + * All rights reserved.
18315 + * This program is free software; you can redistribute it and/or modify
18316 + * it under the terms of the GNU General Public License version 2 as
18317 + * published by the Free Software Foundation;
18319 + * Software distributed under the License is distributed on an "AS
18320 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
18321 + * implied. See the License for the specific language governing
18322 + * rights and limitations under the License.
18327 +#ifndef __DL_LIST_H___
18328 +#define __DL_LIST_H___
18330 +#define A_CONTAINING_STRUCT(address, struct_type, field_name)\
18331 + ((struct_type *)((A_UINT32)(address) - (A_UINT32)(&((struct_type *)0)->field_name)))
18333 +/* list functions */
18334 +/* pointers for the list */
18335 +typedef struct _DL_LIST {
18336 + struct _DL_LIST *pPrev;
18337 + struct _DL_LIST *pNext;
18338 +}DL_LIST, *PDL_LIST;
18340 + * DL_LIST_INIT , initialize doubly linked list
18342 +#define DL_LIST_INIT(pList)\
18343 + {(pList)->pPrev = pList; (pList)->pNext = pList;}
18345 +#define DL_LIST_IS_EMPTY(pList) (((pList)->pPrev == (pList)) && ((pList)->pNext == (pList)))
18346 +#define DL_LIST_GET_ITEM_AT_HEAD(pList) (pList)->pNext
18347 +#define DL_LIST_GET_ITEM_AT_TAIL(pList) (pList)->pPrev
18349 + * ITERATE_OVER_LIST pStart is the list, pTemp is a temp list member
18350 + * NOT: do not use this function if the items in the list are deleted inside the
18353 +#define ITERATE_OVER_LIST(pStart, pTemp) \
18354 + for((pTemp) =(pStart)->pNext; pTemp != (pStart); (pTemp) = (pTemp)->pNext)
18357 +/* safe iterate macro that allows the item to be removed from the list
18358 + * the iteration continues to the next item in the list
18360 +#define ITERATE_OVER_LIST_ALLOW_REMOVE(pStart,pItem,st,offset) \
18362 + PDL_LIST pTemp; \
18363 + pTemp = (pStart)->pNext; \
18364 + while (pTemp != (pStart)) { \
18365 + (pItem) = A_CONTAINING_STRUCT(pTemp,st,offset); \
18366 + pTemp = pTemp->pNext; \
18368 +#define ITERATE_END }}
18371 + * DL_ListInsertTail - insert pAdd to the end of the list
18373 +static INLINE PDL_LIST DL_ListInsertTail(PDL_LIST pList, PDL_LIST pAdd) {
18374 + /* insert at tail */
18375 + pAdd->pPrev = pList->pPrev;
18376 + pAdd->pNext = pList;
18377 + pList->pPrev->pNext = pAdd;
18378 + pList->pPrev = pAdd;
18383 + * DL_ListInsertHead - insert pAdd into the head of the list
18385 +static INLINE PDL_LIST DL_ListInsertHead(PDL_LIST pList, PDL_LIST pAdd) {
18386 + /* insert at head */
18387 + pAdd->pPrev = pList;
18388 + pAdd->pNext = pList->pNext;
18389 + pList->pNext->pPrev = pAdd;
18390 + pList->pNext = pAdd;
18394 +#define DL_ListAdd(pList,pItem) DL_ListInsertHead((pList),(pItem))
18396 + * DL_ListRemove - remove pDel from list
18398 +static INLINE PDL_LIST DL_ListRemove(PDL_LIST pDel) {
18399 + pDel->pNext->pPrev = pDel->pPrev;
18400 + pDel->pPrev->pNext = pDel->pNext;
18401 + /* point back to itself just to be safe, incase remove is called again */
18402 + pDel->pNext = pDel;
18403 + pDel->pPrev = pDel;
18408 + * DL_ListRemoveItemFromHead - get a list item from the head
18410 +static INLINE PDL_LIST DL_ListRemoveItemFromHead(PDL_LIST pList) {
18411 + PDL_LIST pItem = NULL;
18412 + if (pList->pNext != pList) {
18413 + pItem = pList->pNext;
18414 + /* remove the first item from head */
18415 + DL_ListRemove(pItem);
18420 +#endif /* __DL_LIST_H___ */
18421 diff --git a/drivers/sdio/function/wlan/ar6000/include/dset_api.h b/drivers/sdio/function/wlan/ar6000/include/dset_api.h
18422 new file mode 100644
18423 index 0000000..de5cc6a
18425 +++ b/drivers/sdio/function/wlan/ar6000/include/dset_api.h
18428 + * Copyright (c) 2004-2006 Atheros Communications Inc.
18429 + * All rights reserved.
18432 + * This program is free software; you can redistribute it and/or modify
18433 + * it under the terms of the GNU General Public License version 2 as
18434 + * published by the Free Software Foundation;
18436 + * Software distributed under the License is distributed on an "AS
18437 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
18438 + * implied. See the License for the specific language governing
18439 + * rights and limitations under the License.
18443 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/dset_api.h#1 $
18445 + * Host-side DataSet API.
18449 +#ifndef _DSET_API_H_
18450 +#define _DSET_API_H_
18452 +#ifdef __cplusplus
18454 +#endif /* __cplusplus */
18457 + * Host-side DataSet support is optional, and is not
18458 + * currently required for correct operation. To disable
18459 + * Host-side DataSet support, set this to 0.
18461 +#ifndef CONFIG_HOST_DSET_SUPPORT
18462 +#define CONFIG_HOST_DSET_SUPPORT 1
18465 +/* Called to send a DataSet Open Reply back to the Target. */
18466 +A_STATUS wmi_dset_open_reply(struct wmi_t *wmip,
18468 + A_UINT32 access_cookie,
18470 + A_UINT32 version,
18471 + A_UINT32 targ_handle,
18472 + A_UINT32 targ_reply_fn,
18473 + A_UINT32 targ_reply_arg);
18475 +/* Called to send a DataSet Data Reply back to the Target. */
18476 +A_STATUS wmi_dset_data_reply(struct wmi_t *wmip,
18478 + A_UINT8 *host_buf,
18480 + A_UINT32 targ_buf,
18481 + A_UINT32 targ_reply_fn,
18482 + A_UINT32 targ_reply_arg);
18484 +#ifdef __cplusplus
18486 +#endif /* __cplusplus */
18489 +#endif /* _DSET_API_H_ */
18490 diff --git a/drivers/sdio/function/wlan/ar6000/include/dset_internal.h b/drivers/sdio/function/wlan/ar6000/include/dset_internal.h
18491 new file mode 100644
18492 index 0000000..f0be380
18494 +++ b/drivers/sdio/function/wlan/ar6000/include/dset_internal.h
18497 + * Copyright (c) 2007 Atheros Communications Inc.
18498 + * All rights reserved.
18500 + * $ATH_LICENSE_HOSTSDK0_C$
18504 +#ifndef __DSET_INTERNAL_H__
18505 +#define __DSET_INTERNAL_H__
18508 + * Internal dset definitions, common for DataSet layer.
18511 +#define DSET_TYPE_STANDARD 0
18512 +#define DSET_TYPE_BPATCHED 1
18513 +#define DSET_TYPE_COMPRESSED 2
18515 +/* Dataset descriptor */
18517 +typedef struct dset_descriptor_s {
18518 + struct dset_descriptor_s *next; /* List link. NULL only at the last
18520 + A_UINT16 id; /* Dset ID */
18521 + A_UINT16 size; /* Dset size. */
18522 + void *DataPtr; /* Pointer to raw data for standard
18523 + DataSet or pointer to original
18524 + dset_descriptor for patched
18526 + A_UINT32 data_type; /* DSET_TYPE_*, above */
18528 + void *AuxPtr; /* Additional data that might
18529 + needed for data_type. For
18530 + example, pointer to patch
18531 + Dataset descriptor for BPatch. */
18532 +} dset_descriptor_t;
18534 +#endif /* __DSET_INTERNAL_H__ */
18535 diff --git a/drivers/sdio/function/wlan/ar6000/include/dsetid.h b/drivers/sdio/function/wlan/ar6000/include/dsetid.h
18536 new file mode 100644
18537 index 0000000..85729f8
18539 +++ b/drivers/sdio/function/wlan/ar6000/include/dsetid.h
18542 + * Copyright (c) 2004-2007 Atheros Communications Inc.
18543 + * All rights reserved.
18545 + * $ATH_LICENSE_HOSTSDK0_C$
18549 +#ifndef __DSETID_H__
18550 +#define __DSETID_H__
18552 +/* Well-known DataSet IDs */
18553 +#define DSETID_UNUSED 0x00000000
18554 +#define DSETID_BOARD_DATA 0x00000001 /* Cal and board data */
18555 +#define DSETID_REGDB 0x00000002 /* Regulatory Database */
18556 +#define DSETID_POWER_CONTROL 0x00000003 /* TX Pwr Lim & Ant Gain */
18557 +#define DSETID_USER_CONFIG 0x00000004 /* User Configuration */
18559 +#define DSETID_ANALOG_CONTROL_DATA_START 0x00000005
18560 +#define DSETID_ANALOG_CONTROL_DATA_END 0x00000025
18562 + * Get DSETID for various reference clock speeds.
18563 + * For each speed there are three DataSets that correspond
18564 + * to the three columns of bank6 data (addr, 11a, 11b/g).
18565 + * This macro returns the dsetid of the first of those
18566 + * three DataSets.
18568 +#define ANALOG_CONTROL_DATA_DSETID(refclk) \
18569 + (DSETID_ANALOG_CONTROL_DATA_START + 3*refclk)
18572 + * There are TWO STARTUP_PATCH DataSets.
18573 + * DSETID_STARTUP_PATCH is historical, and was applied before BMI on
18574 + * earlier systems. On AR6002, it is applied after BMI, just like
18575 + * DSETID_STARTUP_PATCH2.
18577 +#define DSETID_STARTUP_PATCH 0x00000026
18578 +#define DSETID_GPIO_CONFIG_PATCH 0x00000027
18579 +#define DSETID_WLANREGS 0x00000028 /* override wlan regs */
18580 +#define DSETID_STARTUP_PATCH2 0x00000029
18582 +#define DSETID_WOW_CONFIG 0x00000090 /* WoW Configuration */
18584 +/* Add WHAL_INI_DATA_ID to DSETID_INI_DATA for a specific WHAL INI table. */
18585 +#define DSETID_INI_DATA 0x00000100
18586 +/* Reserved for WHAL INI Tables: 0x100..0x11f */
18587 +#define DSETID_INI_DATA_END 0x0000011f
18589 +#define DSETID_VENDOR_START 0x00010000 /* Vendor-defined DataSets */
18591 +#define DSETID_INDEX_END 0xfffffffe /* Reserved to indicate the
18592 + end of a memory-based
18594 +#define DSETID_INDEX_FREE 0xffffffff /* An unused index entry */
18597 + * PATCH DataSet format:
18598 + * A list of patches, terminated by a patch with
18599 + * address=PATCH_END.
18601 + * This allows for patches to be stored in flash.
18604 + A_UINT32 *address;
18609 + * Skip some patches. Can be used to erase a single patch in a
18610 + * patch DataSet without having to re-write the DataSet. May
18611 + * also be used to embed information for use by subsequent
18612 + * patch code. The "data" in a PATCH_SKIP tells how many
18613 + * bytes of length "patch_s" to skip.
18615 +#define PATCH_SKIP ((A_UINT32 *)0x00000000)
18618 + * Execute code at the address specified by "data".
18619 + * The address of the patch structure is passed as
18620 + * the one parameter.
18622 +#define PATCH_CODE_ABS ((A_UINT32 *)0x00000001)
18625 + * Same as PATCH_CODE_ABS, but treat "data" as an
18626 + * offset from the start of the patch word.
18628 +#define PATCH_CODE_REL ((A_UINT32 *)0x00000002)
18630 +/* Mark the end of this patch DataSet. */
18631 +#define PATCH_END ((A_UINT32 *)0xffffffff)
18634 + * A DataSet which contains a Binary Patch to some other DataSet
18635 + * uses the original dsetid with the DSETID_BPATCH_FLAG bit set.
18636 + * Such a BPatch DataSet consists of BPatch metadata followed by
18637 + * the bdiff bytes. BPatch metadata consists of a single 32-bit
18638 + * word that contains the size of the BPatched final image.
18640 + * To create a suitable bdiff DataSet, use bdiff in host/tools/bdiff
18641 + * to create "diffs":
18642 + * bdiff -q -O -nooldmd5 -nonewmd5 -d ORIGfile NEWfile diffs
18643 + * Then add BPatch metadata to the start of "diffs".
18645 + * NB: There are some implementation-induced restrictions
18646 + * on which DataSets can be BPatched.
18648 +#define DSETID_BPATCH_FLAG 0x80000000
18650 +#endif /* __DSETID_H__ */
18651 diff --git a/drivers/sdio/function/wlan/ar6000/include/gpio.h b/drivers/sdio/function/wlan/ar6000/include/gpio.h
18652 new file mode 100644
18653 index 0000000..2203c7e
18655 +++ b/drivers/sdio/function/wlan/ar6000/include/gpio.h
18658 + * Copyright (c) 2005 Atheros Communications Inc.
18659 + * All rights reserved.
18661 + * $ATH_LICENSE_HOSTSDK0_C$
18665 +#if defined(AR6001)
18666 +#define GPIO_PIN_COUNT 18
18668 +#define GPIO_PIN_COUNT 18
18672 + * Possible values for WMIX_GPIO_SET_REGISTER_CMDID.
18673 + * NB: These match hardware order, so that addresses can
18674 + * easily be computed.
18676 +#define GPIO_ID_OUT 0x00000000
18677 +#define GPIO_ID_OUT_W1TS 0x00000001
18678 +#define GPIO_ID_OUT_W1TC 0x00000002
18679 +#define GPIO_ID_ENABLE 0x00000003
18680 +#define GPIO_ID_ENABLE_W1TS 0x00000004
18681 +#define GPIO_ID_ENABLE_W1TC 0x00000005
18682 +#define GPIO_ID_IN 0x00000006
18683 +#define GPIO_ID_STATUS 0x00000007
18684 +#define GPIO_ID_STATUS_W1TS 0x00000008
18685 +#define GPIO_ID_STATUS_W1TC 0x00000009
18686 +#define GPIO_ID_PIN0 0x0000000a
18687 +#define GPIO_ID_PIN(n) (GPIO_ID_PIN0+(n))
18689 +#define GPIO_LAST_REGISTER_ID GPIO_ID_PIN(17)
18690 +#define GPIO_ID_NONE 0xffffffff
18691 diff --git a/drivers/sdio/function/wlan/ar6000/include/gpio_api.h b/drivers/sdio/function/wlan/ar6000/include/gpio_api.h
18692 new file mode 100644
18693 index 0000000..8078aa5
18695 +++ b/drivers/sdio/function/wlan/ar6000/include/gpio_api.h
18697 +#ifndef _GPIO_API_H_
18698 +#define _GPIO_API_H_
18700 + * Copyright 2005 Atheros Communications, Inc., All Rights Reserved.
18703 + * This program is free software; you can redistribute it and/or modify
18704 + * it under the terms of the GNU General Public License version 2 as
18705 + * published by the Free Software Foundation;
18707 + * Software distributed under the License is distributed on an "AS
18708 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
18709 + * implied. See the License for the specific language governing
18710 + * rights and limitations under the License.
18717 + * Host-side General Purpose I/O API.
18719 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/gpio_api.h#1 $
18723 + * Send a command to the Target in order to change output on GPIO pins.
18725 +A_STATUS wmi_gpio_output_set(struct wmi_t *wmip,
18726 + A_UINT32 set_mask,
18727 + A_UINT32 clear_mask,
18728 + A_UINT32 enable_mask,
18729 + A_UINT32 disable_mask);
18732 + * Send a command to the Target requesting input state of GPIO pins.
18734 +A_STATUS wmi_gpio_input_get(struct wmi_t *wmip);
18737 + * Send a command to the Target to change the value of a GPIO register.
18739 +A_STATUS wmi_gpio_register_set(struct wmi_t *wmip,
18740 + A_UINT32 gpioreg_id,
18744 + * Send a command to the Target to fetch the value of a GPIO register.
18746 +A_STATUS wmi_gpio_register_get(struct wmi_t *wmip, A_UINT32 gpioreg_id);
18749 + * Send a command to the Target, acknowledging some GPIO interrupts.
18751 +A_STATUS wmi_gpio_intr_ack(struct wmi_t *wmip, A_UINT32 ack_mask);
18753 +#endif /* _GPIO_API_H_ */
18754 diff --git a/drivers/sdio/function/wlan/ar6000/include/hif.h b/drivers/sdio/function/wlan/ar6000/include/hif.h
18755 new file mode 100644
18756 index 0000000..f32388c
18758 +++ b/drivers/sdio/function/wlan/ar6000/include/hif.h
18761 + * Copyright (c) 2004-2007 Atheros Communications Inc.
18762 + * All rights reserved.
18765 + * This program is free software; you can redistribute it and/or modify
18766 + * it under the terms of the GNU General Public License version 2 as
18767 + * published by the Free Software Foundation;
18769 + * Software distributed under the License is distributed on an "AS
18770 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
18771 + * implied. See the License for the specific language governing
18772 + * rights and limitations under the License.
18776 + * HIF specific declarations and prototypes
18782 +#ifdef __cplusplus
18784 +#endif /* __cplusplus */
18786 +/* Header files */
18787 +#include "a_config.h"
18788 +#include "athdefs.h"
18789 +#include "a_types.h"
18790 +#include "a_osapi.h"
18792 +typedef struct htc_callbacks HTC_CALLBACKS;
18793 +typedef struct hif_device HIF_DEVICE;
18796 + * direction - Direction of transfer (HIF_READ/HIF_WRITE).
18798 +#define HIF_READ 0x00000001
18799 +#define HIF_WRITE 0x00000002
18800 +#define HIF_DIR_MASK (HIF_READ | HIF_WRITE)
18803 + * type - An interface may support different kind of read/write commands.
18804 + * The command type is divided into a basic and an extended command
18805 + * and can be specified using HIF_BASIC_IO/HIF_EXTENDED_IO.
18807 +#define HIF_BASIC_IO 0x00000004
18808 +#define HIF_EXTENDED_IO 0x00000008
18809 +#define HIF_TYPE_MASK (HIF_BASIC_IO | HIF_EXTENDED_IO)
18812 + * emode - This indicates the whether the command is to be executed in a
18813 + * blocking or non-blocking fashion (HIF_SYNCHRONOUS/
18814 + * HIF_ASYNCHRONOUS). The read/write data paths in HTC have been
18815 + * implemented using the asynchronous mode allowing the the bus
18816 + * driver to indicate the completion of operation through the
18817 + * registered callback routine. The requirement primarily comes
18818 + * from the contexts these operations get called from (a driver's
18819 + * transmit context or the ISR context in case of receive).
18820 + * Support for both of these modes is essential.
18822 +#define HIF_SYNCHRONOUS 0x00000010
18823 +#define HIF_ASYNCHRONOUS 0x00000020
18824 +#define HIF_EMODE_MASK (HIF_SYNCHRONOUS | HIF_ASYNCHRONOUS)
18827 + * dmode - An interface may support different kinds of commands based on
18828 + * the tradeoff between the amount of data it can carry and the
18829 + * setup time. Byte and Block modes are supported (HIF_BYTE_BASIS/
18830 + * HIF_BLOCK_BASIS). In case of latter, the data is rounded off
18831 + * to the nearest block size by padding. The size of the block is
18832 + * configurable at compile time using the HIF_BLOCK_SIZE and is
18833 + * negotiated with the target during initialization after the
18834 + * dragon interrupts are enabled.
18836 +#define HIF_BYTE_BASIS 0x00000040
18837 +#define HIF_BLOCK_BASIS 0x00000080
18838 +#define HIF_DMODE_MASK (HIF_BYTE_BASIS | HIF_BLOCK_BASIS)
18841 + * amode - This indicates if the address has to be incremented on dragon
18842 + * after every read/write operation (HIF?FIXED_ADDRESS/
18843 + * HIF_INCREMENTAL_ADDRESS).
18845 +#define HIF_FIXED_ADDRESS 0x00000100
18846 +#define HIF_INCREMENTAL_ADDRESS 0x00000200
18847 +#define HIF_AMODE_MASK (HIF_FIXED_ADDRESS | HIF_INCREMENTAL_ADDRESS)
18849 +#define HIF_WR_ASYNC_BYTE_FIX \
18850 + (HIF_WRITE | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_FIXED_ADDRESS)
18851 +#define HIF_WR_ASYNC_BYTE_INC \
18852 + (HIF_WRITE | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS)
18853 +#define HIF_WR_ASYNC_BLOCK_INC \
18854 + (HIF_WRITE | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS)
18855 +#define HIF_WR_SYNC_BYTE_FIX \
18856 + (HIF_WRITE | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_FIXED_ADDRESS)
18857 +#define HIF_WR_SYNC_BYTE_INC \
18858 + (HIF_WRITE | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS)
18859 +#define HIF_WR_SYNC_BLOCK_INC \
18860 + (HIF_WRITE | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS)
18861 +#define HIF_RD_SYNC_BYTE_INC \
18862 + (HIF_READ | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS)
18863 +#define HIF_RD_SYNC_BYTE_FIX \
18864 + (HIF_READ | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_FIXED_ADDRESS)
18865 +#define HIF_RD_ASYNC_BYTE_FIX \
18866 + (HIF_READ | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_FIXED_ADDRESS)
18867 +#define HIF_RD_ASYNC_BLOCK_FIX \
18868 + (HIF_READ | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_FIXED_ADDRESS)
18869 +#define HIF_RD_ASYNC_BYTE_INC \
18870 + (HIF_READ | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS)
18871 +#define HIF_RD_ASYNC_BLOCK_INC \
18872 + (HIF_READ | HIF_ASYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS)
18873 +#define HIF_RD_SYNC_BLOCK_INC \
18874 + (HIF_READ | HIF_SYNCHRONOUS | HIF_EXTENDED_IO | HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS)
18878 + HIF_DEVICE_POWER_STATE = 0,
18879 + HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
18880 + HIF_DEVICE_GET_MBOX_ADDR,
18881 + HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
18882 + HIF_DEVICE_GET_IRQ_PROC_MODE,
18883 + HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
18884 +} HIF_DEVICE_CONFIG_OPCODE;
18887 + * HIF CONFIGURE definitions:
18889 + * HIF_DEVICE_GET_MBOX_BLOCK_SIZE
18891 + * output : array of 4 A_UINT32s
18892 + * notes: block size is returned for each mailbox (4)
18894 + * HIF_DEVICE_GET_MBOX_ADDR
18896 + * output : array of 4 A_UINT32
18897 + * notes: address is returned for each mailbox (4) in the array
18899 + * HIF_DEVICE_GET_PENDING_EVENTS_FUNC
18901 + * output: HIF_PENDING_EVENTS_FUNC function pointer
18902 + * notes: this is optional for the HIF layer, if the request is
18903 + * not handled then it indicates that the upper layer can use
18904 + * the standard device methods to get pending events (IRQs, mailbox messages etc..)
18905 + * otherwise it can call the function pointer to check pending events.
18907 + * HIF_DEVICE_GET_IRQ_PROC_MODE
18909 + * output : HIF_DEVICE_IRQ_PROCESSING_MODE (interrupt processing mode)
18910 + * note: the hif layer interfaces with the underlying OS-specific bus driver. The HIF
18911 + * layer can report whether IRQ processing is requires synchronous behavior or
18912 + * can be processed using asynchronous bus requests (typically faster).
18914 + * HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC
18916 + * output : HIF_MASK_UNMASK_RECV_EVENT function pointer
18917 + * notes: this is optional for the HIF layer. The HIF layer may require a special mechanism
18918 + * to mask receive message events. The upper layer can call this pointer when it needs
18919 + * to mask/unmask receive events (in case it runs out of buffers).
18925 + HIF_DEVICE_IRQ_SYNC_ONLY, /* for HIF implementations that require the DSR to process all
18926 + interrupts before returning */
18927 + HIF_DEVICE_IRQ_ASYNC_SYNC, /* for HIF implementations that allow DSR to process interrupts
18928 + using ASYNC I/O (that is HIFAckInterrupt can be called at a
18930 +} HIF_DEVICE_IRQ_PROCESSING_MODE;
18932 +#define HIF_MAX_DEVICES 1
18934 +struct htc_callbacks {
18937 + A_STATUS (* deviceInsertedHandler)(void *hif_handle);
18938 + A_STATUS (* deviceRemovedHandler)(void *htc_handle, A_STATUS status);
18939 + A_STATUS (* deviceSuspendHandler)(void *htc_handle);
18940 + A_STATUS (* deviceResumeHandler)(void *htc_handle);
18941 + A_STATUS (* deviceWakeupHandler)(void *htc_handle);
18942 + A_STATUS (* rwCompletionHandler)(void *context, A_STATUS status);
18943 + A_STATUS (* dsrHandler)(void *htc_handle);
18947 +#define HIF_OTHER_EVENTS (1 << 0) /* other interrupts (non-Recv) are pending, host
18948 + needs to read the register table to figure out what */
18949 +#define HIF_RECV_MSG_AVAIL (1 << 1) /* pending recv packet */
18951 +typedef struct _HIF_PENDING_EVENTS_INFO {
18953 + A_UINT32 LookAhead;
18954 +} HIF_PENDING_EVENTS_INFO;
18956 + /* function to get pending events , some HIF modules use special mechanisms
18957 + * to detect packet available and other interrupts */
18958 +typedef A_STATUS ( *HIF_PENDING_EVENTS_FUNC)(HIF_DEVICE *device,
18959 + HIF_PENDING_EVENTS_INFO *pEvents,
18960 + void *AsyncContext);
18962 +#define HIF_MASK_RECV TRUE
18963 +#define HIF_UNMASK_RECV FALSE
18964 + /* function to mask recv events */
18965 +typedef A_STATUS ( *HIF_MASK_UNMASK_RECV_EVENT)(HIF_DEVICE *device,
18967 + void *AsyncContext);
18971 + * This API is used by the HTC layer to initialize the HIF layer and to
18972 + * register different callback routines. Support for following events has
18973 + * been captured - DSR, Read/Write completion, Device insertion/removal,
18974 + * Device suspension/resumption/wakeup. In addition to this, the API is
18975 + * also used to register the name and the revision of the chip. The latter
18976 + * can be used to verify the revision of the chip read from the device
18977 + * before reporting it to HTC.
18979 +int HIFInit(HTC_CALLBACKS *callbacks);
18982 + * This API is used to provide the read/write interface over the specific bus
18984 + * address - Starting address in the dragon's address space. For mailbox
18985 + * writes, it refers to the start of the mbox boundary. It should
18986 + * be ensured that the last byte falls on the mailbox's EOM. For
18987 + * mailbox reads, it refers to the end of the mbox boundary.
18988 + * buffer - Pointer to the buffer containg the data to be transmitted or
18990 + * length - Amount of data to be transmitted or received.
18991 + * request - Characterizes the attributes of the command.
18994 +HIFReadWrite(HIF_DEVICE *device,
18995 + A_UINT32 address,
18998 + A_UINT32 request,
19002 + * This can be initiated from the unload driver context ie when the HTCShutdown
19003 + * routine is called.
19005 +void HIFShutDownDevice(HIF_DEVICE *device);
19008 + * This should translate to an acknowledgment to the bus driver indicating that
19009 + * the previous interrupt request has been serviced and the all the relevant
19010 + * sources have been cleared. HTC is ready to process more interrupts.
19011 + * This should prevent the bus driver from raising an interrupt unless the
19012 + * previous one has been serviced and acknowledged using the previous API.
19014 +void HIFAckInterrupt(HIF_DEVICE *device);
19016 +void HIFMaskInterrupt(HIF_DEVICE *device);
19018 +void HIFUnMaskInterrupt(HIF_DEVICE *device);
19021 + * This set of functions are to be used by the bus driver to notify
19022 + * the HIF module about various events.
19023 + * These are not implemented if the bus driver provides an alternative
19024 + * way for this notification though callbacks for instance.
19026 +int HIFInsertEventNotify(void);
19028 +int HIFRemoveEventNotify(void);
19030 +int HIFIRQEventNotify(void);
19032 +int HIFRWCompleteEventNotify(void);
19035 + * This function associates a opaque handle with the HIF layer
19036 + * to be used in communication with upper layer i.e. HTC.
19037 + * This would normaly be a pointer to htc_target data structure.
19039 +void HIFSetHandle(void *hif_handle, void *handle);
19042 +HIFConfigureDevice(HIF_DEVICE *device, HIF_DEVICE_CONFIG_OPCODE opcode,
19043 + void *config, A_UINT32 configLen);
19046 +#ifdef __cplusplus
19050 +#endif /* _HIF_H_ */
19051 diff --git a/drivers/sdio/function/wlan/ar6000/include/host_version.h b/drivers/sdio/function/wlan/ar6000/include/host_version.h
19052 new file mode 100644
19053 index 0000000..c090115
19055 +++ b/drivers/sdio/function/wlan/ar6000/include/host_version.h
19057 +#ifndef _HOST_VERSION_H_
19058 +#define _HOST_VERSION_H_
19060 + * Copyright (c) 2004-2005 Atheros Communications Inc.
19061 + * All rights reserved.
19063 + * This file contains version information for the sample host driver for the
19066 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/host_version.h#2 $
19069 + * This program is free software; you can redistribute it and/or modify
19070 + * it under the terms of the GNU General Public License version 2 as
19071 + * published by the Free Software Foundation;
19073 + * Software distributed under the License is distributed on an "AS
19074 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
19075 + * implied. See the License for the specific language governing
19076 + * rights and limitations under the License.
19082 +#ifdef __cplusplus
19086 +#include <AR6K_version.h>
19089 + * The version number is made up of major, minor, patch and build
19090 + * numbers. These are 16 bit numbers. The build and release script will
19091 + * set the build number using a Perforce counter. Here the build number is
19092 + * set to 9999 so that builds done without the build-release script are easily
19096 +#define ATH_SW_VER_MAJOR __VER_MAJOR_
19097 +#define ATH_SW_VER_MINOR __VER_MINOR_
19098 +#define ATH_SW_VER_PATCH __VER_PATCH_
19099 +#define ATH_SW_VER_BUILD 9999
19101 +#ifdef __cplusplus
19105 +#endif /* _HOST_VERSION_H_ */
19106 diff --git a/drivers/sdio/function/wlan/ar6000/include/htc.h b/drivers/sdio/function/wlan/ar6000/include/htc.h
19107 new file mode 100644
19108 index 0000000..152d867
19110 +++ b/drivers/sdio/function/wlan/ar6000/include/htc.h
19113 + * Copyright (c) 2007 Atheros Communications Inc.
19114 + * All rights reserved.
19116 + * $ATH_LICENSE_HOSTSDK0_C$
19124 +#ifndef ATH_TARGET
19125 +#include "athstartpack.h"
19128 +#define A_OFFSETOF(type,field) (int)(&(((type *)NULL)->field))
19130 +#define ASSEMBLE_UNALIGNED_UINT16(p,highbyte,lowbyte) \
19131 + (((A_UINT16)(((A_UINT8 *)(p))[(highbyte)])) << 8 | (A_UINT16)(((A_UINT8 *)(p))[(lowbyte)]))
19133 +/* alignment independent macros (little-endian) to fetch UINT16s or UINT8s from a
19134 + * structure using only the type and field name.
19135 + * Use these macros if there is the potential for unaligned buffer accesses. */
19136 +#define A_GET_UINT16_FIELD(p,type,field) \
19137 + ASSEMBLE_UNALIGNED_UINT16(p,\
19138 + A_OFFSETOF(type,field) + 1, \
19139 + A_OFFSETOF(type,field))
19141 +#define A_SET_UINT16_FIELD(p,type,field,value) \
19143 + ((A_UINT8 *)(p))[A_OFFSETOF(type,field)] = (A_UINT8)(value); \
19144 + ((A_UINT8 *)(p))[A_OFFSETOF(type,field) + 1] = (A_UINT8)((value) >> 8); \
19147 +#define A_GET_UINT8_FIELD(p,type,field) \
19148 + ((A_UINT8 *)(p))[A_OFFSETOF(type,field)]
19150 +#define A_SET_UINT8_FIELD(p,type,field,value) \
19151 + ((A_UINT8 *)(p))[A_OFFSETOF(type,field)] = (value)
19153 +/****** DANGER DANGER ***************
19155 + * The frame header length and message formats defined herein were
19156 + * selected to accommodate optimal alignment for target processing. This reduces code
19157 + * size and improves performance.
19159 + * Any changes to the header length may alter the alignment and cause exceptions
19160 + * on the target. When adding to the message structures insure that fields are
19161 + * properly aligned.
19165 +/* HTC frame header */
19166 +typedef PREPACK struct _HTC_FRAME_HDR{
19167 + /* do not remove or re-arrange these fields, these are minimally required
19168 + * to take advantage of 4-byte lookaheads in some hardware implementations */
19169 + A_UINT8 EndpointID;
19171 + A_UINT16 PayloadLen; /* length of data (including trailer) that follows the header */
19173 + /***** end of 4-byte lookahead ****/
19175 + A_UINT8 ControlBytes[2];
19177 + /* message payload starts after the header */
19179 +} POSTPACK HTC_FRAME_HDR;
19181 +/* frame header flags */
19182 +#define HTC_FLAGS_NEED_CREDIT_UPDATE (1 << 0)
19183 +#define HTC_FLAGS_RECV_TRAILER (1 << 1)
19186 +#define HTC_HDR_LENGTH (sizeof(HTC_FRAME_HDR))
19187 +#define HTC_MAX_TRAILER_LENGTH 255
19188 +#define HTC_MAX_PAYLOAD_LENGTH (2048 - sizeof(HTC_FRAME_HDR))
19190 +/* HTC control message IDs */
19192 + HTC_MSG_READY_ID = 1,
19193 + HTC_MSG_CONNECT_SERVICE_ID = 2,
19194 + HTC_MSG_CONNECT_SERVICE_RESPONSE_ID = 3,
19195 + HTC_MSG_SETUP_COMPLETE_ID = 4,
19198 +#define HTC_MAX_CONTROL_MESSAGE_LENGTH 256
19200 +/* base message ID header */
19201 +typedef PREPACK struct {
19202 + A_UINT16 MessageID;
19203 +} POSTPACK HTC_UNKNOWN_MSG;
19205 +/* HTC ready message
19206 + * direction : target-to-host */
19207 +typedef PREPACK struct {
19208 + A_UINT16 MessageID; /* ID */
19209 + A_UINT16 CreditCount; /* number of credits the target can offer */
19210 + A_UINT16 CreditSize; /* size of each credit */
19211 + A_UINT8 MaxEndpoints; /* maximum number of endpoints the target has resources for */
19213 +} POSTPACK HTC_READY_MSG;
19215 +#define HTC_SERVICE_META_DATA_MAX_LENGTH 128
19217 +/* connect service
19218 + * direction : host-to-target */
19219 +typedef PREPACK struct {
19220 + A_UINT16 MessageID;
19221 + A_UINT16 ServiceID; /* service ID of the service to connect to */
19222 + A_UINT16 ConnectionFlags; /* connection flags */
19224 +#define HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE (1 << 2) /* reduce credit dribbling when
19225 + the host needs credits */
19226 +#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK (0x3)
19227 +#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_FOURTH 0x0
19228 +#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF 0x1
19229 +#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_THREE_FOURTHS 0x2
19230 +#define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_UNITY 0x3
19232 + A_UINT8 ServiceMetaLength; /* length of meta data that follows */
19235 + /* service-specific meta data starts after the header */
19237 +} POSTPACK HTC_CONNECT_SERVICE_MSG;
19239 +/* connect response
19240 + * direction : target-to-host */
19241 +typedef PREPACK struct {
19242 + A_UINT16 MessageID;
19243 + A_UINT16 ServiceID; /* service ID that the connection request was made */
19244 + A_UINT8 Status; /* service connection status */
19245 + A_UINT8 EndpointID; /* assigned endpoint ID */
19246 + A_UINT16 MaxMsgSize; /* maximum expected message size on this endpoint */
19247 + A_UINT8 ServiceMetaLength; /* length of meta data that follows */
19250 + /* service-specific meta data starts after the header */
19252 +} POSTPACK HTC_CONNECT_SERVICE_RESPONSE_MSG;
19254 +typedef PREPACK struct {
19255 + A_UINT16 MessageID;
19256 + /* currently, no other fields */
19257 +} POSTPACK HTC_SETUP_COMPLETE_MSG;
19260 +/* connect response status codes */
19261 +#define HTC_SERVICE_SUCCESS 0 /* success */
19262 +#define HTC_SERVICE_NOT_FOUND 1 /* service could not be found */
19263 +#define HTC_SERVICE_FAILED 2 /* specific service failed the connect */
19264 +#define HTC_SERVICE_NO_RESOURCES 3 /* no resources (i.e. no more endpoints) */
19265 +#define HTC_SERVICE_NO_MORE_EP 4 /* specific service is not allowing any more
19268 +/* report record IDs */
19270 + HTC_RECORD_NULL = 0,
19271 + HTC_RECORD_CREDITS = 1,
19272 + HTC_RECORD_LOOKAHEAD = 2,
19275 +typedef PREPACK struct {
19276 + A_UINT8 RecordID; /* Record ID */
19277 + A_UINT8 Length; /* Length of record */
19278 +} POSTPACK HTC_RECORD_HDR;
19280 +typedef PREPACK struct {
19281 + A_UINT8 EndpointID; /* Endpoint that owns these credits */
19282 + A_UINT8 Credits; /* credits to report since last report */
19283 +} POSTPACK HTC_CREDIT_REPORT;
19285 +typedef PREPACK struct {
19286 + A_UINT8 PreValid; /* pre valid guard */
19287 + A_UINT8 LookAhead[4]; /* 4 byte lookahead */
19288 + A_UINT8 PostValid; /* post valid guard */
19290 + /* NOTE: the LookAhead array is guarded by a PreValid and Post Valid guard bytes.
19291 + * The PreValid bytes must equal the inverse of the PostValid byte */
19293 +} POSTPACK HTC_LOOKAHEAD_REPORT;
19295 +#ifndef ATH_TARGET
19296 +#include "athendpack.h"
19300 +#endif /* __HTC_H__ */
19302 diff --git a/drivers/sdio/function/wlan/ar6000/include/htc_api.h b/drivers/sdio/function/wlan/ar6000/include/htc_api.h
19303 new file mode 100644
19304 index 0000000..73b7df6
19306 +++ b/drivers/sdio/function/wlan/ar6000/include/htc_api.h
19310 + * Copyright (c) 2007 Atheros Communications Inc.
19311 + * All rights reserved.
19314 + * This program is free software; you can redistribute it and/or modify
19315 + * it under the terms of the GNU General Public License version 2 as
19316 + * published by the Free Software Foundation;
19318 + * Software distributed under the License is distributed on an "AS
19319 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
19320 + * implied. See the License for the specific language governing
19321 + * rights and limitations under the License.
19327 +#ifndef _HTC_API_H_
19328 +#define _HTC_API_H_
19331 +#include <htc_services.h>
19332 +#include "htc_packet.h"
19334 +#ifdef __cplusplus
19336 +#endif /* __cplusplus */
19338 +/* TODO.. for BMI */
19339 +#define ENDPOINT1 0
19340 +// TODO -remove me, but we have to fix BMI first
19341 +#define HTC_MAILBOX_NUM_MAX 4
19344 +/* ------ Endpoint IDS ------ */
19347 + ENDPOINT_UNUSED = -1,
19358 +} HTC_ENDPOINT_ID;
19360 +/* this is the amount of header room required by users of HTC */
19361 +#define HTC_HEADER_LEN HTC_HDR_LENGTH
19363 +typedef void *HTC_HANDLE;
19365 +typedef A_UINT16 HTC_SERVICE_ID;
19367 +typedef struct _HTC_INIT_INFO {
19368 + void (*AddInstance)(HTC_HANDLE);
19369 + void (*DeleteInstance)(void *Instance);
19370 + void (*TargetFailure)(void *Instance, A_STATUS Status);
19373 +/* per service connection send completion */
19374 +typedef void (*HTC_EP_SEND_PKT_COMPLETE)(void *,HTC_PACKET *);
19375 +/* per service connection pkt received */
19376 +typedef void (*HTC_EP_RECV_PKT)(void *,HTC_PACKET *);
19378 +/* Optional per service connection receive buffer re-fill callback,
19379 + * On some OSes (like Linux) packets are allocated from a global pool and indicated up
19380 + * to the network stack. The driver never gets the packets back from the OS. For these OSes
19381 + * a refill callback can be used to allocate and re-queue buffers into HTC.
19383 + * On other OSes, the network stack can call into the driver's OS-specifc "return_packet" handler and
19384 + * the driver can re-queue these buffers into HTC. In this regard a refill callback is
19386 +typedef void (*HTC_EP_RECV_REFILL)(void *, HTC_ENDPOINT_ID Endpoint);
19388 +/* Optional per service connection callback when a send queue is full. This can occur if the
19389 + * host continues queueing up TX packets faster than credits can arrive
19390 + * To prevent the host (on some Oses like Linux) from continuously queueing packets
19391 + * and consuming resources, this callback is provided so that that the host
19392 + * can disable TX in the subsystem (i.e. network stack)
19393 + * Other OSes require a "per-packet" indication_RAW_STREAM_NUM_MAX for each completed TX packet, this
19394 + * closed loop mechanism will prevent the network stack from overunning the NIC */
19395 +typedef void (*HTC_EP_SEND_QUEUE_FULL)(void *, HTC_ENDPOINT_ID Endpoint);
19397 +typedef struct _HTC_EP_CALLBACKS {
19398 + void *pContext; /* context for each callback */
19399 + HTC_EP_SEND_PKT_COMPLETE EpTxComplete; /* tx completion callback for connected endpoint */
19400 + HTC_EP_RECV_PKT EpRecv; /* receive callback for connected endpoint */
19401 + HTC_EP_RECV_REFILL EpRecvRefill; /* OPTIONAL receive re-fill callback for connected endpoint */
19402 + HTC_EP_SEND_QUEUE_FULL EpSendFull; /* OPTIONAL send full callback */
19403 +} HTC_EP_CALLBACKS;
19405 +/* service connection information */
19406 +typedef struct _HTC_SERVICE_CONNECT_REQ {
19407 + HTC_SERVICE_ID ServiceID; /* service ID to connect to */
19408 + A_UINT16 ConnectionFlags; /* connection flags, see htc protocol definition */
19409 + A_UINT8 *pMetaData; /* ptr to optional service-specific meta-data */
19410 + A_UINT8 MetaDataLength; /* optional meta data length */
19411 + HTC_EP_CALLBACKS EpCallbacks; /* endpoint callbacks */
19412 + int MaxSendQueueDepth; /* maximum depth of any send queue */
19413 +} HTC_SERVICE_CONNECT_REQ;
19415 +/* service connection response information */
19416 +typedef struct _HTC_SERVICE_CONNECT_RESP {
19417 + A_UINT8 *pMetaData; /* caller supplied buffer to optional meta-data */
19418 + A_UINT8 BufferLength; /* length of caller supplied buffer */
19419 + A_UINT8 ActualLength; /* actual length of meta data */
19420 + HTC_ENDPOINT_ID Endpoint; /* endpoint to communicate over */
19421 + int MaxMsgLength; /* max length of all messages over this endpoint */
19422 + A_UINT8 ConnectRespCode; /* connect response code from target */
19423 +} HTC_SERVICE_CONNECT_RESP;
19425 +/* endpoint distribution structure */
19426 +typedef struct _HTC_ENDPOINT_CREDIT_DIST {
19427 + struct _HTC_ENDPOINT_CREDIT_DIST *pNext;
19428 + struct _HTC_ENDPOINT_CREDIT_DIST *pPrev;
19429 + HTC_SERVICE_ID ServiceID; /* Service ID (set by HTC) */
19430 + HTC_ENDPOINT_ID Endpoint; /* endpoint for this distribution struct (set by HTC) */
19431 + A_UINT32 DistFlags; /* distribution flags, distribution function can
19432 + set default activity using SET_EP_ACTIVE() macro */
19433 + int TxCreditsNorm; /* credits for normal operation, anything above this
19434 + indicates the endpoint is over-subscribed, this field
19435 + is only relevant to the credit distribution function */
19436 + int TxCreditsMin; /* floor for credit distribution, this field is
19437 + only relevant to the credit distribution function */
19438 + int TxCreditsAssigned; /* number of credits assigned to this EP, this field
19439 + is only relevant to the credit dist function */
19440 + int TxCredits; /* current credits available, this field is used by
19441 + HTC to determine whether a message can be sent or
19442 + must be queued */
19443 + int TxCreditsToDist; /* pending credits to distribute on this endpoint, this
19444 + is set by HTC when credit reports arrive.
19445 + The credit distribution functions sets this to zero
19446 + when it distributes the credits */
19447 + int TxCreditsSeek; /* this is the number of credits that the current pending TX
19448 + packet needs to transmit. This is set by HTC when
19449 + and endpoint needs credits in order to transmit */
19450 + int TxCreditSize; /* size in bytes of each credit (set by HTC) */
19451 + int TxCreditsPerMaxMsg; /* credits required for a maximum sized messages (set by HTC) */
19452 + void *pHTCReserved; /* reserved for HTC use */
19453 +} HTC_ENDPOINT_CREDIT_DIST;
19455 +#define HTC_EP_ACTIVE (1 << 31)
19457 +/* macro to check if an endpoint has gone active, useful for credit
19458 + * distributions */
19459 +#define IS_EP_ACTIVE(epDist) ((epDist)->DistFlags & HTC_EP_ACTIVE)
19460 +#define SET_EP_ACTIVE(epDist) (epDist)->DistFlags |= HTC_EP_ACTIVE
19462 + /* credit distibution code that is passed into the distrbution function,
19463 + * there are mandatory and optional codes that must be handled */
19464 +typedef enum _HTC_CREDIT_DIST_REASON {
19465 + HTC_CREDIT_DIST_SEND_COMPLETE = 0, /* credits available as a result of completed
19466 + send operations (MANDATORY) resulting in credit reports */
19467 + HTC_CREDIT_DIST_ACTIVITY_CHANGE = 1, /* a change in endpoint activity occured (OPTIONAL) */
19468 + HTC_CREDIT_DIST_SEEK_CREDITS, /* an endpoint needs to "seek" credits (OPTIONAL) */
19469 + HTC_DUMP_CREDIT_STATE /* for debugging, dump any state information that is kept by
19470 + the distribution function */
19471 +} HTC_CREDIT_DIST_REASON;
19473 +typedef void (*HTC_CREDIT_DIST_CALLBACK)(void *Context,
19474 + HTC_ENDPOINT_CREDIT_DIST *pEPList,
19475 + HTC_CREDIT_DIST_REASON Reason);
19477 +typedef void (*HTC_CREDIT_INIT_CALLBACK)(void *Context,
19478 + HTC_ENDPOINT_CREDIT_DIST *pEPList,
19479 + int TotalCredits);
19481 + /* endpoint statistics action */
19482 +typedef enum _HTC_ENDPOINT_STAT_ACTION {
19483 + HTC_EP_STAT_SAMPLE = 0, /* only read statistics */
19484 + HTC_EP_STAT_SAMPLE_AND_CLEAR = 1, /* sample and immediately clear statistics */
19485 + HTC_EP_STAT_CLEAR /* clear only */
19486 +} HTC_ENDPOINT_STAT_ACTION;
19488 + /* endpoint statistics */
19489 +typedef struct _HTC_ENDPOINT_STATS {
19490 + A_UINT32 TxCreditLowIndications; /* number of times the host set the credit-low flag in a send message on
19492 + A_UINT32 TxIssued; /* running count of TX packets issued */
19493 + A_UINT32 TxCreditRpts; /* running count of total credit reports received for this endpoint */
19494 + A_UINT32 TxCreditRptsFromRx;
19495 + A_UINT32 TxCreditRptsFromOther;
19496 + A_UINT32 TxCreditRptsFromEp0;
19497 + A_UINT32 TxCreditsFromRx; /* count of credits received via Rx packets on this endpoint */
19498 + A_UINT32 TxCreditsFromOther; /* count of credits received via another endpoint */
19499 + A_UINT32 TxCreditsFromEp0; /* count of credits received via another endpoint */
19500 + A_UINT32 TxCreditsConsummed; /* count of consummed credits */
19501 + A_UINT32 TxCreditsReturned; /* count of credits returned */
19502 + A_UINT32 RxReceived; /* count of RX packets received */
19503 + A_UINT32 RxLookAheads; /* count of lookahead records
19504 + found in messages received on this endpoint */
19505 +} HTC_ENDPOINT_STATS;
19507 +/* ------ Function Prototypes ------ */
19508 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19509 + @desc: Initialize HTC
19510 + @function name: HTCInit
19511 + @input: pInfo - initialization information
19513 + @return: A_OK on success
19514 + @notes: The caller initializes global HTC state and registers various instance
19515 + notification callbacks (see HTC_INIT_INFO).
19518 + @see also: HTCShutdown
19519 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19520 +A_STATUS HTCInit(HTC_INIT_INFO *pInfo);
19521 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19522 + @desc: Get the underlying HIF device handle
19523 + @function name: HTCGetHifDevice
19524 + @input: HTCHandle - handle passed into the AddInstance callback
19526 + @return: opaque HIF device handle usable in HIF API calls.
19530 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19531 +void *HTCGetHifDevice(HTC_HANDLE HTCHandle);
19532 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19533 + @desc: Set the associated instance for the HTC handle
19534 + @function name: HTCSetInstance
19535 + @input: HTCHandle - handle passed into the AddInstance callback
19536 + Instance - caller supplied instance object
19539 + @notes: Caller must set the instance information for the HTC handle in order to receive
19540 + notifications for instance deletion (DeleteInstance callback is called) and for target
19541 + failure notification.
19544 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19545 +void HTCSetInstance(HTC_HANDLE HTCHandle, void *Instance);
19546 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19547 + @desc: Set credit distribution parameters
19548 + @function name: HTCSetCreditDistribution
19549 + @input: HTCHandle - HTC handle
19550 + pCreditDistCont - caller supplied context to pass into distribution functions
19551 + CreditDistFunc - Distribution function callback
19552 + CreditDistInit - Credit Distribution initialization callback
19553 + ServicePriorityOrder - Array containing list of service IDs, lowest index is highest
19555 + ListLength - number of elements in ServicePriorityOrder
19558 + @notes: The user can set a custom credit distribution function to handle special requirements
19559 + for each endpoint. A default credit distribution routine can be used by setting
19560 + CreditInitFunc to NULL. The default credit distribution is only provided for simple
19561 + "fair" credit distribution without regard to any prioritization.
19565 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19566 +void HTCSetCreditDistribution(HTC_HANDLE HTCHandle,
19567 + void *pCreditDistContext,
19568 + HTC_CREDIT_DIST_CALLBACK CreditDistFunc,
19569 + HTC_CREDIT_INIT_CALLBACK CreditInitFunc,
19570 + HTC_SERVICE_ID ServicePriorityOrder[],
19572 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19573 + @desc: Wait for the target to indicate the HTC layer is ready
19574 + @function name: HTCWaitTarget
19575 + @input: HTCHandle - HTC handle
19578 + @notes: This API blocks until the target responds with an HTC ready message.
19579 + The caller should not connect services until the target has indicated it is
19582 + @see also: HTCConnectService
19583 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19584 +A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle);
19585 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19586 + @desc: Start target service communications
19587 + @function name: HTCStart
19588 + @input: HTCHandle - HTC handle
19591 + @notes: This API indicates to the target that the service connection phase is complete
19592 + and the target can freely start all connected services. This API should only be
19593 + called AFTER all service connections have been made. TCStart will issue a
19594 + SETUP_COMPLETE message to the target to indicate that all service connections
19595 + have been made and the target can start communicating over the endpoints.
19597 + @see also: HTCConnectService
19598 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19599 +A_STATUS HTCStart(HTC_HANDLE HTCHandle);
19600 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19601 + @desc: Add receive packet to HTC
19602 + @function name: HTCAddReceivePkt
19603 + @input: HTCHandle - HTC handle
19604 + pPacket - HTC receive packet to add
19606 + @return: A_OK on success
19607 + @notes: user must supply HTC packets for capturing incomming HTC frames. The caller
19608 + must initialize each HTC packet using the SET_HTC_PACKET_INFO_RX_REFILL()
19612 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19613 +A_STATUS HTCAddReceivePkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket);
19614 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19615 + @desc: Connect to an HTC service
19616 + @function name: HTCConnectService
19617 + @input: HTCHandle - HTC handle
19618 + pReq - connection details
19619 + @output: pResp - connection response
19621 + @notes: Service connections must be performed before HTCStart. User provides callback handlers
19622 + for various endpoint events.
19624 + @see also: HTCStart
19625 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19626 +A_STATUS HTCConnectService(HTC_HANDLE HTCHandle,
19627 + HTC_SERVICE_CONNECT_REQ *pReq,
19628 + HTC_SERVICE_CONNECT_RESP *pResp);
19629 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19630 + @desc: Send an HTC packet
19631 + @function name: HTCSendPkt
19632 + @input: HTCHandle - HTC handle
19633 + pPacket - packet to send
19636 + @notes: Caller must initialize packet using SET_HTC_PACKET_INFO_TX() macro.
19637 + This interface is fully asynchronous. On error, HTC SendPkt will
19638 + call the registered Endpoint callback to cleanup the packet.
19640 + @see also: HTCFlushEndpoint
19641 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19642 +A_STATUS HTCSendPkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket);
19643 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19644 + @desc: Stop HTC service communications
19645 + @function name: HTCStop
19646 + @input: HTCHandle - HTC handle
19649 + @notes: HTC communications is halted. All receive and pending TX packets will
19653 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19654 +void HTCStop(HTC_HANDLE HTCHandle);
19655 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19656 + @desc: Shutdown HTC
19657 + @function name: HTCShutdown
19661 + @notes: This cleans up all resources allocated by HTCInit().
19663 + @see also: HTCInit
19664 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19665 +void HTCShutDown(void);
19666 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19667 + @desc: Flush pending TX packets
19668 + @function name: HTCFlushEndpoint
19669 + @input: HTCHandle - HTC handle
19670 + Endpoint - Endpoint to flush
19674 + @notes: The Tag parameter is used to selectively flush packets with matching tags.
19675 + The value of 0 forces all packets to be flush regardless of tag.
19677 + @see also: HTCSendPkt
19678 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19679 +void HTCFlushEndpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, HTC_TX_TAG Tag);
19680 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19681 + @desc: Dump credit distribution state
19682 + @function name: HTCDumpCreditStates
19683 + @input: HTCHandle - HTC handle
19686 + @notes: This dumps all credit distribution information to the debugger
19689 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19690 +void HTCDumpCreditStates(HTC_HANDLE HTCHandle);
19691 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19692 + @desc: Indicate a traffic activity change on an endpoint
19693 + @function name: HTCIndicateActivityChange
19694 + @input: HTCHandle - HTC handle
19695 + Endpoint - endpoint in which activity has changed
19696 + Active - TRUE if active, FALSE if it has become inactive
19699 + @notes: This triggers the registered credit distribution function to
19700 + re-adjust credits for active/inactive endpoints.
19703 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19704 +void HTCIndicateActivityChange(HTC_HANDLE HTCHandle,
19705 + HTC_ENDPOINT_ID Endpoint,
19708 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19709 + @desc: Get endpoint statistics
19710 + @function name: HTCGetEndpointStatistics
19711 + @input: HTCHandle - HTC handle
19712 + Endpoint - Endpoint identifier
19713 + Action - action to take with statistics
19715 + pStats - statistics that were sampled (can be NULL if Action is HTC_EP_STAT_CLEAR)
19717 + @return: TRUE if statistics profiling is enabled, otherwise FALSE.
19719 + @notes: Statistics is a compile-time option and this function may return FALSE
19720 + if HTC is not compiled with profiling.
19722 + The caller can specify the statistic "action" to take when sampling
19723 + the statistics. This includes:
19725 + HTC_EP_STAT_SAMPLE: The pStats structure is filled with the current values.
19726 + HTC_EP_STAT_SAMPLE_AND_CLEAR: The structure is filled and the current statistics
19728 + HTC_EP_STAT_CLEA : the statistics are cleared, the called can pass a NULL value for
19733 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19734 +A_BOOL HTCGetEndpointStatistics(HTC_HANDLE HTCHandle,
19735 + HTC_ENDPOINT_ID Endpoint,
19736 + HTC_ENDPOINT_STAT_ACTION Action,
19737 + HTC_ENDPOINT_STATS *pStats);
19739 +#ifdef __cplusplus
19743 +#endif /* _HTC_API_H_ */
19744 diff --git a/drivers/sdio/function/wlan/ar6000/include/htc_packet.h b/drivers/sdio/function/wlan/ar6000/include/htc_packet.h
19745 new file mode 100644
19746 index 0000000..9ce8718
19748 +++ b/drivers/sdio/function/wlan/ar6000/include/htc_packet.h
19752 + * Copyright (c) 2007 Atheros Communications Inc.
19753 + * All rights reserved.
19756 + * This program is free software; you can redistribute it and/or modify
19757 + * it under the terms of the GNU General Public License version 2 as
19758 + * published by the Free Software Foundation;
19760 + * Software distributed under the License is distributed on an "AS
19761 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
19762 + * implied. See the License for the specific language governing
19763 + * rights and limitations under the License.
19769 +#ifndef HTC_PACKET_H_
19770 +#define HTC_PACKET_H_
19773 +#include "dl_list.h"
19775 +struct _HTC_PACKET;
19777 +typedef void (* HTC_PACKET_COMPLETION)(void *,struct _HTC_PACKET *);
19779 +typedef A_UINT16 HTC_TX_TAG;
19781 +typedef struct _HTC_TX_PACKET_INFO {
19782 + HTC_TX_TAG Tag; /* tag used to selective flush packets */
19783 +} HTC_TX_PACKET_INFO;
19785 +#define HTC_TX_PACKET_TAG_ALL 0 /* a tag of zero is reserved and used to flush ALL packets */
19786 +#define HTC_TX_PACKET_TAG_INTERNAL 1 /* internal tags start here */
19787 +#define HTC_TX_PACKET_TAG_USER_DEFINED (HTC_TX_PACKET_TAG_INTERNAL + 9) /* user-defined tags start here */
19789 +typedef struct _HTC_RX_PACKET_INFO {
19790 + A_UINT32 Unused; /* for future use and to make compilers happy */
19791 +} HTC_RX_PACKET_INFO;
19793 +/* wrapper around endpoint-specific packets */
19794 +typedef struct _HTC_PACKET {
19795 + DL_LIST ListLink; /* double link */
19796 + void *pPktContext; /* caller's per packet specific context */
19798 + A_UINT8 *pBufferStart; /* the true buffer start , the caller can
19799 + store the real buffer start here. In
19800 + receive callbacks, the HTC layer sets pBuffer
19801 + to the start of the payload past the header. This
19802 + field allows the caller to reset pBuffer when it
19803 + recycles receive packets back to HTC */
19805 + * Pointer to the start of the buffer. In the transmit
19806 + * direction this points to the start of the payload. In the
19807 + * receive direction, however, the buffer when queued up
19808 + * points to the start of the HTC header but when returned
19809 + * to the caller points to the start of the payload
19811 + A_UINT8 *pBuffer; /* payload start (RX/TX) */
19812 + A_UINT32 BufferLength; /* length of buffer */
19813 + A_UINT32 ActualLength; /* actual length of payload */
19814 + int Endpoint; /* endpoint that this packet was sent/recv'd from */
19815 + A_STATUS Status; /* completion status */
19817 + HTC_TX_PACKET_INFO AsTx; /* Tx Packet specific info */
19818 + HTC_RX_PACKET_INFO AsRx; /* Rx Packet specific info */
19821 + /* the following fields are for internal HTC use */
19822 + HTC_PACKET_COMPLETION Completion; /* completion */
19823 + void *pContext; /* HTC private completion context */
19824 + A_UINT32 HTCReserved; /* reserved */
19829 +#define COMPLETE_HTC_PACKET(p,status) \
19831 + (p)->Status = (status); \
19832 + (p)->Completion((p)->pContext,(p)); \
19835 +#define INIT_HTC_PACKET_INFO(p,b,len) \
19837 + (p)->pBufferStart = (b); \
19838 + (p)->BufferLength = (len); \
19841 +/* macro to set an initial RX packet for refilling HTC */
19842 +#define SET_HTC_PACKET_INFO_RX_REFILL(p,c,b,len,ep) \
19844 + (p)->pPktContext = (c); \
19845 + (p)->pBuffer = (b); \
19846 + (p)->pBufferStart = (b); \
19847 + (p)->BufferLength = (len); \
19848 + (p)->Endpoint = (ep); \
19851 +/* fast macro to recycle an RX packet that will be re-queued to HTC */
19852 +#define HTC_PACKET_RESET_RX(p) \
19853 + (p)->pBuffer = (p)->pBufferStart
19855 +/* macro to set packet parameters for TX */
19856 +#define SET_HTC_PACKET_INFO_TX(p,c,b,len,ep,tag) \
19858 + (p)->pPktContext = (c); \
19859 + (p)->pBuffer = (b); \
19860 + (p)->ActualLength = (len); \
19861 + (p)->Endpoint = (ep); \
19862 + (p)->PktInfo.AsTx.Tag = (tag); \
19865 +/* HTC Packet Queueing Macros */
19866 +typedef DL_LIST HTC_PACKET_QUEUE;
19867 +/* initialize queue */
19868 +#define INIT_HTC_PACKET_QUEUE(pQ) DL_LIST_INIT((pQ))
19869 +/* enqueue HTC packet to the tail of the queue */
19870 +#define HTC_PACKET_ENQUEUE(pQ,p) DL_ListInsertTail((pQ),&(p)->ListLink)
19871 +/* test if a queue is empty */
19872 +#define HTC_QUEUE_EMPTY(pQ) DL_LIST_IS_EMPTY((pQ))
19873 +/* get packet at head without removing it */
19874 +#define HTC_GET_PKT_AT_HEAD(pQ) A_CONTAINING_STRUCT((DL_LIST_GET_ITEM_AT_HEAD(pQ)),HTC_PACKET,ListLink);
19875 +/* remove a packet from the current list it is linked to */
19876 +#define HTC_PACKET_REMOVE(p) DL_ListRemove(&(p)->ListLink)
19878 +/* dequeue an HTC packet from the head of the queue */
19879 +static INLINE HTC_PACKET *HTC_PACKET_DEQUEUE(HTC_PACKET_QUEUE *queue) {
19880 + DL_LIST *pItem = DL_ListRemoveItemFromHead(queue);
19881 + if (pItem != NULL) {
19882 + return A_CONTAINING_STRUCT(pItem, HTC_PACKET, ListLink);
19887 +#endif /*HTC_PACKET_H_*/
19888 diff --git a/drivers/sdio/function/wlan/ar6000/include/htc_services.h b/drivers/sdio/function/wlan/ar6000/include/htc_services.h
19889 new file mode 100644
19890 index 0000000..fc6fc29
19892 +++ b/drivers/sdio/function/wlan/ar6000/include/htc_services.h
19895 + * Copyright (c) 2007 Atheros Communications Inc.
19896 + * All rights reserved.
19898 + * $ATH_LICENSE_HOSTSDK0_C$
19902 +#ifndef __HTC_SERVICES_H__
19903 +#define __HTC_SERVICES_H__
19905 +/* Current service IDs */
19908 + RSVD_SERVICE_GROUP = 0,
19909 + WMI_SERVICE_GROUP = 1,
19911 + HTC_TEST_GROUP = 254,
19912 + HTC_SERVICE_GROUP_LAST = 255
19913 +}HTC_SERVICE_GROUP_IDS;
19915 +#define MAKE_SERVICE_ID(group,index) \
19916 + (int)(((int)group << 8) | (int)(index))
19918 +/* NOTE: service ID of 0x0000 is reserved and should never be used */
19919 +#define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP,1)
19920 +#define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,0)
19921 +#define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,1)
19922 +#define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,2)
19923 +#define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,3)
19924 +#define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP,4)
19925 +#define WMI_MAX_SERVICES 5
19927 +/* raw stream service (i.e. flash, tcmd, calibration apps) */
19928 +#define HTC_RAW_STREAMS_SVC MAKE_SERVICE_ID(HTC_TEST_GROUP,0)
19930 +#endif /*HTC_SERVICES_H_*/
19931 diff --git a/drivers/sdio/function/wlan/ar6000/include/ieee80211.h b/drivers/sdio/function/wlan/ar6000/include/ieee80211.h
19932 new file mode 100644
19933 index 0000000..7090040
19935 +++ b/drivers/sdio/function/wlan/ar6000/include/ieee80211.h
19938 + * Copyright (c) 2001 Atsushi Onoe
19939 + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
19940 + * Copyright (c) 2006 Atheros Communications, Inc.
19942 + * Wireless Network driver for Atheros AR6001
19943 + * All rights reserved.
19945 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19946 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19947 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19948 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19949 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19950 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19951 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19952 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19953 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19954 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19957 +#ifndef _NET80211_IEEE80211_H_
19958 +#define _NET80211_IEEE80211_H_
19960 +#include "athstartpack.h"
19963 + * 802.11 protocol definitions.
19966 +#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
19967 +/* is 802.11 address multicast/broadcast? */
19968 +#define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01)
19969 +#define IEEE80211_ADDR_EQ(addr1, addr2) \
19970 + (A_MEMCMP(addr1, addr2, IEEE80211_ADDR_LEN) == 0)
19972 +#define IEEE80211_KEYBUF_SIZE 16
19973 +#define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx and rx */
19976 + * NB: these values are ordered carefully; there are lots of
19977 + * of implications in any reordering. In particular beware
19978 + * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
19980 +#define IEEE80211_CIPHER_WEP 0
19981 +#define IEEE80211_CIPHER_TKIP 1
19982 +#define IEEE80211_CIPHER_AES_OCB 2
19983 +#define IEEE80211_CIPHER_AES_CCM 3
19984 +#define IEEE80211_CIPHER_CKIP 5
19985 +#define IEEE80211_CIPHER_CCKM_KRK 6
19986 +#define IEEE80211_CIPHER_NONE 7 /* pseudo value */
19988 +#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1)
19990 +#define IEEE80211_IS_VALID_WEP_CIPHER_LEN(len) \
19991 + (((len) == 5) || ((len) == 13) || ((len) == 16))
19996 + * generic definitions for IEEE 802.11 frames
19998 +PREPACK struct ieee80211_frame {
20000 + A_UINT8 i_dur[2];
20001 + A_UINT8 i_addr1[IEEE80211_ADDR_LEN];
20002 + A_UINT8 i_addr2[IEEE80211_ADDR_LEN];
20003 + A_UINT8 i_addr3[IEEE80211_ADDR_LEN];
20004 + A_UINT8 i_seq[2];
20005 + /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
20009 +#define IEEE80211_FC0_VERSION_MASK 0x03
20010 +#define IEEE80211_FC0_VERSION_SHIFT 0
20011 +#define IEEE80211_FC0_VERSION_0 0x00
20012 +#define IEEE80211_FC0_TYPE_MASK 0x0c
20013 +#define IEEE80211_FC0_TYPE_SHIFT 2
20014 +#define IEEE80211_FC0_TYPE_MGT 0x00
20015 +#define IEEE80211_FC0_TYPE_CTL 0x04
20016 +#define IEEE80211_FC0_TYPE_DATA 0x08
20018 +#define IEEE80211_FC0_SUBTYPE_MASK 0xf0
20019 +#define IEEE80211_FC0_SUBTYPE_SHIFT 4
20020 +/* for TYPE_MGT */
20021 +#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
20022 +#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
20023 +#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
20024 +#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
20025 +#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
20026 +#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
20027 +#define IEEE80211_FC0_SUBTYPE_BEACON 0x80
20028 +#define IEEE80211_FC0_SUBTYPE_ATIM 0x90
20029 +#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
20030 +#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
20031 +#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
20032 +/* for TYPE_CTL */
20033 +#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
20034 +#define IEEE80211_FC0_SUBTYPE_RTS 0xb0
20035 +#define IEEE80211_FC0_SUBTYPE_CTS 0xc0
20036 +#define IEEE80211_FC0_SUBTYPE_ACK 0xd0
20037 +#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
20038 +#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
20039 +/* for TYPE_DATA (bit combination) */
20040 +#define IEEE80211_FC0_SUBTYPE_DATA 0x00
20041 +#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
20042 +#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
20043 +#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
20044 +#define IEEE80211_FC0_SUBTYPE_NODATA 0x40
20045 +#define IEEE80211_FC0_SUBTYPE_CFACK 0x50
20046 +#define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60
20047 +#define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
20048 +#define IEEE80211_FC0_SUBTYPE_QOS 0x80
20049 +#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
20051 +#define IEEE80211_FC1_DIR_MASK 0x03
20052 +#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
20053 +#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
20054 +#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
20055 +#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
20057 +#define IEEE80211_FC1_MORE_FRAG 0x04
20058 +#define IEEE80211_FC1_RETRY 0x08
20059 +#define IEEE80211_FC1_PWR_MGT 0x10
20060 +#define IEEE80211_FC1_MORE_DATA 0x20
20061 +#define IEEE80211_FC1_WEP 0x40
20062 +#define IEEE80211_FC1_ORDER 0x80
20064 +#define IEEE80211_SEQ_FRAG_MASK 0x000f
20065 +#define IEEE80211_SEQ_FRAG_SHIFT 0
20066 +#define IEEE80211_SEQ_SEQ_MASK 0xfff0
20067 +#define IEEE80211_SEQ_SEQ_SHIFT 4
20069 +#define IEEE80211_NWID_LEN 32
20072 + * 802.11 rate set.
20074 +#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
20075 +#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
20077 +#define WMM_NUM_AC 4 /* 4 AC categories */
20079 +#define WMM_PARAM_ACI_M 0x60 /* Mask for ACI field */
20080 +#define WMM_PARAM_ACI_S 5 /* Shift for ACI field */
20081 +#define WMM_PARAM_ACM_M 0x10 /* Mask for ACM bit */
20082 +#define WMM_PARAM_ACM_S 4 /* Shift for ACM bit */
20083 +#define WMM_PARAM_AIFSN_M 0x0f /* Mask for aifsn field */
20084 +#define WMM_PARAM_LOGCWMIN_M 0x0f /* Mask for CwMin field (in log) */
20085 +#define WMM_PARAM_LOGCWMAX_M 0xf0 /* Mask for CwMax field (in log) */
20086 +#define WMM_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */
20088 +#define WMM_AC_TO_TID(_ac) ( \
20089 + ((_ac) == WMM_AC_VO) ? 6 : \
20090 + ((_ac) == WMM_AC_VI) ? 5 : \
20091 + ((_ac) == WMM_AC_BK) ? 1 : \
20094 +#define TID_TO_WMM_AC(_tid) ( \
20095 + ((_tid) < 1) ? WMM_AC_BE : \
20096 + ((_tid) < 3) ? WMM_AC_BK : \
20097 + ((_tid) < 6) ? WMM_AC_VI : \
20100 + * Management information element payloads.
20104 + IEEE80211_ELEMID_SSID = 0,
20105 + IEEE80211_ELEMID_RATES = 1,
20106 + IEEE80211_ELEMID_FHPARMS = 2,
20107 + IEEE80211_ELEMID_DSPARMS = 3,
20108 + IEEE80211_ELEMID_CFPARMS = 4,
20109 + IEEE80211_ELEMID_TIM = 5,
20110 + IEEE80211_ELEMID_IBSSPARMS = 6,
20111 + IEEE80211_ELEMID_COUNTRY = 7,
20112 + IEEE80211_ELEMID_CHALLENGE = 16,
20113 + /* 17-31 reserved for challenge text extension */
20114 + IEEE80211_ELEMID_PWRCNSTR = 32,
20115 + IEEE80211_ELEMID_PWRCAP = 33,
20116 + IEEE80211_ELEMID_TPCREQ = 34,
20117 + IEEE80211_ELEMID_TPCREP = 35,
20118 + IEEE80211_ELEMID_SUPPCHAN = 36,
20119 + IEEE80211_ELEMID_CHANSWITCH = 37,
20120 + IEEE80211_ELEMID_MEASREQ = 38,
20121 + IEEE80211_ELEMID_MEASREP = 39,
20122 + IEEE80211_ELEMID_QUIET = 40,
20123 + IEEE80211_ELEMID_IBSSDFS = 41,
20124 + IEEE80211_ELEMID_ERP = 42,
20125 + IEEE80211_ELEMID_RSN = 48,
20126 + IEEE80211_ELEMID_XRATES = 50,
20127 + IEEE80211_ELEMID_TPC = 150,
20128 + IEEE80211_ELEMID_CCKM = 156,
20129 + IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
20132 +#define ATH_OUI 0x7f0300 /* Atheros OUI */
20133 +#define ATH_OUI_TYPE 0x01
20134 +#define ATH_OUI_SUBTYPE 0x01
20135 +#define ATH_OUI_VERSION 0x00
20137 +#define WPA_OUI 0xf25000
20138 +#define WPA_OUI_TYPE 0x01
20139 +#define WPA_VERSION 1 /* current supported version */
20141 +#define WPA_CSE_NULL 0x00
20142 +#define WPA_CSE_WEP40 0x01
20143 +#define WPA_CSE_TKIP 0x02
20144 +#define WPA_CSE_CCMP 0x04
20145 +#define WPA_CSE_WEP104 0x05
20147 +#define WPA_ASE_NONE 0x00
20148 +#define WPA_ASE_8021X_UNSPEC 0x01
20149 +#define WPA_ASE_8021X_PSK 0x02
20151 +#define RSN_OUI 0xac0f00
20152 +#define RSN_VERSION 1 /* current supported version */
20154 +#define RSN_CSE_NULL 0x00
20155 +#define RSN_CSE_WEP40 0x01
20156 +#define RSN_CSE_TKIP 0x02
20157 +#define RSN_CSE_WRAP 0x03
20158 +#define RSN_CSE_CCMP 0x04
20159 +#define RSN_CSE_WEP104 0x05
20161 +#define RSN_ASE_NONE 0x00
20162 +#define RSN_ASE_8021X_UNSPEC 0x01
20163 +#define RSN_ASE_8021X_PSK 0x02
20165 +#define RSN_CAP_PREAUTH 0x01
20167 +#define WMM_OUI 0xf25000
20168 +#define WMM_OUI_TYPE 0x02
20169 +#define WMM_INFO_OUI_SUBTYPE 0x00
20170 +#define WMM_PARAM_OUI_SUBTYPE 0x01
20171 +#define WMM_VERSION 1
20173 +/* WMM stream classes */
20174 +#define WMM_NUM_AC 4
20175 +#define WMM_AC_BE 0 /* best effort */
20176 +#define WMM_AC_BK 1 /* background */
20177 +#define WMM_AC_VI 2 /* video */
20178 +#define WMM_AC_VO 3 /* voice */
20180 +/* TSPEC related */
20181 +#define ACTION_CATEGORY_CODE_TSPEC 17
20182 +#define ACTION_CODE_TSPEC_ADDTS 0
20183 +#define ACTION_CODE_TSPEC_ADDTS_RESP 1
20184 +#define ACTION_CODE_TSPEC_DELTS 2
20187 + TSPEC_STATUS_CODE_ADMISSION_ACCEPTED = 0,
20188 + TSPEC_STATUS_CODE_ADDTS_INVALID_PARAMS = 0x1,
20189 + TSPEC_STATUS_CODE_ADDTS_REQUEST_REFUSED = 0x3,
20190 + TSPEC_STATUS_CODE_UNSPECIFIED_QOS_RELATED_FAILURE = 0xC8,
20191 + TSPEC_STATUS_CODE_REQUESTED_REFUSED_POLICY_CONFIGURATION = 0xC9,
20192 + TSPEC_STATUS_CODE_INSUFFCIENT_BANDWIDTH = 0xCA,
20193 + TSPEC_STATUS_CODE_INVALID_PARAMS = 0xCB,
20194 + TSPEC_STATUS_CODE_DELTS_SENT = 0x30,
20195 + TSPEC_STATUS_CODE_DELTS_RECV = 0x31,
20196 +} TSPEC_STATUS_CODE;
20199 + * WMM/802.11e Tspec Element
20201 +typedef PREPACK struct wmm_tspec_ie_t {
20202 + A_UINT8 elementId;
20206 + A_UINT8 ouiSubType;
20208 + A_UINT16 tsInfo_info;
20209 + A_UINT8 tsInfo_reserved;
20210 + A_UINT16 nominalMSDU;
20211 + A_UINT16 maxMSDU;
20212 + A_UINT32 minServiceInt;
20213 + A_UINT32 maxServiceInt;
20214 + A_UINT32 inactivityInt;
20215 + A_UINT32 suspensionInt;
20216 + A_UINT32 serviceStartTime;
20217 + A_UINT32 minDataRate;
20218 + A_UINT32 meanDataRate;
20219 + A_UINT32 peakDataRate;
20220 + A_UINT32 maxBurstSize;
20221 + A_UINT32 delayBound;
20222 + A_UINT32 minPhyRate;
20224 + A_UINT16 mediumTime;
20225 +} POSTPACK WMM_TSPEC_IE;
20229 + * BEACON management packets
20231 + * octet timestamp[8]
20232 + * octet beacon interval[2]
20233 + * octet capability information[2]
20234 + * information element
20237 + * octet information[length]
20240 +#define IEEE80211_BEACON_INTERVAL(beacon) \
20241 + ((beacon)[8] | ((beacon)[9] << 8))
20242 +#define IEEE80211_BEACON_CAPABILITY(beacon) \
20243 + ((beacon)[10] | ((beacon)[11] << 8))
20245 +#define IEEE80211_CAPINFO_ESS 0x0001
20246 +#define IEEE80211_CAPINFO_IBSS 0x0002
20247 +#define IEEE80211_CAPINFO_CF_POLLABLE 0x0004
20248 +#define IEEE80211_CAPINFO_CF_POLLREQ 0x0008
20249 +#define IEEE80211_CAPINFO_PRIVACY 0x0010
20250 +#define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020
20251 +#define IEEE80211_CAPINFO_PBCC 0x0040
20252 +#define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080
20253 +/* bits 8-9 are reserved */
20254 +#define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400
20255 +#define IEEE80211_CAPINFO_APSD 0x0800
20256 +/* bit 12 is reserved */
20257 +#define IEEE80211_CAPINFO_DSSSOFDM 0x2000
20258 +/* bits 14-15 are reserved */
20261 + * Authentication Modes
20264 +enum ieee80211_authmode {
20265 + IEEE80211_AUTH_NONE = 0,
20266 + IEEE80211_AUTH_OPEN = 1,
20267 + IEEE80211_AUTH_SHARED = 2,
20268 + IEEE80211_AUTH_8021X = 3,
20269 + IEEE80211_AUTH_AUTO = 4, /* auto-select/accept */
20270 + /* NB: these are used only for ioctls */
20271 + IEEE80211_AUTH_WPA = 5, /* WPA/RSN w/ 802.1x */
20272 + IEEE80211_AUTH_WPA_PSK = 6, /* WPA/RSN w/ PSK */
20273 + IEEE80211_AUTH_WPA_CCKM = 7, /* WPA/RSN IE w/ CCKM */
20276 +#include "athendpack.h"
20278 +#endif /* _NET80211_IEEE80211_H_ */
20279 diff --git a/drivers/sdio/function/wlan/ar6000/include/ieee80211_ioctl.h b/drivers/sdio/function/wlan/ar6000/include/ieee80211_ioctl.h
20280 new file mode 100644
20281 index 0000000..dab6747
20283 +++ b/drivers/sdio/function/wlan/ar6000/include/ieee80211_ioctl.h
20286 + * Copyright (c) 2004-2005 Atheros Communications Inc.
20287 + * All rights reserved.
20290 + * This program is free software; you can redistribute it and/or modify
20291 + * it under the terms of the GNU General Public License version 2 as
20292 + * published by the Free Software Foundation;
20294 + * Software distributed under the License is distributed on an "AS
20295 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
20296 + * implied. See the License for the specific language governing
20297 + * rights and limitations under the License.
20302 + * $Id: //depot/sw/releases/olca2.0-GPL/host/os/linux/include/ieee80211_ioctl.h#1 $
20305 +#ifndef _IEEE80211_IOCTL_H_
20306 +#define _IEEE80211_IOCTL_H_
20308 +#ifdef __cplusplus
20313 + * Extracted from the MADWIFI net80211/ieee80211_ioctl.h
20317 + * WPA/RSN get/set key request. Specify the key/cipher
20318 + * type and whether the key is to be used for sending and/or
20319 + * receiving. The key index should be set only when working
20320 + * with global keys (use IEEE80211_KEYIX_NONE for ``no index'').
20321 + * Otherwise a unicast/pairwise key is specified by the bssid
20322 + * (on a station) or mac address (on an ap). They key length
20323 + * must include any MIC key data; otherwise it should be no
20324 + more than IEEE80211_KEYBUF_SIZE.
20326 +struct ieee80211req_key {
20327 + u_int8_t ik_type; /* key/cipher type */
20329 + u_int16_t ik_keyix; /* key index */
20330 + u_int8_t ik_keylen; /* key length in bytes */
20331 + u_int8_t ik_flags;
20332 +#define IEEE80211_KEY_XMIT 0x01
20333 +#define IEEE80211_KEY_RECV 0x02
20334 +#define IEEE80211_KEY_DEFAULT 0x80 /* default xmit key */
20335 + u_int8_t ik_macaddr[IEEE80211_ADDR_LEN];
20336 + u_int64_t ik_keyrsc; /* key receive sequence counter */
20337 + u_int64_t ik_keytsc; /* key transmit sequence counter */
20338 + u_int8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
20341 + * Delete a key either by index or address. Set the index
20342 + * to IEEE80211_KEYIX_NONE when deleting a unicast key.
20344 +struct ieee80211req_del_key {
20345 + u_int8_t idk_keyix; /* key index */
20346 + u_int8_t idk_macaddr[IEEE80211_ADDR_LEN];
20349 + * MLME state manipulation request. IEEE80211_MLME_ASSOC
20350 + * only makes sense when operating as a station. The other
20351 + * requests can be used when operating as a station or an
20352 + * ap (to effect a station).
20354 +struct ieee80211req_mlme {
20355 + u_int8_t im_op; /* operation to perform */
20356 +#define IEEE80211_MLME_ASSOC 1 /* associate station */
20357 +#define IEEE80211_MLME_DISASSOC 2 /* disassociate station */
20358 +#define IEEE80211_MLME_DEAUTH 3 /* deauthenticate station */
20359 +#define IEEE80211_MLME_AUTHORIZE 4 /* authorize station */
20360 +#define IEEE80211_MLME_UNAUTHORIZE 5 /* unauthorize station */
20361 + u_int16_t im_reason; /* 802.11 reason code */
20362 + u_int8_t im_macaddr[IEEE80211_ADDR_LEN];
20365 +struct ieee80211req_addpmkid {
20366 + u_int8_t pi_bssid[IEEE80211_ADDR_LEN];
20367 + u_int8_t pi_enable;
20368 + u_int8_t pi_pmkid[16];
20371 +#define AUTH_ALG_OPEN_SYSTEM 0x01
20372 +#define AUTH_ALG_SHARED_KEY 0x02
20373 +#define AUTH_ALG_LEAP 0x04
20375 +struct ieee80211req_authalg {
20376 + u_int8_t auth_alg;
20380 + * Request to add an IE to a Management Frame
20383 + IEEE80211_APPIE_FRAME_BEACON = 0,
20384 + IEEE80211_APPIE_FRAME_PROBE_REQ = 1,
20385 + IEEE80211_APPIE_FRAME_PROBE_RESP = 2,
20386 + IEEE80211_APPIE_FRAME_ASSOC_REQ = 3,
20387 + IEEE80211_APPIE_FRAME_ASSOC_RESP = 4,
20388 + IEEE80211_APPIE_NUM_OF_FRAME = 5
20392 + * The Maximum length of the IE that can be added to a Management frame
20394 +#define IEEE80211_APPIE_FRAME_MAX_LEN 78
20396 +struct ieee80211req_getset_appiebuf {
20397 + u_int32_t app_frmtype; /* management frame type for which buffer is added */
20398 + u_int32_t app_buflen; /*application supplied buffer length */
20399 + u_int8_t app_buf[];
20403 + * The following definitions are used by an application to set filter
20404 + * for receiving management frames
20407 + IEEE80211_FILTER_TYPE_BEACON = 0x1,
20408 + IEEE80211_FILTER_TYPE_PROBE_REQ = 0x2,
20409 + IEEE80211_FILTER_TYPE_PROBE_RESP = 0x4,
20410 + IEEE80211_FILTER_TYPE_ASSOC_REQ = 0x8,
20411 + IEEE80211_FILTER_TYPE_ASSOC_RESP = 0x10,
20412 + IEEE80211_FILTER_TYPE_AUTH = 0x20,
20413 + IEEE80211_FILTER_TYPE_DEAUTH = 0x40,
20414 + IEEE80211_FILTER_TYPE_DISASSOC = 0x80,
20415 + IEEE80211_FILTER_TYPE_ALL = 0xFF /* used to check the valid filter bits */
20418 +struct ieee80211req_set_filter {
20419 + u_int32_t app_filterype; /* management frame filter type */
20423 + IEEE80211_PARAM_AUTHMODE = 3, /* Authentication Mode */
20424 + IEEE80211_PARAM_MCASTCIPHER = 5,
20425 + IEEE80211_PARAM_MCASTKEYLEN = 6, /* multicast key length */
20426 + IEEE80211_PARAM_UCASTCIPHER = 8,
20427 + IEEE80211_PARAM_UCASTKEYLEN = 9, /* unicast key length */
20428 + IEEE80211_PARAM_WPA = 10, /* WPA mode (0,1,2) */
20429 + IEEE80211_PARAM_ROAMING = 12, /* roaming mode */
20430 + IEEE80211_PARAM_PRIVACY = 13, /* privacy invoked */
20431 + IEEE80211_PARAM_COUNTERMEASURES = 14, /* WPA/TKIP countermeasures */
20432 + IEEE80211_PARAM_DROPUNENCRYPTED = 15, /* discard unencrypted frames */
20436 + * Values for IEEE80211_PARAM_WPA
20438 +#define WPA_MODE_WPA1 1
20439 +#define WPA_MODE_WPA2 2
20440 +#define WPA_MODE_AUTO 3
20441 +#define WPA_MODE_NONE 4
20443 +#ifdef __cplusplus
20447 +#endif /* _IEEE80211_IOCTL_H_ */
20448 diff --git a/drivers/sdio/function/wlan/ar6000/include/ieee80211_node.h b/drivers/sdio/function/wlan/ar6000/include/ieee80211_node.h
20449 new file mode 100644
20450 index 0000000..46b613c
20452 +++ b/drivers/sdio/function/wlan/ar6000/include/ieee80211_node.h
20455 + * Copyright (c) 2001 Atsushi Onoe
20456 + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
20457 + * Copyright (c) 2006 Atheros Communications, Inc.
20459 + * Wireless Network driver for Atheros AR6001
20460 + * All rights reserved.
20462 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20463 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20464 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20465 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20466 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20467 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20468 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20469 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20470 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20471 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20474 +#ifndef _IEEE80211_NODE_H_
20475 +#define _IEEE80211_NODE_H_
20478 + * Node locking definitions.
20480 +#define IEEE80211_NODE_LOCK_INIT(_nt) A_MUTEX_INIT(&(_nt)->nt_nodelock)
20481 +#define IEEE80211_NODE_LOCK_DESTROY(_nt)
20482 +#define IEEE80211_NODE_LOCK(_nt) A_MUTEX_LOCK(&(_nt)->nt_nodelock)
20483 +#define IEEE80211_NODE_UNLOCK(_nt) A_MUTEX_UNLOCK(&(_nt)->nt_nodelock)
20484 +#define IEEE80211_NODE_LOCK_BH(_nt) A_MUTEX_LOCK(&(_nt)->nt_nodelock)
20485 +#define IEEE80211_NODE_UNLOCK_BH(_nt) A_MUTEX_UNLOCK(&(_nt)->nt_nodelock)
20486 +#define IEEE80211_NODE_LOCK_ASSERT(_nt)
20489 + * Node reference counting definitions.
20491 + * ieee80211_node_initref initialize the reference count to 1
20492 + * ieee80211_node_incref add a reference
20493 + * ieee80211_node_decref remove a reference
20494 + * ieee80211_node_dectestref remove a reference and return 1 if this
20495 + * is the last reference, otherwise 0
20496 + * ieee80211_node_refcnt reference count for printing (only)
20498 +#define ieee80211_node_initref(_ni) ((_ni)->ni_refcnt = 1)
20499 +#define ieee80211_node_incref(_ni) ((_ni)->ni_refcnt++)
20500 +#define ieee80211_node_decref(_ni) ((_ni)->ni_refcnt--)
20501 +#define ieee80211_node_dectestref(_ni) (((_ni)->ni_refcnt--) == 0)
20502 +#define ieee80211_node_refcnt(_ni) ((_ni)->ni_refcnt)
20504 +#define IEEE80211_NODE_HASHSIZE 32
20505 +/* simple hash is enough for variation of macaddr */
20506 +#define IEEE80211_NODE_HASH(addr) \
20507 + (((const A_UINT8 *)(addr))[IEEE80211_ADDR_LEN - 1] % \
20508 + IEEE80211_NODE_HASHSIZE)
20511 + * Table of ieee80211_node instances. Each ieee80211com
20512 + * has at least one for holding the scan candidates.
20513 + * When operating as an access point or in ibss mode there
20514 + * is a second table for associated stations or neighbors.
20516 +struct ieee80211_node_table {
20517 + void *nt_wmip; /* back reference */
20518 + A_MUTEX_T nt_nodelock; /* on node table */
20519 + struct bss *nt_node_first; /* information of all nodes */
20520 + struct bss *nt_node_last; /* information of all nodes */
20521 + struct bss *nt_hash[IEEE80211_NODE_HASHSIZE];
20522 + const char *nt_name; /* for debugging */
20523 + A_UINT32 nt_scangen; /* gen# for timeout scan */
20524 + A_TIMER nt_inact_timer;
20525 + A_UINT8 isTimerArmed; /* is the node timer armed */
20528 +#define WLAN_NODE_INACT_TIMEOUT_MSEC 10000
20530 +#endif /* _IEEE80211_NODE_H_ */
20531 diff --git a/drivers/sdio/function/wlan/ar6000/include/ini_dset.h b/drivers/sdio/function/wlan/ar6000/include/ini_dset.h
20532 new file mode 100644
20533 index 0000000..410f2b5
20535 +++ b/drivers/sdio/function/wlan/ar6000/include/ini_dset.h
20538 + * Copyright (c) 2004-2007 Atheros Communications Inc.
20539 + * All rights reserved.
20541 + * $ATH_LICENSE_HOSTSDK0_C$
20544 +#ifndef _INI_DSET_H_
20545 +#define _INI_DSET_H_
20548 + * Each of these represents a WHAL INI table, which consists
20549 + * of an "address column" followed by 1 or more "value columns".
20551 + * Software uses the base WHAL_INI_DATA_ID+column to access a
20552 + * DataSet that holds a particular column of data.
20555 + WHAL_INI_DATA_ID_NULL =0,
20556 + WHAL_INI_DATA_ID_MODE_SPECIFIC =1, /* 2,3 */
20557 + WHAL_INI_DATA_ID_COMMON =4, /* 5 */
20558 + WHAL_INI_DATA_ID_BB_RFGAIN =6, /* 7,8 */
20559 + WHAL_INI_DATA_ID_ANALOG_BANK1 =9, /* 10 */
20560 + WHAL_INI_DATA_ID_ANALOG_BANK2 =11, /* 12 */
20561 + WHAL_INI_DATA_ID_ANALOG_BANK3 =13, /* 14, 15 */
20562 + WHAL_INI_DATA_ID_ANALOG_BANK6 =16, /* 17, 18 */
20563 + WHAL_INI_DATA_ID_ANALOG_BANK7 =19, /* 20 */
20564 + WHAL_INI_DATA_ID_MODE_OVERRIDES =21, /* 22,23 */
20565 + WHAL_INI_DATA_ID_COMMON_OVERRIDES =24, /* 25 */
20567 + WHAL_INI_DATA_ID_MAX =25
20568 +} WHAL_INI_DATA_ID;
20570 +typedef PREPACK struct {
20571 + A_UINT16 freqIndex; // 1 - A mode 2 - B or G mode 0 - common
20573 + A_UINT32 newValue;
20574 +} POSTPACK INI_DSET_REG_OVERRIDE;
20577 diff --git a/drivers/sdio/function/wlan/ar6000/include/regDb.h b/drivers/sdio/function/wlan/ar6000/include/regDb.h
20578 new file mode 100644
20579 index 0000000..b3f665f
20581 +++ b/drivers/sdio/function/wlan/ar6000/include/regDb.h
20584 + * Copyright (c) 2005 Atheros Communications, Inc.
20585 + * All rights reserved.
20588 + * $ATH_LICENSE_HOSTSDK0_C$
20590 + * This module contains the header files for regulatory module,
20591 + * which include the DB schema and DB values.
20595 +#ifndef __REG_DB_H__
20596 +#define __REG_DB_H__
20598 +#include "./regulatory/reg_dbschema.h"
20599 +#include "./regulatory/reg_dbvalues.h"
20601 +#endif /* __REG_DB_H__ */
20602 diff --git a/drivers/sdio/function/wlan/ar6000/include/regdump.h b/drivers/sdio/function/wlan/ar6000/include/regdump.h
20603 new file mode 100644
20604 index 0000000..0106825
20606 +++ b/drivers/sdio/function/wlan/ar6000/include/regdump.h
20608 +#ifndef __REGDUMP_H__
20609 +#define __REGDUMP_H__
20611 + * Copyright (c) 2004-2007 Atheros Communications Inc.
20612 + * All rights reserved.
20614 + * $ATH_LICENSE_HOSTSDK0_C$
20617 +#if defined(AR6001)
20618 +#include "AR6001/AR6001_regdump.h"
20620 +#if defined(AR6002)
20621 +#include "AR6002/AR6002_regdump.h"
20624 +#if !defined(__ASSEMBLER__)
20626 + * Target CPU state at the time of failure is reflected
20627 + * in a register dump, which the Host can fetch through
20628 + * the diagnostic window.
20630 +struct register_dump_s {
20631 + A_UINT32 target_id; /* Target ID */
20632 + A_UINT32 assline; /* Line number (if assertion failure) */
20633 + A_UINT32 pc; /* Program Counter at time of exception */
20634 + A_UINT32 badvaddr; /* Virtual address causing exception */
20635 + CPU_exception_frame_t exc_frame; /* CPU-specific exception info */
20637 + /* Could copy top of stack here, too.... */
20639 +#endif /* __ASSEMBLER__ */
20640 +#endif /* __REGDUMP_H__ */
20641 diff --git a/drivers/sdio/function/wlan/ar6000/include/targaddrs.h b/drivers/sdio/function/wlan/ar6000/include/targaddrs.h
20642 new file mode 100644
20643 index 0000000..da2a650
20645 +++ b/drivers/sdio/function/wlan/ar6000/include/targaddrs.h
20648 + * Copyright (c) 2004-2007 Atheros Communications Inc.
20649 + * All rights reserved.
20651 + * $ATH_LICENSE_HOSTSDK0_C$
20655 +#ifndef __TARGADDRS_H__
20656 +#define __TARGADDRS_H__
20657 +#if defined(AR6001)
20658 +#include "AR6001/addrs.h"
20660 +#if defined(AR6002)
20661 +#include "AR6002/addrs.h"
20665 + * AR6K option bits, to enable/disable various features.
20666 + * By default, all option bits are 0.
20667 + * These bits can be set in LOCAL_SCRATCH register 0.
20669 +#define AR6K_OPTION_BMI_DISABLE 0x01 /* Disable BMI comm with Host */
20670 +#define AR6K_OPTION_SERIAL_ENABLE 0x02 /* Enable serial port msgs */
20671 +#define AR6K_OPTION_WDT_DISABLE 0x04 /* WatchDog Timer override */
20672 +#define AR6K_OPTION_SLEEP_DISABLE 0x08 /* Disable system sleep */
20673 +#define AR6K_OPTION_STOP_BOOT 0x10 /* Stop boot processes (for ATE) */
20674 +#define AR6K_OPTION_ENABLE_NOANI 0x20 /* Operate without ANI */
20675 +#define AR6K_OPTION_DSET_DISABLE 0x40 /* Ignore DataSets */
20676 +#define AR6K_OPTION_IGNORE_FLASH 0x80 /* Ignore flash during bootup */
20679 + * xxx_HOST_INTEREST_ADDRESS is the address in Target RAM of the
20680 + * host_interest structure. It must match the address of the _host_interest
20681 + * symbol (see linker script).
20683 + * Host Interest is shared between Host and Target in order to coordinate
20684 + * between the two, and is intended to remain constant (with additions only
20685 + * at the end) across software releases.
20687 +#define AR6001_HOST_INTEREST_ADDRESS 0x80000600
20688 +#define AR6002_HOST_INTEREST_ADDRESS 0x00500400
20690 +#define HOST_INTEREST_MAX_SIZE 0x100
20692 +#if !defined(__ASSEMBLER__)
20693 +struct register_dump_s;
20694 +struct dbglog_hdr_s;
20697 + * These are items that the Host may need to access
20698 + * via BMI or via the Diagnostic Window. The position
20699 + * of items in this structure must remain constant
20700 + * across firmware revisions!
20702 + * Types for each item must be fixed size across
20703 + * target and host platforms.
20705 + * More items may be added at the end.
20707 +struct host_interest_s {
20709 + * Pointer to application-defined area, if any.
20710 + * Set by Target application during startup.
20712 + A_UINT32 hi_app_host_interest; /* 0x00 */
20714 + /* Pointer to register dump area, valid after Target crash. */
20715 + A_UINT32 hi_failure_state; /* 0x04 */
20717 + /* Pointer to debug logging header */
20718 + A_UINT32 hi_dbglog_hdr; /* 0x08 */
20720 + /* Indicates whether or not flash is present on Target.
20721 + * NB: flash_is_present indicator is here not just
20722 + * because it might be of interest to the Host; but
20723 + * also because it's set early on by Target's startup
20724 + * asm code and we need it to have a special RAM address
20725 + * so that it doesn't get reinitialized with the rest
20728 + A_UINT32 hi_flash_is_present; /* 0x0c */
20731 + * General-purpose flag bits, similar to AR6000_OPTION_* flags.
20732 + * Can be used by application rather than by OS.
20734 + A_UINT32 hi_option_flag; /* 0x10 */
20737 + * Boolean that determines whether or not to
20738 + * display messages on the serial port.
20740 + A_UINT32 hi_serial_enable; /* 0x14 */
20742 + /* Start address of Flash DataSet index, if any */
20743 + A_UINT32 hi_dset_list_head; /* 0x18 */
20745 + /* Override Target application start address */
20746 + A_UINT32 hi_app_start; /* 0x1c */
20748 + /* Clock and voltage tuning */
20749 + A_UINT32 hi_skip_clock_init; /* 0x20 */
20750 + A_UINT32 hi_core_clock_setting; /* 0x24 */
20751 + A_UINT32 hi_cpu_clock_setting; /* 0x28 */
20752 + A_UINT32 hi_system_sleep_setting; /* 0x2c */
20753 + A_UINT32 hi_xtal_control_setting; /* 0x30 */
20754 + A_UINT32 hi_pll_ctrl_setting_24ghz; /* 0x34 */
20755 + A_UINT32 hi_pll_ctrl_setting_5ghz; /* 0x38 */
20756 + A_UINT32 hi_ref_voltage_trim_setting; /* 0x3c */
20757 + A_UINT32 hi_clock_info; /* 0x40 */
20760 + * Flash configuration overrides, used only
20761 + * when firmware is not executing from flash.
20762 + * (When using flash, modify the global variables
20763 + * with equivalent names.)
20765 + A_UINT32 hi_bank0_addr_value; /* 0x44 */
20766 + A_UINT32 hi_bank0_read_value; /* 0x48 */
20767 + A_UINT32 hi_bank0_write_value; /* 0x4c */
20768 + A_UINT32 hi_bank0_config_value; /* 0x50 */
20770 + /* Pointer to Board Data */
20771 + A_UINT32 hi_board_data; /* 0x54 */
20772 + A_UINT32 hi_board_data_initialized; /* 0x58 */
20774 + A_UINT32 hi_dset_RAM_index_table; /* 0x5c */
20776 + A_UINT32 hi_desired_baud_rate; /* 0x60 */
20777 + A_UINT32 hi_dbglog_config; /* 0x64 */
20778 + A_UINT32 hi_end_RAM_reserve_sz; /* 0x68 */
20779 + A_UINT32 hi_mbox_io_block_sz; /* 0x6c */
20781 + A_UINT32 hi_num_bpatch_streams; /* 0x70 */
20782 + A_UINT32 hi_mbox_isr_yield_limit; /* 0x74 */
20784 + A_UINT32 hi_refclk_hz; /* 0x78 */
20787 +/* Bits defined in hi_option_flag */
20788 +#define HI_OPTION_TIMER_WAR 1 /* not really used */
20791 + * Intended for use by Host software, this macro returns the Target RAM
20792 + * address of any item in the host_interest structure.
20793 + * Example: target_addr = AR6001_HOST_INTEREST_ITEM_ADDRESS(hi_board_data);
20795 +#define AR6001_HOST_INTEREST_ITEM_ADDRESS(item) \
20796 + ((A_UINT32)&((((struct host_interest_s *)(AR6001_HOST_INTEREST_ADDRESS))->item)))
20798 +#define AR6002_HOST_INTEREST_ITEM_ADDRESS(item) \
20799 + ((A_UINT32)&((((struct host_interest_s *)(AR6002_HOST_INTEREST_ADDRESS))->item)))
20802 +#endif /* !__ASSEMBLER__ */
20804 +#endif /* __TARGADDRS_H__ */
20805 diff --git a/drivers/sdio/function/wlan/ar6000/include/testcmd.h b/drivers/sdio/function/wlan/ar6000/include/testcmd.h
20806 new file mode 100644
20807 index 0000000..737533a
20809 +++ b/drivers/sdio/function/wlan/ar6000/include/testcmd.h
20812 + * Copyright (c) 2004-2005 Atheros Communications Inc.
20813 + * All rights reserved.
20816 + * $ATH_LICENSE_HOSTSDK0_C$
20820 +#ifndef TESTCMD_H_
20821 +#define TESTCMD_H_
20823 +#ifdef __cplusplus
20828 + ZEROES_PATTERN = 0,
20837 + mode : TCMD_CONT_TX_OFF - Disabling continous tx
20838 + TCMD_CONT_TX_SINE - Enable continuous unmodulated tx
20839 + TCMD_CONT_TX_FRAME- Enable continuous modulated tx
20840 + freq : Channel freq in Mhz. (e.g 2412 for channel 1 in 11 g)
20841 +dataRate: 0 - 1 Mbps
20853 + txPwr: Tx power in dBm[5 -11] for unmod Tx, [5-14] for mod Tx
20854 +antenna: 1 - one antenna
20856 +Note : Enable/disable continuous tx test cmd works only when target is awake.
20860 + TCMD_CONT_TX_OFF = 0,
20861 + TCMD_CONT_TX_SINE,
20862 + TCMD_CONT_TX_FRAME,
20863 + TCMD_CONT_TX_TX99,
20864 + TCMD_CONT_TX_TX100
20865 +} TCMD_CONT_TX_MODE;
20867 +typedef PREPACK struct {
20868 + A_UINT32 testCmdId;
20871 + A_UINT32 dataRate;
20873 + A_UINT32 antenna;
20875 + A_UINT32 scramblerOff;
20878 + A_UINT16 txPattern;
20879 +} POSTPACK TCMD_CONT_TX;
20881 +#define TCMD_TXPATTERN_ZERONE 0x1
20882 +#define TCMD_TXPATTERN_ZERONE_DIS_SCRAMBLE 0x2
20885 + act: TCMD_CONT_RX_PROMIS - promiscuous mode (accept all incoming frames)
20886 + TCMD_CONT_RX_FILTER - filter mode (accept only frames with dest
20887 + address equal specified
20888 + mac address (set via act =3)
20889 + TCMD_CONT_RX_REPORT off mode (disable cont rx mode and get the
20890 + report from the last cont
20893 + TCMD_CONT_RX_SETMAC - set MacAddr mode (sets the MAC address for the
20894 + target. This Overrides
20895 + the default MAC address.)
20899 + TCMD_CONT_RX_PROMIS =0,
20900 + TCMD_CONT_RX_FILTER,
20901 + TCMD_CONT_RX_REPORT,
20902 + TCMD_CONT_RX_SETMAC
20903 +} TCMD_CONT_RX_ACT;
20905 +typedef PREPACK struct {
20906 + A_UINT32 testCmdId;
20910 + struct PREPACK TCMD_CONT_RX_PARA {
20912 + A_UINT32 antenna;
20914 + struct PREPACK TCMD_CONT_RX_REPORT {
20915 + A_UINT32 totalPkt;
20916 + A_INT32 rssiInDBm;
20917 + } POSTPACK report;
20918 + struct PREPACK TCMD_CONT_RX_MAC {
20919 + A_UCHAR addr[ATH_MAC_LEN];
20922 +} POSTPACK TCMD_CONT_RX;
20924 +/* Force sleep/wake test cmd
20925 + mode: TCMD_PM_WAKEUP - Wakeup the target
20926 + TCMD_PM_SLEEP - Force the target to sleep.
20929 + TCMD_PM_WAKEUP = 1, /* be consistent with target */
20933 +typedef PREPACK struct {
20934 + A_UINT32 testCmdId;
20936 +} POSTPACK TCMD_PM;
20944 +typedef PREPACK union {
20945 + TCMD_CONT_TX contTx;
20946 + TCMD_CONT_RX contRx;
20948 +} POSTPACK TEST_CMD;
20950 +#ifdef __cplusplus
20954 +#endif /* TESTCMD_H_ */
20955 diff --git a/drivers/sdio/function/wlan/ar6000/include/wlan_api.h b/drivers/sdio/function/wlan/ar6000/include/wlan_api.h
20956 new file mode 100644
20957 index 0000000..aabca4b
20959 +++ b/drivers/sdio/function/wlan/ar6000/include/wlan_api.h
20961 +#ifndef _HOST_WLAN_API_H_
20962 +#define _HOST_WLAN_API_H_
20964 + * Copyright (c) 2004-2005 Atheros Communications Inc.
20965 + * All rights reserved.
20967 + * This file contains the API for the host wlan module
20969 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/wlan_api.h#1 $
20972 + * This program is free software; you can redistribute it and/or modify
20973 + * it under the terms of the GNU General Public License version 2 as
20974 + * published by the Free Software Foundation;
20976 + * Software distributed under the License is distributed on an "AS
20977 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
20978 + * implied. See the License for the specific language governing
20979 + * rights and limitations under the License.
20985 +#ifdef __cplusplus
20989 +struct ieee80211_node_table;
20990 +struct ieee80211_frame;
20992 +struct ieee80211_common_ie {
20993 + A_UINT16 ie_chan;
20994 + A_UINT8 *ie_tstamp;
20995 + A_UINT8 *ie_ssid;
20996 + A_UINT8 *ie_rates;
20997 + A_UINT8 *ie_xrates;
20998 + A_UINT8 *ie_country;
21003 + A_UINT16 ie_capInfo;
21004 + A_UINT16 ie_beaconInt;
21006 + A_UINT8 *ie_chswitch;
21011 +typedef struct bss {
21012 + A_UINT8 ni_macaddr[6];
21015 + struct bss *ni_list_next;
21016 + struct bss *ni_list_prev;
21017 + struct bss *ni_hash_next;
21018 + struct bss *ni_hash_prev;
21019 + struct ieee80211_common_ie ni_cie;
21021 + struct ieee80211_node_table *ni_table;
21022 + A_UINT32 ni_refcnt;
21024 + A_UINT32 ni_tstamp;
21027 +typedef void wlan_node_iter_func(void *arg, bss_t *);
21029 +bss_t *wlan_node_alloc(struct ieee80211_node_table *nt, int wh_size);
21030 +void wlan_node_free(bss_t *ni);
21031 +void wlan_setup_node(struct ieee80211_node_table *nt, bss_t *ni,
21032 + const A_UINT8 *macaddr);
21033 +bss_t *wlan_find_node(struct ieee80211_node_table *nt, const A_UINT8 *macaddr);
21034 +void wlan_node_reclaim(struct ieee80211_node_table *nt, bss_t *ni);
21035 +void wlan_free_allnodes(struct ieee80211_node_table *nt);
21036 +void wlan_iterate_nodes(struct ieee80211_node_table *nt, wlan_node_iter_func *f,
21039 +void wlan_node_table_init(void *wmip, struct ieee80211_node_table *nt);
21040 +void wlan_node_table_reset(struct ieee80211_node_table *nt);
21041 +void wlan_node_table_cleanup(struct ieee80211_node_table *nt);
21043 +A_STATUS wlan_parse_beacon(A_UINT8 *buf, int framelen,
21044 + struct ieee80211_common_ie *cie);
21046 +A_UINT16 wlan_ieee2freq(int chan);
21047 +A_UINT32 wlan_freq2ieee(A_UINT16 freq);
21051 +wlan_find_Ssidnode (struct ieee80211_node_table *nt, A_UCHAR *pSsid,
21052 + A_UINT32 ssidLength, A_BOOL bIsWPA2);
21055 +wlan_node_return (struct ieee80211_node_table *nt, bss_t *ni);
21057 +#ifdef __cplusplus
21061 +#endif /* _HOST_WLAN_API_H_ */
21062 diff --git a/drivers/sdio/function/wlan/ar6000/include/wlan_dset.h b/drivers/sdio/function/wlan/ar6000/include/wlan_dset.h
21063 new file mode 100644
21064 index 0000000..8a876d6
21066 +++ b/drivers/sdio/function/wlan/ar6000/include/wlan_dset.h
21069 + * Copyright (c) 2007 Atheros Communications, Inc.
21070 + * All rights reserved.
21073 + * $ATH_LICENSE_HOSTSDK0_C$
21077 +#ifndef __WLAN_DSET_H__
21078 +#define __WKAN_DSET_H__
21080 +typedef PREPACK struct wow_config_dset {
21082 + A_UINT8 valid_dset;
21083 + A_UINT8 gpio_enable;
21084 + A_UINT16 gpio_pin;
21085 +} POSTPACK WOW_CONFIG_DSET;
21088 diff --git a/drivers/sdio/function/wlan/ar6000/include/wmi.h b/drivers/sdio/function/wlan/ar6000/include/wmi.h
21089 new file mode 100644
21090 index 0000000..045acd4
21092 +++ b/drivers/sdio/function/wlan/ar6000/include/wmi.h
21095 + * Copyright (c) 2004-2006 Atheros Communications Inc.
21096 + * All rights reserved.
21099 + * $ATH_LICENSE_HOSTSDK0_C$
21101 + * This file contains the definitions of the WMI protocol specified in the
21102 + * Wireless Module Interface (WMI). It includes definitions of all the
21103 + * commands and events. Commands are messages from the host to the WM.
21104 + * Events and Replies are messages from the WM to the host.
21106 + * Ownership of correctness in regards to WMI commands
21107 + * belongs to the host driver and the WM is not required to validate
21108 + * parameters for value, proper range, or any other checking.
21115 +#ifndef ATH_TARGET
21116 +#include "athstartpack.h"
21121 +#ifdef __cplusplus
21125 +#define WMI_PROTOCOL_VERSION 0x0002
21126 +#define WMI_PROTOCOL_REVISION 0x0000
21128 +#define ATH_MAC_LEN 6 /* length of mac in bytes */
21129 +#define WMI_CMD_MAX_LEN 100
21130 +#define WMI_CONTROL_MSG_MAX_LEN 256
21131 +#define WMI_OPT_CONTROL_MSG_MAX_LEN 1536
21132 +#define IS_ETHERTYPE(_typeOrLen) ((_typeOrLen) >= 0x0600)
21133 +#define RFC1042OUI {0x00, 0x00, 0x00}
21135 +#define IP_ETHERTYPE 0x0800
21137 +#define WMI_IMPLICIT_PSTREAM 0xFF
21138 +#define WMI_MAX_THINSTREAM 15
21140 +struct host_app_area_s {
21141 + A_UINT32 wmi_protocol_ver;
21147 +typedef PREPACK struct {
21148 + A_UINT8 dstMac[ATH_MAC_LEN];
21149 + A_UINT8 srcMac[ATH_MAC_LEN];
21150 + A_UINT16 typeOrLen;
21151 +} POSTPACK ATH_MAC_HDR;
21153 +typedef PREPACK struct {
21157 + A_UINT8 orgCode[3];
21158 + A_UINT16 etherType;
21159 +} POSTPACK ATH_LLC_SNAP_HDR;
21162 + DATA_MSGTYPE = 0x0,
21168 +typedef PREPACK struct {
21170 + A_UINT8 info; /* WMI_MSG_TYPE in lower 2 bits - b1b0 */
21171 + /* UP in next 3 bits - b4b3b2 */
21172 +#define WMI_DATA_HDR_MSG_TYPE_MASK 0x03
21173 +#define WMI_DATA_HDR_MSG_TYPE_SHIFT 0
21174 +#define WMI_DATA_HDR_UP_MASK 0x07
21175 +#define WMI_DATA_HDR_UP_SHIFT 2
21176 +#define WMI_DATA_HDR_IS_MSG_TYPE(h, t) (((h)->info & (WMI_DATA_HDR_MSG_TYPE_MASK)) == (t))
21177 +} POSTPACK WMI_DATA_HDR;
21180 +#define WMI_DATA_HDR_SET_MSG_TYPE(h, t) (h)->info = (((h)->info & ~(WMI_DATA_HDR_MSG_TYPE_MASK << WMI_DATA_HDR_MSG_TYPE_SHIFT)) | (t << WMI_DATA_HDR_MSG_TYPE_SHIFT))
21181 +#define WMI_DATA_HDR_SET_UP(h, p) (h)->info = (((h)->info & ~(WMI_DATA_HDR_UP_MASK << WMI_DATA_HDR_UP_SHIFT)) | (p << WMI_DATA_HDR_UP_SHIFT))
21186 +typedef PREPACK struct {
21187 + A_UINT16 commandId;
21188 +} POSTPACK WMI_CMD_HDR; /* used for commands and events */
21191 + * List of Commnands
21194 + WMI_CONNECT_CMDID = 0x0001,
21195 + WMI_RECONNECT_CMDID,
21196 + WMI_DISCONNECT_CMDID,
21197 + WMI_SYNCHRONIZE_CMDID,
21198 + WMI_CREATE_PSTREAM_CMDID,
21199 + WMI_DELETE_PSTREAM_CMDID,
21200 + WMI_START_SCAN_CMDID,
21201 + WMI_SET_SCAN_PARAMS_CMDID,
21202 + WMI_SET_BSS_FILTER_CMDID,
21203 + WMI_SET_PROBED_SSID_CMDID,
21204 + WMI_SET_LISTEN_INT_CMDID,
21205 + WMI_SET_BMISS_TIME_CMDID,
21206 + WMI_SET_DISC_TIMEOUT_CMDID,
21207 + WMI_GET_CHANNEL_LIST_CMDID,
21208 + WMI_SET_BEACON_INT_CMDID,
21209 + WMI_GET_STATISTICS_CMDID,
21210 + WMI_SET_CHANNEL_PARAMS_CMDID,
21211 + WMI_SET_POWER_MODE_CMDID,
21212 + WMI_SET_IBSS_PM_CAPS_CMDID,
21213 + WMI_SET_POWER_PARAMS_CMDID,
21214 + WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID,
21215 + WMI_ADD_CIPHER_KEY_CMDID,
21216 + WMI_DELETE_CIPHER_KEY_CMDID,
21217 + WMI_ADD_KRK_CMDID,
21218 + WMI_DELETE_KRK_CMDID,
21219 + WMI_SET_PMKID_CMDID,
21220 + WMI_SET_TX_PWR_CMDID,
21221 + WMI_GET_TX_PWR_CMDID,
21222 + WMI_SET_ASSOC_INFO_CMDID,
21223 + WMI_ADD_BAD_AP_CMDID,
21224 + WMI_DELETE_BAD_AP_CMDID,
21225 + WMI_SET_TKIP_COUNTERMEASURES_CMDID,
21226 + WMI_RSSI_THRESHOLD_PARAMS_CMDID,
21227 + WMI_TARGET_ERROR_REPORT_BITMASK_CMDID,
21228 + WMI_SET_ACCESS_PARAMS_CMDID,
21229 + WMI_SET_RETRY_LIMITS_CMDID,
21230 + WMI_SET_OPT_MODE_CMDID,
21231 + WMI_OPT_TX_FRAME_CMDID,
21232 + WMI_SET_VOICE_PKT_SIZE_CMDID,
21233 + WMI_SET_MAX_SP_LEN_CMDID,
21234 + WMI_SET_ROAM_CTRL_CMDID,
21235 + WMI_GET_ROAM_TBL_CMDID,
21236 + WMI_GET_ROAM_DATA_CMDID,
21237 + WMI_ENABLE_RM_CMDID,
21238 + WMI_SET_MAX_OFFHOME_DURATION_CMDID,
21239 + WMI_EXTENSION_CMDID, /* Non-wireless extensions */
21240 + WMI_SNR_THRESHOLD_PARAMS_CMDID,
21241 + WMI_LQ_THRESHOLD_PARAMS_CMDID,
21242 + WMI_SET_LPREAMBLE_CMDID,
21243 + WMI_SET_RTS_CMDID,
21244 + WMI_CLR_RSSI_SNR_CMDID,
21245 + WMI_SET_FIXRATES_CMDID,
21246 + WMI_GET_FIXRATES_CMDID,
21247 + WMI_SET_AUTH_MODE_CMDID,
21248 + WMI_SET_REASSOC_MODE_CMDID,
21249 + WMI_SET_WMM_CMDID,
21250 + WMI_SET_WMM_TXOP_CMDID,
21252 + WMI_SET_BT_STATUS_CMDID,
21253 + WMI_SET_BT_PARAMS_CMDID,
21255 + WMI_SET_KEEPALIVE_CMDID,
21256 + WMI_GET_KEEPALIVE_CMDID,
21257 + WMI_SET_APPIE_CMDID,
21258 + WMI_GET_APPIE_CMDID,
21259 + WMI_SET_WSC_STATUS_CMDID,
21261 + /* Wake on Wireless */
21262 + WMI_SET_HOST_SLEEP_MODE_CMDID,
21263 + WMI_SET_WOW_MODE_CMDID,
21264 + WMI_GET_WOW_LIST_CMDID,
21265 + WMI_ADD_WOW_PATTERN_CMDID,
21266 + WMI_DEL_WOW_PATTERN_CMDID,
21267 + WMI_SET_MAC_ADDRESS_CMDID,
21268 + WMI_SET_AKMP_PARAMS_CMDID,
21269 + WMI_SET_PMKID_LIST_CMDID,
21270 + WMI_GET_PMKID_LIST_CMDID,
21273 + * Developer commands starts at 0xF000
21275 + WMI_SET_BITRATE_CMDID = 0xF000,
21276 + WMI_GET_BITRATE_CMDID,
21277 + WMI_SET_WHALPARAM_CMDID,
21285 + WMI_FRAME_BEACON = 0,
21286 + WMI_FRAME_PROBE_REQ,
21287 + WMI_FRAME_PROBE_RESP,
21288 + WMI_FRAME_ASSOC_REQ,
21289 + WMI_FRAME_ASSOC_RESP,
21290 + WMI_NUM_MGMT_FRAME
21291 +} WMI_MGMT_FRAME_TYPE;
21294 + * Connect Command
21297 + INFRA_NETWORK = 0x01,
21298 + ADHOC_NETWORK = 0x02,
21299 + ADHOC_CREATOR = 0x04,
21303 + OPEN_AUTH = 0x01,
21304 + SHARED_AUTH = 0x02,
21305 + LEAP_AUTH = 0x04, /* different from IEEE_AUTH_MODE definitions */
21306 +} DOT11_AUTH_MODE;
21309 + NONE_AUTH = 0x01,
21311 + WPA_PSK_AUTH = 0x03,
21312 + WPA2_AUTH = 0x04,
21313 + WPA2_PSK_AUTH = 0x05,
21314 + WPA_AUTH_CCKM = 0x06,
21315 + WPA2_AUTH_CCKM = 0x07,
21319 + NONE_CRYPT = 0x01,
21320 + WEP_CRYPT = 0x02,
21321 + TKIP_CRYPT = 0x03,
21322 + AES_CRYPT = 0x04,
21325 +#define WMI_MIN_CRYPTO_TYPE NONE_CRYPT
21326 +#define WMI_MAX_CRYPTO_TYPE (AES_CRYPT + 1)
21328 +#define WMI_MIN_KEY_INDEX 0
21329 +#define WMI_MAX_KEY_INDEX 3
21331 +#define WMI_MAX_KEY_LEN 32
21333 +#define WMI_MAX_SSID_LEN 32
21336 + CONNECT_ASSOC_POLICY_USER = 0x0001,
21337 + CONNECT_SEND_REASSOC = 0x0002,
21338 + CONNECT_IGNORE_WPAx_GROUP_CIPHER = 0x0004,
21339 + CONNECT_PROFILE_MATCH_DONE = 0x0008,
21340 + CONNECT_IGNORE_AAC_BEACON = 0x0010,
21341 + CONNECT_CSA_FOLLOW_BSS = 0x0020,
21342 +} WMI_CONNECT_CTRL_FLAGS_BITS;
21344 +#define DEFAULT_CONNECT_CTRL_FLAGS (CONNECT_CSA_FOLLOW_BSS)
21346 +typedef PREPACK struct {
21347 + A_UINT8 networkType;
21348 + A_UINT8 dot11AuthMode;
21349 + A_UINT8 authMode;
21350 + A_UINT8 pairwiseCryptoType;
21351 + A_UINT8 pairwiseCryptoLen;
21352 + A_UINT8 groupCryptoType;
21353 + A_UINT8 groupCryptoLen;
21354 + A_UINT8 ssidLength;
21355 + A_UCHAR ssid[WMI_MAX_SSID_LEN];
21356 + A_UINT16 channel;
21357 + A_UINT8 bssid[ATH_MAC_LEN];
21358 + A_UINT32 ctrl_flags;
21359 +} POSTPACK WMI_CONNECT_CMD;
21362 + * WMI_RECONNECT_CMDID
21364 +typedef PREPACK struct {
21365 + A_UINT16 channel; /* hint */
21366 + A_UINT8 bssid[ATH_MAC_LEN]; /* mandatory if set */
21367 +} POSTPACK WMI_RECONNECT_CMD;
21370 + * WMI_ADD_CIPHER_KEY_CMDID
21373 + PAIRWISE_USAGE = 0x00,
21374 + GROUP_USAGE = 0x01,
21375 + TX_USAGE = 0x02, /* default Tx Key - Static WEP only */
21380 + * Bit 0 - Initialise TSC - default is Initialize
21382 +#define KEY_OP_INIT_TSC 0x01
21383 +#define KEY_OP_INIT_RSC 0x02
21385 +#define KEY_OP_INIT_VAL 0x03 /* Default Initialise the TSC & RSC */
21386 +#define KEY_OP_VALID_MASK 0x03
21388 +typedef PREPACK struct {
21389 + A_UINT8 keyIndex;
21391 + A_UINT8 keyUsage; /* KEY_USAGE */
21392 + A_UINT8 keyLength;
21393 + A_UINT8 keyRSC[8]; /* key replay sequence counter */
21394 + A_UINT8 key[WMI_MAX_KEY_LEN];
21395 + A_UINT8 key_op_ctrl; /* Additional Key Control information */
21396 +} POSTPACK WMI_ADD_CIPHER_KEY_CMD;
21399 + * WMI_DELETE_CIPHER_KEY_CMDID
21401 +typedef PREPACK struct {
21402 + A_UINT8 keyIndex;
21403 +} POSTPACK WMI_DELETE_CIPHER_KEY_CMD;
21405 +#define WMI_KRK_LEN 16
21407 + * WMI_ADD_KRK_CMDID
21409 +typedef PREPACK struct {
21410 + A_UINT8 krk[WMI_KRK_LEN];
21411 +} POSTPACK WMI_ADD_KRK_CMD;
21414 + * WMI_SET_TKIP_COUNTERMEASURES_CMDID
21417 + WMI_TKIP_CM_DISABLE = 0x0,
21418 + WMI_TKIP_CM_ENABLE = 0x1,
21419 +} WMI_TKIP_CM_CONTROL;
21421 +typedef PREPACK struct {
21422 + A_UINT8 cm_en; /* WMI_TKIP_CM_CONTROL */
21423 +} POSTPACK WMI_SET_TKIP_COUNTERMEASURES_CMD;
21426 + * WMI_SET_PMKID_CMDID
21429 +#define WMI_PMKID_LEN 16
21432 + PMKID_DISABLE = 0,
21433 + PMKID_ENABLE = 1,
21434 +} PMKID_ENABLE_FLG;
21436 +typedef PREPACK struct {
21437 + A_UINT8 bssid[ATH_MAC_LEN];
21438 + A_UINT8 enable; /* PMKID_ENABLE_FLG */
21439 + A_UINT8 pmkid[WMI_PMKID_LEN];
21440 +} POSTPACK WMI_SET_PMKID_CMD;
21443 + * WMI_START_SCAN_CMD
21446 + WMI_LONG_SCAN = 0,
21447 + WMI_SHORT_SCAN = 1,
21450 +typedef PREPACK struct {
21451 + A_BOOL forceFgScan;
21452 + A_BOOL isLegacy; /* For Legacy Cisco AP compatibility */
21453 + A_UINT32 homeDwellTime; /* Maximum duration in the home channel(milliseconds) */
21454 + A_UINT32 forceScanInterval; /* Time interval between scans (milliseconds)*/
21455 + A_UINT8 scanType; /* WMI_SCAN_TYPE */
21456 +} POSTPACK WMI_START_SCAN_CMD;
21459 + * WMI_SET_SCAN_PARAMS_CMDID
21461 +#define WMI_SHORTSCANRATIO_DEFAULT 3
21463 + CONNECT_SCAN_CTRL_FLAGS = 0x01, /* set if can scan in the Connect cmd */
21464 + SCAN_CONNECTED_CTRL_FLAGS = 0x02, /* set if scan for the SSID it is */
21465 + /* already connected to */
21466 + ACTIVE_SCAN_CTRL_FLAGS = 0x04, /* set if enable active scan */
21467 + ROAM_SCAN_CTRL_FLAGS = 0x08, /* set if enable roam scan when bmiss and lowrssi */
21468 + REPORT_BSSINFO_CTRL_FLAGS = 0x10, /* set if follows customer BSSINFO reporting rule */
21469 + ENABLE_AUTO_CTRL_FLAGS = 0x20, /* if disabled, target doesn't
21470 + scan after a disconnect event */
21471 + ENABLE_SCAN_ABORT_EVENT = 0x40 /* Scan complete event with canceled status will be generated when a scan is prempted before it gets completed */
21473 +} WMI_SCAN_CTRL_FLAGS_BITS;
21475 +#define CAN_SCAN_IN_CONNECT(flags) (flags & CONNECT_SCAN_CTRL_FLAGS)
21476 +#define CAN_SCAN_CONNECTED(flags) (flags & SCAN_CONNECTED_CTRL_FLAGS)
21477 +#define ENABLE_ACTIVE_SCAN(flags) (flags & ACTIVE_SCAN_CTRL_FLAGS)
21478 +#define ENABLE_ROAM_SCAN(flags) (flags & ROAM_SCAN_CTRL_FLAGS)
21479 +#define CONFIG_REPORT_BSSINFO(flags) (flags & REPORT_BSSINFO_CTRL_FLAGS)
21480 +#define IS_AUTO_SCAN_ENABLED(flags) (flags & ENABLE_AUTO_CTRL_FLAGS)
21481 +#define SCAN_ABORT_EVENT_ENABLED(flags) (flags & ENABLE_SCAN_ABORT_EVENT)
21483 +#define DEFAULT_SCAN_CTRL_FLAGS (CONNECT_SCAN_CTRL_FLAGS| SCAN_CONNECTED_CTRL_FLAGS| ACTIVE_SCAN_CTRL_FLAGS| ROAM_SCAN_CTRL_FLAGS | ENABLE_AUTO_CTRL_FLAGS)
21486 +typedef PREPACK struct {
21487 + A_UINT16 fg_start_period; /* seconds */
21488 + A_UINT16 fg_end_period; /* seconds */
21489 + A_UINT16 bg_period; /* seconds */
21490 + A_UINT16 maxact_chdwell_time; /* msec */
21491 + A_UINT16 pas_chdwell_time; /* msec */
21492 + A_UINT8 shortScanRatio; /* how many shorts scan for one long */
21493 + A_UINT8 scanCtrlFlags;
21494 + A_UINT16 minact_chdwell_time; /* msec */
21495 + A_UINT32 max_dfsch_act_time; /* msecs */
21496 +} POSTPACK WMI_SCAN_PARAMS_CMD;
21499 + * WMI_SET_BSS_FILTER_CMDID
21502 + NONE_BSS_FILTER = 0x0, /* no beacons forwarded */
21503 + ALL_BSS_FILTER, /* all beacons forwarded */
21504 + PROFILE_FILTER, /* only beacons matching profile */
21505 + ALL_BUT_PROFILE_FILTER, /* all but beacons matching profile */
21506 + CURRENT_BSS_FILTER, /* only beacons matching current BSS */
21507 + ALL_BUT_BSS_FILTER, /* all but beacons matching BSS */
21508 + PROBED_SSID_FILTER, /* beacons matching probed ssid */
21509 + LAST_BSS_FILTER, /* marker only */
21512 +typedef PREPACK struct {
21513 + A_UINT8 bssFilter; /* see WMI_BSS_FILTER */
21515 +} POSTPACK WMI_BSS_FILTER_CMD;
21518 + * WMI_SET_PROBED_SSID_CMDID
21520 +#define MAX_PROBED_SSID_INDEX 5
21523 + DISABLE_SSID_FLAG = 0, /* disables entry */
21524 + SPECIFIC_SSID_FLAG = 0x01, /* probes specified ssid */
21525 + ANY_SSID_FLAG = 0x02, /* probes for any ssid */
21528 +typedef PREPACK struct {
21529 + A_UINT8 entryIndex; /* 0 to MAX_PROBED_SSID_INDEX */
21530 + A_UINT8 flag; /* WMI_SSID_FLG */
21531 + A_UINT8 ssidLength;
21532 + A_UINT8 ssid[32];
21533 +} POSTPACK WMI_PROBED_SSID_CMD;
21536 + * WMI_SET_LISTEN_INT_CMDID
21537 + * The Listen interval is between 15 and 3000 TUs
21539 +#define MIN_LISTEN_INTERVAL 15
21540 +#define MAX_LISTEN_INTERVAL 5000
21541 +#define MIN_LISTEN_BEACONS 1
21542 +#define MAX_LISTEN_BEACONS 50
21544 +typedef PREPACK struct {
21545 + A_UINT16 listenInterval;
21546 + A_UINT16 numBeacons;
21547 +} POSTPACK WMI_LISTEN_INT_CMD;
21550 + * WMI_SET_BEACON_INT_CMDID
21552 +typedef PREPACK struct {
21553 + A_UINT16 beaconInterval;
21554 +} POSTPACK WMI_BEACON_INT_CMD;
21557 + * WMI_SET_BMISS_TIME_CMDID
21558 + * valid values are between 1000 and 5000 TUs
21561 +#define MIN_BMISS_TIME 1000
21562 +#define MAX_BMISS_TIME 5000
21563 +#define MIN_BMISS_BEACONS 1
21564 +#define MAX_BMISS_BEACONS 50
21566 +typedef PREPACK struct {
21567 + A_UINT16 bmissTime;
21568 + A_UINT16 numBeacons;
21569 +} POSTPACK WMI_BMISS_TIME_CMD;
21572 + * WMI_SET_POWER_MODE_CMDID
21575 + REC_POWER = 0x01,
21579 +typedef PREPACK struct {
21580 + A_UINT8 powerMode; /* WMI_POWER_MODE */
21581 +} POSTPACK WMI_POWER_MODE_CMD;
21584 + * WMI_SET_POWER_PARAMS_CMDID
21587 + IGNORE_DTIM = 0x01,
21588 + NORMAL_DTIM = 0x02,
21589 + STICK_DTIM = 0x03,
21590 +} WMI_DTIM_POLICY;
21592 +typedef PREPACK struct {
21593 + A_UINT16 idle_period; /* msec */
21594 + A_UINT16 pspoll_number;
21595 + A_UINT16 dtim_policy;
21596 +} POSTPACK WMI_POWER_PARAMS_CMD;
21598 +typedef PREPACK struct {
21599 + A_UINT8 power_saving;
21600 + A_UINT8 ttl; /* number of beacon periods */
21601 + A_UINT16 atim_windows; /* msec */
21602 + A_UINT16 timeout_value; /* msec */
21603 +} POSTPACK WMI_IBSS_PM_CAPS_CMD;
21606 + * WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID
21609 + IGNORE_TIM_ALL_QUEUES_APSD = 0,
21610 + PROCESS_TIM_ALL_QUEUES_APSD = 1,
21611 + IGNORE_TIM_SIMULATED_APSD = 2,
21612 + PROCESS_TIM_SIMULATED_APSD = 3,
21613 +} APSD_TIM_POLICY;
21615 +typedef PREPACK struct {
21616 + A_UINT16 psPollTimeout; /* msec */
21617 + A_UINT16 triggerTimeout; /* msec */
21618 + A_UINT32 apsdTimPolicy; /* TIM behavior with ques APSD enabled. Default is IGNORE_TIM_ALL_QUEUES_APSD */
21619 + A_UINT32 simulatedAPSDTimPolicy; /* TIM behavior with simulated APSD enabled. Default is PROCESS_TIM_SIMULATED_APSD */
21620 +} POSTPACK WMI_POWERSAVE_TIMERS_POLICY_CMD;
21623 + * WMI_SET_VOICE_PKT_SIZE_CMDID
21625 +typedef PREPACK struct {
21626 + A_UINT16 voicePktSize;
21627 +} POSTPACK WMI_SET_VOICE_PKT_SIZE_CMD;
21630 + * WMI_SET_MAX_SP_LEN_CMDID
21633 + DELIVER_ALL_PKT = 0x0,
21634 + DELIVER_2_PKT = 0x1,
21635 + DELIVER_4_PKT = 0x2,
21636 + DELIVER_6_PKT = 0x3,
21637 +} APSD_SP_LEN_TYPE;
21639 +typedef PREPACK struct {
21640 + A_UINT8 maxSPLen;
21641 +} POSTPACK WMI_SET_MAX_SP_LEN_CMD;
21644 + * WMI_SET_DISC_TIMEOUT_CMDID
21646 +typedef PREPACK struct {
21647 + A_UINT8 disconnectTimeout; /* seconds */
21648 +} POSTPACK WMI_DISC_TIMEOUT_CMD;
21651 + UPLINK_TRAFFIC = 0,
21652 + DNLINK_TRAFFIC = 1,
21653 + BIDIR_TRAFFIC = 2,
21657 + DISABLE_FOR_THIS_AC = 0,
21658 + ENABLE_FOR_THIS_AC = 1,
21659 + ENABLE_FOR_ALL_AC = 2,
21660 +} VOICEPS_CAP_TYPE;
21663 + TRAFFIC_TYPE_APERIODIC = 0,
21664 + TRAFFIC_TYPE_PERIODIC = 1,
21668 + * WMI_CREATE_PSTREAM_CMDID
21670 +typedef PREPACK struct {
21671 + A_UINT32 minServiceInt; /* in milli-sec */
21672 + A_UINT32 maxServiceInt; /* in milli-sec */
21673 + A_UINT32 inactivityInt; /* in milli-sec */
21674 + A_UINT32 suspensionInt; /* in milli-sec */
21675 + A_UINT32 serviceStartTime;
21676 + A_UINT32 minDataRate; /* in bps */
21677 + A_UINT32 meanDataRate; /* in bps */
21678 + A_UINT32 peakDataRate; /* in bps */
21679 + A_UINT32 maxBurstSize;
21680 + A_UINT32 delayBound;
21681 + A_UINT32 minPhyRate; /* in bps */
21683 + A_UINT32 mediumTime;
21684 + A_UINT16 nominalMSDU; /* in octects */
21685 + A_UINT16 maxMSDU; /* in octects */
21686 + A_UINT8 trafficClass;
21687 + A_UINT8 trafficType; /* TRAFFIC_TYPE */
21688 + A_UINT8 trafficDirection; /* TRAFFIC_DIR */
21689 + A_UINT8 voicePSCapability; /* VOICEPS_CAP_TYPE */
21691 + A_UINT8 userPriority; /* 802.1D user priority */
21692 +} POSTPACK WMI_CREATE_PSTREAM_CMD;
21695 + * WMI_DELETE_PSTREAM_CMDID
21697 +typedef PREPACK struct {
21698 + A_UINT8 trafficClass;
21700 +} POSTPACK WMI_DELETE_PSTREAM_CMD;
21703 + * WMI_SET_CHANNEL_PARAMS_CMDID
21706 + WMI_11A_MODE = 0x1,
21707 + WMI_11G_MODE = 0x2,
21708 + WMI_11AG_MODE = 0x3,
21709 + WMI_11B_MODE = 0x4,
21710 + WMI_11GONLY_MODE = 0x5,
21713 +#define WMI_MAX_CHANNELS 32
21715 +typedef PREPACK struct {
21716 + A_UINT8 reserved1;
21717 + A_UINT8 scanParam; /* set if enable scan */
21718 + A_UINT8 phyMode; /* see WMI_PHY_MODE */
21719 + A_UINT8 numChannels; /* how many channels follow */
21720 + A_UINT16 channelList[1]; /* channels in Mhz */
21721 +} POSTPACK WMI_CHANNEL_PARAMS_CMD;
21725 + * WMI_RSSI_THRESHOLD_PARAMS_CMDID
21726 + * Setting the polltime to 0 would disable polling.
21727 + * Threshold values are in the ascending order, and should agree to:
21728 + * (lowThreshold_lowerVal < lowThreshold_upperVal < highThreshold_lowerVal
21729 + * < highThreshold_upperVal)
21732 +typedef PREPACK struct WMI_RSSI_THRESHOLD_PARAMS{
21733 + A_UINT32 pollTime; /* Polling time as a factor of LI */
21734 + A_INT16 thresholdAbove1_Val; /* lowest of upper */
21735 + A_INT16 thresholdAbove2_Val;
21736 + A_INT16 thresholdAbove3_Val;
21737 + A_INT16 thresholdAbove4_Val;
21738 + A_INT16 thresholdAbove5_Val;
21739 + A_INT16 thresholdAbove6_Val; /* highest of upper */
21740 + A_INT16 thresholdBelow1_Val; /* lowest of bellow */
21741 + A_INT16 thresholdBelow2_Val;
21742 + A_INT16 thresholdBelow3_Val;
21743 + A_INT16 thresholdBelow4_Val;
21744 + A_INT16 thresholdBelow5_Val;
21745 + A_INT16 thresholdBelow6_Val; /* highest of bellow */
21746 + A_UINT8 weight; /* "alpha" */
21747 + A_UINT8 reserved[3];
21748 +} POSTPACK WMI_RSSI_THRESHOLD_PARAMS_CMD;
21751 + * WMI_SNR_THRESHOLD_PARAMS_CMDID
21752 + * Setting the polltime to 0 would disable polling.
21755 +typedef PREPACK struct WMI_SNR_THRESHOLD_PARAMS{
21756 + A_UINT32 pollTime; /* Polling time as a factor of LI */
21757 + A_UINT8 weight; /* "alpha" */
21758 + A_UINT8 thresholdAbove1_Val; /* lowest of uppper*/
21759 + A_UINT8 thresholdAbove2_Val;
21760 + A_UINT8 thresholdAbove3_Val;
21761 + A_UINT8 thresholdAbove4_Val; /* highest of upper */
21762 + A_UINT8 thresholdBelow1_Val; /* lowest of bellow */
21763 + A_UINT8 thresholdBelow2_Val;
21764 + A_UINT8 thresholdBelow3_Val;
21765 + A_UINT8 thresholdBelow4_Val; /* highest of bellow */
21766 + A_UINT8 reserved[3];
21767 +} POSTPACK WMI_SNR_THRESHOLD_PARAMS_CMD;
21770 + * WMI_LQ_THRESHOLD_PARAMS_CMDID
21772 +typedef PREPACK struct WMI_LQ_THRESHOLD_PARAMS {
21774 + A_UINT8 thresholdAbove1_Val;
21775 + A_UINT8 thresholdAbove2_Val;
21776 + A_UINT8 thresholdAbove3_Val;
21777 + A_UINT8 thresholdAbove4_Val;
21778 + A_UINT8 thresholdBelow1_Val;
21779 + A_UINT8 thresholdBelow2_Val;
21780 + A_UINT8 thresholdBelow3_Val;
21781 + A_UINT8 thresholdBelow4_Val;
21782 + A_UINT8 reserved[3];
21783 +} POSTPACK WMI_LQ_THRESHOLD_PARAMS_CMD;
21786 + WMI_LPREAMBLE_DISABLED = 0,
21787 + WMI_LPREAMBLE_ENABLED
21788 +} WMI_LPREAMBLE_STATUS;
21790 +typedef PREPACK struct {
21792 +}POSTPACK WMI_SET_LPREAMBLE_CMD;
21794 +typedef PREPACK struct {
21795 + A_UINT16 threshold;
21796 +}POSTPACK WMI_SET_RTS_CMD;
21799 + * WMI_TARGET_ERROR_REPORT_BITMASK_CMDID
21800 + * Sets the error reporting event bitmask in target. Target clears it
21801 + * upon an error. Subsequent errors are counted, but not reported
21802 + * via event, unless the bitmask is set again.
21804 +typedef PREPACK struct {
21805 + A_UINT32 bitmask;
21806 +} POSTPACK WMI_TARGET_ERROR_REPORT_BITMASK;
21809 + * WMI_SET_TX_PWR_CMDID
21811 +typedef PREPACK struct {
21812 + A_UINT8 dbM; /* in dbM units */
21813 +} POSTPACK WMI_SET_TX_PWR_CMD, WMI_TX_PWR_REPLY;
21816 + * WMI_SET_ASSOC_INFO_CMDID
21818 + * A maximum of 2 private IEs can be sent in the [Re]Assoc request.
21819 + * A 3rd one, the CCX version IE can also be set from the host.
21821 +#define WMI_MAX_ASSOC_INFO_TYPE 2
21822 +#define WMI_CCX_VER_IE 2 /* ieType to set CCX Version IE */
21824 +#define WMI_MAX_ASSOC_INFO_LEN 240
21826 +typedef PREPACK struct {
21828 + A_UINT8 bufferSize;
21829 + A_UINT8 assocInfo[1]; /* up to WMI_MAX_ASSOC_INFO_LEN */
21830 +} POSTPACK WMI_SET_ASSOC_INFO_CMD;
21834 + * WMI_GET_TX_PWR_CMDID does not take any parameters
21838 + * WMI_ADD_BAD_AP_CMDID
21840 +#define WMI_MAX_BAD_AP_INDEX 1
21842 +typedef PREPACK struct {
21843 + A_UINT8 badApIndex; /* 0 to WMI_MAX_BAD_AP_INDEX */
21844 + A_UINT8 bssid[ATH_MAC_LEN];
21845 +} POSTPACK WMI_ADD_BAD_AP_CMD;
21848 + * WMI_DELETE_BAD_AP_CMDID
21850 +typedef PREPACK struct {
21851 + A_UINT8 badApIndex; /* 0 to WMI_MAX_BAD_AP_INDEX */
21852 +} POSTPACK WMI_DELETE_BAD_AP_CMD;
21855 + * WMI_SET_ACCESS_PARAMS_CMDID
21857 +#define WMI_DEFAULT_TXOP_ACPARAM 0 /* implies one MSDU */
21858 +#define WMI_DEFAULT_ECWMIN_ACPARAM 4 /* corresponds to CWmin of 15 */
21859 +#define WMI_DEFAULT_ECWMAX_ACPARAM 10 /* corresponds to CWmax of 1023 */
21860 +#define WMI_MAX_CW_ACPARAM 15 /* maximum eCWmin or eCWmax */
21861 +#define WMI_DEFAULT_AIFSN_ACPARAM 2
21862 +#define WMI_MAX_AIFSN_ACPARAM 15
21863 +typedef PREPACK struct {
21864 + A_UINT16 txop; /* in units of 32 usec */
21868 +} POSTPACK WMI_SET_ACCESS_PARAMS_CMD;
21872 + * WMI_SET_RETRY_LIMITS_CMDID
21874 + * This command is used to customize the number of retries the
21875 + * wlan device will perform on a given frame.
21877 +#define WMI_MIN_RETRIES 2
21878 +#define WMI_MAX_RETRIES 13
21880 + MGMT_FRAMETYPE = 0,
21881 + CONTROL_FRAMETYPE = 1,
21882 + DATA_FRAMETYPE = 2
21885 +typedef PREPACK struct {
21886 + A_UINT8 frameType; /* WMI_FRAMETYPE */
21887 + A_UINT8 trafficClass; /* applies only to DATA_FRAMETYPE */
21888 + A_UINT8 maxRetries;
21889 + A_UINT8 enableNotify;
21890 +} POSTPACK WMI_SET_RETRY_LIMITS_CMD;
21893 + * WMI_SET_ROAM_CTRL_CMDID
21895 + * This command is used to influence the Roaming behaviour
21896 + * Set the host biases of the BSSs before setting the roam mode as bias
21901 + * Different types of Roam Control
21905 + WMI_FORCE_ROAM = 1, /* Roam to the specified BSSID */
21906 + WMI_SET_ROAM_MODE = 2, /* default ,progd bias, no roam */
21907 + WMI_SET_HOST_BIAS = 3, /* Set the Host Bias */
21908 + WMI_SET_LOWRSSI_SCAN_PARAMS = 4, /* Set lowrssi Scan parameters */
21909 +} WMI_ROAM_CTRL_TYPE;
21911 +#define WMI_MIN_ROAM_CTRL_TYPE WMI_FORCE_ROAM
21912 +#define WMI_MAX_ROAM_CTRL_TYPE WMI_SET_LOWRSSI_SCAN_PARAMS
21919 + WMI_DEFAULT_ROAM_MODE = 1, /* RSSI based ROAM */
21920 + WMI_HOST_BIAS_ROAM_MODE = 2, /* HOST BIAS based ROAM */
21921 + WMI_LOCK_BSS_MODE = 3 /* Lock to the Current BSS - no Roam */
21925 + * BSS HOST BIAS INFO
21928 +typedef PREPACK struct {
21929 + A_UINT8 bssid[ATH_MAC_LEN];
21931 +} POSTPACK WMI_BSS_BIAS;
21933 +typedef PREPACK struct {
21935 + WMI_BSS_BIAS bssBias[1];
21936 +} POSTPACK WMI_BSS_BIAS_INFO;
21938 +typedef PREPACK struct WMI_LOWRSSI_SCAN_PARAMS {
21939 + A_UINT16 lowrssi_scan_period;
21940 + A_INT16 lowrssi_scan_threshold;
21941 + A_INT16 lowrssi_roam_threshold;
21942 + A_UINT8 roam_rssi_floor;
21943 + A_UINT8 reserved[1]; /* For alignment */
21944 +} POSTPACK WMI_LOWRSSI_SCAN_PARAMS;
21946 +typedef PREPACK struct {
21948 + A_UINT8 bssid[ATH_MAC_LEN]; /* WMI_FORCE_ROAM */
21949 + A_UINT8 roamMode; /* WMI_SET_ROAM_MODE */
21950 + WMI_BSS_BIAS_INFO bssBiasInfo; /* WMI_SET_HOST_BIAS */
21951 + WMI_LOWRSSI_SCAN_PARAMS lrScanParams;
21953 + A_UINT8 roamCtrlType ;
21954 +} POSTPACK WMI_SET_ROAM_CTRL_CMD;
21957 + * WMI_ENABLE_RM_CMDID
21959 +typedef PREPACK struct {
21960 + A_BOOL enable_radio_measurements;
21961 +} POSTPACK WMI_ENABLE_RM_CMD;
21964 + * WMI_SET_MAX_OFFHOME_DURATION_CMDID
21966 +typedef PREPACK struct {
21967 + A_UINT8 max_offhome_duration;
21968 +} POSTPACK WMI_SET_MAX_OFFHOME_DURATION_CMD;
21970 +typedef PREPACK struct {
21971 + A_UINT32 frequency;
21972 + A_UINT8 threshold;
21973 +} POSTPACK WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD;
21976 + BT_STREAM_UNDEF = 0,
21977 + BT_STREAM_SCO, /* SCO stream */
21978 + BT_STREAM_A2DP, /* A2DP stream */
21983 + BT_PARAM_SCO = 1, /* SCO stream parameters */
21984 + BT_PARAM_A2DP, /* A2DP stream parameters */
21985 + BT_PARAM_MISC, /* miscellaneous parameters */
21986 + BT_PARAM_REGS, /* co-existence register parameters */
21991 + BT_STATUS_UNDEF = 0,
21994 + BT_STATUS_RESUME,
21995 + BT_STATUS_SUSPEND,
21997 +} BT_STREAM_STATUS;
21999 +typedef PREPACK struct {
22000 + A_UINT8 streamType;
22002 +} POSTPACK WMI_SET_BT_STATUS_CMD;
22004 +typedef PREPACK struct {
22005 + A_UINT8 noSCOPkts;
22006 + A_UINT8 pspollTimeout;
22008 +} POSTPACK BT_PARAMS_SCO;
22010 +typedef PREPACK struct {
22012 + A_UINT32 dutycycle;
22014 +} POSTPACK BT_PARAMS_A2DP;
22016 +typedef PREPACK struct {
22018 + A_UINT32 scoWghts;
22019 + A_UINT32 a2dpWghts;
22020 + A_UINT32 genWghts;
22023 +} POSTPACK BT_COEX_REGS;
22026 + WLAN_PROTECT_POLICY = 1,
22027 + WLAN_COEX_CTRL_FLAGS
22028 +} BT_PARAMS_MISC_TYPE;
22031 + WLAN_PROTECT_PER_STREAM = 0x01, /* default */
22032 + WLAN_PROTECT_ANY_TX = 0x02
22033 +} WLAN_PROTECT_FLAGS;
22036 +#define WLAN_DISABLE_COEX_IN_DISCONNECT 0x01 /* default */
22037 +#define WLAN_KEEP_COEX_IN_DISCONNECT 0x02
22038 +#define WLAN_STOMPBT_IN_DISCONNECT 0x04
22040 +#define WLAN_DISABLE_COEX_IN_ROAM 0x10 /* default */
22041 +#define WLAN_KEEP_COEX_IN_ROAM 0x20
22042 +#define WLAN_STOMPBT_IN_ROAM 0x40
22044 +#define WLAN_DISABLE_COEX_IN_SCAN 0x100 /* default */
22045 +#define WLAN_KEEP_COEX_IN_SCAN 0x200
22046 +#define WLAN_STOMPBT_IN_SCAN 0x400
22048 +#define WLAN_DISABLE_COEX_BT_OFF 0x1000 /* default */
22049 +#define WLAN_KEEP_COEX_BT_OFF 0x2000
22050 +#define WLAN_STOMPBT_BT_OFF 0x4000
22052 +typedef PREPACK struct {
22054 + A_UINT32 dutycycle;
22057 +} POSTPACK WLAN_PROTECT_POLICY_TYPE;
22059 +typedef PREPACK struct {
22061 + WLAN_PROTECT_POLICY_TYPE protectParams;
22062 + A_UINT16 wlanCtrlFlags;
22064 + A_UINT8 paramType;
22065 +} POSTPACK BT_PARAMS_MISC;
22067 +typedef PREPACK struct {
22069 + BT_PARAMS_SCO scoParams;
22070 + BT_PARAMS_A2DP a2dpParams;
22071 + BT_PARAMS_MISC miscParams;
22072 + BT_COEX_REGS regs;
22074 + A_UINT8 paramType;
22075 +} POSTPACK WMI_SET_BT_PARAMS_CMD;
22078 + * Command Replies
22082 + * WMI_GET_CHANNEL_LIST_CMDID reply
22084 +typedef PREPACK struct {
22085 + A_UINT8 reserved1;
22086 + A_UINT8 numChannels; /* number of channels in reply */
22087 + A_UINT16 channelList[1]; /* channel in Mhz */
22088 +} POSTPACK WMI_CHANNEL_LIST_REPLY;
22091 + A_SUCCEEDED = A_OK,
22092 + A_FAILED_DELETE_STREAM_DOESNOT_EXIST=250,
22093 + A_SUCCEEDED_MODIFY_STREAM=251,
22094 + A_FAILED_INVALID_STREAM = 252,
22095 + A_FAILED_MAX_THINSTREAMS = 253,
22096 + A_FAILED_CREATE_REMOVE_PSTREAM_FIRST = 254,
22097 +} PSTREAM_REPLY_STATUS;
22100 + * List of Events (target to host)
22103 + WMI_READY_EVENTID = 0x1001,
22104 + WMI_CONNECT_EVENTID,
22105 + WMI_DISCONNECT_EVENTID,
22106 + WMI_BSSINFO_EVENTID,
22107 + WMI_CMDERROR_EVENTID,
22108 + WMI_REGDOMAIN_EVENTID,
22109 + WMI_PSTREAM_TIMEOUT_EVENTID,
22110 + WMI_NEIGHBOR_REPORT_EVENTID,
22111 + WMI_TKIP_MICERR_EVENTID,
22112 + WMI_SCAN_COMPLETE_EVENTID,
22113 + WMI_REPORT_STATISTICS_EVENTID,
22114 + WMI_RSSI_THRESHOLD_EVENTID,
22115 + WMI_ERROR_REPORT_EVENTID,
22116 + WMI_OPT_RX_FRAME_EVENTID,
22117 + WMI_REPORT_ROAM_TBL_EVENTID,
22118 + WMI_EXTENSION_EVENTID,
22120 + WMI_SNR_THRESHOLD_EVENTID,
22121 + WMI_LQ_THRESHOLD_EVENTID,
22122 + WMI_TX_RETRY_ERR_EVENTID,
22123 + WMI_REPORT_ROAM_DATA_EVENTID,
22124 + WMI_TEST_EVENTID,
22125 + WMI_APLIST_EVENTID,
22126 + WMI_GET_WOW_LIST_EVENTID,
22127 + WMI_GET_PMKID_LIST_EVENTID
22131 + WMI_11A_CAPABILITY = 1,
22132 + WMI_11G_CAPABILITY = 2,
22133 + WMI_11AG_CAPABILITY = 3,
22134 +} WMI_PHY_CAPABILITY;
22136 +typedef PREPACK struct {
22137 + A_UINT8 macaddr[ATH_MAC_LEN];
22138 + A_UINT8 phyCapability; /* WMI_PHY_CAPABILITY */
22139 +} POSTPACK WMI_READY_EVENT;
22144 +typedef PREPACK struct {
22145 + A_UINT16 channel;
22146 + A_UINT8 bssid[ATH_MAC_LEN];
22147 + A_UINT16 listenInterval;
22148 + A_UINT16 beaconInterval;
22149 + A_UINT32 networkType;
22150 + A_UINT8 beaconIeLen;
22151 + A_UINT8 assocReqLen;
22152 + A_UINT8 assocRespLen;
22153 + A_UINT8 assocInfo[1];
22154 +} POSTPACK WMI_CONNECT_EVENT;
22157 + * Disconnect Event
22160 + NO_NETWORK_AVAIL = 0x01,
22161 + LOST_LINK = 0x02, /* bmiss */
22162 + DISCONNECT_CMD = 0x03,
22163 + BSS_DISCONNECTED = 0x04,
22164 + AUTH_FAILED = 0x05,
22165 + ASSOC_FAILED = 0x06,
22166 + NO_RESOURCES_AVAIL = 0x07,
22167 + CSERV_DISCONNECT = 0x08,
22168 + INVALID_PROFILE = 0x0a,
22169 + DOT11H_CHANNEL_SWITCH = 0x0b,
22170 +} WMI_DISCONNECT_REASON;
22172 +typedef PREPACK struct {
22173 + A_UINT16 protocolReasonStatus; /* reason code, see 802.11 spec. */
22174 + A_UINT8 bssid[ATH_MAC_LEN]; /* set if known */
22175 + A_UINT8 disconnectReason ; /* see WMI_DISCONNECT_REASON */
22176 + A_UINT8 assocRespLen;
22177 + A_UINT8 assocInfo[1];
22178 +} POSTPACK WMI_DISCONNECT_EVENT;
22181 + * BSS Info Event.
22182 + * Mechanism used to inform host of the presence and characteristic of
22183 + * wireless networks present. Consists of bss info header followed by
22184 + * the beacon or probe-response frame body. The 802.11 header is not included.
22187 + BEACON_FTYPE = 0x1,
22189 + ACTION_MGMT_FTYPE,
22193 + BSS_ELEMID_CHANSWITCH = 0x01,
22194 + BSS_ELEMID_ATHEROS = 0x02,
22197 +typedef PREPACK struct {
22198 + A_UINT16 channel;
22199 + A_UINT8 frameType; /* see WMI_BI_FTYPE */
22202 + A_UINT8 bssid[ATH_MAC_LEN];
22204 +} POSTPACK WMI_BSS_INFO_HDR;
22207 + * Command Error Event
22210 + INVALID_PARAM = 0x01,
22211 + ILLEGAL_STATE = 0x02,
22212 + INTERNAL_ERROR = 0x03,
22215 +typedef PREPACK struct {
22216 + A_UINT16 commandId;
22217 + A_UINT8 errorCode;
22218 +} POSTPACK WMI_CMD_ERROR_EVENT;
22221 + * New Regulatory Domain Event
22223 +typedef PREPACK struct {
22224 + A_UINT32 regDomain;
22225 +} POSTPACK WMI_REG_DOMAIN_EVENT;
22227 +typedef PREPACK struct {
22228 + A_UINT8 trafficClass;
22229 +} POSTPACK WMI_PSTREAM_TIMEOUT_EVENT;
22232 + * The WMI_NEIGHBOR_REPORT Event is generated by the target to inform
22233 + * the host of BSS's it has found that matches the current profile.
22234 + * It can be used by the host to cache PMKs and/to initiate pre-authentication
22235 + * if the BSS supports it. The first bssid is always the current associated
22237 + * The bssid and bssFlags information repeats according to the number
22238 + * or APs reported.
22241 + WMI_DEFAULT_BSS_FLAGS = 0x00,
22242 + WMI_PREAUTH_CAPABLE_BSS = 0x01,
22243 + WMI_PMKID_VALID_BSS = 0x02,
22246 +typedef PREPACK struct {
22247 + A_UINT8 bssid[ATH_MAC_LEN];
22248 + A_UINT8 bssFlags; /* see WMI_BSS_FLAGS */
22249 +} POSTPACK WMI_NEIGHBOR_INFO;
22251 +typedef PREPACK struct {
22252 + A_INT8 numberOfAps;
22253 + WMI_NEIGHBOR_INFO neighbor[1];
22254 +} POSTPACK WMI_NEIGHBOR_REPORT_EVENT;
22257 + * TKIP MIC Error Event
22259 +typedef PREPACK struct {
22262 +} POSTPACK WMI_TKIP_MICERR_EVENT;
22265 + * WMI_SCAN_COMPLETE_EVENTID - no parameters (old), staus parameter (new)
22267 +typedef PREPACK struct {
22269 +} POSTPACK WMI_SCAN_COMPLETE_EVENT;
22271 +#define MAX_OPT_DATA_LEN 1400
22274 + * WMI_SET_ADHOC_BSSID_CMDID
22276 +typedef PREPACK struct {
22277 + A_UINT8 bssid[ATH_MAC_LEN];
22278 +} POSTPACK WMI_SET_ADHOC_BSSID_CMD;
22281 + * WMI_SET_OPT_MODE_CMDID
22288 +typedef PREPACK struct {
22290 +} POSTPACK WMI_SET_OPT_MODE_CMD;
22293 + * WMI_TX_OPT_FRAME_CMDID
22296 + OPT_PROBE_REQ = 0x01,
22297 + OPT_PROBE_RESP = 0x02,
22298 + OPT_CPPP_START = 0x03,
22299 + OPT_CPPP_STOP = 0x04,
22302 +typedef PREPACK struct {
22303 + A_UINT16 optIEDataLen;
22305 + A_UINT8 dstAddr[ATH_MAC_LEN];
22306 + A_UINT8 bssid[ATH_MAC_LEN];
22307 + A_UINT8 reserved; /* For alignment */
22308 + A_UINT8 optIEData[1];
22309 +} POSTPACK WMI_OPT_TX_FRAME_CMD;
22312 + * Special frame receive Event.
22313 + * Mechanism used to inform host of the receiption of the special frames.
22314 + * Consists of special frame info header followed by special frame body.
22315 + * The 802.11 header is not included.
22317 +typedef PREPACK struct {
22318 + A_UINT16 channel;
22319 + A_UINT8 frameType; /* see WMI_OPT_FTYPE */
22321 + A_UINT8 srcAddr[ATH_MAC_LEN];
22322 + A_UINT8 bssid[ATH_MAC_LEN];
22323 +} POSTPACK WMI_OPT_RX_INFO_HDR;
22326 + * Reporting statistics.
22328 +typedef PREPACK struct {
22329 + A_UINT32 tx_packets;
22330 + A_UINT32 tx_bytes;
22331 + A_UINT32 tx_unicast_pkts;
22332 + A_UINT32 tx_unicast_bytes;
22333 + A_UINT32 tx_multicast_pkts;
22334 + A_UINT32 tx_multicast_bytes;
22335 + A_UINT32 tx_broadcast_pkts;
22336 + A_UINT32 tx_broadcast_bytes;
22337 + A_UINT32 tx_rts_success_cnt;
22338 + A_UINT32 tx_packet_per_ac[4];
22339 + A_UINT32 tx_errors_per_ac[4];
22341 + A_UINT32 tx_errors;
22342 + A_UINT32 tx_failed_cnt;
22343 + A_UINT32 tx_retry_cnt;
22344 + A_UINT32 tx_rts_fail_cnt;
22345 + A_INT32 tx_unicast_rate;
22346 +}POSTPACK tx_stats_t;
22348 +typedef PREPACK struct {
22349 + A_UINT32 rx_packets;
22350 + A_UINT32 rx_bytes;
22351 + A_UINT32 rx_unicast_pkts;
22352 + A_UINT32 rx_unicast_bytes;
22353 + A_UINT32 rx_multicast_pkts;
22354 + A_UINT32 rx_multicast_bytes;
22355 + A_UINT32 rx_broadcast_pkts;
22356 + A_UINT32 rx_broadcast_bytes;
22357 + A_UINT32 rx_fragment_pkt;
22359 + A_UINT32 rx_errors;
22360 + A_UINT32 rx_crcerr;
22361 + A_UINT32 rx_key_cache_miss;
22362 + A_UINT32 rx_decrypt_err;
22363 + A_UINT32 rx_duplicate_frames;
22364 + A_INT32 rx_unicast_rate;
22365 +}POSTPACK rx_stats_t;
22367 +typedef PREPACK struct {
22368 + A_UINT32 tkip_local_mic_failure;
22369 + A_UINT32 tkip_counter_measures_invoked;
22370 + A_UINT32 tkip_replays;
22371 + A_UINT32 tkip_format_errors;
22372 + A_UINT32 ccmp_format_errors;
22373 + A_UINT32 ccmp_replays;
22374 +}POSTPACK tkip_ccmp_stats_t;
22376 +typedef PREPACK struct {
22377 + A_UINT32 power_save_failure_cnt;
22378 +}POSTPACK pm_stats_t;
22380 +typedef PREPACK struct {
22381 + A_UINT32 cs_bmiss_cnt;
22382 + A_UINT32 cs_lowRssi_cnt;
22383 + A_UINT16 cs_connect_cnt;
22384 + A_UINT16 cs_disconnect_cnt;
22385 + A_INT16 cs_aveBeacon_rssi;
22386 + A_UINT16 cs_roam_count;
22387 + A_UINT16 cs_rssi;
22389 + A_UINT8 cs_aveBeacon_snr;
22390 + A_UINT8 cs_lastRoam_msec;
22391 +} POSTPACK cserv_stats_t;
22393 +typedef PREPACK struct {
22394 + tx_stats_t tx_stats;
22395 + rx_stats_t rx_stats;
22396 + tkip_ccmp_stats_t tkipCcmpStats;
22397 +}POSTPACK wlan_net_stats_t;
22399 +typedef PREPACK struct {
22400 + A_UINT32 wow_num_pkts_dropped;
22401 + A_UINT16 wow_num_events_discarded;
22402 + A_UINT8 wow_num_host_pkt_wakeups;
22403 + A_UINT8 wow_num_host_event_wakeups;
22404 +} POSTPACK wlan_wow_stats_t;
22406 +typedef PREPACK struct {
22408 + A_INT32 noise_floor_calibation;
22409 + pm_stats_t pmStats;
22410 + wlan_net_stats_t txrxStats;
22411 + wlan_wow_stats_t wowStats;
22412 + cserv_stats_t cservStats;
22413 +} POSTPACK WMI_TARGET_STATS;
22416 + * WMI_RSSI_THRESHOLD_EVENTID.
22417 + * Indicate the RSSI events to host. Events are indicated when we breach a
22418 + * thresold value.
22421 + WMI_RSSI_THRESHOLD1_ABOVE = 0,
22422 + WMI_RSSI_THRESHOLD2_ABOVE,
22423 + WMI_RSSI_THRESHOLD3_ABOVE,
22424 + WMI_RSSI_THRESHOLD4_ABOVE,
22425 + WMI_RSSI_THRESHOLD5_ABOVE,
22426 + WMI_RSSI_THRESHOLD6_ABOVE,
22427 + WMI_RSSI_THRESHOLD1_BELOW,
22428 + WMI_RSSI_THRESHOLD2_BELOW,
22429 + WMI_RSSI_THRESHOLD3_BELOW,
22430 + WMI_RSSI_THRESHOLD4_BELOW,
22431 + WMI_RSSI_THRESHOLD5_BELOW,
22432 + WMI_RSSI_THRESHOLD6_BELOW
22433 +}WMI_RSSI_THRESHOLD_VAL;
22435 +typedef PREPACK struct {
22438 +}POSTPACK WMI_RSSI_THRESHOLD_EVENT;
22441 + * WMI_ERROR_REPORT_EVENTID
22444 + WMI_TARGET_PM_ERR_FAIL = 0x00000001,
22445 + WMI_TARGET_KEY_NOT_FOUND = 0x00000002,
22446 + WMI_TARGET_DECRYPTION_ERR = 0x00000004,
22447 + WMI_TARGET_BMISS = 0x00000008,
22448 + WMI_PSDISABLE_NODE_JOIN = 0x00000010,
22449 + WMI_TARGET_COM_ERR = 0x00000020,
22450 + WMI_TARGET_FATAL_ERR = 0x00000040
22451 +} WMI_TARGET_ERROR_VAL;
22453 +typedef PREPACK struct {
22454 + A_UINT32 errorVal;
22455 +}POSTPACK WMI_TARGET_ERROR_REPORT_EVENT;
22457 +typedef PREPACK struct {
22459 +}POSTPACK WMI_TX_RETRY_ERR_EVENT;
22462 + WMI_SNR_THRESHOLD1_ABOVE = 1,
22463 + WMI_SNR_THRESHOLD1_BELOW,
22464 + WMI_SNR_THRESHOLD2_ABOVE,
22465 + WMI_SNR_THRESHOLD2_BELOW,
22466 + WMI_SNR_THRESHOLD3_ABOVE,
22467 + WMI_SNR_THRESHOLD3_BELOW,
22468 + WMI_SNR_THRESHOLD4_ABOVE,
22469 + WMI_SNR_THRESHOLD4_BELOW
22470 +} WMI_SNR_THRESHOLD_VAL;
22472 +typedef PREPACK struct {
22473 + A_UINT8 range; /* WMI_SNR_THRESHOLD_VAL */
22475 +}POSTPACK WMI_SNR_THRESHOLD_EVENT;
22478 + WMI_LQ_THRESHOLD1_ABOVE = 1,
22479 + WMI_LQ_THRESHOLD1_BELOW,
22480 + WMI_LQ_THRESHOLD2_ABOVE,
22481 + WMI_LQ_THRESHOLD2_BELOW,
22482 + WMI_LQ_THRESHOLD3_ABOVE,
22483 + WMI_LQ_THRESHOLD3_BELOW,
22484 + WMI_LQ_THRESHOLD4_ABOVE,
22485 + WMI_LQ_THRESHOLD4_BELOW
22486 +} WMI_LQ_THRESHOLD_VAL;
22488 +typedef PREPACK struct {
22490 + A_UINT8 range; /* WMI_LQ_THRESHOLD_VAL */
22491 +}POSTPACK WMI_LQ_THRESHOLD_EVENT;
22493 + * WMI_REPORT_ROAM_TBL_EVENTID
22495 +#define MAX_ROAM_TBL_CAND 5
22497 +typedef PREPACK struct {
22498 + A_INT32 roam_util;
22499 + A_UINT8 bssid[ATH_MAC_LEN];
22502 + A_INT8 last_rssi;
22505 + A_UINT8 reserved; /* For alignment */
22506 +} POSTPACK WMI_BSS_ROAM_INFO;
22509 +typedef PREPACK struct {
22510 + A_UINT16 roamMode;
22511 + A_UINT16 numEntries;
22512 + WMI_BSS_ROAM_INFO bssRoamInfo[1];
22513 +} POSTPACK WMI_TARGET_ROAM_TBL;
22516 + * WMI_CAC_EVENTID
22519 + CAC_INDICATION_ADMISSION = 0x00,
22520 + CAC_INDICATION_ADMISSION_RESP = 0x01,
22521 + CAC_INDICATION_DELETE = 0x02,
22522 + CAC_INDICATION_NO_RESP = 0x03,
22525 +#define WMM_TSPEC_IE_LEN 63
22527 +typedef PREPACK struct {
22529 + A_UINT8 cac_indication;
22530 + A_UINT8 statusCode;
22531 + A_UINT8 tspecSuggestion[WMM_TSPEC_IE_LEN];
22532 +}POSTPACK WMI_CAC_EVENT;
22535 + * WMI_APLIST_EVENTID
22542 +typedef PREPACK struct {
22543 + A_UINT8 bssid[ATH_MAC_LEN];
22544 + A_UINT16 channel;
22545 +} POSTPACK WMI_AP_INFO_V1;
22547 +typedef PREPACK union {
22548 + WMI_AP_INFO_V1 apInfoV1;
22549 +} POSTPACK WMI_AP_INFO;
22551 +typedef PREPACK struct {
22552 + A_UINT8 apListVer;
22554 + WMI_AP_INFO apList[1];
22555 +} POSTPACK WMI_APLIST_EVENT;
22558 + * developer commands
22562 + * WMI_SET_BITRATE_CMDID
22564 + * Get bit rate cmd uses same definition as set bit rate cmd
22582 +typedef PREPACK struct {
22583 + A_INT8 rateIndex; /* see WMI_BIT_RATE */
22584 +} POSTPACK WMI_BIT_RATE_CMD, WMI_BIT_RATE_REPLY;
22587 + * WMI_SET_FIXRATES_CMDID
22589 + * Get fix rates cmd uses same definition as set fix rates cmd
22592 + FIX_RATE_1Mb = 0x1,
22593 + FIX_RATE_2Mb = 0x2,
22594 + FIX_RATE_5_5Mb = 0x4,
22595 + FIX_RATE_11Mb = 0x8,
22596 + FIX_RATE_6Mb = 0x10,
22597 + FIX_RATE_9Mb = 0x20,
22598 + FIX_RATE_12Mb = 0x40,
22599 + FIX_RATE_18Mb = 0x80,
22600 + FIX_RATE_24Mb = 0x100,
22601 + FIX_RATE_36Mb = 0x200,
22602 + FIX_RATE_48Mb = 0x400,
22603 + FIX_RATE_54Mb = 0x800,
22604 +} WMI_FIX_RATES_MASK;
22606 +typedef PREPACK struct {
22607 + A_UINT16 fixRateMask; /* see WMI_BIT_RATE */
22608 +} POSTPACK WMI_FIX_RATES_CMD, WMI_FIX_RATES_REPLY;
22611 + * WMI_SET_RECONNECT_AUTH_MODE_CMDID
22613 + * Set authentication mode
22616 + RECONN_DO_AUTH = 0x00,
22617 + RECONN_NOT_AUTH = 0x01
22620 +typedef PREPACK struct {
22622 +} POSTPACK WMI_SET_AUTH_MODE_CMD;
22625 + * WMI_SET_REASSOC_MODE_CMDID
22627 + * Set authentication mode
22630 + REASSOC_DO_DISASSOC = 0x00,
22631 + REASSOC_DONOT_DISASSOC = 0x01
22632 +} WMI_REASSOC_MODE;
22634 +typedef PREPACK struct {
22636 +}POSTPACK WMI_SET_REASSOC_MODE_CMD;
22639 + ROAM_DATA_TIME = 1, /* Get The Roam Time Data */
22642 +typedef PREPACK struct {
22643 + A_UINT32 disassoc_time;
22644 + A_UINT32 no_txrx_time;
22645 + A_UINT32 assoc_time;
22646 + A_UINT32 allow_txrx_time;
22647 + A_UINT32 last_data_txrx_time;
22648 + A_UINT32 first_data_txrx_time;
22649 + A_UINT8 disassoc_bssid[ATH_MAC_LEN];
22650 + A_INT8 disassoc_bss_rssi;
22651 + A_UINT8 assoc_bssid[ATH_MAC_LEN];
22652 + A_INT8 assoc_bss_rssi;
22653 +} POSTPACK WMI_TARGET_ROAM_TIME;
22655 +typedef PREPACK struct {
22657 + WMI_TARGET_ROAM_TIME roamTime;
22659 + A_UINT8 roamDataType ;
22660 +} POSTPACK WMI_TARGET_ROAM_DATA;
22663 + WMI_WMM_DISABLED = 0,
22667 +typedef PREPACK struct {
22669 +}POSTPACK WMI_SET_WMM_CMD;
22672 + WMI_TXOP_DISABLED = 0,
22676 +typedef PREPACK struct {
22677 + A_UINT8 txopEnable;
22678 +}POSTPACK WMI_SET_WMM_TXOP_CMD;
22680 +typedef PREPACK struct {
22681 + A_UINT8 keepaliveInterval;
22682 +} POSTPACK WMI_SET_KEEPALIVE_CMD;
22684 +typedef PREPACK struct {
22685 + A_BOOL configured;
22686 + A_UINT8 keepaliveInterval;
22687 +} POSTPACK WMI_GET_KEEPALIVE_CMD;
22690 + * Add Application specified IE to a management frame
22692 +#define WMI_MAX_IE_LEN 78
22694 +typedef PREPACK struct {
22695 + A_UINT8 mgmtFrmType; /* one of WMI_MGMT_FRAME_TYPE */
22696 + A_UINT8 ieLen; /* Length of the IE that should be added to the MGMT frame */
22697 + A_UINT8 ieInfo[1];
22698 +} POSTPACK WMI_SET_APPIE_CMD;
22701 + * Notify the WSC registration status to the target
22703 +#define WSC_REG_ACTIVE 1
22704 +#define WSC_REG_INACTIVE 0
22705 +/* Generic Hal Interface for setting hal paramters. */
22706 +/* Add new Set HAL Param cmdIds here for newer params */
22708 + WHAL_SETCABTO_CMDID = 1,
22711 +typedef PREPACK struct {
22712 + A_UINT8 cabTimeOut;
22713 +} POSTPACK WHAL_SETCABTO_PARAM;
22715 +typedef PREPACK struct {
22716 + A_UINT8 whalCmdId;
22718 +} POSTPACK WHAL_PARAMCMD;
22721 +#define WOW_MAX_FILTER_LISTS 1 /*4*/
22722 +#define WOW_MAX_FILTERS_PER_LIST 4
22723 +#define WOW_PATTERN_SIZE 64
22724 +#define WOW_MASK_SIZE 64
22726 +typedef PREPACK struct {
22727 + A_UINT8 wow_valid_filter;
22728 + A_UINT8 wow_filter_id;
22729 + A_UINT8 wow_filter_size;
22730 + A_UINT8 wow_filter_offset;
22731 + A_UINT8 wow_filter_mask[WOW_MASK_SIZE];
22732 + A_UINT8 wow_filter_pattern[WOW_PATTERN_SIZE];
22733 +} POSTPACK WOW_FILTER;
22736 +typedef PREPACK struct {
22737 + A_UINT8 wow_valid_list;
22738 + A_UINT8 wow_list_id;
22739 + A_UINT8 wow_num_filters;
22740 + A_UINT8 wow_total_list_size;
22741 + WOW_FILTER list[WOW_MAX_FILTERS_PER_LIST];
22742 +} POSTPACK WOW_FILTER_LIST;
22744 +typedef PREPACK struct {
22747 +} POSTPACK WMI_SET_HOST_SLEEP_MODE_CMD;
22749 +typedef PREPACK struct {
22750 + A_BOOL enable_wow;
22751 +} POSTPACK WMI_SET_WOW_MODE_CMD;
22753 +typedef PREPACK struct {
22754 + A_UINT8 filter_list_id;
22755 +} POSTPACK WMI_GET_WOW_LIST_CMD;
22758 + * WMI_GET_WOW_LIST_CMD reply
22760 +typedef PREPACK struct {
22761 + A_UINT8 num_filters; /* number of patterns in reply */
22762 + A_UINT8 this_filter_num; /* this is filter # x of total num_filters */
22763 + A_UINT8 wow_mode;
22764 + A_UINT8 host_mode;
22765 + WOW_FILTER wow_filters[1];
22766 +} POSTPACK WMI_GET_WOW_LIST_REPLY;
22768 +typedef PREPACK struct {
22769 + A_UINT8 filter_list_id;
22770 + A_UINT8 filter_size;
22771 + A_UINT8 filter_offset;
22772 + A_UINT8 filter[1];
22773 +} POSTPACK WMI_ADD_WOW_PATTERN_CMD;
22775 +typedef PREPACK struct {
22776 + A_UINT16 filter_list_id;
22777 + A_UINT16 filter_id;
22778 +} POSTPACK WMI_DEL_WOW_PATTERN_CMD;
22780 +typedef PREPACK struct {
22781 + A_UINT8 macaddr[ATH_MAC_LEN];
22782 +} POSTPACK WMI_SET_MAC_ADDRESS_CMD;
22785 + * WMI_SET_AKMP_PARAMS_CMD
22788 +#define WMI_AKMP_MULTI_PMKID_EN 0x000001
22790 +typedef PREPACK struct {
22791 + A_UINT32 akmpInfo;
22792 +} POSTPACK WMI_SET_AKMP_PARAMS_CMD;
22794 +typedef PREPACK struct {
22795 + A_UINT8 pmkid[WMI_PMKID_LEN];
22796 +} POSTPACK WMI_PMKID;
22799 + * WMI_SET_PMKID_LIST_CMD
22801 +#define WMI_MAX_PMKID_CACHE 8
22803 +typedef PREPACK struct {
22804 + A_UINT32 numPMKID;
22805 + WMI_PMKID pmkidList[WMI_MAX_PMKID_CACHE];
22806 +} POSTPACK WMI_SET_PMKID_LIST_CMD;
22809 + * WMI_GET_PMKID_LIST_CMD Reply
22810 + * Following the Number of PMKIDs is the list of PMKIDs
22812 +typedef PREPACK struct {
22813 + A_UINT32 numPMKID;
22814 + WMI_PMKID pmkidList[1];
22815 +} POSTPACK WMI_PMKID_LIST_REPLY;
22817 +/* index used for priority streams */
22819 + WMI_NOT_MAPPED = -1,
22820 + WMI_CONTROL_PRI = 0,
22821 + WMI_BEST_EFFORT_PRI = 1,
22823 + WMI_HIGH_PRI = 3,
22825 + WMI_PRI_MAX_COUNT
22826 +} WMI_PRI_STREAM_ID;
22828 +#ifndef ATH_TARGET
22829 +#include "athendpack.h"
22832 +#ifdef __cplusplus
22836 +#endif /* _WMI_H_ */
22837 diff --git a/drivers/sdio/function/wlan/ar6000/include/wmi_api.h b/drivers/sdio/function/wlan/ar6000/include/wmi_api.h
22838 new file mode 100644
22839 index 0000000..aa9a9c6
22841 +++ b/drivers/sdio/function/wlan/ar6000/include/wmi_api.h
22843 +#ifndef _WMI_API_H_
22844 +#define _WMI_API_H_
22846 + * Copyright (c) 2004-2006 Atheros Communications Inc.
22847 + * All rights reserved.
22849 + * This file contains the definitions for the Wireless Module Interface (WMI).
22851 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/wmi_api.h#2 $
22854 + * This program is free software; you can redistribute it and/or modify
22855 + * it under the terms of the GNU General Public License version 2 as
22856 + * published by the Free Software Foundation;
22858 + * Software distributed under the License is distributed on an "AS
22859 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
22860 + * implied. See the License for the specific language governing
22861 + * rights and limitations under the License.
22867 +#ifdef __cplusplus
22872 + * IP QoS Field definitions according to 802.1p
22874 +#define BEST_EFFORT_PRI 0
22875 +#define BACKGROUND_PRI 1
22876 +#define EXCELLENT_EFFORT_PRI 3
22877 +#define CONTROLLED_LOAD_PRI 4
22878 +#define VIDEO_PRI 5
22879 +#define VOICE_PRI 6
22880 +#define NETWORK_CONTROL_PRI 7
22881 +#define MAX_NUM_PRI 8
22883 +#define UNDEFINED_PRI (0xff)
22885 +/* simple mapping of IP TOS field to a WMI priority stream
22886 + * this mapping was taken from the original linux driver implementation
22887 + * The operation maps the following
22890 +#define IP_TOS_TO_WMI_PRI(tos) \
22891 + ((WMI_PRI_STREAM_ID)(((tos) >> 1) & 0x03))
22893 +#define WMI_IMPLICIT_PSTREAM_INACTIVITY_INT 5000 /* 5 seconds */
22898 +void *wmi_init(void *devt);
22900 +void wmi_qos_state_init(struct wmi_t *wmip);
22901 +void wmi_shutdown(struct wmi_t *wmip);
22902 +A_UINT16 wmi_get_mapped_qos_queue(struct wmi_t *, A_UINT8);
22903 +A_STATUS wmi_dix_2_dot3(struct wmi_t *wmip, void *osbuf);
22904 +A_STATUS wmi_data_hdr_add(struct wmi_t *wmip, void *osbuf, A_UINT8 msgType);
22905 +A_STATUS wmi_dot3_2_dix(struct wmi_t *wmip, void *osbuf);
22906 +A_STATUS wmi_data_hdr_remove(struct wmi_t *wmip, void *osbuf);
22907 +A_STATUS wmi_syncpoint(struct wmi_t *wmip);
22908 +A_STATUS wmi_syncpoint_reset(struct wmi_t *wmip);
22909 +WMI_PRI_STREAM_ID wmi_get_stream_id(struct wmi_t *wmip, A_UINT8 trafficClass);
22910 +A_UINT8 wmi_implicit_create_pstream(struct wmi_t *wmip, void *osbuf, A_UINT8 dir, A_UINT8 up);
22912 +A_STATUS wmi_control_rx(struct wmi_t *wmip, void *osbuf);
22913 +void wmi_iterate_nodes(struct wmi_t *wmip, wlan_node_iter_func *f, void *arg);
22914 +void wmi_free_allnodes(struct wmi_t *wmip);
22915 +bss_t *wmi_find_node(struct wmi_t *wmip, const A_UINT8 *macaddr);
22919 + NO_SYNC_WMIFLAG = 0,
22920 + SYNC_BEFORE_WMIFLAG, /* transmit all queued data before cmd */
22921 + SYNC_AFTER_WMIFLAG, /* any new data waits until cmd execs */
22922 + SYNC_BOTH_WMIFLAG,
22923 + END_WMIFLAG /* end marker */
22926 +A_STATUS wmi_cmd_send(struct wmi_t *wmip, void *osbuf, WMI_COMMAND_ID cmdId,
22927 + WMI_SYNC_FLAG flag);
22928 +A_STATUS wmi_connect_cmd(struct wmi_t *wmip,
22929 + NETWORK_TYPE netType,
22930 + DOT11_AUTH_MODE dot11AuthMode,
22931 + AUTH_MODE authMode,
22932 + CRYPTO_TYPE pairwiseCrypto,
22933 + A_UINT8 pairwiseCryptoLen,
22934 + CRYPTO_TYPE groupCrypto,
22935 + A_UINT8 groupCryptoLen,
22939 + A_UINT16 channel,
22940 + A_UINT32 ctrl_flags);
22941 +A_STATUS wmi_reconnect_cmd(struct wmi_t *wmip,
22943 + A_UINT16 channel);
22944 +A_STATUS wmi_disconnect_cmd(struct wmi_t *wmip);
22945 +A_STATUS wmi_getrev_cmd(struct wmi_t *wmip);
22946 +A_STATUS wmi_startscan_cmd(struct wmi_t *wmip, WMI_SCAN_TYPE scanType,
22947 + A_BOOL forceFgScan, A_BOOL isLegacy,
22948 + A_UINT32 homeDwellTime, A_UINT32 forceScanInterval);
22949 +A_STATUS wmi_scanparams_cmd(struct wmi_t *wmip, A_UINT16 fg_start_sec,
22950 + A_UINT16 fg_end_sec, A_UINT16 bg_sec,
22951 + A_UINT16 minact_chdw_msec,
22952 + A_UINT16 maxact_chdw_msec, A_UINT16 pas_chdw_msec,
22953 + A_UINT8 shScanRatio, A_UINT8 scanCtrlFlags,
22954 + A_UINT32 max_dfsch_act_time);
22955 +A_STATUS wmi_bssfilter_cmd(struct wmi_t *wmip, A_UINT8 filter, A_UINT32 ieMask);
22956 +A_STATUS wmi_probedSsid_cmd(struct wmi_t *wmip, A_UINT8 index, A_UINT8 flag,
22957 + A_UINT8 ssidLength, A_UCHAR *ssid);
22958 +A_STATUS wmi_listeninterval_cmd(struct wmi_t *wmip, A_UINT16 listenInterval, A_UINT16 listenBeacons);
22959 +A_STATUS wmi_bmisstime_cmd(struct wmi_t *wmip, A_UINT16 bmisstime, A_UINT16 bmissbeacons);
22960 +A_STATUS wmi_associnfo_cmd(struct wmi_t *wmip, A_UINT8 ieType,
22961 + A_UINT8 ieLen, A_UINT8 *ieInfo);
22962 +A_STATUS wmi_powermode_cmd(struct wmi_t *wmip, A_UINT8 powerMode);
22963 +A_STATUS wmi_ibsspmcaps_cmd(struct wmi_t *wmip, A_UINT8 pmEnable, A_UINT8 ttl,
22964 + A_UINT16 atim_windows, A_UINT16 timeout_value);
22965 +A_STATUS wmi_pmparams_cmd(struct wmi_t *wmip, A_UINT16 idlePeriod,
22966 + A_UINT16 psPollNum, A_UINT16 dtimPolicy);
22967 +A_STATUS wmi_disctimeout_cmd(struct wmi_t *wmip, A_UINT8 timeout);
22968 +A_STATUS wmi_sync_cmd(struct wmi_t *wmip, A_UINT8 syncNumber);
22969 +A_STATUS wmi_create_pstream_cmd(struct wmi_t *wmip, WMI_CREATE_PSTREAM_CMD *pstream);
22970 +A_STATUS wmi_delete_pstream_cmd(struct wmi_t *wmip, A_UINT8 trafficClass, A_UINT8 streamID);
22971 +A_STATUS wmi_set_bitrate_cmd(struct wmi_t *wmip, A_INT32 rate);
22972 +A_STATUS wmi_get_bitrate_cmd(struct wmi_t *wmip);
22973 +A_INT8 wmi_validate_bitrate(struct wmi_t *wmip, A_INT32 rate);
22974 +A_STATUS wmi_get_regDomain_cmd(struct wmi_t *wmip);
22975 +A_STATUS wmi_get_channelList_cmd(struct wmi_t *wmip);
22976 +A_STATUS wmi_set_channelParams_cmd(struct wmi_t *wmip, A_UINT8 scanParam,
22977 + WMI_PHY_MODE mode, A_INT8 numChan,
22978 + A_UINT16 *channelList);
22980 +A_STATUS wmi_set_snr_threshold_params(struct wmi_t *wmip,
22981 + WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd);
22982 +A_STATUS wmi_set_rssi_threshold_params(struct wmi_t *wmip,
22983 + WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd);
22984 +A_STATUS wmi_clr_rssi_snr(struct wmi_t *wmip);
22985 +A_STATUS wmi_set_lq_threshold_params(struct wmi_t *wmip,
22986 + WMI_LQ_THRESHOLD_PARAMS_CMD *lqCmd);
22987 +A_STATUS wmi_set_rts_cmd(struct wmi_t *wmip, A_UINT16 threshold);
22988 +A_STATUS wmi_set_lpreamble_cmd(struct wmi_t *wmip, A_UINT8 status);
22990 +A_STATUS wmi_set_error_report_bitmask(struct wmi_t *wmip, A_UINT32 bitmask);
22992 +A_STATUS wmi_get_challenge_resp_cmd(struct wmi_t *wmip, A_UINT32 cookie,
22993 + A_UINT32 source);
22994 +A_STATUS wmi_config_debug_module_cmd(struct wmi_t *wmip, A_UINT16 mmask,
22995 + A_UINT16 tsr, A_BOOL rep, A_UINT16 size,
22997 +A_STATUS wmi_get_stats_cmd(struct wmi_t *wmip);
22998 +A_STATUS wmi_addKey_cmd(struct wmi_t *wmip, A_UINT8 keyIndex,
22999 + CRYPTO_TYPE keyType, A_UINT8 keyUsage,
23000 + A_UINT8 keyLength,A_UINT8 *keyRSC,
23001 + A_UINT8 *keyMaterial, A_UINT8 key_op_ctrl,
23002 + WMI_SYNC_FLAG sync_flag);
23003 +A_STATUS wmi_add_krk_cmd(struct wmi_t *wmip, A_UINT8 *krk);
23004 +A_STATUS wmi_delete_krk_cmd(struct wmi_t *wmip);
23005 +A_STATUS wmi_deleteKey_cmd(struct wmi_t *wmip, A_UINT8 keyIndex);
23006 +A_STATUS wmi_set_akmp_params_cmd(struct wmi_t *wmip,
23007 + WMI_SET_AKMP_PARAMS_CMD *akmpParams);
23008 +A_STATUS wmi_get_pmkid_list_cmd(struct wmi_t *wmip);
23009 +A_STATUS wmi_set_pmkid_list_cmd(struct wmi_t *wmip,
23010 + WMI_SET_PMKID_LIST_CMD *pmkInfo);
23011 +A_STATUS wmi_set_txPwr_cmd(struct wmi_t *wmip, A_UINT8 dbM);
23012 +A_STATUS wmi_get_txPwr_cmd(struct wmi_t *wmip);
23013 +A_STATUS wmi_addBadAp_cmd(struct wmi_t *wmip, A_UINT8 apIndex, A_UINT8 *bssid);
23014 +A_STATUS wmi_deleteBadAp_cmd(struct wmi_t *wmip, A_UINT8 apIndex);
23015 +A_STATUS wmi_set_tkip_countermeasures_cmd(struct wmi_t *wmip, A_BOOL en);
23016 +A_STATUS wmi_setPmkid_cmd(struct wmi_t *wmip, A_UINT8 *bssid, A_UINT8 *pmkId,
23018 +A_STATUS wmi_set_access_params_cmd(struct wmi_t *wmip, A_UINT16 txop,
23019 + A_UINT8 eCWmin, A_UINT8 eCWmax,
23021 +A_STATUS wmi_set_retry_limits_cmd(struct wmi_t *wmip, A_UINT8 frameType,
23022 + A_UINT8 trafficClass, A_UINT8 maxRetries,
23023 + A_UINT8 enableNotify);
23025 +void wmi_get_current_bssid(struct wmi_t *wmip, A_UINT8 *bssid);
23027 +A_STATUS wmi_get_roam_tbl_cmd(struct wmi_t *wmip);
23028 +A_STATUS wmi_get_roam_data_cmd(struct wmi_t *wmip, A_UINT8 roamDataType);
23029 +A_STATUS wmi_set_roam_ctrl_cmd(struct wmi_t *wmip, WMI_SET_ROAM_CTRL_CMD *p,
23031 +A_STATUS wmi_set_powersave_timers_cmd(struct wmi_t *wmip,
23032 + WMI_POWERSAVE_TIMERS_POLICY_CMD *pCmd,
23035 +A_STATUS wmi_set_opt_mode_cmd(struct wmi_t *wmip, A_UINT8 optMode);
23036 +A_STATUS wmi_opt_tx_frame_cmd(struct wmi_t *wmip,
23038 + A_UINT8 *dstMacAddr,
23040 + A_UINT16 optIEDataLen,
23041 + A_UINT8 *optIEData);
23043 +A_STATUS wmi_set_adhoc_bconIntvl_cmd(struct wmi_t *wmip, A_UINT16 intvl);
23044 +A_STATUS wmi_set_voice_pkt_size_cmd(struct wmi_t *wmip, A_UINT16 voicePktSize);
23045 +A_STATUS wmi_set_max_sp_len_cmd(struct wmi_t *wmip, A_UINT8 maxSpLen);
23046 +A_UINT8 convert_userPriority_to_trafficClass(A_UINT8 userPriority);
23047 +A_UINT8 wmi_get_power_mode_cmd(struct wmi_t *wmip);
23048 +A_STATUS wmi_verify_tspec_params(WMI_CREATE_PSTREAM_CMD *pCmd, A_BOOL tspecCompliance);
23050 +#ifdef CONFIG_HOST_TCMD_SUPPORT
23051 +A_STATUS wmi_test_cmd(struct wmi_t *wmip, A_UINT8 *buf, A_UINT32 len);
23054 +A_STATUS wmi_set_bt_status_cmd(struct wmi_t *wmip, A_UINT8 streamType, A_UINT8 status);
23055 +A_STATUS wmi_set_bt_params_cmd(struct wmi_t *wmip, WMI_SET_BT_PARAMS_CMD* cmd);
23059 + * This function is used to configure the fix rates mask to the target.
23061 +A_STATUS wmi_set_fixrates_cmd(struct wmi_t *wmip, A_INT16 fixRatesMask);
23062 +A_STATUS wmi_get_ratemask_cmd(struct wmi_t *wmip);
23064 +A_STATUS wmi_set_authmode_cmd(struct wmi_t *wmip, A_UINT8 mode);
23066 +A_STATUS wmi_set_reassocmode_cmd(struct wmi_t *wmip, A_UINT8 mode);
23068 +A_STATUS wmi_set_wmm_cmd(struct wmi_t *wmip, WMI_WMM_STATUS status);
23069 +A_STATUS wmi_set_wmm_txop(struct wmi_t *wmip, WMI_TXOP_CFG txEnable);
23071 +A_STATUS wmi_get_keepalive_configured(struct wmi_t *wmip);
23072 +A_UINT8 wmi_get_keepalive_cmd(struct wmi_t *wmip);
23073 +A_STATUS wmi_set_keepalive_cmd(struct wmi_t *wmip, A_UINT8 keepaliveInterval);
23075 +A_STATUS wmi_set_appie_cmd(struct wmi_t *wmip, A_UINT8 mgmtFrmType,
23076 + A_UINT8 ieLen,A_UINT8 *ieInfo);
23078 +A_STATUS wmi_set_halparam_cmd(struct wmi_t *wmip, A_UINT8 *cmd, A_UINT16 dataLen);
23079 +A_INT32 wmi_get_rate(A_INT8 rateindex);
23081 +/*Wake on Wireless WMI commands*/
23082 +A_STATUS wmi_set_host_sleep_mode_cmd(struct wmi_t *wmip, WMI_SET_HOST_SLEEP_MODE_CMD *cmd);
23083 +A_STATUS wmi_set_wow_mode_cmd(struct wmi_t *wmip, WMI_SET_WOW_MODE_CMD *cmd);
23084 +A_STATUS wmi_get_wow_list_cmd(struct wmi_t *wmip, WMI_GET_WOW_LIST_CMD *cmd);
23085 +A_STATUS wmi_add_wow_pattern_cmd(struct wmi_t *wmip,
23086 + WMI_ADD_WOW_PATTERN_CMD *cmd, A_UINT8* pattern, A_UINT8* mask, A_UINT8 pattern_size);
23087 +A_STATUS wmi_del_wow_pattern_cmd(struct wmi_t *wmip,
23088 + WMI_DEL_WOW_PATTERN_CMD *cmd);
23089 +A_STATUS wmi_set_wsc_status_cmd(struct wmi_t *wmip, A_UINT32 status);
23092 +wmi_find_Ssidnode (struct wmi_t *wmip, A_UCHAR *pSsid,
23093 + A_UINT32 ssidLength, A_BOOL bIsWPA2);
23096 +wmi_node_return (struct wmi_t *wmip, bss_t *bss);
23097 +#ifdef __cplusplus
23101 +#endif /* _WMI_API_H_ */
23102 diff --git a/drivers/sdio/function/wlan/ar6000/include/wmix.h b/drivers/sdio/function/wlan/ar6000/include/wmix.h
23103 new file mode 100644
23104 index 0000000..8f12b5e
23106 +++ b/drivers/sdio/function/wlan/ar6000/include/wmix.h
23109 + * Copyright (c) 2004-2005 Atheros Communications Inc.
23110 + * All rights reserved.
23113 + * $ATH_LICENSE_HOSTSDK0_C$
23115 + * This file contains extensions of the WMI protocol specified in the
23116 + * Wireless Module Interface (WMI). It includes definitions of all
23117 + * extended commands and events. Extensions include useful commands
23118 + * that are not directly related to wireless activities. They may
23119 + * be hardware-specific, and they might not be supported on all
23120 + * implementations.
23122 + * Extended WMIX commands are encapsulated in a WMI message with
23123 + * cmd=WMI_EXTENSION_CMD.
23130 +#ifdef __cplusplus
23134 +#ifndef ATH_TARGET
23135 +#include "athstartpack.h"
23138 +#include "dbglog.h"
23141 + * Extended WMI commands are those that are needed during wireless
23142 + * operation, but which are not really wireless commands. This allows,
23143 + * for instance, platform-specific commands. Extended WMI commands are
23144 + * embedded in a WMI command message with WMI_COMMAND_ID=WMI_EXTENSION_CMDID.
23145 + * Extended WMI events are similarly embedded in a WMI event message with
23146 + * WMI_EVENT_ID=WMI_EXTENSION_EVENTID.
23148 +typedef PREPACK struct {
23149 + A_UINT32 commandId;
23150 +} POSTPACK WMIX_CMD_HDR;
23153 + WMIX_DSETOPEN_REPLY_CMDID = 0x2001,
23154 + WMIX_DSETDATA_REPLY_CMDID,
23155 + WMIX_GPIO_OUTPUT_SET_CMDID,
23156 + WMIX_GPIO_INPUT_GET_CMDID,
23157 + WMIX_GPIO_REGISTER_SET_CMDID,
23158 + WMIX_GPIO_REGISTER_GET_CMDID,
23159 + WMIX_GPIO_INTR_ACK_CMDID,
23160 + WMIX_HB_CHALLENGE_RESP_CMDID,
23161 + WMIX_DBGLOG_CFG_MODULE_CMDID,
23162 +} WMIX_COMMAND_ID;
23165 + WMIX_DSETOPENREQ_EVENTID = 0x3001,
23166 + WMIX_DSETCLOSE_EVENTID,
23167 + WMIX_DSETDATAREQ_EVENTID,
23168 + WMIX_GPIO_INTR_EVENTID,
23169 + WMIX_GPIO_DATA_EVENTID,
23170 + WMIX_GPIO_ACK_EVENTID,
23171 + WMIX_HB_CHALLENGE_RESP_EVENTID,
23172 + WMIX_DBGLOG_EVENTID,
23176 + * =============DataSet support=================
23180 + * WMIX_DSETOPENREQ_EVENTID
23181 + * DataSet Open Request Event
23183 +typedef PREPACK struct {
23184 + A_UINT32 dset_id;
23185 + A_UINT32 targ_dset_handle; /* echo'ed, not used by Host, */
23186 + A_UINT32 targ_reply_fn; /* echo'ed, not used by Host, */
23187 + A_UINT32 targ_reply_arg; /* echo'ed, not used by Host, */
23188 +} POSTPACK WMIX_DSETOPENREQ_EVENT;
23191 + * WMIX_DSETCLOSE_EVENTID
23192 + * DataSet Close Event
23194 +typedef PREPACK struct {
23195 + A_UINT32 access_cookie;
23196 +} POSTPACK WMIX_DSETCLOSE_EVENT;
23199 + * WMIX_DSETDATAREQ_EVENTID
23200 + * DataSet Data Request Event
23202 +typedef PREPACK struct {
23203 + A_UINT32 access_cookie;
23206 + A_UINT32 targ_buf; /* echo'ed, not used by Host, */
23207 + A_UINT32 targ_reply_fn; /* echo'ed, not used by Host, */
23208 + A_UINT32 targ_reply_arg; /* echo'ed, not used by Host, */
23209 +} POSTPACK WMIX_DSETDATAREQ_EVENT;
23211 +typedef PREPACK struct {
23213 + A_UINT32 targ_dset_handle;
23214 + A_UINT32 targ_reply_fn;
23215 + A_UINT32 targ_reply_arg;
23216 + A_UINT32 access_cookie;
23218 + A_UINT32 version;
23219 +} POSTPACK WMIX_DSETOPEN_REPLY_CMD;
23221 +typedef PREPACK struct {
23223 + A_UINT32 targ_buf;
23224 + A_UINT32 targ_reply_fn;
23225 + A_UINT32 targ_reply_arg;
23228 +} POSTPACK WMIX_DSETDATA_REPLY_CMD;
23232 + * =============GPIO support=================
23233 + * All masks are 18-bit masks with bit N operating on GPIO pin N.
23239 + * Set GPIO pin output state.
23240 + * In order for output to be driven, a pin must be enabled for output.
23241 + * This can be done during initialization through the GPIO Configuration
23242 + * DataSet, or during operation with the enable_mask.
23244 + * If a request is made to simultaneously set/clear or set/disable or
23245 + * clear/disable or disable/enable, results are undefined.
23247 +typedef PREPACK struct {
23248 + A_UINT32 set_mask; /* pins to set */
23249 + A_UINT32 clear_mask; /* pins to clear */
23250 + A_UINT32 enable_mask; /* pins to enable for output */
23251 + A_UINT32 disable_mask; /* pins to disable/tristate */
23252 +} POSTPACK WMIX_GPIO_OUTPUT_SET_CMD;
23255 + * Set a GPIO register. For debug/exceptional cases.
23256 + * Values for gpioreg_id are GPIO_REGISTER_IDs, defined in a
23257 + * platform-dependent header.
23259 +typedef PREPACK struct {
23260 + A_UINT32 gpioreg_id; /* GPIO register ID */
23261 + A_UINT32 value; /* value to write */
23262 +} POSTPACK WMIX_GPIO_REGISTER_SET_CMD;
23264 +/* Get a GPIO register. For debug/exceptional cases. */
23265 +typedef PREPACK struct {
23266 + A_UINT32 gpioreg_id; /* GPIO register to read */
23267 +} POSTPACK WMIX_GPIO_REGISTER_GET_CMD;
23270 + * Host acknowledges and re-arms GPIO interrupts. A single
23271 + * message should be used to acknowledge all interrupts that
23272 + * were delivered in an earlier WMIX_GPIO_INTR_EVENT message.
23274 +typedef PREPACK struct {
23275 + A_UINT32 ack_mask; /* interrupts to acknowledge */
23276 +} POSTPACK WMIX_GPIO_INTR_ACK_CMD;
23279 + * Target informs Host of GPIO interrupts that have ocurred since the
23280 + * last WMIX_GIPO_INTR_ACK_CMD was received. Additional information --
23281 + * the current GPIO input values is provided -- in order to support
23282 + * use of a GPIO interrupt as a Data Valid signal for other GPIO pins.
23284 +typedef PREPACK struct {
23285 + A_UINT32 intr_mask; /* pending GPIO interrupts */
23286 + A_UINT32 input_values; /* recent GPIO input values */
23287 +} POSTPACK WMIX_GPIO_INTR_EVENT;
23290 + * Target responds to Host's earlier WMIX_GPIO_INPUT_GET_CMDID request
23291 + * using a GPIO_DATA_EVENT with
23292 + * value set to the mask of GPIO pin inputs and
23293 + * reg_id set to GPIO_ID_NONE
23296 + * Target responds to Hosts's earlier WMIX_GPIO_REGISTER_GET_CMDID request
23297 + * using a GPIO_DATA_EVENT with
23298 + * value set to the value of the requested register and
23299 + * reg_id identifying the register (reflects the original request)
23300 + * NB: reg_id supports the future possibility of unsolicited
23301 + * WMIX_GPIO_DATA_EVENTs (for polling GPIO input), and it may
23302 + * simplify Host GPIO support.
23304 +typedef PREPACK struct {
23307 +} POSTPACK WMIX_GPIO_DATA_EVENT;
23310 + * =============Error Detection support=================
23314 + * WMIX_HB_CHALLENGE_RESP_CMDID
23315 + * Heartbeat Challenge Response command
23317 +typedef PREPACK struct {
23320 +} POSTPACK WMIX_HB_CHALLENGE_RESP_CMD;
23323 + * WMIX_HB_CHALLENGE_RESP_EVENTID
23324 + * Heartbeat Challenge Response Event
23326 +#define WMIX_HB_CHALLENGE_RESP_EVENT WMIX_HB_CHALLENGE_RESP_CMD
23328 +typedef PREPACK struct {
23329 + struct dbglog_config_s config;
23330 +} POSTPACK WMIX_DBGLOG_CFG_MODULE_CMD;
23332 +#ifndef ATH_TARGET
23333 +#include "athendpack.h"
23336 +#ifdef __cplusplus
23340 +#endif /* _WMIX_H_ */
23341 diff --git a/drivers/sdio/function/wlan/ar6000/miscdrv/common_drv.c b/drivers/sdio/function/wlan/ar6000/miscdrv/common_drv.c
23342 new file mode 100644
23343 index 0000000..2b0dfd3
23345 +++ b/drivers/sdio/function/wlan/ar6000/miscdrv/common_drv.c
23350 + * Copyright (c) 2004-2007 Atheros Communications Inc.
23351 + * All rights reserved.
23354 + * This program is free software; you can redistribute it and/or modify
23355 + * it under the terms of the GNU General Public License version 2 as
23356 + * published by the Free Software Foundation;
23358 + * Software distributed under the License is distributed on an "AS
23359 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
23360 + * implied. See the License for the specific language governing
23361 + * rights and limitations under the License.
23367 +#include "a_config.h"
23368 +#include "athdefs.h"
23369 +#include "a_types.h"
23370 +#include "AR6Khwreg.h"
23371 +#include "targaddrs.h"
23372 +#include "a_osapi.h"
23374 +#include "htc_api.h"
23376 +#include "bmi_msg.h"
23377 +#include "common_drv.h"
23378 +#include "a_debug.h"
23379 +#include "targaddrs.h"
23381 +#define HOST_INTEREST_ITEM_ADDRESS(target, item) \
23382 +(((TargetType) == TARGET_TYPE_AR6001) ? \
23383 + AR6001_HOST_INTEREST_ITEM_ADDRESS(item) : \
23384 + AR6002_HOST_INTEREST_ITEM_ADDRESS(item))
23387 +/* Compile the 4BYTE version of the window register setup routine,
23388 + * This mitigates host interconnect issues with non-4byte aligned bus requests, some
23389 + * interconnects use bus adapters that impose strict limitations.
23390 + * Since diag window access is not intended for performance critical operations, the 4byte mode should
23391 + * be satisfactory even though it generates 4X the bus activity. */
23393 +#ifdef USE_4BYTE_REGISTER_ACCESS
23395 + /* set the window address register (using 4-byte register access ). */
23396 +A_STATUS ar6000_SetAddressWindowRegister(HIF_DEVICE *hifDevice, A_UINT32 RegisterAddr, A_UINT32 Address)
23399 + A_UINT8 addrValue[4];
23402 + /* write bytes 1,2,3 of the register to set the upper address bytes, the LSB is written
23403 + * last to initiate the access cycle */
23405 + for (i = 1; i <= 3; i++) {
23406 + /* fill the buffer with the address byte value we want to hit 4 times*/
23407 + addrValue[0] = ((A_UINT8 *)&Address)[i];
23408 + addrValue[1] = addrValue[0];
23409 + addrValue[2] = addrValue[0];
23410 + addrValue[3] = addrValue[0];
23412 + /* hit each byte of the register address with a 4-byte write operation to the same address,
23413 + * this is a harmless operation */
23414 + status = HIFReadWrite(hifDevice,
23418 + HIF_WR_SYNC_BYTE_FIX,
23420 + if (status != A_OK) {
23425 + if (status != A_OK) {
23426 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write initial bytes of 0x%x to window reg: 0x%X \n",
23427 + RegisterAddr, Address));
23431 + /* write the address register again, this time write the whole 4-byte value.
23432 + * The effect here is that the LSB write causes the cycle to start, the extra
23433 + * 3 byte write to bytes 1,2,3 has no effect since we are writing the same values again */
23434 + status = HIFReadWrite(hifDevice,
23436 + (A_UCHAR *)(&Address),
23438 + HIF_WR_SYNC_BYTE_INC,
23441 + if (status != A_OK) {
23442 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write 0x%x to window reg: 0x%X \n",
23443 + RegisterAddr, Address));
23456 + /* set the window address register */
23457 +A_STATUS ar6000_SetAddressWindowRegister(HIF_DEVICE *hifDevice, A_UINT32 RegisterAddr, A_UINT32 Address)
23461 + /* write bytes 1,2,3 of the register to set the upper address bytes, the LSB is written
23462 + * last to initiate the access cycle */
23463 + status = HIFReadWrite(hifDevice,
23464 + RegisterAddr+1, /* write upper 3 bytes */
23465 + ((A_UCHAR *)(&Address))+1,
23466 + sizeof(A_UINT32)-1,
23467 + HIF_WR_SYNC_BYTE_INC,
23470 + if (status != A_OK) {
23471 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write initial bytes of 0x%x to window reg: 0x%X \n",
23472 + RegisterAddr, Address));
23476 + /* write the LSB of the register, this initiates the operation */
23477 + status = HIFReadWrite(hifDevice,
23479 + (A_UCHAR *)(&Address),
23481 + HIF_WR_SYNC_BYTE_INC,
23484 + if (status != A_OK) {
23485 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write 0x%x to window reg: 0x%X \n",
23486 + RegisterAddr, Address));
23496 + * Read from the AR6000 through its diagnostic window.
23497 + * No cooperation from the Target is required for this.
23500 +ar6000_ReadRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data)
23504 + /* set window register to start read cycle */
23505 + status = ar6000_SetAddressWindowRegister(hifDevice,
23506 + WINDOW_READ_ADDR_ADDRESS,
23509 + if (status != A_OK) {
23513 + /* read the data */
23514 + status = HIFReadWrite(hifDevice,
23515 + WINDOW_DATA_ADDRESS,
23517 + sizeof(A_UINT32),
23518 + HIF_RD_SYNC_BYTE_INC,
23520 + if (status != A_OK) {
23521 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot read from WINDOW_DATA_ADDRESS\n"));
23530 + * Write to the AR6000 through its diagnostic window.
23531 + * No cooperation from the Target is required for this.
23534 +ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data)
23538 + /* set write data */
23539 + status = HIFReadWrite(hifDevice,
23540 + WINDOW_DATA_ADDRESS,
23542 + sizeof(A_UINT32),
23543 + HIF_WR_SYNC_BYTE_INC,
23545 + if (status != A_OK) {
23546 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write 0x%x to WINDOW_DATA_ADDRESS\n", *data));
23550 + /* set window register, which starts the write cycle */
23551 + return ar6000_SetAddressWindowRegister(hifDevice,
23552 + WINDOW_WRITE_ADDR_ADDRESS,
23557 +ar6000_ReadDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address,
23558 + A_UCHAR *data, A_UINT32 length)
23561 + A_STATUS status = A_OK;
23563 + for (count = 0; count < length; count += 4, address += 4) {
23564 + if ((status = ar6000_ReadRegDiag(hifDevice, &address,
23565 + (A_UINT32 *)&data[count])) != A_OK)
23575 +ar6000_WriteDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address,
23576 + A_UCHAR *data, A_UINT32 length)
23579 + A_STATUS status = A_OK;
23581 + for (count = 0; count < length; count += 4, address += 4) {
23582 + if ((status = ar6000_WriteRegDiag(hifDevice, &address,
23583 + (A_UINT32 *)&data[count])) != A_OK)
23593 +ar6000_reset_device_skipflash(HIF_DEVICE *hifDevice)
23596 + struct forceROM_s {
23600 + struct forceROM_s *ForceROM;
23602 + A_UINT32 instruction;
23604 + static struct forceROM_s ForceROM_REV2[] = {
23605 + /* NB: This works for old REV2 ROM (old). */
23606 + {0x00001ff0, 0x175b0027}, /* jump instruction at 0xa0001ff0 */
23607 + {0x00001ff4, 0x00000000}, /* nop instruction at 0xa0001ff4 */
23609 + {MC_REMAP_TARGET_ADDRESS, 0x00001ff0}, /* remap to 0xa0001ff0 */
23610 + {MC_REMAP_COMPARE_ADDRESS, 0x01000040},/* ...from 0xbfc00040 */
23611 + {MC_REMAP_SIZE_ADDRESS, 0x00000000}, /* ...1 cache line */
23612 + {MC_REMAP_VALID_ADDRESS, 0x00000001}, /* ...remap is valid */
23614 + {LOCAL_COUNT_ADDRESS+0x10, 0}, /* clear BMI credit counter */
23616 + {RESET_CONTROL_ADDRESS, RESET_CONTROL_WARM_RST_MASK},
23619 + static struct forceROM_s ForceROM_NEW[] = {
23620 + /* NB: This works for AR6000 ROM REV3 and beyond. */
23621 + {LOCAL_SCRATCH_ADDRESS, AR6K_OPTION_IGNORE_FLASH},
23622 + {LOCAL_COUNT_ADDRESS+0x10, 0}, /* clear BMI credit counter */
23623 + {RESET_CONTROL_ADDRESS, RESET_CONTROL_WARM_RST_MASK},
23627 + * Examine a semi-arbitrary instruction that's different
23628 + * in REV2 and other revisions.
23629 + * NB: If a Host port does not require simultaneous support
23630 + * for multiple revisions of Target ROM, this code can be elided.
23632 + (void)ar6000_ReadDataDiag(hifDevice, 0x01000040,
23633 + (A_UCHAR *)&instruction, 4);
23635 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("instruction=0x%x\n", instruction));
23637 + if (instruction == 0x3c1aa200) {
23638 + /* It's an old ROM */
23639 + ForceROM = ForceROM_REV2;
23640 + szForceROM = sizeof(ForceROM_REV2)/sizeof(*ForceROM);
23641 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Using OLD method\n"));
23643 + ForceROM = ForceROM_NEW;
23644 + szForceROM = sizeof(ForceROM_NEW)/sizeof(*ForceROM);
23645 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Using NEW method\n"));
23648 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Force Target to execute from ROM....\n"));
23649 + for (i = 0; i < szForceROM; i++)
23651 + if (ar6000_WriteRegDiag(hifDevice,
23652 + &ForceROM[i].addr,
23653 + &ForceROM[i].data) != A_OK)
23655 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot force Target to execute ROM!\n"));
23660 + A_MDELAY(50); /* delay to allow dragon to come to BMI phase */
23664 +/* reset device */
23665 +A_STATUS ar6000_reset_device(HIF_DEVICE *hifDevice, A_UINT32 TargetType)
23668 +#if !defined(DWSIM)
23669 + A_STATUS status = A_OK;
23670 + A_UINT32 address;
23675 + // address = RESET_CONTROL_ADDRESS;
23676 + data = RESET_CONTROL_COLD_RST_MASK;
23678 + /* Hardcode the address of RESET_CONTROL_ADDRESS based on the target type */
23679 + if (TargetType == TARGET_TYPE_AR6001) {
23680 + address = 0x0C000000;
23682 + if (TargetType == TARGET_TYPE_AR6002) {
23683 + address = 0x00004000;
23689 + status = ar6000_WriteRegDiag(hifDevice, &address, &data);
23691 + if (A_FAILED(status)) {
23696 + * Read back the RESET CAUSE register to ensure that the cold reset
23699 + A_MDELAY(2000); /* 2 second delay to allow things to settle down */
23702 + // address = RESET_CAUSE_ADDRESS;
23703 + /* Hardcode the address of RESET_CAUSE_ADDRESS based on the target type */
23704 + if (TargetType == TARGET_TYPE_AR6001) {
23705 + address = 0x0C0000CC;
23707 + if (TargetType == TARGET_TYPE_AR6002) {
23708 + address = 0x000040C0;
23715 + status = ar6000_ReadRegDiag(hifDevice, &address, &data);
23717 + if (A_FAILED(status)) {
23721 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Reset Cause readback: 0x%X \n",data));
23722 + data &= RESET_CAUSE_LAST_MASK;
23724 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Unable to cold reset the target \n"));
23729 + if (A_FAILED(status)) {
23730 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Failed to reset target \n"));
23736 +#define REG_DUMP_COUNT_AR6001 38 /* WORDs, derived from AR6001_regdump.h */
23737 +#define REG_DUMP_COUNT_AR6002 32 /* WORDs, derived from AR6002_regdump.h */
23740 +#if REG_DUMP_COUNT_AR6001 <= REG_DUMP_COUNT_AR6002
23741 +#define REGISTER_DUMP_LEN_MAX REG_DUMP_COUNT_AR6002
23743 +#define REGISTER_DUMP_LEN_MAX REG_DUMP_COUNT_AR6001
23746 +void ar6000_dump_target_assert_info(HIF_DEVICE *hifDevice, A_UINT32 TargetType)
23748 + A_UINT32 address;
23749 + A_UINT32 regDumpArea = 0;
23751 + A_UINT32 regDumpValues[REGISTER_DUMP_LEN_MAX];
23752 + A_UINT32 regDumpCount = 0;
23757 + /* the reg dump pointer is copied to the host interest area */
23758 + address = HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_failure_state);
23760 + if (TargetType == TARGET_TYPE_AR6001) {
23761 + /* for AR6001, this is a fixed location because the ptr is actually stuck in cache,
23762 + * this may be fixed in later firmware versions */
23763 + address = 0x18a0;
23764 + regDumpCount = REG_DUMP_COUNT_AR6001;
23766 + } else if (TargetType == TARGET_TYPE_AR6002) {
23768 + regDumpCount = REG_DUMP_COUNT_AR6002;
23774 + /* read RAM location through diagnostic window */
23775 + status = ar6000_ReadRegDiag(hifDevice, &address, ®DumpArea);
23777 + if (A_FAILED(status)) {
23778 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Failed to get ptr to register dump area \n"));
23782 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Location of register dump data: 0x%X \n",regDumpArea));
23784 + if (regDumpArea == 0) {
23785 + /* no reg dump */
23789 + if (TargetType == TARGET_TYPE_AR6001) {
23790 + regDumpArea &= 0x0FFFFFFF; /* convert to physical address in target memory */
23793 + /* fetch register dump data */
23794 + status = ar6000_ReadDataDiag(hifDevice,
23796 + (A_UCHAR *)®DumpValues[0],
23797 + regDumpCount * (sizeof(A_UINT32)));
23799 + if (A_FAILED(status)) {
23800 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Failed to get register dump \n"));
23804 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Register Dump: \n"));
23806 + for (i = 0; i < regDumpCount; i++) {
23807 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" %d : 0x%8.8X \n",i, regDumpValues[i]));
23814 diff --git a/drivers/sdio/function/wlan/ar6000/miscdrv/credit_dist.c b/drivers/sdio/function/wlan/ar6000/miscdrv/credit_dist.c
23815 new file mode 100644
23816 index 0000000..8d37d62
23818 +++ b/drivers/sdio/function/wlan/ar6000/miscdrv/credit_dist.c
23823 + * Copyright (c) 2004-2007 Atheros Communications Inc.
23824 + * All rights reserved.
23827 + * This program is free software; you can redistribute it and/or modify
23828 + * it under the terms of the GNU General Public License version 2 as
23829 + * published by the Free Software Foundation;
23831 + * Software distributed under the License is distributed on an "AS
23832 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
23833 + * implied. See the License for the specific language governing
23834 + * rights and limitations under the License.
23840 +#include "a_config.h"
23841 +#include "athdefs.h"
23842 +#include "a_types.h"
23843 +#include "a_osapi.h"
23844 +#include "a_debug.h"
23845 +#include "htc_api.h"
23846 +#include "common_drv.h"
23848 +/********* CREDIT DISTRIBUTION FUNCTIONS ******************************************/
23850 +#define NO_VO_SERVICE 1 /* currently WMI only uses 3 data streams, so we leave VO service inactive */
23852 +#ifdef NO_VO_SERVICE
23853 +#define DATA_SVCS_USED 3
23855 +#define DATA_SVCS_USED 4
23858 +static void RedistributeCredits(COMMON_CREDIT_STATE_INFO *pCredInfo,
23859 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList);
23861 +static void SeekCredits(COMMON_CREDIT_STATE_INFO *pCredInfo,
23862 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList);
23864 +/* reduce an ep's credits back to a set limit */
23865 +static INLINE void ReduceCredits(COMMON_CREDIT_STATE_INFO *pCredInfo,
23866 + HTC_ENDPOINT_CREDIT_DIST *pEpDist,
23871 + /* set the new limit */
23872 + pEpDist->TxCreditsAssigned = Limit;
23874 + if (pEpDist->TxCredits <= Limit) {
23878 + /* figure out how much to take away */
23879 + credits = pEpDist->TxCredits - Limit;
23880 + /* take them away */
23881 + pEpDist->TxCredits -= credits;
23882 + pCredInfo->CurrentFreeCredits += credits;
23885 +/* give an endpoint some credits from the free credit pool */
23886 +#define GiveCredits(pCredInfo,pEpDist,credits) \
23888 + (pEpDist)->TxCredits += (credits); \
23889 + (pEpDist)->TxCreditsAssigned += (credits); \
23890 + (pCredInfo)->CurrentFreeCredits -= (credits); \
23894 +/* default credit init callback.
23895 + * This function is called in the context of HTCStart() to setup initial (application-specific)
23896 + * credit distributions */
23897 +static void ar6000_credit_init(void *Context,
23898 + HTC_ENDPOINT_CREDIT_DIST *pEPList,
23899 + int TotalCredits)
23901 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
23903 + COMMON_CREDIT_STATE_INFO *pCredInfo = (COMMON_CREDIT_STATE_INFO *)Context;
23905 + pCredInfo->CurrentFreeCredits = TotalCredits;
23906 + pCredInfo->TotalAvailableCredits = TotalCredits;
23908 + pCurEpDist = pEPList;
23910 + /* run through the list and initialize */
23911 + while (pCurEpDist != NULL) {
23913 + /* set minimums for each endpoint */
23914 + pCurEpDist->TxCreditsMin = pCurEpDist->TxCreditsPerMaxMsg;
23916 + if (pCurEpDist->ServiceID == WMI_CONTROL_SVC) {
23917 + /* give control service some credits */
23918 + GiveCredits(pCredInfo,pCurEpDist,pCurEpDist->TxCreditsMin);
23919 + /* control service is always marked active, it never goes inactive EVER */
23920 + SET_EP_ACTIVE(pCurEpDist);
23921 + } else if (pCurEpDist->ServiceID == WMI_DATA_BK_SVC) {
23922 + /* this is the lowest priority data endpoint, save this off for easy access */
23923 + pCredInfo->pLowestPriEpDist = pCurEpDist;
23926 + /* Streams have to be created (explicit | implicit)for all kinds
23927 + * of traffic. BE endpoints are also inactive in the beginning.
23928 + * When BE traffic starts it creates implicit streams that
23929 + * redistributes credits.
23932 + /* note, all other endpoints have minimums set but are initially given NO credits.
23933 + * Credits will be distributed as traffic activity demands */
23934 + pCurEpDist = pCurEpDist->pNext;
23937 + if (pCredInfo->CurrentFreeCredits <= 0) {
23938 + AR_DEBUG_PRINTF(ATH_LOG_INF, ("Not enough credits (%d) to do credit distributions \n", TotalCredits));
23944 + pCurEpDist = pEPList;
23945 + /* now run through the list and set max operating credit limits for everyone */
23946 + while (pCurEpDist != NULL) {
23947 + if (pCurEpDist->ServiceID == WMI_CONTROL_SVC) {
23948 + /* control service max is just 1 max message */
23949 + pCurEpDist->TxCreditsNorm = pCurEpDist->TxCreditsPerMaxMsg;
23951 + /* for the remaining data endpoints, we assume that each TxCreditsPerMaxMsg are
23953 + * We use a simple calculation here, we take the remaining credits and
23954 + * determine how many max messages this can cover and then set each endpoint's
23955 + * normal value equal to half this amount.
23957 + count = (pCredInfo->CurrentFreeCredits/pCurEpDist->TxCreditsPerMaxMsg) * pCurEpDist->TxCreditsPerMaxMsg;
23958 + count = count >> 1;
23959 + count = max(count,pCurEpDist->TxCreditsPerMaxMsg);
23961 + pCurEpDist->TxCreditsNorm = count;
23964 + pCurEpDist = pCurEpDist->pNext;
23970 +/* default credit distribution callback
23971 + * This callback is invoked whenever endpoints require credit distributions.
23972 + * A lock is held while this function is invoked, this function shall NOT block.
23973 + * The pEPDistList is a list of distribution structures in prioritized order as
23974 + * defined by the call to the HTCSetCreditDistribution() api.
23977 +static void ar6000_credit_distribute(void *Context,
23978 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList,
23979 + HTC_CREDIT_DIST_REASON Reason)
23981 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
23982 + COMMON_CREDIT_STATE_INFO *pCredInfo = (COMMON_CREDIT_STATE_INFO *)Context;
23984 + switch (Reason) {
23985 + case HTC_CREDIT_DIST_SEND_COMPLETE :
23986 + pCurEpDist = pEPDistList;
23987 + /* we are given the start of the endpoint distribution list.
23988 + * There may be one or more endpoints to service.
23989 + * Run through the list and distribute credits */
23990 + while (pCurEpDist != NULL) {
23992 + if (pCurEpDist->TxCreditsToDist > 0) {
23993 + /* return the credits back to the endpoint */
23994 + pCurEpDist->TxCredits += pCurEpDist->TxCreditsToDist;
23995 + /* always zero out when we are done */
23996 + pCurEpDist->TxCreditsToDist = 0;
23998 + if (pCurEpDist->TxCredits > pCurEpDist->TxCreditsAssigned) {
23999 + /* reduce to the assigned limit, previous credit reductions
24000 + * could have caused the limit to change */
24001 + ReduceCredits(pCredInfo, pCurEpDist, pCurEpDist->TxCreditsAssigned);
24004 + if (pCurEpDist->TxCredits > pCurEpDist->TxCreditsNorm) {
24005 + /* oversubscribed endpoints need to reduce back to normal */
24006 + ReduceCredits(pCredInfo, pCurEpDist, pCurEpDist->TxCreditsNorm);
24010 + pCurEpDist = pCurEpDist->pNext;
24013 + A_ASSERT(pCredInfo->CurrentFreeCredits <= pCredInfo->TotalAvailableCredits);
24017 + case HTC_CREDIT_DIST_ACTIVITY_CHANGE :
24018 + RedistributeCredits(pCredInfo,pEPDistList);
24020 + case HTC_CREDIT_DIST_SEEK_CREDITS :
24021 + SeekCredits(pCredInfo,pEPDistList);
24023 + case HTC_DUMP_CREDIT_STATE :
24024 + AR_DEBUG_PRINTF(ATH_LOG_INF, ("Credit Distribution, total : %d, free : %d\n",
24025 + pCredInfo->TotalAvailableCredits, pCredInfo->CurrentFreeCredits));
24034 +/* redistribute credits based on activity change */
24035 +static void RedistributeCredits(COMMON_CREDIT_STATE_INFO *pCredInfo,
24036 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList)
24038 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist = pEPDistList;
24040 + /* walk through the list and remove credits from inactive endpoints */
24041 + while (pCurEpDist != NULL) {
24043 + if (pCurEpDist->ServiceID != WMI_CONTROL_SVC) {
24044 + if (!IS_EP_ACTIVE(pCurEpDist)) {
24045 + /* EP is inactive, reduce credits back to zero */
24046 + ReduceCredits(pCredInfo, pCurEpDist, 0);
24050 + /* NOTE in the active case, we do not need to do anything further,
24051 + * when an EP goes active and needs credits, HTC will call into
24052 + * our distribution function using a reason code of HTC_CREDIT_DIST_SEEK_CREDITS */
24054 + pCurEpDist = pCurEpDist->pNext;
24057 + A_ASSERT(pCredInfo->CurrentFreeCredits <= pCredInfo->TotalAvailableCredits);
24061 +/* HTC has an endpoint that needs credits, pEPDist is the endpoint in question */
24062 +static void SeekCredits(COMMON_CREDIT_STATE_INFO *pCredInfo,
24063 + HTC_ENDPOINT_CREDIT_DIST *pEPDist)
24065 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
24071 + if (pEPDist->ServiceID == WMI_CONTROL_SVC) {
24072 + /* we never oversubscribe on the control service, this is not
24073 + * a high performance path and the target never holds onto control
24074 + * credits for too long */
24078 + /* for all other services, we follow a simple algorithm of
24079 + * 1. checking the free pool for credits
24080 + * 2. checking lower priority endpoints for credits to take */
24082 + if (pCredInfo->CurrentFreeCredits >= 2 * pEPDist->TxCreditsSeek) {
24083 + /* try to give more credits than it needs */
24084 + credits = 2 * pEPDist->TxCreditsSeek;
24086 + /* give what we can */
24087 + credits = min(pCredInfo->CurrentFreeCredits,pEPDist->TxCreditsSeek);
24090 + if (credits >= pEPDist->TxCreditsSeek) {
24091 + /* we found some to fullfill the seek request */
24095 + /* we don't have enough in the free pool, try taking away from lower priority services
24097 + * The rule for taking away credits:
24098 + * 1. Only take from lower priority endpoints
24099 + * 2. Only take what is allocated above the minimum (never starve an endpoint completely)
24100 + * 3. Only take what you need.
24104 + /* starting at the lowest priority */
24105 + pCurEpDist = pCredInfo->pLowestPriEpDist;
24107 + /* work backwards until we hit the endpoint again */
24108 + while (pCurEpDist != pEPDist) {
24109 + /* calculate how many we need so far */
24110 + need = pEPDist->TxCreditsSeek - pCredInfo->CurrentFreeCredits;
24112 + if ((pCurEpDist->TxCreditsAssigned - need) > pCurEpDist->TxCreditsMin) {
24113 + /* the current one has been allocated more than it's minimum and it
24114 + * has enough credits assigned above it's minimum to fullfill our need
24115 + * try to take away just enough to fullfill our need */
24116 + ReduceCredits(pCredInfo,
24118 + pCurEpDist->TxCreditsAssigned - need);
24120 + if (pCredInfo->CurrentFreeCredits >= pEPDist->TxCreditsSeek) {
24121 + /* we have enough */
24126 + pCurEpDist = pCurEpDist->pPrev;
24129 + /* return what we can get */
24130 + credits = min(pCredInfo->CurrentFreeCredits,pEPDist->TxCreditsSeek);
24134 + /* did we find some credits? */
24136 + /* give what we can */
24137 + GiveCredits(pCredInfo, pEPDist, credits);
24142 +/* initialize and setup credit distribution */
24143 +A_STATUS ar6000_setup_credit_dist(HTC_HANDLE HTCHandle, COMMON_CREDIT_STATE_INFO *pCredInfo)
24145 + HTC_SERVICE_ID servicepriority[5];
24147 + A_MEMZERO(pCredInfo,sizeof(COMMON_CREDIT_STATE_INFO));
24149 + servicepriority[0] = WMI_CONTROL_SVC; /* highest */
24150 + servicepriority[1] = WMI_DATA_VO_SVC;
24151 + servicepriority[2] = WMI_DATA_VI_SVC;
24152 + servicepriority[3] = WMI_DATA_BE_SVC;
24153 + servicepriority[4] = WMI_DATA_BK_SVC; /* lowest */
24155 + /* set callbacks and priority list */
24156 + HTCSetCreditDistribution(HTCHandle,
24158 + ar6000_credit_distribute,
24159 + ar6000_credit_init,
24166 diff --git a/drivers/sdio/function/wlan/ar6000/wlan/wlan_node.c b/drivers/sdio/function/wlan/ar6000/wlan/wlan_node.c
24167 new file mode 100644
24168 index 0000000..b124845
24170 +++ b/drivers/sdio/function/wlan/ar6000/wlan/wlan_node.c
24173 + * Copyright (c) 2001 Atsushi Onoe
24174 + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
24175 + * Copyright (c) 2004-2005 Atheros Communications
24176 + * All rights reserved.
24178 + * Redistribution and use in source and binary forms, with or without
24179 + * modification, are permitted provided that the following conditions
24181 + * 1. Redistributions of source code must retain the above copyright
24182 + * notice, this list of conditions and the following disclaimer.
24183 + * 2. Redistributions in binary form must reproduce the above copyright
24184 + * notice, this list of conditions and the following disclaimer in the
24185 + * documentation and/or other materials provided with the distribution.
24186 + * 3. The name of the author may not be used to endorse or promote products
24187 + * derived from this software without specific prior written permission.
24189 + * Alternatively, this software may be distributed under the terms of the
24190 + * GNU General Public License ("GPL") version 2 as published by the Free
24191 + * Software Foundation.
24193 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24194 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24195 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24196 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24197 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24198 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24199 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24200 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24201 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24202 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24204 + * $Id: //depot/sw/releases/olca2.0-GPL/host/wlan/src/wlan_node.c#1 $
24207 + * IEEE 802.11 node handling support.
24209 +#include <a_config.h>
24210 +#include <athdefs.h>
24211 +#include <a_types.h>
24212 +#include <a_osapi.h>
24213 +#include <a_debug.h>
24214 +#include <ieee80211.h>
24215 +#include <wlan_api.h>
24216 +#include <ieee80211_node.h>
24217 +#include <htc_api.h>
24219 +#include <wmi_api.h>
24221 +static void wlan_node_timeout(A_ATH_TIMER arg);
24222 +static bss_t * _ieee80211_find_node(struct ieee80211_node_table *nt,
24223 + const A_UINT8 *macaddr);
24226 +wlan_node_alloc(struct ieee80211_node_table *nt, int wh_size)
24230 + ni = A_MALLOC_NOWAIT(sizeof(bss_t));
24232 + if (ni != NULL) {
24233 + ni->ni_buf = A_MALLOC_NOWAIT(wh_size);
24234 + if (ni->ni_buf == NULL) {
24243 + /* Make sure our lists are clean */
24244 + ni->ni_list_next = NULL;
24245 + ni->ni_list_prev = NULL;
24246 + ni->ni_hash_next = NULL;
24247 + ni->ni_hash_prev = NULL;
24250 + // ni_scangen never initialized before and during suspend/resume of winmobile, customer (LG/SEMCO) identified
24251 + // that some junk has been stored in this, due to this scan list didn't properly updated
24253 + ni->ni_scangen = 0;
24259 +wlan_node_free(bss_t *ni)
24261 + if (ni->ni_buf != NULL) {
24262 + A_FREE(ni->ni_buf);
24268 +wlan_setup_node(struct ieee80211_node_table *nt, bss_t *ni,
24269 + const A_UINT8 *macaddr)
24273 + A_MEMCPY(ni->ni_macaddr, macaddr, IEEE80211_ADDR_LEN);
24274 + hash = IEEE80211_NODE_HASH(macaddr);
24275 + ieee80211_node_initref(ni); /* mark referenced */
24277 + ni->ni_tstamp = A_GET_MS(WLAN_NODE_INACT_TIMEOUT_MSEC);
24278 + IEEE80211_NODE_LOCK_BH(nt);
24280 + /* Insert at the end of the node list */
24281 + ni->ni_list_next = NULL;
24282 + ni->ni_list_prev = nt->nt_node_last;
24283 + if(nt->nt_node_last != NULL)
24285 + nt->nt_node_last->ni_list_next = ni;
24287 + nt->nt_node_last = ni;
24288 + if(nt->nt_node_first == NULL)
24290 + nt->nt_node_first = ni;
24293 + /* Insert into the hash list i.e. the bucket */
24294 + if((ni->ni_hash_next = nt->nt_hash[hash]) != NULL)
24296 + nt->nt_hash[hash]->ni_hash_prev = ni;
24298 + ni->ni_hash_prev = NULL;
24299 + nt->nt_hash[hash] = ni;
24301 + if (!nt->isTimerArmed) {
24302 + A_TIMEOUT_MS(&nt->nt_inact_timer, WLAN_NODE_INACT_TIMEOUT_MSEC, 0);
24303 + nt->isTimerArmed = TRUE;
24306 + IEEE80211_NODE_UNLOCK_BH(nt);
24310 +_ieee80211_find_node(struct ieee80211_node_table *nt,
24311 + const A_UINT8 *macaddr)
24316 + IEEE80211_NODE_LOCK_ASSERT(nt);
24318 + hash = IEEE80211_NODE_HASH(macaddr);
24319 + for(ni = nt->nt_hash[hash]; ni; ni = ni->ni_hash_next) {
24320 + if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) {
24321 + ieee80211_node_incref(ni); /* mark referenced */
24329 +wlan_find_node(struct ieee80211_node_table *nt, const A_UINT8 *macaddr)
24333 + IEEE80211_NODE_LOCK(nt);
24334 + ni = _ieee80211_find_node(nt, macaddr);
24335 + IEEE80211_NODE_UNLOCK(nt);
24340 + * Reclaim a node. If this is the last reference count then
24341 + * do the normal free work. Otherwise remove it from the node
24342 + * table and mark it gone by clearing the back-reference.
24345 +wlan_node_reclaim(struct ieee80211_node_table *nt, bss_t *ni)
24347 + IEEE80211_NODE_LOCK(nt);
24349 + if(ni->ni_list_prev == NULL)
24351 + /* First in list so fix the list head */
24352 + nt->nt_node_first = ni->ni_list_next;
24356 + ni->ni_list_prev->ni_list_next = ni->ni_list_next;
24359 + if(ni->ni_list_next == NULL)
24361 + /* Last in list so fix list tail */
24362 + nt->nt_node_last = ni->ni_list_prev;
24366 + ni->ni_list_next->ni_list_prev = ni->ni_list_prev;
24369 + if(ni->ni_hash_prev == NULL)
24371 + /* First in list so fix the list head */
24373 + hash = IEEE80211_NODE_HASH(ni->ni_macaddr);
24374 + nt->nt_hash[hash] = ni->ni_hash_next;
24378 + ni->ni_hash_prev->ni_hash_next = ni->ni_hash_next;
24381 + if(ni->ni_hash_next != NULL)
24383 + ni->ni_hash_next->ni_hash_prev = ni->ni_hash_prev;
24385 + wlan_node_free(ni);
24387 + IEEE80211_NODE_UNLOCK(nt);
24391 +wlan_node_dec_free(bss_t *ni)
24393 + if (ieee80211_node_dectestref(ni)) {
24394 + wlan_node_free(ni);
24399 +wlan_free_allnodes(struct ieee80211_node_table *nt)
24403 + while ((ni = nt->nt_node_first) != NULL) {
24404 + wlan_node_reclaim(nt, ni);
24409 +wlan_iterate_nodes(struct ieee80211_node_table *nt, wlan_node_iter_func *f,
24415 + gen = ++nt->nt_scangen;
24417 + IEEE80211_NODE_LOCK(nt);
24418 + for (ni = nt->nt_node_first; ni; ni = ni->ni_list_next) {
24419 + if (ni->ni_scangen != gen) {
24420 + ni->ni_scangen = gen;
24421 + (void) ieee80211_node_incref(ni);
24423 + wlan_node_dec_free(ni);
24426 + IEEE80211_NODE_UNLOCK(nt);
24430 + * Node table support.
24433 +wlan_node_table_init(void *wmip, struct ieee80211_node_table *nt)
24437 + AR_DEBUG_PRINTF(ATH_DEBUG_WLAN, ("node table = 0x%x\n", (A_UINT32)nt));
24438 + IEEE80211_NODE_LOCK_INIT(nt);
24440 + nt->nt_node_first = nt->nt_node_last = NULL;
24441 + for(i = 0; i < IEEE80211_NODE_HASHSIZE; i++)
24443 + nt->nt_hash[i] = NULL;
24445 + A_INIT_TIMER(&nt->nt_inact_timer, wlan_node_timeout, nt);
24446 + nt->isTimerArmed = FALSE;
24447 + nt->nt_wmip = wmip;
24451 +wlan_node_timeout(A_ATH_TIMER arg)
24453 + struct ieee80211_node_table *nt = (struct ieee80211_node_table *)arg;
24454 + bss_t *bss, *nextBss;
24455 + A_UINT8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = FALSE;
24457 + wmi_get_current_bssid(nt->nt_wmip, myBssid);
24459 + bss = nt->nt_node_first;
24460 + while (bss != NULL)
24462 + nextBss = bss->ni_list_next;
24463 + if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0)
24466 + if (bss->ni_tstamp <= A_GET_MS(0))
24469 + * free up all but the current bss - if set
24471 + wlan_node_reclaim(nt, bss);
24476 + * Re-arm timer, only when we have a bss other than
24477 + * current bss AND it is not aged-out.
24479 + reArmTimer = TRUE;
24486 + A_TIMEOUT_MS(&nt->nt_inact_timer, WLAN_NODE_INACT_TIMEOUT_MSEC, 0);
24488 + nt->isTimerArmed = reArmTimer;
24492 +wlan_node_table_cleanup(struct ieee80211_node_table *nt)
24494 + A_UNTIMEOUT(&nt->nt_inact_timer);
24495 + A_DELETE_TIMER(&nt->nt_inact_timer);
24496 + wlan_free_allnodes(nt);
24497 + IEEE80211_NODE_LOCK_DESTROY(nt);
24501 +wlan_find_Ssidnode (struct ieee80211_node_table *nt, A_UCHAR *pSsid,
24502 + A_UINT32 ssidLength, A_BOOL bIsWPA2)
24504 + bss_t *ni = NULL;
24505 + A_UCHAR *pIESsid = NULL;
24507 + IEEE80211_NODE_LOCK (nt);
24509 + for (ni = nt->nt_node_first; ni; ni = ni->ni_list_next) {
24510 + pIESsid = ni->ni_cie.ie_ssid;
24511 + if (pIESsid[1] <= 32) {
24513 + // Step 1 : Check SSID
24514 + if (0x00 == memcmp (pSsid, &pIESsid[2], ssidLength)) {
24516 + // Step 2 : if SSID matches, check WPA or WPA2
24517 + if (TRUE == bIsWPA2 && NULL != ni->ni_cie.ie_rsn) {
24518 + ieee80211_node_incref (ni); /* mark referenced */
24519 + IEEE80211_NODE_UNLOCK (nt);
24522 + if (FALSE == bIsWPA2 && NULL != ni->ni_cie.ie_wpa) {
24523 + ieee80211_node_incref(ni); /* mark referenced */
24524 + IEEE80211_NODE_UNLOCK (nt);
24531 + IEEE80211_NODE_UNLOCK (nt);
24537 +wlan_node_return (struct ieee80211_node_table *nt, bss_t *ni)
24539 + IEEE80211_NODE_LOCK (nt);
24540 + wlan_node_dec_free (ni);
24541 + IEEE80211_NODE_UNLOCK (nt);
24543 diff --git a/drivers/sdio/function/wlan/ar6000/wlan/wlan_recv_beacon.c b/drivers/sdio/function/wlan/ar6000/wlan/wlan_recv_beacon.c
24544 new file mode 100644
24545 index 0000000..15beabb
24547 +++ b/drivers/sdio/function/wlan/ar6000/wlan/wlan_recv_beacon.c
24550 + * Copyright (c) 2001 Atsushi Onoe
24551 + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
24552 + * All rights reserved.
24554 + * Redistribution and use in source and binary forms, with or without
24555 + * modification, are permitted provided that the following conditions
24557 + * 1. Redistributions of source code must retain the above copyright
24558 + * notice, this list of conditions and the following disclaimer.
24559 + * 2. Redistributions in binary form must reproduce the above copyright
24560 + * notice, this list of conditions and the following disclaimer in the
24561 + * documentation and/or other materials provided with the distribution.
24562 + * 3. The name of the author may not be used to endorse or promote products
24563 + * derived from this software without specific prior written permission.
24565 + * Alternatively, this software may be distributed under the terms of the
24566 + * GNU General Public License ("GPL") version 2 as published by the Free
24567 + * Software Foundation.
24569 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24570 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24571 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24572 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24573 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24574 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24575 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24576 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24577 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24578 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24581 + * IEEE 802.11 input handling.
24584 +#include "a_config.h"
24585 +#include "athdefs.h"
24586 +#include "a_types.h"
24587 +#include "a_osapi.h"
24589 +#include <ieee80211.h>
24590 +#include <wlan_api.h>
24592 +#define IEEE80211_VERIFY_LENGTH(_len, _minlen) do { \
24593 + if ((_len) < (_minlen)) { \
24594 + return A_EINVAL; \
24598 +#define IEEE80211_VERIFY_ELEMENT(__elem, __maxlen) do { \
24599 + if ((__elem) == NULL) { \
24600 + return A_EINVAL; \
24602 + if ((__elem)[1] > (__maxlen)) { \
24603 + return A_EINVAL; \
24608 +/* unaligned little endian access */
24609 +#define LE_READ_2(p) \
24611 + ((((A_UINT8 *)(p))[0] ) | (((A_UINT8 *)(p))[1] << 8)))
24613 +#define LE_READ_4(p) \
24615 + ((((A_UINT8 *)(p))[0] ) | (((A_UINT8 *)(p))[1] << 8) | \
24616 + (((A_UINT8 *)(p))[2] << 16) | (((A_UINT8 *)(p))[3] << 24)))
24619 +static int __inline
24620 +iswpaoui(const A_UINT8 *frm)
24622 + return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI);
24625 +static int __inline
24626 +iswmmoui(const A_UINT8 *frm)
24628 + return frm[1] > 3 && LE_READ_4(frm+2) == ((WMM_OUI_TYPE<<24)|WMM_OUI);
24631 +static int __inline
24632 +iswmmparam(const A_UINT8 *frm)
24634 + return frm[1] > 5 && frm[6] == WMM_PARAM_OUI_SUBTYPE;
24637 +static int __inline
24638 +iswmminfo(const A_UINT8 *frm)
24640 + return frm[1] > 5 && frm[6] == WMM_INFO_OUI_SUBTYPE;
24643 +static int __inline
24644 +isatherosoui(const A_UINT8 *frm)
24646 + return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI);
24649 +static int __inline
24650 +iswscoui(const A_UINT8 *frm)
24652 + return frm[1] > 3 && LE_READ_4(frm+2) == ((0x04<<24)|WPA_OUI);
24656 +wlan_parse_beacon(A_UINT8 *buf, int framelen, struct ieee80211_common_ie *cie)
24658 + A_UINT8 *frm, *efrm;
24661 + efrm = (A_UINT8 *) (frm + framelen);
24664 + * beacon/probe response frame format
24666 + * [2] beacon interval
24667 + * [2] capability information
24669 + * [tlv] supported rates
24670 + * [tlv] country information
24671 + * [tlv] parameter set (FH/DS)
24672 + * [tlv] erp information
24673 + * [tlv] extended supported rates
24675 + * [tlv] WPA or RSN
24676 + * [tlv] Atheros Advanced Capabilities
24678 + IEEE80211_VERIFY_LENGTH(efrm - frm, 12);
24679 + A_MEMZERO(cie, sizeof(*cie));
24681 + cie->ie_tstamp = frm; frm += 8;
24682 + cie->ie_beaconInt = A_LE2CPU16(*(A_UINT16 *)frm); frm += 2;
24683 + cie->ie_capInfo = A_LE2CPU16(*(A_UINT16 *)frm); frm += 2;
24684 + cie->ie_chan = 0;
24686 + while (frm < efrm) {
24688 + case IEEE80211_ELEMID_SSID:
24689 + cie->ie_ssid = frm;
24691 + case IEEE80211_ELEMID_RATES:
24692 + cie->ie_rates = frm;
24694 + case IEEE80211_ELEMID_COUNTRY:
24695 + cie->ie_country = frm;
24697 + case IEEE80211_ELEMID_FHPARMS:
24699 + case IEEE80211_ELEMID_DSPARMS:
24700 + cie->ie_chan = frm[2];
24702 + case IEEE80211_ELEMID_TIM:
24703 + cie->ie_tim = frm;
24705 + case IEEE80211_ELEMID_IBSSPARMS:
24707 + case IEEE80211_ELEMID_XRATES:
24708 + cie->ie_xrates = frm;
24710 + case IEEE80211_ELEMID_ERP:
24711 + if (frm[1] != 1) {
24712 + //A_PRINTF("Discarding ERP Element - Bad Len\n");
24715 + cie->ie_erp = frm[2];
24717 + case IEEE80211_ELEMID_RSN:
24718 + cie->ie_rsn = frm;
24720 + case IEEE80211_ELEMID_VENDOR:
24721 + if (iswpaoui(frm)) {
24722 + cie->ie_wpa = frm;
24723 + } else if (iswmmoui(frm)) {
24724 + cie->ie_wmm = frm;
24725 + } else if (isatherosoui(frm)) {
24726 + cie->ie_ath = frm;
24727 + } else if(iswscoui(frm)) {
24728 + cie->ie_wsc = frm;
24734 + frm += frm[1] + 2;
24736 + IEEE80211_VERIFY_ELEMENT(cie->ie_rates, IEEE80211_RATE_MAXSIZE);
24737 + IEEE80211_VERIFY_ELEMENT(cie->ie_ssid, IEEE80211_NWID_LEN);
24741 diff --git a/drivers/sdio/function/wlan/ar6000/wlan/wlan_utils.c b/drivers/sdio/function/wlan/ar6000/wlan/wlan_utils.c
24742 new file mode 100644
24743 index 0000000..fd5aac9
24745 +++ b/drivers/sdio/function/wlan/ar6000/wlan/wlan_utils.c
24748 + * Copyright (c) 2004-2005 Atheros Communications Inc.
24749 + * All rights reserved.
24751 + * This module implements frequently used wlan utilies
24753 + * $Id: //depot/sw/releases/olca2.0-GPL/host/wlan/src/wlan_utils.c#1 $
24756 + * This program is free software; you can redistribute it and/or modify
24757 + * it under the terms of the GNU General Public License version 2 as
24758 + * published by the Free Software Foundation;
24760 + * Software distributed under the License is distributed on an "AS
24761 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
24762 + * implied. See the License for the specific language governing
24763 + * rights and limitations under the License.
24769 +#include <a_config.h>
24770 +#include <athdefs.h>
24771 +#include <a_types.h>
24772 +#include <a_osapi.h>
24775 + * converts ieee channel number to frequency
24778 +wlan_ieee2freq(int chan)
24780 + if (chan == 14) {
24783 + if (chan < 14) { /* 0-13 */
24784 + return (2407 + (chan*5));
24786 + if (chan < 27) { /* 15-26 */
24787 + return (2512 + ((chan-15)*20));
24789 + return (5000 + (chan*5));
24793 + * Converts MHz frequency to IEEE channel number.
24796 +wlan_freq2ieee(A_UINT16 freq)
24798 + if (freq == 2484)
24801 + return (freq - 2407) / 5;
24803 + return 15 + ((freq - 2512) / 20);
24804 + return (freq - 5000) / 5;
24806 diff --git a/drivers/sdio/function/wlan/ar6000/wmi/wmi.c b/drivers/sdio/function/wlan/ar6000/wmi/wmi.c
24807 new file mode 100644
24808 index 0000000..0e0e6ba
24810 +++ b/drivers/sdio/function/wlan/ar6000/wmi/wmi.c
24813 + * Copyright (c) 2004-2007 Atheros Communications Inc.
24814 + * All rights reserved.
24816 + * This module implements the hardware independent layer of the
24817 + * Wireless Module Interface (WMI) protocol.
24819 + * $Id: //depot/sw/releases/olca2.0-GPL/host/wmi/wmi.c#3 $
24822 + * This program is free software; you can redistribute it and/or modify
24823 + * it under the terms of the GNU General Public License version 2 as
24824 + * published by the Free Software Foundation;
24826 + * Software distributed under the License is distributed on an "AS
24827 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
24828 + * implied. See the License for the specific language governing
24829 + * rights and limitations under the License.
24835 +#include <a_config.h>
24836 +#include <athdefs.h>
24837 +#include <a_types.h>
24838 +#include <a_osapi.h>
24840 +#include "htc_api.h"
24842 +#include <ieee80211.h>
24843 +#include <ieee80211_node.h>
24844 +#include <wlan_api.h>
24845 +#include <wmi_api.h>
24846 +#include "dset_api.h"
24847 +#include "gpio_api.h"
24848 +#include "wmi_host.h"
24849 +#include "a_drv.h"
24850 +#include "a_drv_api.h"
24851 +#include "a_debug.h"
24852 +#include "dbglog_api.h"
24854 +static A_STATUS wmi_ready_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24856 +static A_STATUS wmi_connect_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24858 +static A_STATUS wmi_disconnect_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24860 +static A_STATUS wmi_tkip_micerr_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24862 +static A_STATUS wmi_bssInfo_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24864 +static A_STATUS wmi_opt_frame_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24866 +static A_STATUS wmi_pstream_timeout_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24868 +static A_STATUS wmi_sync_point(struct wmi_t *wmip);
24870 +static A_STATUS wmi_bitrate_reply_rx(struct wmi_t *wmip, A_UINT8 *datap,
24872 +static A_STATUS wmi_ratemask_reply_rx(struct wmi_t *wmip, A_UINT8 *datap,
24874 +static A_STATUS wmi_channelList_reply_rx(struct wmi_t *wmip, A_UINT8 *datap,
24876 +static A_STATUS wmi_regDomain_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24878 +static A_STATUS wmi_txPwr_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24879 +static A_STATUS wmi_neighborReport_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24882 +static A_STATUS wmi_dset_open_req_rx(struct wmi_t *wmip, A_UINT8 *datap,
24884 +#ifdef CONFIG_HOST_DSET_SUPPORT
24885 +static A_STATUS wmi_dset_close_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24886 +static A_STATUS wmi_dset_data_req_rx(struct wmi_t *wmip, A_UINT8 *datap,
24888 +#endif /* CONFIG_HOST_DSET_SUPPORT */
24891 +static A_STATUS wmi_scanComplete_rx(struct wmi_t *wmip, A_UINT8 *datap,
24893 +static A_STATUS wmi_errorEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24894 +static A_STATUS wmi_statsEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24895 +static A_STATUS wmi_rssiThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24896 +static A_STATUS wmi_hbChallengeResp_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24897 +static A_STATUS wmi_reportErrorEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24898 +static A_STATUS wmi_cac_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24899 +static A_STATUS wmi_roam_tbl_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24901 +static A_STATUS wmi_roam_data_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24903 +static A_STATUS wmi_get_wow_list_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24906 +wmi_get_pmkid_list_event_rx(struct wmi_t *wmip, A_UINT8 *datap, A_UINT32 len);
24908 +#ifdef CONFIG_HOST_GPIO_SUPPORT
24909 +static A_STATUS wmi_gpio_intr_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24910 +static A_STATUS wmi_gpio_data_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24911 +static A_STATUS wmi_gpio_ack_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24912 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
24914 +#ifdef CONFIG_HOST_TCMD_SUPPORT
24916 +wmi_tcmd_test_report_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24920 +wmi_txRetryErrEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24923 +wmi_snrThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24926 +wmi_lqThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24929 +wmi_is_bitrate_index_valid(struct wmi_t *wmip, A_UINT32 rateIndex);
24932 +wmi_aplistEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24935 +wmi_dbglog_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24937 +static A_STATUS wmi_keepalive_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24940 +static const A_INT32 wmi_rateTable[] = {
24955 +#define MODE_A_SUPPORT_RATE_START 4
24956 +#define MODE_A_SUPPORT_RATE_STOP 11
24958 +#define MODE_GONLY_SUPPORT_RATE_START MODE_A_SUPPORT_RATE_START
24959 +#define MODE_GONLY_SUPPORT_RATE_STOP MODE_A_SUPPORT_RATE_STOP
24961 +#define MODE_B_SUPPORT_RATE_START 0
24962 +#define MODE_B_SUPPORT_RATE_STOP 3
24964 +#define MODE_G_SUPPORT_RATE_START 0
24965 +#define MODE_G_SUPPORT_RATE_STOP 11
24967 +#define MAX_NUMBER_OF_SUPPORT_RATES (MODE_G_SUPPORT_RATE_STOP + 1)
24969 +/* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
24970 +const A_UINT8 up_to_ac[]= {
24982 +wmi_init(void *devt)
24984 + struct wmi_t *wmip;
24986 + wmip = A_MALLOC(sizeof(struct wmi_t));
24987 + if (wmip == NULL) {
24990 + A_MEMZERO(wmip, sizeof(*wmip));
24991 + A_MUTEX_INIT(&wmip->wmi_lock);
24992 + wmip->wmi_devt = devt;
24993 + wlan_node_table_init(wmip, &wmip->wmi_scan_table);
24994 + wmi_qos_state_init(wmip);
24995 + wmip->wmi_powerMode = REC_POWER;
24996 + wmip->wmi_phyMode = WMI_11G_MODE;
25002 +wmi_qos_state_init(struct wmi_t *wmip)
25006 + if (wmip == NULL) {
25011 + /* Initialize QoS States */
25012 + wmip->wmi_numQoSStream = 0;
25014 + wmip->wmi_fatPipeExists = 0;
25016 + for (i=0; i < WMM_NUM_AC; i++) {
25017 + wmip->wmi_streamExistsForAC[i]=0;
25020 + /* Initialize the static Wmi stream Pri to WMM AC mappings Arrays */
25021 + WMI_INIT_WMISTREAM_AC_MAP(wmip);
25023 + UNLOCK_WMI(wmip);
25025 + A_WMI_SET_NUMDATAENDPTS(wmip->wmi_devt, 1);
25029 +wmi_shutdown(struct wmi_t *wmip)
25031 + if (wmip != NULL) {
25032 + wlan_node_table_cleanup(&wmip->wmi_scan_table);
25033 + if (A_IS_MUTEX_VALID(&wmip->wmi_lock)) {
25034 + A_MUTEX_DELETE(&wmip->wmi_lock);
25041 + * performs DIX to 802.3 encapsulation for transmit packets.
25042 + * uses passed in buffer. Returns buffer or NULL if failed.
25043 + * Assumes the entire DIX header is contigous and that there is
25044 + * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
25047 +wmi_dix_2_dot3(struct wmi_t *wmip, void *osbuf)
25050 + A_UINT16 typeorlen;
25051 + ATH_MAC_HDR macHdr;
25052 + ATH_LLC_SNAP_HDR *llcHdr;
25054 + A_ASSERT(osbuf != NULL);
25056 + if (A_NETBUF_HEADROOM(osbuf) <
25057 + (sizeof(ATH_LLC_SNAP_HDR) + sizeof(WMI_DATA_HDR)))
25059 + return A_NO_MEMORY;
25062 + datap = A_NETBUF_DATA(osbuf);
25064 + typeorlen = *(A_UINT16 *)(datap + ATH_MAC_LEN + ATH_MAC_LEN);
25066 + if (!IS_ETHERTYPE(A_BE2CPU16(typeorlen))) {
25068 + * packet is already in 802.3 format - return success
25070 + A_DPRINTF(DBG_WMI, (DBGFMT "packet already 802.3\n", DBGARG));
25075 + * Save mac fields and length to be inserted later
25077 + A_MEMCPY(macHdr.dstMac, datap, ATH_MAC_LEN);
25078 + A_MEMCPY(macHdr.srcMac, datap + ATH_MAC_LEN, ATH_MAC_LEN);
25079 + macHdr.typeOrLen = A_CPU2BE16(A_NETBUF_LEN(osbuf) - sizeof(ATH_MAC_HDR) +
25080 + sizeof(ATH_LLC_SNAP_HDR));
25083 + * Make room for LLC+SNAP headers
25085 + if (A_NETBUF_PUSH(osbuf, sizeof(ATH_LLC_SNAP_HDR)) != A_OK) {
25086 + return A_NO_MEMORY;
25089 + datap = A_NETBUF_DATA(osbuf);
25091 + A_MEMCPY(datap, &macHdr, sizeof (ATH_MAC_HDR));
25093 + llcHdr = (ATH_LLC_SNAP_HDR *)(datap + sizeof(ATH_MAC_HDR));
25094 + llcHdr->dsap = 0xAA;
25095 + llcHdr->ssap = 0xAA;
25096 + llcHdr->cntl = 0x03;
25097 + llcHdr->orgCode[0] = 0x0;
25098 + llcHdr->orgCode[1] = 0x0;
25099 + llcHdr->orgCode[2] = 0x0;
25100 + llcHdr->etherType = typeorlen;
25106 + * Adds a WMI data header
25107 + * Assumes there is enough room in the buffer to add header.
25110 +wmi_data_hdr_add(struct wmi_t *wmip, void *osbuf, A_UINT8 msgType)
25112 + WMI_DATA_HDR *dtHdr;
25114 + A_ASSERT(osbuf != NULL);
25116 + if (A_NETBUF_PUSH(osbuf, sizeof(WMI_DATA_HDR)) != A_OK) {
25117 + return A_NO_MEMORY;
25120 + dtHdr = (WMI_DATA_HDR *)A_NETBUF_DATA(osbuf);
25121 + dtHdr->info = msgType;
25127 +A_UINT8 wmi_implicit_create_pstream(struct wmi_t *wmip, void *osbuf, A_UINT8 dir, A_UINT8 up)
25130 + A_UINT8 trafficClass = WMM_AC_BE, userPriority = up;
25131 + ATH_LLC_SNAP_HDR *llcHdr;
25132 + A_UINT16 ipType = IP_ETHERTYPE;
25133 + WMI_DATA_HDR *dtHdr;
25134 + WMI_CREATE_PSTREAM_CMD cmd;
25135 + A_BOOL streamExists = FALSE;
25137 + A_ASSERT(osbuf != NULL);
25139 + datap = A_NETBUF_DATA(osbuf);
25141 + if (up == UNDEFINED_PRI) {
25142 + llcHdr = (ATH_LLC_SNAP_HDR *)(datap + sizeof(WMI_DATA_HDR) +
25143 + sizeof(ATH_MAC_HDR));
25145 + if (llcHdr->etherType == A_CPU2BE16(ipType)) {
25146 + /* Extract the endpoint info from the TOS field in the IP header */
25147 + userPriority = A_WMI_IPTOS_TO_USERPRIORITY(((A_UINT8 *)llcHdr) + sizeof(ATH_LLC_SNAP_HDR));
25151 + if (userPriority < MAX_NUM_PRI) {
25152 + trafficClass = convert_userPriority_to_trafficClass(userPriority);
25155 + dtHdr = (WMI_DATA_HDR *)datap;
25156 + if(dir==UPLINK_TRAFFIC)
25157 + dtHdr->info |= (userPriority & WMI_DATA_HDR_UP_MASK) << WMI_DATA_HDR_UP_SHIFT; /* lower 3-bits are 802.1d priority */
25160 + streamExists = wmip->wmi_fatPipeExists;
25161 + UNLOCK_WMI(wmip);
25163 + if (!(streamExists & (1 << trafficClass))) {
25165 + A_MEMZERO(&cmd, sizeof(cmd));
25166 + cmd.trafficClass = trafficClass;
25167 + cmd.userPriority = userPriority;
25168 + cmd.inactivityInt = WMI_IMPLICIT_PSTREAM_INACTIVITY_INT;
25169 + /* Implicit streams are created with TSID 0xFF */
25170 + cmd.tsid = WMI_IMPLICIT_PSTREAM;
25171 + wmi_create_pstream_cmd(wmip, &cmd);
25174 + return trafficClass;
25178 +wmi_get_stream_id(struct wmi_t *wmip, A_UINT8 trafficClass)
25180 + return WMI_ACCESSCATEGORY_WMISTREAM(wmip, trafficClass);
25184 + * performs 802.3 to DIX encapsulation for received packets.
25185 + * Assumes the entire 802.3 header is contigous.
25188 +wmi_dot3_2_dix(struct wmi_t *wmip, void *osbuf)
25191 + ATH_MAC_HDR macHdr;
25192 + ATH_LLC_SNAP_HDR *llcHdr;
25194 + A_ASSERT(osbuf != NULL);
25195 + datap = A_NETBUF_DATA(osbuf);
25197 + A_MEMCPY(&macHdr, datap, sizeof(ATH_MAC_HDR));
25198 + llcHdr = (ATH_LLC_SNAP_HDR *)(datap + sizeof(ATH_MAC_HDR));
25199 + macHdr.typeOrLen = llcHdr->etherType;
25201 + if (A_NETBUF_PULL(osbuf, sizeof(ATH_LLC_SNAP_HDR)) != A_OK) {
25202 + return A_NO_MEMORY;
25205 + datap = A_NETBUF_DATA(osbuf);
25207 + A_MEMCPY(datap, &macHdr, sizeof (ATH_MAC_HDR));
25213 + * Removes a WMI data header
25216 +wmi_data_hdr_remove(struct wmi_t *wmip, void *osbuf)
25218 + A_ASSERT(osbuf != NULL);
25220 + return (A_NETBUF_PULL(osbuf, sizeof(WMI_DATA_HDR)));
25224 +wmi_iterate_nodes(struct wmi_t *wmip, wlan_node_iter_func *f, void *arg)
25226 + wlan_iterate_nodes(&wmip->wmi_scan_table, f, arg);
25230 + * WMI Extended Event received from Target.
25233 +wmi_control_rx_xtnd(struct wmi_t *wmip, void *osbuf)
25235 + WMIX_CMD_HDR *cmd;
25239 + A_STATUS status = A_OK;
25241 + if (A_NETBUF_LEN(osbuf) < sizeof(WMIX_CMD_HDR)) {
25242 + A_DPRINTF(DBG_WMI, (DBGFMT "bad packet 1\n", DBGARG));
25243 + wmip->wmi_stats.cmd_len_err++;
25244 + A_NETBUF_FREE(osbuf);
25248 + cmd = (WMIX_CMD_HDR *)A_NETBUF_DATA(osbuf);
25249 + id = cmd->commandId;
25251 + if (A_NETBUF_PULL(osbuf, sizeof(WMIX_CMD_HDR)) != A_OK) {
25252 + A_DPRINTF(DBG_WMI, (DBGFMT "bad packet 2\n", DBGARG));
25253 + wmip->wmi_stats.cmd_len_err++;
25254 + A_NETBUF_FREE(osbuf);
25258 + datap = A_NETBUF_DATA(osbuf);
25259 + len = A_NETBUF_LEN(osbuf);
25262 + case (WMIX_DSETOPENREQ_EVENTID):
25263 + status = wmi_dset_open_req_rx(wmip, datap, len);
25265 +#ifdef CONFIG_HOST_DSET_SUPPORT
25266 + case (WMIX_DSETCLOSE_EVENTID):
25267 + status = wmi_dset_close_rx(wmip, datap, len);
25269 + case (WMIX_DSETDATAREQ_EVENTID):
25270 + status = wmi_dset_data_req_rx(wmip, datap, len);
25272 +#endif /* CONFIG_HOST_DSET_SUPPORT */
25273 +#ifdef CONFIG_HOST_GPIO_SUPPORT
25274 + case (WMIX_GPIO_INTR_EVENTID):
25275 + wmi_gpio_intr_rx(wmip, datap, len);
25277 + case (WMIX_GPIO_DATA_EVENTID):
25278 + wmi_gpio_data_rx(wmip, datap, len);
25280 + case (WMIX_GPIO_ACK_EVENTID):
25281 + wmi_gpio_ack_rx(wmip, datap, len);
25283 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
25284 + case (WMIX_HB_CHALLENGE_RESP_EVENTID):
25285 + wmi_hbChallengeResp_rx(wmip, datap, len);
25287 + case (WMIX_DBGLOG_EVENTID):
25288 + wmi_dbglog_event_rx(wmip, datap, len);
25291 + A_DPRINTF(DBG_WMI|DBG_ERROR,
25292 + (DBGFMT "Unknown id 0x%x\n", DBGARG, id));
25293 + wmip->wmi_stats.cmd_id_err++;
25294 + status = A_ERROR;
25304 +A_UINT32 cmdRecvNum;
25307 +wmi_control_rx(struct wmi_t *wmip, void *osbuf)
25309 + WMI_CMD_HDR *cmd;
25312 + A_UINT32 len, i, loggingReq;
25313 + A_STATUS status = A_OK;
25315 + A_ASSERT(osbuf != NULL);
25316 + if (A_NETBUF_LEN(osbuf) < sizeof(WMI_CMD_HDR)) {
25317 + A_DPRINTF(DBG_WMI, (DBGFMT "bad packet 1\n", DBGARG));
25318 + wmip->wmi_stats.cmd_len_err++;
25319 + A_NETBUF_FREE(osbuf);
25323 + cmd = (WMI_CMD_HDR *)A_NETBUF_DATA(osbuf);
25324 + id = cmd->commandId;
25326 + if (A_NETBUF_PULL(osbuf, sizeof(WMI_CMD_HDR)) != A_OK) {
25327 + A_DPRINTF(DBG_WMI, (DBGFMT "bad packet 2\n", DBGARG));
25328 + wmip->wmi_stats.cmd_len_err++;
25329 + A_NETBUF_FREE(osbuf);
25333 + datap = A_NETBUF_DATA(osbuf);
25334 + len = A_NETBUF_LEN(osbuf);
25336 + ar6000_get_driver_cfg(wmip->wmi_devt,
25337 + AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS,
25341 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("WMI %d \n",id));
25342 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("WMI recv, MsgNo %d : ", cmdRecvNum));
25343 + for(i = 0; i < len; i++)
25344 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("%x ", datap[i]));
25345 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("\n"));
25350 + UNLOCK_WMI(wmip);
25353 + case (WMI_GET_BITRATE_CMDID):
25354 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_BITRATE_CMDID\n", DBGARG));
25355 + status = wmi_bitrate_reply_rx(wmip, datap, len);
25357 + case (WMI_GET_CHANNEL_LIST_CMDID):
25358 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_CHANNEL_LIST_CMDID\n", DBGARG));
25359 + status = wmi_channelList_reply_rx(wmip, datap, len);
25361 + case (WMI_GET_TX_PWR_CMDID):
25362 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_TX_PWR_CMDID\n", DBGARG));
25363 + status = wmi_txPwr_reply_rx(wmip, datap, len);
25365 + case (WMI_READY_EVENTID):
25366 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_READY_EVENTID\n", DBGARG));
25367 + status = wmi_ready_event_rx(wmip, datap, len);
25368 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25369 + A_WMI_DBGLOG_INIT_DONE(wmip->wmi_devt);
25371 + case (WMI_CONNECT_EVENTID):
25372 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CONNECT_EVENTID\n", DBGARG));
25373 + status = wmi_connect_event_rx(wmip, datap, len);
25374 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25376 + case (WMI_DISCONNECT_EVENTID):
25377 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_DISCONNECT_EVENTID\n", DBGARG));
25378 + status = wmi_disconnect_event_rx(wmip, datap, len);
25379 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25381 + case (WMI_TKIP_MICERR_EVENTID):
25382 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_TKIP_MICERR_EVENTID\n", DBGARG));
25383 + status = wmi_tkip_micerr_event_rx(wmip, datap, len);
25385 + case (WMI_BSSINFO_EVENTID):
25386 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_BSSINFO_EVENTID\n", DBGARG));
25387 + status = wmi_bssInfo_event_rx(wmip, datap, len);
25388 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25390 + case (WMI_REGDOMAIN_EVENTID):
25391 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_REGDOMAIN_EVENTID\n", DBGARG));
25392 + status = wmi_regDomain_event_rx(wmip, datap, len);
25394 + case (WMI_PSTREAM_TIMEOUT_EVENTID):
25395 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_PSTREAM_TIMEOUT_EVENTID\n", DBGARG));
25396 + status = wmi_pstream_timeout_event_rx(wmip, datap, len);
25397 + /* pstreams are fatpipe abstractions that get implicitly created.
25398 + * User apps only deal with thinstreams. creation of a thinstream
25399 + * by the user or data traffic flow in an AC triggers implicit
25400 + * pstream creation. Do we need to send this event to App..?
25401 + * no harm in sending it.
25403 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25405 + case (WMI_NEIGHBOR_REPORT_EVENTID):
25406 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_NEIGHBOR_REPORT_EVENTID\n", DBGARG));
25407 + status = wmi_neighborReport_event_rx(wmip, datap, len);
25409 + case (WMI_SCAN_COMPLETE_EVENTID):
25410 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SCAN_COMPLETE_EVENTID\n", DBGARG));
25411 + status = wmi_scanComplete_rx(wmip, datap, len);
25412 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25414 + case (WMI_CMDERROR_EVENTID):
25415 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CMDERROR_EVENTID\n", DBGARG));
25416 + status = wmi_errorEvent_rx(wmip, datap, len);
25418 + case (WMI_REPORT_STATISTICS_EVENTID):
25419 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_REPORT_STATISTICS_EVENTID\n", DBGARG));
25420 + status = wmi_statsEvent_rx(wmip, datap, len);
25422 + case (WMI_RSSI_THRESHOLD_EVENTID):
25423 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_RSSI_THRESHOLD_EVENTID\n", DBGARG));
25424 + status = wmi_rssiThresholdEvent_rx(wmip, datap, len);
25426 + case (WMI_ERROR_REPORT_EVENTID):
25427 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_ERROR_REPORT_EVENTID\n", DBGARG));
25428 + status = wmi_reportErrorEvent_rx(wmip, datap, len);
25429 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25431 + case (WMI_OPT_RX_FRAME_EVENTID):
25432 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_OPT_RX_FRAME_EVENTID\n", DBGARG));
25433 + status = wmi_opt_frame_event_rx(wmip, datap, len);
25435 + case (WMI_REPORT_ROAM_TBL_EVENTID):
25436 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_REPORT_ROAM_TBL_EVENTID\n", DBGARG));
25437 + status = wmi_roam_tbl_event_rx(wmip, datap, len);
25439 + case (WMI_EXTENSION_EVENTID):
25440 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_EXTENSION_EVENTID\n", DBGARG));
25441 + status = wmi_control_rx_xtnd(wmip, osbuf);
25443 + case (WMI_CAC_EVENTID):
25444 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CAC_EVENTID\n", DBGARG));
25445 + status = wmi_cac_event_rx(wmip, datap, len);
25447 + case (WMI_REPORT_ROAM_DATA_EVENTID):
25448 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_REPORT_ROAM_DATA_EVENTID\n", DBGARG));
25449 + status = wmi_roam_data_event_rx(wmip, datap, len);
25451 +#ifdef CONFIG_HOST_TCMD_SUPPORT
25452 + case (WMI_TEST_EVENTID):
25453 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_TEST_EVENTID\n", DBGARG));
25454 + status = wmi_tcmd_test_report_rx(wmip, datap, len);
25457 + case (WMI_GET_FIXRATES_CMDID):
25458 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_FIXRATES_CMDID\n", DBGARG));
25459 + status = wmi_ratemask_reply_rx(wmip, datap, len);
25461 + case (WMI_TX_RETRY_ERR_EVENTID):
25462 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_TX_RETRY_ERR_EVENTID\n", DBGARG));
25463 + status = wmi_txRetryErrEvent_rx(wmip, datap, len);
25464 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25466 + case (WMI_SNR_THRESHOLD_EVENTID):
25467 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SNR_THRESHOLD_EVENTID\n", DBGARG));
25468 + status = wmi_snrThresholdEvent_rx(wmip, datap, len);
25469 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25471 + case (WMI_LQ_THRESHOLD_EVENTID):
25472 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_LQ_THRESHOLD_EVENTID\n", DBGARG));
25473 + status = wmi_lqThresholdEvent_rx(wmip, datap, len);
25474 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25476 + case (WMI_APLIST_EVENTID):
25477 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Received APLIST Event\n"));
25478 + status = wmi_aplistEvent_rx(wmip, datap, len);
25480 + case (WMI_GET_KEEPALIVE_CMDID):
25481 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_KEEPALIVE_CMDID\n", DBGARG));
25482 + status = wmi_keepalive_reply_rx(wmip, datap, len);
25484 + case (WMI_GET_WOW_LIST_EVENTID):
25485 + status = wmi_get_wow_list_event_rx(wmip, datap, len);
25487 + case (WMI_GET_PMKID_LIST_EVENTID):
25488 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_GET_PMKID_LIST Event\n", DBGARG));
25489 + status = wmi_get_pmkid_list_event_rx(wmip, datap, len);
25492 + A_DPRINTF(DBG_WMI|DBG_ERROR,
25493 + (DBGFMT "Unknown id 0x%x\n", DBGARG, id));
25494 + wmip->wmi_stats.cmd_id_err++;
25495 + status = A_ERROR;
25499 + A_NETBUF_FREE(osbuf);
25505 +wmi_ready_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25507 + WMI_READY_EVENT *ev = (WMI_READY_EVENT *)datap;
25509 + if (len < sizeof(WMI_READY_EVENT)) {
25512 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25513 + wmip->wmi_ready = TRUE;
25514 + A_WMI_READY_EVENT(wmip->wmi_devt, ev->macaddr, ev->phyCapability);
25520 +wmi_connect_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25522 + WMI_CONNECT_EVENT *ev;
25524 + if (len < sizeof(WMI_CONNECT_EVENT)) {
25527 + ev = (WMI_CONNECT_EVENT *)datap;
25528 + A_DPRINTF(DBG_WMI,
25529 + (DBGFMT "freq %d bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
25530 + DBGARG, ev->channel,
25531 + ev->bssid[0], ev->bssid[1], ev->bssid[2],
25532 + ev->bssid[3], ev->bssid[4], ev->bssid[5]));
25534 + A_MEMCPY(wmip->wmi_bssid, ev->bssid, ATH_MAC_LEN);
25536 + A_WMI_CONNECT_EVENT(wmip->wmi_devt, ev->channel, ev->bssid,
25537 + ev->listenInterval, ev->beaconInterval,
25538 + ev->networkType, ev->beaconIeLen,
25539 + ev->assocReqLen, ev->assocRespLen,
25546 +wmi_regDomain_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25548 + WMI_REG_DOMAIN_EVENT *ev;
25550 + if (len < sizeof(*ev)) {
25553 + ev = (WMI_REG_DOMAIN_EVENT *)datap;
25555 + A_WMI_REGDOMAIN_EVENT(wmip->wmi_devt, ev->regDomain);
25561 +wmi_neighborReport_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25563 + WMI_NEIGHBOR_REPORT_EVENT *ev;
25566 + if (len < sizeof(*ev)) {
25569 + ev = (WMI_NEIGHBOR_REPORT_EVENT *)datap;
25570 + numAps = ev->numberOfAps;
25572 + if (len < (int)(sizeof(*ev) + ((numAps - 1) * sizeof(WMI_NEIGHBOR_INFO)))) {
25576 + A_WMI_NEIGHBORREPORT_EVENT(wmip->wmi_devt, numAps, ev->neighbor);
25582 +wmi_disconnect_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25584 + WMI_DISCONNECT_EVENT *ev;
25586 + if (len < sizeof(WMI_DISCONNECT_EVENT)) {
25589 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25591 + ev = (WMI_DISCONNECT_EVENT *)datap;
25593 + A_MEMZERO(wmip->wmi_bssid, sizeof(wmip->wmi_bssid));
25595 + A_WMI_DISCONNECT_EVENT(wmip->wmi_devt, ev->disconnectReason, ev->bssid,
25596 + ev->assocRespLen, ev->assocInfo, ev->protocolReasonStatus);
25602 +wmi_tkip_micerr_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25604 + WMI_TKIP_MICERR_EVENT *ev;
25606 + if (len < sizeof(*ev)) {
25609 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25611 + ev = (WMI_TKIP_MICERR_EVENT *)datap;
25612 + A_WMI_TKIP_MICERR_EVENT(wmip->wmi_devt, ev->keyid, ev->ismcast);
25618 +wmi_bssInfo_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25621 + WMI_BSS_INFO_HDR *bih;
25623 + A_UINT32 nodeCachingAllowed;
25625 + if (len <= sizeof(WMI_BSS_INFO_HDR)) {
25629 + A_WMI_BSSINFO_EVENT_RX(wmip->wmi_devt, datap, len);
25630 + /* What is driver config for wlan node caching? */
25631 + if(ar6000_get_driver_cfg(wmip->wmi_devt,
25632 + AR6000_DRIVER_CFG_GET_WLANNODECACHING,
25633 + &nodeCachingAllowed) != A_OK) {
25637 + if(!nodeCachingAllowed) {
25642 + bih = (WMI_BSS_INFO_HDR *)datap;
25643 + buf = datap + sizeof(WMI_BSS_INFO_HDR);
25644 + len -= sizeof(WMI_BSS_INFO_HDR);
25646 + A_DPRINTF(DBG_WMI2, (DBGFMT "bssInfo event - ch %u, rssi %02x, "
25647 + "bssid \"%02x:%02x:%02x:%02x:%02x:%02x\"\n", DBGARG,
25648 + bih->channel, (unsigned char) bih->rssi, bih->bssid[0],
25649 + bih->bssid[1], bih->bssid[2], bih->bssid[3], bih->bssid[4],
25652 + if(wps_enable && (bih->frameType == PROBERESP_FTYPE) ) {
25653 + printk("%s() A_OK 2\n", __FUNCTION__);
25657 + bss = wlan_find_node(&wmip->wmi_scan_table, bih->bssid);
25658 + if (bss != NULL) {
25660 + * Free up the node. Not the most efficient process given
25661 + * we are about to allocate a new node but it is simple and should be
25664 + wlan_node_reclaim(&wmip->wmi_scan_table, bss);
25667 + bss = wlan_node_alloc(&wmip->wmi_scan_table, len);
25668 + if (bss == NULL) {
25669 + return A_NO_MEMORY;
25672 + bss->ni_snr = bih->snr;
25673 + bss->ni_rssi = bih->rssi;
25674 + A_ASSERT(bss->ni_buf != NULL);
25675 + A_MEMCPY(bss->ni_buf, buf, len);
25677 + if (wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie) != A_OK) {
25678 + wlan_node_free(bss);
25683 + * Update the frequency in ie_chan, overwriting of channel number
25684 + * which is done in wlan_parse_beacon
25686 + bss->ni_cie.ie_chan = bih->channel;
25687 + wlan_setup_node(&wmip->wmi_scan_table, bss, bih->bssid);
25693 +wmi_opt_frame_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25696 + WMI_OPT_RX_INFO_HDR *bih;
25699 + if (len <= sizeof(WMI_OPT_RX_INFO_HDR)) {
25703 + bih = (WMI_OPT_RX_INFO_HDR *)datap;
25704 + buf = datap + sizeof(WMI_OPT_RX_INFO_HDR);
25705 + len -= sizeof(WMI_OPT_RX_INFO_HDR);
25707 + A_DPRINTF(DBG_WMI2, (DBGFMT "opt frame event %2.2x:%2.2x\n", DBGARG,
25708 + bih->bssid[4], bih->bssid[5]));
25710 + bss = wlan_find_node(&wmip->wmi_scan_table, bih->bssid);
25711 + if (bss != NULL) {
25713 + * Free up the node. Not the most efficient process given
25714 + * we are about to allocate a new node but it is simple and should be
25717 + wlan_node_reclaim(&wmip->wmi_scan_table, bss);
25720 + bss = wlan_node_alloc(&wmip->wmi_scan_table, len);
25721 + if (bss == NULL) {
25722 + return A_NO_MEMORY;
25725 + bss->ni_snr = bih->snr;
25726 + bss->ni_cie.ie_chan = bih->channel;
25727 + A_ASSERT(bss->ni_buf != NULL);
25728 + A_MEMCPY(bss->ni_buf, buf, len);
25729 + wlan_setup_node(&wmip->wmi_scan_table, bss, bih->bssid);
25734 + /* This event indicates inactivity timeout of a fatpipe(pstream)
25738 +wmi_pstream_timeout_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25740 + WMI_PSTREAM_TIMEOUT_EVENT *ev;
25742 + if (len < sizeof(WMI_PSTREAM_TIMEOUT_EVENT)) {
25746 + A_DPRINTF(DBG_WMI, (DBGFMT "wmi_pstream_timeout_event_rx\n", DBGARG));
25748 + ev = (WMI_PSTREAM_TIMEOUT_EVENT *)datap;
25750 + /* When the pstream (fat pipe == AC) timesout, it means there were no
25751 + * thinStreams within this pstream & it got implicitly created due to
25752 + * data flow on this AC. We start the inactivity timer only for
25753 + * implicitly created pstream. Just reset the host state.
25755 + /* Set the activeTsids for this AC to 0 */
25757 + wmip->wmi_streamExistsForAC[ev->trafficClass]=0;
25758 + wmip->wmi_fatPipeExists &= ~(1 << ev->trafficClass);
25759 + UNLOCK_WMI(wmip);
25761 + /*Indicate inactivity to driver layer for this fatpipe (pstream)*/
25762 + A_WMI_STREAM_TX_INACTIVE(wmip->wmi_devt, ev->trafficClass);
25768 +wmi_bitrate_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25770 + WMI_BIT_RATE_CMD *reply;
25773 + if (len < sizeof(WMI_BIT_RATE_CMD)) {
25776 + reply = (WMI_BIT_RATE_CMD *)datap;
25777 + A_DPRINTF(DBG_WMI,
25778 + (DBGFMT "Enter - rateindex %d\n", DBGARG, reply->rateIndex));
25780 + if (reply->rateIndex == RATE_AUTO) {
25781 + rate = RATE_AUTO;
25783 + rate = wmi_rateTable[(A_UINT32) reply->rateIndex];
25786 + A_WMI_BITRATE_RX(wmip->wmi_devt, rate);
25792 +wmi_ratemask_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25794 + WMI_FIX_RATES_CMD *reply;
25796 + if (len < sizeof(WMI_BIT_RATE_CMD)) {
25799 + reply = (WMI_FIX_RATES_CMD *)datap;
25800 + A_DPRINTF(DBG_WMI,
25801 + (DBGFMT "Enter - fixed rate mask %x\n", DBGARG, reply->fixRateMask));
25803 + A_WMI_RATEMASK_RX(wmip->wmi_devt, reply->fixRateMask);
25809 +wmi_channelList_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25811 + WMI_CHANNEL_LIST_REPLY *reply;
25813 + if (len < sizeof(WMI_CHANNEL_LIST_REPLY)) {
25816 + reply = (WMI_CHANNEL_LIST_REPLY *)datap;
25817 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25819 + A_WMI_CHANNELLIST_RX(wmip->wmi_devt, reply->numChannels,
25820 + reply->channelList);
25826 +wmi_txPwr_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25828 + WMI_TX_PWR_REPLY *reply;
25830 + if (len < sizeof(*reply)) {
25833 + reply = (WMI_TX_PWR_REPLY *)datap;
25834 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25836 + A_WMI_TXPWR_RX(wmip->wmi_devt, reply->dbM);
25841 +wmi_keepalive_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25843 + WMI_GET_KEEPALIVE_CMD *reply;
25845 + if (len < sizeof(*reply)) {
25848 + reply = (WMI_GET_KEEPALIVE_CMD *)datap;
25849 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25851 + A_WMI_KEEPALIVE_RX(wmip->wmi_devt, reply->configured);
25858 +wmi_dset_open_req_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25860 + WMIX_DSETOPENREQ_EVENT *dsetopenreq;
25862 + if (len < sizeof(WMIX_DSETOPENREQ_EVENT)) {
25865 + dsetopenreq = (WMIX_DSETOPENREQ_EVENT *)datap;
25866 + A_DPRINTF(DBG_WMI,
25867 + (DBGFMT "Enter - dset_id=0x%x\n", DBGARG, dsetopenreq->dset_id));
25868 + A_WMI_DSET_OPEN_REQ(wmip->wmi_devt,
25869 + dsetopenreq->dset_id,
25870 + dsetopenreq->targ_dset_handle,
25871 + dsetopenreq->targ_reply_fn,
25872 + dsetopenreq->targ_reply_arg);
25877 +#ifdef CONFIG_HOST_DSET_SUPPORT
25879 +wmi_dset_close_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25881 + WMIX_DSETCLOSE_EVENT *dsetclose;
25883 + if (len < sizeof(WMIX_DSETCLOSE_EVENT)) {
25886 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25888 + dsetclose = (WMIX_DSETCLOSE_EVENT *)datap;
25889 + A_WMI_DSET_CLOSE(wmip->wmi_devt, dsetclose->access_cookie);
25895 +wmi_dset_data_req_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25897 + WMIX_DSETDATAREQ_EVENT *dsetdatareq;
25899 + if (len < sizeof(WMIX_DSETDATAREQ_EVENT)) {
25902 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25904 + dsetdatareq = (WMIX_DSETDATAREQ_EVENT *)datap;
25905 + A_WMI_DSET_DATA_REQ(wmip->wmi_devt,
25906 + dsetdatareq->access_cookie,
25907 + dsetdatareq->offset,
25908 + dsetdatareq->length,
25909 + dsetdatareq->targ_buf,
25910 + dsetdatareq->targ_reply_fn,
25911 + dsetdatareq->targ_reply_arg);
25915 +#endif /* CONFIG_HOST_DSET_SUPPORT */
25918 +wmi_scanComplete_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25920 + WMI_SCAN_COMPLETE_EVENT *ev;
25922 + ev = (WMI_SCAN_COMPLETE_EVENT *)datap;
25923 + A_WMI_SCANCOMPLETE_EVENT(wmip->wmi_devt, ev->status);
25929 + * Target is reporting a programming error. This is for
25930 + * developer aid only. Target only checks a few common violations
25931 + * and it is responsibility of host to do all error checking.
25932 + * Behavior of target after wmi error event is undefined.
25933 + * A reset is recommended.
25936 +wmi_errorEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25938 + WMI_CMD_ERROR_EVENT *ev;
25940 + ev = (WMI_CMD_ERROR_EVENT *)datap;
25941 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Programming Error: cmd=%d ", ev->commandId));
25942 + switch (ev->errorCode) {
25943 + case (INVALID_PARAM):
25944 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Illegal Parameter\n"));
25946 + case (ILLEGAL_STATE):
25947 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Illegal State\n"));
25949 + case (INTERNAL_ERROR):
25950 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Internal Error\n"));
25959 +wmi_statsEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25961 + WMI_TARGET_STATS *reply;
25963 + if (len < sizeof(*reply)) {
25966 + reply = (WMI_TARGET_STATS *)datap;
25967 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25969 + A_WMI_TARGETSTATS_EVENT(wmip->wmi_devt, reply);
25975 +wmi_rssiThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25977 + WMI_RSSI_THRESHOLD_EVENT *reply;
25979 + if (len < sizeof(*reply)) {
25982 + reply = (WMI_RSSI_THRESHOLD_EVENT *)datap;
25983 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25985 + A_WMI_RSSI_THRESHOLD_EVENT(wmip->wmi_devt, reply->range, reply->rssi);
25992 +wmi_reportErrorEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25994 + WMI_TARGET_ERROR_REPORT_EVENT *reply;
25996 + if (len < sizeof(*reply)) {
25999 + reply = (WMI_TARGET_ERROR_REPORT_EVENT *)datap;
26000 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26002 + A_WMI_REPORT_ERROR_EVENT(wmip->wmi_devt, reply->errorVal);
26008 +wmi_cac_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26010 + WMI_CAC_EVENT *reply;
26012 + if (len < sizeof(*reply)) {
26015 + reply = (WMI_CAC_EVENT *)datap;
26016 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26018 + A_WMI_CAC_EVENT(wmip->wmi_devt, reply->ac,
26019 + reply->cac_indication, reply->statusCode,
26020 + reply->tspecSuggestion);
26026 +wmi_hbChallengeResp_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26028 + WMIX_HB_CHALLENGE_RESP_EVENT *reply;
26030 + if (len < sizeof(*reply)) {
26033 + reply = (WMIX_HB_CHALLENGE_RESP_EVENT *)datap;
26034 + A_DPRINTF(DBG_WMI, (DBGFMT "wmi: challenge response event\n", DBGARG));
26036 + A_WMI_HBCHALLENGERESP_EVENT(wmip->wmi_devt, reply->cookie, reply->source);
26042 +wmi_roam_tbl_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26044 + WMI_TARGET_ROAM_TBL *reply;
26046 + if (len < sizeof(*reply)) {
26049 + reply = (WMI_TARGET_ROAM_TBL *)datap;
26050 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26052 + A_WMI_ROAM_TABLE_EVENT(wmip->wmi_devt, reply);
26058 +wmi_roam_data_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26060 + WMI_TARGET_ROAM_DATA *reply;
26062 + if (len < sizeof(*reply)) {
26065 + reply = (WMI_TARGET_ROAM_DATA *)datap;
26066 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26068 + A_WMI_ROAM_DATA_EVENT(wmip->wmi_devt, reply);
26074 +wmi_txRetryErrEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26076 + WMI_TX_RETRY_ERR_EVENT *reply;
26078 + if (len < sizeof(*reply)) {
26081 + reply = (WMI_TX_RETRY_ERR_EVENT *)datap;
26082 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26084 + A_WMI_TX_RETRY_ERR_EVENT(wmip->wmi_devt);
26090 +wmi_snrThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26092 + WMI_SNR_THRESHOLD_EVENT *reply;
26094 + if (len < sizeof(*reply)) {
26097 + reply = (WMI_SNR_THRESHOLD_EVENT *)datap;
26098 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26100 + A_WMI_SNR_THRESHOLD_EVENT_RX(wmip->wmi_devt, reply->range, reply->snr);
26106 +wmi_lqThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26108 + WMI_LQ_THRESHOLD_EVENT *reply;
26110 + if (len < sizeof(*reply)) {
26113 + reply = (WMI_LQ_THRESHOLD_EVENT *)datap;
26114 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26116 + A_WMI_LQ_THRESHOLD_EVENT_RX(wmip->wmi_devt, reply->range, reply->lq);
26122 +wmi_aplistEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26124 + A_UINT16 ap_info_entry_size;
26125 + WMI_APLIST_EVENT *ev = (WMI_APLIST_EVENT *)datap;
26126 + WMI_AP_INFO_V1 *ap_info_v1;
26129 + if (len < sizeof(WMI_APLIST_EVENT)) {
26133 + if (ev->apListVer == APLIST_VER1) {
26134 + ap_info_entry_size = sizeof(WMI_AP_INFO_V1);
26135 + ap_info_v1 = (WMI_AP_INFO_V1 *)ev->apList;
26140 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Number of APs in APLIST Event is %d\n", ev->numAP));
26141 + if (len < (int)(sizeof(WMI_APLIST_EVENT) +
26142 + (ev->numAP - 1) * ap_info_entry_size))
26148 + * AP List Ver1 Contents
26150 + for (i = 0; i < ev->numAP; i++) {
26151 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("AP#%d BSSID %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x "\
26152 + "Channel %d\n", i,
26153 + ap_info_v1->bssid[0], ap_info_v1->bssid[1],
26154 + ap_info_v1->bssid[2], ap_info_v1->bssid[3],
26155 + ap_info_v1->bssid[4], ap_info_v1->bssid[5],
26156 + ap_info_v1->channel));
26163 +wmi_dbglog_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26165 + A_UINT32 dropped;
26167 + dropped = *((A_UINT32 *)datap);
26168 + datap += sizeof(dropped);
26169 + len -= sizeof(dropped);
26170 + A_WMI_DBGLOG_EVENT(wmip->wmi_devt, dropped, datap, len);
26174 +#ifdef CONFIG_HOST_GPIO_SUPPORT
26176 +wmi_gpio_intr_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26178 + WMIX_GPIO_INTR_EVENT *gpio_intr = (WMIX_GPIO_INTR_EVENT *)datap;
26180 + A_DPRINTF(DBG_WMI,
26181 + (DBGFMT "Enter - intrmask=0x%x input=0x%x.\n", DBGARG,
26182 + gpio_intr->intr_mask, gpio_intr->input_values));
26184 + A_WMI_GPIO_INTR_RX(gpio_intr->intr_mask, gpio_intr->input_values);
26190 +wmi_gpio_data_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26192 + WMIX_GPIO_DATA_EVENT *gpio_data = (WMIX_GPIO_DATA_EVENT *)datap;
26194 + A_DPRINTF(DBG_WMI,
26195 + (DBGFMT "Enter - reg=%d value=0x%x\n", DBGARG,
26196 + gpio_data->reg_id, gpio_data->value));
26198 + A_WMI_GPIO_DATA_RX(gpio_data->reg_id, gpio_data->value);
26204 +wmi_gpio_ack_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26206 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26208 + A_WMI_GPIO_ACK_RX();
26212 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
26215 + * Called to send a wmi command. Command specific data is already built
26216 + * on osbuf and current osbuf->data points to it.
26219 +wmi_cmd_send(struct wmi_t *wmip, void *osbuf, WMI_COMMAND_ID cmdId,
26220 + WMI_SYNC_FLAG syncflag)
26222 +#define IS_LONG_CMD(cmdId) ((cmdId == WMI_OPT_TX_FRAME_CMDID) || (cmdId == WMI_ADD_WOW_PATTERN_CMDID))
26223 + WMI_CMD_HDR *cHdr;
26224 + WMI_PRI_STREAM_ID streamID = WMI_CONTROL_PRI;
26226 + A_ASSERT(osbuf != NULL);
26228 + if (syncflag >= END_WMIFLAG) {
26232 + if ((syncflag == SYNC_BEFORE_WMIFLAG) || (syncflag == SYNC_BOTH_WMIFLAG)) {
26234 + * We want to make sure all data currently queued is transmitted before
26235 + * the cmd execution. Establish a new sync point.
26237 + wmi_sync_point(wmip);
26240 + if (A_NETBUF_PUSH(osbuf, sizeof(WMI_CMD_HDR)) != A_OK) {
26241 + return A_NO_MEMORY;
26244 + cHdr = (WMI_CMD_HDR *)A_NETBUF_DATA(osbuf);
26245 + cHdr->commandId = cmdId;
26248 + * Send cmd, some via control pipe, others via data pipe
26250 + if (IS_LONG_CMD(cmdId)) {
26251 + wmi_data_hdr_add(wmip, osbuf, CNTL_MSGTYPE);
26252 + // TODO ... these can now go through the control endpoint via HTC 2.0
26253 + streamID = WMI_BEST_EFFORT_PRI;
26255 + A_WMI_CONTROL_TX(wmip->wmi_devt, osbuf, streamID);
26257 + if ((syncflag == SYNC_AFTER_WMIFLAG) || (syncflag == SYNC_BOTH_WMIFLAG)) {
26259 + * We want to make sure all new data queued waits for the command to
26260 + * execute. Establish a new sync point.
26262 + wmi_sync_point(wmip);
26265 +#undef IS_LONG_CMD
26269 +wmi_cmd_send_xtnd(struct wmi_t *wmip, void *osbuf, WMI_COMMAND_ID cmdId,
26270 + WMI_SYNC_FLAG syncflag)
26272 + WMIX_CMD_HDR *cHdr;
26274 + if (A_NETBUF_PUSH(osbuf, sizeof(WMIX_CMD_HDR)) != A_OK) {
26275 + return A_NO_MEMORY;
26278 + cHdr = (WMIX_CMD_HDR *)A_NETBUF_DATA(osbuf);
26279 + cHdr->commandId = cmdId;
26281 + return wmi_cmd_send(wmip, osbuf, WMI_EXTENSION_CMDID, syncflag);
26285 +wmi_connect_cmd(struct wmi_t *wmip, NETWORK_TYPE netType,
26286 + DOT11_AUTH_MODE dot11AuthMode, AUTH_MODE authMode,
26287 + CRYPTO_TYPE pairwiseCrypto, A_UINT8 pairwiseCryptoLen,
26288 + CRYPTO_TYPE groupCrypto,A_UINT8 groupCryptoLen,
26289 + int ssidLength, A_UCHAR *ssid,
26290 + A_UINT8 *bssid, A_UINT16 channel, A_UINT32 ctrl_flags)
26293 + WMI_CONNECT_CMD *cc;
26295 + if ((pairwiseCrypto == NONE_CRYPT) && (groupCrypto != NONE_CRYPT)) {
26298 + if ((pairwiseCrypto != NONE_CRYPT) && (groupCrypto == NONE_CRYPT)) {
26302 + osbuf = A_NETBUF_ALLOC(sizeof(WMI_CONNECT_CMD));
26303 + if (osbuf == NULL) {
26304 + return A_NO_MEMORY;
26307 + A_NETBUF_PUT(osbuf, sizeof(WMI_CONNECT_CMD));
26309 + cc = (WMI_CONNECT_CMD *)(A_NETBUF_DATA(osbuf));
26310 + A_MEMZERO(cc, sizeof(*cc));
26312 + A_MEMCPY(cc->ssid, ssid, ssidLength);
26313 + cc->ssidLength = ssidLength;
26314 + cc->networkType = netType;
26315 + cc->dot11AuthMode = dot11AuthMode;
26316 + cc->authMode = authMode;
26317 + cc->pairwiseCryptoType = pairwiseCrypto;
26318 + cc->pairwiseCryptoLen = pairwiseCryptoLen;
26319 + cc->groupCryptoType = groupCrypto;
26320 + cc->groupCryptoLen = groupCryptoLen;
26321 + cc->channel = channel;
26322 + cc->ctrl_flags = ctrl_flags;
26324 + if (bssid != NULL) {
26325 + A_MEMCPY(cc->bssid, bssid, ATH_MAC_LEN);
26327 + if (wmi_set_keepalive_cmd(wmip, wmip->wmi_keepaliveInterval) != A_OK) {
26331 + return (wmi_cmd_send(wmip, osbuf, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG));
26335 +wmi_reconnect_cmd(struct wmi_t *wmip, A_UINT8 *bssid, A_UINT16 channel)
26338 + WMI_RECONNECT_CMD *cc;
26340 + osbuf = A_NETBUF_ALLOC(sizeof(WMI_RECONNECT_CMD));
26341 + if (osbuf == NULL) {
26342 + return A_NO_MEMORY;
26345 + A_NETBUF_PUT(osbuf, sizeof(WMI_RECONNECT_CMD));
26347 + cc = (WMI_RECONNECT_CMD *)(A_NETBUF_DATA(osbuf));
26348 + A_MEMZERO(cc, sizeof(*cc));
26350 + cc->channel = channel;
26352 + if (bssid != NULL) {
26353 + A_MEMCPY(cc->bssid, bssid, ATH_MAC_LEN);
26356 + return (wmi_cmd_send(wmip, osbuf, WMI_RECONNECT_CMDID, NO_SYNC_WMIFLAG));
26360 +wmi_disconnect_cmd(struct wmi_t *wmip)
26365 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
26366 + if (osbuf == NULL) {
26367 + return A_NO_MEMORY;
26370 + /* Bug fix for 24817(elevator bug) - the disconnect command does not
26371 + need to do a SYNC before.*/
26372 + status = (wmi_cmd_send(wmip, osbuf, WMI_DISCONNECT_CMDID,
26373 + NO_SYNC_WMIFLAG));
26379 +wmi_startscan_cmd(struct wmi_t *wmip, WMI_SCAN_TYPE scanType,
26380 + A_BOOL forceFgScan, A_BOOL isLegacy,
26381 + A_UINT32 homeDwellTime, A_UINT32 forceScanInterval)
26384 + WMI_START_SCAN_CMD *sc;
26386 + if ((scanType != WMI_LONG_SCAN) && (scanType != WMI_SHORT_SCAN)) {
26390 + osbuf = A_NETBUF_ALLOC(sizeof(*sc));
26391 + if (osbuf == NULL) {
26392 + return A_NO_MEMORY;
26395 + A_NETBUF_PUT(osbuf, sizeof(*sc));
26397 + sc = (WMI_START_SCAN_CMD *)(A_NETBUF_DATA(osbuf));
26398 + sc->scanType = scanType;
26399 + sc->forceFgScan = forceFgScan;
26400 + sc->isLegacy = isLegacy;
26401 + sc->homeDwellTime = homeDwellTime;
26402 + sc->forceScanInterval = forceScanInterval;
26404 + return (wmi_cmd_send(wmip, osbuf, WMI_START_SCAN_CMDID, NO_SYNC_WMIFLAG));
26408 +wmi_scanparams_cmd(struct wmi_t *wmip, A_UINT16 fg_start_sec,
26409 + A_UINT16 fg_end_sec, A_UINT16 bg_sec,
26410 + A_UINT16 minact_chdw_msec, A_UINT16 maxact_chdw_msec,
26411 + A_UINT16 pas_chdw_msec,
26412 + A_UINT8 shScanRatio, A_UINT8 scanCtrlFlags,
26413 + A_UINT32 max_dfsch_act_time)
26416 + WMI_SCAN_PARAMS_CMD *sc;
26418 + osbuf = A_NETBUF_ALLOC(sizeof(*sc));
26419 + if (osbuf == NULL) {
26420 + return A_NO_MEMORY;
26423 + A_NETBUF_PUT(osbuf, sizeof(*sc));
26425 + sc = (WMI_SCAN_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
26426 + A_MEMZERO(sc, sizeof(*sc));
26427 + sc->fg_start_period = fg_start_sec;
26428 + sc->fg_end_period = fg_end_sec;
26429 + sc->bg_period = bg_sec;
26430 + sc->minact_chdwell_time = minact_chdw_msec;
26431 + sc->maxact_chdwell_time = maxact_chdw_msec;
26432 + sc->pas_chdwell_time = pas_chdw_msec;
26433 + sc->shortScanRatio = shScanRatio;
26434 + sc->scanCtrlFlags = scanCtrlFlags;
26435 + sc->max_dfsch_act_time = max_dfsch_act_time;
26437 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_SCAN_PARAMS_CMDID,
26438 + NO_SYNC_WMIFLAG));
26442 +wmi_bssfilter_cmd(struct wmi_t *wmip, A_UINT8 filter, A_UINT32 ieMask)
26445 + WMI_BSS_FILTER_CMD *cmd;
26447 + if (filter >= LAST_BSS_FILTER) {
26451 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26452 + if (osbuf == NULL) {
26453 + return A_NO_MEMORY;
26456 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26458 + cmd = (WMI_BSS_FILTER_CMD *)(A_NETBUF_DATA(osbuf));
26459 + A_MEMZERO(cmd, sizeof(*cmd));
26460 + cmd->bssFilter = filter;
26461 + cmd->ieMask = ieMask;
26463 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BSS_FILTER_CMDID,
26464 + NO_SYNC_WMIFLAG));
26468 +wmi_probedSsid_cmd(struct wmi_t *wmip, A_UINT8 index, A_UINT8 flag,
26469 + A_UINT8 ssidLength, A_UCHAR *ssid)
26472 + WMI_PROBED_SSID_CMD *cmd;
26474 + if (index > MAX_PROBED_SSID_INDEX) {
26477 + if (ssidLength > sizeof(cmd->ssid)) {
26480 + if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssidLength > 0)) {
26483 + if ((flag & SPECIFIC_SSID_FLAG) && !ssidLength) {
26487 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26488 + if (osbuf == NULL) {
26489 + return A_NO_MEMORY;
26492 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26494 + cmd = (WMI_PROBED_SSID_CMD *)(A_NETBUF_DATA(osbuf));
26495 + A_MEMZERO(cmd, sizeof(*cmd));
26496 + cmd->entryIndex = index;
26497 + cmd->flag = flag;
26498 + cmd->ssidLength = ssidLength;
26499 + A_MEMCPY(cmd->ssid, ssid, ssidLength);
26501 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_PROBED_SSID_CMDID,
26502 + NO_SYNC_WMIFLAG));
26506 +wmi_listeninterval_cmd(struct wmi_t *wmip, A_UINT16 listenInterval, A_UINT16 listenBeacons)
26509 + WMI_LISTEN_INT_CMD *cmd;
26511 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26512 + if (osbuf == NULL) {
26513 + return A_NO_MEMORY;
26516 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26518 + cmd = (WMI_LISTEN_INT_CMD *)(A_NETBUF_DATA(osbuf));
26519 + A_MEMZERO(cmd, sizeof(*cmd));
26520 + cmd->listenInterval = listenInterval;
26521 + cmd->numBeacons = listenBeacons;
26523 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_LISTEN_INT_CMDID,
26524 + NO_SYNC_WMIFLAG));
26528 +wmi_bmisstime_cmd(struct wmi_t *wmip, A_UINT16 bmissTime, A_UINT16 bmissBeacons)
26531 + WMI_BMISS_TIME_CMD *cmd;
26533 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26534 + if (osbuf == NULL) {
26535 + return A_NO_MEMORY;
26538 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26540 + cmd = (WMI_BMISS_TIME_CMD *)(A_NETBUF_DATA(osbuf));
26541 + A_MEMZERO(cmd, sizeof(*cmd));
26542 + cmd->bmissTime = bmissTime;
26543 + cmd->numBeacons = bmissBeacons;
26545 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BMISS_TIME_CMDID,
26546 + NO_SYNC_WMIFLAG));
26550 +wmi_associnfo_cmd(struct wmi_t *wmip, A_UINT8 ieType,
26551 + A_UINT8 ieLen, A_UINT8 *ieInfo)
26554 + WMI_SET_ASSOC_INFO_CMD *cmd;
26557 + cmdLen = sizeof(*cmd) + ieLen - 1;
26558 + osbuf = A_NETBUF_ALLOC(cmdLen);
26559 + if (osbuf == NULL) {
26560 + return A_NO_MEMORY;
26563 + A_NETBUF_PUT(osbuf, cmdLen);
26565 + cmd = (WMI_SET_ASSOC_INFO_CMD *)(A_NETBUF_DATA(osbuf));
26566 + A_MEMZERO(cmd, cmdLen);
26567 + cmd->ieType = ieType;
26568 + cmd->bufferSize = ieLen;
26569 + A_MEMCPY(cmd->assocInfo, ieInfo, ieLen);
26571 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_ASSOC_INFO_CMDID,
26572 + NO_SYNC_WMIFLAG));
26576 +wmi_powermode_cmd(struct wmi_t *wmip, A_UINT8 powerMode)
26579 + WMI_POWER_MODE_CMD *cmd;
26581 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26582 + if (osbuf == NULL) {
26583 + return A_NO_MEMORY;
26586 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26588 + cmd = (WMI_POWER_MODE_CMD *)(A_NETBUF_DATA(osbuf));
26589 + A_MEMZERO(cmd, sizeof(*cmd));
26590 + cmd->powerMode = powerMode;
26591 + wmip->wmi_powerMode = powerMode;
26593 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWER_MODE_CMDID,
26594 + NO_SYNC_WMIFLAG));
26598 +wmi_ibsspmcaps_cmd(struct wmi_t *wmip, A_UINT8 pmEnable, A_UINT8 ttl,
26599 + A_UINT16 atim_windows, A_UINT16 timeout_value)
26602 + WMI_IBSS_PM_CAPS_CMD *cmd;
26604 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26605 + if (osbuf == NULL) {
26606 + return A_NO_MEMORY;
26609 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26611 + cmd = (WMI_IBSS_PM_CAPS_CMD *)(A_NETBUF_DATA(osbuf));
26612 + A_MEMZERO(cmd, sizeof(*cmd));
26613 + cmd->power_saving = pmEnable;
26615 + cmd->atim_windows = atim_windows;
26616 + cmd->timeout_value = timeout_value;
26618 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_IBSS_PM_CAPS_CMDID,
26619 + NO_SYNC_WMIFLAG));
26623 +wmi_pmparams_cmd(struct wmi_t *wmip, A_UINT16 idlePeriod,
26624 + A_UINT16 psPollNum, A_UINT16 dtimPolicy)
26627 + WMI_POWER_PARAMS_CMD *pm;
26629 + osbuf = A_NETBUF_ALLOC(sizeof(*pm));
26630 + if (osbuf == NULL) {
26631 + return A_NO_MEMORY;
26634 + A_NETBUF_PUT(osbuf, sizeof(*pm));
26636 + pm = (WMI_POWER_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
26637 + A_MEMZERO(pm, sizeof(*pm));
26638 + pm->idle_period = idlePeriod;
26639 + pm->pspoll_number = psPollNum;
26640 + pm->dtim_policy = dtimPolicy;
26642 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWER_PARAMS_CMDID,
26643 + NO_SYNC_WMIFLAG));
26647 +wmi_disctimeout_cmd(struct wmi_t *wmip, A_UINT8 timeout)
26650 + WMI_DISC_TIMEOUT_CMD *cmd;
26652 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26653 + if (osbuf == NULL) {
26654 + return A_NO_MEMORY;
26657 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26659 + cmd = (WMI_DISC_TIMEOUT_CMD *)(A_NETBUF_DATA(osbuf));
26660 + A_MEMZERO(cmd, sizeof(*cmd));
26661 + cmd->disconnectTimeout = timeout;
26663 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_DISC_TIMEOUT_CMDID,
26664 + NO_SYNC_WMIFLAG));
26668 +wmi_addKey_cmd(struct wmi_t *wmip, A_UINT8 keyIndex, CRYPTO_TYPE keyType,
26669 + A_UINT8 keyUsage, A_UINT8 keyLength, A_UINT8 *keyRSC,
26670 + A_UINT8 *keyMaterial, A_UINT8 key_op_ctrl,
26671 + WMI_SYNC_FLAG sync_flag)
26674 + WMI_ADD_CIPHER_KEY_CMD *cmd;
26676 + if ((keyIndex > WMI_MAX_KEY_INDEX) || (keyLength > WMI_MAX_KEY_LEN) ||
26677 + (keyMaterial == NULL))
26682 + if ((WEP_CRYPT != keyType) && (NULL == keyRSC)) {
26686 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26687 + if (osbuf == NULL) {
26688 + return A_NO_MEMORY;
26691 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26693 + cmd = (WMI_ADD_CIPHER_KEY_CMD *)(A_NETBUF_DATA(osbuf));
26694 + A_MEMZERO(cmd, sizeof(*cmd));
26695 + cmd->keyIndex = keyIndex;
26696 + cmd->keyType = keyType;
26697 + cmd->keyUsage = keyUsage;
26698 + cmd->keyLength = keyLength;
26699 + A_MEMCPY(cmd->key, keyMaterial, keyLength);
26700 + if (NULL != keyRSC) {
26701 + A_MEMCPY(cmd->keyRSC, keyRSC, sizeof(cmd->keyRSC));
26703 + cmd->key_op_ctrl = key_op_ctrl;
26705 + return (wmi_cmd_send(wmip, osbuf, WMI_ADD_CIPHER_KEY_CMDID, sync_flag));
26709 +wmi_add_krk_cmd(struct wmi_t *wmip, A_UINT8 *krk)
26712 + WMI_ADD_KRK_CMD *cmd;
26714 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26716 + if (osbuf == NULL) {
26717 + return A_NO_MEMORY;
26720 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26722 + cmd = (WMI_ADD_KRK_CMD *)(A_NETBUF_DATA(osbuf));
26723 + A_MEMZERO(cmd, sizeof(*cmd));
26724 + A_MEMCPY(cmd->krk, krk, WMI_KRK_LEN);
26726 + return (wmi_cmd_send(wmip, osbuf, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG));
26730 +wmi_delete_krk_cmd(struct wmi_t *wmip)
26734 + osbuf = A_NETBUF_ALLOC(0);
26736 + if (osbuf == NULL) {
26737 + return A_NO_MEMORY;
26740 + return (wmi_cmd_send(wmip, osbuf, WMI_DELETE_KRK_CMDID, NO_SYNC_WMIFLAG));
26744 +wmi_deleteKey_cmd(struct wmi_t *wmip, A_UINT8 keyIndex)
26747 + WMI_DELETE_CIPHER_KEY_CMD *cmd;
26749 + if (keyIndex > WMI_MAX_KEY_INDEX) {
26753 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26754 + if (osbuf == NULL) {
26755 + return A_NO_MEMORY;
26758 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26760 + cmd = (WMI_DELETE_CIPHER_KEY_CMD *)(A_NETBUF_DATA(osbuf));
26761 + A_MEMZERO(cmd, sizeof(*cmd));
26762 + cmd->keyIndex = keyIndex;
26764 + return (wmi_cmd_send(wmip, osbuf, WMI_DELETE_CIPHER_KEY_CMDID,
26765 + NO_SYNC_WMIFLAG));
26769 +wmi_setPmkid_cmd(struct wmi_t *wmip, A_UINT8 *bssid, A_UINT8 *pmkId,
26773 + WMI_SET_PMKID_CMD *cmd;
26775 + if (bssid == NULL) {
26779 + if ((set == TRUE) && (pmkId == NULL)) {
26783 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26784 + if (osbuf == NULL) {
26785 + return A_NO_MEMORY;
26788 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26790 + cmd = (WMI_SET_PMKID_CMD *)(A_NETBUF_DATA(osbuf));
26791 + A_MEMCPY(cmd->bssid, bssid, sizeof(cmd->bssid));
26792 + if (set == TRUE) {
26793 + A_MEMCPY(cmd->pmkid, pmkId, sizeof(cmd->pmkid));
26794 + cmd->enable = PMKID_ENABLE;
26796 + A_MEMZERO(cmd->pmkid, sizeof(cmd->pmkid));
26797 + cmd->enable = PMKID_DISABLE;
26800 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_PMKID_CMDID, NO_SYNC_WMIFLAG));
26804 +wmi_set_tkip_countermeasures_cmd(struct wmi_t *wmip, A_BOOL en)
26807 + WMI_SET_TKIP_COUNTERMEASURES_CMD *cmd;
26809 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26810 + if (osbuf == NULL) {
26811 + return A_NO_MEMORY;
26814 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26816 + cmd = (WMI_SET_TKIP_COUNTERMEASURES_CMD *)(A_NETBUF_DATA(osbuf));
26817 + cmd->cm_en = (en == TRUE)? WMI_TKIP_CM_ENABLE : WMI_TKIP_CM_DISABLE;
26819 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_TKIP_COUNTERMEASURES_CMDID,
26820 + NO_SYNC_WMIFLAG));
26824 +wmi_set_akmp_params_cmd(struct wmi_t *wmip,
26825 + WMI_SET_AKMP_PARAMS_CMD *akmpParams)
26828 + WMI_SET_AKMP_PARAMS_CMD *cmd;
26830 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26831 + if (osbuf == NULL) {
26832 + return A_NO_MEMORY;
26835 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26836 + cmd = (WMI_SET_AKMP_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
26837 + cmd->akmpInfo = akmpParams->akmpInfo;
26839 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_AKMP_PARAMS_CMDID,
26840 + NO_SYNC_WMIFLAG));
26844 +wmi_set_pmkid_list_cmd(struct wmi_t *wmip,
26845 + WMI_SET_PMKID_LIST_CMD *pmkInfo)
26848 + WMI_SET_PMKID_LIST_CMD *cmd;
26852 + cmdLen = sizeof(pmkInfo->numPMKID) +
26853 + pmkInfo->numPMKID * sizeof(WMI_PMKID);
26855 + osbuf = A_NETBUF_ALLOC(cmdLen);
26857 + if (osbuf == NULL) {
26858 + return A_NO_MEMORY;
26861 + A_NETBUF_PUT(osbuf, cmdLen);
26862 + cmd = (WMI_SET_PMKID_LIST_CMD *)(A_NETBUF_DATA(osbuf));
26863 + cmd->numPMKID = pmkInfo->numPMKID;
26865 + for (i = 0; i < cmd->numPMKID; i++) {
26866 + A_MEMCPY(&cmd->pmkidList[i], &pmkInfo->pmkidList[i],
26870 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_PMKID_LIST_CMDID,
26871 + NO_SYNC_WMIFLAG));
26875 +wmi_get_pmkid_list_cmd(struct wmi_t *wmip)
26879 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
26880 + if (osbuf == NULL) {
26881 + return A_NO_MEMORY;
26884 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_PMKID_LIST_CMDID,
26885 + NO_SYNC_WMIFLAG));
26889 +wmi_dataSync_send(struct wmi_t *wmip, void *osbuf, WMI_PRI_STREAM_ID streamID)
26891 + WMI_DATA_HDR *dtHdr;
26893 + A_ASSERT(streamID != WMI_CONTROL_PRI);
26894 + A_ASSERT(osbuf != NULL);
26896 + if (A_NETBUF_PUSH(osbuf, sizeof(WMI_DATA_HDR)) != A_OK) {
26897 + return A_NO_MEMORY;
26900 + dtHdr = (WMI_DATA_HDR *)A_NETBUF_DATA(osbuf);
26902 + (SYNC_MSGTYPE & WMI_DATA_HDR_MSG_TYPE_MASK) << WMI_DATA_HDR_MSG_TYPE_SHIFT;
26904 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter - streamID %d\n", DBGARG, streamID));
26906 + return (A_WMI_CONTROL_TX(wmip->wmi_devt, osbuf, streamID));
26909 +typedef struct _WMI_DATA_SYNC_BUFS {
26910 + A_UINT8 trafficClass;
26912 +}WMI_DATA_SYNC_BUFS;
26915 +wmi_sync_point(struct wmi_t *wmip)
26918 + WMI_DATA_SYNC_BUFS dataSyncBufs[WMM_NUM_AC];
26919 + A_UINT8 i,numPriStreams=0;
26922 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26924 + memset(dataSyncBufs,0,sizeof(dataSyncBufs));
26926 + /* lock out while we walk through the priority list and assemble our local array */
26929 + for (i=0; i < WMM_NUM_AC ; i++) {
26930 + if (wmip->wmi_fatPipeExists & (1 << i)) {
26932 + dataSyncBufs[numPriStreams-1].trafficClass = i;
26936 + UNLOCK_WMI(wmip);
26938 + /* dataSyncBufs is now filled with entries (starting at index 0) containing valid streamIDs */
26942 + * We allocate all network buffers needed so we will be able to
26943 + * send all required frames.
26945 + cmd_osbuf = A_NETBUF_ALLOC(0); /* no payload */
26946 + if (cmd_osbuf == NULL) {
26947 + status = A_NO_MEMORY;
26951 + for (i=0; i < numPriStreams ; i++) {
26952 + dataSyncBufs[i].osbuf = A_NETBUF_ALLOC(0);
26953 + if (dataSyncBufs[i].osbuf == NULL) {
26954 + status = A_NO_MEMORY;
26960 + * Send sync cmd followed by sync data messages on all endpoints being
26963 + status = wmi_cmd_send(wmip, cmd_osbuf, WMI_SYNCHRONIZE_CMDID,
26964 + NO_SYNC_WMIFLAG);
26966 + if (A_FAILED(status)) {
26969 + /* cmd buffer sent, we no longer own it */
26970 + cmd_osbuf = NULL;
26972 + for(i=0; i < numPriStreams; i++) {
26973 + A_ASSERT(dataSyncBufs[i].osbuf != NULL);
26975 + status = wmi_dataSync_send(wmip, dataSyncBufs[i].osbuf,
26976 + WMI_ACCESSCATEGORY_WMISTREAM(wmip,dataSyncBufs[i].trafficClass));
26978 + if (A_FAILED(status)) {
26981 + /* we don't own this buffer anymore, NULL it out of the array so it
26982 + * won't get cleaned up */
26983 + dataSyncBufs[i].osbuf = NULL;
26988 + /* free up any resources left over (possibly due to an error) */
26990 + if (cmd_osbuf != NULL) {
26991 + A_NETBUF_FREE(cmd_osbuf);
26994 + for (i = 0; i < numPriStreams; i++) {
26995 + if (dataSyncBufs[i].osbuf != NULL) {
26996 + A_NETBUF_FREE(dataSyncBufs[i].osbuf);
27004 +wmi_create_pstream_cmd(struct wmi_t *wmip, WMI_CREATE_PSTREAM_CMD *params)
27007 + WMI_CREATE_PSTREAM_CMD *cmd;
27008 + A_UINT16 activeTsids=0;
27009 + A_UINT8 fatPipeExistsForAC=0;
27011 + /* Validate all the parameters. */
27012 + if( !((params->userPriority < 8) &&
27013 + (params->userPriority <= 0x7) &&
27014 + (convert_userPriority_to_trafficClass(params->userPriority) == params->trafficClass) &&
27015 + (params->trafficDirection == UPLINK_TRAFFIC ||
27016 + params->trafficDirection == DNLINK_TRAFFIC ||
27017 + params->trafficDirection == BIDIR_TRAFFIC) &&
27018 + (params->trafficType == TRAFFIC_TYPE_APERIODIC ||
27019 + params->trafficType == TRAFFIC_TYPE_PERIODIC ) &&
27020 + (params->voicePSCapability == DISABLE_FOR_THIS_AC ||
27021 + params->voicePSCapability == ENABLE_FOR_THIS_AC ||
27022 + params->voicePSCapability == ENABLE_FOR_ALL_AC) &&
27023 + (params->tsid == WMI_IMPLICIT_PSTREAM || params->tsid <= WMI_MAX_THINSTREAM)) )
27028 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27029 + if (osbuf == NULL) {
27030 + return A_NO_MEMORY;
27033 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27035 + A_DPRINTF(DBG_WMI,
27036 + (DBGFMT "Sending create_pstream_cmd: ac=%d tsid:%d\n", DBGARG,
27037 + params->trafficClass, params->tsid));
27039 + cmd = (WMI_CREATE_PSTREAM_CMD *)(A_NETBUF_DATA(osbuf));
27040 + A_MEMZERO(cmd, sizeof(*cmd));
27041 + A_MEMCPY(cmd, params, sizeof(*cmd));
27043 + /* this is an implicitly created Fat pipe */
27044 + if (params->tsid == WMI_IMPLICIT_PSTREAM) {
27046 + fatPipeExistsForAC = (wmip->wmi_fatPipeExists & (1 << params->trafficClass));
27047 + wmip->wmi_fatPipeExists |= (1<<params->trafficClass);
27048 + UNLOCK_WMI(wmip);
27050 + /* this is an explicitly created thin stream within a fat pipe */
27052 + fatPipeExistsForAC = (wmip->wmi_fatPipeExists & (1 << params->trafficClass));
27053 + activeTsids = wmip->wmi_streamExistsForAC[params->trafficClass];
27054 + wmip->wmi_streamExistsForAC[params->trafficClass] |= (1<<params->tsid);
27055 + /* if a thinstream becomes active, the fat pipe automatically
27058 + wmip->wmi_fatPipeExists |= (1<<params->trafficClass);
27059 + UNLOCK_WMI(wmip);
27062 + /* Indicate activty change to driver layer only if this is the
27063 + * first TSID to get created in this AC explicitly or an implicit
27064 + * fat pipe is getting created.
27066 + if (!fatPipeExistsForAC) {
27067 + A_WMI_STREAM_TX_ACTIVE(wmip->wmi_devt, params->trafficClass);
27070 + /* mike: should be SYNC_BEFORE_WMIFLAG */
27071 + return (wmi_cmd_send(wmip, osbuf, WMI_CREATE_PSTREAM_CMDID,
27072 + NO_SYNC_WMIFLAG));
27076 +wmi_delete_pstream_cmd(struct wmi_t *wmip, A_UINT8 trafficClass, A_UINT8 tsid)
27079 + WMI_DELETE_PSTREAM_CMD *cmd;
27081 + A_UINT16 activeTsids=0;
27083 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27084 + if (osbuf == NULL) {
27085 + return A_NO_MEMORY;
27088 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27090 + cmd = (WMI_DELETE_PSTREAM_CMD *)(A_NETBUF_DATA(osbuf));
27091 + A_MEMZERO(cmd, sizeof(*cmd));
27093 + cmd->trafficClass = trafficClass;
27094 + cmd->tsid = tsid;
27097 + activeTsids = wmip->wmi_streamExistsForAC[trafficClass];
27098 + UNLOCK_WMI(wmip);
27100 + /* Check if the tsid was created & exists */
27101 + if (!(activeTsids & (1<<tsid))) {
27103 + A_DPRINTF(DBG_WMI,
27104 + (DBGFMT "TSID %d does'nt exist for trafficClass: %d\n", DBGARG, tsid, trafficClass));
27105 + /* TODO: return a more appropriate err code */
27109 + A_DPRINTF(DBG_WMI,
27110 + (DBGFMT "Sending delete_pstream_cmd: trafficClass: %d tsid=%d\n", DBGARG, trafficClass, tsid));
27112 + status = (wmi_cmd_send(wmip, osbuf, WMI_DELETE_PSTREAM_CMDID,
27113 + SYNC_BEFORE_WMIFLAG));
27116 + wmip->wmi_streamExistsForAC[trafficClass] &= ~(1<<tsid);
27117 + activeTsids = wmip->wmi_streamExistsForAC[trafficClass];
27118 + UNLOCK_WMI(wmip);
27121 + /* Indicate stream inactivity to driver layer only if all tsids
27122 + * within this AC are deleted.
27124 + if(!activeTsids) {
27125 + A_WMI_STREAM_TX_INACTIVE(wmip->wmi_devt, trafficClass);
27126 + wmip->wmi_fatPipeExists &= ~(1<<trafficClass);
27133 + * used to set the bit rate. rate is in Kbps. If rate == -1
27134 + * then auto selection is used.
27137 +wmi_set_bitrate_cmd(struct wmi_t *wmip, A_INT32 rate)
27140 + WMI_BIT_RATE_CMD *cmd;
27143 + if (rate != -1) {
27144 + index = wmi_validate_bitrate(wmip, rate);
27145 + if(index == A_EINVAL){
27152 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27153 + if (osbuf == NULL) {
27154 + return A_NO_MEMORY;
27157 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27159 + cmd = (WMI_BIT_RATE_CMD *)(A_NETBUF_DATA(osbuf));
27160 + A_MEMZERO(cmd, sizeof(*cmd));
27162 + cmd->rateIndex = index;
27164 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BITRATE_CMDID, NO_SYNC_WMIFLAG));
27168 +wmi_get_bitrate_cmd(struct wmi_t *wmip)
27172 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27173 + if (osbuf == NULL) {
27174 + return A_NO_MEMORY;
27177 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_BITRATE_CMDID, NO_SYNC_WMIFLAG));
27181 + * Returns TRUE iff the given rate index is legal in the current PHY mode.
27184 +wmi_is_bitrate_index_valid(struct wmi_t *wmip, A_UINT32 rateIndex)
27186 + WMI_PHY_MODE phyMode = wmip->wmi_phyMode;
27187 + A_BOOL isValid = TRUE;
27188 + switch(phyMode) {
27189 + case WMI_11A_MODE:
27190 + if ((rateIndex < MODE_A_SUPPORT_RATE_START) || (rateIndex > MODE_A_SUPPORT_RATE_STOP)) {
27195 + case WMI_11B_MODE:
27196 + if ((rateIndex < MODE_B_SUPPORT_RATE_START) || (rateIndex > MODE_B_SUPPORT_RATE_STOP)) {
27201 + case WMI_11GONLY_MODE:
27202 + if ((rateIndex < MODE_GONLY_SUPPORT_RATE_START) || (rateIndex > MODE_GONLY_SUPPORT_RATE_STOP)) {
27207 + case WMI_11G_MODE:
27208 + case WMI_11AG_MODE:
27209 + if ((rateIndex < MODE_G_SUPPORT_RATE_START) || (rateIndex > MODE_G_SUPPORT_RATE_STOP)) {
27223 +wmi_validate_bitrate(struct wmi_t *wmip, A_INT32 rate)
27230 + if (wmi_rateTable[(A_UINT32) i] == 0) {
27233 + if (wmi_rateTable[(A_UINT32) i] == rate) {
27242 + if(wmi_is_bitrate_index_valid(wmip, i) != TRUE) {
27250 +wmi_set_fixrates_cmd(struct wmi_t *wmip, A_INT16 fixRatesMask)
27253 + WMI_FIX_RATES_CMD *cmd;
27254 + A_UINT32 rateIndex;
27256 + /* Make sure all rates in the mask are valid in the current PHY mode */
27257 + for(rateIndex = 0; rateIndex < MAX_NUMBER_OF_SUPPORT_RATES; rateIndex++) {
27258 + if((1 << rateIndex) & (A_UINT32)fixRatesMask) {
27259 + if(wmi_is_bitrate_index_valid(wmip, rateIndex) != TRUE) {
27260 + A_DPRINTF(DBG_WMI, (DBGFMT "Set Fix Rates command failed: Given rate is illegal in current PHY mode\n", DBGARG));
27267 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27268 + if (osbuf == NULL) {
27269 + return A_NO_MEMORY;
27272 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27274 + cmd = (WMI_FIX_RATES_CMD *)(A_NETBUF_DATA(osbuf));
27275 + A_MEMZERO(cmd, sizeof(*cmd));
27277 + cmd->fixRateMask = fixRatesMask;
27279 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_FIXRATES_CMDID, NO_SYNC_WMIFLAG));
27283 +wmi_get_ratemask_cmd(struct wmi_t *wmip)
27287 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27288 + if (osbuf == NULL) {
27289 + return A_NO_MEMORY;
27292 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_FIXRATES_CMDID, NO_SYNC_WMIFLAG));
27296 +wmi_get_channelList_cmd(struct wmi_t *wmip)
27300 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27301 + if (osbuf == NULL) {
27302 + return A_NO_MEMORY;
27305 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_CHANNEL_LIST_CMDID,
27306 + NO_SYNC_WMIFLAG));
27310 + * used to generate a wmi sey channel Parameters cmd.
27311 + * mode should always be specified and corresponds to the phy mode of the
27313 + * numChan should alway sbe specified. If zero indicates that all available
27314 + * channels should be used.
27315 + * channelList is an array of channel frequencies (in Mhz) which the radio
27316 + * should limit its operation to. It should be NULL if numChan == 0. Size of
27317 + * array should correspond to numChan entries.
27320 +wmi_set_channelParams_cmd(struct wmi_t *wmip, A_UINT8 scanParam,
27321 + WMI_PHY_MODE mode, A_INT8 numChan,
27322 + A_UINT16 *channelList)
27325 + WMI_CHANNEL_PARAMS_CMD *cmd;
27328 + size = sizeof (*cmd);
27331 + if (numChan > WMI_MAX_CHANNELS) {
27334 + size += sizeof(A_UINT16) * (numChan - 1);
27337 + osbuf = A_NETBUF_ALLOC(size);
27338 + if (osbuf == NULL) {
27339 + return A_NO_MEMORY;
27342 + A_NETBUF_PUT(osbuf, size);
27344 + cmd = (WMI_CHANNEL_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
27345 + A_MEMZERO(cmd, size);
27347 + wmip->wmi_phyMode = mode;
27348 + cmd->scanParam = scanParam;
27349 + cmd->phyMode = mode;
27350 + cmd->numChannels = numChan;
27351 + A_MEMCPY(cmd->channelList, channelList, numChan * sizeof(A_UINT16));
27353 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_CHANNEL_PARAMS_CMDID,
27354 + NO_SYNC_WMIFLAG));
27358 +wmi_set_rssi_threshold_params(struct wmi_t *wmip,
27359 + WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd)
27363 + WMI_RSSI_THRESHOLD_PARAMS_CMD *cmd;
27364 + /* These values are in ascending order */
27365 + if( rssiCmd->thresholdAbove6_Val <= rssiCmd->thresholdAbove5_Val ||
27366 + rssiCmd->thresholdAbove5_Val <= rssiCmd->thresholdAbove4_Val ||
27367 + rssiCmd->thresholdAbove4_Val <= rssiCmd->thresholdAbove3_Val ||
27368 + rssiCmd->thresholdAbove3_Val <= rssiCmd->thresholdAbove2_Val ||
27369 + rssiCmd->thresholdAbove2_Val <= rssiCmd->thresholdAbove1_Val ||
27370 + rssiCmd->thresholdBelow6_Val <= rssiCmd->thresholdBelow5_Val ||
27371 + rssiCmd->thresholdBelow5_Val <= rssiCmd->thresholdBelow4_Val ||
27372 + rssiCmd->thresholdBelow4_Val <= rssiCmd->thresholdBelow3_Val ||
27373 + rssiCmd->thresholdBelow3_Val <= rssiCmd->thresholdBelow2_Val ||
27374 + rssiCmd->thresholdBelow2_Val <= rssiCmd->thresholdBelow1_Val) {
27379 + size = sizeof (*cmd);
27381 + osbuf = A_NETBUF_ALLOC(size);
27382 + if (osbuf == NULL) {
27383 + return A_NO_MEMORY;
27386 + A_NETBUF_PUT(osbuf, size);
27388 + cmd = (WMI_RSSI_THRESHOLD_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
27389 + A_MEMZERO(cmd, size);
27390 + A_MEMCPY(cmd, rssiCmd, sizeof(WMI_RSSI_THRESHOLD_PARAMS_CMD));
27392 + return (wmi_cmd_send(wmip, osbuf, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
27393 + NO_SYNC_WMIFLAG));
27397 +wmi_set_host_sleep_mode_cmd(struct wmi_t *wmip,
27398 + WMI_SET_HOST_SLEEP_MODE_CMD *hostModeCmd)
27402 + WMI_SET_HOST_SLEEP_MODE_CMD *cmd;
27404 + if( hostModeCmd->awake == hostModeCmd->asleep) {
27408 + size = sizeof (*cmd);
27410 + osbuf = A_NETBUF_ALLOC(size);
27411 + if (osbuf == NULL) {
27412 + return A_NO_MEMORY;
27415 + A_NETBUF_PUT(osbuf, size);
27417 + cmd = (WMI_SET_HOST_SLEEP_MODE_CMD *)(A_NETBUF_DATA(osbuf));
27418 + A_MEMZERO(cmd, size);
27419 + A_MEMCPY(cmd, hostModeCmd, sizeof(WMI_SET_HOST_SLEEP_MODE_CMD));
27421 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_HOST_SLEEP_MODE_CMDID,
27422 + NO_SYNC_WMIFLAG));
27426 +wmi_set_wow_mode_cmd(struct wmi_t *wmip,
27427 + WMI_SET_WOW_MODE_CMD *wowModeCmd)
27431 + WMI_SET_WOW_MODE_CMD *cmd;
27433 + size = sizeof (*cmd);
27435 + osbuf = A_NETBUF_ALLOC(size);
27436 + if (osbuf == NULL) {
27437 + return A_NO_MEMORY;
27440 + A_NETBUF_PUT(osbuf, size);
27442 + cmd = (WMI_SET_WOW_MODE_CMD *)(A_NETBUF_DATA(osbuf));
27443 + A_MEMZERO(cmd, size);
27444 + A_MEMCPY(cmd, wowModeCmd, sizeof(WMI_SET_WOW_MODE_CMD));
27446 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WOW_MODE_CMDID,
27447 + NO_SYNC_WMIFLAG));
27452 +wmi_get_wow_list_cmd(struct wmi_t *wmip,
27453 + WMI_GET_WOW_LIST_CMD *wowListCmd)
27457 + WMI_GET_WOW_LIST_CMD *cmd;
27459 + size = sizeof (*cmd);
27461 + osbuf = A_NETBUF_ALLOC(size);
27462 + if (osbuf == NULL) {
27463 + return A_NO_MEMORY;
27466 + A_NETBUF_PUT(osbuf, size);
27468 + cmd = (WMI_GET_WOW_LIST_CMD *)(A_NETBUF_DATA(osbuf));
27469 + A_MEMZERO(cmd, size);
27470 + A_MEMCPY(cmd, wowListCmd, sizeof(WMI_GET_WOW_LIST_CMD));
27472 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_WOW_LIST_CMDID,
27473 + NO_SYNC_WMIFLAG));
27478 +wmi_get_wow_list_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
27480 + WMI_GET_WOW_LIST_REPLY *reply;
27482 + if (len < sizeof(WMI_GET_WOW_LIST_REPLY)) {
27485 + reply = (WMI_GET_WOW_LIST_REPLY *)datap;
27487 + A_WMI_WOW_LIST_EVENT(wmip->wmi_devt, reply->num_filters,
27493 +A_STATUS wmi_add_wow_pattern_cmd(struct wmi_t *wmip,
27494 + WMI_ADD_WOW_PATTERN_CMD *addWowCmd,
27495 + A_UINT8* pattern, A_UINT8* mask,
27496 + A_UINT8 pattern_size)
27500 + WMI_ADD_WOW_PATTERN_CMD *cmd;
27501 + A_UINT8 *filter_mask = NULL;
27503 + size = sizeof (*cmd);
27505 + size += ((2 * addWowCmd->filter_size)* sizeof(A_UINT8));
27506 + osbuf = A_NETBUF_ALLOC(size);
27507 + if (osbuf == NULL) {
27508 + return A_NO_MEMORY;
27511 + A_NETBUF_PUT(osbuf, size);
27513 + cmd = (WMI_ADD_WOW_PATTERN_CMD *)(A_NETBUF_DATA(osbuf));
27514 + cmd->filter_list_id = addWowCmd->filter_list_id;
27515 + cmd->filter_offset = addWowCmd->filter_offset;
27516 + cmd->filter_size = addWowCmd->filter_size;
27518 + A_MEMCPY(cmd->filter, pattern, addWowCmd->filter_size);
27520 + filter_mask = (A_UINT8*)(cmd->filter + cmd->filter_size);
27521 + A_MEMCPY(filter_mask, mask, addWowCmd->filter_size);
27524 + return (wmi_cmd_send(wmip, osbuf, WMI_ADD_WOW_PATTERN_CMDID,
27525 + NO_SYNC_WMIFLAG));
27529 +wmi_del_wow_pattern_cmd(struct wmi_t *wmip,
27530 + WMI_DEL_WOW_PATTERN_CMD *delWowCmd)
27534 + WMI_DEL_WOW_PATTERN_CMD *cmd;
27536 + size = sizeof (*cmd);
27538 + osbuf = A_NETBUF_ALLOC(size);
27539 + if (osbuf == NULL) {
27540 + return A_NO_MEMORY;
27543 + A_NETBUF_PUT(osbuf, size);
27545 + cmd = (WMI_DEL_WOW_PATTERN_CMD *)(A_NETBUF_DATA(osbuf));
27546 + A_MEMZERO(cmd, size);
27547 + A_MEMCPY(cmd, delWowCmd, sizeof(WMI_DEL_WOW_PATTERN_CMD));
27549 + return (wmi_cmd_send(wmip, osbuf, WMI_DEL_WOW_PATTERN_CMDID,
27550 + NO_SYNC_WMIFLAG));
27555 +wmi_set_snr_threshold_params(struct wmi_t *wmip,
27556 + WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd)
27560 + WMI_SNR_THRESHOLD_PARAMS_CMD *cmd;
27561 + /* These values are in ascending order */
27562 + if( snrCmd->thresholdAbove4_Val <= snrCmd->thresholdAbove3_Val ||
27563 + snrCmd->thresholdAbove3_Val <= snrCmd->thresholdAbove2_Val ||
27564 + snrCmd->thresholdAbove2_Val <= snrCmd->thresholdAbove1_Val ||
27565 + snrCmd->thresholdBelow4_Val <= snrCmd->thresholdBelow3_Val ||
27566 + snrCmd->thresholdBelow3_Val <= snrCmd->thresholdBelow2_Val ||
27567 + snrCmd->thresholdBelow2_Val <= snrCmd->thresholdBelow1_Val) {
27572 + size = sizeof (*cmd);
27574 + osbuf = A_NETBUF_ALLOC(size);
27575 + if (osbuf == NULL) {
27576 + return A_NO_MEMORY;
27579 + A_NETBUF_PUT(osbuf, size);
27581 + cmd = (WMI_SNR_THRESHOLD_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
27582 + A_MEMZERO(cmd, size);
27583 + A_MEMCPY(cmd, snrCmd, sizeof(WMI_SNR_THRESHOLD_PARAMS_CMD));
27585 + return (wmi_cmd_send(wmip, osbuf, WMI_SNR_THRESHOLD_PARAMS_CMDID,
27586 + NO_SYNC_WMIFLAG));
27590 +wmi_clr_rssi_snr(struct wmi_t *wmip)
27594 + osbuf = A_NETBUF_ALLOC(sizeof(int));
27595 + if (osbuf == NULL) {
27596 + return A_NO_MEMORY;
27599 + return (wmi_cmd_send(wmip, osbuf, WMI_CLR_RSSI_SNR_CMDID,
27600 + NO_SYNC_WMIFLAG));
27604 +wmi_set_lq_threshold_params(struct wmi_t *wmip,
27605 + WMI_LQ_THRESHOLD_PARAMS_CMD *lqCmd)
27609 + WMI_LQ_THRESHOLD_PARAMS_CMD *cmd;
27610 + /* These values are in ascending order */
27611 + if( lqCmd->thresholdAbove4_Val <= lqCmd->thresholdAbove3_Val ||
27612 + lqCmd->thresholdAbove3_Val <= lqCmd->thresholdAbove2_Val ||
27613 + lqCmd->thresholdAbove2_Val <= lqCmd->thresholdAbove1_Val ||
27614 + lqCmd->thresholdBelow4_Val <= lqCmd->thresholdBelow3_Val ||
27615 + lqCmd->thresholdBelow3_Val <= lqCmd->thresholdBelow2_Val ||
27616 + lqCmd->thresholdBelow2_Val <= lqCmd->thresholdBelow1_Val ) {
27621 + size = sizeof (*cmd);
27623 + osbuf = A_NETBUF_ALLOC(size);
27624 + if (osbuf == NULL) {
27625 + return A_NO_MEMORY;
27628 + A_NETBUF_PUT(osbuf, size);
27630 + cmd = (WMI_LQ_THRESHOLD_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
27631 + A_MEMZERO(cmd, size);
27632 + A_MEMCPY(cmd, lqCmd, sizeof(WMI_LQ_THRESHOLD_PARAMS_CMD));
27634 + return (wmi_cmd_send(wmip, osbuf, WMI_LQ_THRESHOLD_PARAMS_CMDID,
27635 + NO_SYNC_WMIFLAG));
27639 +wmi_set_error_report_bitmask(struct wmi_t *wmip, A_UINT32 mask)
27643 + WMI_TARGET_ERROR_REPORT_BITMASK *cmd;
27645 + size = sizeof (*cmd);
27647 + osbuf = A_NETBUF_ALLOC(size);
27648 + if (osbuf == NULL) {
27649 + return A_NO_MEMORY;
27652 + A_NETBUF_PUT(osbuf, size);
27654 + cmd = (WMI_TARGET_ERROR_REPORT_BITMASK *)(A_NETBUF_DATA(osbuf));
27655 + A_MEMZERO(cmd, size);
27657 + cmd->bitmask = mask;
27659 + return (wmi_cmd_send(wmip, osbuf, WMI_TARGET_ERROR_REPORT_BITMASK_CMDID,
27660 + NO_SYNC_WMIFLAG));
27664 +wmi_get_challenge_resp_cmd(struct wmi_t *wmip, A_UINT32 cookie, A_UINT32 source)
27667 + WMIX_HB_CHALLENGE_RESP_CMD *cmd;
27669 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27670 + if (osbuf == NULL) {
27671 + return A_NO_MEMORY;
27674 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27676 + cmd = (WMIX_HB_CHALLENGE_RESP_CMD *)(A_NETBUF_DATA(osbuf));
27677 + cmd->cookie = cookie;
27678 + cmd->source = source;
27680 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_HB_CHALLENGE_RESP_CMDID,
27681 + NO_SYNC_WMIFLAG));
27685 +wmi_config_debug_module_cmd(struct wmi_t *wmip, A_UINT16 mmask,
27686 + A_UINT16 tsr, A_BOOL rep, A_UINT16 size,
27690 + WMIX_DBGLOG_CFG_MODULE_CMD *cmd;
27692 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27693 + if (osbuf == NULL) {
27694 + return A_NO_MEMORY;
27697 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27699 + cmd = (WMIX_DBGLOG_CFG_MODULE_CMD *)(A_NETBUF_DATA(osbuf));
27700 + cmd->config.cfgmmask = mmask;
27701 + cmd->config.cfgtsr = tsr;
27702 + cmd->config.cfgrep = rep;
27703 + cmd->config.cfgsize = size;
27704 + cmd->config.cfgvalid = valid;
27706 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DBGLOG_CFG_MODULE_CMDID,
27707 + NO_SYNC_WMIFLAG));
27711 +wmi_get_stats_cmd(struct wmi_t *wmip)
27715 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27716 + if (osbuf == NULL) {
27717 + return A_NO_MEMORY;
27720 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_STATISTICS_CMDID,
27721 + NO_SYNC_WMIFLAG));
27725 +wmi_addBadAp_cmd(struct wmi_t *wmip, A_UINT8 apIndex, A_UINT8 *bssid)
27728 + WMI_ADD_BAD_AP_CMD *cmd;
27730 + if ((bssid == NULL) || (apIndex > WMI_MAX_BAD_AP_INDEX)) {
27734 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27735 + if (osbuf == NULL) {
27736 + return A_NO_MEMORY;
27739 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27741 + cmd = (WMI_ADD_BAD_AP_CMD *)(A_NETBUF_DATA(osbuf));
27742 + cmd->badApIndex = apIndex;
27743 + A_MEMCPY(cmd->bssid, bssid, sizeof(cmd->bssid));
27745 + return (wmi_cmd_send(wmip, osbuf, WMI_ADD_BAD_AP_CMDID, NO_SYNC_WMIFLAG));
27749 +wmi_deleteBadAp_cmd(struct wmi_t *wmip, A_UINT8 apIndex)
27752 + WMI_DELETE_BAD_AP_CMD *cmd;
27754 + if (apIndex > WMI_MAX_BAD_AP_INDEX) {
27758 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27759 + if (osbuf == NULL) {
27760 + return A_NO_MEMORY;
27763 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27765 + cmd = (WMI_DELETE_BAD_AP_CMD *)(A_NETBUF_DATA(osbuf));
27766 + cmd->badApIndex = apIndex;
27768 + return (wmi_cmd_send(wmip, osbuf, WMI_DELETE_BAD_AP_CMDID,
27769 + NO_SYNC_WMIFLAG));
27773 +wmi_set_txPwr_cmd(struct wmi_t *wmip, A_UINT8 dbM)
27776 + WMI_SET_TX_PWR_CMD *cmd;
27778 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27779 + if (osbuf == NULL) {
27780 + return A_NO_MEMORY;
27783 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27785 + cmd = (WMI_SET_TX_PWR_CMD *)(A_NETBUF_DATA(osbuf));
27788 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_TX_PWR_CMDID, NO_SYNC_WMIFLAG));
27792 +wmi_get_txPwr_cmd(struct wmi_t *wmip)
27796 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27797 + if (osbuf == NULL) {
27798 + return A_NO_MEMORY;
27801 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_TX_PWR_CMDID, NO_SYNC_WMIFLAG));
27805 +wmi_get_mapped_qos_queue(struct wmi_t *wmip, A_UINT8 trafficClass)
27807 + A_UINT16 activeTsids=0;
27810 + activeTsids = wmip->wmi_streamExistsForAC[trafficClass];
27811 + UNLOCK_WMI(wmip);
27813 + return activeTsids;
27817 +wmi_get_roam_tbl_cmd(struct wmi_t *wmip)
27821 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27822 + if (osbuf == NULL) {
27823 + return A_NO_MEMORY;
27826 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_ROAM_TBL_CMDID,
27827 + NO_SYNC_WMIFLAG));
27831 +wmi_get_roam_data_cmd(struct wmi_t *wmip, A_UINT8 roamDataType)
27834 + A_UINT32 size = sizeof(A_UINT8);
27835 + WMI_TARGET_ROAM_DATA *cmd;
27837 + osbuf = A_NETBUF_ALLOC(size); /* no payload */
27838 + if (osbuf == NULL) {
27839 + return A_NO_MEMORY;
27842 + A_NETBUF_PUT(osbuf, size);
27844 + cmd = (WMI_TARGET_ROAM_DATA *)(A_NETBUF_DATA(osbuf));
27845 + cmd->roamDataType = roamDataType;
27847 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_ROAM_DATA_CMDID,
27848 + NO_SYNC_WMIFLAG));
27852 +wmi_set_roam_ctrl_cmd(struct wmi_t *wmip, WMI_SET_ROAM_CTRL_CMD *p,
27856 + WMI_SET_ROAM_CTRL_CMD *cmd;
27858 + osbuf = A_NETBUF_ALLOC(size);
27859 + if (osbuf == NULL) {
27860 + return A_NO_MEMORY;
27863 + A_NETBUF_PUT(osbuf, size);
27865 + cmd = (WMI_SET_ROAM_CTRL_CMD *)(A_NETBUF_DATA(osbuf));
27866 + A_MEMZERO(cmd, size);
27868 + A_MEMCPY(cmd, p, size);
27870 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_ROAM_CTRL_CMDID,
27871 + NO_SYNC_WMIFLAG));
27875 +wmi_set_powersave_timers_cmd(struct wmi_t *wmip,
27876 + WMI_POWERSAVE_TIMERS_POLICY_CMD *pCmd,
27880 + WMI_POWERSAVE_TIMERS_POLICY_CMD *cmd;
27882 + /* These timers can't be zero */
27883 + if(!pCmd->psPollTimeout || !pCmd->triggerTimeout ||
27884 + !(pCmd->apsdTimPolicy == IGNORE_TIM_ALL_QUEUES_APSD ||
27885 + pCmd->apsdTimPolicy == PROCESS_TIM_ALL_QUEUES_APSD) ||
27886 + !(pCmd->simulatedAPSDTimPolicy == IGNORE_TIM_SIMULATED_APSD ||
27887 + pCmd->simulatedAPSDTimPolicy == PROCESS_TIM_SIMULATED_APSD))
27890 + osbuf = A_NETBUF_ALLOC(size);
27891 + if (osbuf == NULL) {
27892 + return A_NO_MEMORY;
27895 + A_NETBUF_PUT(osbuf, size);
27897 + cmd = (WMI_POWERSAVE_TIMERS_POLICY_CMD *)(A_NETBUF_DATA(osbuf));
27898 + A_MEMZERO(cmd, size);
27900 + A_MEMCPY(cmd, pCmd, size);
27902 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID,
27903 + NO_SYNC_WMIFLAG));
27906 +#ifdef CONFIG_HOST_GPIO_SUPPORT
27907 +/* Send a command to Target to change GPIO output pins. */
27909 +wmi_gpio_output_set(struct wmi_t *wmip,
27910 + A_UINT32 set_mask,
27911 + A_UINT32 clear_mask,
27912 + A_UINT32 enable_mask,
27913 + A_UINT32 disable_mask)
27916 + WMIX_GPIO_OUTPUT_SET_CMD *output_set;
27919 + size = sizeof(*output_set);
27921 + A_DPRINTF(DBG_WMI,
27922 + (DBGFMT "Enter - set=0x%x clear=0x%x enb=0x%x dis=0x%x\n", DBGARG,
27923 + set_mask, clear_mask, enable_mask, disable_mask));
27925 + osbuf = A_NETBUF_ALLOC(size);
27926 + if (osbuf == NULL) {
27927 + return A_NO_MEMORY;
27929 + A_NETBUF_PUT(osbuf, size);
27930 + output_set = (WMIX_GPIO_OUTPUT_SET_CMD *)(A_NETBUF_DATA(osbuf));
27932 + output_set->set_mask = set_mask;
27933 + output_set->clear_mask = clear_mask;
27934 + output_set->enable_mask = enable_mask;
27935 + output_set->disable_mask = disable_mask;
27937 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_OUTPUT_SET_CMDID,
27938 + NO_SYNC_WMIFLAG));
27941 +/* Send a command to the Target requesting state of the GPIO input pins */
27943 +wmi_gpio_input_get(struct wmi_t *wmip)
27947 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
27949 + osbuf = A_NETBUF_ALLOC(0);
27950 + if (osbuf == NULL) {
27951 + return A_NO_MEMORY;
27954 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_INPUT_GET_CMDID,
27955 + NO_SYNC_WMIFLAG));
27958 +/* Send a command to the Target that changes the value of a GPIO register. */
27960 +wmi_gpio_register_set(struct wmi_t *wmip,
27961 + A_UINT32 gpioreg_id,
27965 + WMIX_GPIO_REGISTER_SET_CMD *register_set;
27968 + size = sizeof(*register_set);
27970 + A_DPRINTF(DBG_WMI,
27971 + (DBGFMT "Enter - reg=%d value=0x%x\n", DBGARG, gpioreg_id, value));
27973 + osbuf = A_NETBUF_ALLOC(size);
27974 + if (osbuf == NULL) {
27975 + return A_NO_MEMORY;
27977 + A_NETBUF_PUT(osbuf, size);
27978 + register_set = (WMIX_GPIO_REGISTER_SET_CMD *)(A_NETBUF_DATA(osbuf));
27980 + register_set->gpioreg_id = gpioreg_id;
27981 + register_set->value = value;
27983 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_REGISTER_SET_CMDID,
27984 + NO_SYNC_WMIFLAG));
27987 +/* Send a command to the Target to fetch the value of a GPIO register. */
27989 +wmi_gpio_register_get(struct wmi_t *wmip,
27990 + A_UINT32 gpioreg_id)
27993 + WMIX_GPIO_REGISTER_GET_CMD *register_get;
27996 + size = sizeof(*register_get);
27998 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter - reg=%d\n", DBGARG, gpioreg_id));
28000 + osbuf = A_NETBUF_ALLOC(size);
28001 + if (osbuf == NULL) {
28002 + return A_NO_MEMORY;
28004 + A_NETBUF_PUT(osbuf, size);
28005 + register_get = (WMIX_GPIO_REGISTER_GET_CMD *)(A_NETBUF_DATA(osbuf));
28007 + register_get->gpioreg_id = gpioreg_id;
28009 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_REGISTER_GET_CMDID,
28010 + NO_SYNC_WMIFLAG));
28013 +/* Send a command to the Target acknowledging some GPIO interrupts. */
28015 +wmi_gpio_intr_ack(struct wmi_t *wmip,
28016 + A_UINT32 ack_mask)
28019 + WMIX_GPIO_INTR_ACK_CMD *intr_ack;
28022 + size = sizeof(*intr_ack);
28024 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter ack_mask=0x%x\n", DBGARG, ack_mask));
28026 + osbuf = A_NETBUF_ALLOC(size);
28027 + if (osbuf == NULL) {
28028 + return A_NO_MEMORY;
28030 + A_NETBUF_PUT(osbuf, size);
28031 + intr_ack = (WMIX_GPIO_INTR_ACK_CMD *)(A_NETBUF_DATA(osbuf));
28033 + intr_ack->ack_mask = ack_mask;
28035 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_INTR_ACK_CMDID,
28036 + NO_SYNC_WMIFLAG));
28038 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
28041 +wmi_set_access_params_cmd(struct wmi_t *wmip, A_UINT16 txop, A_UINT8 eCWmin,
28042 + A_UINT8 eCWmax, A_UINT8 aifsn)
28045 + WMI_SET_ACCESS_PARAMS_CMD *cmd;
28047 + if ((eCWmin > WMI_MAX_CW_ACPARAM) || (eCWmax > WMI_MAX_CW_ACPARAM) ||
28048 + (aifsn > WMI_MAX_AIFSN_ACPARAM))
28053 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28054 + if (osbuf == NULL) {
28055 + return A_NO_MEMORY;
28058 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28060 + cmd = (WMI_SET_ACCESS_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
28061 + cmd->txop = txop;
28062 + cmd->eCWmin = eCWmin;
28063 + cmd->eCWmax = eCWmax;
28064 + cmd->aifsn = aifsn;
28066 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_ACCESS_PARAMS_CMDID,
28067 + NO_SYNC_WMIFLAG));
28071 +wmi_set_retry_limits_cmd(struct wmi_t *wmip, A_UINT8 frameType,
28072 + A_UINT8 trafficClass, A_UINT8 maxRetries,
28073 + A_UINT8 enableNotify)
28076 + WMI_SET_RETRY_LIMITS_CMD *cmd;
28078 + if ((frameType != MGMT_FRAMETYPE) && (frameType != CONTROL_FRAMETYPE) &&
28079 + (frameType != DATA_FRAMETYPE))
28084 + if (maxRetries > WMI_MAX_RETRIES) {
28088 + if (frameType != DATA_FRAMETYPE) {
28089 + trafficClass = 0;
28092 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28093 + if (osbuf == NULL) {
28094 + return A_NO_MEMORY;
28097 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28099 + cmd = (WMI_SET_RETRY_LIMITS_CMD *)(A_NETBUF_DATA(osbuf));
28100 + cmd->frameType = frameType;
28101 + cmd->trafficClass = trafficClass;
28102 + cmd->maxRetries = maxRetries;
28103 + cmd->enableNotify = enableNotify;
28105 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_RETRY_LIMITS_CMDID,
28106 + NO_SYNC_WMIFLAG));
28110 +wmi_get_current_bssid(struct wmi_t *wmip, A_UINT8 *bssid)
28112 + if (bssid != NULL) {
28113 + A_MEMCPY(bssid, wmip->wmi_bssid, ATH_MAC_LEN);
28118 +wmi_set_opt_mode_cmd(struct wmi_t *wmip, A_UINT8 optMode)
28121 + WMI_SET_OPT_MODE_CMD *cmd;
28123 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28124 + if (osbuf == NULL) {
28125 + return A_NO_MEMORY;
28128 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28130 + cmd = (WMI_SET_OPT_MODE_CMD *)(A_NETBUF_DATA(osbuf));
28131 + A_MEMZERO(cmd, sizeof(*cmd));
28132 + cmd->optMode = optMode;
28134 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_OPT_MODE_CMDID,
28135 + SYNC_BOTH_WMIFLAG));
28139 +wmi_opt_tx_frame_cmd(struct wmi_t *wmip,
28141 + A_UINT8 *dstMacAddr,
28143 + A_UINT16 optIEDataLen,
28144 + A_UINT8 *optIEData)
28147 + WMI_OPT_TX_FRAME_CMD *cmd;
28148 + osbuf = A_NETBUF_ALLOC(optIEDataLen + sizeof(*cmd));
28149 + if (osbuf == NULL) {
28150 + return A_NO_MEMORY;
28153 + A_NETBUF_PUT(osbuf, (optIEDataLen + sizeof(*cmd)));
28155 + cmd = (WMI_OPT_TX_FRAME_CMD *)(A_NETBUF_DATA(osbuf));
28156 + A_MEMZERO(cmd, (optIEDataLen + sizeof(*cmd)-1));
28158 + cmd->frmType = frmType;
28159 + cmd->optIEDataLen = optIEDataLen;
28160 + //cmd->optIEData = (A_UINT8 *)((int)cmd + sizeof(*cmd));
28161 + A_MEMCPY(cmd->bssid, bssid, sizeof(cmd->bssid));
28162 + A_MEMCPY(cmd->dstAddr, dstMacAddr, sizeof(cmd->dstAddr));
28163 + A_MEMCPY(&cmd->optIEData[0], optIEData, optIEDataLen);
28165 + return (wmi_cmd_send(wmip, osbuf, WMI_OPT_TX_FRAME_CMDID,
28166 + NO_SYNC_WMIFLAG));
28170 +wmi_set_adhoc_bconIntvl_cmd(struct wmi_t *wmip, A_UINT16 intvl)
28173 + WMI_BEACON_INT_CMD *cmd;
28175 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28176 + if (osbuf == NULL) {
28177 + return A_NO_MEMORY;
28180 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28182 + cmd = (WMI_BEACON_INT_CMD *)(A_NETBUF_DATA(osbuf));
28183 + A_MEMZERO(cmd, sizeof(*cmd));
28184 + cmd->beaconInterval = intvl;
28186 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BEACON_INT_CMDID,
28187 + NO_SYNC_WMIFLAG));
28192 +wmi_set_voice_pkt_size_cmd(struct wmi_t *wmip, A_UINT16 voicePktSize)
28195 + WMI_SET_VOICE_PKT_SIZE_CMD *cmd;
28197 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28198 + if (osbuf == NULL) {
28199 + return A_NO_MEMORY;
28202 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28204 + cmd = (WMI_SET_VOICE_PKT_SIZE_CMD *)(A_NETBUF_DATA(osbuf));
28205 + A_MEMZERO(cmd, sizeof(*cmd));
28206 + cmd->voicePktSize = voicePktSize;
28208 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_VOICE_PKT_SIZE_CMDID,
28209 + NO_SYNC_WMIFLAG));
28214 +wmi_set_max_sp_len_cmd(struct wmi_t *wmip, A_UINT8 maxSPLen)
28217 + WMI_SET_MAX_SP_LEN_CMD *cmd;
28219 + /* maxSPLen is a two-bit value. If user trys to set anything
28220 + * other than this, then its invalid
28222 + if(maxSPLen & ~0x03)
28225 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28226 + if (osbuf == NULL) {
28227 + return A_NO_MEMORY;
28230 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28232 + cmd = (WMI_SET_MAX_SP_LEN_CMD *)(A_NETBUF_DATA(osbuf));
28233 + A_MEMZERO(cmd, sizeof(*cmd));
28234 + cmd->maxSPLen = maxSPLen;
28236 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_MAX_SP_LEN_CMDID,
28237 + NO_SYNC_WMIFLAG));
28241 +convert_userPriority_to_trafficClass(A_UINT8 userPriority)
28243 + return (up_to_ac[userPriority & 0x7]);
28247 +wmi_get_power_mode_cmd(struct wmi_t *wmip)
28249 + return wmip->wmi_powerMode;
28253 +wmi_verify_tspec_params(WMI_CREATE_PSTREAM_CMD *pCmd, A_BOOL tspecCompliance)
28258 +#ifdef CONFIG_HOST_TCMD_SUPPORT
28260 +wmi_tcmd_test_report_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
28263 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
28265 + A_WMI_TCMD_RX_REPORT_EVENT(wmip->wmi_devt, datap, len);
28270 +#endif /* CONFIG_HOST_TCMD_SUPPORT*/
28273 +wmi_set_authmode_cmd(struct wmi_t *wmip, A_UINT8 mode)
28276 + WMI_SET_AUTH_MODE_CMD *cmd;
28278 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28279 + if (osbuf == NULL) {
28280 + return A_NO_MEMORY;
28283 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28285 + cmd = (WMI_SET_AUTH_MODE_CMD *)(A_NETBUF_DATA(osbuf));
28286 + A_MEMZERO(cmd, sizeof(*cmd));
28287 + cmd->mode = mode;
28289 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_AUTH_MODE_CMDID,
28290 + NO_SYNC_WMIFLAG));
28294 +wmi_set_reassocmode_cmd(struct wmi_t *wmip, A_UINT8 mode)
28297 + WMI_SET_REASSOC_MODE_CMD *cmd;
28299 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28300 + if (osbuf == NULL) {
28301 + return A_NO_MEMORY;
28304 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28306 + cmd = (WMI_SET_REASSOC_MODE_CMD *)(A_NETBUF_DATA(osbuf));
28307 + A_MEMZERO(cmd, sizeof(*cmd));
28308 + cmd->mode = mode;
28310 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_REASSOC_MODE_CMDID,
28311 + NO_SYNC_WMIFLAG));
28315 +wmi_set_lpreamble_cmd(struct wmi_t *wmip, A_UINT8 status)
28318 + WMI_SET_LPREAMBLE_CMD *cmd;
28320 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28321 + if (osbuf == NULL) {
28322 + return A_NO_MEMORY;
28325 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28327 + cmd = (WMI_SET_LPREAMBLE_CMD *)(A_NETBUF_DATA(osbuf));
28328 + A_MEMZERO(cmd, sizeof(*cmd));
28329 + cmd->status = status;
28331 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_LPREAMBLE_CMDID,
28332 + NO_SYNC_WMIFLAG));
28336 +wmi_set_rts_cmd(struct wmi_t *wmip, A_UINT16 threshold)
28339 + WMI_SET_RTS_CMD *cmd;
28341 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28342 + if (osbuf == NULL) {
28343 + return A_NO_MEMORY;
28346 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28348 + cmd = (WMI_SET_RTS_CMD*)(A_NETBUF_DATA(osbuf));
28349 + A_MEMZERO(cmd, sizeof(*cmd));
28350 + cmd->threshold = threshold;
28352 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_RTS_CMDID,
28353 + NO_SYNC_WMIFLAG));
28357 +wmi_set_wmm_cmd(struct wmi_t *wmip, WMI_WMM_STATUS status)
28360 + WMI_SET_WMM_CMD *cmd;
28362 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28363 + if (osbuf == NULL) {
28364 + return A_NO_MEMORY;
28367 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28369 + cmd = (WMI_SET_WMM_CMD*)(A_NETBUF_DATA(osbuf));
28370 + A_MEMZERO(cmd, sizeof(*cmd));
28371 + cmd->status = status;
28373 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WMM_CMDID,
28374 + NO_SYNC_WMIFLAG));
28379 +wmi_set_wmm_txop(struct wmi_t *wmip, WMI_TXOP_CFG cfg)
28382 + WMI_SET_WMM_TXOP_CMD *cmd;
28384 + if( !((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)) )
28387 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28388 + if (osbuf == NULL) {
28389 + return A_NO_MEMORY;
28392 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28394 + cmd = (WMI_SET_WMM_TXOP_CMD *)(A_NETBUF_DATA(osbuf));
28395 + A_MEMZERO(cmd, sizeof(*cmd));
28396 + cmd->txopEnable = cfg;
28398 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WMM_TXOP_CMDID,
28399 + NO_SYNC_WMIFLAG));
28403 +#ifdef CONFIG_HOST_TCMD_SUPPORT
28404 +/* WMI layer doesn't need to know the data type of the test cmd.
28405 + This would be beneficial for customers like Qualcomm, who might
28406 + have different test command requirements from differnt manufacturers
28409 +wmi_test_cmd(struct wmi_t *wmip, A_UINT8 *buf, A_UINT32 len)
28414 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
28416 + osbuf= A_NETBUF_ALLOC(len);
28417 + if(osbuf == NULL)
28419 + return A_NO_MEMORY;
28421 + A_NETBUF_PUT(osbuf, len);
28422 + data = A_NETBUF_DATA(osbuf);
28423 + A_MEMCPY(data, buf, len);
28425 + return(wmi_cmd_send(wmip, osbuf, WMI_TEST_CMDID,
28426 + NO_SYNC_WMIFLAG));
28432 +wmi_set_bt_status_cmd(struct wmi_t *wmip, A_UINT8 streamType, A_UINT8 status)
28435 + WMI_SET_BT_STATUS_CMD *cmd;
28437 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28438 + if (osbuf == NULL) {
28439 + return A_NO_MEMORY;
28442 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28444 + cmd = (WMI_SET_BT_STATUS_CMD *)(A_NETBUF_DATA(osbuf));
28445 + A_MEMZERO(cmd, sizeof(*cmd));
28446 + cmd->streamType = streamType;
28447 + cmd->status = status;
28449 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BT_STATUS_CMDID,
28450 + NO_SYNC_WMIFLAG));
28454 +wmi_set_bt_params_cmd(struct wmi_t *wmip, WMI_SET_BT_PARAMS_CMD* cmd)
28457 + WMI_SET_BT_PARAMS_CMD* alloc_cmd;
28459 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28460 + if (osbuf == NULL) {
28461 + return A_NO_MEMORY;
28464 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28466 + alloc_cmd = (WMI_SET_BT_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
28467 + A_MEMZERO(alloc_cmd, sizeof(*cmd));
28468 + A_MEMCPY(alloc_cmd, cmd, sizeof(*cmd));
28470 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BT_PARAMS_CMDID,
28471 + NO_SYNC_WMIFLAG));
28475 +wmi_get_keepalive_configured(struct wmi_t *wmip)
28478 + WMI_GET_KEEPALIVE_CMD *cmd;
28479 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28480 + if (osbuf == NULL) {
28481 + return A_NO_MEMORY;
28483 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28484 + cmd = (WMI_GET_KEEPALIVE_CMD *)(A_NETBUF_DATA(osbuf));
28485 + A_MEMZERO(cmd, sizeof(*cmd));
28486 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_KEEPALIVE_CMDID,
28487 + NO_SYNC_WMIFLAG));
28491 +wmi_get_keepalive_cmd(struct wmi_t *wmip)
28493 + return wmip->wmi_keepaliveInterval;
28497 +wmi_set_keepalive_cmd(struct wmi_t *wmip, A_UINT8 keepaliveInterval)
28500 + WMI_SET_KEEPALIVE_CMD *cmd;
28502 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28503 + if (osbuf == NULL) {
28504 + return A_NO_MEMORY;
28507 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28509 + cmd = (WMI_SET_KEEPALIVE_CMD *)(A_NETBUF_DATA(osbuf));
28510 + A_MEMZERO(cmd, sizeof(*cmd));
28511 + cmd->keepaliveInterval = keepaliveInterval;
28512 + wmip->wmi_keepaliveInterval = keepaliveInterval;
28514 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_KEEPALIVE_CMDID,
28515 + NO_SYNC_WMIFLAG));
28519 +wmi_set_appie_cmd(struct wmi_t *wmip, A_UINT8 mgmtFrmType, A_UINT8 ieLen,
28523 + WMI_SET_APPIE_CMD *cmd;
28526 + if (ieLen > WMI_MAX_IE_LEN) {
28529 + cmdLen = sizeof(*cmd) + ieLen - 1;
28530 + osbuf = A_NETBUF_ALLOC(cmdLen);
28531 + if (osbuf == NULL) {
28532 + return A_NO_MEMORY;
28535 + A_NETBUF_PUT(osbuf, cmdLen);
28537 + cmd = (WMI_SET_APPIE_CMD *)(A_NETBUF_DATA(osbuf));
28538 + A_MEMZERO(cmd, cmdLen);
28540 + cmd->mgmtFrmType = mgmtFrmType;
28541 + cmd->ieLen = ieLen;
28542 + A_MEMCPY(cmd->ieInfo, ieInfo, ieLen);
28544 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_APPIE_CMDID, NO_SYNC_WMIFLAG));
28548 +wmi_set_halparam_cmd(struct wmi_t *wmip, A_UINT8 *cmd, A_UINT16 dataLen)
28553 + osbuf = A_NETBUF_ALLOC(dataLen);
28554 + if (osbuf == NULL) {
28555 + return A_NO_MEMORY;
28558 + A_NETBUF_PUT(osbuf, dataLen);
28560 + data = A_NETBUF_DATA(osbuf);
28562 + A_MEMCPY(data, cmd, dataLen);
28564 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WHALPARAM_CMDID, NO_SYNC_WMIFLAG));
28568 +wmi_get_rate(A_INT8 rateindex)
28570 + if (rateindex == RATE_AUTO) {
28573 + return(wmi_rateTable[(A_UINT32) rateindex]);
28578 +wmi_node_return (struct wmi_t *wmip, bss_t *bss)
28582 + wlan_node_return (&wmip->wmi_scan_table, bss);
28587 +wmi_find_Ssidnode (struct wmi_t *wmip, A_UCHAR *pSsid,
28588 + A_UINT32 ssidLength, A_BOOL bIsWPA2)
28590 + bss_t *node = NULL;
28591 + node = wlan_find_Ssidnode (&wmip->wmi_scan_table, pSsid,
28592 + ssidLength, bIsWPA2);
28597 +wmi_free_allnodes(struct wmi_t *wmip)
28599 + wlan_free_allnodes(&wmip->wmi_scan_table);
28603 +wmi_find_node(struct wmi_t *wmip, const A_UINT8 *macaddr)
28606 + ni=wlan_find_node(&wmip->wmi_scan_table,macaddr);
28611 +wmi_dset_open_reply(struct wmi_t *wmip,
28613 + A_UINT32 access_cookie,
28614 + A_UINT32 dset_size,
28615 + A_UINT32 dset_version,
28616 + A_UINT32 targ_handle,
28617 + A_UINT32 targ_reply_fn,
28618 + A_UINT32 targ_reply_arg)
28621 + WMIX_DSETOPEN_REPLY_CMD *open_reply;
28623 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter - wmip=0x%x\n", DBGARG, (int)wmip));
28625 + osbuf = A_NETBUF_ALLOC(sizeof(*open_reply));
28626 + if (osbuf == NULL) {
28627 + return A_NO_MEMORY;
28630 + A_NETBUF_PUT(osbuf, sizeof(*open_reply));
28631 + open_reply = (WMIX_DSETOPEN_REPLY_CMD *)(A_NETBUF_DATA(osbuf));
28633 + open_reply->status = status;
28634 + open_reply->targ_dset_handle = targ_handle;
28635 + open_reply->targ_reply_fn = targ_reply_fn;
28636 + open_reply->targ_reply_arg = targ_reply_arg;
28637 + open_reply->access_cookie = access_cookie;
28638 + open_reply->size = dset_size;
28639 + open_reply->version = dset_version;
28641 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DSETOPEN_REPLY_CMDID,
28642 + NO_SYNC_WMIFLAG));
28646 +wmi_get_pmkid_list_event_rx(struct wmi_t *wmip, A_UINT8 *datap, A_UINT32 len)
28648 + WMI_PMKID_LIST_REPLY *reply;
28649 + A_UINT32 expected_len;
28651 + if (len < sizeof(WMI_PMKID_LIST_REPLY)) {
28654 + reply = (WMI_PMKID_LIST_REPLY *)datap;
28655 + expected_len = sizeof(reply->numPMKID) + reply->numPMKID * WMI_PMKID_LEN;
28657 + if (len < expected_len) {
28661 + A_WMI_PMKID_LIST_EVENT(wmip->wmi_devt, reply->numPMKID,
28662 + reply->pmkidList);
28667 +#ifdef CONFIG_HOST_DSET_SUPPORT
28669 +wmi_dset_data_reply(struct wmi_t *wmip,
28671 + A_UINT8 *user_buf,
28673 + A_UINT32 targ_buf,
28674 + A_UINT32 targ_reply_fn,
28675 + A_UINT32 targ_reply_arg)
28678 + WMIX_DSETDATA_REPLY_CMD *data_reply;
28681 + size = sizeof(*data_reply) + length;
28683 + A_DPRINTF(DBG_WMI,
28684 + (DBGFMT "Enter - length=%d status=%d\n", DBGARG, length, status));
28686 + osbuf = A_NETBUF_ALLOC(size);
28687 + if (osbuf == NULL) {
28688 + return A_NO_MEMORY;
28690 + A_NETBUF_PUT(osbuf, size);
28691 + data_reply = (WMIX_DSETDATA_REPLY_CMD *)(A_NETBUF_DATA(osbuf));
28693 + data_reply->status = status;
28694 + data_reply->targ_buf = targ_buf;
28695 + data_reply->targ_reply_fn = targ_reply_fn;
28696 + data_reply->targ_reply_arg = targ_reply_arg;
28697 + data_reply->length = length;
28699 + if (status == A_OK) {
28700 + if (a_copy_from_user(data_reply->buf, user_buf, length)) {
28705 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DSETDATA_REPLY_CMDID,
28706 + NO_SYNC_WMIFLAG));
28708 +#endif /* CONFIG_HOST_DSET_SUPPORT */
28711 +wmi_set_wsc_status_cmd(struct wmi_t *wmip, A_UINT32 status)
28716 + wps_enable = status;
28718 + osbuf = a_netbuf_alloc(sizeof(1));
28719 + if (osbuf == NULL) {
28720 + return A_NO_MEMORY;
28723 + a_netbuf_put(osbuf, sizeof(1));
28725 + cmd = (char *)(a_netbuf_to_data(osbuf));
28727 + A_MEMZERO(cmd, sizeof(*cmd));
28728 + cmd[0] = (status?1:0);
28729 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WSC_STATUS_CMDID,
28730 + NO_SYNC_WMIFLAG));
28733 diff --git a/drivers/sdio/function/wlan/ar6000/wmi/wmi_doc.h b/drivers/sdio/function/wlan/ar6000/wmi/wmi_doc.h
28734 new file mode 100644
28735 index 0000000..19cd938
28737 +++ b/drivers/sdio/function/wlan/ar6000/wmi/wmi_doc.h
28741 + * Copyright (c) 2004-2007 Atheros Communications Inc.
28742 + * All rights reserved.
28745 + * This program is free software; you can redistribute it and/or modify
28746 + * it under the terms of the GNU General Public License version 2 as
28747 + * published by the Free Software Foundation;
28749 + * Software distributed under the License is distributed on an "AS
28750 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
28751 + * implied. See the License for the specific language governing
28752 + * rights and limitations under the License.
28760 +Wireless Module Interface (WMI) Documentaion
28762 + This section describes the format and the usage model for WMI control and
28763 + data messages between the host and the AR6000-based targets. The header
28764 + file include/wmi.h contains all command and event manifest constants as
28765 + well as structure typedefs for each set of command and reply parameters.
28769 + The data payload transmitted and received by the target follows RFC-1042
28770 + encapsulation and thus starts with an 802.2-style LLC-SNAP header. The
28771 + WLAN module completes 802.11 encapsulation of the payload, including the
28772 + MAC header, FCS, and WLAN security related fields. At the interface to the
28773 + message transport (HTC), a data frame is encapsulated in a WMI message.
28775 +WMI Message Structure
28777 + The WMI protocol leverages an 802.3-style Ethernet header in communicating
28778 + the source and destination information between the host and the AR6000
28779 + modules using a 14-byte 802.3 header ahead of the 802.2-style payload. In
28780 + addition, the WMI protocol adds a header to all data messages:
28784 + The RSSI of the received packet and its units are shown in db above the
28785 + noise floor, and the noise floor is shown in dbm.
28787 + Contains information on message type and user priority. Message type
28788 + differentiates between a data packet and a synchronization message.
28791 + User priority contains the 802.1d user priority info from host to target. Host
28792 + software translates the host Ethernet format to 802.3 format prior to Tx and
28793 + 802.3 format to host format in the Rx direction. The host does not transmit the
28794 + FCS that follows the data. MsgType differentiates between a regular data
28795 + packet (msgType=0) and a synchronization message (msgType=1).
28799 + The AR6000 chipset provides several data endpoints to support quality of
28800 + service (QoS) and maintains separate queues and separate DMA engines for
28801 + each data endpoint. A data endpoint can be bi-directional.
28803 + Best effort (BE) class traffic uses the default data endpoint (2). The host can
28804 + establish up to two additional data endpoints for other traffic classes. Once
28805 + such a data endpoint is established, it sends and receives corresponding QoS
28806 + traffic in a manner similar to the default data endpoint.
28808 + If QoS is desired over the interconnect, host software must classify each data
28809 + packet and place it on the appropriate data endpoint. The information
28810 + required to classify data is generally available in-band as an 802.1p/q style
28811 + tag or as the ToS field in the IP header. The information may also be available
28812 + out-of-band depending on the host DDI.
28816 + Table B-1 describes the AR6000 WLAN connection states:
28818 + Table B-1. AR6000 Connection States
28824 + In this state, the AR6000 device is not connected to a wireless
28825 + network. The device is in this state after reset when it sends the
28826 + WIRELESS MODULE
\93READY
\94 EVENT, after it processes a
28827 + DISCONNECT command, and when it loses its link with the
28828 + access point (AP) that it was connected to. The device signals a
28829 + transition to the DISCONNECTED state with a
\93DISCONNECT
\94
28833 + In this state, the AR6000 device is connected to wireless networks.
28834 + The device enters this state after successfully processing a
28835 + CONNECT, which establishes a connection with a wireless
28836 + network. The device signals a transition to the CONNECTED state
28837 + with a
\93CONNECT
\94 event.
28842 + WMI uses commands, replies, and events for the control and configuration of
28843 + the AR6000 device. The control protocol is asynchronous. Table B-2 describes
28844 + AR6000 message types:
28846 +Table B-2. AR6000 Message Types
28852 + Control messages that flow from the host to the device
28855 + Control messages that flow from the device to the host.
28857 + The device issues a reply to some WMI commands, but not to others.
28858 + The payload in a reply is command-specific, and some commands do
28859 + not trigger a reply message at all. Events are control messages issued
28860 + by the device to signal the occurrence of an asynchronous event.
28863 +WMI Message Format
28865 + All WMI control commands, replies and events use the header format:
28867 + WMI_CMD_HDR Header Format
28870 + This 16-bit constant identifies which WMI command the host is issuing,
28871 + which command the target is replying to, or which event has occurred.
28876 + A variable-size command-, reply-, or event-specific payload follows the
28877 + header. Over the interconnect, all fields in control messages (including
28878 + WMI_CMD_HDR and the command specific payload) use 32-bit little Endian
28879 + byte ordering and fields are packed. The AR6000 device always executes
28880 + commands in order, and the host may send multiple commands without
28881 + waiting for previous commands to complete. A majority of commands are
28882 + processed to completion once received. Other commands trigger a longer
28883 + duration activity whose completion is signaled to the host through an event.
28885 +Command Restrictions
28887 + Some commands may only be issued when the AR6000 device is in a certain
28888 + state. The host is required to wait for an event signaling a state transition
28889 + before such a command can be issued. For example, if a command requires
28890 + the device to be in the CONNECTED state, then the host is required to wait
28891 + for a
\93CONNECT
\94 event before it issues that command.
28893 + The device ignores any commands inappropriate for its current state. If the
28894 + command triggers a reply, the device generates an error reply. Otherwise, the
28895 + device silently ignores the inappropriate command.
28897 +Command and Data Synchronization
28899 + WMI provides a mechanism for a host to advise the device of necessary
28900 + synchronization between commands and data. The device implements
28901 + synchronization; no implicit synchronization exists between endpoints.
28903 + The host controls synchronization using the
\93SYNCHRONIZE
\94 command
28904 + over the control channel and synchronization messages over data channels.
28905 + The device stops each data channel upon receiving a synchronization message
28906 + on that channel, processing all data packets received prior to that message.
28907 + After the device receives synchronization messages for each data endpoint
28908 + and the
\93SYNCHRONIZE
\94 command, it resumes all channels.
28910 + When the host must guarantee a command executes before processing new
28911 + data packets, it first issues the command, then issues the
\93SYNCHRONIZE
\94
28912 + command and sends synchronization messages on data channels. When the
28913 + host must guarantee the device has processed all old data packets before a
28914 + processing a new command, it issues a
\93SYNCHRONIZE
\94 command and
28915 + synchronization messages on all data channels, then issues the desired
28923 + Cause the AR6000 device to avoid a particular AP
28925 + Add or replace any of the four AR6000 encryption keys
28927 + Used to add a pattern to the WoW pattern list
28929 + Clear the current calculated RSSI and SNR value
28931 + Request that the AR6000 device establish a wireless connection
28932 + with the specified SSID
28934 + Create prioritized data endpoint between the host and device
28936 + Clear an entry in the bad AP table
28937 + DELETE_CIPHER_KEY
28938 + Delete a previously added cipher key
28940 + Delete a prioritized data endpoint
28941 + DELETE_WOW_PATTERN
28942 + Remove a pre-specified pattern from the WoW pattern list
28944 + WMI message interface command
28946 + Retrieve rate most recently used by the AR6000
28948 + Retrieve list of channels used by the AR6000
28950 + Retrieves the rate-mask set via the SET_FIXRATES command.
28951 + GET_PMKID_LIST_CMD
28952 + Retrieve the firmware list of PMKIDs
28954 + Internal use for data collection; available in special build only
28956 + Retrieve the roaming table maintained on the target
28958 + Request that the target send the statistics it maintains
28960 + Retrieve the current AR6000 device Tx power levels
28962 + Retrieve the current list of WoW patterns
28963 + LQ_THRESHOLD_PARAMS
28964 + Set the link quality thresholds
28966 + Send a special frame (special feature)
28968 + Request a reconnection to a BSS
28969 + RSSI_THRESHOLD_PARAMS
28970 + Configure how the AR6000 device monitors and reports signal
28971 + strength (RSSI) of the connected BSS
28973 + Determine dwell time and changes scanned channels
28974 + SET_ACCESS_PARAMS
28975 + Set access parameters for the wireless network
28977 + Set the BSSID for an ad hoc network
28979 + Set multiPMKID mode
28981 + Add application-specified IE to a management frame
28983 + Specify the IEs the device should add to association or
28984 + reassociation requests
28986 + Set 802.11 authentication mode of reconnection
28988 + Set the beacon interval for an ad hoc network
28990 + Set the AR6000 to a specific fixed bit rate
28992 + Set the beacon miss time
28994 + Inform the AR6000 of network types about which it wants to
28995 + receive information using a
\93BSSINFO
\94 event
28997 + Set the status of a Bluetooth stream (SCO or A2DP) or set
28998 + Bluetooth coexistence register parameters
29000 + Set the status of a Bluetooth stream (SCO or A2DP)
29001 + SET_CHANNEL_PARAMETERS
29002 + Configure WLAN channel parameters
29004 + Set the amount of time the AR6000 spends attempting to
29005 + reestablish a connection
29007 + Set the device to a specific fixed PHY rate (supported subset)
29009 + Internal AR6000 command to set certain hardware parameters
29010 + SET_HOST_SLEEP_MODE
29011 + Set the host mode to asleep or awake
29013 + Support a non-standard power management scheme for an
29016 + Request a listen interval
29018 + Override the short preamble capability of the AR6000 device
29020 + Set the maximum service period
29022 + Set the special mode on/off (special feature)
29024 + Set the pairwise master key ID (PMKID)
29025 + SET_PMKID_LIST_CMD
29026 + Configure the firmware list of PMKIDs
29028 + Set guidelines on trade-off between power utilization
29030 + Configure power parameters
29031 + SET_POWERSAVE_PARAMS
29032 + Set the two AR6000 power save timers
29034 + Provide list of SSIDs the device should seek
29036 + Specify whether the disassociated frame should be sent upon
29039 + Limit how many times the device tries to send a frame
29041 + Control roaming behavior
29043 + Determine when RTS should be sent
29045 + Set the AR6000 scan parameters
29046 + SET_TKIP_COUNTERMEASURES
29047 + Enable/disable reports of TKIP MIC errors
29049 + Specify the AR6000 device Tx power levels
29050 + SET_VOICE_PKT_SIZE
29051 + Set voice packet size
29053 + Override the AR6000 WMM capability
29055 + Configure TxOP bursting when sending traffic to a WMM-
29058 + Enable/disable WoW mode
29060 + Enable/disable profile check in cserv when the WPS protocol
29062 + SNR_THRESHOLD_PARAMS
29063 + Configure how the device monitors and reports SNR of BSS
29065 + Start a long or short channel scan
29067 + Force a synchronization point between command and data
29069 + TARGET_REPORT_ERROR_BITMASK
29070 + Control
\93ERROR_REPORT
\94 events from the AR6000
29079 + The host uses this command to cause the AR6000 to avoid a particular AP. The
29080 + AR6000 maintain a table with up to two APs to avoid. An ADD_BAD_AP command
29081 + adds or replaces the specified entry in this bad AP table.
29083 + If the AR6000 are currently connected to the AP specified in this command, they
29087 + wmiconfig eth1 --badap <bssid> <badApIndex>
29089 +Command Parameters
29090 + UINT8 badApIndex Index [0...1] that identifies which entry in the
29091 + bad AP table to use
29094 + UINT8 bssid[6] MAC address of the AP to avoid
29097 + badApIndex = 0, 1 Entry in the bad AP table to use
29100 + The bad AP table is cleared
29106 +
\93DELETE_BAD_AP
\94 on page B-13
29108 +=====================================================================
29113 + The host uses this command to add/replace any of four encryption keys on the
29114 + AR6000. The ADD_CIPHER_KEY command is issued after the CONNECT event
29115 + has been received by the host for all dot11Auth modes except for SHARED_AUTH.
29116 + When the dot11AuthMode is SHARED_AUTH, then the ADD_CIPHER_KEY
29117 + command should be issued before the
\93CONNECT
\94 command.
29120 + wmiconfig eth1 --cipherkey <keyIndex> <keyType> <keyUsage>
29121 + <keyLength> <keyopctrl> <keyRSC> <key>
29123 +Command Parameters
29124 + UINT8 keyIndex Index (0...3) of the key to add/replace;
29125 + uniquely identifies the key
29126 + UINT8 keyType CRYPTO_TYPE
29127 + UINT8 keyUsage Specifies usage parameters of the key when
29128 + keyType = WEP_CRYPT
29129 + UINT8 keyLength Length of the key in bytes
29130 + UINT8 keyOpCtrl bit[0] = Initialize TSC (default),
29131 + bit[1] = Initialize RSC
29132 + UINT8 keyRSC[8] Key replay sequence counter (RSC) initial
29133 + value the device should use
29134 + UINT8 key[32] Key material used for this connection
29141 + KEY_OP_INIT_TSC 0x01
29142 + KEY_OP_INIT_RSC 0x02
29143 + KEY_OP_INIT_VAL 0x03
29144 + Default is to Initialize the TSC
29145 + KEY_OP_VALID_MASK 0x04
29146 + Two operations defined
29150 + PAIRWISE_USAGE = 0 Set if the key is used for unicast traffic only
29151 + GROUP_USAGE = 1 Set if the key is used to receive multicast
29152 + traffic (also set for static WEP keys)
29153 + TX_USAGE = 2 Set for the GROUP key used to transmit frames
29154 + All others are reserved
29158 + The four available keys are disabled.
29161 + The cipher should correspond to the encryption mode specified in the
\93CONNECT
\94
29165 +
\93DELETE_CIPHER_KEY
\94
29167 +=====================================================================
29174 + The host uses this command to add a pattern to the WoW pattern list; used for
29175 + pattern-matching for host wakeups by the WoW module. If the host mode is asleep
29176 + and WoW is enabled, all packets are matched against the existing WoW patterns. If a
29177 + packet matches any of the patterns specified, the target will wake up the host. All
29178 + non-matching packets are discarded by the target without being sent up to the host.
29181 + wmiconfig
\96addwowpattern <list-id> <filter-size> <filter-offset>
29184 +Command Parameters
29185 + A_UINT8 filter_list_id ID of the list that is to include the new pattern
29186 + A_UINT8 filter_size Size of the new pattern
29187 + A_UINT8 filter_offset Offset at which the pattern matching for this
29188 + new pattern should begin at
29189 + A_UINT8 filter[1] Byte stream that contains both the pattern and
29190 + the mask of the new WoW wake-up pattern
29196 + None defined (default host mode is awake)
29202 +
\93DELETE_WOW_PATTERN
\94
29204 +=====================================================================
29211 + Clears the current calculated RSSI and SNR value. RSSI and SNR are reported by
29212 + running-average value. This command will clear the history and have a fresh start
29213 + for the running-average mechanism.
29216 + wmiconfig eth1 --cleanRssiSnr
29218 +Command Parameters
29230 +=====================================================================
29236 + New connect control information (connectCtrl) is added, with 32 possible modifiers.
29238 + CONNECT_SEND_REASSOC
29239 + Valid only for a host-controlled connection to a
29240 + particular AP. If this bit is set, a reassociation frame is
29241 + sent. If this bit is clear, an association request frame is
29244 + CONNECT_IGNORE_WPAx_GROUP_CIPHER
29245 + No group key is issued in the CONNECT command,
29246 + so use the group key advertised by the AP. In a target-
29247 + initiated roaming situation this allows a STA to roam
29248 + between APs that support different multicast ciphers.
29250 + CONNECT_PROFILE_MATCH_DONE
29251 + In a host-controlled connection case, it is possible that
29252 + during connect, firmware may not have the
29253 + information for a profile match (e.g, when the AP
29254 + supports hidden SSIDs and the device may not
29255 + transmit probe requests during connect). By setting
29256 + this bit in the connection control information, the
29257 + firmware waits for a beacon from the AP with the
29258 + BSSID supplied in the CONNECT command. No
29259 + additional profile checks are done.
29261 + CONNECT_IGNORE_AAC_BEACON
29262 + Ignore the Admission Capacity information in the
29265 + CONNECT_ASSOC_POLICY_USER
29266 + When set, the CONNECT_SEND_REASSOC setting
29267 + determines if an Assoc or Reassoc is sent to an AP
29270 + wmiconfig --setconnectctrl <ctrl flags bitmask>
29272 +Command Parameters
29274 + A_UINT8 networktype;
29275 + A_UINT8 dot11authmode;
29276 + A_UINT8 authmode;
29277 + A_UINT8 pairwiseCryptoType; /*CRYPTO_TYPE*/
29278 + A_UINT8 pairwiseCryptoLen;
29279 + A_UINT8 groupCryptoType; /*CRYPTO_TYPE*/
29280 + A_UINT8 groupCryptoLen;
29281 + A_UINT8 ssidLength;
29282 + A_UCHAR ssid[WMI_MAX_SSID_LEN];
29283 + A_UINT16 channel;
29284 + A_UINT8 bssid[AUTH_MAC_LEN];
29285 + A_UINT8 ctrl_flags; /*WMI_CONNECT_CTRL_FLAGS_BITS*/
29286 + } WMI_CONNECT_CMD;
29288 + ctrl flags bitmask
29289 + = 0x0001 CONNECT_ASSOC_POLICY_USER
29290 + Assoc frames are sent using the policy specified by
29292 + = 0x0002 CONNECT_SEND_REASSOC
29293 + Send Reassoc frame while connecting, otherwise send
29295 + = 0x0004 CONNECT_IGNORE_WPAx_GROUP_CIPHER
29296 + Ignore WPAx group cipher for WPA/WPA2
29297 + = 0x0008 CONNECT_PROFILE_MATCH_DONE
29298 + Ignore any profile check
29299 + = 0x0010 CONNECT_IGNORE_AAC_BEACON
29300 + Ignore the admission control information in the
29302 + ... CONNECT_CMD, continued
29305 + INFRA_NETWORK = 0x01,
29306 + ADHOC_NETWORK = 0x02,
29307 + ADHOC_CREATOR = 0x04,
29311 + OPEN_AUTH = 0x01,
29312 + SHARED_AUTH = 0x02,
29313 + LEAP_AUTH = 0x04,
29314 + } DOT11_AUTH_MODE;
29316 + NONE_AUTH = 0x01,
29318 + WPA_PSK_AUTH = 0x03,
29319 + WPA2_AUTH = 0x04,
29320 + WPA2_PSK_AUTH = 0x05,
29321 + WPA_AUTH_CCKM = 0x06,
29322 + WPA2_AUTH_CCKM = 0x07,
29325 + NONE_CRYPT = 0x01,
29326 + WEP_CRYPT = 0x02,
29327 + TKIP_CRYPT = 0x03,
29328 + AES_CRYPT = 0x04,
29331 + CONNECT_ASSOC_POLICY_USER = 0x0001,
29332 + CONNECT_SEND_REASSOC = 0x0002,
29333 + CONNECT_IGNORE_WPAx_GROUP_CIPHER = 0x0004,
29334 + CONNECT_PROFILE_MATCH_DONE = 0x0008,
29335 + CONNECT_IGNORE_AAC_BEACON = 0x0010,
29336 + } WMI_CONNECT_CTRL_FLAGS_BITS;
29338 + pairwiseCryptoLen and groupCryptoLen are valid when the respective
29339 + CryptoTypesis WEP_CRYPT, otherwise this value should be 0. This is the length in
29348 +=====================================================================
29355 + The host uses this command to create a new prioritized data endpoint between the
29356 + host and the AR6000 device that carries a prioritized stream of data. If the AP that the
29357 + device connects to requires TSPEC stream establishment, the device requests the
29358 + corresponding TSPEC with the AP. The maximum and minimum service interval
29359 + ranges from 0
\96 0x7FFFFFFF (ms), where 0 = disabled. The device does not send a
29360 + reply event for this command, as it is always assumed the command has succeeded.
29361 + An AP admission control response comes to the host via a WMI_CAC_INDICATION
29362 + event, once the response for the ADDTS frame comes.
29364 + Examples of cases where reassociation is generated (when WMM) and cases where
29365 + ADDTS is generated (when WMM and enabling ACM) are when:
29366 + Changing UAPSD flags in WMM mode, reassociation is generated
29367 + Changing the interval of sending auto QoS Null frame in WMM mode;
29368 + reassociation is not generated
29369 + Issuing a command with same previous parameters in WMM mode and enabling
29370 + ACM, an ADDTS request is generated
29371 + Changing the interval of a QoS null frame sending in WMM mode and enabling
29372 + ACM, an ADDTS request is generated
29373 + Issuing the command in disconnected state, reassociation or ADDTS is not
29374 + generated but the parameters are available after (re)association
29377 + --createqos <user priority> <direction> <traffic class>
29378 +<trafficType> <voice PS capability> <min service interval> <max
29379 +service interval> <inactivity interval> <suspension interval>
29380 +<service start time> <tsid> <nominal MSDU> <max MSDU> <min data
29381 +rate> <mean data rate> <peak data rate> <max burst size> <delay
29382 +bound> <min phy rate> <sba> <medium time> where:
29385 + 802.1D user priority range (0
\967)
29387 + = 0 Tx (uplink) traffic
29388 + = 1 Rx (downlink) traffic
29389 + = 2 Bi-directional traffic
29397 + <voice PS capability>
29398 + Specifies whether the voice power save mechanism
29399 + (APSD if AP supports it or legacy/simulated APSD
29400 + [using PS-Poll]) should be used
29401 + = 0 Disable voice power save for traffic class
29402 + = 1 Enable APSD voice power save for traffic class
29403 + = 2 Enable voice power save for all traffic classes
29404 + <min service interval>
29406 + <max service interval>
29407 + Inactivity interval (in ms) (0 = Infinite)
29408 + <suspension interval>
29410 + <service start time>
29411 + Service start time
29413 + TSID range (0
\9615)
29415 + Nominal MAC SDU size
29417 + Maximum MAC SDU size
29419 + Minimum data rate (in bps)
29421 + Mean data rate (in bps)
29423 + Peak data rate (in bps)
29425 + Maximum burst size (in bps)
29429 + Minimum PHY rate (in bps)
29431 + Surplus bandwidth allowance
29433 + Medium time in TU of 32-ms periods per sec
29434 + ... CREATE_PSTREAM (continued)
29436 +Command Parameters
29437 + UINT8 trafficClass TRAFFIC_CLASS value
29442 + AR6000 device mailbox index (2 or 3)
29443 + corresponding to the endpoint the host
29444 + wishes to use to receive packets for the
29445 + prioritized stream
29446 + UINT8 trafficType TRAFFIC_TYPE value
29449 + VOICEPS_CAP_TYPE value
29450 + UINT8 tsid Traffic stream ID
29451 + UINT8 userPriority 802.1D user priority
29452 + UINT16 nominalMSDU Nominal MSDU in octets
29453 + UINT16 maxMSDU Maximum MSDU in octets
29454 + UINT32 minServiceInt Minimum service interval: the min.
29455 + period of traffic specified (in ms)
29456 + UINT32 maxServiceInt Maximum service interval: the max.
29457 + period of traffic specified (in ms)
29458 + UINT32 inactivityInt Indicates how many ms an established
29459 + stream is inactive before the prioritized
29460 + data endpoint is taken down and the
29461 + corresponding T-SPEC deleted
29462 + UINT32 suspensionInt Suspension interval (in ms)
29463 + UINT32 service StartTime Service start time
29464 + UINT32 minDataRate Minimum data rate (in bps)
29465 + UINT32 meanDataRate Mean data rate (in bps)
29466 + UINT32 peakDataRate Peak data rate (in bps)
29467 + UINT32 maxBurstSize
29468 + UINT32 delayBound
29469 + UINT32 minPhyRate Minimum PHY rate for TSPEC (in bps)
29470 + UINT32 sba Surplus bandwidth allowance
29471 + UINT32 mediumTime Medium TSPEC time (in units of 32 ms)
29474 + WMM_AC_BE = 0 Best Effort
29475 + WMM_AC_BK = 1 Background
29476 + WMM_AC_VI = 2 Video
29477 + WMM_AC_VO = 3 Voice
29478 + All other values reserved
29481 + UPLINK_TRAFFIC = 0 From the AR6000 device to the AP
29482 + DOWNLINK_TRAFFIC = 1 From the AP to the AR6000 device
29483 + BIDIR_TRAFFIC = 2 Bi-directional traffic
29484 + All other values reserved
29487 + DISABLE_FOR_THIS_AC = 0
29488 + ENABLE_FOR_THIS_AC = 1
29489 + ENABLE_FOR_ALL_AC = 2
29490 + All other values reserved
29491 + } VOICEPS_CAP_TYPE
29493 + ... CREATE_PSTREAM (continued)
29496 + VI BE BK Supported, Y/N?
29515 + No pstream is present after reset; each of the BE, BK, VI,VO pstreams must be created
29516 + (either implicitly by data flow or explicitly by user)
29519 + This command can only be issued when the device is in the CONNECTED state. If
29520 + the device receives the command while in DISCONNECTED state, it replies with a
29521 + failure indication. At most four prioritized data endpoints can be created, one for
29525 +
\93DELETE_PSTREAM
\94
29526 +=====================================================================
29532 + The host uses this command to clear a particular entry in the bad AP table
29535 + wmiconfig eth1 --rmAP [--num=<index>] // used to clear a badAP
29536 + entry. num is index from 0-3
29538 +Command Parameters
29539 + UINT8 badApIndex Index [0...n] that identifies the entry in the bad
29540 + AP table to delete
29543 + badApIndex = 0, 1, 2, 3
29544 + Entry in the bad AP table
29555 +=====================================================================
29559 + DELETE_CIPHER_KEY
29562 + The host uses this command to delete a key that was previously added with the
29563 +
\93ADD_CIPHER_KEY
\94 command.
29568 +Command Parameters
29569 + UINT8 keyIndex Index (0...3) of the key to be deleted
29572 + keyIndex = 0, 1,2, 3 Key to delete
29578 + The host should not delete a key that is currently in use by the AR6000.
29581 +
\93ADD_CIPHER_KEY
\94
29583 +=====================================================================
29589 + The host uses this command to delete a prioritized data endpoint created by a
29590 + previous
\93CREATE_PSTREAM
\94 command
29593 + --deleteqos <trafficClass> <tsid>, where:
29601 + The TSpec ID; use the -qosqueue option
29602 + to get the active TSpec IDs for each traffic class
29604 +Command Parameters
29605 + A_UINT8 trafficClass Indicate the traffic class of the stream
29610 + WMM_AC_BE = 0 Best effort
29611 + WMM_AC_BK = 1 Background
29612 + WMM_AC_VI = 2 Video
29613 + WMM_AC_VO = 3 Voice
29622 + This command should only be issued after a
\93CREATE_PSTREAM
\94 command has
29623 + successfully created a prioritized stream
29626 +
\93CREATE_PSTREAM
\94
29628 +=====================================================================
29632 + DELETE_WOW_PATTERN
29635 + The host uses this command to remove a pre-specified pattern from the
29636 + WoW pattern list.
29639 + wmiconfig
\96delwowpattern <list-id> <pattern-id>
29641 +Command Parameters
29642 + A_UINT8 filter_list_id ID of the list that contains the WoW filter
29643 + pattern to delete
29644 + A_UINT8 filter_id ID of the WoW filter pattern to delete
29658 +
\93ADD_WOW_PATTERN
\94
29660 +=====================================================================
29667 + The WMI message interface is used mostly for wireless control messages to a wireless
29668 + module applicable to wireless module management regardless of the target platform
29669 + implementation. However, some commands only peripherally related to wireless
29670 + management are desired during operation. These wireless extension commands may
29671 + be platform-specific or implementation-dependent.
29676 +Command Parameters
29691 +=====================================================================
29698 + Used by the host to obtain the rate most recently used by the AR6000 device
29701 + wmiconfig eth1 --getfixrates
29703 +Command Parameters
29711 + See the
\93SET_BIT_RATE
\94 command
29717 + This command should only be used during development/debug; it is not intended
29718 +for use in production. It is only valid when the device is in the CONNECTED state
29721 +
\93SET_BIT_RATE
\94
29723 +=====================================================================
29730 + Used by the host uses to retrieve the list of channels that can be used by the device
29731 + while in the current wireless mode and in the current regulatory domain.
29736 +Command Parameters
29740 + UINT8 reserved Reserved
29741 + UINT8 numberOfChannels Number of channels the reply contains
29742 + UINT16 channelList[numberOfChannels] Array of channel frequencies (in MHz)
29748 + The maximum number of channels that can be reported are 32
29750 +=====================================================================
29757 + Clears the current calculated RSSI and SNR value. RSSI and SNR are reported by
29758 + running-average value. This command will clear the history and have a fresh start for
29759 + the running-average mechanism.
29762 + This returns rate-mask set via WMI_SET_FIXRATES to retrieve the current fixed rate
29763 + that the AR6001 or AR6001 is using. See
\93SET_FIXRATES
\94.
29766 + wmiconfig eth1 --getfixrates
29768 +Command Parameters
29769 + A_UINT16 fixRateMask; Note: if this command is used prior to
29770 + using WMI_SET_FIXRATES, AR6000
29771 + returns 0xffff as fixRateMask, indicating
29772 + all the rates are enabled
29784 +
\93SET_FIXRATES
\94
29786 +=====================================================================
29791 + GET_PMKID_LIST_CMD
29794 + Retrieves the list of PMKIDs on the firmware. The
29795 + WMI_GET_PMKID_LIST_EVENT is generated by the firmware.
29800 +Command Parameters
29809 + SET_PMKID_LIST_CMD GET_PMKID_LIST_EVENT
29811 +=====================================================================
29818 + Retrieve the roaming table maintained on the target. The response is reported
29819 + asynchronously through the ROAM_TBL_EVENT.
29822 + wmiconfig --getroamtable <roamctrl> <info>
29824 +Command Parameters
29825 + A_UINT8 roamCtrlType;
29826 + A_UINT16 roamMode
29827 + A_UINT16 numEntries
29828 + WMI_BSS_ROAM_INFO bssRoamInfo[1]
29831 + Reported asynchronously through the ROAM_TBL_EVENT
29842 +=====================================================================
29849 + The host uses this command to request that the target send the statistics that it
29850 + maintains. The statistics obtained from the target are accrued in the host every time
29851 + the GET_TARGET_STATS command is issued. The --clearStats option is added to
29852 + clear the target statistics maintained in the host.
29855 + wmiconfig --getTargetStats --clearStats
29857 +Command Parameters
29858 + TARGET_STATS targetStats
29864 + RSSI return value (0
\96100)
29867 + All statistics are cleared (zeroed)
29870 + The --getTargetStats option must be used; the --clearStats option is also available also
29873 +=====================================================================
29879 + The host uses this command to retrieve the current Tx power level
29882 + wmiconfig -i eth1 --getpower
29884 +Command Parameters
29888 + UINT16 dbM The current Tx power level specified in dbM
29891 + The maximum permitted by the regulatory domain
29899 +=====================================================================
29906 + The host uses this command to retrieve the current list of WoW patterns.
29909 + wmiconfig
\96getwowlist <list-id>
29911 +Command Parameters
29912 + A_UINT8 filter_list_id ID of the list of WoW patterns to retrieve
29915 + A_UINT16 num_filters Number of WoW patterns contained in the list
29916 + A_UINT8 wow_mode Current mode of WoW (enabled or disabled)
29917 + A_UINT8 host_mode Current host mode (asleep or awake)
29918 + WOW_FILTER wow_filters[1]
29919 + Contents of the WoW filter pattern list
29920 + (contains mask, pattern, offset and size
29921 + information for each of the patterns)
29930 +
\93SET_WSC_STATUS
\94
29932 +=====================================================================
29936 + LQ_THRESHOLD_PARAMS
29939 + Sets Link Quality thresholds, the sampling will happen at every unicast data frame
29940 + Tx if a certain threshold is met, and the corresponding event will be sent to the host.
29943 + --lqThreshold <enable> <upper_threshold_1> ...
29944 + <upper_threshold_4> <lower_threshold_1> ... <lower_threshold_4>
29946 +Command Parameters
29947 + <enable> = 0 Disable link quality sampling
29948 + = 1 Enable link quality sampling
29949 + <upper_threshold_x> Above thresholds (value in [0,100]), in
29951 + <lower_threshold_x> Below thresholds (value in [0,100]), in
29955 + See command parameters
29963 +=====================================================================
29970 + Special feature, sends a special frame.
29973 + wmiconfig --sendframe <frmType> <dstaddr> <bssid> <optIEDatalen>
29976 +Command Parameters
29978 + A_UINT16 optIEDataLen;
29980 + A_UINT8 dstAddr[ATH_MAC_LEN];
29981 + A_UINT8 bssid[ATH_MAC_LEN];
29982 + A_UINT8 optIEData[1];
29983 + } WMI_OPT_TX_FRAME_CMD;
29986 + <frmtype> = 1 Probe request frame
29987 + = 2 Probe response frame
29995 + Send a special frame only when special mode is on.
29997 +=====================================================================
30004 + This command requests a reconnection to a BSS to which the AR6000 device was
30005 + formerly connected
30010 +Command Parameters
30011 + UINT16 channel Provides a hint as to which channel was
30012 + used for a previous connection
30013 + UINT8 bssid[6] If set, indicates which BSSID to connect to
30025 +
\93CONNECT_CMD
\94
30027 +=====================================================================
30031 + RSSI_THRESHOLD_PARAMS
30034 + Configures how the AR6000 device monitors and reports signal strength (RSSI) of the
30035 + connected BSS, which is used as a link quality metric. The four RSSI threshold sets (in
30036 + dbM) of the host specification divide the signal strength range into six segments.
30037 + When signal strength increases or decreases across one of the boundaries, an
30038 + RSSI_THRESHOLD event is signaled to the host. The host may then choose to take
30039 + action (such as influencing roaming).
30042 + wmiconfig eth1 --rssiThreshold <weight> <pollTime>
30043 + <above_threshold_val_1> ... <above_threshold_tag_6>
30044 + <above_threshold_val_6>
30045 + <below_threshold_tag_1> <below_threshold_val_1> ...
30046 + <below_threshold_tag_6> <below_threshold_val_6>
30048 +Command Parameters
30049 + UINT8 weight Range in [1, 16] used to calculate average RSSI
30050 + UINT32 pollTime RSSI (signal strength) sampling frequency in
30051 + seconds (if pollTime = 0, single strength
30052 + sampling is disabled)
30053 + USER_RSS__THOLD tholds[12] Thresholds (6 x 2)
30059 + pollTime is 0, and sampling is disabled
30062 + Can only be issued if the AR6000 device is connected
30065 +=====================================================================
30071 + The minact parameter determines the minimum active channel dwell time, within
30072 + which if the STA receives any beacon, it remains on that channel until the maxact
30073 + channel dwell time. If the STA does not receive a beacon within the minact dwell
30074 + time, it switches to scan the next channel.
30077 + wmiconfig -scan -minact=<ms> --maxact=<ms>
30079 +Command Parameters
30080 + UINT16 maxact Channel dwell time (in ms), default = 0
30081 + UINT16 minact Channel dwell time (in ms), default = 105
30084 + See channel parameters
30090 + The minact value should be greater than 0; maxact should be between 5
\9665535 ms
30091 + and greater than minact
30093 +=====================================================================
30097 + SET_ACCESS_PARAMS
30100 + Allows the host to set access parameters for the wireless network. A thorough
30101 + understanding of IEEE 802.11 is required to properly manipulate these parameters.
30104 + wmiconfig eth1 --acparams --txop <limit> --cwmin <0-15>
30105 + --cwmax <0-15> --aifsn<0-15>
30107 +Command Parameters
30108 + UINT16 txop The maximum time (expressed in units of
30109 + 32 ms) the device can spend transmitting
30110 + after acquiring the right to transmit
30111 + UINT8 eCWmin Minimum contention window
30112 + UINT8 eCWmax Maximum contention window
30113 + UINT8 aifsn The arbitration inter-frame space number
30119 + Reasonable defaults that vary, between endpoints (prioritized streams)
30124 +=====================================================================
30131 + Allows the host to set the BSSID for an ad hoc network. If a network with this BSSID
30132 + is not found, the target creates an ad hoc network with this BSSID after the connect
30133 + WMI command is triggered (e.g., by the SIOCSIWESSID IOCTL).
30136 + wmiconfig eth1 --adhocbssid <bssid>
30138 +Command Parameters
30139 + A_UINT8 bssid[ATH_MAC_LEN] BSSID is specified in xx:xx:xx:xx:xx:xx format
30150 +=====================================================================
30157 + Enables or disables multi PMKID mode.
30160 + wmiconfig eth1 --setakmp --multipmkid=<on/off>
30162 +Command Parameters
30164 + A_UINT32 akmpInfo;
30165 + } WMI_SET_AKMP_PARAMS_CMD;
30170 + MultiPMKID mode is disabled and PMKIDs that
30171 + were set using the WMI_SET_PMKID_CMD are
30172 + used in the [Re]AssocRequest frame.
30174 + MultiPMKID mode is enabled and PMKIDs issued
30175 + by the WMI_SET_PMKID_LIST_CMD are used in
30176 + the next [Re]AssocRequest sent to the AP.
30179 + MultiPMKID mode is disabled
30184 +=====================================================================
30191 + Add an application-specified IE to a management frame. The maximum length is
30192 + 76 bytes. Including the length and the element ID, this translates to 78 bytes.
30195 + wmiconfig --setappie <frame> <IE>, where:
30198 + One of beacon, probe, respon, assoc
30201 + A hex string beginning with DD (if = 0, no
30202 + IE is sent in the management frame)
30204 +Command Parameters
30206 + A WMI_MGMT_FRAME_TYPE
30209 + Length of the IE to add to the GMT frame
30218 + Supported only for the probe request and association request management frame
30219 +types. Also, only one IE can be added per management frame type.
30221 +=====================================================================
30228 + The host uses this command to specify any information elements (IEs) it wishes the
30229 + AR6000 device to add to all future association and reassociation requests. IEs must be
30230 + correct and are used as is by the device. IEs specified through this command are
30231 + cleared with a DISCONNECT.
30234 + wmiconfig eth1 --setAssocIe <IE>
30236 +Command Parameters
30237 + UINT8 ieType Used directly in 802.11 frames
30238 + UINT8 bufferSize Size of assocInfo (in bytes) ranging from
30239 + 0
\96240. If = 0, previously set IEs are cleared.
30240 + UINT8 assocInfo[bufferSize] Used directly in 802.11 frames
30249 + This command can only be issued in the DISCONNECTED state
30251 +=====================================================================
30258 + Sets the 802.11 authentication mode of reconnection
30261 + wmiconfig eth1 --setauthmode <mode>
30263 +Command Parameters
30267 + mode = 0x00 Proceed with authentication during reconnect
30268 + = 0x01 Do not proceed with authentication during reconnect
30276 +=====================================================================
30283 + Sets the beacon interval for an ad hoc network. Beacon interval selection may have an
30284 + impact on power savings. To some degree, a longer interval reduces power
30285 + consumption but also decreases throughput. A thorough understanding of IEEE
30286 + 802.11 ad hoc networks is required to use this command effectively.
30289 + wmiconfig eth1 --ibssconintv
30291 +Command Parameters
30292 + UINT16 beaconInterval Specifies the beacon interval in TU units (1024 ms)
30298 + The default beacon interval is 100 TUs (102.4 ms)
30301 + This command can only be issued before the AR6000 device starts an ad hoc network
30304 +
\93SET_IBSS_PM_CAPS
\94
30306 +=====================================================================
30313 + The host uses this command to set the AR6000 device to a specific fixed rate.
30316 + wmiconfig eth1 --setfixrates <rate_0> ... <rate_n>
30318 +Command Parameters
30320 + A WMI_BIT_RATE value
30339 + See command parameters
30342 + The dynamic rate is determined by the AR6000 device
30345 + This command is intended for use only during development/debug; it is not
30346 +intended for use in production
30349 +
\93GET_BIT_RATE
\94
30351 +=====================================================================
30358 + This command sets the beacon miss (BMISS) time, which the AR6000 hardware use
30359 + to recognize missed beacons. When an excessive number (15) of consecutive beacons
30360 + are missed, the AR6000 consider switching to a different BSS. The time can be
30361 + specified in number of beacons or in TUs.
30364 + wmiconfig eth1 --setbmissbeacons=<val>
30365 + wmiconfig eth1 --setbmisstime=<val>
30367 +Command Parameters
30368 + UINT16 bmissTime Specifies the beacon miss time
30369 + [1000...5000] in TUs (1024 ms)
30370 + UINT16 bmissbeacons Specifies the number of beacons [5...50]
30376 + bmissTime is 1500 TUs (1536 ms)
30381 +=====================================================================
30388 + The host uses this to inform the AR6000 device of the types of networks about which
30389 + it wants to receive information from the
\93BSSINFO
\94 event. As the device performs
30390 + either foreground or background scans, it applies the filter and sends
\93BSSINFO
\94
30391 + events only for the networks that pass the filter. If any of the bssFilter or the ieMask
30392 + filter matches, a BSS Info is sent to the host. The ieMask currently is used as a match
30393 + for the IEs in the beacons, probe reponses and channel switch action management
30394 + frame. See also
\93Scan and Roam
\94 on page C-1.
30396 + The BSS filter command has been enhanced to support IE based filtering. The IEs can
30397 + be specified as a bitmask through this command using this enum.
30400 + wmiconfig eth1
\96filter = <filter> --ieMask 0x<mask>
30402 +Command Parameters
30407 + A_UINT8 bssFilter; See WMI_BSS_FILTER
30409 + } __ATTRIB_PACK WMI_BSS_FILTER_CMD;
30411 + The ieMask can take this combination of values:
30414 + BSS_ELEMID_CHANSWITCH = 0x01
30415 + BSS_ELEMID_ATHEROS = 0x02,
30422 + BssFilter = NONE_BSS_FILTER (0)
30428 +
\93CONNECT_CMD
\94
30430 +=====================================================================
30437 + This command is used to set the status of a Bluetooth stream or set Bluetooth
30438 + coexistence register parameters. The stream may be an SCO or an A2DP stream and
30439 + its status can be started/stopped/suspended/resumed.
30442 + wmiconfig
\96setBTparams <paramType> <params>
30444 +Command Parameters
30447 + BT_PARAMS_SCO scoParams;
30448 + BT_PARAMS_A2DP a2dpParams;
30449 + BT_PARAMS_MISC miscParams;
30450 + BT_COEX_REGS regs;
30452 + A_UINT8 paramType;
30454 + A_UINT8 noSCOPkts; Number of SCO packets between consecutive PS-POLLs
30455 + A_UINT8 pspollTimeout;
30459 + A2DP BT stream parameters
30461 + A_UINT32 dutycycle;
30463 + } BT_PARAMS_A2DP;
30466 + WLAN_PROTECT_POLICY_TYPE protectParams;
30467 + A_UINT16 wlanCtrlFlags;
30469 + A_UINT8 paramType;
30470 + } BT_PARAMS_MISC;
30472 + BT coexistence registers values
30473 + A_UINT32 mode; Coexistence mode
30474 + A_UINT32 scoWghts; WLAN and BT weights
30475 + A_UINT32 a2dpWghts;
30476 + A_UINT32 genWghts;
30477 + A_UINT32 mode2; Coexistence mode2
30490 +=====================================================================
30497 + Sets the status of a Bluetooth stream. The stream may be a SCO or an A2DP stream
30498 + and its status can be started/stopped/suspended/resumed.
30501 + wmiconfig
\96setBTstatus <streamType> <status>
30503 +Command Parameters
30505 + A_UINT8 streamType; Stream type
30506 + A_UINT8 status; Stream status
30507 + }WMI_SET_BT_STATUS_CMD;
30511 + BT_STREAM_UNDEF = 0
30517 + } BT_STREAM_TYPE;
30520 + BT_STATUS_UNDEF = 0
30524 + BT_STATUS_SUSPEND
30526 + } BT_STREAM_STATUS;
30534 +=====================================================================
30538 + SET_CHANNEL_PARAMETERS
30541 + Configures various WLAN parameters related to channels, sets the wireless mode,
30542 + and can restrict the AR6000 device to a subset of available channels. The list of
30543 + available channels varies depending on the wireless mode and the regulatory
30544 + domain. The device never operates on a channel outside of its regulatory domain. The
30545 + device starts to scan the list of channels right after this command.
30548 + wmiconfig eth1 --wmode <mode> <list>
30550 +Command Parameters
30551 + UINT8 phyMode See Values below.
30552 + UINT8 numberOfChannels
30553 + Number of channels in the channel array that
30554 + follows. If = 0, then the device uses all of the
30555 + channels permitted by the regulatory domain
30556 + and by the specified phyMode.
30557 + UINT16 channel[numberOfChannels]
30558 + Array listing the subset of channels (expressed
30559 + as frequencies in MHz) the host wants the
30560 + device to use. Any channel not permitted by
30561 + the specified phyMode or by the specified
30562 + regulatory domain is ignored by the device.
30577 + 802.11a/g modules
30581 + Defaults to all channels permitted by the
30582 + current regulatory domain.
30585 + This command, if issued, should be issued soon after reset and prior to the first
30586 + connection. This command should only be issued in the DISCONNECTED state.
30588 +=====================================================================
30595 + The host uses this command to configure the amount of time that the AR6000 should
30596 + spend when it attempts to reestablish a connection after losing link with its current
30597 + BSS. If this time limit is exceeded, the AR6000 send a
\93DISCONNECT
\94 event. After
30598 + sending the
\93DISCONNECT
\94 event the AR6000 continues to attempt to reestablish a
30599 + connection, but they do so at the interval corresponding to a foreground scan as
30600 + established by the
\93SET_SCAN_PARAMS
\94 command.
30602 + A timeout value of 0 indicates that the AR6000 will disable all autonomous roaming,
30603 + so that the AR6000 will not perform any scans after sending a
\93DISCONNECT
\94
30604 + event to the host. The state is maintained until a shutdown or host sets different
30605 + timeout value from 0.
30608 + wmiconfig eth1 --disc=<timeout in seconds>
30610 +Command Parameters
30611 + UINT8 disconnectTimeout
30612 + Specifies the time limit (in seconds) after
30613 + which a failure to reestablish a connection
30614 + results in a
\93DISCONNECT
\94 event
30620 + disconnectTimeout is 10 seconds
30623 + This command can only be issued while in a DISCONNECTED state
30625 +=====================================================================
30632 + By default, the AR6000 device uses all PHY rates based on mode of operation. If the
30633 + host application requires the device to use subset of supported rates, it can set those
30634 + rates with this command. In 802.11g mode, the AR6000 device takes the entire
30635 + 802.11g basic rate set and the rates specified with this command and uses it as the
30636 + supported rate set.
30638 + This rate set is advertised in the probe request and the assoc/re-assoc request as
30639 + supported rates. Upon successful association, the device modifies the rate set pool
30640 + using the: intersection of AP-supported rates with the union of the 802.11g basic rate
30641 + set and rates set using this command. The device picks transmission rates from this
30642 + pool based on a rate control algorithm.
30647 +Command Parameters
30648 + A_UINT16 fixRateMask;
30649 + The individual bit is an index for rate table,
30650 + and setting the that index to 1 would set that
30651 + corresponding rate. E.g., fixRateMask = 9
30652 + (1001) sets 1 Mbps and 11 Mbps.
30664 +
\93GET_FIXRATES
\94
30666 +=====================================================================
30673 + An internal AR6000 command that is used to set certain hardware parameters. The
30674 + description of this command is in $WORKAREA/include/halapi.h.
30679 +Command Parameters
30680 + ATH_HAL_SETCABTO_CMDID
30681 + Sets the timeout waiting for the multicast
30682 + traffic after a DTIM beacon (in TUs).
30691 + This command should be executed before issuing a connect command.
30693 +=====================================================================
30697 + SET_HOST_SLEEP_MODE
30700 + The host uses this command to set the host mode to asleep or awake. All packets are
30701 + delivered to the host when the host mode is awake. When host mode is asleep, only if
30702 + WoW is enabled and the incoming packet matches one of the specified WoW
30703 + patterns, will the packet be delivered to the host. The host will also be woken up by
30704 + the target for pattern-matching packets and important events.
30707 + wmiconfig
\96sethostmode=<asleep/awake>
30709 +Command Parameters
30710 + A_BOOL awake Set the host mode to awake
30711 + A_BOOL asleep Set the host mode to asleep
30714 + 1 = awake, 0 = asleep
30717 + None defined (default host mode is awake)
30723 +=====================================================================
30729 + Used to support a non-standard power management scheme for an ad hoc wireless
30730 + network consisting of up to eight stations (STAs) that support this form of power
30731 + saving (e.g., Atheros-based STAs). A thorough understanding of IEEE 802.11 ad hoc
30732 + networks is required to use this command effectively.
30735 + wmiconfig eth1 --ibsspmcaps --ps=<enable/disable>
30736 + --aw=<ATIM Windows in ms>
30737 + --ttl=<Time to live in number of beacon periods>
30738 + --to=<timeout in ms>
30740 +Command Parameters
30741 + UINT8 power_saving
30743 + The non-standard power saving scheme is
30744 + disabled and maximum throughput (with no
30745 + power saving) is obtained.
30748 + Ad hoc power saving scheme is enabled (but
30749 + throughput may be decreased)
30751 + UINT16 atim_windows
30752 + Specifies the length (in ms) of the ad hoc traffic
30753 + indication message (ATIM) windows used in an ad
30754 + hoc network. All Atheros-based STAs that join the
30755 + network use this duration ATIM window.
30757 + The duration is communicated between wireless
30758 + STAs through an IE in beacons and probe responses.
30760 + The host sets atim_windows to control trade-offs
30761 + between power use and throughput. The value
30762 + chosen should be based on the beacon interval (see
30763 + the
\93SET_BEACON_INT
\94 command) on the
30764 + expected number of STAs in the IBSS, and on the
30765 + amount of traffic and traffic patterns between STAs.
30767 + UINT16 timeout_value
30768 + Specifies the timeout (in ms). The value is the same
30769 + for all ad hoc connections, but tracks separately for
30772 + Applicable only for a beacon period and used to
30773 + derive actual timeout values on the Tx and Rx sides.
30774 + On the Tx side, the value defines a window during
30775 + which the STA accepts the frame(s) from the host for a
30776 + particular connection. Until closed, the window
30777 + restarts with every frame received from the host. On
30778 + the Rx side, indicates the time until which the STA
30779 + continues accepting frames from a particular
30780 + connection. The value resets with every frame
30781 + received. The value can be used to determine the
30782 + trade off between throughput and power.
30786 + Specifies the value in number of beacon periods. The
30787 + value is used to set a limit on the time until which a
30788 + frame is kept alive in the AR6001 before being
30789 + discarded. Default = 5
30795 + By default, power_saving is enabled with atim_window = 20 ms
30798 + Can only be issued before the AR6000 starts an ad hoc network
30801 +
\93SET_BEACON_INT
\94
30803 +=====================================================================
30811 + The host uses this command to request a listen interval, which determines how often
30812 + the AR6000 device should wake up and listen for traffic. The listen interval can be set
30813 + by the TUs or by the number of beacons. The device may not be able to comply with
30814 + the request (e.g., if the beacon interval is greater than the requested listen interval, the
30815 + device sets the listen interval to the beacon interval). The actual listen interval used
30816 + by the device is available in the
\93CONNECT
\94 event.
30819 + wmiconfig eth1 --listen=<#of TUs, can range from 15 to 3000>
30821 + --listenbeacons=<#of beacons, can range from 1 to 50>
30823 +Command Parameters
30824 + UINT16 listenInterval
30825 + Specifies the listen interval in Kms
30826 + (1024 ms), ranging from 100 to 1000
30828 + UINT16 listenbeacons
30829 + Specifies the listen interval in beacons,
30830 + ranging from 1 to 50
30836 + The device sets the listen interval equal to the beacon interval of the AP it associates
30842 +=====================================================================
30849 + Overrides the short preamble capability of the AR6000 device
30854 +Command Parameters
30855 + WMI_LPREAMBLE_DISABLED
30856 + The device is short-preamble capable
30858 + WMI_LPREAMBLE_ENABLED
30859 + The device supports only the long-
30872 +=====================================================================
30878 + Set the maximum service period; indicates the number of packets the AR6001 can
30879 + receive from the AP when triggered
30882 + wmiconfig eth1 --setMaxSPLength <maxSPLen>
30884 +Command Parameters
30886 + An APSD_SP_LEN_TYPE value
30890 + DELIVER_ALL_PKT = 0x0
30891 + DELIVER_2_PKT = 0x1
30892 + DELIVER_4_PKT = 0x2
30893 + DELIVER_6_PKT = 0x3
30894 + }APSD_SP_LEN_TYPE
30898 + maxSPLen is DELIVER_ALL_PKT
30903 +=====================================================================
30910 + Special feature, sets the special mode on/off
30913 + wmiconfig eth1 --mode <mode>
30914 + Set the optional mode, where mode is special or off
30916 +Command Parameters
30930 +=====================================================================
30937 + The host uses this command to enable or disable a pairwise master key ID (PMKID)
30938 + in the AR6000 PMKID cache. The AR6000 clears its PMKID cache on receipt of a
30939 + DISCONNECT command from the host. Individual entries in the cache might be
30940 + deleted as the AR6000 detect new APs and decides to remove old ones.
30943 + wmiconfig eth1 --setbsspmkid --bssid=<aabbccddeeff>
30944 + --bsspmkid=<pmkid>
30946 +Command Parameters
30948 + The MAC address of the AP that the
30949 + PMKID corresponds to (6 bytes in hex
30953 + Either PMKID_DISABLE (0) to disable
30954 + the PMKID or PMKID_ENABLE (1) to
30955 + enable it (16 bytes in hex format)
30958 + Meaningful only if enable is
30959 + PMKID_ENABLE, when it is the PMKID
30960 + that the AR6000 should use on the next
30961 + reassociation with the specified AP
30965 + = 0 (disable), 1 (enable)
30966 + PKMID enabled/disabled
30972 + Only supported in infrastructure networks
30974 +=====================================================================
30978 + SET_PMKID_LIST_CMD
30981 + Configures the list of PMKIDs on the firmware.
30984 + wmiconfig --setpmkidlist --numpmkid=<n> --pmkid=<pmkid_1>
30985 + ... --pmkid=<pmkid_n>
30987 + Where n is the number of pmkids (maximum = 8) and pmkid_i is the ith pmkid (16
30988 + bytes in hex format)
30990 +Command Parameters
30992 + A_UINT8 pmkid[WMI_PMKID_LEN];
30993 + } __ATTRIB_PACK WMI_PMKID;
30996 + A_UINT32 numPMKID;
30997 + WMI_PMKID pmkidList[WMI_MAX_PMKID_CACHE];
30998 + } __ATTRIB_PACK WMI_SET_PMKID_LIST_CMD;
31007 + Supported only in infrastructure modes
31009 +=====================================================================
31016 + The host uses this command to provide the AR6000 device with guidelines on the
31017 + desired trade-off between power utilization and performance.
31019 + In normal power mode, the device enters a sleep state if they have nothing to do,
31020 + which conserves power but may cost performance as it can take up to 2 ms to
31021 + resume operation after leaving sleep state.
31023 + In maximum performance mode, the device never enters sleep state, thus no time
31024 + is spent waking up, resulting in higher power consumption and better
31030 +Command Parameters
31032 + WMI_POWER_MODE value
31035 + (Recommended setting) Tries to conserve
31036 + power without sacrificing performance
31037 + MAX_PERF_POWER = 2
31038 + Setting that maximizes performance at
31039 + the expense of power
31041 + All other values are reserved
31045 + See command parameters
31048 + powerMode is REC_POWER
31051 + This command should only be issued in the DISCONNECTED state for the
31052 + infrastructure network.
31054 + For a PM-disabled ad hoc network, the power mode should remain in
31057 + For a PM-enabled ad hoc network, the device can have REC_POWER or
31058 + MAX_PERF_POWER set, but either way it must follow the power save ad hoc
31059 + protocol. The host can change power modes in the CONNECTED state.
31061 + Host changes to the PS setting when the STA is off the home channel take no effect
31062 + and cause a TARGET_PM_FAIL event.
31064 +=====================================================================
31071 + The host uses this command to configure power parameters
31074 + wmiconfig eth1 --pmparams --it=<ms> --np=<number of PS POLL>
31075 + --dp=<DTIM policy: ignore/normal/stick>
31077 +Command Parameters
31078 + UINT16 idle_period
31079 + Length of time (in ms) the AR6000 device
31080 + remains awake after frame Rx/Tx before going
31083 + UINT16 pspoll_number
31084 + The number of PowerSavePoll (PS-poll)
31085 + messages the device should send before
31086 + notifying the AP it is awake
31088 + UINT16 dtim_policy
31089 + A WMI_POWER_PARAMS_CMD value
31093 + The device does not listen to any content after
31094 + beacon (CAB) traffic
31096 + DTIM period follows the listen interval (e.g., if
31097 + the listen interval is 4 and the DTIM period is 2,
31098 + the device wakes up every fourth beacon)
31100 + Device attempt to receive all CAB traffic (e.g., if
31101 + the DTIM period is 2 and the listen interval is 4,
31102 + the device wakes up every second beacon)
31103 + } WMI_POWER_PARAMS_CMD
31105 +Command Parameters
31106 + See command parameters
31121 +=====================================================================
31125 + SET_POWERSAVE_PARAMS
31128 + Set the two AR6000 power save timers (PS-POLL timer and APSD trigger timer) and
31129 + the two ASPD TIM policies
31132 + wmiconfig eth1--psparams --psPollTimer=<psPollTimeout in ms>
31133 + --triggerTimer=<triggerTimeout in ms> --apsdTimPolicy=<ignore/
31134 + adhere> --simulatedAPSDTimPolicy=<ignore/adhere>
31136 +Command Parameters
31138 + A_UINT16 psPollTimeout;
31139 + Timeout (in ms) after sending PS-POLL; the
31140 + AR6000 device sleeps if it does not receive a
31141 + data packet from the AP
31143 + A_UINT16 triggerTimeout;
31144 + Timeout (in ms) after sending a trigger; the
31145 + device sleeps if it does not receive any data
31146 + or null frame from the AP
31148 + APSD_TIM_POLICY apsdTimPolicy;
31149 + TIM behavior with queue APSD enabled
31151 + APSD_TIM_POLICY simulatedAPSD
31154 + TIM behavior with simulated APSD
31158 + IGNORE_TIM_ALL_QUEUES_APSD = 0,
31159 + PROCESS_TIM_ALL_QUEUES_APSD = 1,
31160 + IGNORE_TIM_SIMULATED_APSD = 2,
31161 + POWERSAVE_TIMERS_POLICY = 3,
31162 + } APSD_TIM_POLICY;
31168 + psPollTimeout is 50 ms; triggerTimeout is 10 ms;
31169 + apsdTimPolicy = IGNORE_TIM_ALL_QUEUES_APSD;
31170 + simulatedAPSDTimPolicy = POWERSAVE_TIMERS_POLICY
31173 + When this command is used, all parameters must be set; this command does not
31174 + allow setting only one parameter.
31176 +=====================================================================
31183 + The host uses this command to provide a list of up to MAX_PROBED_SSID_INDEX
31184 + (six) SSIDs that the AR6000 device should actively look for. It lists the active SSID
31185 + table. By default, the device actively looks for only the SSID specified in the
31186 +
\93CONNECT_CMD
\94 command, and only when the regulatory domain allows active
31187 + probing. With this command, specified SSIDs are probed for, even if they are hidden.
31190 + wmiconfig eth1 --ssid=<ssid> [--num=<index>]
31192 +Command Parameters
31195 + A number from 0 to
31196 + MAX_PROBED_SSID_INDEX indicating
31197 + the active SSID table entry index for this
31198 + command (if the specified entry index
31199 + already has an SSID, the SSID specified in
31200 + this command replaces it)
31202 + WMI_PROBED_SSID_INFO probedSSID[1]
31203 + } WMI_PROBED_SSID_CMD
31207 + WMI_SSID_FLAG indicates the current
31208 + entry in the active SSID table
31209 + A_UINT8 ssidLength
31210 + Length of the specified SSID in bytes.
31211 + If = 0, the entry corresponding to the
31214 + SSID string actively probed for when
31215 + permitted by the regulatory domain
31216 + } WMI_PROBED_SSID_INFO
31221 + DISABLE_SSID_FLAG = 0
31223 + SPECIFIC_SSID_FLAG = 1
31224 + Probes specified SSID
31225 + ANY_SSID_FLAG = 2
31226 + Probes for any SSID
31230 + The entries are unused.
31235 +=====================================================================
31242 + Specify whether the disassociated frame should be sent or not upon reassociation.
31245 + wmiconfig eth1 --setreassocmode <mode>
31247 +Command Parameters
31253 + Send disassoc to a previously connected AP
31254 + upon reassociation
31256 + Do not send disassoc to previously connected
31257 + AP upon reassociation
31266 +=====================================================================
31272 + Allows the host to influence the number of times that the AR6000 device should
31273 + attempt to send a frame before they give up.
31276 + wmiconfig --setretrylimits <frameType> <trafficClass> <maxRetries>
31279 +Command Parameters
31282 + A WMI_FRAMETYPE specifying
31283 + which type of frame is of interest.
31284 + UINT8 trafficClass
31285 + Specifies a traffic class (see
31286 +
\93CREATE_PSTREAM
\94). This
31287 + parameter is only significant when
31288 + frameType = DATA_FRAMETYPE.
31290 + Maximum number of times the
31291 + device attempts to retry a frame Tx,
31292 + ranging from WMI_MIN_RETRIES
31293 + (2) to WMI_MAX_RETRIES (15). If
31294 + the special value 0 is used,
31295 + maxRetries is set to 15.
31296 + A_UINT8 enableNotify
31297 + Notify when enabled
31298 + } WMI_RETRY_LIMIT_INFO
31301 + A_UINT8 numEntries
31302 + WMI_RETRY_LIMIT_INFO retryLimitInfo[1]
31303 + } WMI_SET_RETRY_LIMITS_CMD
31307 + MGMT_FRAMETYPE = 0 Management frame
31308 + CONTROL_FRAMETYPE = 1 Control frame
31309 + DATA_FRAMETYPE = 2 Data frame
31313 + Retries are set to 15
31318 +=====================================================================
31325 + Affects how the AR6000 device selects a BSS. The host uses this command to set and
31326 + enable low RSSI scan parameters. The time period of low RSSI background scan is
31327 + mentioned in scan period. Low RSSI scan is triggered when the current RSSI
31328 + threshold (75% of current RSSI) is equal to or less than scan threshold.
31330 + Low RSSI roam is triggered when the current RSSI threshold falls below the roam
31331 + threshold and roams to a better AP by the end of the scan cycle. During Low RSSI
31332 + roam, if the STA finds a new AP with an RSSI greater than roam RSSI to floor, during
31333 + scan, it roams immediately to it instead of waiting for the end of the scan cycle. See
31334 + also
\93Scan and Roam
\94 on page C-1.
31337 + wmiconfig --roam <roamctrl> <info>, where info is <scan period>
31338 + <scan threshold> <roam threshold> <roam rssi floor>
31340 +Command Parameters
31341 + A_UINT8 roamCtrlType;
31344 + WMI_FORCE_ROAM = 1
31345 + Roam to the specified BSSID
31347 + WMI_SET_ROAM_MODE = 2
31348 + Default, progd bias, no roam
31350 + WMI_SET_HOST_BIAS = 3
31351 + Set the host bias
31353 + WMI_SET_LOWRSSI_SCAN_PARAMS = 4
31356 + A_UINT8 bssid[ATH_MAC_LEN];
31359 + A_UINT8 roamMode;
31360 + WMI_SET_ROAM_MODE
31362 + A_UINT8 bssBiasInfo;
31363 + WMI_SET_HOST_BIAS
31365 + A_UINT16 lowrssi_scan_period;
31366 + WMI_SET_LOWRSSI_SCAN_PARAMS
31369 + lowrssi_scan_threshold;
31370 + WMI_SET_LOWRSSI_SCAN_PARAMS
31372 + A_INT16 lowrssi_roam_threshold;
31373 + WMI_SET_LOWRSSI_SCAN_PARAMS
31375 + A_UINT8 roam_rssi_floor;
31376 + WMI_SET_LOWRSSI_SCAN_PARAMS
31379 + None defined (default lowrssi scan is disabled. Enabled only when scan period is set.)
31384 +=====================================================================
31391 + Decides when RTS should be sent.
31394 + wmiconfig eth1 --setRTS <pkt length threshold>
31396 +Command Parameters
31399 + Command parameter threshold in bytes. An RTS is
31400 + sent if the data length is more than this threshold.
31401 + The default is to NOT send RTS.
31413 +=====================================================================
31419 + The host uses this command to set the AR6000 scan parameters, including the duty
31420 + cycle for both foreground and background scanning. Foreground scanning takes
31421 + place when the AR6000 device is not connected, and discovers all available wireless
31422 + networks to find the best BSS to join. Background scanning takes place when the
31423 + device is already connected to a network and scans for potential roaming candidates
31424 + and maintains them in order of best to worst. A second priority of background
31425 + scanning is to find new wireless networks.
31427 + The device initiates a scan when necessary. For example, a foreground scan is always
31428 + started on receipt of a
\93CONNECT_CMD
\94 command or when the device cannot find
31429 + a BSS to connect to. Foreground scanning is disabled by default until receipt of a
31430 + CONNECT command. Background scanning is enabled by default and occurs every
31431 + 60 seconds after the device is connected.
31433 + The device implements a binary backoff interval for foreground scanning when it
31434 + enters the DISCONNECTED state after losing connectivity with an AP or when a
31435 + CONNECT command is received. The first interval is ForegroundScanStartPeriod,
31436 + which doubles after each scan until the interval reaches ForegroundScanEndPeriod.
31437 + If the host terminates a connection with DISCONNECT, the foreground scan period
31438 + is ForegroundScanEndPeriod. All scan intervals are measured from the time a full
31439 + scan ends to the time the next full scan starts. The host starts a scan by issuing a
31440 +
\93START_SCAN
\94 command. See also
\93Scan and Roam
\94 on page C-1.
31443 + wmiconfig eth1 --scan --fgstart=<sec> --fgend=<sec> --bg=<sec> --
31444 + act=<msec> --pas=<msec> --sr=<short scan ratio> --scanctrlflags
31445 + <connScan> <scanConnected> <activeScan> <reportBSSINFO>
31447 +Command Parameters
31448 + UINT16 fgStartPeriod
31449 + First interval used by the device when it
31450 + disconnects from an AP or receives a
31451 + CONNECT command, specified in seconds (0
\96
31452 + 65535). If = 0, the device uses the reset value.
31453 + If = 65535, the device disables foreground
31456 + UINT16 fgEndPeriod
31457 + The maximum interval the device waits between
31458 + foreground scans specified in seconds (from
31459 + ForegroundScanStartPeriod to 65535). If = 0, the
31460 + device uses the reset value.
31462 + UINT16 bgScanPeriod
31463 + The period of background scan specified in
31464 + seconds (0
\9665535). By default, it is set to the reset
31465 + value of 60 seconds. If 0 or 65535 is specified, the
31466 + device disables background scanning.
31468 + UINT16 maxactChDwellTime
31469 + The period of time the device stays on a
31470 + particular channel while active scanning. It is
31471 + specified in ms (10
\9665535). If the special value of
31472 + 0 is specified, the device uses the reset value.
31474 + UINT16 PasChDwellTime
31475 + The period of time the device remains on a
31476 + particular channel while passive scanning. It is
31477 + specified in ms (10
\9665535). If the special value of
31478 + 0 is specified, the device uses the reset value.
31480 + UINT8 shortScanRatio
31481 + Number of short scans to perform for each
31484 + UINT8 scanCtrlFlasgs
31486 + UINT16 minactChDwellTime
31489 + UINT32 maxDFSchActTime
31490 + The maximum time a DFS channel can stay
31491 + active before being marked passive, specified in
31498 + ForegroundScanStart
31502 + ForegroundScanEndPeriod
31505 + BackgroundScanPeriod
31508 + ActiveChannelDwellTime
31511 +=====================================================================
31515 + SET_TKIP_COUNTERMEASURES
31518 + The host issues this command to tell the target whether to enable or disable TKIP
31524 +Command Parameters
31525 + UINT8 WMI_TKIP_CM_ENABLE
31526 + Enables the countermeasures
31529 + UINT8 TKIP_CM_DISABLE
31530 + Disables the countermeasures
31536 + By default, TKIP MIC reporting is disabled
31541 +=====================================================================
31548 + The host uses this command to specify the Tx power level of the AR6000. Cannot be
31549 + used to exceed the power limit permitted by the regulatory domain. The maximum
31550 + output power is limited in the chip to 31.5 dBm; the range is 0
\96 31.5 dbm.
31553 + wmiconfig --power <dbM>
31555 +Command Parameters
31557 + The desired Tx power specified in dbM.
31558 + If = 0, the device chooses the maximum
31559 + permitted by the regulatory domain.
31565 + The maximum permitted by the regulatory domain
31574 +=====================================================================
31577 + SET_VOICE_PKT_SIZE
31580 + If an AP does not support WMM, it has no way to differentiate voice from data.
31581 + Because the voice packet is typically small, packet in size less than voicePktSize are
31582 + assumed to be voice, otherwise it is treated as data.
31585 + wmiconfig eth1 --setVoicePktSize <size-in-bytes>
31587 +Command Parameters
31588 + UINT16 voicePktSize
31589 + Packet size in octets
31595 + voicePktSize default is 400 bytes
31598 + No effect if WMM is unavailable
31601 +=====================================================================
31607 + Overrides the AR6000 device WMM capability
31610 + wmiconfig eth1 --setwmm <enable>
31612 +Command Parameters
31617 + Disables WMM support
31630 +=====================================================================
31636 + Configures TxOP Bursting when sending traffic to a WMM capable AP
31639 + wmiconfig eth1 --txopbursting <burstEnable>
31643 + Disallow TxOp bursting
31646 + Allow TxOp bursting
31648 +Command Parameters
31650 + = WMI_TXOP_DISABLED
31653 + = WMI_TXOP_ENABLED
31663 + Bursting is off by default
31668 +=====================================================================
31675 + The host uses this command to enable or disable the WoW mode. When WoW mode
31676 + is enabled and the host is asleep, pattern matching takes place at the target level.
31677 + Only packets that match any of the pre-specified WoW filter patterns, will be passed
31678 + up to the host. The host will also be woken up by the target. Packets which do not
31679 + match any of the WoW patterns are discarded.
31682 + wmiconfig
\96setwowmode <enable/disable>
31684 +Command Parameters
31685 + A_BOOL enable_wow
31686 + Enable or disable WoW:
31696 + None defined (default WoW mode is disabled).
31702 +
\93GET_WOW_LIST
\94
31705 +=====================================================================
31711 + The supplicant uses this command to inform the target about the status of the WSC
31712 + registration protocol. During the WSC registration protocol, a flag is set so the target
31713 + bypasses some of the checks in the CSERV module. At the end of the registration, this
31719 +Command Parameters
31721 + = 1 WSC registration in progress
31722 + = 0 WSC protocol not running
31728 + None defined (default = 0)
31734 +=====================================================================
31737 + SNR_THRESHOLD_PARAMS
31740 + Configures how the AR6000 device monitors and reports SNR of the connected BSS,
31741 + used as a link quality metric.
31744 + --snrThreshold <weight> <upper_threshold_1> ...
31745 + <upper_threshold_4> <lower_threshold_1> ... <lower_threshold_4>
31748 +Command Parameters
31750 + Share with rssiThreshold. Range in [1, 16], used
31751 + in the formula to calculate average RSSI
31753 + <upper_threshold_x>
31754 + Above thresholds expressed in db, in ascending
31757 + <lower_threshold_x>
31758 + Below thresholds expressed in db, in ascending
31762 + The signal strength sampling frequency in
31763 + seconds. If polltime = 0, signal strength
31764 + sampling is disabled
31775 +=====================================================================
31782 + The host uses this command to start a long or short channel scan. All future scans are
31783 + relative to the time the AR6000 device processes this command. The device performs
31784 + a channel scan on receipt of this command, even if a scan was already in progress.
31785 + The host uses this command when it wishes to refresh its cached database of wireless
31786 + networks. The isLegacy field will be removed (0 for now) because it is achieved by
31787 + setting CONNECT_PROFILE_MATCH_DONE in the CONNECT command. See also
31788 +
\93Scan and Roam
\94
31791 + wmiconfig eth1 --startscan <scan type> <forcefgscan> 0
31792 + <homeDwellTime> <forceScanInterval>
31794 +Command Parameters
31800 + WMI_LONG_SCAN =0x0
31801 + Requests a full scan
31802 + WMI_SHORT_SCAN =0x1
31803 + Requests a short scan
31806 + A_BOOL forceFgScan
31809 + Disable the foreground scan
31813 + Forces a foreground scan
31815 + A_UINT32 homeDwellTime
31816 + Maximum duration in the home
31819 + A_UINT32 forceScanInterval
31820 + Time interval between scans (in ms)
31822 + A_UINT32 scanType
31826 + Disable forcing foreground scan
31829 + isLegacy field will no longer be supported (pass as 0 for now)
31832 +=====================================================================
31838 + The host uses this command to force a synchronization point between the command
31844 +Command Parameters
31863 +=====================================================================
31866 + TARGET_ERROR_REPORT_BITMASK
31869 + Allows the host to control
\93ERROR_REPORT
\94 events from the AR6000 device.
31871 + If error reporting is disabled for an error type, a count of errors of that type is
31872 + maintained by the device.
31874 + If error reporting is enabled for an error type, an
\93ERROR_REPORT
\94 event is
31875 + sent when an error occurs and the error report bit is cleared.
31877 + Error counts for each error type are available through the
\93GET_TARGET_STATS
\94
31881 + wmiconfig eth1 --setErrorReportingBitmask
31883 +Command Parameters
31885 + Represents the set of
31886 + WMI_TARGET_ERROR_VAL error types
31887 + enabled for reporting
31891 + WMI_TARGET_PM_ERR_FAIL = 0x00000001
31892 + Power save fails (only two cases):
31893 + Retry out of null function/QoS null
31894 + function to associated AP for PS
31896 + Host changes the PS setting when
31897 + STA is off home channel
31899 + WMI_TARGET_KEY_NOT_FOUND = 0x00000002
31901 + WMI_TARGET_DECRYPTION_ERR = 0x00000004
31903 + WMI_TARGET_BMISS = 0x00000008
31905 + WMI_PSDISABLE_NODE_JOIN = 0x00000010
31906 + A non-PS-enabled STA joined the
31907 + PS-enabled network
31908 + WMI_TARGET_COM_ERR = 0x00000020
31909 + Host/target communication error
31910 + WMI_TARGET_FATAL_ERR = 0x00000040
31912 + } WMI_TARGET_ERROR_VAL
31915 + Bitmask is 0, and all error reporting is disabled
31921 +=====================================================================
31930 + Contains information describing BSSs collected during a scan
31933 + Indicates signalling events in admission control
31936 + The AR6000 device encounters an error while attempting to process
31940 + The device has connected to a wireless network
31943 + The device lost connectivity with a wireless network
31946 + An error has occurred for which the host previously requested
31947 + notification with the command
31948 +
\93TARGET_ERROR_REPORT_BITMASK
\94
31951 + WMI extension event
31953 +GET_PMKID_LIST_EVENT
31954 + Created in response to a
\93GET_PMKID_LIST_CMD
\94 command
31956 +GET_WOW_LIST_EVENT
31957 + Response to the wmiconfig
\93GET_WOW_LIST
\94 command to
31958 + retrieve the configured WoW patterns
31961 + Neighbor APs that match the current profile were detected
31963 +OPT_RX_FRAME_EVENT
31964 + (Special feature) informs the host of the reception of a special frame
31967 + A prioritized stream has been idle for a specified interval
31970 + The AR6000 device is ready to accept commands
31973 + The regulatory domain has changed
31975 +REPORT_ROAM_DATA_EVENT
31976 + Reports the roam time calculations made by the device
31977 + (generated with a special build)
31981 + Reply to a
\93GET_TARGET_STATS
\94 command
31984 + Reports the roam table
31987 + Signal strength from the connected AP has crossed the threshold
31988 + defined in the
\93RSSI_THRESHOLD_PARAMS
\94 command
31990 +SCAN_COMPLETE_EVENT
31991 + A scan has completed (added status SCAN_ABORTED in release 2.0)
31994 + Event generated by the TCMD
31997 + TKIP MIC errors were detected
31999 +=====================================================================
32005 + Contains information describing one or more BSSs as collected during a scan.
32006 + Information includes the BSSID, SSID, RSSI, network type, channel, supported rates,
32007 + and IEs. BSSINFO events are sent only after the device receives a beacon or probe-
32008 + response frame that pass the filter specified in the
\93SET_BSS_FILTER
\94 command.
32009 + BSSINFO events consist of a small header followed by a copy of the beacon or probe
32010 + response frame. The 802.11 header is not present. For formats of beacon and probe-
32011 + response frames please consult the IEEE 802.11 specification.
32013 + The beacons or probe responses containing the IE specified by the
32014 + WMI_BSS_FILTER_CMD are passed to the host through the
32015 + WMI_BSSINFO_EVENT. The event carries a 32-bit bitmask that indicates the IEs that
32016 + were detected in the management frame. The frame type field has been extended to
32017 + indicate action management frames. This would be helpful to route these frames
32018 + through the same event mechanism as used by the beacon processing function.
32020 + If the bssFilter in the SET_BSS_FILTER matches, then the ieMask is not relevant
32021 + because the BSSINFO event is sent to the host. If the bssFilter doesnot match in the
32022 + beacons/probe respones, then the ieMask match dictates whether the BSSINFO
32023 + event is sent to the host. In the case of action management frames, the ieMask is the
32024 + filter that is applied.
32031 + A_UINT16 channel;
32032 + Specifies the frequency (in MHz) where the
32033 + frame was received
32034 + A_UINT8 frameType;
32035 + A WMI_BI_FTYPE value
32038 + Indicates signal strength
32039 + A_UINT8 bssid[ATH_MAC_LEN];
32041 + } _ATTRIB_PACK_WMI_BSS_INFO_HDR;
32043 + Beacon or Probe Response Frame
32047 + BEACON_FTYPE = 0x1
32048 + Indicates a beacon frame
32050 + Indicates a probe response frame
32051 + ACTION_MGMT_FTYPE
32054 +=====================================================================
32060 + Indicates signalling events in admission control. Events are generated when
32061 + admission is accepted, rejected, or deleted by either the host or the AP. If the AP does
32062 + not respond to an admission request within a timeout of 500 ms, an event is
32063 + generated to the host.
32071 + Access class pertaining to the
32074 + UINT8 cac_indication
32075 + Type of indication; indications are
32076 + listed in WMI_CAC_INDICATION
32079 + AP response status code for a
32082 + UINT8 tspecSuggestion[63]
32083 + Suggested TSPEC from AP
32087 + CAC_INDICATION_ADMISSION = 0x00
32088 + CAC_INDICATION_ADMISSION_RESP = 0x01
32089 + CAC_INDICATION_DELETE = 0x02
32090 + CAC_INDICATION_NO_RESP = 0x03
32091 + } WMI_CAC_INDICATION
32094 +=====================================================================
32101 + Indicates that the AR6000 device encountered an error while attempting to process a
32102 + command. This error is fatal and indicates that the device requires a reset.
32109 + Corresponds to the command which generated
32112 + A WMI_ERROR_CODE value
32116 + INVALID_PARAM = 1
32117 + Invalid parameter
32118 + ILLEGAL_STATE = 2
32120 + INTERNAL_ERROR = 3
32122 + All other values reserved
32126 +=====================================================================
32133 + Signals that the AR6000 connected to a wireless network. Connection occurs due to a
32134 +
\93CONNECT
\94 command or roaming to a new AP. For infrastructure networks, shows
32135 + that the AR6000 successfully performed 802.11 authentication and AP association.
32142 + Channel frequency (in MHz) of the network the
32143 + AR6000 are connected to
32146 + MAC address of the AP the AR6000 are
32147 + connected to or the BSSID of the ad hoc
32150 + UINT16 listenInterval
32151 + Listen interval (in Kms) that the AR6000 are
32154 + UINT 8 beaconIeLen
32155 + Length (in bytes) of the beacon IEs
32158 + Pointer to an array containing beacon IEs,
32159 + followed first by association request IEs then by
32160 + association response IEs
32162 + UINT8 assocReqLen
32163 + Length (in bytes) of the assocReqIEs array
32165 + UINT8 assocRespLen
32166 + Length (in bytes) of the assocRespIEs array
32171 +=====================================================================
32178 + Signals that the AR6000 device lost connectivity with the wireless network.
32179 + DISCONENCT is generated when the device fails to complete a
\93CONNECT
\94
32180 + command or as a result of a transition from a connected state to disconnected state.
32182 + After sending the
\93DISCONNECT
\94 event the device continually tries to re-establish
32183 + a connection. A LOST_LINK occurs when STA cannot receive beacons within the
32184 + specified time for the SET_BMISS_TIME command.
32192 + A WMI_DISCONNECT_REASON value
32195 + Indicates which BSS the device was connected to
32197 + UINT8 assocRespLen
32198 + Length of the 802.11 association response frame
32199 + that triggered this event, or 0 if not applicable
32201 + UINT8 assocInfo[assocRespLen]
32202 + Copy of the 802.11 association response frame
32206 + NO_NETWORK_AVAIL =0x01
32207 + Indicates that the device was unable to
32208 + establish or find the desired network
32210 + Indicates the devices is no longer receiving
32211 + beacons from the BSS it was previously
32214 + DISCONNECT_CMD =0x03
32215 + Indicates a
\93DISCONNECT
\94 command was
32217 + BSS_DISCONNECTED =0x04
32218 + Indicates the BSS explicitly disconnected the
32219 + device. Possible mechanisms include the AP
32220 + sending 802.11 management frames
32221 + (e.g., disassociate or deauthentication
32223 + AUTH_FAILED =0x05
32224 + Indicates that the device failed 802.11
32225 + authentication with the BSS
32226 + ASSOC_FAILED =0x06
32227 + Indicates that the device failed 802.11
32228 + association with the BSS
32229 + NO_RESOURCES_AVAIL =0x07
32230 + Indicates that a connection failed because the
32231 + AP had insufficient resources to complete the
32233 + CSERV_DISCONNECT =0x08
32234 + Indicates that the device
\92s connection services
32235 + module decided to disconnect from a BSS,
32236 + which can happen for a variety of reasons (e.g.,
32237 + the host marks the current connected AP as a
32239 + INVALID_PROFILE =0x0A
32240 + Indicates that an attempt was made to
32241 + reconnect to a BSS that no longer matches the
32243 + All other values are reserved
32244 + } WMI_DISCONNECT_REASON
32247 +=====================================================================
32254 + Signals that a type of error has occurred for which the host previously requested
32255 + notification through the
\93TARGET_ERROR_REPORT_BITMASK
\94 command.
32262 + WMI_TARGET_ERROR_VAL value. See
32263 +
\93TARGET_ERROR_REPORT_BITMASK
\94.
32280 + A non-power save disabled node has joined
32281 + the PS-enabled network
32284 +=====================================================================
32291 + The WMI is used mostly for wireless control messages to a wireless module that
32292 + apply to wireless module management regardless of the target platform
32293 + implementation. However, some events peripherally related to wireless management
32294 + are desired during operation. These wireless extension events may be platform-
32295 + specific or implementation-dependent. See
\93WMI Extension Commands
\94
32302 +=====================================================================
32306 + GET_PMKID_LIST_EVENT
32309 + Generated by firmware in response to a
\93GET_PMKID_LIST_CMD
\94 command.
32313 + A_UINT32 numPMKID;
32314 + Contains the number of PMKIDs in the reply
32315 + WMI_PMKID pmkidList[1];
32316 + } __ATTRIB_PACK WMI_PMKID_LIST_REPLY;
32322 +=====================================================================
32326 + GET_WOW_LIST_EVENT
32329 + Response to the wmiconfig
\96getwowlist command to retrieve the configured Wake on
32330 + Wireless patterns
32338 + A_UINT8 num_filters
32339 + Total number of patterns in the list
32340 + A_UINT8 this_filter_num
32341 + The filter number
32343 + Shows whether WoW is enabled or disabled
32344 + A_UINT8 host_mode
32345 + Shows whether the host is asleep or awake
32346 + WOW_FILTER wow_filters[1]
32347 + List of WoW filters (pattern and mask data bytes)
32348 + } WMI_GET_WOW_LIST_REPLY;
32351 + Each wow_filter_list element shows:
32352 + A_UINT8 wow_valid_filter
32353 + Whether the filter is valid
32354 + A_UINT8 wow_filter_list_id
32355 + Filter List ID (23 = default)
32356 + A_UINT8 wow_filter_size
32357 + Size in bytes of the filter
32358 + A_UINT8 wow_filter_offset
32359 + Offset of the pattern to search in the data packet
32360 + A_UINT8 wow_filter_mask[MASK_SIZE]
32361 + The mask to be applied to the pattern
32362 + A_UINT8 wow_filter_pattern[WOW_PATTERN_SIZE]
32363 + The pattern that to match to wake up the host
32369 +=====================================================================
32377 + Indicates the existence of neighbor APs that match the current profile. The host uses
32378 + this event to populate the PMKID cache on the AR6000 and/or to perform
32379 + preauthentication. This event is only generated in infrastructure mode.
32381 + A total of numberOfAps pairs of bssid/bssFlags exist, one pair for each AP.
32387 + UINT8 numberOfAps
32388 + The number of APs reported about in
32392 + MAC address of a neighbor AP
32394 + A WMI_BSS_FLAGS value
32400 + WMI_DEFAULT_BSS_FLAGS = 0
32401 + Logical OR of 1 or more
32403 + WMI_PREAUTH_CAPABLE_BSS
32405 + Indicates that this AP is capable of
32406 + preauthentication
32407 + WMI_PMKID_VALID_BSS
32409 + Indicates that the AR6000 have a
32410 + valid pairwise master key for this AP
32414 +=====================================================================
32419 + OPT_RX_FRAME_EVENT
32422 + Special feature, informs host of the reception of a special frame.
32429 + A_UINT16 channel;
32430 + A_UINT8 frameType;
32432 + A_UINT8 srcAddr[ATH_MAC_LEN];
32433 + A_UINT8 bssid[ATH_MAC_LEN];
32434 + }WMI_OPT_RX_INFO_HDR
32439 +=====================================================================
32447 + Indicates that a priority stream that got created as a result of priority-marked data
32448 + flow (priority marked in IP TOS) being idle for the default inactivity interval period
32449 + (specified in the
\93CREATE_PSTREAM
\94 command) used for priority streams created
32450 + implicitly by the driver. This event is not indicated for user-created priority streams.
32451 + User-created priority streams exist until the users delete them explicitly. They do not
32452 + timeout due to data inactivity.
32460 + Indicated the traffic class of priority
32461 + stream that timed out
32476 +=====================================================================
32482 + Indicates that the AR6000 device is prepared to accept commands. It is sent once after
32483 + power on or reset. It also indicates the MAC address of the device.
32490 + Device MAC address
32491 + UINT8 phyCapability
32492 + A WMI_PHY_CAPABILITY value. Indicates the
32493 + capabilities of the device wireless module
\92s radio
32497 + WMI_11A_CAPABILITY = 1
32498 + WMI_11G_CAPABILITY = 2
32499 + WMI_11AG_CAPABILITY = 3
32500 + } WMI_PHY_CAPABILITY
32503 +=====================================================================
32509 + Indicates that the regulatory domain has changed. It initially occurs when the
32510 + AR6000 device reads the board data information. The regulatory domain can also
32511 + change when the device is a world-mode SKU. In this case, the regulatory domain is
32512 + based on the country advertised by APs per the IEEE 802.11d specification. A
32513 + potential side effect of a regulatory domain change is a change in the list of available
32514 + channels. Any channel restrictions that exist as a result of a previous
32515 +
\93SET_CHANNEL_PARAMETERS
\94 command are lifted.
32522 + The range of 0x0000
\96 0x00FF
32523 + corresponds to an ISO country code.
32525 + Other regCodes are reserved for world
32526 + mode settings and specific regulatory
32533 +=====================================================================
32538 + REPORT_STATISTICS
32541 + A reply to a
\93GET_TARGET_STATS
\94 command.
32547 + When the statistics are sent to the host, the AR6001 clear them so that a new set of
32548 + statistics are collected for the next report.
32550 + UINT32 tx_packets
32552 + UINT32 tx_unicast_pkts
32553 + UINT32 tx_unicast_bytes
32554 + UINT32 tx_multicast_pkts
32555 + UINT32 tx_multicast_bytes
32556 + UINT32 tx_broadcast_pkts
32557 + UINT32 tx_broadcast_bytes
32558 + UINT32 tx_rts_success_cnt
32559 + UINT32 tx_packet_per_ac[4]
32560 + Tx packets per AC: [0] = BE, [1] = BK,
32561 + [2] = VI, [3] = VO
32563 + Number of packets which failed Tx, due
32565 + ... REPORT_STATISTICS, continued
32566 + UINT32 tx_failed_cnt
32567 + Number of data packets that failed Tx
32568 + UINT32 tx_retry_cnt
32569 + Number of Tx retries for all packets
32570 + UINT32 tx_rts_fail_cnt
32571 + Number of RTS Tx failed count
32572 + UINT32 rx_packets
32574 + UINT32 rx_unicast_pkts
32575 + UINT32 rx_unicast_bytes
32576 + UINT32 rx_multicast_pkts
32577 + UINT32 rx_multicast_bytes
32578 + UINT32 rx_broadcast_pkts
32579 + UINT32 rx_broadcast_bytes
32580 + UINT32 rx_fragment_pkt
32581 + Number of fragmented packets received
32583 + Number of Rx errors due to all failures
32585 + Number of Rx errors due to CRC errors
32586 + UINT32 rx_key_cache_miss
32587 + Number of Rx errors due to a key not
32589 + UINT32 rx_decrypt_err
32590 + Number of Rx errors due to decryption
32592 + UINT32 rx_duplicate_frames
32593 + Number of duplicate frames received
32594 + UINT32 tkip_local_mic_failure
32595 + Number of TKIP MIC errors detected
32596 + UINT32 tkip_counter_measures_invoked
32597 + Number of times TKIP countermeasures
32599 + UINT32 tkip_replays
32600 + Number of frames that replayed a TKIP
32601 + encrypted frame received earlier
32602 + UINT32 tkip_format_errors
32603 + Number of frames that did not conform
32604 + to the TKIP frame format
32605 + UINT32 ccmp_format_errors
32606 + Number of frames that did not conform
32607 + to the CCMP frame format
32608 + UINT32 ccmp_replays
32609 + Number of frames that replayed a CCMP
32610 + encrypted frame received earlier
32611 + UINT32 power_save_failure_cnt
32612 + Number of failures that occurred when
32613 + the AR6001 could not go to sleep
32614 + UINT32 cs_bmiss_cnt
32615 + Number of BMISS interrupts since
32617 + UINT32 cs_lowRssi_cnt
32618 + Number of the times the RSSI went below
32619 + the low RSSI threshold
32620 + UINT16 cs_connect_cnt
32621 + Number of connection times
32622 + UINT16 cs_disconnect_cnt
32623 + Number of disconnection times
32624 + UINT8 cs_aveBeacon_rssi
32625 + The current averaged value of the RSSI
32626 + from the beacons of the connected BSS
32627 + UINT8 cs_lastRoam_msec
32628 + Time that the last roaming took, in ms.
32629 + This time is the difference between
32630 + roaming start and actual connection.
32636 +=====================================================================
32642 + Reports the roam table, which contains the current roam mode and this information
32649 + A_UINT8 bssid[ATH_MAC_LEN];
32655 + A_UINT8 last_rssi
32656 + Last recorded RSSI
32657 + A_UINT8 roam_util
32658 + Utility value used in roaming decision
32660 + Base utility with the BSS
32662 + Host configured for this BSS
32666 + Current roam mode
32672 + Host bias-based roam
32675 + Lock to the current BSS
32678 + Autonomous roaming disabled
32681 +=====================================================================
32687 + Alerts the host that the signal strength from the connected AP has crossed a
32688 + interesting threshold as defined in a previous
\93RSSI_THRESHOLD_PARAMS
\94
32696 + A WMI_RSSI_THRESHOLD_VAL
32697 + value, which indicates the range of
32698 + the average signal strength
32702 + WMI_RSSI_LOWTHRESHOLD_BELOW_LOWERVAL = 1
32703 + WMI_RSSI_LOWTHRESHOLD_LOWERVAL = 2
32704 + WMI_RSSI_LOWTHRESHOLD_UPPERVAL = 3
32705 + WMI_RSSI_HIGHTHRESHOLD_LOWERVAL = 4
32706 + WMI_RSSI_HIGHTHRESHOLD_HIGHERVAL = 5
32707 + } WMI_RSSI_THRESHOLD_VAL
32710 +=====================================================================
32713 + SCAN_COMPLETE_EVENT
32716 + Indicates the scan status. if the Scan was not completed, this event is generated with
32717 + the status A_ECANCELED.
32723 + A_UINT8 scanStatus
32727 + #define SCAN_ABORTED 16
32728 + #define SCAN_COMPLETED 0
32729 + A_UINT8 scanStatus
32730 + A_OK or A_ECANCELED
32731 + } WMI_SCAN_COMPLETE_EVENT;
32734 +=====================================================================
32740 + The TCMD application uses a single WMI event (WMI_TEST_EVENTID) to
32741 + communicate events from target to host. The events are parsed by the TCMD
32742 + application and WMI layer is oblivious of it.
32755 +=====================================================================
32763 + Indicates that TKIP MIC errors were detected.
32770 + Indicates the TKIP key ID
32777 + See event parameters
32779 +=====================================================================
32781 +WMI Extension Commands
32783 +The WMI EXTENSION command is used to multiplex a collection of
32786 + Are not generic wireless commands
32787 + May be implementation-specific
32788 + May be target platform-specific
32789 + May be optional for a host implementation
32791 + An extension command is sent to the AR6000 targets like any other WMI
32792 +command message and uses the WMI_EXTENSION. The first field of the
32793 +payload for this EXTENSION command is another commandId, sometimes
32794 +called the subcommandId, which indicates which extension command is
32795 +being used. A subcommandId-specific payload follows the subcommandId.
32797 +All extensions (subcommandIds) are listed in the header file include/wmix.h.
32798 +See also
\93WMI Extension Events
\94 on page B-58.
32801 +WMI Extension Commands
32805 + Read GPIO pins configured for input
32808 + Acknowledge and re-arm GPIO interrupts reported earlier
32811 + Manage output on GPIO pins configured for output
32814 + Read an arbitrary GPIO register
32817 + Dynamically change GPIO configuration
32820 + Set link quality thresholds; the sampling happens at every unicast
32821 + data frame Tx, if certain thresholds are met, and corresponding
32822 + events are sent to the host
32825 +=====================================================================
32831 + Allows the host to read GPIO pins that are configured for input. The values read are
32832 + returned through a
\93GPIO_DATA
\94 extension event.
32834 +NOTE: Support for GPIO is optional.
32839 +Command Parameters
32856 +=====================================================================
32863 + The host uses this command to acknowledge and to re-arm GPIO interrupts reported
32864 + through an earlier
\93GPIO_INTR
\94 extension event. A single
\93GPIO_INTR_ACK
\94
32865 + command should be used to acknowledge all GPIO interrupts that the host knows to
32866 + be outstanding (if pending interrupts are not acknowledged through
32867 +
\93GPIO_INTR_ACK
\94, another
\93GPIO_INTR
\94 extension event is raised).
32869 +NOTE: Support for GPIO is optional.
32874 +Command Parameters
32876 + A mask of interrupting GPIO pins (e.g., ack_mask
32877 + bit [3] acknowledges an interrupt from the pin GPIO3).
32886 + The host should acknowledge only interrupts about which it was notified.
32889 +=====================================================================
32895 + Manages output on GPIO pins configured for output.
32897 + Conflicts between set_mask and clear_mask or enable_mask and disable_mask result
32898 + in undefined behavior.
32900 +NOTE: Support for GPIO is optional.
32905 +Command Parameters
32907 + Specifies which pins should drive a 1 out
32908 + UINT32 clear_mask
32909 + Specifies which pins should drive a 0 out
32910 + UINT32 enable_mask
32911 + Specifies which pins should be enabled for output
32912 + UINT32 disable_mask
32913 + Specifies which pins should be disabled for output
32928 +=====================================================================
32932 + GPIO_REGISTER_GET
32935 + Allows the host to read an arbitrary GPIO register. It is intended for use during
32936 + bringup/debug. The target responds to this command with a
\93GPIO_DATA
\94 event.
32938 +NOTE: Support for GPIO is optional.
32943 +Command Parameters
32946 + Specifies a GPIO register identifier, as defined
32947 +in include/AR6000/AR6000_gpio.h
32959 +=====================================================================
32962 + GPIO_REGISTER_SET
32965 + Allows the host to dynamically change GPIO configuration (usually handled
32966 + statically through the GPIO configuration DataSet).
32968 +NOTE: Support for GPIO is optional.
32973 +Command Parameters
32974 + UINT32 gpioreg_id
32975 + Specifies a GPIO register identifier, as defined in
32976 + include/AR6000/AR6000_gpio.h
32978 + Specifies a value to write to the specified
32986 + Initial hardware configuration is as defined in the AR6001 or AR6002 ROCmTM
32987 + Single-Chip MAC/BB/Radio for 2.4/5 GHz Embedded WLAN Applications data sheet. This
32988 + configuration is modified by the GPIO Configuration DataSet, if one exists.
32994 +=====================================================================
33001 + Set link quality thresholds, the sampling happens at every unicast data frame Tx, if
33002 + certain threshold is met, corresponding event will be sent to host.
33005 + wmiconfig eth1 --lqThreshold <enable> <upper_threshold_1>...
33006 + <upper_threshold_4> <lower_threshold_1>... <lower_threshold_4>
33008 +Command Parameters
33010 + A_UINT8 thresholdAbove1_Val;
33011 + A_UINT8 thresholdAbove2_Val;
33012 + A_UINT8 thresholdAbove3_Val;
33013 + A_UINT8 thresholdAbove4_Val;
33014 + A_UINT8 thresholdBelow1_Val;
33015 + A_UINT8 thresholdBelow2_Val;
33016 + A_UINT8 thresholdBelow3_Val;
33017 + A_UINT8 thresholdBelow4_Val;
33022 + Disable link quality sampling
33025 + Enable link quality sampling
33028 + thresholdAbove_Val
33030 + Above thresholds (value in [0,100]), in ascending
33033 + Below_Val [1...4] = below thresholds (value
33034 + in [0,100]), in ascending order
33042 +=====================================================================
33043 +WMI Extension Events
33045 +The WMI EXTENSION event is used for a collection of events that:
33047 + Are not generic wireless events
33048 + May be implementation-specific
33049 + May be target platform-specific
33050 + May be optional for a host implementation
33052 + An extension event is sent from the AR6000 device targets to the host just like
33053 +any other WMI event message, using the WMI_EXTENSION_EVENTID. The
33054 +first field of the payload for this
\93EXTENSION
\94 event is another commandId
33055 +(sometimes called the subcommandId) that indicates which
\93EXTENSION
\94
33056 +event is being used. A subcommandId-specific payload follows the
33059 +All extensions (subcommandIds) are listed in the header file include/wmix.h.
33060 +See also
\93WMI Extension Commands
\94 on page B-55.
33063 +WMI Extension Events
33067 + Acknowledges a host set command has been processed by the device
33070 + Response to a host
\92s request for data
33073 + Signals that GPIO interrupts are pending
33076 +=====================================================================
33082 + Acknowledges that a host set command (either
\93GPIO_OUTPUT_SET
\94 or
33083 +
\93GPIO_REGISTER_SET
\94) has been processed by the AR6000 device.
33085 +NOTE: Support for GPIO is optional.
33097 +=====================================================================
33104 + The AR6000 device uses this event to respond to the host
\92s earlier request for data
33105 + (through either a
\93GPIO_REGISTER_GET
\94 or a
\93GPIO_INPUT_GET
\94 command).
33107 +NOTE: Support for GPIO is optional.
33114 + Holds the data of interest, which is either a register value
33115 + (in the case of
\93GPIO_REGISTER_GET
\94) or a mask of
33116 + pin inputs (in the case of
\93GPIO_INPUT_GET
\94).
33118 + Indicates which register was read (in the case of
33119 +
\93GPIO_REGISTER_GET
\94) or is GPIO_ID_NONE (in the
33120 + case of
\93GPIO_INPUT_GET
\94)
33126 +=====================================================================
33134 + The AR6000 device raises this event to signal that GPIO interrupts are pending.
33135 + These GPIOs may be interrupts that occurred after the last
\93GPIO_INTR_ACK
\94
33136 + command was issued, or may be GPIO interrupts that the host failed to acknowledge
33137 + in the last
\93GPIO_INTR_ACK
\94. The AR6000 will not raise another GPIO_INTR
33138 + event until this event is acknowledged through a
\93GPIO_INTR_ACK
\94 command.
33140 +NOTE: Support for GPIO is optional.
33147 + Indicates which GPIO interrupts are currently pending
33149 + UINT32 input_values
33150 + A recent copy of the GPIO input values, taken at the
33151 + time the most recent GPIO interrupt was processed
33158 +=====================================================================
33160 diff --git a/drivers/sdio/function/wlan/ar6000/wmi/wmi_host.h b/drivers/sdio/function/wlan/ar6000/wmi/wmi_host.h
33161 new file mode 100644
33162 index 0000000..57844bc
33164 +++ b/drivers/sdio/function/wlan/ar6000/wmi/wmi_host.h
33166 +#ifndef _WMI_HOST_H_
33167 +#define _WMI_HOST_H_
33169 + * Copyright (c) 2004-2006 Atheros Communications Inc.
33170 + * All rights reserved.
33172 + * This file contains local definitios for the wmi host module.
33174 + * $Id: //depot/sw/releases/olca2.0-GPL/host/wmi/wmi_host.h#1 $
33177 + * This program is free software; you can redistribute it and/or modify
33178 + * it under the terms of the GNU General Public License version 2 as
33179 + * published by the Free Software Foundation;
33181 + * Software distributed under the License is distributed on an "AS
33182 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
33183 + * implied. See the License for the specific language governing
33184 + * rights and limitations under the License.
33190 +#ifdef __cplusplus
33194 +struct wmi_stats {
33195 + A_UINT32 cmd_len_err;
33196 + A_UINT32 cmd_id_err;
33200 + A_BOOL wmi_ready;
33201 + A_BOOL wmi_numQoSStream;
33202 + A_UINT8 wmi_wmiStream2AcMapping[WMI_PRI_MAX_COUNT];
33203 + WMI_PRI_STREAM_ID wmi_ac2WmiStreamMapping[WMM_NUM_AC];
33204 + A_UINT16 wmi_streamExistsForAC[WMM_NUM_AC];
33205 + A_UINT8 wmi_fatPipeExists;
33207 + struct wmi_stats wmi_stats;
33208 + struct ieee80211_node_table wmi_scan_table;
33209 + A_UINT8 wmi_bssid[ATH_MAC_LEN];
33210 + A_UINT8 wmi_powerMode;
33211 + A_UINT8 wmi_phyMode;
33212 + A_UINT8 wmi_keepaliveInterval;
33213 + A_MUTEX_T wmi_lock;
33216 +#define WMI_INIT_WMISTREAM_AC_MAP(w) \
33217 +{ (w)->wmi_wmiStream2AcMapping[WMI_BEST_EFFORT_PRI] = WMM_AC_BE; \
33218 + (w)->wmi_wmiStream2AcMapping[WMI_LOW_PRI] = WMM_AC_BK; \
33219 + (w)->wmi_wmiStream2AcMapping[WMI_HIGH_PRI] = WMM_AC_VI; \
33220 + (w)->wmi_wmiStream2AcMapping[WMI_HIGHEST_PRI] = WMM_AC_VO; \
33221 + (w)->wmi_ac2WmiStreamMapping[WMM_AC_BE] = WMI_BEST_EFFORT_PRI; \
33222 + (w)->wmi_ac2WmiStreamMapping[WMM_AC_BK] = WMI_LOW_PRI; \
33223 + (w)->wmi_ac2WmiStreamMapping[WMM_AC_VI] = WMI_HIGH_PRI; \
33224 + (w)->wmi_ac2WmiStreamMapping[WMM_AC_VO] = WMI_HIGHEST_PRI; }
33226 +#define WMI_WMISTREAM_ACCESSCATEGORY(w,s) (w)->wmi_wmiStream2AcMapping[s]
33227 +#define WMI_ACCESSCATEGORY_WMISTREAM(w,ac) (w)->wmi_ac2WmiStreamMapping[ac]
33229 +#define LOCK_WMI(w) A_MUTEX_LOCK(&(w)->wmi_lock);
33230 +#define UNLOCK_WMI(w) A_MUTEX_UNLOCK(&(w)->wmi_lock);
33232 +#ifdef __cplusplus
33236 +#endif /* _WMI_HOST_H_ */