[adm5120] add USB drivers for the NFS-101U/WU profiles
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1063-atheros_2_0_function.patch.patch
1 From 5fe4b00cb39ab337cfeab4ceb8ad252b9aac4583 Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Sun, 13 Apr 2008 07:23:55 +0100
4 Subject: [PATCH] atheros_2_0_function.patch
5
6 ---
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
176
177 diff --git a/drivers/sdio/function/Kconfig b/drivers/sdio/function/Kconfig
178 new file mode 100644
179 index 0000000..9b46af3
180 --- /dev/null
181 +++ b/drivers/sdio/function/Kconfig
182 @@ -0,0 +1,11 @@
183 +#menu "SDIO function drivers"
184 +
185 +config SDIO_AR6000_WLAN
186 + tristate "ar6000 wireless networking over sdio"
187 + depends on SDIO
188 + select WIRELESS_EXT
189 + default m
190 + help
191 + good luck.
192 +
193 +#endmenu
194 \ No newline at end of file
195 diff --git a/drivers/sdio/function/Makefile b/drivers/sdio/function/Makefile
196 new file mode 100644
197 index 0000000..4940d37
198 --- /dev/null
199 +++ b/drivers/sdio/function/Makefile
200 @@ -0,0 +1 @@
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
204 new file mode 100644
205 index 0000000..b1e61fc
206 --- /dev/null
207 +++ b/drivers/sdio/function/wlan/Makefile
208 @@ -0,0 +1,4 @@
209 +#
210 +# SDIO wlan ar600 card function driver
211 +#
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
215 new file mode 100644
216 index 0000000..810dab6
217 --- /dev/null
218 +++ b/drivers/sdio/function/wlan/ar6000/Makefile
219 @@ -0,0 +1,38 @@
220 +REV ?= 2
221 +
222 +PWD := $(shell pwd)
223 +
224 +EXTRA_CFLAGS += -I$(src)/include
225 +
226 +EXTRA_CFLAGS += -DLINUX -DDEBUG -D__KERNEL__ -DHTC_RAW_INTERFACE\
227 + -DTCMD -DSEND_EVENT_TO_APP -DUSER_KEYS \
228 + -DNO_SYNC_FLUSH #\
229 + -DMULTIPLE_FRAMES_PER_INTERRUPT -DAR6000REV$(REV) \
230 + -DBLOCK_TX_PATH_FLAG \
231 + -DSDIO \
232 +
233 +EXTRA_CFLAGS += -DKERNEL_2_6
234 +
235 +obj-$(CONFIG_SDIO_AR6000_WLAN) += ar6000.o
236 +
237 +ar6000-objs += htc/ar6k.o \
238 + htc/ar6k_events.o \
239 + htc/htc_send.o \
240 + htc/htc_recv.o \
241 + htc/htc_services.o \
242 + htc/htc.o \
243 + hif/hif.o \
244 + bmi/bmi.o \
245 + ar6000/ar6000_drv.o \
246 + ar6000/ar6000_raw_if.o \
247 + ar6000/netbuf.o \
248 + ar6000/wireless_ext.o \
249 + ar6000/ioctl.o \
250 + miscdrv/common_drv.o \
251 + miscdrv/credit_dist.o \
252 + wmi/wmi.o \
253 + wlan/wlan_node.o \
254 + wlan/wlan_recv_beacon.o \
255 + wlan/wlan_utils.o
256 +
257 +
258 diff --git a/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
259 new file mode 100644
260 index 0000000..bb9ef55
261 --- /dev/null
262 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
263 @@ -0,0 +1,3062 @@
264 +/*
265 + *
266 + * Copyright (c) 2004-2007 Atheros Communications Inc.
267 + * All rights reserved.
268 + *
269 + *
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;
273 + *
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.
278 + *
279 + *
280 + *
281 + */
282 +
283 +/*
284 + * This driver is a pseudo ethernet driver to access the Atheros AR6000
285 + * WLAN Device
286 + */
287 +static const char athId[] __attribute__ ((unused)) = "$Id: //depot/sw/releases/olca2.0-GPL/host/os/linux/ar6000_drv.c#2 $";
288 +
289 +#include "ar6000_drv.h"
290 +#include "htc.h"
291 +
292 +MODULE_LICENSE("GPL and additional rights");
293 +
294 +#ifndef REORG_APTC_HEURISTICS
295 +#undef ADAPTIVE_POWER_THROUGHPUT_CONTROL
296 +#endif /* REORG_APTC_HEURISTICS */
297 +
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 */
302 +
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;
309 +
310 +A_TIMER aptcTimer;
311 +APTC_TRAFFIC_RECORD aptcTR;
312 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
313 +
314 +int bmienable = 0;
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;
331 +#endif
332 +
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);
351 +#endif
352 +#else
353 +
354 +#define __user
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");
372 +#endif
373 +#endif
374 +
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
379 +#else
380 +unsigned int mboxnum = HTC_MAILBOX_NUM_MAX;
381 +#endif
382 +
383 +#ifdef DEBUG
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};
395 +
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);
407 +#else
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");
419 +#endif
420 +
421 +#endif /* DEBUG */
422 +
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 */
440 +#else
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 */
449 +#endif
450 +
451 +#ifdef BLOCK_TX_PATH_FLAG
452 +int blocktx = 0;
453 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
454 +module_param(blocktx, int, 0644);
455 +#else
456 +MODULE_PARM(blocktx, "i");
457 +#endif
458 +#endif /* BLOCK_TX_PATH_FLAG */
459 +
460 +// TODO move to arsoft_c
461 +USER_RSSI_THOLD rssi_map[12];
462 +
463 +int reconnect_flag = 0;
464 +
465 +DECLARE_WAIT_QUEUE_HEAD(ar6000_scan_queue);
466 +
467 +/* Function declarations */
468 +static int ar6000_init_module(void);
469 +static void ar6000_cleanup_module(void);
470 +
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);
476 +
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);
481 +
482 +/*
483 + * HTC service connection handlers
484 + */
485 +static void ar6000_avail_ev(HTC_HANDLE HTCHandle);
486 +
487 +static void ar6000_unavail_ev(void *Instance);
488 +
489 +static void ar6000_target_failure(void *Instance, A_STATUS Status);
490 +
491 +static void ar6000_rx(void *Context, HTC_PACKET *pPacket);
492 +
493 +static void ar6000_rx_refill(void *Context,HTC_ENDPOINT_ID Endpoint);
494 +
495 +static void ar6000_tx_complete(void *Context, HTC_PACKET *pPacket);
496 +
497 +static void ar6000_tx_queue_full(void *Context, HTC_ENDPOINT_ID Endpoint);
498 +
499 +/*
500 + * Static variables
501 + */
502 +
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);
511 +
512 +#ifdef USER_KEYS
513 +static A_STATUS ar6000_reinstall_keys(AR_SOFTC_T *ar,A_UINT8 key_op_ctrl);
514 +#endif
515 +
516 +
517 +static struct ar_cookie s_ar_cookie_mem[MAX_COOKIE_NUM];
518 +
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))
523 +
524 +
525 +/* Debug log support */
526 +
527 +/*
528 + * Flag to govern whether the debug logs should be parsed in the kernel
529 + * or reported to the application.
530 + */
531 +#define REPORT_DEBUG_LOGS_TO_APP
532 +
533 +A_STATUS
534 +ar6000_set_host_app_area(AR_SOFTC_T *ar)
535 +{
536 + A_UINT32 address, data;
537 + struct host_app_area_s host_app_area;
538 +
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) {
542 + return A_ERROR;
543 + }
544 + address = data;
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)
549 + {
550 + return A_ERROR;
551 + }
552 +
553 + return A_OK;
554 +}
555 +
556 +A_UINT32
557 +dbglog_get_debug_hdr_ptr(AR_SOFTC_T *ar)
558 +{
559 + A_UINT32 param;
560 + A_UINT32 address;
561 + A_STATUS status;
562 +
563 + address = HOST_INTEREST_ITEM_ADDRESS(ar, hi_dbglog_hdr);
564 + if ((status = ar6000_ReadDataDiag(ar->arHifDevice, address,
565 + (A_UCHAR *)&param, 4)) != A_OK)
566 + {
567 + param = 0;
568 + }
569 +
570 + return param;
571 +}
572 +
573 +/*
574 + * The dbglog module has been initialized. Its ok to access the relevant
575 + * data stuctures over the diagnostic window.
576 + */
577 +void
578 +ar6000_dbglog_init_done(AR_SOFTC_T *ar)
579 +{
580 + ar->dbglog_init_done = TRUE;
581 +}
582 +
583 +A_UINT32
584 +dbglog_get_debug_fragment(A_INT8 *datap, A_UINT32 len, A_UINT32 limit)
585 +{
586 + A_INT32 *buffer;
587 + A_UINT32 count;
588 + A_UINT32 numargs;
589 + A_UINT32 length;
590 + A_UINT32 fraglen;
591 +
592 + count = fraglen = 0;
593 + buffer = (A_INT32 *)datap;
594 + length = (limit >> 2);
595 +
596 + if (len <= limit) {
597 + fraglen = len;
598 + } else {
599 + while (count < length) {
600 + numargs = DBGLOG_GET_NUMARGS(buffer[count]);
601 + fraglen = (count << 2);
602 + count += numargs + 1;
603 + }
604 + }
605 +
606 + return fraglen;
607 +}
608 +
609 +void
610 +dbglog_parse_debug_logs(A_INT8 *datap, A_UINT32 len)
611 +{
612 + A_INT32 *buffer;
613 + A_UINT32 count;
614 + A_UINT32 timestamp;
615 + A_UINT32 debugid;
616 + A_UINT32 moduleid;
617 + A_UINT32 numargs;
618 + A_UINT32 length;
619 +
620 + count = 0;
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]);
628 + switch (numargs) {
629 + case 0:
630 + AR_DEBUG_PRINTF("%d %d (%d)\n", moduleid, debugid, timestamp);
631 + break;
632 +
633 + case 1:
634 + AR_DEBUG_PRINTF("%d %d (%d): 0x%x\n", moduleid, debugid,
635 + timestamp, buffer[count+1]);
636 + break;
637 +
638 + case 2:
639 + AR_DEBUG_PRINTF("%d %d (%d): 0x%x, 0x%x\n", moduleid, debugid,
640 + timestamp, buffer[count+1], buffer[count+2]);
641 + break;
642 +
643 + default:
644 + AR_DEBUG_PRINTF("Invalid args: %d\n", numargs);
645 + }
646 + count += numargs + 1;
647 + }
648 +}
649 +
650 +int
651 +ar6000_dbglog_get_debug_logs(AR_SOFTC_T *ar)
652 +{
653 + struct dbglog_hdr_s debug_hdr;
654 + struct dbglog_buf_s debug_buf;
655 + A_UINT32 address;
656 + A_UINT32 length;
657 + A_UINT32 dropped;
658 + A_UINT32 firstbuf;
659 + A_UINT32 debug_hdr_ptr;
660 +
661 + if (!ar->dbglog_init_done) return A_ERROR;
662 +
663 +
664 + AR6000_SPIN_LOCK(&ar->arLock, 0);
665 +
666 + if (ar->dbgLogFetchInProgress) {
667 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
668 + return A_EBUSY;
669 + }
670 +
671 + /* block out others */
672 + ar->dbgLogFetchInProgress = TRUE;
673 +
674 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
675 +
676 + debug_hdr_ptr = dbglog_get_debug_hdr_ptr(ar);
677 + printk("debug_hdr_ptr: 0x%x\n", debug_hdr_ptr);
678 +
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);
691 +
692 + do {
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)) {
698 + ar->log_cnt = 0;
699 + }
700 + if(A_OK != ar6000_ReadDataDiag(ar->arHifDevice, address,
701 + (A_UCHAR *)&ar->log_buffer[ar->log_cnt], length))
702 + {
703 + break;
704 + }
705 + ar6000_dbglog_event(ar, dropped, &ar->log_buffer[ar->log_cnt], length);
706 + ar->log_cnt += length;
707 + } else {
708 + AR_DEBUG_PRINTF("Length: %d (Total size: %d)\n",
709 + debug_buf.length, debug_buf.bufsize);
710 + }
711 +
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))
716 + {
717 + break;
718 + }
719 +
720 + } while (address != firstbuf);
721 + }
722 +
723 + ar->dbgLogFetchInProgress = FALSE;
724 +
725 + return A_OK;
726 +}
727 +
728 +void
729 +ar6000_dbglog_event(AR_SOFTC_T *ar, A_UINT32 dropped,
730 + A_INT8 *buffer, A_UINT32 length)
731 +{
732 +#ifdef REPORT_DEBUG_LOGS_TO_APP
733 + #define MAX_WIRELESS_EVENT_SIZE 252
734 + /*
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.
738 + */
739 + A_UINT32 send, sent;
740 +
741 + sent = 0;
742 + send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
743 + MAX_WIRELESS_EVENT_SIZE);
744 + while (send) {
745 + ar6000_send_event_to_app(ar, WMIX_DBGLOG_EVENTID, &buffer[sent], send);
746 + sent += send;
747 + send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
748 + MAX_WIRELESS_EVENT_SIZE);
749 + }
750 +#else
751 + AR_DEBUG_PRINTF("Dropped logs: 0x%x\nDebug info length: %d\n",
752 + dropped, length);
753 +
754 + /* Interpret the debug logs */
755 + dbglog_parse_debug_logs(buffer, length);
756 +#endif /* REPORT_DEBUG_LOGS_TO_APP */
757 +}
758 +
759 +
760 +
761 +static int __init
762 +ar6000_init_module(void)
763 +{
764 + static int probed = 0;
765 + A_STATUS status;
766 + HTC_INIT_INFO initInfo;
767 +
768 + A_MEMZERO(&initInfo,sizeof(initInfo));
769 + initInfo.AddInstance = ar6000_avail_ev;
770 + initInfo.DeleteInstance = ar6000_unavail_ev;
771 + initInfo.TargetFailure = ar6000_target_failure;
772 +
773 +
774 +#ifdef DEBUG
775 + /* Set the debug flags if specified at load time */
776 + if(debugflags != 0)
777 + {
778 + g_dbg_flags = debugflags;
779 + }
780 +#endif
781 +
782 + if (probed) {
783 + return -ENODEV;
784 + }
785 + probed++;
786 +
787 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
788 + memset(&aptcTR, 0, sizeof(APTC_TRAFFIC_RECORD));
789 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
790 +
791 +#ifdef CONFIG_HOST_GPIO_SUPPORT
792 + ar6000_gpio_init();
793 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
794 +
795 + status = HTCInit(&initInfo);
796 + if(status != A_OK)
797 + return -ENODEV;
798 +
799 + return 0;
800 +}
801 +
802 +static void __exit
803 +ar6000_cleanup_module(void)
804 +{
805 + int i = 0;
806 + struct net_device *ar6000_netdev;
807 +
808 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
809 + /* Delete the Adaptive Power Control timer */
810 + if (timer_pending(&aptcTimer)) {
811 + del_timer_sync(&aptcTimer);
812 + }
813 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
814 +
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);
820 + }
821 + }
822 +
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 */
826 + HTCShutDown();
827 +
828 + AR_DEBUG_PRINTF("ar6000_cleanup: success\n");
829 +}
830 +
831 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
832 +void
833 +aptcTimerHandler(unsigned long arg)
834 +{
835 + A_UINT32 numbytes;
836 + A_UINT32 throughput;
837 + AR_SOFTC_T *ar;
838 + A_STATUS status;
839 +
840 + ar = (AR_SOFTC_T *)arg;
841 + A_ASSERT(ar != NULL);
842 + A_ASSERT(!timer_pending(&aptcTimer));
843 +
844 + AR6000_SPIN_LOCK(&ar->arLock, 0);
845 +
846 + /* Get the number of bytes transferred */
847 + numbytes = aptcTR.bytesTransmitted + aptcTR.bytesReceived;
848 + aptcTR.bytesTransmitted = aptcTR.bytesReceived = 0;
849 +
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;
860 + } else {
861 + A_TIMEOUT_MS(&aptcTimer, APTC_TRAFFIC_SAMPLING_INTERVAL, 0);
862 + }
863 +
864 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
865 +}
866 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
867 +
868 +
869 +
870 +/* set HTC block size, assume BMI is already initialized */
871 +A_STATUS ar6000_SetHTCBlockSize(AR_SOFTC_T *ar)
872 +{
873 + A_STATUS status;
874 + A_UINT32 blocksizes[HTC_MAILBOX_NUM_MAX];
875 +
876 + do {
877 + /* get the block sizes */
878 + status = HIFConfigureDevice(ar->arHifDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
879 + blocksizes, sizeof(blocksizes));
880 +
881 + if (A_FAILED(status)) {
882 + AR_DEBUG_PRINTF("Failed to get block size info from HIF layer...\n");
883 + break;
884 + }
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);
889 +
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],
894 + 4);
895 +
896 + if (A_FAILED(status)) {
897 + AR_DEBUG_PRINTF("BMIWriteMemory for IO block size failed \n");
898 + break;
899 + }
900 +
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));
903 +
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,
908 + 4);
909 +
910 + if (A_FAILED(status)) {
911 + AR_DEBUG_PRINTF("BMIWriteMemory for yield limit failed \n");
912 + break;
913 + }
914 +
915 + } while (FALSE);
916 +
917 + return status;
918 +}
919 +
920 +/*
921 + * HTC Event handlers
922 + */
923 +static void
924 +ar6000_avail_ev(HTC_HANDLE HTCHandle)
925 +{
926 + int i;
927 + struct net_device *dev;
928 + AR_SOFTC_T *ar;
929 + int device_index = 0;
930 +
931 + AR_DEBUG_PRINTF("ar6000_available\n");
932 +
933 + for (i=0; i < MAX_AR6000; i++) {
934 + if (ar6000_devices[i] == NULL) {
935 + break;
936 + }
937 + }
938 +
939 + if (i == MAX_AR6000) {
940 + AR_DEBUG_PRINTF("ar6000_available: max devices reached\n");
941 + return;
942 + }
943 +
944 + /* Save this. It gives a bit better readability especially since */
945 + /* we use another local "i" variable below. */
946 + device_index = i;
947 +
948 + A_ASSERT(HTCHandle != NULL);
949 +
950 + dev = alloc_etherdev(sizeof(AR_SOFTC_T));
951 + if (dev == NULL) {
952 + AR_DEBUG_PRINTF("ar6000_available: can't alloc etherdev\n");
953 + return;
954 + }
955 +
956 + ether_setup(dev);
957 +
958 + if (dev->priv == NULL) {
959 + printk(KERN_CRIT "ar6000_available: Could not allocate memory\n");
960 + return;
961 + }
962 +
963 + A_MEMZERO(dev->priv, sizeof(AR_SOFTC_T));
964 +
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;
971 +
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;
978 +
979 + ar6000_init_control_info(ar);
980 + init_waitqueue_head(&arEvent);
981 + sema_init(&ar->arSem, 1);
982 +
983 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
984 + A_INIT_TIMER(&aptcTimer, aptcTimerHandler, ar);
985 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
986 +
987 + /*
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
990 + * OS from ROM.
991 + *
992 + * This is intended to support recovery from a corrupted flash on Targets
993 + * that support flash.
994 + */
995 + if (skipflash)
996 + {
997 + ar6000_reset_device_skipflash(ar->arHifDevice);
998 + }
999 +
1000 + BMIInit();
1001 + {
1002 + struct bmi_target_info targ_info;
1003 +
1004 + if (BMIGetTargetInfo(ar->arHifDevice, &targ_info) != A_OK) {
1005 + return;
1006 + }
1007 +
1008 + ar->arVersion.target_ver = targ_info.target_ver;
1009 + ar->arTargetType = targ_info.target_type;
1010 + }
1011 +
1012 + if (enableuartprint) {
1013 + A_UINT32 param;
1014 + param = 1;
1015 + if (BMIWriteMemory(ar->arHifDevice,
1016 + HOST_INTEREST_ITEM_ADDRESS(ar, hi_serial_enable),
1017 + (A_UCHAR *)&param,
1018 + 4)!= A_OK)
1019 + {
1020 + AR_DEBUG_PRINTF("BMIWriteMemory for enableuartprint failed \n");
1021 + return ;
1022 + }
1023 + AR_DEBUG_PRINTF("Serial console prints enabled\n");
1024 + }
1025 +#ifdef CONFIG_HOST_TCMD_SUPPORT
1026 + if(testmode) {
1027 + ar->arTargetMode = AR6000_TCMD_MODE;
1028 + }else {
1029 + ar->arTargetMode = AR6000_WLAN_MODE;
1030 + }
1031 +#endif
1032 + if (enabletimerwar) {
1033 + A_UINT32 param;
1034 +
1035 + if (BMIReadMemory(ar->arHifDevice,
1036 + HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1037 + (A_UCHAR *)&param,
1038 + 4)!= A_OK)
1039 + {
1040 + AR_DEBUG_PRINTF("BMIReadMemory for enabletimerwar failed \n");
1041 + return;
1042 + }
1043 +
1044 + param |= HI_OPTION_TIMER_WAR;
1045 +
1046 + if (BMIWriteMemory(ar->arHifDevice,
1047 + HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1048 + (A_UCHAR *)&param,
1049 + 4) != A_OK)
1050 + {
1051 + AR_DEBUG_PRINTF("BMIWriteMemory for enabletimerwar failed \n");
1052 + return;
1053 + }
1054 + AR_DEBUG_PRINTF("Timer WAR enabled\n");
1055 + }
1056 +
1057 +
1058 + /* since BMIInit is called in the driver layer, we have to set the block
1059 + * size here for the target */
1060 +
1061 + if (A_FAILED(ar6000_SetHTCBlockSize(ar))) {
1062 + return;
1063 + }
1064 +
1065 + spin_lock_init(&ar->arLock);
1066 +
1067 + /* Don't install the init function if BMI is requested */
1068 + if(!bmienable)
1069 + {
1070 + dev->init = ar6000_init;
1071 + } else {
1072 + AR_DEBUG_PRINTF(" BMI enabled \n");
1073 + }
1074 +
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;
1079 +
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 */
1086 +
1087 + /*
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
1090 + */
1091 + dev->hard_header_len = ETH_HLEN + sizeof(ATH_LLC_SNAP_HDR) +
1092 + sizeof(WMI_DATA_HDR) + HTC_HEADER_LEN;
1093 +
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);
1098 + return;
1099 + }
1100 +
1101 + HTCSetInstance(ar->arHtcTarget, ar);
1102 +
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;
1107 +
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,
1110 + (A_UINT32)ar);
1111 +}
1112 +
1113 +static void ar6000_target_failure(void *Instance, A_STATUS Status)
1114 +{
1115 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Instance;
1116 + WMI_TARGET_ERROR_REPORT_EVENT errEvent;
1117 + static A_BOOL sip = FALSE;
1118 +
1119 + if (Status != A_OK) {
1120 + if (timer_pending(&ar->arHBChallengeResp.timer)) {
1121 + A_UNTIMEOUT(&ar->arHBChallengeResp.timer);
1122 + }
1123 +
1124 + /* try dumping target assertion information (if any) */
1125 + ar6000_dump_target_assert_info(ar->arHifDevice,ar->arTargetType);
1126 +
1127 + /*
1128 + * Fetch the logs from the target via the diagnostic
1129 + * window.
1130 + */
1131 + ar6000_dbglog_get_debug_logs(ar);
1132 +
1133 + /* Report the error only once */
1134 + if (!sip) {
1135 + sip = TRUE;
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));
1141 + }
1142 + }
1143 +}
1144 +
1145 +static void
1146 +ar6000_unavail_ev(void *Instance)
1147 +{
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);
1152 +}
1153 +
1154 +/*
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.
1167 + */
1168 +static void
1169 +ar6000_destroy(struct net_device *dev, unsigned int unregister)
1170 +{
1171 + AR_SOFTC_T *ar;
1172 +
1173 + AR_DEBUG_PRINTF("+ar6000_destroy \n");
1174 +
1175 + if((dev == NULL) || ((ar = netdev_priv(dev)) == NULL))
1176 + {
1177 + AR_DEBUG_PRINTF("%s(): Failed to get device structure.\n", __func__);
1178 + return;
1179 + }
1180 +
1181 + /* Stop the transmit queues */
1182 + netif_stop_queue(dev);
1183 +
1184 + /* Disable the target and the interrupts associated with it */
1185 + if (ar->arWmiReady == TRUE)
1186 + {
1187 + if (!bypasswmi)
1188 + {
1189 + if (ar->arConnected == TRUE || ar->arConnectPending == TRUE)
1190 + {
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);
1196 + }
1197 +
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;
1204 + ar->arWmi = NULL;
1205 + ar->arWlanState = WLAN_ENABLED;
1206 +#ifdef USER_KEYS
1207 + ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
1208 + ar->user_key_ctrl = 0;
1209 +#endif
1210 + }
1211 +
1212 + AR_DEBUG_PRINTF("%s(): WMI stopped\n", __func__);
1213 + }
1214 + else
1215 + {
1216 + AR_DEBUG_PRINTF("%s(): WMI not ready 0x%08x 0x%08x\n",
1217 + __func__, (unsigned int) ar, (unsigned int) ar->arWmi);
1218 +
1219 + /* Shut down WMI if we have started it */
1220 + if(ar->arWmiEnabled == TRUE)
1221 + {
1222 + AR_DEBUG_PRINTF("%s(): Shut down WMI\n", __func__);
1223 + wmi_shutdown(ar->arWmi);
1224 + ar->arWmiEnabled = FALSE;
1225 + ar->arWmi = NULL;
1226 + }
1227 + }
1228 +
1229 + /* stop HTC */
1230 + HTCStop(ar->arHtcTarget);
1231 +
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);
1235 +
1236 + if (resetok) {
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);
1242 + } else {
1243 + AR_DEBUG_PRINTF(" Host does not want target reset. \n");
1244 + }
1245 +
1246 + /* Done with cookies */
1247 + ar6000_cookie_cleanup(ar);
1248 +
1249 + /* Cleanup BMI */
1250 + BMIInit();
1251 +
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));
1256 +
1257 +
1258 + /* Free up the device data structure */
1259 + if (unregister)
1260 + unregister_netdev(dev);
1261 +#ifndef free_netdev
1262 + kfree(dev);
1263 +#else
1264 + free_netdev(dev);
1265 +#endif
1266 +
1267 + AR_DEBUG_PRINTF("-ar6000_destroy \n");
1268 +}
1269 +
1270 +static void ar6000_detect_error(unsigned long ptr)
1271 +{
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;
1275 +
1276 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1277 +
1278 + if (ar->arHBChallengeResp.outstanding) {
1279 + ar->arHBChallengeResp.missCnt++;
1280 + } else {
1281 + ar->arHBChallengeResp.missCnt = 0;
1282 + }
1283 +
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));
1293 + return;
1294 + }
1295 +
1296 + /* Generate the sequence number for the next challenge */
1297 + ar->arHBChallengeResp.seqNum++;
1298 + ar->arHBChallengeResp.outstanding = TRUE;
1299 +
1300 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1301 +
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");
1305 + }
1306 +
1307 +
1308 + /* Reschedule the timer for the next challenge */
1309 + A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
1310 +}
1311 +
1312 +void ar6000_init_profile_info(AR_SOFTC_T *ar)
1313 +{
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;
1327 +}
1328 +
1329 +static void
1330 +ar6000_init_control_info(AR_SOFTC_T *ar)
1331 +{
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;
1339 + ar->arRssi = 0;
1340 + ar->arTxPwr = 0;
1341 + ar->arTxPwrSet = FALSE;
1342 + ar->arSkipScan = 0;
1343 + ar->arBeaconInterval = 0;
1344 + ar->arBitRate = 0;
1345 + ar->arMaxRetries = 0;
1346 + ar->arWmmEnabled = TRUE;
1347 +}
1348 +
1349 +static int
1350 +ar6000_open(struct net_device *dev)
1351 +{
1352 + /* Wake up the queues */
1353 + netif_wake_queue(dev);
1354 +
1355 + return 0;
1356 +}
1357 +
1358 +static int
1359 +ar6000_close(struct net_device *dev)
1360 +{
1361 + netif_stop_queue(dev);
1362 +
1363 + return 0;
1364 +}
1365 +
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,
1370 + char *pDesc)
1371 +{
1372 + A_STATUS status;
1373 + HTC_SERVICE_CONNECT_RESP response;
1374 +
1375 + do {
1376 +
1377 + A_MEMZERO(&response,sizeof(response));
1378 +
1379 + status = HTCConnectService(ar->arHtcTarget,
1380 + pConnect,
1381 + &response);
1382 +
1383 + if (A_FAILED(status)) {
1384 + AR_DEBUG_PRINTF(" Failed to connect to %s service status:%d \n", pDesc, status);
1385 + break;
1386 + }
1387 +
1388 + if (WmiStreamID == WMI_NOT_MAPPED) {
1389 + /* done */
1390 + break;
1391 + }
1392 +
1393 + /* set endpoint mapping for the WMI stream in the driver layer */
1394 + arSetWMIStream2EndpointIDMap(ar,WmiStreamID,response.Endpoint);
1395 +
1396 + } while (FALSE);
1397 +
1398 + return status;
1399 +}
1400 +
1401 +static void ar6000_TxDataCleanup(AR_SOFTC_T *ar)
1402 +{
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);
1418 +}
1419 +
1420 +/* This function does one time initialization for the lifetime of the device */
1421 +int ar6000_init(struct net_device *dev)
1422 +{
1423 + AR_SOFTC_T *ar;
1424 + A_STATUS status;
1425 + A_INT32 timeleft;
1426 +
1427 + if((ar = netdev_priv(dev)) == NULL)
1428 + {
1429 + return(-EIO);
1430 + }
1431 +
1432 + /* Do we need to finish the BMI phase */
1433 + if(BMIDone(ar->arHifDevice) != A_OK)
1434 + {
1435 + return -EIO;
1436 + }
1437 +
1438 + if (!bypasswmi)
1439 + {
1440 +#if 0 /* TBDXXX */
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);
1445 + }
1446 +#endif
1447 +
1448 + /* Indicate that WMI is enabled (although not ready yet) */
1449 + ar->arWmiEnabled = TRUE;
1450 + if ((ar->arWmi = wmi_init((void *) ar)) == NULL)
1451 + {
1452 + AR_DEBUG_PRINTF("%s() Failed to initialize WMI.\n", __func__);
1453 + return(-EIO);
1454 + }
1455 +
1456 + AR_DEBUG_PRINTF("%s() Got WMI @ 0x%08x.\n", __func__,
1457 + (unsigned int) ar->arWmi);
1458 + }
1459 +
1460 + do {
1461 + HTC_SERVICE_CONNECT_REQ connect;
1462 +
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,
1465 + */
1466 + status = HTCWaitTarget(ar->arHtcTarget);
1467 +
1468 + if (A_FAILED(status)) {
1469 + break;
1470 + }
1471 +
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;
1490 +
1491 + /* connect to control service */
1492 + connect.ServiceID = WMI_CONTROL_SVC;
1493 + status = ar6000_connectservice(ar,
1494 + &connect,
1495 + WMI_CONTROL_PRI,
1496 + "WMI CONTROL");
1497 + if (A_FAILED(status)) {
1498 + break;
1499 + }
1500 +
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
1506 + * of 0-3 */
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;
1510 + }
1511 + /* connect to best-effort service */
1512 + connect.ServiceID = WMI_DATA_BE_SVC;
1513 +
1514 + status = ar6000_connectservice(ar,
1515 + &connect,
1516 + WMI_BEST_EFFORT_PRI,
1517 + "WMI DATA BE");
1518 + if (A_FAILED(status)) {
1519 + break;
1520 + }
1521 +
1522 + /* connect to back-ground
1523 + * map this to WMI LOW_PRI */
1524 + connect.ServiceID = WMI_DATA_BK_SVC;
1525 + status = ar6000_connectservice(ar,
1526 + &connect,
1527 + WMI_LOW_PRI,
1528 + "WMI DATA BK");
1529 + if (A_FAILED(status)) {
1530 + break;
1531 + }
1532 +
1533 + /* connect to Video service, map this to
1534 + * to HI PRI */
1535 + connect.ServiceID = WMI_DATA_VI_SVC;
1536 + status = ar6000_connectservice(ar,
1537 + &connect,
1538 + WMI_HIGH_PRI,
1539 + "WMI DATA VI");
1540 + if (A_FAILED(status)) {
1541 + break;
1542 + }
1543 +
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,
1551 + &connect,
1552 + WMI_HIGHEST_PRI,
1553 + "WMI DATA VO");
1554 + if (A_FAILED(status)) {
1555 + break;
1556 + }
1557 +
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);
1563 + } while (FALSE);
1564 +
1565 + if (A_FAILED(status)) {
1566 + return (-EIO);
1567 + }
1568 +
1569 + /*
1570 + * give our connected endpoints some buffers
1571 + */
1572 + ar6000_rx_refill(ar, arWMIStream2EndpointID(ar,WMI_CONTROL_PRI));
1573 +
1574 + ar6000_rx_refill(ar, arWMIStream2EndpointID(ar,WMI_BEST_EFFORT_PRI));
1575 +
1576 + /*
1577 + * We will post the receive buffers only for SPE testing and so we are
1578 + * making it conditional on the 'bypasswmi' flag.
1579 + */
1580 + if (bypasswmi) {
1581 + ar6000_rx_refill(ar,arWMIStream2EndpointID(ar,WMI_LOW_PRI));
1582 + ar6000_rx_refill(ar,arWMIStream2EndpointID(ar,WMI_HIGH_PRI));
1583 + }
1584 +
1585 + /* setup credit distribution */
1586 + ar6000_setup_credit_dist(ar->arHtcTarget, &ar->arCreditStateInfo);
1587 +
1588 + /* Since cookies are used for HTC transports, they should be */
1589 + /* initialized prior to enabling HTC. */
1590 + ar6000_cookie_init(ar);
1591 +
1592 + /* start HTC */
1593 + status = HTCStart(ar->arHtcTarget);
1594 +
1595 + if (status != A_OK) {
1596 + if (ar->arWmiEnabled == TRUE) {
1597 + wmi_shutdown(ar->arWmi);
1598 + ar->arWmiEnabled = FALSE;
1599 + ar->arWmi = NULL;
1600 + }
1601 + ar6000_cookie_cleanup(ar);
1602 + return -EIO;
1603 + }
1604 +
1605 + if (!bypasswmi) {
1606 + /* Wait for Wmi event to be ready */
1607 + timeleft = wait_event_interruptible_timeout(arEvent,
1608 + (ar->arWmiReady == TRUE), wmitimeout * HZ);
1609 +
1610 + if(!timeleft || signal_pending(current))
1611 + {
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");
1615 +#else
1616 + return -EIO;
1617 +#endif
1618 + }
1619 +
1620 + AR_DEBUG_PRINTF("%s() WMI is ready\n", __func__);
1621 +
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");
1625 + }
1626 + }
1627 +
1628 + ar->arNumDataEndPts = 1;
1629 +
1630 + return(0);
1631 +}
1632 +
1633 +
1634 +void
1635 +ar6000_bitrate_rx(void *devt, A_INT32 rateKbps)
1636 +{
1637 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
1638 +
1639 + ar->arBitRate = rateKbps;
1640 + wake_up(&arEvent);
1641 +}
1642 +
1643 +void
1644 +ar6000_ratemask_rx(void *devt, A_UINT16 ratemask)
1645 +{
1646 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
1647 +
1648 + ar->arRateMask = ratemask;
1649 + wake_up(&arEvent);
1650 +}
1651 +
1652 +void
1653 +ar6000_txPwr_rx(void *devt, A_UINT8 txPwr)
1654 +{
1655 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
1656 +
1657 + ar->arTxPwr = txPwr;
1658 + wake_up(&arEvent);
1659 +}
1660 +
1661 +
1662 +void
1663 +ar6000_channelList_rx(void *devt, A_INT8 numChan, A_UINT16 *chanList)
1664 +{
1665 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
1666 +
1667 + A_MEMCPY(ar->arChannelList, chanList, numChan * sizeof (A_UINT16));
1668 + ar->arNumChannels = numChan;
1669 +
1670 + wake_up(&arEvent);
1671 +}
1672 +
1673 +A_UINT8
1674 +ar6000_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, A_UINT32 * mapNo)
1675 +{
1676 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
1677 + A_UINT8 *datap;
1678 + ATH_MAC_HDR *macHdr;
1679 + A_UINT32 i, eptMap;
1680 +
1681 + (*mapNo) = 0;
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;
1686 + }
1687 +
1688 + eptMap = -1;
1689 + for (i = 0; i < ar->arNodeNum; i ++) {
1690 + if (IEEE80211_ADDR_EQ(macHdr->dstMac, ar->arNodeMap[i].macAddress)) {
1691 + (*mapNo) = i + 1;
1692 + ar->arNodeMap[i].txPending ++;
1693 + return ar->arNodeMap[i].epId;
1694 + }
1695 +
1696 + if ((eptMap == -1) && !ar->arNodeMap[i].txPending) {
1697 + eptMap = i;
1698 + }
1699 + }
1700 +
1701 + if (eptMap == -1) {
1702 + eptMap = ar->arNodeNum;
1703 + ar->arNodeNum ++;
1704 + A_ASSERT(ar->arNodeNum <= MAX_NODE_NUM);
1705 + }
1706 +
1707 + A_MEMCPY(ar->arNodeMap[eptMap].macAddress, macHdr->dstMac, IEEE80211_ADDR_LEN);
1708 +
1709 + for (i = ENDPOINT_2; i <= ENDPOINT_5; i ++) {
1710 + if (!ar->arTxPending[i]) {
1711 + ar->arNodeMap[eptMap].epId = i;
1712 + break;
1713 + }
1714 + // No free endpoint is available, start redistribution on the inuse endpoints.
1715 + if (i == ENDPOINT_5) {
1716 + ar->arNodeMap[eptMap].epId = ar->arNexEpId;
1717 + ar->arNexEpId ++;
1718 + if (ar->arNexEpId > ENDPOINT_5) {
1719 + ar->arNexEpId = ENDPOINT_2;
1720 + }
1721 + }
1722 + }
1723 +
1724 + (*mapNo) = eptMap + 1;
1725 + ar->arNodeMap[eptMap].txPending ++;
1726 +
1727 + return ar->arNodeMap[eptMap].epId;
1728 +}
1729 +
1730 +#ifdef DEBUG
1731 +static void ar6000_dump_skb(struct sk_buff *skb)
1732 +{
1733 + u_char *ch;
1734 + for (ch = A_NETBUF_DATA(skb);
1735 + (A_UINT32)ch < ((A_UINT32)A_NETBUF_DATA(skb) +
1736 + A_NETBUF_LEN(skb)); ch++)
1737 + {
1738 + AR_DEBUG_PRINTF("%2.2x ", *ch);
1739 + }
1740 + AR_DEBUG_PRINTF("\n");
1741 +}
1742 +#endif
1743 +
1744 +static int
1745 +ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
1746 +{
1747 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
1748 + WMI_PRI_STREAM_ID streamID = WMI_NOT_MAPPED;
1749 + A_UINT32 mapNo = 0;
1750 + int len;
1751 + struct ar_cookie *cookie;
1752 + A_BOOL checkAdHocPsMapping = FALSE;
1753 +
1754 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)
1755 + skb->list = NULL;
1756 +#endif
1757 +
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);
1765 + return 0;
1766 + }
1767 +#endif
1768 + do {
1769 +
1770 + if (ar->arWmiReady == FALSE && bypasswmi == 0) {
1771 + break;
1772 + }
1773 +
1774 +#ifdef BLOCK_TX_PATH_FLAG
1775 + if (blocktx) {
1776 + break;
1777 + }
1778 +#endif /* BLOCK_TX_PATH_FLAG */
1779 +
1780 + if (ar->arWmiEnabled) {
1781 + if (A_NETBUF_HEADROOM(skb) < dev->hard_header_len) {
1782 + struct sk_buff *newbuf;
1783 + /*
1784 + * We really should have gotten enough headroom but sometimes
1785 + * we still get packets with not enough headroom. Copy the packet.
1786 + */
1787 + len = A_NETBUF_LEN(skb);
1788 + newbuf = A_NETBUF_ALLOC(len);
1789 + if (newbuf == NULL) {
1790 + break;
1791 + }
1792 + A_NETBUF_PUT(newbuf, len);
1793 + A_MEMCPY(A_NETBUF_DATA(newbuf), A_NETBUF_DATA(skb), len);
1794 + A_NETBUF_FREE(skb);
1795 + skb = newbuf;
1796 + /* fall through and assemble header */
1797 + }
1798 +
1799 + if (wmi_dix_2_dot3(ar->arWmi, skb) != A_OK) {
1800 + AR_DEBUG_PRINTF("ar6000_data_tx - wmi_dix_2_dot3 failed\n");
1801 + break;
1802 + }
1803 +
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");
1806 + break;
1807 + }
1808 +
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;
1813 +
1814 + } else {
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));
1819 + } else {
1820 + streamID = WMI_BEST_EFFORT_PRI;
1821 + }
1822 + }
1823 +
1824 + } else {
1825 + struct iphdr *ipHdr;
1826 + /*
1827 + * the endpoint is directly based on the TOS field in the IP
1828 + * header **** only for testing ******
1829 + */
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);
1834 + }
1835 +
1836 + } while (FALSE);
1837 +
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);
1844 + return 0;
1845 + }
1846 +
1847 + cookie = NULL;
1848 +
1849 + /* take the lock to protect driver data */
1850 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1851 +
1852 + do {
1853 +
1854 + if (checkAdHocPsMapping) {
1855 + streamID = ar6000_ibss_map_epid(skb, dev, &mapNo);
1856 + }
1857 +
1858 + A_ASSERT(streamID != WMI_NOT_MAPPED);
1859 +
1860 + /* validate that the endpoint is connected */
1861 + if (arWMIStream2EndpointID(ar,streamID) == 0) {
1862 + AR_DEBUG_PRINTF("Stream %d is NOT mapped!\n",streamID);
1863 + break;
1864 + }
1865 + /* allocate resource for this packet */
1866 + cookie = ar6000_alloc_cookie(ar);
1867 +
1868 + if (cookie != NULL) {
1869 + /* update counts while the lock is held */
1870 + ar->arTxPending[streamID]++;
1871 + ar->arTotalTxDataPending++;
1872 + }
1873 +
1874 + } while (FALSE);
1875 +
1876 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1877 +
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,
1882 + cookie,
1883 + A_NETBUF_DATA(skb),
1884 + A_NETBUF_LEN(skb),
1885 + arWMIStream2EndpointID(ar,streamID),
1886 + AR6K_DATA_PKT_TAG);
1887 +
1888 +#ifdef DEBUG
1889 + if (debugdriver >= 3) {
1890 + ar6000_dump_skb(skb);
1891 + }
1892 +#endif
1893 + /* HTC interface is asynchronous, if this fails, cleanup will happen in
1894 + * the ar6000_tx_complete callback */
1895 + HTCSendPkt(ar->arHtcTarget, &cookie->HtcPkt);
1896 + } else {
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);
1901 + }
1902 +
1903 + return 0;
1904 +}
1905 +
1906 +#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
1907 +static void
1908 +tvsub(register struct timeval *out, register struct timeval *in)
1909 +{
1910 + if((out->tv_usec -= in->tv_usec) < 0) {
1911 + out->tv_sec--;
1912 + out->tv_usec += 1000000;
1913 + }
1914 + out->tv_sec -= in->tv_sec;
1915 +}
1916 +
1917 +void
1918 +applyAPTCHeuristics(AR_SOFTC_T *ar)
1919 +{
1920 + A_UINT32 duration;
1921 + A_UINT32 numbytes;
1922 + A_UINT32 throughput;
1923 + struct timeval ts;
1924 + A_STATUS status;
1925 +
1926 + AR6000_SPIN_LOCK(&ar->arLock, 0);
1927 +
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;
1933 +
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);
1938 +
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;
1949 + }
1950 + }
1951 + }
1952 +
1953 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1954 +}
1955 +#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
1956 +
1957 +static void ar6000_tx_queue_full(void *Context, HTC_ENDPOINT_ID Endpoint)
1958 +{
1959 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
1960 +
1961 +
1962 + if (Endpoint == arWMIStream2EndpointID(ar,WMI_CONTROL_PRI)) {
1963 + if (!bypasswmi) {
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 */
1967 +
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");
1973 + }
1974 + } else {
1975 +
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);
1982 + }
1983 +
1984 +
1985 +}
1986 +
1987 +
1988 +static void
1989 +ar6000_tx_complete(void *Context, HTC_PACKET *pPacket)
1990 +{
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;
1995 + A_STATUS status;
1996 + struct ar_cookie * ar_cookie;
1997 + WMI_PRI_STREAM_ID streamID;
1998 + A_BOOL wakeEvent = FALSE;
1999 +
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];
2005 +
2006 + A_ASSERT(skb);
2007 + A_ASSERT(pPacket->pBuffer == A_NETBUF_DATA(skb));
2008 +
2009 + if (A_SUCCESS(status)) {
2010 + A_ASSERT(pPacket->ActualLength == A_NETBUF_LEN(skb));
2011 + }
2012 +
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,
2016 + streamID);
2017 +
2018 + /* lock the driver as we update internal state */
2019 + AR6000_SPIN_LOCK(&ar->arLock, 0);
2020 +
2021 + ar->arTxPending[streamID]--;
2022 +
2023 + if ((streamID != WMI_CONTROL_PRI) || bypasswmi) {
2024 + ar->arTotalTxDataPending--;
2025 + }
2026 +
2027 + if (streamID == WMI_CONTROL_PRI)
2028 + {
2029 + if (ar->arWMIControlEpFull) {
2030 + /* since this packet completed, the WMI EP is no longer full */
2031 + ar->arWMIControlEpFull = FALSE;
2032 + }
2033 +
2034 + if (ar->arTxPending[streamID] == 0) {
2035 + wakeEvent = TRUE;
2036 + }
2037 + }
2038 +
2039 + if (A_FAILED(status)) {
2040 + AR_DEBUG_PRINTF("%s() -TX ERROR, status: 0x%x\n", __func__,
2041 + status);
2042 + AR6000_STAT_INC(ar, tx_errors);
2043 + } else {
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 */
2051 + }
2052 +
2053 + // TODO this needs to be looked at
2054 + if ((ar->arNetworkType == ADHOC_NETWORK) && ar->arIbssPsEnable
2055 + && (streamID != WMI_CONTROL_PRI) && mapNo)
2056 + {
2057 + mapNo --;
2058 + ar->arNodeMap[mapNo].txPending --;
2059 +
2060 + if (!ar->arNodeMap[mapNo].txPending && (mapNo == (ar->arNodeNum - 1))) {
2061 + A_UINT32 i;
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));
2065 + ar->arNodeNum --;
2066 + } else {
2067 + break;
2068 + }
2069 + }
2070 + }
2071 + }
2072 +
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))
2077 + {
2078 + ar6000_free_cookie(ar, cookie);
2079 + }
2080 +
2081 + if (ar->arNetQueueStopped) {
2082 + ar->arNetQueueStopped = FALSE;
2083 + }
2084 +
2085 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2086 +
2087 + /* lock is released, we can freely call other kernel APIs */
2088 +
2089 + /* this indirectly frees the HTC_PACKET */
2090 + A_NETBUF_FREE(skb);
2091 +
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);
2097 + }
2098 + }
2099 +
2100 + if (wakeEvent) {
2101 + wake_up(&arEvent);
2102 + }
2103 +
2104 +}
2105 +
2106 +/*
2107 + * Receive event handler. This is called by HTC when a packet is received
2108 + */
2109 +int pktcount;
2110 +static void
2111 +ar6000_rx(void *Context, HTC_PACKET *pPacket)
2112 +{
2113 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
2114 + struct sk_buff *skb = (struct sk_buff *)pPacket->pPktContext;
2115 + int minHdrLen;
2116 + A_STATUS status = pPacket->Status;
2117 + WMI_PRI_STREAM_ID streamID = arEndpoint2WMIStreamID(ar,pPacket->Endpoint);
2118 + HTC_ENDPOINT_ID ept = pPacket->Endpoint;
2119 +
2120 + A_ASSERT((status != A_OK) || (pPacket->pBuffer == (A_NETBUF_DATA(skb) + HTC_HEADER_LEN)));
2121 +
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");
2127 + } else {
2128 + AR_DEBUG2_PRINTF("OK\n");
2129 + }
2130 +
2131 + /* take lock to protect buffer counts
2132 + * and adaptive power throughput state */
2133 + AR6000_SPIN_LOCK(&ar->arLock, 0);
2134 +
2135 + ar->arRxBuffers[streamID]--;
2136 +
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 */
2144 +
2145 + A_NETBUF_PUT(skb, pPacket->ActualLength + HTC_HEADER_LEN);
2146 + A_NETBUF_PULL(skb, HTC_HEADER_LEN);
2147 +
2148 +#ifdef DEBUG
2149 + if (debugdriver >= 2) {
2150 + ar6000_dump_skb(skb);
2151 + }
2152 +#endif /* DEBUG */
2153 + }
2154 +
2155 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2156 +
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) {
2162 + /*
2163 + * this is a wmi control msg
2164 + */
2165 + wmi_control_rx(ar->arWmi, skb);
2166 + } else {
2167 + WMI_DATA_HDR *dhdr = (WMI_DATA_HDR *)A_NETBUF_DATA(skb);
2168 + if (WMI_DATA_HDR_IS_MSG_TYPE(dhdr, CNTL_MSGTYPE)) {
2169 + /*
2170 + * this is a wmi control msg
2171 + */
2172 + /* strip off WMI hdr */
2173 + wmi_data_hdr_remove(ar->arWmi, skb);
2174 + wmi_control_rx(ar->arWmi, skb);
2175 + } else {
2176 + /*
2177 + * this is a wmi data packet
2178 + */
2179 + minHdrLen = sizeof (WMI_DATA_HDR) + sizeof(ATH_MAC_HDR) +
2180 + sizeof(ATH_LLC_SNAP_HDR);
2181 +
2182 + if ((pPacket->ActualLength < minHdrLen) ||
2183 + (pPacket->ActualLength > AR6000_BUFFER_SIZE))
2184 + {
2185 + /*
2186 + * packet is too short or too long
2187 + */
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);
2192 + } else {
2193 + if (ar->arWmmEnabled) {
2194 + wmi_implicit_create_pstream(ar->arWmi, skb,
2195 + DNLINK_TRAFFIC, UNDEFINED_PRI);
2196 + }
2197 +#if 0
2198 + /* Access RSSI values here */
2199 + AR_DEBUG_PRINTF("RSSI %d\n",
2200 + ((WMI_DATA_HDR *) A_NETBUF_DATA(skb))->rssi);
2201 +#endif
2202 + wmi_data_hdr_remove(ar->arWmi, skb);
2203 + wmi_dot3_2_dix(ar->arWmi, skb);
2204 +
2205 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
2206 + /*
2207 + * extra push and memcpy, for eth_type_trans() of 2.4 kernel
2208 + * will pull out hard_header_len bytes of the skb.
2209 + */
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));
2213 +#endif
2214 + if ((ar->arNetDev->flags & IFF_UP) == IFF_UP)
2215 + {
2216 + skb->dev = ar->arNetDev;
2217 + skb->protocol = eth_type_trans(skb, ar->arNetDev);
2218 + netif_rx(skb);
2219 + }
2220 + else
2221 + {
2222 + A_NETBUF_FREE(skb);
2223 + }
2224 + }
2225 + }
2226 + }
2227 + } else {
2228 + if ((ar->arNetDev->flags & IFF_UP) == IFF_UP)
2229 + {
2230 + skb->dev = ar->arNetDev;
2231 + skb->protocol = eth_type_trans(skb, ar->arNetDev);
2232 + netif_rx(skb);
2233 + }
2234 + else
2235 + {
2236 + A_NETBUF_FREE(skb);
2237 + }
2238 + }
2239 +
2240 + if (status != A_ECANCELED) {
2241 + /*
2242 + * HTC provides A_ECANCELED status when it doesn't want to be refilled
2243 + * (probably due to a shutdown)
2244 + */
2245 + ar6000_rx_refill(Context, ept);
2246 + }
2247 +
2248 +
2249 +}
2250 +
2251 +static void
2252 +ar6000_rx_refill(void *Context, HTC_ENDPOINT_ID Endpoint)
2253 +{
2254 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
2255 + void *osBuf;
2256 + int RxBuffers;
2257 + int buffersToRefill;
2258 + HTC_PACKET *pPacket;
2259 + WMI_PRI_STREAM_ID streamId = arEndpoint2WMIStreamID(ar,Endpoint);
2260 +
2261 + buffersToRefill = (int)AR6000_MAX_RX_BUFFERS -
2262 + (int)ar->arRxBuffers[streamId];
2263 +
2264 + if (buffersToRefill <= 0) {
2265 + /* fast return, nothing to fill */
2266 + return;
2267 + }
2268 +
2269 + AR_DEBUG2_PRINTF("ar6000_rx_refill: providing htc with %d buffers at eid=%d\n",
2270 + buffersToRefill, Endpoint);
2271 +
2272 + for (RxBuffers = 0; RxBuffers < buffersToRefill; RxBuffers++) {
2273 + osBuf = A_NETBUF_ALLOC(AR6000_BUFFER_SIZE);
2274 + if (NULL == osBuf) {
2275 + break;
2276 + }
2277 + /* the HTC packet wrapper is at the head of the reserved area
2278 + * in the skb */
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);
2284 + }
2285 +
2286 + /* update count */
2287 + AR6000_SPIN_LOCK(&ar->arLock, 0);
2288 + ar->arRxBuffers[streamId] += RxBuffers;
2289 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2290 +}
2291 +
2292 +static struct net_device_stats *
2293 +ar6000_get_stats(struct net_device *dev)
2294 +{
2295 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
2296 + return &ar->arNetStats;
2297 +}
2298 +
2299 +static struct iw_statistics *
2300 +ar6000_get_iwstats(struct net_device * dev)
2301 +{
2302 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
2303 + TARGET_STATS *pStats = &ar->arTargetStats;
2304 + struct iw_statistics * pIwStats = &ar->arIwStats;
2305 +
2306 + if ((ar->arWmiReady == FALSE)
2307 + /*
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.
2313 + */
2314 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
2315 + || (in_atomic())
2316 +#endif
2317 + )
2318 + {
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;
2326 + return pIwStats;
2327 + }
2328 + if (down_interruptible(&ar->arSem)) {
2329 + pIwStats->status = 0;
2330 + return pIwStats;
2331 + }
2332 +
2333 +
2334 + ar->statsUpdatePending = TRUE;
2335 +
2336 + if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
2337 + up(&ar->arSem);
2338 + pIwStats->status = 0;
2339 + return pIwStats;
2340 + }
2341 +
2342 + wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
2343 +
2344 + if (signal_pending(current)) {
2345 + AR_DEBUG_PRINTF("ar6000 : WMI get stats timeout \n");
2346 + up(&ar->arSem);
2347 + pIwStats->status = 0;
2348 + return pIwStats;
2349 + }
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;
2357 + up(&ar->arSem);
2358 + return pIwStats;
2359 +}
2360 +
2361 +void
2362 +ar6000_ready_event(void *devt, A_UINT8 *datap, A_UINT8 phyCap)
2363 +{
2364 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
2365 + struct net_device *dev = ar->arNetDev;
2366 +
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]);
2374 +
2375 + ar->arPhyCapability = phyCap;
2376 +}
2377 +
2378 +A_UINT8
2379 +ar6000_iptos_to_userPriority(A_UINT8 *pkt)
2380 +{
2381 + struct iphdr *ipHdr = (struct iphdr *)pkt;
2382 + A_UINT8 userPriority;
2383 +
2384 + /*
2385 + * IP Tos format :
2386 + * (Refer Pg 57 WMM-test-plan-v1.2)
2387 + * IP-TOS - 8bits
2388 + * : DSCP(6-bits) ECN(2-bits)
2389 + * : DSCP - P2 P1 P0 X X X
2390 + * where (P2 P1 P0) form 802.1D
2391 + */
2392 + userPriority = ipHdr->tos >> 5;
2393 + return (userPriority & 0x7);
2394 +}
2395 +
2396 +void
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)
2402 +{
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)];
2409 + char *pos;
2410 + A_UINT8 key_op_ctrl;
2411 +
2412 + A_MEMCPY(ar->arBssid, bssid, sizeof(ar->arBssid));
2413 + ar->arBssChannel = channel;
2414 +
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");
2426 + } else {
2427 + A_PRINTF("Network: Adhoc (Joiner)\n");
2428 + }
2429 + } else {
2430 + A_PRINTF("Network: Infrastructure\n");
2431 + }
2432 +
2433 + if (beaconIeLen && (sizeof(buf) > (9 + beaconIeLen * 2))) {
2434 + AR_DEBUG_PRINTF("\nBeaconIEs= ");
2435 +
2436 + beacon_ie_pos = 0;
2437 + A_MEMZERO(buf, sizeof(buf));
2438 + sprintf(buf, "%s", beaconIetag);
2439 + pos = buf + 9;
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]);
2443 + pos += 2;
2444 + }
2445 + AR_DEBUG_PRINTF("\n");
2446 +
2447 + A_MEMZERO(&wrqu, sizeof(wrqu));
2448 + wrqu.data.length = strlen(buf);
2449 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
2450 + }
2451 +
2452 + if (assocRespLen && (sizeof(buf) > (12 + (assocRespLen * 2))))
2453 + {
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);
2460 + pos = buf + 12;
2461 + AR_DEBUG_PRINTF("\nAssocRespIEs= ");
2462 + /*
2463 + * The Association Response Frame w.o. the WLAN header is delivered to
2464 + * the host, so skip over to the IEs
2465 + */
2466 + for (i = assoc_resp_ie_pos; i < assoc_resp_ie_pos + assocRespLen - 6; i++)
2467 + {
2468 + AR_DEBUG_PRINTF("%2.2x ", assocInfo[i]);
2469 + sprintf(pos, "%2.2x", assocInfo[i]);
2470 + pos += 2;
2471 + }
2472 + AR_DEBUG_PRINTF("\n");
2473 +
2474 + A_MEMZERO(&wrqu, sizeof(wrqu));
2475 + wrqu.data.length = strlen(buf);
2476 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
2477 + }
2478 +
2479 + if (assocReqLen && (sizeof(buf) > (17 + (assocReqLen * 2)))) {
2480 + /*
2481 + * assoc Request includes capability and listen interval. Skip these.
2482 + */
2483 + assoc_req_ie_pos = beaconIeLen +
2484 + sizeof(A_UINT16) + /* capinfo*/
2485 + sizeof(A_UINT16); /* listen interval */
2486 +
2487 + A_MEMZERO(buf, sizeof(buf));
2488 + sprintf(buf, "%s", tag1);
2489 + pos = buf + 17;
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]);
2494 + pos += 2;;
2495 + }
2496 + AR_DEBUG_PRINTF("\n");
2497 +
2498 + A_MEMZERO(&wrqu, sizeof(wrqu));
2499 + wrqu.data.length = strlen(buf);
2500 + wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
2501 + }
2502 +
2503 +#ifdef USER_KEYS
2504 + if (ar->user_savedkeys_stat == USER_SAVEDKEYS_STAT_RUN &&
2505 + ar->user_saved_keys.keyOk == TRUE)
2506 + {
2507 +
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;
2511 + } else {
2512 + key_op_ctrl |= KEY_OP_INIT_RSC;
2513 + }
2514 + ar6000_reinstall_keys(ar, key_op_ctrl);
2515 + }
2516 +#endif /* USER_KEYS */
2517 +
2518 + /* flush data queues */
2519 + ar6000_TxDataCleanup(ar);
2520 +
2521 + netif_wake_queue(ar->arNetDev);
2522 +
2523 + if ((OPEN_AUTH == ar->arDot11AuthMode) &&
2524 + (NONE_AUTH == ar->arAuthMode) &&
2525 + (WEP_CRYPT == ar->arPairwiseCrypto))
2526 + {
2527 + if (!ar->arConnected) {
2528 + ar6000_install_static_wep_keys(ar);
2529 + }
2530 + }
2531 +
2532 + ar->arConnected = TRUE;
2533 + ar->arConnectPending = FALSE;
2534 +
2535 + reconnect_flag = 0;
2536 +
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;
2545 + }
2546 +
2547 +}
2548 +
2549 +void ar6000_set_numdataendpts(AR_SOFTC_T *ar, A_UINT32 num)
2550 +{
2551 + A_ASSERT(num <= (HTC_MAILBOX_NUM_MAX - 1));
2552 + ar->arNumDataEndPts = num;
2553 +}
2554 +
2555 +void
2556 +ar6000_disconnect_event(AR_SOFTC_T *ar, A_UINT8 reason, A_UINT8 *bssid,
2557 + A_UINT8 assocRespLen, A_UINT8 *assocInfo, A_UINT16 protocolReasonStatus)
2558 +{
2559 + A_UINT8 i;
2560 +
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]);
2565 + }
2566 +
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");
2574 + }
2575 + AR_DEBUG_PRINTF("%2.2x ", assocInfo[i]);
2576 + }
2577 + AR_DEBUG_PRINTF("\n");
2578 + /*
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.
2582 + *
2583 + */
2584 + if( reason == DISCONNECT_CMD)
2585 + {
2586 + ar->arConnectPending = FALSE;
2587 + } else {
2588 + ar->arConnectPending = TRUE;
2589 + if (((reason == ASSOC_FAILED) && (protocolReasonStatus == 0x11)) ||
2590 + ((reason == ASSOC_FAILED) && (protocolReasonStatus == 0x0) && (reconnect_flag == 1))) {
2591 + ar->arConnected = TRUE;
2592 + return;
2593 + }
2594 + }
2595 + ar->arConnected = FALSE;
2596 +
2597 + if( (reason != CSERV_DISCONNECT) || (reconnect_flag != 1) ) {
2598 + reconnect_flag = 0;
2599 + }
2600 +
2601 +#ifdef USER_KEYS
2602 + if (reason != CSERV_DISCONNECT)
2603 + {
2604 + ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
2605 + ar->user_key_ctrl = 0;
2606 + }
2607 +#endif /* USER_KEYS */
2608 +
2609 + netif_stop_queue(ar->arNetDev);
2610 + A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));
2611 + ar->arBssChannel = 0;
2612 + ar->arBeaconInterval = 0;
2613 +
2614 + ar6000_TxDataCleanup(ar);
2615 +}
2616 +
2617 +void
2618 +ar6000_regDomain_event(AR_SOFTC_T *ar, A_UINT32 regCode)
2619 +{
2620 + A_PRINTF("AR6000 Reg Code = 0x%x\n", regCode);
2621 + ar->arRegCode = regCode;
2622 +}
2623 +
2624 +void
2625 +ar6000_neighborReport_event(AR_SOFTC_T *ar, int numAps, WMI_NEIGHBOR_INFO *info)
2626 +{
2627 + static const char *tag = "PRE-AUTH";
2628 + char buf[128];
2629 + union iwreq_data wrqu;
2630 + int i;
2631 +
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");
2639 + }
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 */
2643 + }
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",
2646 + tag,
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);
2653 + }
2654 +}
2655 +
2656 +void
2657 +ar6000_tkip_micerr_event(AR_SOFTC_T *ar, A_UINT8 keyid, A_BOOL ismcast)
2658 +{
2659 + static const char *tag = "MLME-MICHAELMICFAILURE.indication";
2660 + char buf[128];
2661 + union iwreq_data wrqu;
2662 +
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);
2670 +}
2671 +
2672 +void
2673 +ar6000_scanComplete_event(AR_SOFTC_T *ar, A_STATUS status)
2674 +{
2675 + AR_DEBUG_PRINTF("AR6000 scan complete: %d\n", status);
2676 +
2677 + ar->scan_complete = 1;
2678 + wake_up_interruptible(&ar6000_scan_queue);
2679 +}
2680 +
2681 +void
2682 +ar6000_targetStats_event(AR_SOFTC_T *ar, WMI_TARGET_STATS *pTarget)
2683 +{
2684 + TARGET_STATS *pStats = &ar->arTargetStats;
2685 + A_UINT8 ac;
2686 +
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);
2704 +
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);
2720 +
2721 +
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;
2730 +
2731 +
2732 + pStats->power_save_failure_cnt += pTarget->pmStats.power_save_failure_cnt;
2733 + pStats->noise_floor_calibation = pTarget->noise_floor_calibation;
2734 +
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;
2744 +
2745 + pStats->lq_val = pTarget->lqVal;
2746 +
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;
2751 +
2752 + ar->statsUpdatePending = FALSE;
2753 + wake_up(&arEvent);
2754 +}
2755 +
2756 +void
2757 +ar6000_rssiThreshold_event(AR_SOFTC_T *ar, WMI_RSSI_THRESHOLD_VAL newThreshold, A_INT16 rssi)
2758 +{
2759 + USER_RSSI_THOLD userRssiThold;
2760 +
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));
2765 +}
2766 +
2767 +
2768 +void
2769 +ar6000_hbChallengeResp_event(AR_SOFTC_T *ar, A_UINT32 cookie, A_UINT32 source)
2770 +{
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));
2775 + } else {
2776 + /* This would ignore the replys that come in after their due time */
2777 + if (cookie == ar->arHBChallengeResp.seqNum) {
2778 + ar->arHBChallengeResp.outstanding = FALSE;
2779 + }
2780 + }
2781 +}
2782 +
2783 +
2784 +void
2785 +ar6000_reportError_event(AR_SOFTC_T *ar, WMI_TARGET_ERROR_VAL errorVal)
2786 +{
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"
2793 + };
2794 +
2795 + A_PRINTF("AR6000 Error on Target. Error = 0x%x\n", errorVal);
2796 +
2797 + /* One error is reported at a time, and errorval is a bitmask */
2798 + if(errorVal & (errorVal - 1))
2799 + return;
2800 +
2801 + A_PRINTF("AR6000 Error type = ");
2802 + switch(errorVal)
2803 + {
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]);
2810 + break;
2811 + default:
2812 + A_PRINTF("INVALID\n");
2813 + break;
2814 + }
2815 +
2816 +}
2817 +
2818 +
2819 +void
2820 +ar6000_cac_event(AR_SOFTC_T *ar, A_UINT8 ac, A_UINT8 cacIndication,
2821 + A_UINT8 statusCode, A_UINT8 *tspecSuggestion)
2822 +{
2823 + WMM_TSPEC_IE *tspecIe;
2824 +
2825 + /*
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.
2830 + */
2831 + tspecIe = (WMM_TSPEC_IE *)tspecSuggestion;
2832 +
2833 + /*
2834 + * What do we do, if we get TSPEC rejection? One thought
2835 + * that comes to mind is implictly delete the pstream...
2836 + */
2837 + A_PRINTF("AR6000 CAC notification. "
2838 + "AC = %d, cacIndication = 0x%x, statusCode = 0x%x\n",
2839 + ac, cacIndication, statusCode);
2840 +}
2841 +
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]); \
2846 +} while(0)
2847 +
2848 +void
2849 +ar6000_roam_tbl_event(AR_SOFTC_T *ar, WMI_TARGET_ROAM_TBL *pTbl)
2850 +{
2851 + A_UINT8 i;
2852 +
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"
2863 + " BIAS %d\n",
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);
2870 + }
2871 +}
2872 +
2873 +void
2874 +ar6000_wow_list_event(struct ar6_softc *ar, A_UINT8 num_filters, WMI_GET_WOW_LIST_REPLY *wow_reply)
2875 +{
2876 + A_UINT8 i,j;
2877 +
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"));
2883 +
2884 +
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*/
2888 +
2889 + /* If this event contains pattern information, display it*/
2890 + if (wow_reply->this_filter_num) {
2891 + i=0;
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]);
2899 + }
2900 +
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]);
2904 + }
2905 + A_PRINTF("\n");
2906 + }
2907 +}
2908 +
2909 +/*
2910 + * Report the Roaming related data collected on the target
2911 + */
2912 +void
2913 +ar6000_display_roam_time(WMI_TARGET_ROAM_TIME *p)
2914 +{
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,
2919 + p->no_txrx_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);
2928 +}
2929 +
2930 +void
2931 +ar6000_roam_data_event(AR_SOFTC_T *ar, WMI_TARGET_ROAM_DATA *p)
2932 +{
2933 + switch (p->roamDataType) {
2934 + case ROAM_DATA_TIME:
2935 + ar6000_display_roam_time(&p->u.roamTime);
2936 + break;
2937 + default:
2938 + break;
2939 + }
2940 +}
2941 +
2942 +void
2943 +ar6000_bssInfo_event_rx(AR_SOFTC_T *ar, A_UINT8 *datap, int len)
2944 +{
2945 + struct sk_buff *skb;
2946 + WMI_BSS_INFO_HDR *bih = (WMI_BSS_INFO_HDR *)datap;
2947 +
2948 +
2949 + if (!ar->arMgmtFilter) {
2950 + return;
2951 + }
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)))
2956 + {
2957 + return;
2958 + }
2959 +
2960 + if ((skb = A_NETBUF_ALLOC_RAW(len)) != NULL) {
2961 +
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);
2970 + netif_rx(skb);
2971 + }
2972 +}
2973 +
2974 +A_UINT32 wmiSendCmdNum;
2975 +
2976 +A_STATUS
2977 +ar6000_control_tx(void *devt, void *osbuf, WMI_PRI_STREAM_ID streamID)
2978 +{
2979 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
2980 + A_STATUS status = A_OK;
2981 + struct ar_cookie *cookie = NULL;
2982 + int i;
2983 +
2984 + /* take lock to protect ar6000_alloc_cookie() */
2985 + AR6000_SPIN_LOCK(&ar->arLock, 0);
2986 +
2987 + do {
2988 +
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);
2991 +
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 */
2995 + cookie = NULL;
2996 + AR_DEBUG_PRINTF(" WMI Control EP full, dropping packet : 0x%X, len:%d \n",
2997 + (A_UINT32)osbuf, A_NETBUF_LEN(osbuf));
2998 + } else {
2999 + cookie = ar6000_alloc_cookie(ar);
3000 + }
3001 +
3002 + if (cookie == NULL) {
3003 + status = A_NO_MEMORY;
3004 + break;
3005 + }
3006 +
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]);
3011 + A_PRINTF("\n");
3012 + }
3013 +
3014 + wmiSendCmdNum++;
3015 +
3016 + } while (FALSE);
3017 +
3018 + if (cookie != NULL) {
3019 + /* got a structure to send it out on */
3020 + ar->arTxPending[streamID]++;
3021 +
3022 + if (streamID != WMI_CONTROL_PRI) {
3023 + ar->arTotalTxDataPending++;
3024 + }
3025 + }
3026 +
3027 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3028 +
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,
3033 + cookie,
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);
3041 + status = A_OK;
3042 + }
3043 +
3044 + return status;
3045 +}
3046 +
3047 +/* indicate tx activity or inactivity on a WMI stream */
3048 +void ar6000_indicate_tx_activity(void *devt, A_UINT8 TrafficClass, A_BOOL Active)
3049 +{
3050 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
3051 + WMI_PRI_STREAM_ID streamid;
3052 +
3053 + if (ar->arWmiEnabled) {
3054 + streamid = wmi_get_stream_id(ar->arWmi, TrafficClass);
3055 + } else {
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;
3059 + }
3060 +
3061 + /* notify HTC, this may cause credit distribution changes */
3062 +
3063 + HTCIndicateActivityChange(ar->arHtcTarget,
3064 + arWMIStream2EndpointID(ar,streamid),
3065 + Active);
3066 +
3067 +}
3068 +
3069 +module_init(ar6000_init_module);
3070 +module_exit(ar6000_cleanup_module);
3071 +
3072 +/* Init cookie queue */
3073 +static void
3074 +ar6000_cookie_init(AR_SOFTC_T *ar)
3075 +{
3076 + A_UINT32 i;
3077 +
3078 + ar->arCookieList = NULL;
3079 + A_MEMZERO(s_ar_cookie_mem, sizeof(s_ar_cookie_mem));
3080 +
3081 + for (i = 0; i < MAX_COOKIE_NUM; i++) {
3082 + ar6000_free_cookie(ar, &s_ar_cookie_mem[i]);
3083 + }
3084 +}
3085 +
3086 +/* cleanup cookie queue */
3087 +static void
3088 +ar6000_cookie_cleanup(AR_SOFTC_T *ar)
3089 +{
3090 + /* It is gone .... */
3091 + ar->arCookieList = NULL;
3092 +}
3093 +
3094 +/* Init cookie queue */
3095 +static void
3096 +ar6000_free_cookie(AR_SOFTC_T *ar, struct ar_cookie * cookie)
3097 +{
3098 + /* Insert first */
3099 + A_ASSERT(ar != NULL);
3100 + A_ASSERT(cookie != NULL);
3101 + cookie->arc_list_next = ar->arCookieList;
3102 + ar->arCookieList = cookie;
3103 +}
3104 +
3105 +/* cleanup cookie queue */
3106 +static struct ar_cookie *
3107 +ar6000_alloc_cookie(AR_SOFTC_T *ar)
3108 +{
3109 + struct ar_cookie *cookie;
3110 +
3111 + cookie = ar->arCookieList;
3112 + if(cookie != NULL)
3113 + {
3114 + ar->arCookieList = cookie->arc_list_next;
3115 + }
3116 +
3117 + return cookie;
3118 +}
3119 +
3120 +#ifdef SEND_EVENT_TO_APP
3121 +/*
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.
3125 + */
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)
3129 +{
3130 +
3131 +#if (WIRELESS_EXT >= 15)
3132 +
3133 +/* note: IWEVCUSTOM only exists in wireless extensions after version 15 */
3134 +
3135 + char *buf;
3136 + A_UINT16 size;
3137 + union iwreq_data wrqu;
3138 +
3139 + size = len + EVENT_ID_LEN;
3140 +
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);
3144 + return;
3145 + }
3146 +
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);
3151 +
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);
3156 +
3157 + A_FREE(buf);
3158 +#endif
3159 +
3160 +
3161 +}
3162 +#endif
3163 +
3164 +
3165 +void
3166 +ar6000_tx_retry_err_event(void *devt)
3167 +{
3168 + AR_DEBUG2_PRINTF("Tx retries reach maximum!\n");
3169 +}
3170 +
3171 +void
3172 +ar6000_snrThresholdEvent_rx(void *devt, WMI_SNR_THRESHOLD_VAL newThreshold, A_UINT8 snr)
3173 +{
3174 + AR_DEBUG2_PRINTF("snr threshold range %d, snr %d\n", newThreshold, snr);
3175 +}
3176 +
3177 +void
3178 +ar6000_lqThresholdEvent_rx(void *devt, WMI_LQ_THRESHOLD_VAL newThreshold, A_UINT8 lq)
3179 +{
3180 + AR_DEBUG2_PRINTF("lq threshold range %d, lq %d\n", newThreshold, lq);
3181 +}
3182 +
3183 +
3184 +
3185 +A_UINT32
3186 +a_copy_to_user(void *to, const void *from, A_UINT32 n)
3187 +{
3188 + return(copy_to_user(to, from, n));
3189 +}
3190 +
3191 +A_UINT32
3192 +a_copy_from_user(void *to, const void *from, A_UINT32 n)
3193 +{
3194 + return(copy_from_user(to, from, n));
3195 +}
3196 +
3197 +
3198 +A_STATUS
3199 +ar6000_get_driver_cfg(struct net_device *dev,
3200 + A_UINT16 cfgParam,
3201 + void *result)
3202 +{
3203 +
3204 + A_STATUS ret = 0;
3205 +
3206 + switch(cfgParam)
3207 + {
3208 + case AR6000_DRIVER_CFG_GET_WLANNODECACHING:
3209 + *((A_UINT32 *)result) = wlanNodeCaching;
3210 + break;
3211 + case AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS:
3212 + *((A_UINT32 *)result) = logWmiRawMsgs;
3213 + break;
3214 + default:
3215 + ret = EINVAL;
3216 + break;
3217 + }
3218 +
3219 + return ret;
3220 +}
3221 +
3222 +void
3223 +ar6000_keepalive_rx(void *devt, A_UINT8 configured)
3224 +{
3225 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
3226 +
3227 + ar->arKeepaliveConfigured = configured;
3228 + wake_up(&arEvent);
3229 +}
3230 +
3231 +void
3232 +ar6000_pmkid_list_event(void *devt, A_UINT8 numPMKID, WMI_PMKID *pmkidList)
3233 +{
3234 + A_UINT8 i, j;
3235 +
3236 + A_PRINTF("Number of Cached PMKIDs is %d\n", numPMKID);
3237 +
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]);
3242 + }
3243 + pmkidList++;
3244 + }
3245 +}
3246 +
3247 +#ifdef USER_KEYS
3248 +static A_STATUS
3249 +
3250 +ar6000_reinstall_keys(AR_SOFTC_T *ar, A_UINT8 key_op_ctrl)
3251 +{
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;
3256 +
3257 + if (IEEE80211_CIPHER_CCKM_KRK != uik->ik_type) {
3258 + if (NONE_CRYPT == keyType) {
3259 + goto _reinstall_keys_out;
3260 + }
3261 +
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);
3267 + }
3268 +
3269 + } else {
3270 + status = wmi_add_krk_cmd(ar->arWmi, uik->ik_keydata);
3271 + }
3272 +
3273 + if (IEEE80211_CIPHER_CCKM_KRK != bik->ik_type) {
3274 + if (NONE_CRYPT == keyType) {
3275 + goto _reinstall_keys_out;
3276 + }
3277 +
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);
3283 + }
3284 + } else {
3285 + status = wmi_add_krk_cmd(ar->arWmi, bik->ik_keydata);
3286 + }
3287 +
3288 +_reinstall_keys_out:
3289 + ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
3290 + ar->user_key_ctrl = 0;
3291 +
3292 + return status;
3293 +}
3294 +#endif /* USER_KEYS */
3295 +
3296 +
3297 +void
3298 +ar6000_dset_open_req(
3299 + void *context,
3300 + A_UINT32 id,
3301 + A_UINT32 targHandle,
3302 + A_UINT32 targReplyFn,
3303 + A_UINT32 targReplyArg)
3304 +{
3305 +}
3306 +
3307 +void
3308 +ar6000_dset_close(
3309 + void *context,
3310 + A_UINT32 access_cookie)
3311 +{
3312 + return;
3313 +}
3314 +
3315 +void
3316 +ar6000_dset_data_req(
3317 + void *context,
3318 + A_UINT32 accessCookie,
3319 + A_UINT32 offset,
3320 + A_UINT32 length,
3321 + A_UINT32 targBuf,
3322 + A_UINT32 targReplyFn,
3323 + A_UINT32 targReplyArg)
3324 +{
3325 +}
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
3329 --- /dev/null
3330 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.h
3331 @@ -0,0 +1,360 @@
3332 +/*
3333 + *
3334 + * Copyright (c) 2004-2007 Atheros Communications Inc.
3335 + * All rights reserved.
3336 + *
3337 + *
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;
3341 + *
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.
3346 + *
3347 + *
3348 + *
3349 + */
3350 +
3351 +#ifndef _AR6000_H_
3352 +#define _AR6000_H_
3353 +
3354 +#include <linux/version.h>
3355 +
3356 +
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>
3372 +
3373 +#include <a_config.h>
3374 +#include <athdefs.h>
3375 +#include "a_types.h"
3376 +#include "a_osapi.h"
3377 +#include "htc_api.h"
3378 +#include "wmi.h"
3379 +#include "a_drv.h"
3380 +#include "bmi.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"
3386 +#include "gpio.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>
3395 +#endif
3396 +
3397 +#include "targaddrs.h"
3398 +#include "dbglog_api.h"
3399 +#include "ar6000_diag.h"
3400 +#include "common_drv.h"
3401 +
3402 +#ifndef __dev_put
3403 +#define __dev_put(dev) dev_put(dev)
3404 +#endif
3405 +
3406 +#ifdef USER_KEYS
3407 +
3408 +#define USER_SAVEDKEYS_STAT_INIT 0
3409 +#define USER_SAVEDKEYS_STAT_RUN 1
3410 +
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;
3416 + A_BOOL keyOk;
3417 +};
3418 +#endif
3419 +
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
3429 +
3430 +#define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING)
3431 +
3432 +
3433 +#ifdef DEBUG
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;
3437 +#else
3438 +#define AR_DEBUG_PRINTF(args...)
3439 +#define AR_DEBUG2_PRINTF(args...)
3440 +#endif
3441 +
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);
3444 +
3445 +#ifdef __cplusplus
3446 +extern "C" {
3447 +#endif
3448 +
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
3459 +
3460 +enum {
3461 + DRV_HB_CHALLENGE = 0,
3462 + APP_HB_CHALLENGE
3463 +};
3464 +
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;
3474 +
3475 +#define RAW_HTC_READ_BUFFERS_NUM 4
3476 +#define RAW_HTC_WRITE_BUFFERS_NUM 4
3477 +
3478 +typedef struct {
3479 + int currPtr;
3480 + int length;
3481 + unsigned char data[AR6000_BUFFER_SIZE];
3482 + HTC_PACKET HTCPacket;
3483 +} raw_htc_buffer;
3484 +
3485 +#ifdef CONFIG_HOST_TCMD_SUPPORT
3486 +/*
3487 + * add TCMD_MODE besides wmi and bypasswmi
3488 + * in TCMD_MODE, only few TCMD releated wmi commands
3489 + * counld be hanlder
3490 + */
3491 +enum {
3492 + AR6000_WMI_MODE = 0,
3493 + AR6000_BYPASS_MODE,
3494 + AR6000_TCMD_MODE,
3495 + AR6000_WLAN_MODE
3496 +};
3497 +#endif /* CONFIG_HOST_TCMD_SUPPORT */
3498 +
3499 +struct ar_wep_key {
3500 + A_UINT8 arKeyIndex;
3501 + A_UINT8 arKeyLen;
3502 + A_UINT8 arKey[64];
3503 +} ;
3504 +
3505 +struct ar_node_mapping {
3506 + A_UINT8 macAddress[6];
3507 + A_UINT8 epId;
3508 + A_UINT8 txPending;
3509 +};
3510 +
3511 +struct ar_cookie {
3512 + A_UINT32 arc_bp[2]; /* Must be first field */
3513 + HTC_PACKET HtcPkt; /* HTC packet wrapper */
3514 + struct ar_cookie *arc_list_next;
3515 +};
3516 +
3517 +struct ar_hb_chlng_resp {
3518 + A_TIMER timer;
3519 + A_UINT32 frequency;
3520 + A_UINT32 seqNum;
3521 + A_BOOL outstanding;
3522 + A_UINT8 missCnt;
3523 + A_UINT8 missThres;
3524 +};
3525 +
3526 +typedef struct ar6_softc {
3527 + struct net_device *arNetDev; /* net_device pointer */
3528 + void *arWmi;
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];
3540 + int arSsidLen;
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;
3558 + A_INT8 arRssi;
3559 + A_UINT8 arTxPwr;
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;
3575 + A_UINT32 tcmdPm;
3576 + A_UINT32 arTargetMode;
3577 +#endif
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];
3605 +#endif
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];
3613 + A_UINT32 log_cnt;
3614 + A_UINT32 dbglog_init_done;
3615 + A_UINT32 arConnectCtrlFlags;
3616 + A_UINT32 scan_complete;
3617 +#ifdef USER_KEYS
3618 + A_INT32 user_savedkeys_stat;
3619 + A_UINT32 user_key_ctrl;
3620 + struct USER_SAVEDKEYS user_saved_keys;
3621 +#endif
3622 +} AR_SOFTC_T;
3623 +
3624 +
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)]
3630 +
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)]
3637 +
3638 +struct ar_giwscan_param {
3639 + char *current_ev;
3640 + char *end_buf;
3641 + A_BOOL firstPass;
3642 +};
3643 +
3644 +#define AR6000_STAT_INC(ar, stat) (ar->arNetStats.stat++)
3645 +
3646 +#define AR6000_SPIN_LOCK(lock, param) do { \
3647 + if (irqs_disabled()) { \
3648 + AR_DEBUG_PRINTF("IRQs disabled:AR6000_LOCK\n"); \
3649 + } \
3650 + spin_lock_bh(lock); \
3651 +} while (0)
3652 +
3653 +#define AR6000_SPIN_UNLOCK(lock, param) do { \
3654 + if (irqs_disabled()) { \
3655 + AR_DEBUG_PRINTF("IRQs disabled: AR6000_UNLOCK\n"); \
3656 + } \
3657 + spin_unlock_bh(lock); \
3658 +} while (0)
3659 +
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);
3669 +
3670 +#ifdef HTC_RAW_INTERFACE
3671 +
3672 +#ifndef __user
3673 +#define __user
3674 +#endif
3675 +
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);
3684 +
3685 +#endif /* HTC_RAW_INTERFACE */
3686 +
3687 +#ifdef __cplusplus
3688 +}
3689 +#endif
3690 +
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
3695 --- /dev/null
3696 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_raw_if.c
3697 @@ -0,0 +1,439 @@
3698 +/*
3699 + *
3700 + * Copyright (c) 2004-2007 Atheros Communications Inc.
3701 + * All rights reserved.
3702 + *
3703 + *
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;
3707 + *
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.
3712 + *
3713 + *
3714 + *
3715 + */
3716 +
3717 +#include "ar6000_drv.h"
3718 +
3719 +#ifdef HTC_RAW_INTERFACE
3720 +
3721 +static void
3722 +ar6000_htc_raw_read_cb(void *Context, HTC_PACKET *pPacket)
3723 +{
3724 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
3725 + raw_htc_buffer *busy;
3726 + HTC_RAW_STREAM_ID streamID;
3727 +
3728 + busy = (raw_htc_buffer *)pPacket->pPktContext;
3729 + A_ASSERT(busy != NULL);
3730 +
3731 + if (pPacket->Status == A_ECANCELED) {
3732 + /*
3733 + * HTC provides A_ECANCELED status when it doesn't want to be refilled
3734 + * (probably due to a shutdown)
3735 + */
3736 + return;
3737 + }
3738 +
3739 + streamID = arEndpoint2RawStreamID(ar,pPacket->Endpoint);
3740 + A_ASSERT(streamID != HTC_RAW_STREAM_NOT_MAPPED);
3741 +
3742 +#ifdef CF
3743 + if (down_trylock(&ar->raw_htc_read_sem[streamID])) {
3744 +#else
3745 + if (down_interruptible(&ar->raw_htc_read_sem[streamID])) {
3746 +#endif /* CF */
3747 + AR_DEBUG2_PRINTF("Unable to down the semaphore\n");
3748 + }
3749 +
3750 + A_ASSERT((pPacket->Status != A_OK) ||
3751 + (pPacket->pBuffer == (busy->data + HTC_HEADER_LEN)));
3752 +
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]);
3758 +
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]);
3762 +}
3763 +
3764 +static void
3765 +ar6000_htc_raw_write_cb(void *Context, HTC_PACKET *pPacket)
3766 +{
3767 + AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
3768 + raw_htc_buffer *free;
3769 + HTC_RAW_STREAM_ID streamID;
3770 +
3771 + free = (raw_htc_buffer *)pPacket->pPktContext;
3772 + A_ASSERT(free != NULL);
3773 +
3774 + if (pPacket->Status == A_ECANCELED) {
3775 + /*
3776 + * HTC provides A_ECANCELED status when it doesn't want to be refilled
3777 + * (probably due to a shutdown)
3778 + */
3779 + return;
3780 + }
3781 +
3782 + streamID = arEndpoint2RawStreamID(ar,pPacket->Endpoint);
3783 + A_ASSERT(streamID != HTC_RAW_STREAM_NOT_MAPPED);
3784 +
3785 +#ifdef CF
3786 + if (down_trylock(&ar->raw_htc_write_sem[streamID])) {
3787 +#else
3788 + if (down_interruptible(&ar->raw_htc_write_sem[streamID])) {
3789 +#endif
3790 + AR_DEBUG2_PRINTF("Unable to down the semaphore\n");
3791 + }
3792 +
3793 + A_ASSERT(pPacket->pBuffer == (free->data + HTC_HEADER_LEN));
3794 +
3795 + free->length = 0;
3796 + ar->write_buffer_available[streamID] = TRUE;
3797 + up(&ar->raw_htc_write_sem[streamID]);
3798 +
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]);
3802 +}
3803 +
3804 +/* connect to a service */
3805 +static A_STATUS ar6000_connect_raw_service(AR_SOFTC_T *ar,
3806 + HTC_RAW_STREAM_ID StreamID)
3807 +{
3808 + A_STATUS status;
3809 + HTC_SERVICE_CONNECT_RESP response;
3810 + A_UINT8 streamNo;
3811 + HTC_SERVICE_CONNECT_REQ connect;
3812 +
3813 + do {
3814 +
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;
3828 +
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;
3832 +
3833 + A_MEMZERO(&response,sizeof(response));
3834 +
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,
3838 + &connect,
3839 + &response);
3840 +
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");
3844 + status = A_OK;
3845 + }
3846 + break;
3847 + }
3848 +
3849 + /* set endpoint mapping for the RAW HTC streams */
3850 + arSetRawStream2EndpointIDMap(ar,StreamID,response.Endpoint);
3851 +
3852 + AR_DEBUG_PRINTF("HTC RAW : stream ID: %d, endpoint: %d\n",
3853 + StreamID, arRawStream2EndpointID(ar,StreamID));
3854 +
3855 + } while (FALSE);
3856 +
3857 + return status;
3858 +}
3859 +
3860 +int ar6000_htc_raw_open(AR_SOFTC_T *ar)
3861 +{
3862 + A_STATUS status;
3863 + int streamID, endPt, count2;
3864 + raw_htc_buffer *buffer;
3865 + HTC_SERVICE_ID servicepriority;
3866 +
3867 + A_ASSERT(ar->arHtcTarget != NULL);
3868 +
3869 + /* wait for target */
3870 + status = HTCWaitTarget(ar->arHtcTarget);
3871 +
3872 + if (A_FAILED(status)) {
3873 + AR_DEBUG_PRINTF("HTCWaitTarget failed (%d)\n", status);
3874 + return -ENODEV;
3875 + }
3876 +
3877 + for (endPt = 0; endPt < ENDPOINT_MAX; endPt++) {
3878 + ar->arEp2RawMapping[endPt] = HTC_RAW_STREAM_NOT_MAPPED;
3879 + }
3880 +
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]);
3887 +
3888 + /* try to connect to the raw service */
3889 + status = ar6000_connect_raw_service(ar,streamID);
3890 +
3891 + if (A_FAILED(status)) {
3892 + break;
3893 + }
3894 +
3895 + if (arRawStream2EndpointID(ar,streamID) == 0) {
3896 + break;
3897 + }
3898 +
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));
3905 +
3906 + SET_HTC_PACKET_INFO_RX_REFILL(&buffer->HTCPacket,
3907 + buffer,
3908 + buffer->data,
3909 + AR6000_BUFFER_SIZE,
3910 + arRawStream2EndpointID(ar,streamID));
3911 +
3912 + /* Queue buffers to HTC for receive */
3913 + if ((status = HTCAddReceivePkt(ar->arHtcTarget, &buffer->HTCPacket)) != A_OK)
3914 + {
3915 + BMIInit();
3916 + return -EIO;
3917 + }
3918 + }
3919 +
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));
3924 + }
3925 +
3926 + ar->read_buffer_available[streamID] = FALSE;
3927 + ar->write_buffer_available[streamID] = TRUE;
3928 + }
3929 +
3930 + if (A_FAILED(status)) {
3931 + return -EIO;
3932 + }
3933 +
3934 + AR_DEBUG_PRINTF("HTC RAW, number of streams the target supports: %d \n", streamID);
3935 +
3936 + servicepriority = HTC_RAW_STREAMS_SVC; /* only 1 */
3937 +
3938 + /* set callbacks and priority list */
3939 + HTCSetCreditDistribution(ar->arHtcTarget,
3940 + ar,
3941 + NULL, /* use default */
3942 + NULL, /* use default */
3943 + &servicepriority,
3944 + 1);
3945 +
3946 + /* Start the HTC component */
3947 + if ((status = HTCStart(ar->arHtcTarget)) != A_OK) {
3948 + BMIInit();
3949 + return -EIO;
3950 + }
3951 +
3952 + (ar)->arRawIfInit = TRUE;
3953 +
3954 + return 0;
3955 +}
3956 +
3957 +int ar6000_htc_raw_close(AR_SOFTC_T *ar)
3958 +{
3959 + A_PRINTF("ar6000_htc_raw_close called \n");
3960 + HTCStop(ar->arHtcTarget);
3961 +
3962 + /* reset the device */
3963 + ar6000_reset_device(ar->arHifDevice, ar->arTargetType);
3964 + /* Initialize the BMI component */
3965 + BMIInit();
3966 +
3967 + return 0;
3968 +}
3969 +
3970 +raw_htc_buffer *
3971 +get_filled_buffer(AR_SOFTC_T *ar, HTC_RAW_STREAM_ID StreamID)
3972 +{
3973 + int count;
3974 + raw_htc_buffer *busy;
3975 +
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) {
3980 + break;
3981 + }
3982 + }
3983 + if (busy->length) {
3984 + ar->read_buffer_available[StreamID] = TRUE;
3985 + } else {
3986 + ar->read_buffer_available[StreamID] = FALSE;
3987 + }
3988 +
3989 + return busy;
3990 +}
3991 +
3992 +ssize_t ar6000_htc_raw_read(AR_SOFTC_T *ar, HTC_RAW_STREAM_ID StreamID,
3993 + char __user *buffer, size_t length)
3994 +{
3995 + int readPtr;
3996 + raw_htc_buffer *busy;
3997 +
3998 + if (arRawStream2EndpointID(ar,StreamID) == 0) {
3999 + AR_DEBUG_PRINTF("StreamID(%d) not connected! \n", StreamID);
4000 + return -EFAULT;
4001 + }
4002 +
4003 + if (down_interruptible(&ar->raw_htc_read_sem[StreamID])) {
4004 + return -ERESTARTSYS;
4005 + }
4006 +
4007 + busy = get_filled_buffer(ar,StreamID);
4008 + while (!ar->read_buffer_available[StreamID]) {
4009 + up(&ar->raw_htc_read_sem[StreamID]);
4010 +
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]))
4015 + {
4016 + return -EINTR;
4017 + }
4018 + if (down_interruptible(&ar->raw_htc_read_sem[StreamID])) {
4019 + return -ERESTARTSYS;
4020 + }
4021 + busy = get_filled_buffer(ar,StreamID);
4022 + }
4023 +
4024 + /* Read the data */
4025 + readPtr = busy->currPtr;
4026 + if (length > busy->length - HTC_HEADER_LEN) {
4027 + length = busy->length - HTC_HEADER_LEN;
4028 + }
4029 + if (copy_to_user(buffer, &busy->data[readPtr], length)) {
4030 + up(&ar->raw_htc_read_sem[StreamID]);
4031 + return -EFAULT;
4032 + }
4033 +
4034 + busy->currPtr += length;
4035 +
4036 + //AR_DEBUG_PRINTF("raw read ioctl: currPTR : 0x%X 0x%X \n", busy->currPtr,busy->length);
4037 +
4038 + if (busy->currPtr == busy->length)
4039 + {
4040 + busy->currPtr = 0;
4041 + busy->length = 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);
4045 + }
4046 + ar->read_buffer_available[StreamID] = FALSE;
4047 + up(&ar->raw_htc_read_sem[StreamID]);
4048 +
4049 + return length;
4050 +}
4051 +
4052 +static raw_htc_buffer *
4053 +get_free_buffer(AR_SOFTC_T *ar, HTC_ENDPOINT_ID StreamID)
4054 +{
4055 + int count;
4056 + raw_htc_buffer *free;
4057 +
4058 + free = NULL;
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) {
4062 + break;
4063 + }
4064 + }
4065 + if (!free->length) {
4066 + ar->write_buffer_available[StreamID] = TRUE;
4067 + } else {
4068 + ar->write_buffer_available[StreamID] = FALSE;
4069 + }
4070 +
4071 + return free;
4072 +}
4073 +
4074 +ssize_t ar6000_htc_raw_write(AR_SOFTC_T *ar, HTC_RAW_STREAM_ID StreamID,
4075 + char __user *buffer, size_t length)
4076 +{
4077 + int writePtr;
4078 + raw_htc_buffer *free;
4079 +
4080 + if (arRawStream2EndpointID(ar,StreamID) == 0) {
4081 + AR_DEBUG_PRINTF("StreamID(%d) not connected! \n", StreamID);
4082 + return -EFAULT;
4083 + }
4084 +
4085 + if (down_interruptible(&ar->raw_htc_write_sem[StreamID])) {
4086 + return -ERESTARTSYS;
4087 + }
4088 +
4089 + /* Search for a free buffer */
4090 + free = get_free_buffer(ar,StreamID);
4091 +
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]);
4095 +
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]))
4100 + {
4101 + return -EINTR;
4102 + }
4103 + if (down_interruptible(&ar->raw_htc_write_sem[StreamID])) {
4104 + return -ERESTARTSYS;
4105 + }
4106 + free = get_free_buffer(ar,StreamID);
4107 + }
4108 +
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;
4113 + }
4114 +
4115 + if (copy_from_user(&free->data[writePtr], buffer, length)) {
4116 + up(&ar->raw_htc_read_sem[StreamID]);
4117 + return -EFAULT;
4118 + }
4119 +
4120 + free->length = length;
4121 +
4122 + SET_HTC_PACKET_INFO_TX(&free->HTCPacket,
4123 + free,
4124 + &free->data[writePtr],
4125 + length,
4126 + arRawStream2EndpointID(ar,StreamID),
4127 + AR6K_DATA_PKT_TAG);
4128 +
4129 + HTCSendPkt(ar->arHtcTarget,&free->HTCPacket);
4130 +
4131 + ar->write_buffer_available[StreamID] = FALSE;
4132 + up(&ar->raw_htc_write_sem[StreamID]);
4133 +
4134 + return length;
4135 +}
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
4140 --- /dev/null
4141 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ar6xapi_linux.h
4142 @@ -0,0 +1,128 @@
4143 +#ifndef _AR6XAPI_LINUX_H
4144 +#define _AR6XAPI_LINUX_H
4145 +/*
4146 + *
4147 + * Copyright (c) 2004-2007 Atheros Communications Inc.
4148 + * All rights reserved.
4149 + *
4150 + *
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;
4154 + *
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.
4159 + *
4160 + *
4161 + *
4162 + */
4163 +
4164 +#ifdef __cplusplus
4165 +extern "C" {
4166 +#endif
4167 +
4168 +struct ar6_softc;
4169 +
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,
4182 + A_BOOL ismcast);
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,
4195 + A_INT16 rssi);
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);
4200 +void
4201 +ar6000_roam_tbl_event(struct ar6_softc *ar, WMI_TARGET_ROAM_TBL *pTbl);
4202 +
4203 +void
4204 +ar6000_roam_data_event(struct ar6_softc *ar, WMI_TARGET_ROAM_DATA *p);
4205 +
4206 +void
4207 +ar6000_wow_list_event(struct ar6_softc *ar, A_UINT8 num_filters,
4208 + WMI_GET_WOW_LIST_REPLY *wow_reply);
4209 +
4210 +void ar6000_pmkid_list_event(void *devt, A_UINT8 numPMKID,
4211 + WMI_PMKID *pmkidList);
4212 +
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);
4216 +
4217 +void ar6000_dbglog_init_done(struct ar6_softc *ar);
4218 +
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);
4221 +#endif
4222 +
4223 +#ifdef CONFIG_HOST_TCMD_SUPPORT
4224 +void ar6000_tcmd_rx_report_event(void *devt, A_UINT8 * results, int len);
4225 +#endif
4226 +
4227 +void ar6000_tx_retry_err_event(void *devt);
4228 +
4229 +void ar6000_snrThresholdEvent_rx(void *devt,
4230 + WMI_SNR_THRESHOLD_VAL newThreshold,
4231 + A_UINT8 snr);
4232 +
4233 +void ar6000_lqThresholdEvent_rx(void *devt, WMI_LQ_THRESHOLD_VAL range, A_UINT8 lqVal);
4234 +
4235 +
4236 +void ar6000_ratemask_rx(void *devt, A_UINT16 ratemask);
4237 +
4238 +A_STATUS ar6000_get_driver_cfg(struct net_device *dev,
4239 + A_UINT16 cfgParam,
4240 + void *result);
4241 +void ar6000_bssInfo_event_rx(struct ar6_softc *ar, A_UINT8 *data, int len);
4242 +
4243 +void ar6000_dbglog_event(struct ar6_softc *ar, A_UINT32 dropped,
4244 + A_INT8 *buffer, A_UINT32 length);
4245 +
4246 +int ar6000_dbglog_get_debug_logs(struct ar6_softc *ar);
4247 +
4248 +void ar6000_indicate_tx_activity(void *devt, A_UINT8 trafficClass, A_BOOL Active);
4249 +
4250 +void ar6000_dset_open_req(void *devt,
4251 + A_UINT32 id,
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,
4258 + A_UINT32 offset,
4259 + A_UINT32 length,
4260 + A_UINT32 targ_buf,
4261 + A_UINT32 targ_reply_fn,
4262 + A_UINT32 targ_reply_arg);
4263 +
4264 +
4265 +
4266 +#ifdef __cplusplus
4267 +}
4268 +#endif
4269 +
4270 +#endif
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
4274 --- /dev/null
4275 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/athdrv_linux.h
4276 @@ -0,0 +1,993 @@
4277 +/*
4278 + * Copyright (c) 2004-2006 Atheros Communications Inc.
4279 + * All rights reserved.
4280 + *
4281 + *
4282 + *
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;
4286 + *
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.
4291 + *
4292 + *
4293 + *
4294 + */
4295 +
4296 +#ifndef _ATHDRV_LINUX_H
4297 +#define _ATHDRV_LINUX_H
4298 +
4299 +#ifdef __cplusplus
4300 +extern "C" {
4301 +#endif
4302 +
4303 +
4304 +/*
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.
4311 + */
4312 +
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)
4326 +
4327 +
4328 +
4329 +/* ====WMI Ioctls==== */
4330 +/*
4331 + *
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
4335 + * to the Target.
4336 + */
4337 +
4338 +#define AR6000_IOCTL_WMI_GETREV (SIOCIWFIRSTPRIV+10)
4339 +/*
4340 + * arguments:
4341 + * ar6000_version *revision
4342 + */
4343 +
4344 +#define AR6000_IOCTL_WMI_SETPWR (SIOCIWFIRSTPRIV+11)
4345 +/*
4346 + * arguments:
4347 + * WMI_POWER_MODE_CMD pwrModeCmd (see include/wmi.h)
4348 + * uses: WMI_SET_POWER_MODE_CMDID
4349 + */
4350 +
4351 +#define AR6000_IOCTL_WMI_SETSCAN (SIOCIWFIRSTPRIV+12)
4352 +/*
4353 + * arguments:
4354 + * WMI_SCAN_PARAMS_CMD scanParams (see include/wmi.h)
4355 + * uses: WMI_SET_SCAN_PARAMS_CMDID
4356 + */
4357 +
4358 +#define AR6000_IOCTL_WMI_SETLISTENINT (SIOCIWFIRSTPRIV+13)
4359 +/*
4360 + * arguments:
4361 + * UINT32 listenInterval
4362 + * uses: WMI_SET_LISTEN_INT_CMDID
4363 + */
4364 +
4365 +#define AR6000_IOCTL_WMI_SETBSSFILTER (SIOCIWFIRSTPRIV+14)
4366 +/*
4367 + * arguments:
4368 + * WMI_BSS_FILTER filter (see include/wmi.h)
4369 + * uses: WMI_SET_BSS_FILTER_CMDID
4370 + */
4371 +
4372 +#define AR6000_IOCTL_WMI_SET_CHANNELPARAMS (SIOCIWFIRSTPRIV+16)
4373 +/*
4374 + * arguments:
4375 + * WMI_CHANNEL_PARAMS_CMD chParams
4376 + * uses: WMI_SET_CHANNEL_PARAMS_CMDID
4377 + */
4378 +
4379 +#define AR6000_IOCTL_WMI_SET_PROBEDSSID (SIOCIWFIRSTPRIV+17)
4380 +/*
4381 + * arguments:
4382 + * WMI_PROBED_SSID_CMD probedSsids (see include/wmi.h)
4383 + * uses: WMI_SETPROBED_SSID_CMDID
4384 + */
4385 +
4386 +#define AR6000_IOCTL_WMI_SET_PMPARAMS (SIOCIWFIRSTPRIV+18)
4387 +/*
4388 + * arguments:
4389 + * WMI_POWER_PARAMS_CMD powerParams (see include/wmi.h)
4390 + * uses: WMI_SET_POWER_PARAMS_CMDID
4391 + */
4392 +
4393 +#define AR6000_IOCTL_WMI_SET_BADAP (SIOCIWFIRSTPRIV+19)
4394 +/*
4395 + * arguments:
4396 + * WMI_ADD_BAD_AP_CMD badAPs (see include/wmi.h)
4397 + * uses: WMI_ADD_BAD_AP_CMDID
4398 + */
4399 +
4400 +#define AR6000_IOCTL_WMI_GET_QOS_QUEUE (SIOCIWFIRSTPRIV+20)
4401 +/*
4402 + * arguments:
4403 + * ar6000_queuereq queueRequest (see below)
4404 + */
4405 +
4406 +#define AR6000_IOCTL_WMI_CREATE_QOS (SIOCIWFIRSTPRIV+21)
4407 +/*
4408 + * arguments:
4409 + * WMI_CREATE_PSTREAM createPstreamCmd (see include/wmi.h)
4410 + * uses: WMI_CREATE_PSTREAM_CMDID
4411 + */
4412 +
4413 +#define AR6000_IOCTL_WMI_DELETE_QOS (SIOCIWFIRSTPRIV+22)
4414 +/*
4415 + * arguments:
4416 + * WMI_DELETE_PSTREAM_CMD deletePstreamCmd (see include/wmi.h)
4417 + * uses: WMI_DELETE_PSTREAM_CMDID
4418 + */
4419 +
4420 +#define AR6000_IOCTL_WMI_SET_SNRTHRESHOLD (SIOCIWFIRSTPRIV+23)
4421 +/*
4422 + * arguments:
4423 + * WMI_SNR_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h)
4424 + * uses: WMI_SNR_THRESHOLD_PARAMS_CMDID
4425 + */
4426 +
4427 +#define AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK (SIOCIWFIRSTPRIV+24)
4428 +/*
4429 + * arguments:
4430 + * WMI_TARGET_ERROR_REPORT_BITMASK errorReportBitMask (see include/wmi.h)
4431 + * uses: WMI_TARGET_ERROR_REPORT_BITMASK_CMDID
4432 + */
4433 +
4434 +#define AR6000_IOCTL_WMI_GET_TARGET_STATS (SIOCIWFIRSTPRIV+25)
4435 +/*
4436 + * arguments:
4437 + * TARGET_STATS *targetStats (see below)
4438 + * uses: WMI_GET_STATISTICS_CMDID
4439 + */
4440 +
4441 +#define AR6000_IOCTL_WMI_SET_ASSOC_INFO (SIOCIWFIRSTPRIV+26)
4442 +/*
4443 + * arguments:
4444 + * WMI_SET_ASSOC_INFO_CMD setAssocInfoCmd
4445 + * uses: WMI_SET_ASSOC_INFO_CMDID
4446 + */
4447 +
4448 +#define AR6000_IOCTL_WMI_SET_ACCESS_PARAMS (SIOCIWFIRSTPRIV+27)
4449 +/*
4450 + * arguments:
4451 + * WMI_SET_ACCESS_PARAMS_CMD setAccessParams (see include/wmi.h)
4452 + * uses: WMI_SET_ACCESS_PARAMS_CMDID
4453 + */
4454 +
4455 +#define AR6000_IOCTL_WMI_SET_BMISS_TIME (SIOCIWFIRSTPRIV+28)
4456 +/*
4457 + * arguments:
4458 + * UINT32 beaconMissTime
4459 + * uses: WMI_SET_BMISS_TIME_CMDID
4460 + */
4461 +
4462 +#define AR6000_IOCTL_WMI_SET_DISC_TIMEOUT (SIOCIWFIRSTPRIV+29)
4463 +/*
4464 + * arguments:
4465 + * WMI_DISC_TIMEOUT_CMD disconnectTimeoutCmd (see include/wmi.h)
4466 + * uses: WMI_SET_DISC_TIMEOUT_CMDID
4467 + */
4468 +
4469 +#define AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS (SIOCIWFIRSTPRIV+30)
4470 +/*
4471 + * arguments:
4472 + * WMI_IBSS_PM_CAPS_CMD ibssPowerMgmtCapsCmd
4473 + * uses: WMI_SET_IBSS_PM_CAPS_CMDID
4474 + */
4475 +
4476 +/*
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.
4481 + */
4482 +#define AR6000_IOCTL_EXTENDED (SIOCIWFIRSTPRIV+31)
4483 +
4484 +
4485 +/* ====BMI Extended Ioctls==== */
4486 +
4487 +#define AR6000_XIOCTL_BMI_DONE 1
4488 +/*
4489 + * arguments:
4490 + * UINT32 cmd (AR6000_XIOCTL_BMI_DONE)
4491 + * uses: BMI_DONE
4492 + */
4493 +
4494 +#define AR6000_XIOCTL_BMI_READ_MEMORY 2
4495 +/*
4496 + * arguments:
4497 + * union {
4498 + * struct {
4499 + * UINT32 cmd (AR6000_XIOCTL_BMI_READ_MEMORY)
4500 + * UINT32 address
4501 + * UINT32 length
4502 + * }
4503 + * char results[length]
4504 + * }
4505 + * uses: BMI_READ_MEMORY
4506 + */
4507 +
4508 +#define AR6000_XIOCTL_BMI_WRITE_MEMORY 3
4509 +/*
4510 + * arguments:
4511 + * UINT32 cmd (AR6000_XIOCTL_BMI_WRITE_MEMORY)
4512 + * UINT32 address
4513 + * UINT32 length
4514 + * char data[length]
4515 + * uses: BMI_WRITE_MEMORY
4516 + */
4517 +
4518 +#define AR6000_XIOCTL_BMI_EXECUTE 4
4519 +/*
4520 + * arguments:
4521 + * UINT32 cmd (AR6000_XIOCTL_BMI_EXECUTE)
4522 + * UINT32 TargetAddress
4523 + * UINT32 parameter
4524 + * uses: BMI_EXECUTE
4525 + */
4526 +
4527 +#define AR6000_XIOCTL_BMI_SET_APP_START 5
4528 +/*
4529 + * arguments:
4530 + * UINT32 cmd (AR6000_XIOCTL_BMI_SET_APP_START)
4531 + * UINT32 TargetAddress
4532 + * uses: BMI_SET_APP_START
4533 + */
4534 +
4535 +#define AR6000_XIOCTL_BMI_READ_SOC_REGISTER 6
4536 +/*
4537 + * arguments:
4538 + * union {
4539 + * struct {
4540 + * UINT32 cmd (AR6000_XIOCTL_BMI_READ_SOC_REGISTER)
4541 + * UINT32 TargetAddress, 32-bit aligned
4542 + * }
4543 + * UINT32 result
4544 + * }
4545 + * uses: BMI_READ_SOC_REGISTER
4546 + */
4547 +
4548 +#define AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER 7
4549 +/*
4550 + * arguments:
4551 + * struct {
4552 + * UINT32 cmd (AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER)
4553 + * UINT32 TargetAddress, 32-bit aligned
4554 + * UINT32 newValue
4555 + * }
4556 + * uses: BMI_WRITE_SOC_REGISTER
4557 + */
4558 +
4559 +#define AR6000_XIOCTL_BMI_TEST 8
4560 +/*
4561 + * arguments:
4562 + * UINT32 cmd (AR6000_XIOCTL_BMI_TEST)
4563 + * UINT32 address
4564 + * UINT32 length
4565 + * UINT32 count
4566 + */
4567 +
4568 +
4569 +
4570 +/* Historical Host-side DataSet support */
4571 +#define AR6000_XIOCTL_UNUSED9 9
4572 +#define AR6000_XIOCTL_UNUSED10 10
4573 +#define AR6000_XIOCTL_UNUSED11 11
4574 +
4575 +/* ====Misc Extended Ioctls==== */
4576 +
4577 +#define AR6000_XIOCTL_FORCE_TARGET_RESET 12
4578 +/*
4579 + * arguments:
4580 + * UINT32 cmd (AR6000_XIOCTL_FORCE_TARGET_RESET)
4581 + */
4582 +
4583 +
4584 +#ifdef HTC_RAW_INTERFACE
4585 +/* HTC Raw Interface Ioctls */
4586 +#define AR6000_XIOCTL_HTC_RAW_OPEN 13
4587 +/*
4588 + * arguments:
4589 + * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_OPEN)
4590 + */
4591 +
4592 +#define AR6000_XIOCTL_HTC_RAW_CLOSE 14
4593 +/*
4594 + * arguments:
4595 + * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_CLOSE)
4596 + */
4597 +
4598 +#define AR6000_XIOCTL_HTC_RAW_READ 15
4599 +/*
4600 + * arguments:
4601 + * union {
4602 + * struct {
4603 + * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_READ)
4604 + * UINT32 mailboxID
4605 + * UINT32 length
4606 + * }
4607 + * results[length]
4608 + * }
4609 + */
4610 +
4611 +#define AR6000_XIOCTL_HTC_RAW_WRITE 16
4612 +/*
4613 + * arguments:
4614 + * UINT32 cmd (AR6000_XIOCTL_HTC_RAW_WRITE)
4615 + * UINT32 mailboxID
4616 + * UINT32 length
4617 + * char buffer[length]
4618 + */
4619 +#endif /* HTC_RAW_INTERFACE */
4620 +
4621 +#define AR6000_XIOCTL_CHECK_TARGET_READY 17
4622 +/*
4623 + * arguments:
4624 + * UINT32 cmd (AR6000_XIOCTL_CHECK_TARGET_READY)
4625 + */
4626 +
4627 +
4628 +
4629 +/* ====GPIO (General Purpose I/O) Extended Ioctls==== */
4630 +
4631 +#define AR6000_XIOCTL_GPIO_OUTPUT_SET 18
4632 +/*
4633 + * arguments:
4634 + * UINT32 cmd (AR6000_XIOCTL_GPIO_OUTPUT_SET)
4635 + * ar6000_gpio_output_set_cmd_s (see below)
4636 + * uses: WMIX_GPIO_OUTPUT_SET_CMDID
4637 + */
4638 +
4639 +#define AR6000_XIOCTL_GPIO_INPUT_GET 19
4640 +/*
4641 + * arguments:
4642 + * UINT32 cmd (AR6000_XIOCTL_GPIO_INPUT_GET)
4643 + * uses: WMIX_GPIO_INPUT_GET_CMDID
4644 + */
4645 +
4646 +#define AR6000_XIOCTL_GPIO_REGISTER_SET 20
4647 +/*
4648 + * arguments:
4649 + * UINT32 cmd (AR6000_XIOCTL_GPIO_REGISTER_SET)
4650 + * ar6000_gpio_register_cmd_s (see below)
4651 + * uses: WMIX_GPIO_REGISTER_SET_CMDID
4652 + */
4653 +
4654 +#define AR6000_XIOCTL_GPIO_REGISTER_GET 21
4655 +/*
4656 + * arguments:
4657 + * UINT32 cmd (AR6000_XIOCTL_GPIO_REGISTER_GET)
4658 + * ar6000_gpio_register_cmd_s (see below)
4659 + * uses: WMIX_GPIO_REGISTER_GET_CMDID
4660 + */
4661 +
4662 +#define AR6000_XIOCTL_GPIO_INTR_ACK 22
4663 +/*
4664 + * arguments:
4665 + * UINT32 cmd (AR6000_XIOCTL_GPIO_INTR_ACK)
4666 + * ar6000_cpio_intr_ack_cmd_s (see below)
4667 + * uses: WMIX_GPIO_INTR_ACK_CMDID
4668 + */
4669 +
4670 +#define AR6000_XIOCTL_GPIO_INTR_WAIT 23
4671 +/*
4672 + * arguments:
4673 + * UINT32 cmd (AR6000_XIOCTL_GPIO_INTR_WAIT)
4674 + */
4675 +
4676 +
4677 +
4678 +/* ====more wireless commands==== */
4679 +
4680 +#define AR6000_XIOCTL_SET_ADHOC_BSSID 24
4681 +/*
4682 + * arguments:
4683 + * UINT32 cmd (AR6000_XIOCTL_SET_ADHOC_BSSID)
4684 + * WMI_SET_ADHOC_BSSID_CMD setAdHocBssidCmd (see include/wmi.h)
4685 + */
4686 +
4687 +#define AR6000_XIOCTL_SET_OPT_MODE 25
4688 +/*
4689 + * arguments:
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
4693 + */
4694 +
4695 +#define AR6000_XIOCTL_OPT_SEND_FRAME 26
4696 +/*
4697 + * arguments:
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
4701 + */
4702 +
4703 +#define AR6000_XIOCTL_SET_ADHOC_BEACON_INTVAL 27
4704 +/*
4705 + * arguments:
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
4709 + */
4710 +
4711 +
4712 +#define IEEE80211_IOCTL_SETAUTHALG 28
4713 +
4714 +
4715 +#define AR6000_XIOCTL_SET_VOICE_PKT_SIZE 29
4716 +/*
4717 + * arguments:
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
4721 + */
4722 +
4723 +
4724 +#define AR6000_XIOCTL_SET_MAX_SP 30
4725 +/*
4726 + * arguments:
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
4730 + */
4731 +
4732 +#define AR6000_XIOCTL_WMI_GET_ROAM_TBL 31
4733 +
4734 +#define AR6000_XIOCTL_WMI_SET_ROAM_CTRL 32
4735 +
4736 +#define AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS 33
4737 +
4738 +
4739 +/*
4740 + * arguments:
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
4744 + */
4745 +
4746 +#define AR6000_XIOCTRL_WMI_GET_POWER_MODE 34
4747 +/*
4748 + * arguments:
4749 + * UINT32 cmd (AR6000_XIOCTRL_WMI_GET_POWER_MODE)
4750 + */
4751 +
4752 +#define AR6000_XIOCTRL_WMI_SET_WLAN_STATE 35
4753 +typedef enum {
4754 + WLAN_DISABLED,
4755 + WLAN_ENABLED
4756 +} AR6000_WLAN_STATE;
4757 +/*
4758 + * arguments:
4759 + * enable/disable
4760 + */
4761 +
4762 +#define AR6000_XIOCTL_WMI_GET_ROAM_DATA 36
4763 +
4764 +#define AR6000_XIOCTL_WMI_SETRETRYLIMITS 37
4765 +/*
4766 + * arguments:
4767 + * WMI_SET_RETRY_LIMITS_CMD ibssSetRetryLimitsCmd
4768 + * uses: WMI_SET_RETRY_LIMITS_CMDID
4769 + */
4770 +
4771 +#ifdef CONFIG_HOST_TCMD_SUPPORT
4772 +/* ====extended commands for radio test ==== */
4773 +
4774 +#define AR6000_XIOCTL_TCMD_CONT_TX 38
4775 +/*
4776 + * arguments:
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
4780 + */
4781 +
4782 +#define AR6000_XIOCTL_TCMD_CONT_RX 39
4783 +/*
4784 + * arguments:
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
4788 + */
4789 +
4790 +#define AR6000_XIOCTL_TCMD_PM 40
4791 +/*
4792 + * arguments:
4793 + * UINT32 cmd (AR6000_XIOCTL_TCMD_PM)
4794 + * WMI_TCMD_PM_CMD pmCmd (see include/wmi.h)
4795 + * uses: WMI_TCMD_PM_CMDID
4796 + */
4797 +
4798 +#endif /* CONFIG_HOST_TCMD_SUPPORT */
4799 +
4800 +#define AR6000_XIOCTL_WMI_STARTSCAN 41
4801 +/*
4802 + * arguments:
4803 + * UINT32 cmd (AR6000_XIOCTL_WMI_STARTSCAN)
4804 + * UINT8 scanType
4805 + * UINT8 scanConnected
4806 + * A_BOOL forceFgScan
4807 + * uses: WMI_START_SCAN_CMDID
4808 + */
4809 +
4810 +#define AR6000_XIOCTL_WMI_SETFIXRATES 42
4811 +
4812 +#define AR6000_XIOCTL_WMI_GETFIXRATES 43
4813 +
4814 +
4815 +#define AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD 44
4816 +/*
4817 + * arguments:
4818 + * WMI_RSSI_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h)
4819 + * uses: WMI_RSSI_THRESHOLD_PARAMS_CMDID
4820 + */
4821 +
4822 +#define AR6000_XIOCTL_WMI_CLR_RSSISNR 45
4823 +/*
4824 + * arguments:
4825 + * WMI_CLR_RSSISNR_CMD thresholdParams (see include/wmi.h)
4826 + * uses: WMI_CLR_RSSISNR_CMDID
4827 + */
4828 +
4829 +#define AR6000_XIOCTL_WMI_SET_LQTHRESHOLD 46
4830 +/*
4831 + * arguments:
4832 + * WMI_LQ_THRESHOLD_PARAMS_CMD thresholdParams (see include/wmi.h)
4833 + * uses: WMI_LQ_THRESHOLD_PARAMS_CMDID
4834 + */
4835 +
4836 +#define AR6000_XIOCTL_WMI_SET_RTS 47
4837 +/*
4838 + * arguments:
4839 + * WMI_SET_RTS_MODE_CMD (see include/wmi.h)
4840 + * uses: WMI_SET_RTS_MODE_CMDID
4841 + */
4842 +
4843 +#define AR6000_XIOCTL_WMI_SET_LPREAMBLE 48
4844 +
4845 +#define AR6000_XIOCTL_WMI_SET_AUTHMODE 49
4846 +/*
4847 + * arguments:
4848 + * UINT32 cmd (AR6000_XIOCTL_WMI_SET_AUTHMODE)
4849 + * UINT8 mode
4850 + * uses: WMI_SET_RECONNECT_AUTH_MODE_CMDID
4851 + */
4852 +
4853 +#define AR6000_XIOCTL_WMI_SET_REASSOCMODE 50
4854 +
4855 +/*
4856 + * arguments:
4857 + * UINT32 cmd (AR6000_XIOCTL_WMI_SET_WMM)
4858 + * UINT8 mode
4859 + * uses: WMI_SET_WMM_CMDID
4860 + */
4861 +#define AR6000_XIOCTL_WMI_SET_WMM 51
4862 +
4863 +/*
4864 + * arguments:
4865 + * UINT32 cmd (AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS)
4866 + * UINT32 frequency
4867 + * UINT8 threshold
4868 + */
4869 +#define AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS 52
4870 +
4871 +/*
4872 + * arguments:
4873 + * UINT32 cmd (AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP)
4874 + * UINT32 cookie
4875 + */
4876 +#define AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP 53
4877 +
4878 +/*
4879 + * arguments:
4880 + * UINT32 cmd (AR6000_XIOCTL_WMI_GET_RD)
4881 + * UINT32 regDomain
4882 + */
4883 +#define AR6000_XIOCTL_WMI_GET_RD 54
4884 +
4885 +#define AR6000_XIOCTL_DIAG_READ 55
4886 +
4887 +#define AR6000_XIOCTL_DIAG_WRITE 56
4888 +
4889 +/*
4890 + * arguments cmd (AR6000_XIOCTL_SET_TXOP)
4891 + * WMI_TXOP_CFG txopEnable
4892 + */
4893 +#define AR6000_XIOCTL_WMI_SET_TXOP 57
4894 +
4895 +#ifdef USER_KEYS
4896 +/*
4897 + * arguments:
4898 + * UINT32 cmd (AR6000_XIOCTL_USER_SETKEYS)
4899 + * UINT32 keyOpCtrl
4900 + * uses AR6000_USER_SETKEYS_INFO
4901 + */
4902 +#define AR6000_XIOCTL_USER_SETKEYS 58
4903 +#endif /* USER_KEYS */
4904 +
4905 +#define AR6000_XIOCTL_WMI_SET_KEEPALIVE 59
4906 +/*
4907 + * arguments:
4908 + * UINT8 cmd (AR6000_XIOCTL_WMI_SET_KEEPALIVE)
4909 + * UINT8 keepaliveInterval
4910 + * uses: WMI_SET_KEEPALIVE_CMDID
4911 + */
4912 +
4913 +#define AR6000_XIOCTL_WMI_GET_KEEPALIVE 60
4914 +/*
4915 + * arguments:
4916 + * UINT8 cmd (AR6000_XIOCTL_WMI_GET_KEEPALIVE)
4917 + * UINT8 keepaliveInterval
4918 + * A_BOOL configured
4919 + * uses: WMI_GET_KEEPALIVE_CMDID
4920 + */
4921 +
4922 +/* ====ROM Patching Extended Ioctls==== */
4923 +
4924 +#define AR6000_XIOCTL_BMI_ROMPATCH_INSTALL 61
4925 +/*
4926 + * arguments:
4927 + * union {
4928 + * struct {
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)
4934 + * }
4935 + * A_UINT32 resulting rompatch ID
4936 + * }
4937 + * uses: BMI_ROMPATCH_INSTALL
4938 + */
4939 +
4940 +#define AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL 62
4941 +/*
4942 + * arguments:
4943 + * struct {
4944 + * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL)
4945 + * UINT32 rompatch ID
4946 + * }
4947 + * uses: BMI_ROMPATCH_UNINSTALL
4948 + */
4949 +
4950 +#define AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE 63
4951 +/*
4952 + * arguments:
4953 + * struct {
4954 + * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE)
4955 + * UINT32 rompatch count
4956 + * UINT32 rompatch IDs[rompatch count]
4957 + * }
4958 + * uses: BMI_ROMPATCH_ACTIVATE
4959 + */
4960 +
4961 +#define AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE 64
4962 +/*
4963 + * arguments:
4964 + * struct {
4965 + * UINT32 cmd (AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE)
4966 + * UINT32 rompatch count
4967 + * UINT32 rompatch IDs[rompatch count]
4968 + * }
4969 + * uses: BMI_ROMPATCH_DEACTIVATE
4970 + */
4971 +
4972 +#define AR6000_XIOCTL_WMI_SET_APPIE 65
4973 +/*
4974 + * arguments:
4975 + * struct {
4976 + * UINT32 cmd (AR6000_XIOCTL_WMI_SET_APPIE)
4977 + * UINT32 app_frmtype;
4978 + * UINT32 app_buflen;
4979 + * UINT8 app_buf[];
4980 + * }
4981 + */
4982 +#define AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER 66
4983 +/*
4984 + * arguments:
4985 + * A_UINT32 filter_type;
4986 + */
4987 +
4988 +#define AR6000_XIOCTL_DBGLOG_CFG_MODULE 67
4989 +
4990 +#define AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS 68
4991 +
4992 +#define AR6000_XIOCTL_WMI_SET_WSC_STATUS 70
4993 +/*
4994 + * arguments:
4995 + * A_UINT32 wsc_status;
4996 + * (WSC_REG_INACTIVE or WSC_REG_ACTIVE)
4997 + */
4998 +
4999 +/*
5000 + * arguments:
5001 + * struct {
5002 + * A_UINT8 streamType;
5003 + * A_UINT8 status;
5004 + * }
5005 + * uses: WMI_SET_BT_STATUS_CMDID
5006 + */
5007 +#define AR6000_XIOCTL_WMI_SET_BT_STATUS 71
5008 +
5009 +/*
5010 + * arguments:
5011 + * struct {
5012 + * A_UINT8 paramType;
5013 + * union {
5014 + * A_UINT8 noSCOPkts;
5015 + * BT_PARAMS_A2DP a2dpParams;
5016 + * BT_COEX_REGS regs;
5017 + * };
5018 + * }
5019 + * uses: WMI_SET_BT_PARAM_CMDID
5020 + */
5021 +#define AR6000_XIOCTL_WMI_SET_BT_PARAMS 72
5022 +
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
5028 +
5029 +
5030 +
5031 +#define AR6000_XIOCTL_TARGET_INFO 78
5032 +/*
5033 + * arguments:
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)
5038 + */
5039 +
5040 +#define AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE 79
5041 +/*
5042 + * arguments:
5043 + * none
5044 + */
5045 +
5046 +#define AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE 80
5047 +/*
5048 + * This ioctl is used to emulate traffic activity
5049 + * timeouts. Activity/inactivity will trigger the driver
5050 + * to re-balance credits.
5051 + *
5052 + * arguments:
5053 + * ar6000_traffic_activity_change
5054 + */
5055 +
5056 +#define AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS 81
5057 +/*
5058 + * This ioctl is used to set the connect control flags
5059 + *
5060 + * arguments:
5061 + * A_UINT32 connectCtrlFlags
5062 + */
5063 +
5064 +#define AR6000_XIOCTL_WMI_SET_AKMP_PARAMS 82
5065 +/*
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.
5070 + *
5071 + * arguments:
5072 + * struct {
5073 + * A_UINT32 akmpInfo;
5074 + * }
5075 + * uses: WMI_SET_AKMP_PARAMS_CMD
5076 + */
5077 +
5078 +#define AR6000_XIOCTL_WMI_GET_PMKID_LIST 83
5079 +
5080 +#define AR6000_XIOCTL_WMI_SET_PMKID_LIST 84
5081 +/*
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.
5086 + *
5087 + * arguments:
5088 + * struct {
5089 + * A_UINT32 numPMKID;
5090 + * WMI_PMKID pmkidList[WMI_MAX_PMKID_CACHE];
5091 + * }
5092 + * uses: WMI_SET_PMKIDLIST_CMD
5093 + */
5094 +
5095 +/* Historical DSETPATCH support for INI patches */
5096 +#define AR6000_XIOCTL_UNUSED90 90
5097 +
5098 +
5099 +
5100 +/* used by AR6000_IOCTL_WMI_GETREV */
5101 +struct ar6000_version {
5102 + A_UINT32 host_ver;
5103 + A_UINT32 target_ver;
5104 +};
5105 +
5106 +/* used by AR6000_IOCTL_WMI_GET_QOS_QUEUE */
5107 +struct ar6000_queuereq {
5108 + A_UINT8 trafficClass;
5109 + A_UINT16 activeTsids;
5110 +};
5111 +
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];
5124 +
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;
5139 +
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;
5146 +
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;
5153 +
5154 + A_UINT64 power_save_failure_cnt;
5155 + A_INT16 noise_floor_calibation;
5156 +
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;
5164 + A_UINT8 cs_snr;
5165 + A_INT16 cs_rssi;
5166 +
5167 + A_UINT32 lq_val;
5168 +
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;
5173 +
5174 +}TARGET_STATS;
5175 +
5176 +typedef struct targetStats_cmd_t {
5177 + TARGET_STATS targetStats;
5178 + int clearStats;
5179 +} TARGET_STATS_CMD;
5180 +
5181 +/* used by AR6000_XIOCTL_USER_SETKEYS */
5182 +
5183 +/*
5184 + * Setting this bit to 1 doesnot initialize the RSC on the firmware
5185 + */
5186 +#define AR6000_XIOCTL_USER_SETKEYS_RSC_CTRL 1
5187 +#define AR6000_USER_SETKEYS_RSC_UNCHANGED 0x00000002
5188 +
5189 +typedef struct {
5190 + A_UINT32 keyOpCtrl; /* Bit Map of Key Mgmt Ctrl Flags */
5191 +} AR6000_USER_SETKEYS_INFO;
5192 +
5193 +
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;
5200 +};
5201 +
5202 +/*
5203 + * used by AR6000_XIOCTL_GPIO_REGISTER_GET and AR6000_XIOCTL_GPIO_REGISTER_SET
5204 + */
5205 +struct ar6000_gpio_register_cmd_s {
5206 + A_UINT32 gpioreg_id;
5207 + A_UINT32 value;
5208 +};
5209 +
5210 +/* used by AR6000_XIOCTL_GPIO_INTR_ACK */
5211 +struct ar6000_gpio_intr_ack_cmd_s {
5212 + A_UINT32 ack_mask;
5213 +};
5214 +
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;
5219 +};
5220 +
5221 +/* used by the AR6000_XIOCTL_DBGLOG_CFG_MODULE */
5222 +typedef struct ar6000_dbglog_module_config_s {
5223 + A_UINT32 valid;
5224 + A_UINT16 mmask;
5225 + A_UINT16 tsr;
5226 + A_BOOL rep;
5227 + A_UINT16 size;
5228 +} DBGLOG_MODULE_CONFIG;
5229 +
5230 +typedef struct user_rssi_thold_t {
5231 + A_INT16 tag;
5232 + A_INT16 rssi;
5233 +} USER_RSSI_THOLD;
5234 +
5235 +typedef struct user_rssi_params_t {
5236 + A_UINT8 weight;
5237 + A_UINT32 pollTime;
5238 + USER_RSSI_THOLD tholds[12];
5239 +} USER_RSSI_PARAMS;
5240 +
5241 +/*
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.
5246 + */
5247 +#define AR6000_DRIVER_CFG_BASE 0x8000
5248 +
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
5253 +
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;
5258 +};
5259 +
5260 +
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) */
5264 +};
5265 +
5266 +#ifdef __cplusplus
5267 +}
5268 +#endif
5269 +#endif
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
5273 --- /dev/null
5274 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/athtypes_linux.h
5275 @@ -0,0 +1,47 @@
5276 +/*
5277 + * $Id: //depot/sw/releases/olca2.0-GPL/host/os/linux/include/athtypes_linux.h#1 $
5278 + *
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
5281 + * type.
5282 + *
5283 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
5284 + *
5285 + *
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;
5289 + *
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.
5294 + *
5295 + *
5296 + *
5297 + */
5298 +
5299 +#ifndef _ATHTYPES_LINUX_H_
5300 +#define _ATHTYPES_LINUX_H_
5301 +
5302 +#ifdef __KERNEL__
5303 +#include <linux/types.h>
5304 +#endif
5305 +
5306 +typedef int8_t A_INT8;
5307 +typedef int16_t A_INT16;
5308 +typedef int32_t A_INT32;
5309 +typedef int64_t A_INT64;
5310 +
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;
5315 +
5316 +typedef int A_BOOL;
5317 +typedef char A_CHAR;
5318 +typedef unsigned char A_UCHAR;
5319 +typedef unsigned long A_ATH_TIMER;
5320 +
5321 +
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
5326 --- /dev/null
5327 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/config_linux.h
5328 @@ -0,0 +1,44 @@
5329 +/*
5330 + * Copyright (c) 2004-2007 Atheros Communications Inc.
5331 + * All rights reserved.
5332 + *
5333 + *
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;
5337 + *
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.
5342 + *
5343 + *
5344 + *
5345 + */
5346 +
5347 +#ifndef _CONFIG_LINUX_H_
5348 +#define _CONFIG_LINUX_H_
5349 +
5350 +#ifdef __cplusplus
5351 +extern "C" {
5352 +#endif
5353 +
5354 +/*
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.
5358 + */
5359 +#define CONFIG_HOST_GPIO_SUPPORT
5360 +
5361 +/*
5362 + * Host side Test Command support
5363 + */
5364 +#define CONFIG_HOST_TCMD_SUPPORT
5365 +
5366 +#define USE_4BYTE_REGISTER_ACCESS
5367 +
5368 +#ifdef __cplusplus
5369 +}
5370 +#endif
5371 +
5372 +#endif
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
5376 --- /dev/null
5377 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/debug_linux.h
5378 @@ -0,0 +1,86 @@
5379 +/*
5380 + * Copyright (c) 2004-2006 Atheros Communications Inc.
5381 + * All rights reserved.
5382 + *
5383 + *
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;
5387 + *
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.
5392 + *
5393 + *
5394 + *
5395 + */
5396 +
5397 +#ifndef _DEBUG_LINUX_H_
5398 +#define _DEBUG_LINUX_H_
5399 +
5400 +#define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING)
5401 +
5402 +extern A_UINT32 g_dbg_flags;
5403 +
5404 +#define DBGFMT "%s() : "
5405 +#define DBGARG __func__
5406 +#define DBGFN A_PRINTF
5407 +
5408 +/* ------- Debug related stuff ------- */
5409 +enum {
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,
5426 +};
5427 +
5428 +#ifdef DEBUG
5429 +
5430 +#define A_DPRINTF(f, a) \
5431 + if(g_dbg_flags & (f)) \
5432 + { \
5433 + DBGFN a ; \
5434 + }
5435 +
5436 +
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); \
5442 + } \
5443 +} while(0)
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); \
5448 + } \
5449 +} while (0)
5450 +#define AR_DEBUG_ASSERT(test) do { \
5451 + if (!(test)) { \
5452 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Debug Assert Caught, File %s, Line: %d, Test:%s \n",__FILE__, __LINE__,#test)); \
5453 + } \
5454 +} while(0)
5455 +extern int debughtc;
5456 +#else
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)
5462 +#endif
5463 +
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
5468 --- /dev/null
5469 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/ioctl.c
5470 @@ -0,0 +1,2540 @@
5471 +/*
5472 + *
5473 + * Copyright (c) 2004-2007 Atheros Communications Inc.
5474 + * All rights reserved.
5475 + *
5476 + *
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;
5480 + *
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.
5485 + *
5486 + *
5487 + *
5488 + */
5489 +
5490 +#include "ar6000_drv.h"
5491 +
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;
5500 +
5501 +static int
5502 +ar6000_ioctl_get_roam_tbl(struct net_device *dev, struct ifreq *rq)
5503 +{
5504 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5505 +
5506 + if (ar->arWmiReady == FALSE) {
5507 + return -EIO;
5508 + }
5509 +
5510 + if(wmi_get_roam_tbl_cmd(ar->arWmi) != A_OK) {
5511 + return -EIO;
5512 + }
5513 +
5514 + return 0;
5515 +}
5516 +
5517 +static int
5518 +ar6000_ioctl_get_roam_data(struct net_device *dev, struct ifreq *rq)
5519 +{
5520 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5521 +
5522 + if (ar->arWmiReady == FALSE) {
5523 + return -EIO;
5524 + }
5525 +
5526 +
5527 + /* currently assume only roam times are required */
5528 + if(wmi_get_roam_data_cmd(ar->arWmi, ROAM_DATA_TIME) != A_OK) {
5529 + return -EIO;
5530 + }
5531 +
5532 +
5533 + return 0;
5534 +}
5535 +
5536 +static int
5537 +ar6000_ioctl_set_roam_ctrl(struct net_device *dev, char *userdata)
5538 +{
5539 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5540 + WMI_SET_ROAM_CTRL_CMD cmd;
5541 + A_UINT8 size = sizeof(cmd);
5542 +
5543 + if (ar->arWmiReady == FALSE) {
5544 + return -EIO;
5545 + }
5546 +
5547 +
5548 + if (copy_from_user(&cmd, userdata, size)) {
5549 + return -EFAULT;
5550 + }
5551 +
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);
5555 + }
5556 + }
5557 +
5558 + if (copy_from_user(&cmd, userdata, size)) {
5559 + return -EFAULT;
5560 + }
5561 +
5562 + if(wmi_set_roam_ctrl_cmd(ar->arWmi, &cmd, size) != A_OK) {
5563 + return -EIO;
5564 + }
5565 +
5566 + return 0;
5567 +}
5568 +
5569 +static int
5570 +ar6000_ioctl_set_powersave_timers(struct net_device *dev, char *userdata)
5571 +{
5572 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5573 + WMI_POWERSAVE_TIMERS_POLICY_CMD cmd;
5574 + A_UINT8 size = sizeof(cmd);
5575 +
5576 + if (ar->arWmiReady == FALSE) {
5577 + return -EIO;
5578 + }
5579 +
5580 + if (copy_from_user(&cmd, userdata, size)) {
5581 + return -EFAULT;
5582 + }
5583 +
5584 + if (copy_from_user(&cmd, userdata, size)) {
5585 + return -EFAULT;
5586 + }
5587 +
5588 + if(wmi_set_powersave_timers_cmd(ar->arWmi, &cmd, size) != A_OK) {
5589 + return -EIO;
5590 + }
5591 +
5592 + return 0;
5593 +}
5594 +
5595 +static int
5596 +ar6000_ioctl_set_wmm(struct net_device *dev, struct ifreq *rq)
5597 +{
5598 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5599 + WMI_SET_WMM_CMD cmd;
5600 + A_STATUS ret;
5601 +
5602 + if ((dev->flags & IFF_UP) != IFF_UP) {
5603 + return -EIO;
5604 + }
5605 + if (ar->arWmiReady == FALSE) {
5606 + return -EIO;
5607 + }
5608 +
5609 + if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
5610 + sizeof(cmd)))
5611 + {
5612 + return -EFAULT;
5613 + }
5614 +
5615 + if (cmd.status == WMI_WMM_ENABLED) {
5616 + ar->arWmmEnabled = TRUE;
5617 + } else {
5618 + ar->arWmmEnabled = FALSE;
5619 + }
5620 +
5621 + ret = wmi_set_wmm_cmd(ar->arWmi, cmd.status);
5622 +
5623 + switch (ret) {
5624 + case A_OK:
5625 + return 0;
5626 + case A_EBUSY :
5627 + return -EBUSY;
5628 + case A_NO_MEMORY:
5629 + return -ENOMEM;
5630 + case A_EINVAL:
5631 + default:
5632 + return -EFAULT;
5633 + }
5634 +}
5635 +
5636 +static int
5637 +ar6000_ioctl_set_txop(struct net_device *dev, struct ifreq *rq)
5638 +{
5639 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5640 + WMI_SET_WMM_TXOP_CMD cmd;
5641 + A_STATUS ret;
5642 +
5643 + if ((dev->flags & IFF_UP) != IFF_UP) {
5644 + return -EIO;
5645 + }
5646 + if (ar->arWmiReady == FALSE) {
5647 + return -EIO;
5648 + }
5649 +
5650 + if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
5651 + sizeof(cmd)))
5652 + {
5653 + return -EFAULT;
5654 + }
5655 +
5656 + ret = wmi_set_wmm_txop(ar->arWmi, cmd.txopEnable);
5657 +
5658 + switch (ret) {
5659 + case A_OK:
5660 + return 0;
5661 + case A_EBUSY :
5662 + return -EBUSY;
5663 + case A_NO_MEMORY:
5664 + return -ENOMEM;
5665 + case A_EINVAL:
5666 + default:
5667 + return -EFAULT;
5668 + }
5669 +}
5670 +
5671 +static int
5672 +ar6000_ioctl_get_rd(struct net_device *dev, struct ifreq *rq)
5673 +{
5674 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5675 + A_STATUS ret = 0;
5676 +
5677 + if ((dev->flags & IFF_UP) != IFF_UP || ar->arWmiReady == FALSE) {
5678 + return -EIO;
5679 + }
5680 +
5681 + if(copy_to_user((char *)((unsigned int*)rq->ifr_data + 1),
5682 + &ar->arRegCode, sizeof(ar->arRegCode)))
5683 + ret = -EFAULT;
5684 +
5685 + return ret;
5686 +}
5687 +
5688 +
5689 +/* Get power mode command */
5690 +static int
5691 +ar6000_ioctl_get_power_mode(struct net_device *dev, struct ifreq *rq)
5692 +{
5693 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5694 + WMI_POWER_MODE_CMD power_mode;
5695 + int ret = 0;
5696 +
5697 + if (ar->arWmiReady == FALSE) {
5698 + return -EIO;
5699 + }
5700 +
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))) {
5703 + ret = -EFAULT;
5704 + }
5705 +
5706 + return ret;
5707 +}
5708 +
5709 +
5710 +static int
5711 +ar6000_ioctl_set_channelParams(struct net_device *dev, struct ifreq *rq)
5712 +{
5713 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5714 + WMI_CHANNEL_PARAMS_CMD cmd, *cmdp;
5715 + int ret = 0;
5716 +
5717 + if (ar->arWmiReady == FALSE) {
5718 + return -EIO;
5719 + }
5720 +
5721 +
5722 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5723 + return -EFAULT;
5724 + }
5725 +
5726 + if (cmd.numChannels > 1) {
5727 + cmdp = A_MALLOC(130);
5728 + if (copy_from_user(cmdp, rq->ifr_data,
5729 + sizeof (*cmdp) +
5730 + ((cmd.numChannels - 1) * sizeof(A_UINT16))))
5731 + {
5732 + kfree(cmdp);
5733 + return -EFAULT;
5734 + }
5735 + } else {
5736 + cmdp = &cmd;
5737 + }
5738 +
5739 + if ((ar->arPhyCapability == WMI_11G_CAPABILITY) &&
5740 + ((cmdp->phyMode == WMI_11A_MODE) || (cmdp->phyMode == WMI_11AG_MODE)))
5741 + {
5742 + ret = -EINVAL;
5743 + }
5744 +
5745 + if (!ret &&
5746 + (wmi_set_channelParams_cmd(ar->arWmi, cmdp->scanParam, cmdp->phyMode,
5747 + cmdp->numChannels, cmdp->channelList)
5748 + != A_OK))
5749 + {
5750 + ret = -EIO;
5751 + }
5752 +
5753 + if (cmd.numChannels > 1) {
5754 + kfree(cmdp);
5755 + }
5756 +
5757 + return ret;
5758 +}
5759 +
5760 +static int
5761 +ar6000_ioctl_set_snr_threshold(struct net_device *dev, struct ifreq *rq)
5762 +{
5763 +
5764 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5765 + WMI_SNR_THRESHOLD_PARAMS_CMD cmd;
5766 + int ret = 0;
5767 +
5768 + if (ar->arWmiReady == FALSE) {
5769 + return -EIO;
5770 + }
5771 +
5772 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5773 + return -EFAULT;
5774 + }
5775 +
5776 + if( wmi_set_snr_threshold_params(ar->arWmi, &cmd) != A_OK ) {
5777 + ret = -EIO;
5778 + }
5779 +
5780 + return ret;
5781 +}
5782 +
5783 +static int
5784 +ar6000_ioctl_set_rssi_threshold(struct net_device *dev, struct ifreq *rq)
5785 +{
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; \
5794 +} while (0)
5795 +
5796 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5797 + WMI_RSSI_THRESHOLD_PARAMS_CMD cmd;
5798 + USER_RSSI_PARAMS rssiParams;
5799 + A_INT32 i, j;
5800 +
5801 + int ret = 0;
5802 +
5803 + if (ar->arWmiReady == FALSE) {
5804 + return -EIO;
5805 + }
5806 +
5807 + if (copy_from_user((char *)&rssiParams, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(USER_RSSI_PARAMS))) {
5808 + return -EFAULT;
5809 + }
5810 + cmd.weight = rssiParams.weight;
5811 + cmd.pollTime = rssiParams.pollTime;
5812 +
5813 + A_MEMCPY(rssi_map, &rssiParams.tholds, sizeof(rssi_map));
5814 + /*
5815 + * only 6 elements, so use bubble sorting, in ascending order
5816 + */
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) {
5822 + return EFAULT;
5823 + }
5824 + }
5825 + }
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) {
5831 + return EFAULT;
5832 + }
5833 + }
5834 + }
5835 +
5836 +#ifdef DEBUG
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);
5840 + }
5841 +#endif
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;
5854 +
5855 + if( wmi_set_rssi_threshold_params(ar->arWmi, &cmd) != A_OK ) {
5856 + ret = -EIO;
5857 + }
5858 +
5859 + return ret;
5860 +}
5861 +
5862 +static int
5863 +ar6000_ioctl_set_lq_threshold(struct net_device *dev, struct ifreq *rq)
5864 +{
5865 +
5866 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5867 + WMI_LQ_THRESHOLD_PARAMS_CMD cmd;
5868 + int ret = 0;
5869 +
5870 + if (ar->arWmiReady == FALSE) {
5871 + return -EIO;
5872 + }
5873 +
5874 + if (copy_from_user(&cmd, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(cmd))) {
5875 + return -EFAULT;
5876 + }
5877 +
5878 + if( wmi_set_lq_threshold_params(ar->arWmi, &cmd) != A_OK ) {
5879 + ret = -EIO;
5880 + }
5881 +
5882 + return ret;
5883 +}
5884 +
5885 +
5886 +static int
5887 +ar6000_ioctl_set_probedSsid(struct net_device *dev, struct ifreq *rq)
5888 +{
5889 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5890 + WMI_PROBED_SSID_CMD cmd;
5891 + int ret = 0;
5892 +
5893 + if (ar->arWmiReady == FALSE) {
5894 + return -EIO;
5895 + }
5896 +
5897 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5898 + return -EFAULT;
5899 + }
5900 +
5901 + if (wmi_probedSsid_cmd(ar->arWmi, cmd.entryIndex, cmd.flag, cmd.ssidLength,
5902 + cmd.ssid) != A_OK)
5903 + {
5904 + ret = -EIO;
5905 + }
5906 +
5907 + return ret;
5908 +}
5909 +
5910 +static int
5911 +ar6000_ioctl_set_badAp(struct net_device *dev, struct ifreq *rq)
5912 +{
5913 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5914 + WMI_ADD_BAD_AP_CMD cmd;
5915 + int ret = 0;
5916 +
5917 + if (ar->arWmiReady == FALSE) {
5918 + return -EIO;
5919 + }
5920 +
5921 +
5922 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5923 + return -EFAULT;
5924 + }
5925 +
5926 + if (cmd.badApIndex > WMI_MAX_BAD_AP_INDEX) {
5927 + return -EIO;
5928 + }
5929 +
5930 + if (A_MEMCMP(cmd.bssid, null_mac, AR6000_ETH_ADDR_LEN) == 0) {
5931 + /*
5932 + * This is a delete badAP.
5933 + */
5934 + if (wmi_deleteBadAp_cmd(ar->arWmi, cmd.badApIndex) != A_OK) {
5935 + ret = -EIO;
5936 + }
5937 + } else {
5938 + if (wmi_addBadAp_cmd(ar->arWmi, cmd.badApIndex, cmd.bssid) != A_OK) {
5939 + ret = -EIO;
5940 + }
5941 + }
5942 +
5943 + return ret;
5944 +}
5945 +
5946 +static int
5947 +ar6000_ioctl_create_qos(struct net_device *dev, struct ifreq *rq)
5948 +{
5949 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5950 + WMI_CREATE_PSTREAM_CMD cmd;
5951 + A_STATUS ret;
5952 +
5953 + if (ar->arWmiReady == FALSE) {
5954 + return -EIO;
5955 + }
5956 +
5957 +
5958 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5959 + return -EFAULT;
5960 + }
5961 +
5962 + ret = wmi_verify_tspec_params(&cmd, tspecCompliance);
5963 + if (ret == A_OK)
5964 + ret = wmi_create_pstream_cmd(ar->arWmi, &cmd);
5965 +
5966 + switch (ret) {
5967 + case A_OK:
5968 + return 0;
5969 + case A_EBUSY :
5970 + return -EBUSY;
5971 + case A_NO_MEMORY:
5972 + return -ENOMEM;
5973 + case A_EINVAL:
5974 + default:
5975 + return -EFAULT;
5976 + }
5977 +}
5978 +
5979 +static int
5980 +ar6000_ioctl_delete_qos(struct net_device *dev, struct ifreq *rq)
5981 +{
5982 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
5983 + WMI_DELETE_PSTREAM_CMD cmd;
5984 + int ret = 0;
5985 +
5986 + if (ar->arWmiReady == FALSE) {
5987 + return -EIO;
5988 + }
5989 +
5990 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
5991 + return -EFAULT;
5992 + }
5993 +
5994 + ret = wmi_delete_pstream_cmd(ar->arWmi, cmd.trafficClass, cmd.tsid);
5995 +
5996 + switch (ret) {
5997 + case A_OK:
5998 + return 0;
5999 + case A_EBUSY :
6000 + return -EBUSY;
6001 + case A_NO_MEMORY:
6002 + return -ENOMEM;
6003 + case A_EINVAL:
6004 + default:
6005 + return -EFAULT;
6006 + }
6007 +}
6008 +
6009 +static int
6010 +ar6000_ioctl_get_qos_queue(struct net_device *dev, struct ifreq *rq)
6011 +{
6012 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6013 + struct ar6000_queuereq qreq;
6014 + int ret = 0;
6015 +
6016 + if (ar->arWmiReady == FALSE) {
6017 + return -EIO;
6018 + }
6019 +
6020 + if( copy_from_user(&qreq, rq->ifr_data,
6021 + sizeof(struct ar6000_queuereq)))
6022 + return -EFAULT;
6023 +
6024 + qreq.activeTsids = wmi_get_mapped_qos_queue(ar->arWmi, qreq.trafficClass);
6025 +
6026 + if (copy_to_user(rq->ifr_data, &qreq,
6027 + sizeof(struct ar6000_queuereq)))
6028 + {
6029 + ret = -EFAULT;
6030 + }
6031 +
6032 + return ret;
6033 +}
6034 +
6035 +#ifdef CONFIG_HOST_TCMD_SUPPORT
6036 +static A_STATUS
6037 +ar6000_ioctl_tcmd_get_rx_report(struct net_device *dev,
6038 + struct ifreq *rq, A_UINT8 *data, A_UINT32 len)
6039 +{
6040 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6041 + A_UINT32 buf[2];
6042 + int ret = 0;
6043 +
6044 + if (ar->arWmiReady == FALSE) {
6045 + return -EIO;
6046 + }
6047 +
6048 + if (down_interruptible(&ar->arSem)) {
6049 + return -ERESTARTSYS;
6050 + }
6051 + ar->tcmdRxReport = 0;
6052 + if (wmi_test_cmd(ar->arWmi, data, len) != A_OK) {
6053 + up(&ar->arSem);
6054 + return -EIO;
6055 + }
6056 +
6057 + wait_event_interruptible_timeout(arEvent, ar->tcmdRxReport != 0, wmitimeout * HZ);
6058 +
6059 + if (signal_pending(current)) {
6060 + ret = -EINTR;
6061 + }
6062 +
6063 + buf[0] = ar->tcmdRxTotalPkt;
6064 + buf[1] = ar->tcmdRxRssi;
6065 + if (!ret && copy_to_user(rq->ifr_data, buf, sizeof(buf))) {
6066 + ret = -EFAULT;
6067 + }
6068 +
6069 + up(&ar->arSem);
6070 +
6071 + return ret;
6072 +}
6073 +
6074 +void
6075 +ar6000_tcmd_rx_report_event(void *devt, A_UINT8 * results, int len)
6076 +{
6077 + AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
6078 + TCMD_CONT_RX * rx_rep = (TCMD_CONT_RX *)results;
6079 +
6080 + ar->tcmdRxTotalPkt = rx_rep->u.report.totalPkt;
6081 + ar->tcmdRxRssi = rx_rep->u.report.rssiInDBm;
6082 + ar->tcmdRxReport = 1;
6083 +
6084 + wake_up(&arEvent);
6085 +}
6086 +#endif /* CONFIG_HOST_TCMD_SUPPORT*/
6087 +
6088 +static int
6089 +ar6000_ioctl_set_error_report_bitmask(struct net_device *dev, struct ifreq *rq)
6090 +{
6091 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6092 + WMI_TARGET_ERROR_REPORT_BITMASK cmd;
6093 + int ret = 0;
6094 +
6095 + if (ar->arWmiReady == FALSE) {
6096 + return -EIO;
6097 + }
6098 +
6099 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
6100 + return -EFAULT;
6101 + }
6102 +
6103 + ret = wmi_set_error_report_bitmask(ar->arWmi, cmd.bitmask);
6104 +
6105 + return (ret==0 ? ret : -EINVAL);
6106 +}
6107 +
6108 +static int
6109 +ar6000_clear_target_stats(struct net_device *dev)
6110 +{
6111 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6112 + TARGET_STATS *pStats = &ar->arTargetStats;
6113 + int ret = 0;
6114 +
6115 + if (ar->arWmiReady == FALSE) {
6116 + return -EIO;
6117 + }
6118 + AR6000_SPIN_LOCK(&ar->arLock, 0);
6119 + A_MEMZERO(pStats, sizeof(TARGET_STATS));
6120 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
6121 + return ret;
6122 +}
6123 +
6124 +static int
6125 +ar6000_ioctl_get_target_stats(struct net_device *dev, struct ifreq *rq)
6126 +{
6127 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6128 + TARGET_STATS_CMD cmd;
6129 + TARGET_STATS *pStats = &ar->arTargetStats;
6130 + int ret = 0;
6131 +
6132 + if (ar->arWmiReady == FALSE) {
6133 + return -EIO;
6134 + }
6135 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
6136 + return -EFAULT;
6137 + }
6138 + if (down_interruptible(&ar->arSem)) {
6139 + return -ERESTARTSYS;
6140 + }
6141 +
6142 + ar->statsUpdatePending = TRUE;
6143 +
6144 + if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
6145 + up(&ar->arSem);
6146 + return -EIO;
6147 + }
6148 +
6149 + wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
6150 +
6151 + if (signal_pending(current)) {
6152 + ret = -EINTR;
6153 + }
6154 +
6155 + if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
6156 + ret = -EFAULT;
6157 + }
6158 +
6159 + if (cmd.clearStats == 1) {
6160 + ret = ar6000_clear_target_stats(dev);
6161 + }
6162 +
6163 + up(&ar->arSem);
6164 +
6165 + return ret;
6166 +}
6167 +
6168 +static int
6169 +ar6000_ioctl_set_access_params(struct net_device *dev, struct ifreq *rq)
6170 +{
6171 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6172 + WMI_SET_ACCESS_PARAMS_CMD cmd;
6173 + int ret = 0;
6174 +
6175 + if (ar->arWmiReady == FALSE) {
6176 + return -EIO;
6177 + }
6178 +
6179 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
6180 + return -EFAULT;
6181 + }
6182 +
6183 + if (wmi_set_access_params_cmd(ar->arWmi, cmd.txop, cmd.eCWmin, cmd.eCWmax,
6184 + cmd.aifsn) == A_OK)
6185 + {
6186 + ret = 0;
6187 + } else {
6188 + ret = -EINVAL;
6189 + }
6190 +
6191 + return (ret);
6192 +}
6193 +
6194 +static int
6195 +ar6000_ioctl_set_disconnect_timeout(struct net_device *dev, struct ifreq *rq)
6196 +{
6197 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6198 + WMI_DISC_TIMEOUT_CMD cmd;
6199 + int ret = 0;
6200 +
6201 + if (ar->arWmiReady == FALSE) {
6202 + return -EIO;
6203 + }
6204 +
6205 + if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
6206 + return -EFAULT;
6207 + }
6208 +
6209 + if (wmi_disctimeout_cmd(ar->arWmi, cmd.disconnectTimeout) == A_OK)
6210 + {
6211 + ret = 0;
6212 + } else {
6213 + ret = -EINVAL;
6214 + }
6215 +
6216 + return (ret);
6217 +}
6218 +
6219 +static int
6220 +ar6000_xioctl_set_voice_pkt_size(struct net_device *dev, char * userdata)
6221 +{
6222 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6223 + WMI_SET_VOICE_PKT_SIZE_CMD cmd;
6224 + int ret = 0;
6225 +
6226 + if (ar->arWmiReady == FALSE) {
6227 + return -EIO;
6228 + }
6229 +
6230 + if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
6231 + return -EFAULT;
6232 + }
6233 +
6234 + if (wmi_set_voice_pkt_size_cmd(ar->arWmi, cmd.voicePktSize) == A_OK)
6235 + {
6236 + ret = 0;
6237 + } else {
6238 + ret = -EINVAL;
6239 + }
6240 +
6241 +
6242 + return (ret);
6243 +}
6244 +
6245 +static int
6246 +ar6000_xioctl_set_max_sp_len(struct net_device *dev, char * userdata)
6247 +{
6248 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6249 + WMI_SET_MAX_SP_LEN_CMD cmd;
6250 + int ret = 0;
6251 +
6252 + if (ar->arWmiReady == FALSE) {
6253 + return -EIO;
6254 + }
6255 +
6256 + if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
6257 + return -EFAULT;
6258 + }
6259 +
6260 + if (wmi_set_max_sp_len_cmd(ar->arWmi, cmd.maxSPLen) == A_OK)
6261 + {
6262 + ret = 0;
6263 + } else {
6264 + ret = -EINVAL;
6265 + }
6266 +
6267 + return (ret);
6268 +}
6269 +
6270 +
6271 +static int
6272 +ar6000_xioctl_set_bt_status_cmd(struct net_device *dev, char * userdata)
6273 +{
6274 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6275 + WMI_SET_BT_STATUS_CMD cmd;
6276 + int ret = 0;
6277 +
6278 + if (ar->arWmiReady == FALSE) {
6279 + return -EIO;
6280 + }
6281 +
6282 + if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
6283 + return -EFAULT;
6284 + }
6285 +
6286 + if (wmi_set_bt_status_cmd(ar->arWmi, cmd.streamType, cmd.status) == A_OK)
6287 + {
6288 + ret = 0;
6289 + } else {
6290 + ret = -EINVAL;
6291 + }
6292 +
6293 + return (ret);
6294 +}
6295 +
6296 +static int
6297 +ar6000_xioctl_set_bt_params_cmd(struct net_device *dev, char * userdata)
6298 +{
6299 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6300 + WMI_SET_BT_PARAMS_CMD cmd;
6301 + int ret = 0;
6302 +
6303 + if (ar->arWmiReady == FALSE) {
6304 + return -EIO;
6305 + }
6306 +
6307 + if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
6308 + return -EFAULT;
6309 + }
6310 +
6311 + if (wmi_set_bt_params_cmd(ar->arWmi, &cmd) == A_OK)
6312 + {
6313 + ret = 0;
6314 + } else {
6315 + ret = -EINVAL;
6316 + }
6317 +
6318 + return (ret);
6319 +}
6320 +
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 */
6328 +
6329 +/* Host-side initialization for General Purpose I/O support */
6330 +void ar6000_gpio_init(void)
6331 +{
6332 + gpio_intr_available = FALSE;
6333 + gpio_data_available = FALSE;
6334 + gpio_ack_received = FALSE;
6335 +}
6336 +
6337 +/*
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.
6341 + */
6342 +void
6343 +ar6000_gpio_intr_rx(A_UINT32 intr_mask, A_UINT32 input_values)
6344 +{
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);
6349 +}
6350 +
6351 +/*
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
6354 + * call.
6355 + */
6356 +void
6357 +ar6000_gpio_data_rx(A_UINT32 reg_id, A_UINT32 value)
6358 +{
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);
6363 +}
6364 +
6365 +/*
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
6368 + * call.
6369 + */
6370 +void
6371 +ar6000_gpio_ack_rx(void)
6372 +{
6373 + gpio_ack_received = TRUE;
6374 + wake_up(&arEvent);
6375 +}
6376 +
6377 +A_STATUS
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)
6383 +{
6384 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6385 +
6386 + gpio_ack_received = FALSE;
6387 + return wmi_gpio_output_set(ar->arWmi,
6388 + set_mask, clear_mask, enable_mask, disable_mask);
6389 +}
6390 +
6391 +static A_STATUS
6392 +ar6000_gpio_input_get(struct net_device *dev)
6393 +{
6394 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6395 +
6396 + *((volatile A_BOOL *)&gpio_data_available) = FALSE;
6397 + return wmi_gpio_input_get(ar->arWmi);
6398 +}
6399 +
6400 +static A_STATUS
6401 +ar6000_gpio_register_set(struct net_device *dev,
6402 + A_UINT32 gpioreg_id,
6403 + A_UINT32 value)
6404 +{
6405 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6406 +
6407 + gpio_ack_received = FALSE;
6408 + return wmi_gpio_register_set(ar->arWmi, gpioreg_id, value);
6409 +}
6410 +
6411 +static A_STATUS
6412 +ar6000_gpio_register_get(struct net_device *dev,
6413 + A_UINT32 gpioreg_id)
6414 +{
6415 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6416 +
6417 + *((volatile A_BOOL *)&gpio_data_available) = FALSE;
6418 + return wmi_gpio_register_get(ar->arWmi, gpioreg_id);
6419 +}
6420 +
6421 +static A_STATUS
6422 +ar6000_gpio_intr_ack(struct net_device *dev,
6423 + A_UINT32 ack_mask)
6424 +{
6425 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
6426 +
6427 + gpio_intr_available = FALSE;
6428 + return wmi_gpio_intr_ack(ar->arWmi, ack_mask);
6429 +}
6430 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
6431 +
6432 +int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
6433 +{
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;
6440 + char *userdata;
6441 + A_UINT32 connectCtrlFlags;
6442 +
6443 +
6444 + static WMI_SCAN_PARAMS_CMD scParams = {0, 0, 0, 0, 0,
6445 + WMI_SHORTSCANRATIO_DEFAULT,
6446 + DEFAULT_SCAN_CTRL_FLAGS,
6447 + 0};
6448 + WMI_SET_AKMP_PARAMS_CMD akmpParams;
6449 + WMI_SET_PMKID_LIST_CMD pmkidInfo;
6450 +
6451 + if (cmd == AR6000_IOCTL_EXTENDED)
6452 + {
6453 + /*
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.
6458 + */
6459 + get_user(cmd, (int *)rq->ifr_data);
6460 + userdata = (char *)(((unsigned int *)rq->ifr_data)+1);
6461 + }
6462 + else
6463 + {
6464 + userdata = (char *)rq->ifr_data;
6465 + }
6466 +
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)))
6471 + {
6472 + return -EIO;
6473 + }
6474 +
6475 + ret = 0;
6476 + switch(cmd)
6477 + {
6478 +#ifdef CONFIG_HOST_TCMD_SUPPORT
6479 + case AR6000_XIOCTL_TCMD_CONT_TX:
6480 + {
6481 + TCMD_CONT_TX txCmd;
6482 +
6483 + if (ar->tcmdPm == TCMD_PM_SLEEP) {
6484 + A_PRINTF("Can NOT send tx tcmd when target is asleep! \n");
6485 + return -EFAULT;
6486 + }
6487 +
6488 + if(copy_from_user(&txCmd, userdata, sizeof(TCMD_CONT_TX)))
6489 + return -EFAULT;
6490 + wmi_test_cmd(ar->arWmi,(A_UINT8 *)&txCmd, sizeof(TCMD_CONT_TX));
6491 + }
6492 + break;
6493 + case AR6000_XIOCTL_TCMD_CONT_RX:
6494 + {
6495 + TCMD_CONT_RX rxCmd;
6496 +
6497 + if (ar->tcmdPm == TCMD_PM_SLEEP) {
6498 + A_PRINTF("Can NOT send rx tcmd when target is asleep! \n");
6499 + return -EFAULT;
6500 + }
6501 + if(copy_from_user(&rxCmd, userdata, sizeof(TCMD_CONT_RX)))
6502 + return -EFAULT;
6503 + switch(rxCmd.act)
6504 + {
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));
6510 + break;
6511 + case TCMD_CONT_RX_REPORT:
6512 + ar6000_ioctl_tcmd_get_rx_report(dev, rq,
6513 + (A_UINT8 *)&rxCmd, sizeof(TCMD_CONT_RX));
6514 + break;
6515 + default:
6516 + A_PRINTF("Unknown Cont Rx mode: %d\n",rxCmd.act);
6517 + return -EINVAL;
6518 + }
6519 + }
6520 + break;
6521 + case AR6000_XIOCTL_TCMD_PM:
6522 + {
6523 + TCMD_PM pmCmd;
6524 +
6525 + if(copy_from_user(&pmCmd, userdata, sizeof(TCMD_PM)))
6526 + return -EFAULT;
6527 + ar->tcmdPm = pmCmd.mode;
6528 + wmi_test_cmd(ar->arWmi, (A_UINT8*)&pmCmd, sizeof(TCMD_PM));
6529 + }
6530 + break;
6531 +#endif /* CONFIG_HOST_TCMD_SUPPORT */
6532 +
6533 + case AR6000_XIOCTL_BMI_DONE:
6534 + if(bmienable)
6535 + {
6536 + ret = ar6000_init(dev);
6537 + }
6538 + else
6539 + {
6540 + ret = BMIDone(hifDevice);
6541 + }
6542 + break;
6543 +
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",
6548 + address, length);
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)) {
6553 + ret = -EFAULT;
6554 + }
6555 + A_FREE(buffer);
6556 + } else {
6557 + ret = -ENOMEM;
6558 + }
6559 + break;
6560 +
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",
6565 + address, length);
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))
6570 + {
6571 + ret = -EFAULT;
6572 + } else {
6573 + ret = BMIWriteMemory(hifDevice, address, buffer, length);
6574 + }
6575 + A_FREE(buffer);
6576 + } else {
6577 + ret = -ENOMEM;
6578 + }
6579 + break;
6580 +
6581 + case AR6000_XIOCTL_BMI_TEST:
6582 + AR_DEBUG_PRINTF("No longer supported\n");
6583 + ret = -EOPNOTSUPP;
6584 + break;
6585 +
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",
6590 + address, param);
6591 + ret = BMIExecute(hifDevice, address, &param);
6592 + put_user(param, (unsigned int *)rq->ifr_data); /* return value */
6593 + break;
6594 +
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);
6599 + break;
6600 +
6601 + case AR6000_XIOCTL_BMI_READ_SOC_REGISTER:
6602 + get_user(address, (unsigned int *)userdata);
6603 + ret = BMIReadSOCRegister(hifDevice, address, &param);
6604 + put_user(param, (unsigned int *)rq->ifr_data); /* return value */
6605 + break;
6606 +
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);
6611 + break;
6612 +
6613 +#ifdef HTC_RAW_INTERFACE
6614 + case AR6000_XIOCTL_HTC_RAW_OPEN:
6615 + ret = A_OK;
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)) {
6621 + break;
6622 + }
6623 + /* Terminate the BMI phase */
6624 + ret = BMIDone(hifDevice);
6625 + if (ret == A_OK) {
6626 + ret = ar6000_htc_raw_open(ar);
6627 + }
6628 + }
6629 + break;
6630 +
6631 + case AR6000_XIOCTL_HTC_RAW_CLOSE:
6632 + if (arRawIfEnabled(ar)) {
6633 + ret = ar6000_htc_raw_close(ar);
6634 + arRawIfEnabled(ar) = FALSE;
6635 + } else {
6636 + ret = A_ERROR;
6637 + }
6638 + break;
6639 +
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,
6647 + buffer, length);
6648 + put_user(ret, (unsigned int *)rq->ifr_data);
6649 + } else {
6650 + ret = A_ERROR;
6651 + }
6652 + break;
6653 +
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,
6661 + buffer, length);
6662 + put_user(ret, (unsigned int *)rq->ifr_data);
6663 + } else {
6664 + ret = A_ERROR;
6665 + }
6666 + break;
6667 +#endif /* HTC_RAW_INTERFACE */
6668 +
6669 + case AR6000_IOCTL_WMI_GETREV:
6670 + {
6671 + if (copy_to_user(rq->ifr_data, &ar->arVersion,
6672 + sizeof(ar->arVersion)))
6673 + {
6674 + ret = -EFAULT;
6675 + }
6676 + break;
6677 + }
6678 + case AR6000_IOCTL_WMI_SETPWR:
6679 + {
6680 + WMI_POWER_MODE_CMD pwrModeCmd;
6681 +
6682 + if (ar->arWmiReady == FALSE) {
6683 + ret = -EIO;
6684 + } else if (copy_from_user(&pwrModeCmd, userdata,
6685 + sizeof(pwrModeCmd)))
6686 + {
6687 + ret = -EFAULT;
6688 + } else {
6689 + if (wmi_powermode_cmd(ar->arWmi, pwrModeCmd.powerMode)
6690 + != A_OK)
6691 + {
6692 + ret = -EIO;
6693 + }
6694 + }
6695 + break;
6696 + }
6697 + case AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS:
6698 + {
6699 + WMI_IBSS_PM_CAPS_CMD ibssPmCaps;
6700 +
6701 + if (ar->arWmiReady == FALSE) {
6702 + ret = -EIO;
6703 + } else if (copy_from_user(&ibssPmCaps, userdata,
6704 + sizeof(ibssPmCaps)))
6705 + {
6706 + ret = -EFAULT;
6707 + } else {
6708 + if (wmi_ibsspmcaps_cmd(ar->arWmi, ibssPmCaps.power_saving, ibssPmCaps.ttl,
6709 + ibssPmCaps.atim_windows, ibssPmCaps.timeout_value) != A_OK)
6710 + {
6711 + ret = -EIO;
6712 + }
6713 + AR6000_SPIN_LOCK(&ar->arLock, 0);
6714 + ar->arIbssPsEnable = ibssPmCaps.power_saving;
6715 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
6716 + }
6717 + break;
6718 + }
6719 + case AR6000_IOCTL_WMI_SET_PMPARAMS:
6720 + {
6721 + WMI_POWER_PARAMS_CMD pmParams;
6722 +
6723 + if (ar->arWmiReady == FALSE) {
6724 + ret = -EIO;
6725 + } else if (copy_from_user(&pmParams, userdata,
6726 + sizeof(pmParams)))
6727 + {
6728 + ret = -EFAULT;
6729 + } else {
6730 + if (wmi_pmparams_cmd(ar->arWmi, pmParams.idle_period,
6731 + pmParams.pspoll_number,
6732 + pmParams.dtim_policy) != A_OK)
6733 + {
6734 + ret = -EIO;
6735 + }
6736 + }
6737 + break;
6738 + }
6739 + case AR6000_IOCTL_WMI_SETSCAN:
6740 + {
6741 + if (ar->arWmiReady == FALSE) {
6742 + ret = -EIO;
6743 + } else if (copy_from_user(&scParams, userdata,
6744 + sizeof(scParams)))
6745 + {
6746 + ret = -EFAULT;
6747 + } else {
6748 + if (CAN_SCAN_IN_CONNECT(scParams.scanCtrlFlags)) {
6749 + ar->arSkipScan = FALSE;
6750 + } else {
6751 + ar->arSkipScan = TRUE;
6752 + }
6753 +
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)
6763 + {
6764 + ret = -EIO;
6765 + }
6766 + }
6767 + break;
6768 + }
6769 + case AR6000_IOCTL_WMI_SETLISTENINT:
6770 + {
6771 + WMI_LISTEN_INT_CMD listenCmd;
6772 +
6773 + if (ar->arWmiReady == FALSE) {
6774 + ret = -EIO;
6775 + } else if (copy_from_user(&listenCmd, userdata,
6776 + sizeof(listenCmd)))
6777 + {
6778 + ret = -EFAULT;
6779 + } else {
6780 + if (wmi_listeninterval_cmd(ar->arWmi, listenCmd.listenInterval, listenCmd.numBeacons) != A_OK) {
6781 + ret = -EIO;
6782 + } else {
6783 + AR6000_SPIN_LOCK(&ar->arLock, 0);
6784 + ar->arListenInterval = param;
6785 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
6786 + }
6787 +
6788 + }
6789 + break;
6790 + }
6791 + case AR6000_IOCTL_WMI_SET_BMISS_TIME:
6792 + {
6793 + WMI_BMISS_TIME_CMD bmissCmd;
6794 +
6795 + if (ar->arWmiReady == FALSE) {
6796 + ret = -EIO;
6797 + } else if (copy_from_user(&bmissCmd, userdata,
6798 + sizeof(bmissCmd)))
6799 + {
6800 + ret = -EFAULT;
6801 + } else {
6802 + if (wmi_bmisstime_cmd(ar->arWmi, bmissCmd.bmissTime, bmissCmd.numBeacons) != A_OK) {
6803 + ret = -EIO;
6804 + }
6805 + }
6806 + break;
6807 + }
6808 + case AR6000_IOCTL_WMI_SETBSSFILTER:
6809 + {
6810 + if (ar->arWmiReady == FALSE) {
6811 + ret = -EIO;
6812 + } else {
6813 +
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) {
6818 + ret = -EIO;
6819 + }
6820 + }
6821 + break;
6822 + }
6823 + case AR6000_IOCTL_WMI_SET_SNRTHRESHOLD:
6824 + {
6825 + ret = ar6000_ioctl_set_snr_threshold(dev, rq);
6826 + break;
6827 + }
6828 + case AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD:
6829 + {
6830 + ret = ar6000_ioctl_set_rssi_threshold(dev, rq);
6831 + break;
6832 + }
6833 + case AR6000_XIOCTL_WMI_CLR_RSSISNR:
6834 + {
6835 + if (ar->arWmiReady == FALSE) {
6836 + ret = -EIO;
6837 + }
6838 + ret = wmi_clr_rssi_snr(ar->arWmi);
6839 + break;
6840 + }
6841 + case AR6000_XIOCTL_WMI_SET_LQTHRESHOLD:
6842 + {
6843 + ret = ar6000_ioctl_set_lq_threshold(dev, rq);
6844 + break;
6845 + }
6846 + case AR6000_XIOCTL_WMI_SET_LPREAMBLE:
6847 + {
6848 + WMI_SET_LPREAMBLE_CMD setLpreambleCmd;
6849 +
6850 + if (ar->arWmiReady == FALSE) {
6851 + ret = -EIO;
6852 + } else if (copy_from_user(&setLpreambleCmd, userdata,
6853 + sizeof(setLpreambleCmd)))
6854 + {
6855 + ret = -EFAULT;
6856 + } else {
6857 + if (wmi_set_lpreamble_cmd(ar->arWmi, setLpreambleCmd.status)
6858 + != A_OK)
6859 + {
6860 + ret = -EIO;
6861 + }
6862 + }
6863 +
6864 + break;
6865 + }
6866 + case AR6000_XIOCTL_WMI_SET_RTS:
6867 + {
6868 + WMI_SET_RTS_CMD rtsCmd;
6869 +
6870 + if (ar->arWmiReady == FALSE) {
6871 + ret = -EIO;
6872 + } else if (copy_from_user(&rtsCmd, userdata,
6873 + sizeof(rtsCmd)))
6874 + {
6875 + ret = -EFAULT;
6876 + } else {
6877 + if (wmi_set_rts_cmd(ar->arWmi, rtsCmd.threshold)
6878 + != A_OK)
6879 + {
6880 + ret = -EIO;
6881 + }
6882 + }
6883 +
6884 + break;
6885 + }
6886 + case AR6000_XIOCTL_WMI_SET_WMM:
6887 + {
6888 + ret = ar6000_ioctl_set_wmm(dev, rq);
6889 + break;
6890 + }
6891 + case AR6000_XIOCTL_WMI_SET_TXOP:
6892 + {
6893 + ret = ar6000_ioctl_set_txop(dev, rq);
6894 + break;
6895 + }
6896 + case AR6000_XIOCTL_WMI_GET_RD:
6897 + {
6898 + ret = ar6000_ioctl_get_rd(dev, rq);
6899 + break;
6900 + }
6901 + case AR6000_IOCTL_WMI_SET_CHANNELPARAMS:
6902 + {
6903 + ret = ar6000_ioctl_set_channelParams(dev, rq);
6904 + break;
6905 + }
6906 + case AR6000_IOCTL_WMI_SET_PROBEDSSID:
6907 + {
6908 + ret = ar6000_ioctl_set_probedSsid(dev, rq);
6909 + break;
6910 + }
6911 + case AR6000_IOCTL_WMI_SET_BADAP:
6912 + {
6913 + ret = ar6000_ioctl_set_badAp(dev, rq);
6914 + break;
6915 + }
6916 + case AR6000_IOCTL_WMI_CREATE_QOS:
6917 + {
6918 + ret = ar6000_ioctl_create_qos(dev, rq);
6919 + break;
6920 + }
6921 + case AR6000_IOCTL_WMI_DELETE_QOS:
6922 + {
6923 + ret = ar6000_ioctl_delete_qos(dev, rq);
6924 + break;
6925 + }
6926 + case AR6000_IOCTL_WMI_GET_QOS_QUEUE:
6927 + {
6928 + ret = ar6000_ioctl_get_qos_queue(dev, rq);
6929 + break;
6930 + }
6931 + case AR6000_IOCTL_WMI_GET_TARGET_STATS:
6932 + {
6933 + ret = ar6000_ioctl_get_target_stats(dev, rq);
6934 + break;
6935 + }
6936 + case AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK:
6937 + {
6938 + ret = ar6000_ioctl_set_error_report_bitmask(dev, rq);
6939 + break;
6940 + }
6941 + case AR6000_IOCTL_WMI_SET_ASSOC_INFO:
6942 + {
6943 + WMI_SET_ASSOC_INFO_CMD cmd;
6944 + A_UINT8 assocInfo[WMI_MAX_ASSOC_INFO_LEN];
6945 +
6946 + if (ar->arWmiReady == FALSE) {
6947 + ret = -EIO;
6948 + } else {
6949 + get_user(cmd.ieType, userdata);
6950 + if (cmd.ieType >= WMI_MAX_ASSOC_INFO_TYPE) {
6951 + ret = -EIO;
6952 + } else {
6953 + get_user(cmd.bufferSize, userdata + 1);
6954 + if (cmd.bufferSize > WMI_MAX_ASSOC_INFO_LEN) {
6955 + ret = -EFAULT;
6956 + break;
6957 + }
6958 + if (copy_from_user(assocInfo, userdata + 2,
6959 + cmd.bufferSize))
6960 + {
6961 + ret = -EFAULT;
6962 + } else {
6963 + if (wmi_associnfo_cmd(ar->arWmi, cmd.ieType,
6964 + cmd.bufferSize,
6965 + assocInfo) != A_OK)
6966 + {
6967 + ret = -EIO;
6968 + }
6969 + }
6970 + }
6971 + }
6972 + break;
6973 + }
6974 + case AR6000_IOCTL_WMI_SET_ACCESS_PARAMS:
6975 + {
6976 + ret = ar6000_ioctl_set_access_params(dev, rq);
6977 + break;
6978 + }
6979 + case AR6000_IOCTL_WMI_SET_DISC_TIMEOUT:
6980 + {
6981 + ret = ar6000_ioctl_set_disconnect_timeout(dev, rq);
6982 + break;
6983 + }
6984 + case AR6000_XIOCTL_FORCE_TARGET_RESET:
6985 + {
6986 + if (ar->arHtcTarget)
6987 + {
6988 +// HTCForceReset(htcTarget);
6989 + }
6990 + else
6991 + {
6992 + AR_DEBUG_PRINTF("ar6000_ioctl cannot attempt reset.\n");
6993 + }
6994 + break;
6995 + }
6996 + case AR6000_XIOCTL_TARGET_INFO:
6997 + case AR6000_XIOCTL_CHECK_TARGET_READY: /* backwards compatibility */
6998 + {
6999 + /* If we made it to here, then the Target exists and is ready. */
7000 +
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)))
7004 + {
7005 + ret = -EFAULT;
7006 + }
7007 + if (copy_to_user(((A_UINT32 *)rq->ifr_data)+1, &ar->arTargetType,
7008 + sizeof(ar->arTargetType)))
7009 + {
7010 + ret = -EFAULT;
7011 + }
7012 + }
7013 + break;
7014 + }
7015 + case AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS:
7016 + {
7017 + WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD hbparam;
7018 +
7019 + if (copy_from_user(&hbparam, userdata, sizeof(hbparam)))
7020 + {
7021 + ret = -EFAULT;
7022 + } else {
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;
7027 + }
7028 + if (hbparam.threshold) {
7029 + ar->arHBChallengeResp.missThres = hbparam.threshold;
7030 + }
7031 +
7032 + /* Delete the pending timer and start a new one */
7033 + if (timer_pending(&ar->arHBChallengeResp.timer)) {
7034 + A_UNTIMEOUT(&ar->arHBChallengeResp.timer);
7035 + }
7036 + A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
7037 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7038 + }
7039 + break;
7040 + }
7041 + case AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP:
7042 + {
7043 + A_UINT32 cookie;
7044 +
7045 + if (copy_from_user(&cookie, userdata, sizeof(cookie))) {
7046 + return -EFAULT;
7047 + }
7048 +
7049 + /* Send the challenge on the control channel */
7050 + if (wmi_get_challenge_resp_cmd(ar->arWmi, cookie, APP_HB_CHALLENGE) != A_OK) {
7051 + return -EIO;
7052 + }
7053 + break;
7054 + }
7055 +#ifdef USER_KEYS
7056 + case AR6000_XIOCTL_USER_SETKEYS:
7057 + {
7058 +
7059 + ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_RUN;
7060 +
7061 + if (copy_from_user(&ar->user_key_ctrl, userdata,
7062 + sizeof(ar->user_key_ctrl)))
7063 + {
7064 + return -EFAULT;
7065 + }
7066 +
7067 + A_PRINTF("ar6000 USER set key %x\n", ar->user_key_ctrl);
7068 + break;
7069 + }
7070 +#endif /* USER_KEYS */
7071 +
7072 +#ifdef CONFIG_HOST_GPIO_SUPPORT
7073 + case AR6000_XIOCTL_GPIO_OUTPUT_SET:
7074 + {
7075 + struct ar6000_gpio_output_set_cmd_s gpio_output_set_cmd;
7076 +
7077 + if (ar->arWmiReady == FALSE) {
7078 + return -EIO;
7079 + }
7080 + if (down_interruptible(&ar->arSem)) {
7081 + return -ERESTARTSYS;
7082 + }
7083 +
7084 + if (copy_from_user(&gpio_output_set_cmd, userdata,
7085 + sizeof(gpio_output_set_cmd)))
7086 + {
7087 + ret = -EFAULT;
7088 + } else {
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) {
7095 + ret = EIO;
7096 + }
7097 + }
7098 + up(&ar->arSem);
7099 + break;
7100 + }
7101 + case AR6000_XIOCTL_GPIO_INPUT_GET:
7102 + {
7103 + if (ar->arWmiReady == FALSE) {
7104 + return -EIO;
7105 + }
7106 + if (down_interruptible(&ar->arSem)) {
7107 + return -ERESTARTSYS;
7108 + }
7109 +
7110 + ret = ar6000_gpio_input_get(dev);
7111 + if (ret != A_OK) {
7112 + up(&ar->arSem);
7113 + return -EIO;
7114 + }
7115 +
7116 + /* Wait for Target to respond. */
7117 + wait_event_interruptible(arEvent, gpio_data_available);
7118 + if (signal_pending(current)) {
7119 + ret = -EINTR;
7120 + } else {
7121 + A_ASSERT(gpio_reg_results.gpioreg_id == GPIO_ID_NONE);
7122 +
7123 + if (copy_to_user(userdata, &gpio_reg_results.value,
7124 + sizeof(gpio_reg_results.value)))
7125 + {
7126 + ret = -EFAULT;
7127 + }
7128 + }
7129 + up(&ar->arSem);
7130 + break;
7131 + }
7132 + case AR6000_XIOCTL_GPIO_REGISTER_SET:
7133 + {
7134 + struct ar6000_gpio_register_cmd_s gpio_register_cmd;
7135 +
7136 + if (ar->arWmiReady == FALSE) {
7137 + return -EIO;
7138 + }
7139 + if (down_interruptible(&ar->arSem)) {
7140 + return -ERESTARTSYS;
7141 + }
7142 +
7143 + if (copy_from_user(&gpio_register_cmd, userdata,
7144 + sizeof(gpio_register_cmd)))
7145 + {
7146 + ret = -EFAULT;
7147 + } else {
7148 + ret = ar6000_gpio_register_set(dev,
7149 + gpio_register_cmd.gpioreg_id,
7150 + gpio_register_cmd.value);
7151 + if (ret != A_OK) {
7152 + ret = EIO;
7153 + }
7154 +
7155 + /* Wait for acknowledgement from Target */
7156 + wait_event_interruptible(arEvent, gpio_ack_received);
7157 + if (signal_pending(current)) {
7158 + ret = -EINTR;
7159 + }
7160 + }
7161 + up(&ar->arSem);
7162 + break;
7163 + }
7164 + case AR6000_XIOCTL_GPIO_REGISTER_GET:
7165 + {
7166 + struct ar6000_gpio_register_cmd_s gpio_register_cmd;
7167 +
7168 + if (ar->arWmiReady == FALSE) {
7169 + return -EIO;
7170 + }
7171 + if (down_interruptible(&ar->arSem)) {
7172 + return -ERESTARTSYS;
7173 + }
7174 +
7175 + if (copy_from_user(&gpio_register_cmd, userdata,
7176 + sizeof(gpio_register_cmd)))
7177 + {
7178 + ret = -EFAULT;
7179 + } else {
7180 + ret = ar6000_gpio_register_get(dev, gpio_register_cmd.gpioreg_id);
7181 + if (ret != A_OK) {
7182 + up(&ar->arSem);
7183 + return -EIO;
7184 + }
7185 +
7186 + /* Wait for Target to respond. */
7187 + wait_event_interruptible(arEvent, gpio_data_available);
7188 + if (signal_pending(current)) {
7189 + ret = -EINTR;
7190 + } else {
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)))
7194 + {
7195 + ret = -EFAULT;
7196 + }
7197 + }
7198 + }
7199 + up(&ar->arSem);
7200 + break;
7201 + }
7202 + case AR6000_XIOCTL_GPIO_INTR_ACK:
7203 + {
7204 + struct ar6000_gpio_intr_ack_cmd_s gpio_intr_ack_cmd;
7205 +
7206 + if (ar->arWmiReady == FALSE) {
7207 + return -EIO;
7208 + }
7209 + if (down_interruptible(&ar->arSem)) {
7210 + return -ERESTARTSYS;
7211 + }
7212 +
7213 + if (copy_from_user(&gpio_intr_ack_cmd, userdata,
7214 + sizeof(gpio_intr_ack_cmd)))
7215 + {
7216 + ret = -EFAULT;
7217 + } else {
7218 + ret = ar6000_gpio_intr_ack(dev, gpio_intr_ack_cmd.ack_mask);
7219 + if (ret != A_OK) {
7220 + ret = EIO;
7221 + }
7222 + }
7223 + up(&ar->arSem);
7224 + break;
7225 + }
7226 + case AR6000_XIOCTL_GPIO_INTR_WAIT:
7227 + {
7228 + /* Wait for Target to report an interrupt. */
7229 + dev_hold(dev);
7230 + rtnl_unlock();
7231 + wait_event_interruptible(arEvent, gpio_intr_available);
7232 + rtnl_lock();
7233 + __dev_put(dev);
7234 +
7235 + if (signal_pending(current)) {
7236 + ret = -EINTR;
7237 + } else {
7238 + if (copy_to_user(userdata, &gpio_intr_results,
7239 + sizeof(gpio_intr_results)))
7240 + {
7241 + ret = -EFAULT;
7242 + }
7243 + }
7244 + break;
7245 + }
7246 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
7247 +
7248 + case AR6000_XIOCTL_DBGLOG_CFG_MODULE:
7249 + {
7250 + struct ar6000_dbglog_module_config_s config;
7251 +
7252 + if (copy_from_user(&config, userdata, sizeof(config))) {
7253 + return -EFAULT;
7254 + }
7255 +
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)
7260 + {
7261 + return -EIO;
7262 + }
7263 + break;
7264 + }
7265 +
7266 + case AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS:
7267 + {
7268 + /* Send the challenge on the control channel */
7269 + if (ar6000_dbglog_get_debug_logs(ar) != A_OK)
7270 + {
7271 + return -EIO;
7272 + }
7273 + break;
7274 + }
7275 +
7276 + case AR6000_XIOCTL_SET_ADHOC_BSSID:
7277 + {
7278 + WMI_SET_ADHOC_BSSID_CMD adhocBssid;
7279 +
7280 + if (ar->arWmiReady == FALSE) {
7281 + ret = -EIO;
7282 + } else if (copy_from_user(&adhocBssid, userdata,
7283 + sizeof(adhocBssid)))
7284 + {
7285 + ret = -EFAULT;
7286 + } else if (A_MEMCMP(adhocBssid.bssid, bcast_mac,
7287 + AR6000_ETH_ADDR_LEN) == 0)
7288 + {
7289 + ret = -EFAULT;
7290 + } else {
7291 +
7292 + A_MEMCPY(ar->arReqBssid, adhocBssid.bssid, sizeof(ar->arReqBssid));
7293 + }
7294 + break;
7295 + }
7296 +
7297 + case AR6000_XIOCTL_SET_OPT_MODE:
7298 + {
7299 + WMI_SET_OPT_MODE_CMD optModeCmd;
7300 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
7301 +
7302 + if (ar->arWmiReady == FALSE) {
7303 + ret = -EIO;
7304 + } else if (copy_from_user(&optModeCmd, userdata,
7305 + sizeof(optModeCmd)))
7306 + {
7307 + ret = -EFAULT;
7308 + } else if (ar->arConnected && optModeCmd.optMode == SPECIAL_ON) {
7309 + ret = -EFAULT;
7310 +
7311 + } else if (wmi_set_opt_mode_cmd(ar->arWmi, optModeCmd.optMode)
7312 + != A_OK)
7313 + {
7314 + ret = -EIO;
7315 + }
7316 + break;
7317 + }
7318 +
7319 + case AR6000_XIOCTL_OPT_SEND_FRAME:
7320 + {
7321 + WMI_OPT_TX_FRAME_CMD optTxFrmCmd;
7322 + A_UINT8 data[MAX_OPT_DATA_LEN];
7323 +
7324 + if (ar->arWmiReady == FALSE) {
7325 + ret = -EIO;
7326 + } else if (copy_from_user(&optTxFrmCmd, userdata,
7327 + sizeof(optTxFrmCmd)))
7328 + {
7329 + ret = -EFAULT;
7330 + } else if (copy_from_user(data,
7331 + userdata+sizeof(WMI_OPT_TX_FRAME_CMD)-1,
7332 + optTxFrmCmd.optIEDataLen))
7333 + {
7334 + ret = -EFAULT;
7335 + } else {
7336 + ret = wmi_opt_tx_frame_cmd(ar->arWmi,
7337 + optTxFrmCmd.frmType,
7338 + optTxFrmCmd.dstAddr,
7339 + optTxFrmCmd.bssid,
7340 + optTxFrmCmd.optIEDataLen,
7341 + data);
7342 + }
7343 +
7344 + break;
7345 + }
7346 + case AR6000_XIOCTL_WMI_SETRETRYLIMITS:
7347 + {
7348 + WMI_SET_RETRY_LIMITS_CMD setRetryParams;
7349 +
7350 + if (ar->arWmiReady == FALSE) {
7351 + ret = -EIO;
7352 + } else if (copy_from_user(&setRetryParams, userdata,
7353 + sizeof(setRetryParams)))
7354 + {
7355 + ret = -EFAULT;
7356 + } else {
7357 + if (wmi_set_retry_limits_cmd(ar->arWmi, setRetryParams.frameType,
7358 + setRetryParams.trafficClass,
7359 + setRetryParams.maxRetries,
7360 + setRetryParams.enableNotify) != A_OK)
7361 + {
7362 + ret = -EIO;
7363 + }
7364 + AR6000_SPIN_LOCK(&ar->arLock, 0);
7365 + ar->arMaxRetries = setRetryParams.maxRetries;
7366 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7367 + }
7368 + break;
7369 + }
7370 +
7371 + case AR6000_XIOCTL_SET_ADHOC_BEACON_INTVAL:
7372 + {
7373 + WMI_BEACON_INT_CMD bIntvlCmd;
7374 +
7375 + if (ar->arWmiReady == FALSE) {
7376 + ret = -EIO;
7377 + } else if (copy_from_user(&bIntvlCmd, userdata,
7378 + sizeof(bIntvlCmd)))
7379 + {
7380 + ret = -EFAULT;
7381 + } else if (wmi_set_adhoc_bconIntvl_cmd(ar->arWmi, bIntvlCmd.beaconInterval)
7382 + != A_OK)
7383 + {
7384 + ret = -EIO;
7385 + }
7386 + break;
7387 + }
7388 + case IEEE80211_IOCTL_SETAUTHALG:
7389 + {
7390 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
7391 + struct ieee80211req_authalg req;
7392 +
7393 + if (ar->arWmiReady == FALSE) {
7394 + ret = -EIO;
7395 + } else if (copy_from_user(&req, userdata,
7396 + sizeof(struct ieee80211req_authalg)))
7397 + {
7398 + ret = -EFAULT;
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;
7405 + } else {
7406 + ret = -EIO;
7407 + }
7408 + break;
7409 + }
7410 +
7411 + case AR6000_XIOCTL_SET_VOICE_PKT_SIZE:
7412 + ret = ar6000_xioctl_set_voice_pkt_size(dev, userdata);
7413 + break;
7414 +
7415 + case AR6000_XIOCTL_SET_MAX_SP:
7416 + ret = ar6000_xioctl_set_max_sp_len(dev, userdata);
7417 + break;
7418 +
7419 + case AR6000_XIOCTL_WMI_GET_ROAM_TBL:
7420 + ret = ar6000_ioctl_get_roam_tbl(dev, rq);
7421 + break;
7422 + case AR6000_XIOCTL_WMI_SET_ROAM_CTRL:
7423 + ret = ar6000_ioctl_set_roam_ctrl(dev, userdata);
7424 + break;
7425 + case AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS:
7426 + ret = ar6000_ioctl_set_powersave_timers(dev, userdata);
7427 + break;
7428 + case AR6000_XIOCTRL_WMI_GET_POWER_MODE:
7429 + ret = ar6000_ioctl_get_power_mode(dev, rq);
7430 + break;
7431 + case AR6000_XIOCTRL_WMI_SET_WLAN_STATE:
7432 + get_user(ar->arWlanState, (unsigned int *)userdata);
7433 + if (ar->arWmiReady == FALSE) {
7434 + ret = -EIO;
7435 + break;
7436 + }
7437 +
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)
7449 + {
7450 + ret = -EIO;
7451 + }
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)
7462 + {
7463 + ret = -EIO;
7464 + ar->arConnectPending = FALSE;
7465 + }
7466 + }
7467 + } else {
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);
7473 + } else {
7474 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7475 + }
7476 +
7477 + if (wmi_scanparams_cmd(ar->arWmi, 0xFFFF, 0, 0, 0, 0, 0, 0, 0xFF, 0) != A_OK)
7478 + {
7479 + ret = -EIO;
7480 + }
7481 + }
7482 + break;
7483 + case AR6000_XIOCTL_WMI_GET_ROAM_DATA:
7484 + ret = ar6000_ioctl_get_roam_data(dev, rq);
7485 + break;
7486 + case AR6000_XIOCTL_WMI_SET_BT_STATUS:
7487 + ret = ar6000_xioctl_set_bt_status_cmd(dev, userdata);
7488 + break;
7489 + case AR6000_XIOCTL_WMI_SET_BT_PARAMS:
7490 + ret = ar6000_xioctl_set_bt_params_cmd(dev, userdata);
7491 + break;
7492 + case AR6000_XIOCTL_WMI_STARTSCAN:
7493 + {
7494 + WMI_START_SCAN_CMD setStartScanCmd;
7495 +
7496 + if (ar->arWmiReady == FALSE) {
7497 + ret = -EIO;
7498 + } else if (copy_from_user(&setStartScanCmd, userdata,
7499 + sizeof(setStartScanCmd)))
7500 + {
7501 + ret = -EFAULT;
7502 + } else {
7503 + if (wmi_startscan_cmd(ar->arWmi, setStartScanCmd.scanType,
7504 + setStartScanCmd.forceFgScan,
7505 + setStartScanCmd.isLegacy,
7506 + setStartScanCmd.homeDwellTime,
7507 + setStartScanCmd.forceScanInterval) != A_OK)
7508 + {
7509 + ret = -EIO;
7510 + }
7511 + }
7512 + break;
7513 + }
7514 + case AR6000_XIOCTL_WMI_SETFIXRATES:
7515 + {
7516 + WMI_FIX_RATES_CMD setFixRatesCmd;
7517 + A_STATUS returnStatus;
7518 +
7519 + if (ar->arWmiReady == FALSE) {
7520 + ret = -EIO;
7521 + } else if (copy_from_user(&setFixRatesCmd, userdata,
7522 + sizeof(setFixRatesCmd)))
7523 + {
7524 + ret = -EFAULT;
7525 + } else {
7526 + returnStatus = wmi_set_fixrates_cmd(ar->arWmi, setFixRatesCmd.fixRateMask);
7527 + if (returnStatus == A_EINVAL)
7528 + {
7529 + ret = -EINVAL;
7530 + }
7531 + else if(returnStatus != A_OK) {
7532 + ret = -EIO;
7533 + }
7534 + }
7535 + break;
7536 + }
7537 +
7538 + case AR6000_XIOCTL_WMI_GETFIXRATES:
7539 + {
7540 + WMI_FIX_RATES_CMD getFixRatesCmd;
7541 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
7542 + int ret = 0;
7543 +
7544 + if (ar->arWmiReady == FALSE) {
7545 + return -EIO;
7546 + }
7547 +
7548 + if (down_interruptible(&ar->arSem)) {
7549 + return -ERESTARTSYS;
7550 + }
7551 + /* Used copy_from_user/copy_to_user to access user space data */
7552 + if (copy_from_user(&getFixRatesCmd, userdata, sizeof(getFixRatesCmd))) {
7553 + ret = -EFAULT;
7554 + } else {
7555 + ar->arRateMask = 0xFFFF;
7556 +
7557 + if (wmi_get_ratemask_cmd(ar->arWmi) != A_OK) {
7558 + up(&ar->arSem);
7559 + return -EIO;
7560 + }
7561 +
7562 + wait_event_interruptible_timeout(arEvent, ar->arRateMask != 0xFFFF, wmitimeout * HZ);
7563 +
7564 + if (signal_pending(current)) {
7565 + ret = -EINTR;
7566 + }
7567 +
7568 + if (!ret) {
7569 + getFixRatesCmd.fixRateMask = ar->arRateMask;
7570 + }
7571 +
7572 + if(copy_to_user(userdata, &getFixRatesCmd, sizeof(getFixRatesCmd))) {
7573 + ret = -EFAULT;
7574 + }
7575 +
7576 + up(&ar->arSem);
7577 + }
7578 + break;
7579 + }
7580 + case AR6000_XIOCTL_WMI_SET_AUTHMODE:
7581 + {
7582 + WMI_SET_AUTH_MODE_CMD setAuthMode;
7583 +
7584 + if (ar->arWmiReady == FALSE) {
7585 + ret = -EIO;
7586 + } else if (copy_from_user(&setAuthMode, userdata,
7587 + sizeof(setAuthMode)))
7588 + {
7589 + ret = -EFAULT;
7590 + } else {
7591 + if (wmi_set_authmode_cmd(ar->arWmi, setAuthMode.mode) != A_OK)
7592 + {
7593 + ret = -EIO;
7594 + }
7595 + }
7596 + break;
7597 + }
7598 + case AR6000_XIOCTL_WMI_SET_REASSOCMODE:
7599 + {
7600 + WMI_SET_REASSOC_MODE_CMD setReassocMode;
7601 +
7602 + if (ar->arWmiReady == FALSE) {
7603 + ret = -EIO;
7604 + } else if (copy_from_user(&setReassocMode, userdata,
7605 + sizeof(setReassocMode)))
7606 + {
7607 + ret = -EFAULT;
7608 + } else {
7609 + if (wmi_set_reassocmode_cmd(ar->arWmi, setReassocMode.mode) != A_OK)
7610 + {
7611 + ret = -EIO;
7612 + }
7613 + }
7614 + break;
7615 + }
7616 + case AR6000_XIOCTL_DIAG_READ:
7617 + {
7618 + A_UINT32 addr, data;
7619 + get_user(addr, (unsigned int *)userdata);
7620 + if (ar6000_ReadRegDiag(ar->arHifDevice, &addr, &data) != A_OK) {
7621 + ret = -EIO;
7622 + }
7623 + put_user(data, (unsigned int *)userdata + 1);
7624 + break;
7625 + }
7626 + case AR6000_XIOCTL_DIAG_WRITE:
7627 + {
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) {
7632 + ret = -EIO;
7633 + }
7634 + break;
7635 + }
7636 + case AR6000_XIOCTL_WMI_SET_KEEPALIVE:
7637 + {
7638 + WMI_SET_KEEPALIVE_CMD setKeepAlive;
7639 + if (ar->arWmiReady == FALSE) {
7640 + return -EIO;
7641 + } else if (copy_from_user(&setKeepAlive, userdata,
7642 + sizeof(setKeepAlive))){
7643 + ret = -EFAULT;
7644 + } else {
7645 + if (wmi_set_keepalive_cmd(ar->arWmi, setKeepAlive.keepaliveInterval) != A_OK) {
7646 + ret = -EIO;
7647 + }
7648 + }
7649 + break;
7650 + }
7651 + case AR6000_XIOCTL_WMI_GET_KEEPALIVE:
7652 + {
7653 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
7654 + WMI_GET_KEEPALIVE_CMD getKeepAlive;
7655 + int ret = 0;
7656 + if (ar->arWmiReady == FALSE) {
7657 + return -EIO;
7658 + }
7659 + if (down_interruptible(&ar->arSem)) {
7660 + return -ERESTARTSYS;
7661 + }
7662 + if (copy_from_user(&getKeepAlive, userdata,sizeof(getKeepAlive))) {
7663 + ret = -EFAULT;
7664 + } else {
7665 + getKeepAlive.keepaliveInterval = wmi_get_keepalive_cmd(ar->arWmi);
7666 + ar->arKeepaliveConfigured = 0xFF;
7667 + if (wmi_get_keepalive_configured(ar->arWmi) != A_OK){
7668 + up(&ar->arSem);
7669 + return -EIO;
7670 + }
7671 + wait_event_interruptible_timeout(arEvent, ar->arKeepaliveConfigured != 0xFF, wmitimeout * HZ);
7672 + if (signal_pending(current)) {
7673 + ret = -EINTR;
7674 + }
7675 +
7676 + if (!ret) {
7677 + getKeepAlive.configured = ar->arKeepaliveConfigured;
7678 + }
7679 + if (copy_to_user(userdata, &getKeepAlive, sizeof(getKeepAlive))) {
7680 + ret = -EFAULT;
7681 + }
7682 + up(&ar->arSem);
7683 + }
7684 + break;
7685 + }
7686 + case AR6000_XIOCTL_WMI_SET_APPIE:
7687 + {
7688 + WMI_SET_APPIE_CMD appIEcmd;
7689 + A_UINT8 appIeInfo[IEEE80211_APPIE_FRAME_MAX_LEN];
7690 + A_UINT32 fType,ieLen;
7691 +
7692 + if (ar->arWmiReady == FALSE) {
7693 + return -EIO;
7694 + }
7695 + get_user(fType, (A_UINT32 *)userdata);
7696 + appIEcmd.mgmtFrmType = fType;
7697 + if (appIEcmd.mgmtFrmType >= IEEE80211_APPIE_NUM_OF_FRAME) {
7698 + ret = -EIO;
7699 + } else {
7700 + get_user(ieLen, (A_UINT32 *)(userdata + 4));
7701 + appIEcmd.ieLen = ieLen;
7702 + if (appIEcmd.ieLen > IEEE80211_APPIE_FRAME_MAX_LEN) {
7703 + ret = -EIO;
7704 + break;
7705 + }
7706 + if (copy_from_user(appIeInfo, userdata + 8, appIEcmd.ieLen)) {
7707 + ret = -EFAULT;
7708 + } else {
7709 + if (wmi_set_appie_cmd(ar->arWmi, appIEcmd.mgmtFrmType,
7710 + appIEcmd.ieLen, appIeInfo) != A_OK)
7711 + {
7712 + ret = -EIO;
7713 + }
7714 + }
7715 + }
7716 + break;
7717 + }
7718 + case AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER:
7719 + {
7720 + WMI_BSS_FILTER_CMD cmd;
7721 + A_UINT32 filterType;
7722 +
7723 + if (copy_from_user(&filterType, userdata, sizeof(A_UINT32)))
7724 + {
7725 + return -EFAULT;
7726 + }
7727 + if (filterType & (IEEE80211_FILTER_TYPE_BEACON |
7728 + IEEE80211_FILTER_TYPE_PROBE_RESP))
7729 + {
7730 + cmd.bssFilter = ALL_BSS_FILTER;
7731 + } else {
7732 + cmd.bssFilter = NONE_BSS_FILTER;
7733 + }
7734 + if (wmi_bssfilter_cmd(ar->arWmi, cmd.bssFilter, 0) != A_OK) {
7735 + ret = -EIO;
7736 + }
7737 +
7738 + AR6000_SPIN_LOCK(&ar->arLock, 0);
7739 + ar->arMgmtFilter = filterType;
7740 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
7741 + break;
7742 + }
7743 + case AR6000_XIOCTL_WMI_SET_WSC_STATUS:
7744 + {
7745 + A_UINT32 wsc_status;
7746 +
7747 + if (copy_from_user(&wsc_status, userdata, sizeof(A_UINT32)))
7748 + {
7749 + return -EFAULT;
7750 + }
7751 + if (wmi_set_wsc_status_cmd(ar->arWmi, wsc_status) != A_OK) {
7752 + ret = -EIO;
7753 + }
7754 + break;
7755 + }
7756 + case AR6000_XIOCTL_BMI_ROMPATCH_INSTALL:
7757 + {
7758 + A_UINT32 ROM_addr;
7759 + A_UINT32 RAM_addr;
7760 + A_UINT32 nbytes;
7761 + A_UINT32 do_activate;
7762 + A_UINT32 rompatch_id;
7763 +
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 */
7774 + }
7775 + break;
7776 + }
7777 +
7778 + case AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL:
7779 + {
7780 + A_UINT32 rompatch_id;
7781 +
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);
7785 + break;
7786 + }
7787 +
7788 + case AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE:
7789 + case AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE:
7790 + {
7791 + A_UINT32 rompatch_count;
7792 +
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))
7799 + {
7800 + ret = -EFAULT;
7801 + } else {
7802 + if (cmd == AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE) {
7803 + ret = BMIrompatchActivate(hifDevice, rompatch_count, (A_UINT32 *)buffer);
7804 + } else {
7805 + ret = BMIrompatchDeactivate(hifDevice, rompatch_count, (A_UINT32 *)buffer);
7806 + }
7807 + }
7808 + A_FREE(buffer);
7809 + } else {
7810 + ret = -ENOMEM;
7811 + }
7812 +
7813 + break;
7814 + }
7815 +
7816 + case AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE:
7817 + {
7818 + WMI_SET_HOST_SLEEP_MODE_CMD setHostSleepMode;
7819 +
7820 + if (ar->arWmiReady == FALSE) {
7821 + ret = -EIO;
7822 + } else if (copy_from_user(&setHostSleepMode, userdata,
7823 + sizeof(setHostSleepMode)))
7824 + {
7825 + ret = -EFAULT;
7826 + } else {
7827 + if (wmi_set_host_sleep_mode_cmd(ar->arWmi,
7828 + &setHostSleepMode) != A_OK)
7829 + {
7830 + ret = -EIO;
7831 + }
7832 + }
7833 + break;
7834 + }
7835 + case AR6000_XIOCTL_WMI_SET_WOW_MODE:
7836 + {
7837 + WMI_SET_WOW_MODE_CMD setWowMode;
7838 +
7839 + if (ar->arWmiReady == FALSE) {
7840 + ret = -EIO;
7841 + } else if (copy_from_user(&setWowMode, userdata,
7842 + sizeof(setWowMode)))
7843 + {
7844 + ret = -EFAULT;
7845 + } else {
7846 + if (wmi_set_wow_mode_cmd(ar->arWmi,
7847 + &setWowMode) != A_OK)
7848 + {
7849 + ret = -EIO;
7850 + }
7851 + }
7852 + break;
7853 + }
7854 + case AR6000_XIOCTL_WMI_GET_WOW_LIST:
7855 + {
7856 + WMI_GET_WOW_LIST_CMD getWowList;
7857 +
7858 + if (ar->arWmiReady == FALSE) {
7859 + ret = -EIO;
7860 + } else if (copy_from_user(&getWowList, userdata,
7861 + sizeof(getWowList)))
7862 + {
7863 + ret = -EFAULT;
7864 + } else {
7865 + if (wmi_get_wow_list_cmd(ar->arWmi,
7866 + &getWowList) != A_OK)
7867 + {
7868 + ret = -EIO;
7869 + }
7870 + }
7871 + break;
7872 + }
7873 + case AR6000_XIOCTL_WMI_ADD_WOW_PATTERN:
7874 + {
7875 +#define WOW_PATTERN_SIZE 64
7876 +#define WOW_MASK_SIZE 64
7877 +
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};
7881 +
7882 + if (ar->arWmiReady == FALSE) {
7883 + ret = -EIO;
7884 + } else {
7885 +
7886 + if(copy_from_user(&cmd, userdata,
7887 + sizeof(WMI_ADD_WOW_PATTERN_CMD)))
7888 + return -EFAULT;
7889 + if (copy_from_user(pattern_data,
7890 + userdata + 3,
7891 + cmd.filter_size)){
7892 + ret = -EFAULT;
7893 + break;
7894 + }
7895 + if (copy_from_user(mask_data,
7896 + (userdata + 3 + cmd.filter_size),
7897 + cmd.filter_size)){
7898 + ret = -EFAULT;
7899 + break;
7900 + } else {
7901 + if (wmi_add_wow_pattern_cmd(ar->arWmi,
7902 + &cmd, pattern_data, mask_data, cmd.filter_size) != A_OK){
7903 + ret = -EIO;
7904 + }
7905 + }
7906 + }
7907 +#undef WOW_PATTERN_SIZE
7908 +#undef WOW_MASK_SIZE
7909 + break;
7910 + }
7911 + case AR6000_XIOCTL_WMI_DEL_WOW_PATTERN:
7912 + {
7913 + WMI_DEL_WOW_PATTERN_CMD delWowPattern;
7914 +
7915 + if (ar->arWmiReady == FALSE) {
7916 + ret = -EIO;
7917 + } else if (copy_from_user(&delWowPattern, userdata,
7918 + sizeof(delWowPattern)))
7919 + {
7920 + ret = -EFAULT;
7921 + } else {
7922 + if (wmi_del_wow_pattern_cmd(ar->arWmi,
7923 + &delWowPattern) != A_OK)
7924 + {
7925 + ret = -EIO;
7926 + }
7927 + }
7928 + break;
7929 + }
7930 + case AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE:
7931 + if (ar->arHtcTarget != NULL) {
7932 + HTCDumpCreditStates(ar->arHtcTarget);
7933 + }
7934 + break;
7935 + case AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE:
7936 + if (ar->arHtcTarget != NULL) {
7937 + struct ar6000_traffic_activity_change data;
7938 +
7939 + if (copy_from_user(&data, userdata, sizeof(data)))
7940 + {
7941 + return -EFAULT;
7942 + }
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);
7948 + }
7949 + break;
7950 + case AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS:
7951 + if (ar->arWmiReady == FALSE) {
7952 + ret = -EIO;
7953 + } else if (copy_from_user(&connectCtrlFlags, userdata,
7954 + sizeof(connectCtrlFlags)))
7955 + {
7956 + ret = -EFAULT;
7957 + } else {
7958 + ar->arConnectCtrlFlags = connectCtrlFlags;
7959 + }
7960 + break;
7961 + case AR6000_XIOCTL_WMI_SET_AKMP_PARAMS:
7962 + if (ar->arWmiReady == FALSE) {
7963 + ret = -EIO;
7964 + } else if (copy_from_user(&akmpParams, userdata,
7965 + sizeof(WMI_SET_AKMP_PARAMS_CMD)))
7966 + {
7967 + ret = -EFAULT;
7968 + } else {
7969 + if (wmi_set_akmp_params_cmd(ar->arWmi, &akmpParams) != A_OK) {
7970 + ret = -EIO;
7971 + }
7972 + }
7973 + break;
7974 + case AR6000_XIOCTL_WMI_SET_PMKID_LIST:
7975 + if (ar->arWmiReady == FALSE) {
7976 + ret = -EIO;
7977 + } else {
7978 + if (copy_from_user(&pmkidInfo.numPMKID, userdata,
7979 + sizeof(pmkidInfo.numPMKID)))
7980 + {
7981 + ret = -EFAULT;
7982 + break;
7983 + }
7984 + if (copy_from_user(&pmkidInfo.pmkidList,
7985 + userdata + sizeof(pmkidInfo.numPMKID),
7986 + pmkidInfo.numPMKID * sizeof(WMI_PMKID)))
7987 + {
7988 + ret = -EFAULT;
7989 + break;
7990 + }
7991 + if (wmi_set_pmkid_list_cmd(ar->arWmi, &pmkidInfo) != A_OK) {
7992 + ret = -EIO;
7993 + }
7994 + }
7995 + break;
7996 + case AR6000_XIOCTL_WMI_GET_PMKID_LIST:
7997 + if (ar->arWmiReady == FALSE) {
7998 + ret = -EIO;
7999 + } else {
8000 + if (wmi_get_pmkid_list_cmd(ar->arWmi) != A_OK) {
8001 + ret = -EIO;
8002 + }
8003 + }
8004 + break;
8005 + default:
8006 + ret = -EOPNOTSUPP;
8007 + }
8008 + return ret;
8009 +}
8010 +
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
8014 --- /dev/null
8015 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/netbuf.c
8016 @@ -0,0 +1,225 @@
8017 +
8018 +/*
8019 + *
8020 + * Copyright (c) 2004-2007 Atheros Communications Inc.
8021 + * All rights reserved.
8022 + *
8023 + *
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;
8027 + *
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.
8032 + *
8033 + *
8034 + *
8035 + */
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"
8043 +
8044 +#define AR6000_DATA_OFFSET 64
8045 +
8046 +void a_netbuf_enqueue(A_NETBUF_QUEUE_T *q, void *pkt)
8047 +{
8048 + skb_queue_tail((struct sk_buff_head *) q, (struct sk_buff *) pkt);
8049 +}
8050 +
8051 +void a_netbuf_prequeue(A_NETBUF_QUEUE_T *q, void *pkt)
8052 +{
8053 + skb_queue_head((struct sk_buff_head *) q, (struct sk_buff *) pkt);
8054 +}
8055 +
8056 +void *a_netbuf_dequeue(A_NETBUF_QUEUE_T *q)
8057 +{
8058 + return((void *) skb_dequeue((struct sk_buff_head *) q));
8059 +}
8060 +
8061 +int a_netbuf_queue_size(A_NETBUF_QUEUE_T *q)
8062 +{
8063 + return(skb_queue_len((struct sk_buff_head *) q));
8064 +}
8065 +
8066 +int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q)
8067 +{
8068 + return(skb_queue_empty((struct sk_buff_head *) q));
8069 +}
8070 +
8071 +void a_netbuf_queue_init(A_NETBUF_QUEUE_T *q)
8072 +{
8073 + skb_queue_head_init((struct sk_buff_head *) q);
8074 +}
8075 +
8076 +void *
8077 +a_netbuf_alloc(int size)
8078 +{
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);
8083 +}
8084 +
8085 +/*
8086 + * Allocate an SKB w.o. any encapsulation requirement.
8087 + */
8088 +void *
8089 +a_netbuf_alloc_raw(int size)
8090 +{
8091 + struct sk_buff *skb;
8092 +
8093 + skb = dev_alloc_skb(size);
8094 +
8095 + return ((void *)skb);
8096 +}
8097 +
8098 +void
8099 +a_netbuf_free(void *bufPtr)
8100 +{
8101 + struct sk_buff *skb = (struct sk_buff *)bufPtr;
8102 +
8103 + dev_kfree_skb(skb);
8104 +}
8105 +
8106 +A_UINT32
8107 +a_netbuf_to_len(void *bufPtr)
8108 +{
8109 + return (((struct sk_buff *)bufPtr)->len);
8110 +}
8111 +
8112 +void *
8113 +a_netbuf_to_data(void *bufPtr)
8114 +{
8115 + return (((struct sk_buff *)bufPtr)->data);
8116 +}
8117 +
8118 +/*
8119 + * Add len # of bytes to the beginning of the network buffer
8120 + * pointed to by bufPtr
8121 + */
8122 +A_STATUS
8123 +a_netbuf_push(void *bufPtr, A_INT32 len)
8124 +{
8125 + skb_push((struct sk_buff *)bufPtr, len);
8126 +
8127 + return A_OK;
8128 +}
8129 +
8130 +/*
8131 + * Add len # of bytes to the beginning of the network buffer
8132 + * pointed to by bufPtr and also fill with data
8133 + */
8134 +A_STATUS
8135 +a_netbuf_push_data(void *bufPtr, char *srcPtr, A_INT32 len)
8136 +{
8137 + skb_push((struct sk_buff *) bufPtr, len);
8138 + A_MEMCPY(((struct sk_buff *)bufPtr)->data, srcPtr, len);
8139 +
8140 + return A_OK;
8141 +}
8142 +
8143 +/*
8144 + * Add len # of bytes to the end of the network buffer
8145 + * pointed to by bufPtr
8146 + */
8147 +A_STATUS
8148 +a_netbuf_put(void *bufPtr, A_INT32 len)
8149 +{
8150 + skb_put((struct sk_buff *)bufPtr, len);
8151 +
8152 + return A_OK;
8153 +}
8154 +
8155 +/*
8156 + * Add len # of bytes to the end of the network buffer
8157 + * pointed to by bufPtr and also fill with data
8158 + */
8159 +A_STATUS
8160 +a_netbuf_put_data(void *bufPtr, char *srcPtr, A_INT32 len)
8161 +{
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);
8166 +
8167 + return A_OK;
8168 +}
8169 +
8170 +
8171 +/*
8172 + * Trim the network buffer pointed to by bufPtr to len # of bytes
8173 + */
8174 +A_STATUS
8175 +a_netbuf_setlen(void *bufPtr, A_INT32 len)
8176 +{
8177 + skb_trim((struct sk_buff *)bufPtr, len);
8178 +
8179 + return A_OK;
8180 +}
8181 +
8182 +/*
8183 + * Chop of len # of bytes from the end of the buffer.
8184 + */
8185 +A_STATUS
8186 +a_netbuf_trim(void *bufPtr, A_INT32 len)
8187 +{
8188 + skb_trim((struct sk_buff *)bufPtr, ((struct sk_buff *)bufPtr)->len - len);
8189 +
8190 + return A_OK;
8191 +}
8192 +
8193 +/*
8194 + * Chop of len # of bytes from the end of the buffer and return the data.
8195 + */
8196 +A_STATUS
8197 +a_netbuf_trim_data(void *bufPtr, char *dstPtr, A_INT32 len)
8198 +{
8199 + char *start = ((struct sk_buff *)bufPtr)->data +
8200 + (((struct sk_buff *)bufPtr)->len - len);
8201 +
8202 + A_MEMCPY(dstPtr, start, len);
8203 + skb_trim((struct sk_buff *)bufPtr, ((struct sk_buff *)bufPtr)->len - len);
8204 +
8205 + return A_OK;
8206 +}
8207 +
8208 +
8209 +/*
8210 + * Returns the number of bytes available to a a_netbuf_push()
8211 + */
8212 +A_INT32
8213 +a_netbuf_headroom(void *bufPtr)
8214 +{
8215 + return (skb_headroom((struct sk_buff *)bufPtr));
8216 +}
8217 +
8218 +/*
8219 + * Removes specified number of bytes from the beginning of the buffer
8220 + */
8221 +A_STATUS
8222 +a_netbuf_pull(void *bufPtr, A_INT32 len)
8223 +{
8224 + skb_pull((struct sk_buff *)bufPtr, len);
8225 +
8226 + return A_OK;
8227 +}
8228 +
8229 +/*
8230 + * Removes specified number of bytes from the beginning of the buffer
8231 + * and return the data
8232 + */
8233 +A_STATUS
8234 +a_netbuf_pull_data(void *bufPtr, char *dstPtr, A_INT32 len)
8235 +{
8236 + A_MEMCPY(dstPtr, ((struct sk_buff *)bufPtr)->data, len);
8237 + skb_pull((struct sk_buff *)bufPtr, len);
8238 +
8239 + return A_OK;
8240 +}
8241 +
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
8245 --- /dev/null
8246 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/osapi_linux.h
8247 @@ -0,0 +1,319 @@
8248 +/*
8249 + * $Id: //depot/sw/releases/olca2.0-GPL/host/os/linux/include/osapi_linux.h#1 $
8250 + *
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
8253 + * type.
8254 + *
8255 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
8256 + *
8257 + *
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;
8261 + *
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.
8266 + *
8267 + *
8268 + *
8269 + */
8270 +
8271 +#ifndef _OSAPI_LINUX_H_
8272 +#define _OSAPI_LINUX_H_
8273 +
8274 +#ifdef __KERNEL__
8275 +
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>
8284 +#endif
8285 +#include <linux/timer.h>
8286 +#include <linux/delay.h>
8287 +#include <linux/wait.h>
8288 +#ifdef KERNEL_2_4
8289 +#include <asm/arch/irq.h>
8290 +#include <asm/irq.h>
8291 +#endif
8292 +
8293 +#ifdef __GNUC__
8294 +#define __ATTRIB_PACK __attribute__ ((packed))
8295 +#define __ATTRIB_PRINTF __attribute__ ((format (printf, 1, 2)))
8296 +#define __ATTRIB_NORETURN __attribute__ ((noreturn))
8297 +#ifndef INLINE
8298 +#define INLINE __inline__
8299 +#endif
8300 +#else /* Not GCC */
8301 +#define __ATTRIB_PACK
8302 +#define __ATTRIB_PRINTF
8303 +#define __ATTRIB_NORETURN
8304 +#ifndef INLINE
8305 +#define INLINE __inline
8306 +#endif
8307 +#endif /* End __GNUC__ */
8308 +
8309 +#define PREPACK
8310 +#define POSTPACK __ATTRIB_PACK
8311 +
8312 +/*
8313 + * Endianes macros
8314 + */
8315 +#define A_BE2CPU8(x) ntohb(x)
8316 +#define A_BE2CPU16(x) ntohs(x)
8317 +#define A_BE2CPU32(x) ntohl(x)
8318 +
8319 +#define A_LE2CPU8(x) (x)
8320 +#define A_LE2CPU16(x) (x)
8321 +#define A_LE2CPU32(x) (x)
8322 +
8323 +#define A_CPU2BE8(x) htonb(x)
8324 +#define A_CPU2BE16(x) htons(x)
8325 +#define A_CPU2BE32(x) htonl(x)
8326 +
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)
8334 +
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.. */
8342 +
8343 +/* Get current time in ms adding a constant offset (in ms) */
8344 +#define A_GET_MS(offset) \
8345 + (jiffies + ((offset) / 1000) * HZ)
8346 +
8347 +/*
8348 + * Timer Functions
8349 + */
8350 +#define A_MDELAY(msecs) mdelay(msecs)
8351 +typedef struct timer_list A_TIMER;
8352 +
8353 +#define A_INIT_TIMER(pTimer, pFunction, pArg) do { \
8354 + init_timer(pTimer); \
8355 + (pTimer)->function = (pFunction); \
8356 + (pTimer)->data = (unsigned long)(pArg); \
8357 +} while (0)
8358 +
8359 +/*
8360 + * Start a Timer that elapses after 'periodMSec' milli-seconds
8361 + * Support is provided for a one-shot timer. The 'repeatFlag' is
8362 + * ignored.
8363 + */
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"); \
8368 + } \
8369 + mod_timer((pTimer), jiffies + HZ * (periodMSec) / 1000); \
8370 +} while (0)
8371 +
8372 +/*
8373 + * Cancel the Timer.
8374 + */
8375 +#define A_UNTIMEOUT(pTimer) do { \
8376 + del_timer((pTimer)); \
8377 +} while (0)
8378 +
8379 +#define A_DELETE_TIMER(pTimer) do { \
8380 +} while (0)
8381 +
8382 +/*
8383 + * Wait Queue related functions
8384 + */
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) \
8389 +do { \
8390 + wait_queue_t __wait; \
8391 + init_waitqueue_entry(&__wait, current); \
8392 + \
8393 + add_wait_queue(&wq, &__wait); \
8394 + for (;;) { \
8395 + set_current_state(TASK_INTERRUPTIBLE); \
8396 + if (condition) \
8397 + break; \
8398 + if (!signal_pending(current)) { \
8399 + ret = schedule_timeout(ret); \
8400 + if (!ret) \
8401 + break; \
8402 + continue; \
8403 + } \
8404 + ret = -ERESTARTSYS; \
8405 + break; \
8406 + } \
8407 + current->state = TASK_RUNNING; \
8408 + remove_wait_queue(&wq, &__wait); \
8409 +} while (0)
8410 +
8411 +#define wait_event_interruptible_timeout(wq, condition, timeout) \
8412 +({ \
8413 + long __ret = timeout; \
8414 + if (!(condition)) \
8415 + __wait_event_interruptible_timeout(wq, condition, __ret); \
8416 + __ret; \
8417 +})
8418 +#endif /* wait_event_interruptible_timeout */
8419 +
8420 +#define A_WAIT_EVENT_INTERRUPTIBLE_TIMEOUT(head, condition, timeout) do { \
8421 + wait_event_interruptible_timeout(head, condition, timeout); \
8422 +} while (0)
8423 +
8424 +#define A_WAKE_UP(head) wake_up(head)
8425 +
8426 +#ifdef DEBUG
8427 +#define A_ASSERT(expr) \
8428 + if (!(expr)) { \
8429 + printk(KERN_ALERT "\n" __FILE__ ":%d: Assertion " #expr " failed!\n",__LINE__); \
8430 + panic(#expr); \
8431 + }
8432 +
8433 +#else
8434 +#define A_ASSERT(expr)
8435 +#endif /* DEBUG */
8436 +
8437 +/*
8438 + * Initialization of the network buffer subsystem
8439 + */
8440 +#define A_NETBUF_INIT()
8441 +
8442 +/*
8443 + * Network buffer queue support
8444 + */
8445 +typedef struct sk_buff_head A_NETBUF_QUEUE_T;
8446 +
8447 +#define A_NETBUF_QUEUE_INIT(q) \
8448 + a_netbuf_queue_init(q)
8449 +
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)
8460 +
8461 +/*
8462 + * Network buffer support
8463 + */
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)
8486 +
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)
8490 +
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)
8494 +
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)
8498 +
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)
8502 +
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)
8506 +
8507 +/* return the beginning of the headroom for the buffer */
8508 +#define A_NETBUF_HEAD(bufPtr) \
8509 + ((((struct sk_buff *)(bufPtr))->head))
8510 +
8511 +/*
8512 + * OS specific network buffer access routines
8513 + */
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);
8536 +
8537 +/*
8538 + * Kernel v.s User space functions
8539 + */
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);
8542 +
8543 +#else /* __KERNEL__ */
8544 +
8545 +#ifdef __GNUC__
8546 +#define __ATTRIB_PACK __attribute__ ((packed))
8547 +#define __ATTRIB_PRINTF __attribute__ ((format (printf, 1, 2)))
8548 +#define __ATTRIB_NORETURN __attribute__ ((noreturn))
8549 +#ifndef INLINE
8550 +#define INLINE __inline__
8551 +#endif
8552 +#else /* Not GCC */
8553 +#define __ATTRIB_PACK
8554 +#define __ATTRIB_PRINTF
8555 +#define __ATTRIB_NORETURN
8556 +#ifndef INLINE
8557 +#define INLINE __inline
8558 +#endif
8559 +#endif /* End __GNUC__ */
8560 +
8561 +#define PREPACK
8562 +#define POSTPACK __ATTRIB_PACK
8563 +
8564 +#endif /* __KERNEL__ */
8565 +
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
8570 --- /dev/null
8571 +++ b/drivers/sdio/function/wlan/ar6000/ar6000/wireless_ext.c
8572 @@ -0,0 +1,1946 @@
8573 +/*
8574 + *
8575 + * Copyright (c) 2004-2007 Atheros Communications Inc.
8576 + * All rights reserved.
8577 + *
8578 + *
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;
8582 + *
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.
8587 + *
8588 + *
8589 + *
8590 + */
8591 +
8592 +#include "ar6000_drv.h"
8593 +
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;
8599 +
8600 +/*
8601 + * Encode a WPA or RSN information element as a custom
8602 + * element using the hostap format.
8603 + */
8604 +static u_int
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)
8608 +{
8609 + u_int8_t *p;
8610 + int i;
8611 +
8612 + if (bufsize < leader_len)
8613 + return 0;
8614 + p = buf;
8615 + memcpy(p, leader, leader_len);
8616 + bufsize -= leader_len;
8617 + p += 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);
8621 +}
8622 +
8623 +void
8624 +ar6000_scan_node(void *arg, bss_t *ni)
8625 +{
8626 + struct iw_event iwe;
8627 +#if WIRELESS_EXT > 14
8628 + char buf[64*2 + 30];
8629 +#endif
8630 + struct ar_giwscan_param *param;
8631 + A_CHAR *current_ev;
8632 + A_CHAR *end_buf;
8633 + struct ieee80211_common_ie *cie;
8634 +
8635 + param = (struct ar_giwscan_param *)arg;
8636 +
8637 + if (param->current_ev >= param->end_buf) {
8638 + return;
8639 + }
8640 + if ((param->firstPass == TRUE) &&
8641 + ((ni->ni_cie.ie_wpa == NULL) && (ni->ni_cie.ie_rsn == NULL))) {
8642 + /*
8643 + * Only forward wpa bss's in first pass
8644 + */
8645 + return;
8646 + }
8647 +
8648 + if ((param->firstPass == FALSE) &&
8649 + ((ni->ni_cie.ie_wpa != NULL) || (ni->ni_cie.ie_rsn != NULL))) {
8650 + /*
8651 + * Only forward non-wpa bss's in 2nd pass
8652 + */
8653 + return;
8654 + }
8655 +
8656 + current_ev = param->current_ev;
8657 + end_buf = param->end_buf;
8658 +
8659 + cie = &ni->ni_cie;
8660 +
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,
8666 + IW_EV_ADDR_LEN);
8667 +
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]);
8674 +
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,
8681 + IW_EV_UINT_LEN);
8682 + }
8683 +
8684 + A_MEMZERO(&iwe, sizeof(iwe));
8685 + iwe.cmd = SIOCGIWFREQ;
8686 + iwe.u.freq.m = cie->ie_chan * 100000;
8687 + iwe.u.freq.e = 1;
8688 + current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
8689 + IW_EV_FREQ_LEN);
8690 +
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,
8695 + IW_EV_QUAL_LEN);
8696 +
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;
8701 + } else {
8702 + iwe.u.data.flags = IW_ENCODE_DISABLED;
8703 + }
8704 + iwe.u.data.length = 0;
8705 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
8706 +
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);
8712 +
8713 + if (cie->ie_wpa != NULL) {
8714 + static const char wpa_leader[] = "wpa_ie=";
8715 +
8716 + A_MEMZERO(&iwe, sizeof(iwe));
8717 + iwe.cmd = IWEVCUSTOM;
8718 + iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_wpa,
8719 + cie->ie_wpa[1]+2,
8720 + wpa_leader, sizeof(wpa_leader)-1);
8721 +
8722 + if (iwe.u.data.length != 0) {
8723 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
8724 + }
8725 + }
8726 +
8727 + if (cie->ie_rsn != NULL && cie->ie_rsn[0] == IEEE80211_ELEMID_RSN) {
8728 + static const char rsn_leader[] = "rsn_ie=";
8729 +
8730 + A_MEMZERO(&iwe, sizeof(iwe));
8731 + iwe.cmd = IWEVCUSTOM;
8732 + iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_rsn,
8733 + cie->ie_rsn[1]+2,
8734 + rsn_leader, sizeof(rsn_leader)-1);
8735 +
8736 + if (iwe.u.data.length != 0) {
8737 + current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
8738 + }
8739 + }
8740 +
8741 + if (cie->ie_wmm != NULL) {
8742 + static const char wmm_leader[] = "wmm_ie=";
8743 +
8744 + A_MEMZERO(&iwe, sizeof(iwe));
8745 + iwe.cmd = IWEVCUSTOM;
8746 + iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_wmm,
8747 + cie->ie_wmm[1]+2,
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);
8751 + }
8752 + }
8753 +
8754 + if (cie->ie_ath != NULL) {
8755 + static const char ath_leader[] = "ath_ie=";
8756 +
8757 + A_MEMZERO(&iwe, sizeof(iwe));
8758 + iwe.cmd = IWEVCUSTOM;
8759 + iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_ath,
8760 + cie->ie_ath[1]+2,
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);
8764 + }
8765 + }
8766 +
8767 + param->current_ev = current_ev;
8768 +}
8769 +
8770 +int
8771 +ar6000_ioctl_giwscan(struct net_device *dev,
8772 + struct iw_request_info *info,
8773 + struct iw_point *data, char *extra)
8774 +{
8775 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
8776 + struct ar_giwscan_param param;
8777 + int i;
8778 +
8779 + if (ar->arWlanState == WLAN_DISABLED) {
8780 + return -EIO;
8781 + }
8782 +
8783 + if (ar->arWmiReady == FALSE) {
8784 + return -EIO;
8785 + }
8786 +
8787 + param.current_ev = extra;
8788 + param.end_buf = extra + IW_SCAN_MAX_DATA;
8789 + param.firstPass = TRUE;
8790 +
8791 + /*
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.
8799 + */
8800 + for (i = 0; i < 2; i++) {
8801 + /*
8802 + * Translate data to WE format.
8803 + */
8804 + wmi_iterate_nodes(ar->arWmi, ar6000_scan_node, &param);
8805 + param.firstPass = FALSE;
8806 + if (param.current_ev >= param.end_buf) {
8807 + data->length = param.current_ev - extra;
8808 + return -E2BIG;
8809 + }
8810 + }
8811 +
8812 + if(!(data->length = param.current_ev - extra)) {
8813 + printk("%s(): data length %d\n", __FUNCTION__, data->length);
8814 + return -EAGAIN;
8815 + }
8816 + return 0;
8817 +}
8818 +
8819 +extern int reconnect_flag;
8820 +/* SIOCSIWESSID */
8821 +static int
8822 +ar6000_ioctl_siwessid(struct net_device *dev,
8823 + struct iw_request_info *info,
8824 + struct iw_point *data, char *ssid)
8825 +{
8826 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
8827 + A_STATUS status;
8828 + A_UINT8 arNetworkType;
8829 +
8830 + if (ar->arWlanState == WLAN_DISABLED) {
8831 + return -EIO;
8832 + }
8833 +
8834 + if (ar->arWmiReady == FALSE) {
8835 + return -EIO;
8836 + }
8837 +
8838 + /*
8839 + * iwconfig passes a null terminated string with length including this
8840 + * so we need to account for this
8841 + */
8842 + if (data->flags && (!data->length || (data->length == 1) ||
8843 + ((data->length - 1) > sizeof(ar->arSsid))))
8844 + {
8845 + /*
8846 + * ssid is invalid
8847 + */
8848 + return -EINVAL;
8849 + }
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.
8853 + */
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])))
8859 + {
8860 + return -EINVAL;
8861 + }
8862 + }
8863 +
8864 + if (down_interruptible(&ar->arSem)) {
8865 + return -ERESTARTSYS;
8866 + }
8867 +
8868 + if (ar->arTxPending[WMI_CONTROL_PRI]) {
8869 + /*
8870 + * sleep until the command queue drains
8871 + */
8872 + wait_event_interruptible_timeout(arEvent,
8873 + ar->arTxPending[WMI_CONTROL_PRI] == 0, wmitimeout * HZ);
8874 + if (signal_pending(current)) {
8875 + return -EINTR;
8876 + }
8877 + }
8878 +
8879 + if (!data->flags) {
8880 + arNetworkType = ar->arNetworkType;
8881 + ar6000_init_profile_info(ar);
8882 + ar->arNetworkType = arNetworkType;
8883 + }
8884 +
8885 + if ((ar->arSsidLen) || (!data->flags))
8886 + {
8887 + if ((!data->flags) ||
8888 + (A_MEMCMP(ar->arSsid, ssid, ar->arSsidLen) != 0) ||
8889 + (ar->arSsidLen != (data->length)))
8890 + {
8891 + /*
8892 + * SSID set previously or essid off has been issued.
8893 + *
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
8897 + *
8898 + */
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));
8906 + }
8907 + if (!data->flags) {
8908 + up(&ar->arSem);
8909 + return 0;
8910 + }
8911 + } else {
8912 + up(&ar->arSem);
8913 + }
8914 + }
8915 + else
8916 + {
8917 + /*
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
8921 + * connected.
8922 + */
8923 + if((ar->arConnected == TRUE) && (ar->arWmiReady == TRUE))
8924 + {
8925 + reconnect_flag = TRUE;
8926 + status = wmi_reconnect_cmd(ar->arWmi,ar->arReqBssid,
8927 + ar->arChannelHint);
8928 + up(&ar->arSem);
8929 + if (status != A_OK) {
8930 + return -EIO;
8931 + }
8932 + return 0;
8933 + }
8934 + else{
8935 + /*
8936 + * Dont return if connect is pending.
8937 + */
8938 + if(!(ar->arConnectPending)) {
8939 + up(&ar->arSem);
8940 + return 0;
8941 + }
8942 + }
8943 + }
8944 + }
8945 +
8946 + ar->arSsidLen = data->length;
8947 + A_MEMCPY(ar->arSsid, ssid, ar->arSsidLen);
8948 +
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.
8951 + */
8952 + if((ar->arWmiReady == TRUE) && (ar->arSsidLen > 0) )
8953 + {
8954 + AR6000_SPIN_LOCK(&ar->arLock, 0);
8955 + if (SHARED_AUTH == ar->arDot11AuthMode) {
8956 + ar6000_install_static_wep_keys(ar);
8957 + }
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);
8973 +
8974 +
8975 + up(&ar->arSem);
8976 +
8977 + if (status != A_OK) {
8978 + return -EIO;
8979 + }
8980 + ar->arConnectPending = TRUE;
8981 + }else{
8982 + up(&ar->arSem);
8983 + }
8984 + return 0;
8985 +}
8986 +
8987 +/* SIOCGIWESSID */
8988 +static int
8989 +ar6000_ioctl_giwessid(struct net_device *dev,
8990 + struct iw_request_info *info,
8991 + struct iw_point *data, char *essid)
8992 +{
8993 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
8994 +
8995 + if (ar->arWlanState == WLAN_DISABLED) {
8996 + return -EIO;
8997 + }
8998 +
8999 + if (!ar->arSsidLen) {
9000 + return -EINVAL;
9001 + }
9002 +
9003 + data->flags = 1;
9004 + data->length = ar->arSsidLen;
9005 + A_MEMCPY(essid, ar->arSsid, ar->arSsidLen);
9006 +
9007 + return 0;
9008 +}
9009 +
9010 +
9011 +void ar6000_install_static_wep_keys(AR_SOFTC_T *ar)
9012 +{
9013 + A_UINT8 index;
9014 + A_UINT8 keyUsage;
9015 +
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;
9021 + }
9022 + wmi_addKey_cmd(ar->arWmi,
9023 + index,
9024 + WEP_CRYPT,
9025 + keyUsage,
9026 + ar->arWepKeyList[index].arKeyLen,
9027 + NULL,
9028 + ar->arWepKeyList[index].arKey, KEY_OP_INIT_VAL,
9029 + NO_SYNC_WMIFLAG);
9030 + }
9031 + }
9032 +}
9033 +
9034 +int
9035 +ar6000_ioctl_delkey(struct net_device *dev, struct iw_request_info *info,
9036 + void *w, char *extra)
9037 +{
9038 + return 0;
9039 +}
9040 +
9041 +int
9042 +ar6000_ioctl_setmlme(struct net_device *dev, struct iw_request_info *info,
9043 + void *w, char *extra)
9044 +{
9045 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9046 + struct ieee80211req_mlme *mlme = (struct ieee80211req_mlme *)extra;
9047 +
9048 + if ((ar->arWmiReady == FALSE) || (ar->arConnected != TRUE))
9049 + return -EIO;
9050 +
9051 + switch (mlme->im_op) {
9052 + case IEEE80211_MLME_DISASSOC:
9053 + case IEEE80211_MLME_DEAUTH:
9054 + /* Not Supported */
9055 + break;
9056 + default:
9057 + break;
9058 + }
9059 + return 0;
9060 +}
9061 +
9062 +
9063 +int
9064 +ar6000_ioctl_setwmmparams(struct net_device *dev, struct iw_request_info *info,
9065 + void *w, char *extra)
9066 +{
9067 + return -EIO; /* for now */
9068 +}
9069 +
9070 +int
9071 +ar6000_ioctl_getwmmparams(struct net_device *dev, struct iw_request_info *info,
9072 + void *w, char *extra)
9073 +{
9074 + return -EIO; /* for now */
9075 +}
9076 +
9077 +int ar6000_ioctl_setoptie(struct net_device *dev, struct iw_request_info *info,
9078 + struct iw_point *data, char *extra)
9079 +{
9080 + /* The target generates the WPA/RSN IE */
9081 + return 0;
9082 +}
9083 +
9084 +int
9085 +ar6000_ioctl_setauthalg(struct net_device *dev, struct iw_request_info *info,
9086 + void *w, char *extra)
9087 +{
9088 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9089 + struct ieee80211req_authalg *req = (struct ieee80211req_authalg *)extra;
9090 + int ret = 0;
9091 +
9092 +
9093 + AR6000_SPIN_LOCK(&ar->arLock, 0);
9094 +
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;
9101 + } else {
9102 + ret = -EIO;
9103 + }
9104 +
9105 + AR6000_SPIN_UNLOCK(&ar->arLock, 0);
9106 +
9107 + return ret;
9108 +}
9109 +static int
9110 +ar6000_ioctl_addpmkid(struct net_device *dev, struct iw_request_info *info,
9111 + void *w, char *extra)
9112 +{
9113 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9114 + struct ieee80211req_addpmkid *req = (struct ieee80211req_addpmkid *)extra;
9115 + A_STATUS status;
9116 +
9117 + if (ar->arWlanState == WLAN_DISABLED) {
9118 + return -EIO;
9119 + }
9120 +
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],
9124 + req->pi_enable);
9125 +
9126 + status = wmi_setPmkid_cmd(ar->arWmi, req->pi_bssid, req->pi_pmkid,
9127 + req->pi_enable);
9128 +
9129 + if (status != A_OK) {
9130 + return -EIO;
9131 + }
9132 +
9133 + return 0;
9134 +}
9135 +
9136 +/*
9137 + * SIOCSIWRATE
9138 + */
9139 +int
9140 +ar6000_ioctl_siwrate(struct net_device *dev,
9141 + struct iw_request_info *info,
9142 + struct iw_param *rrq, char *extra)
9143 +{
9144 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9145 + A_UINT32 kbps;
9146 +
9147 + if (rrq->fixed) {
9148 + kbps = rrq->value / 1000; /* rrq->value is in bps */
9149 + } else {
9150 + kbps = -1; /* -1 indicates auto rate */
9151 + }
9152 + if(kbps != -1 && wmi_validate_bitrate(ar->arWmi, kbps) == A_EINVAL)
9153 + {
9154 + AR_DEBUG_PRINTF("BitRate is not Valid %d\n", kbps);
9155 + return -EINVAL;
9156 + }
9157 + ar->arBitRate = kbps;
9158 + if(ar->arWmiReady == TRUE)
9159 + {
9160 + if (wmi_set_bitrate_cmd(ar->arWmi, kbps) != A_OK) {
9161 + return -EINVAL;
9162 + }
9163 + }
9164 + return 0;
9165 +}
9166 +
9167 +/*
9168 + * SIOCGIWRATE
9169 + */
9170 +int
9171 +ar6000_ioctl_giwrate(struct net_device *dev,
9172 + struct iw_request_info *info,
9173 + struct iw_param *rrq, char *extra)
9174 +{
9175 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9176 + int ret = 0;
9177 +
9178 + if (down_interruptible(&ar->arSem)) {
9179 + return -ERESTARTSYS;
9180 + }
9181 + if(ar->arWmiReady == TRUE)
9182 + {
9183 + ar->arBitRate = 0xFFFF;
9184 + if (wmi_get_bitrate_cmd(ar->arWmi) != A_OK) {
9185 + up(&ar->arSem);
9186 + return -EIO;
9187 + }
9188 + wait_event_interruptible_timeout(arEvent, ar->arBitRate != 0xFFFF, wmitimeout * HZ);
9189 + if (signal_pending(current)) {
9190 + ret = -EINTR;
9191 + }
9192 + }
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 */
9195 + if (!ret) {
9196 + if (ar->arBitRate == -1) {
9197 + rrq->fixed = TRUE;
9198 + rrq->value = 0;
9199 + } else {
9200 + rrq->value = ar->arBitRate * 1000;
9201 + }
9202 + }
9203 +
9204 + up(&ar->arSem);
9205 +
9206 + return ret;
9207 +}
9208 +
9209 +/*
9210 + * SIOCSIWTXPOW
9211 + */
9212 +static int
9213 +ar6000_ioctl_siwtxpow(struct net_device *dev,
9214 + struct iw_request_info *info,
9215 + struct iw_param *rrq, char *extra)
9216 +{
9217 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9218 + A_UINT8 dbM;
9219 +
9220 + if (ar->arWlanState == WLAN_DISABLED) {
9221 + return -EIO;
9222 + }
9223 +
9224 + if (rrq->disabled) {
9225 + return -EOPNOTSUPP;
9226 + }
9227 +
9228 + if (rrq->fixed) {
9229 + if (rrq->flags != IW_TXPOW_DBM) {
9230 + return -EOPNOTSUPP;
9231 + }
9232 + ar->arTxPwr= dbM = rrq->value;
9233 + ar->arTxPwrSet = TRUE;
9234 + } else {
9235 + ar->arTxPwr = dbM = 0;
9236 + ar->arTxPwrSet = FALSE;
9237 + }
9238 + if(ar->arWmiReady == TRUE)
9239 + {
9240 + AR_DEBUG_PRINTF("Set tx pwr cmd %d dbM\n", dbM);
9241 + wmi_set_txPwr_cmd(ar->arWmi, dbM);
9242 + }
9243 + return 0;
9244 +}
9245 +
9246 +/*
9247 + * SIOCGIWTXPOW
9248 + */
9249 +int
9250 +ar6000_ioctl_giwtxpow(struct net_device *dev,
9251 + struct iw_request_info *info,
9252 + struct iw_param *rrq, char *extra)
9253 +{
9254 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9255 + int ret = 0;
9256 +
9257 + if (ar->arWlanState == WLAN_DISABLED) {
9258 + return -EIO;
9259 + }
9260 +
9261 + if (down_interruptible(&ar->arSem)) {
9262 + return -ERESTARTSYS;
9263 + }
9264 + if((ar->arWmiReady == TRUE) && (ar->arConnected == TRUE))
9265 + {
9266 + ar->arTxPwr = 0;
9267 +
9268 + if (wmi_get_txPwr_cmd(ar->arWmi) != A_OK) {
9269 + up(&ar->arSem);
9270 + return -EIO;
9271 + }
9272 +
9273 + wait_event_interruptible_timeout(arEvent, ar->arTxPwr != 0, wmitimeout * HZ);
9274 +
9275 + if (signal_pending(current)) {
9276 + ret = -EINTR;
9277 + }
9278 + }
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 */
9281 +
9282 + if (!ret) {
9283 + if (ar->arTxPwrSet == TRUE) {
9284 + rrq->fixed = TRUE;
9285 + }
9286 + rrq->value = ar->arTxPwr;
9287 + rrq->flags = IW_TXPOW_DBM;
9288 + }
9289 +
9290 + up(&ar->arSem);
9291 +
9292 + return ret;
9293 +}
9294 +
9295 +/*
9296 + * SIOCSIWRETRY
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.
9299 + */
9300 +static int
9301 +ar6000_ioctl_siwretry(struct net_device *dev,
9302 + struct iw_request_info *info,
9303 + struct iw_param *rrq, char *extra)
9304 +{
9305 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9306 +
9307 + if (ar->arWlanState == WLAN_DISABLED) {
9308 + return -EIO;
9309 + }
9310 +
9311 + if (rrq->disabled) {
9312 + return -EOPNOTSUPP;
9313 + }
9314 +
9315 + if ((rrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) {
9316 + return -EOPNOTSUPP;
9317 + }
9318 +
9319 + if ( !(rrq->value >= WMI_MIN_RETRIES) || !(rrq->value <= WMI_MAX_RETRIES)) {
9320 + return - EINVAL;
9321 + }
9322 + if(ar->arWmiReady == TRUE)
9323 + {
9324 + if (wmi_set_retry_limits_cmd(ar->arWmi, DATA_FRAMETYPE, WMM_AC_BE,
9325 + rrq->value, 0) != A_OK){
9326 + return -EINVAL;
9327 + }
9328 + }
9329 + ar->arMaxRetries = rrq->value;
9330 + return 0;
9331 +}
9332 +
9333 +/*
9334 + * SIOCGIWRETRY
9335 + */
9336 +static int
9337 +ar6000_ioctl_giwretry(struct net_device *dev,
9338 + struct iw_request_info *info,
9339 + struct iw_param *rrq, char *extra)
9340 +{
9341 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9342 +
9343 + if (ar->arWlanState == WLAN_DISABLED) {
9344 + return -EIO;
9345 + }
9346 +
9347 + rrq->disabled = 0;
9348 + switch (rrq->flags & IW_RETRY_TYPE) {
9349 + case IW_RETRY_LIFETIME:
9350 + return -EOPNOTSUPP;
9351 + break;
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;
9358 + break;
9359 + case IW_RETRY_MAX:
9360 + rrq->flags |= IW_RETRY_MAX;
9361 + rrq->value = ar->arMaxRetries;
9362 + break;
9363 + }
9364 + break;
9365 + }
9366 + return 0;
9367 +}
9368 +
9369 +/*
9370 + * SIOCSIWENCODE
9371 + */
9372 +static int
9373 +ar6000_ioctl_siwencode(struct net_device *dev,
9374 + struct iw_request_info *info,
9375 + struct iw_point *erq, char *keybuf)
9376 +{
9377 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9378 + int index;
9379 + A_INT32 auth = ar->arDot11AuthMode;
9380 + /*
9381 + * Static WEP Keys should be configured before setting the SSID
9382 + */
9383 + if (ar->arSsidLen) {
9384 + return -EIO;
9385 + }
9386 +
9387 + if (ar->arWlanState == WLAN_DISABLED) {
9388 + return -EIO;
9389 + }
9390 +
9391 + index = erq->flags & IW_ENCODE_INDEX;
9392 +
9393 + if (index && (((index - 1) < WMI_MIN_KEY_INDEX) ||
9394 + ((index - 1) > WMI_MAX_KEY_INDEX)))
9395 + {
9396 + return -EIO;
9397 + }
9398 +
9399 + if (erq->flags & IW_ENCODE_DISABLED) {
9400 + /*
9401 + * Encryption disabled
9402 + */
9403 + if (index) {
9404 + /*
9405 + * If key index was specified then clear the specified key
9406 + */
9407 + index--;
9408 + A_MEMZERO(ar->arWepKeyList[index].arKey,
9409 + sizeof(ar->arWepKeyList[index].arKey));
9410 + ar->arWepKeyList[index].arKeyLen = 0;
9411 + }
9412 + ar->arDot11AuthMode = OPEN_AUTH;
9413 + ar->arPairwiseCrypto = NONE_CRYPT;
9414 + ar->arGroupCrypto = NONE_CRYPT;
9415 + ar->arAuthMode = NONE_AUTH;
9416 + } else {
9417 + /*
9418 + * Enabling WEP encryption
9419 + */
9420 + if (index) {
9421 + index--; /* keyindex is off base 1 in iwconfig */
9422 + }
9423 +
9424 + if (erq->flags & IW_ENCODE_OPEN) {
9425 + auth = OPEN_AUTH;
9426 + } else if (erq->flags & IW_ENCODE_RESTRICTED) {
9427 + auth = SHARED_AUTH;
9428 + }
9429 +
9430 + if (erq->length) {
9431 + if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(erq->length)) {
9432 + return -EIO;
9433 + }
9434 +
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;
9439 + } else {
9440 + if (ar->arWepKeyList[index].arKeyLen == 0) {
9441 + return -EIO;
9442 + }
9443 + ar->arDefTxKeyIndex = index;
9444 + }
9445 +
9446 + ar->arPairwiseCrypto = WEP_CRYPT;
9447 + ar->arGroupCrypto = WEP_CRYPT;
9448 + ar->arDot11AuthMode = auth;
9449 + ar->arAuthMode = NONE_AUTH;
9450 + }
9451 +
9452 + /*
9453 + * profile has changed. Erase ssid to signal change
9454 + */
9455 + A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
9456 +
9457 + return 0;
9458 +}
9459 +
9460 +static int
9461 +ar6000_ioctl_giwencode(struct net_device *dev,
9462 + struct iw_request_info *info,
9463 + struct iw_point *erq, char *key)
9464 +{
9465 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9466 + A_UINT8 keyIndex;
9467 + struct ar_wep_key *wk;
9468 +
9469 + if (ar->arWlanState == WLAN_DISABLED) {
9470 + return -EIO;
9471 + }
9472 +
9473 + if (ar->arPairwiseCrypto == NONE_CRYPT) {
9474 + erq->length = 0;
9475 + erq->flags = IW_ENCODE_DISABLED;
9476 + } else {
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))
9483 + {
9484 + keyIndex = WMI_MIN_KEY_INDEX;
9485 + } else {
9486 + keyIndex--;
9487 + }
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;
9493 + }
9494 + if (wk->arKeyLen) {
9495 + A_MEMCPY(key, wk->arKey, erq->length);
9496 + }
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;
9501 + }
9502 + }
9503 +
9504 + return 0;
9505 +}
9506 +
9507 +static int ar6000_ioctl_siwpower(struct net_device *dev,
9508 + struct iw_request_info *info,
9509 + union iwreq_data *wrqu, char *extra)
9510 +{
9511 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9512 + WMI_POWER_MODE power_mode;
9513 +
9514 + if (wrqu->power.disabled)
9515 + power_mode = MAX_PERF_POWER;
9516 + else
9517 + power_mode = REC_POWER;
9518 +
9519 + if (wmi_powermode_cmd(ar->arWmi, power_mode) < 0)
9520 + return -EIO;
9521 +
9522 + return 0;
9523 +}
9524 +
9525 +static int ar6000_ioctl_giwpower(struct net_device *dev,
9526 + struct iw_request_info *info,
9527 + union iwreq_data *wrqu, char *extra)
9528 +{
9529 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9530 +
9531 + return wmi_get_power_mode_cmd(ar->arWmi);
9532 +}
9533 +
9534 +static int ar6000_ioctl_siwgenie(struct net_device *dev,
9535 + struct iw_request_info *info,
9536 + struct iw_point *dwrq,
9537 + char *extra)
9538 +{
9539 + /* The target does that for us */
9540 + return 0;
9541 +}
9542 +
9543 +static int ar6000_ioctl_giwgenie(struct net_device *dev,
9544 + struct iw_request_info *info,
9545 + struct iw_point *dwrq,
9546 + char *extra)
9547 +{
9548 + return 0;
9549 +}
9550 +
9551 +static int ar6000_ioctl_siwauth(struct net_device *dev,
9552 + struct iw_request_info *info,
9553 + struct iw_param *param,
9554 + char *extra)
9555 +{
9556 + AR_SOFTC_T *ar = (AR_SOFTC_T *)netdev_priv(dev);
9557 + int reset = 0;
9558 +
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;
9563 + }
9564 + if (param->value & IW_AUTH_WPA_VERSION_WPA) {
9565 + ar->arAuthMode = WPA_AUTH;
9566 + }
9567 + if (param->value & IW_AUTH_WPA_VERSION_WPA2) {
9568 + ar->arAuthMode = WPA2_AUTH;
9569 + }
9570 +
9571 + reset = 1;
9572 + break;
9573 + case IW_AUTH_CIPHER_PAIRWISE:
9574 + if (param->value & IW_AUTH_CIPHER_NONE) {
9575 + ar->arPairwiseCrypto = NONE_CRYPT;
9576 + }
9577 + if (param->value & IW_AUTH_CIPHER_WEP40) {
9578 + ar->arPairwiseCrypto = WEP_CRYPT;
9579 + }
9580 + if (param->value & IW_AUTH_CIPHER_TKIP) {
9581 + ar->arPairwiseCrypto = TKIP_CRYPT;
9582 + }
9583 + if (param->value & IW_AUTH_CIPHER_CCMP) {
9584 + ar->arPairwiseCrypto = AES_CRYPT;
9585 + }
9586 +
9587 + reset = 1;
9588 + break;
9589 + case IW_AUTH_CIPHER_GROUP:
9590 + if (param->value & IW_AUTH_CIPHER_NONE) {
9591 + ar->arGroupCrypto = NONE_CRYPT;
9592 + }
9593 + if (param->value & IW_AUTH_CIPHER_WEP40) {
9594 + ar->arGroupCrypto = WEP_CRYPT;
9595 + }
9596 + if (param->value & IW_AUTH_CIPHER_TKIP) {
9597 + ar->arGroupCrypto = TKIP_CRYPT;
9598 + }
9599 + if (param->value & IW_AUTH_CIPHER_CCMP) {
9600 + ar->arGroupCrypto = AES_CRYPT;
9601 + }
9602 +
9603 + reset = 1;
9604 + break;
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;
9611 + }
9612 +
9613 + reset = 1;
9614 + }
9615 + break;
9616 +
9617 + case IW_AUTH_TKIP_COUNTERMEASURES:
9618 + if (ar->arWmiReady == FALSE) {
9619 + return -EIO;
9620 + }
9621 + wmi_set_tkip_countermeasures_cmd(ar->arWmi, param->value);
9622 + break;
9623 +
9624 + case IW_AUTH_DROP_UNENCRYPTED:
9625 + break;
9626 +
9627 + case IW_AUTH_80211_AUTH_ALG:
9628 + if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
9629 + ar->arDot11AuthMode = OPEN_AUTH;
9630 + }
9631 + if (param->value & IW_AUTH_ALG_SHARED_KEY) {
9632 + ar->arDot11AuthMode = SHARED_AUTH;
9633 + }
9634 + if (param->value & IW_AUTH_ALG_LEAP) {
9635 + ar->arDot11AuthMode = LEAP_AUTH;
9636 + ar->arPairwiseCrypto = WEP_CRYPT;
9637 + ar->arGroupCrypto = WEP_CRYPT;
9638 + }
9639 +
9640 + reset = 1;
9641 + break;
9642 +
9643 + case IW_AUTH_WPA_ENABLED:
9644 + reset = 1;
9645 + break;
9646 +
9647 + case IW_AUTH_RX_UNENCRYPTED_EAPOL:
9648 + break;
9649 +
9650 + case IW_AUTH_PRIVACY_INVOKED:
9651 + break;
9652 +
9653 + default:
9654 + printk("%s(): Unknown flag 0x%x\n", __FUNCTION__, param->flags);
9655 + return -EOPNOTSUPP;
9656 + }
9657 +
9658 + if (reset)
9659 + memset(ar->arSsid, 0, sizeof(ar->arSsid));
9660 +
9661 + return 0;
9662 +}
9663 +
9664 +static int ar6000_ioctl_giwauth(struct net_device *dev,
9665 + struct iw_request_info *info,
9666 + struct iw_param *dwrq,
9667 + char *extra)
9668 +{
9669 + return 0;
9670 +}
9671 +
9672 +static int ar6000_ioctl_siwencodeext(struct net_device *dev,
9673 + struct iw_request_info *info,
9674 + union iwreq_data *wrqu,
9675 + char *extra)
9676 +{
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;
9681 +
9682 + if (ar->arWlanState == WLAN_DISABLED) {
9683 + return -EIO;
9684 + }
9685 +
9686 + /* Determine and validate the key index */
9687 + idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
9688 + if (idx) {
9689 + if (idx < 0 || idx > 3)
9690 + return -EINVAL;
9691 + }
9692 +
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;
9697 + int status;
9698 +
9699 + ar->user_saved_keys.keyOk = FALSE;
9700 +
9701 + if (alg == IW_ENCODE_ALG_TKIP) {
9702 + key_type = TKIP_CRYPT;
9703 + ik.ik_type = IEEE80211_CIPHER_TKIP;
9704 + } else {
9705 + key_type = AES_CRYPT;
9706 + ik.ik_type = IEEE80211_CIPHER_AES_CCM;
9707 + }
9708 +
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;
9715 + }
9716 +
9717 + if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
9718 + memcpy(&ik.ik_keyrsc, ext->rx_seq, 8);
9719 + }
9720 +
9721 + memcpy(ik.ik_keydata, ext->key, ext->key_len);
9722 +
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));
9729 + } else {
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));
9734 + }
9735 +
9736 + status = wmi_addKey_cmd(ar->arWmi, ik.ik_keyix, key_type,
9737 + key_usage, ik.ik_keylen,
9738 + (A_UINT8 *)&ik.ik_keyrsc,
9739 + ik.ik_keydata,
9740 + KEY_OP_INIT_VAL, SYNC_BEFORE_WMIFLAG);
9741 +
9742 + if (status < 0)
9743 + return -EIO;
9744 +
9745 + ar->user_saved_keys.keyOk = TRUE;
9746 +
9747 + return 0;
9748 +
9749 + } else {
9750 + /* WEP falls back to SIWENCODE */
9751 + return -EOPNOTSUPP;
9752 + }
9753 +
9754 + return 0;
9755 +}
9756 +
9757 +
9758 +static int ar6000_ioctl_giwencodeext(struct net_device *dev,
9759 + struct iw_request_info *info,
9760 + struct iw_point *dwrq,
9761 + char *extra)
9762 +{
9763 + return 0;
9764 +}
9765 +
9766 +
9767 +static int
9768 +ar6000_ioctl_setparam(struct net_device *dev,
9769 + struct iw_request_info *info,
9770 + void *erq, char *extra)
9771 +{
9772 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9773 + int *i = (int *)extra;
9774 + int param = i[0];
9775 + int value = i[1];
9776 + int ret = 0;
9777 + A_BOOL profChanged = FALSE;
9778 +
9779 + if (ar->arWlanState == WLAN_DISABLED) {
9780 + return -EIO;
9781 + }
9782 +
9783 + switch (param) {
9784 + case IEEE80211_PARAM_WPA:
9785 + switch (value) {
9786 + case WPA_MODE_WPA1:
9787 + ar->arAuthMode = WPA_AUTH;
9788 + profChanged = TRUE;
9789 + break;
9790 + case WPA_MODE_WPA2:
9791 + ar->arAuthMode = WPA2_AUTH;
9792 + profChanged = TRUE;
9793 + break;
9794 + case WPA_MODE_NONE:
9795 + ar->arAuthMode = NONE_AUTH;
9796 + profChanged = TRUE;
9797 + break;
9798 + default:
9799 + printk("IEEE80211_PARAM_WPA: Unknown value %d\n", value);
9800 + }
9801 + break;
9802 + case IEEE80211_PARAM_AUTHMODE:
9803 + switch(value) {
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;
9811 + } else {
9812 + AR_DEBUG_PRINTF("Error - Setting PSK mode when WPA "\
9813 + "param was set to %d\n",
9814 + ar->arAuthMode);
9815 + ret = -1;
9816 + }
9817 + break;
9818 + case IEEE80211_AUTH_WPA_CCKM:
9819 + if (WPA2_AUTH == ar->arAuthMode) {
9820 + ar->arAuthMode = WPA2_AUTH_CCKM;
9821 + } else {
9822 + ar->arAuthMode = WPA_AUTH_CCKM;
9823 + }
9824 + break;
9825 + default:
9826 + break;
9827 + }
9828 + break;
9829 + case IEEE80211_PARAM_UCASTCIPHER:
9830 + switch (value) {
9831 + case IEEE80211_CIPHER_AES_CCM:
9832 + ar->arPairwiseCrypto = AES_CRYPT;
9833 + profChanged = TRUE;
9834 + break;
9835 + case IEEE80211_CIPHER_TKIP:
9836 + ar->arPairwiseCrypto = TKIP_CRYPT;
9837 + profChanged = TRUE;
9838 + break;
9839 + case IEEE80211_CIPHER_WEP:
9840 + ar->arPairwiseCrypto = WEP_CRYPT;
9841 + profChanged = TRUE;
9842 + break;
9843 + case IEEE80211_CIPHER_NONE:
9844 + ar->arPairwiseCrypto = NONE_CRYPT;
9845 + profChanged = TRUE;
9846 + break;
9847 + }
9848 + break;
9849 + case IEEE80211_PARAM_UCASTKEYLEN:
9850 + if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
9851 + ret = -EIO;
9852 + } else {
9853 + ar->arPairwiseCryptoLen = value;
9854 + }
9855 + break;
9856 + case IEEE80211_PARAM_MCASTCIPHER:
9857 + switch (value) {
9858 + case IEEE80211_CIPHER_AES_CCM:
9859 + ar->arGroupCrypto = AES_CRYPT;
9860 + profChanged = TRUE;
9861 + break;
9862 + case IEEE80211_CIPHER_TKIP:
9863 + ar->arGroupCrypto = TKIP_CRYPT;
9864 + profChanged = TRUE;
9865 + break;
9866 + case IEEE80211_CIPHER_WEP:
9867 + ar->arGroupCrypto = WEP_CRYPT;
9868 + profChanged = TRUE;
9869 + break;
9870 + case IEEE80211_CIPHER_NONE:
9871 + ar->arGroupCrypto = NONE_CRYPT;
9872 + profChanged = TRUE;
9873 + break;
9874 + }
9875 + break;
9876 + case IEEE80211_PARAM_MCASTKEYLEN:
9877 + if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
9878 + ret = -EIO;
9879 + } else {
9880 + ar->arGroupCryptoLen = value;
9881 + }
9882 + break;
9883 + case IEEE80211_PARAM_COUNTERMEASURES:
9884 + if (ar->arWmiReady == FALSE) {
9885 + return -EIO;
9886 + }
9887 + wmi_set_tkip_countermeasures_cmd(ar->arWmi, value);
9888 + break;
9889 + default:
9890 + break;
9891 + }
9892 +
9893 + if (profChanged == TRUE) {
9894 + /*
9895 + * profile has changed. Erase ssid to signal change
9896 + */
9897 + A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
9898 + }
9899 +
9900 + return ret;
9901 +}
9902 +
9903 +int
9904 +ar6000_ioctl_getparam(struct net_device *dev, struct iw_request_info *info,
9905 + void *w, char *extra)
9906 +{
9907 + return -EIO; /* for now */
9908 +}
9909 +
9910 +int
9911 +ar6000_ioctl_setkey(struct net_device *dev, struct iw_request_info *info,
9912 + void *w, char *extra)
9913 +{
9914 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9915 + struct ieee80211req_key *ik = (struct ieee80211req_key *)extra;
9916 + KEY_USAGE keyUsage;
9917 + A_STATUS status;
9918 + CRYPTO_TYPE keyType = NONE_CRYPT;
9919 +
9920 + if (ar->arWlanState == WLAN_DISABLED) {
9921 + return -EIO;
9922 + }
9923 +
9924 + ar->user_saved_keys.keyOk = FALSE;
9925 +
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));
9931 + } else {
9932 + keyUsage = PAIRWISE_USAGE;
9933 + A_MEMCPY(&ar->user_saved_keys.ucast_ik, ik,
9934 + sizeof(struct ieee80211req_key));
9935 + }
9936 +
9937 + switch (ik->ik_type) {
9938 + case IEEE80211_CIPHER_WEP:
9939 + keyType = WEP_CRYPT;
9940 + break;
9941 + case IEEE80211_CIPHER_TKIP:
9942 + keyType = TKIP_CRYPT;
9943 + break;
9944 + case IEEE80211_CIPHER_AES_CCM:
9945 + keyType = AES_CRYPT;
9946 + break;
9947 + default:
9948 + break;
9949 + }
9950 + ar->user_saved_keys.keyType = keyType;
9951 +
9952 + if (IEEE80211_CIPHER_CCKM_KRK != ik->ik_type) {
9953 + if (NONE_CRYPT == keyType) {
9954 + return -EIO;
9955 + }
9956 +
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);
9961 +
9962 + if (status != A_OK) {
9963 + return -EIO;
9964 + }
9965 + } else {
9966 + status = wmi_add_krk_cmd(ar->arWmi, ik->ik_keydata);
9967 + }
9968 +
9969 + ar->user_saved_keys.keyOk = TRUE;
9970 +
9971 + return 0;
9972 +}
9973 +
9974 +
9975 +/*
9976 + * SIOCGIWNAME
9977 + */
9978 +int
9979 +ar6000_ioctl_giwname(struct net_device *dev,
9980 + struct iw_request_info *info,
9981 + char *name, char *extra)
9982 +{
9983 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
9984 +
9985 + if (ar->arWlanState == WLAN_DISABLED) {
9986 + return -EIO;
9987 + }
9988 +
9989 + switch (ar->arPhyCapability) {
9990 + case (WMI_11A_CAPABILITY):
9991 + strncpy(name, "AR6000 802.11a", IFNAMSIZ);
9992 + break;
9993 + case (WMI_11G_CAPABILITY):
9994 + strncpy(name, "AR6000 802.11g", IFNAMSIZ);
9995 + break;
9996 + case (WMI_11AG_CAPABILITY):
9997 + strncpy(name, "AR6000 802.11ag", IFNAMSIZ);
9998 + break;
9999 + default:
10000 + strncpy(name, "AR6000 802.11", IFNAMSIZ);
10001 + break;
10002 + }
10003 +
10004 + return 0;
10005 +}
10006 +
10007 +/*
10008 + * SIOCSIWFREQ
10009 + */
10010 +int
10011 +ar6000_ioctl_siwfreq(struct net_device *dev,
10012 + struct iw_request_info *info,
10013 + struct iw_freq *freq, char *extra)
10014 +{
10015 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10016 +
10017 + if (ar->arWlanState == WLAN_DISABLED) {
10018 + return -EIO;
10019 + }
10020 +
10021 + /*
10022 + * We support limiting the channels via wmiconfig.
10023 + *
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
10026 + * channel.
10027 + */
10028 + if (freq->e > 1) {
10029 + return -EINVAL;
10030 + } else if (freq->e == 1) {
10031 + ar->arChannelHint = freq->m / 100000;
10032 + } else {
10033 + ar->arChannelHint = wlan_ieee2freq(freq->m);
10034 + }
10035 +
10036 + A_PRINTF("channel hint set to %d\n", ar->arChannelHint);
10037 + return 0;
10038 +}
10039 +
10040 +/*
10041 + * SIOCGIWFREQ
10042 + */
10043 +int
10044 +ar6000_ioctl_giwfreq(struct net_device *dev,
10045 + struct iw_request_info *info,
10046 + struct iw_freq *freq, char *extra)
10047 +{
10048 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10049 +
10050 + if (ar->arWlanState == WLAN_DISABLED) {
10051 + return -EIO;
10052 + }
10053 +
10054 + if (ar->arConnected != TRUE) {
10055 + return -EINVAL;
10056 + }
10057 +
10058 + freq->m = ar->arBssChannel * 100000;
10059 + freq->e = 1;
10060 +
10061 + return 0;
10062 +}
10063 +
10064 +/*
10065 + * SIOCSIWMODE
10066 + */
10067 +int
10068 +ar6000_ioctl_siwmode(struct net_device *dev,
10069 + struct iw_request_info *info,
10070 + __u32 *mode, char *extra)
10071 +{
10072 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10073 +
10074 + if (ar->arWlanState == WLAN_DISABLED) {
10075 + return -EIO;
10076 + }
10077 +
10078 + switch (*mode) {
10079 + case IW_MODE_INFRA:
10080 + ar->arNetworkType = INFRA_NETWORK;
10081 + break;
10082 + case IW_MODE_ADHOC:
10083 + ar->arNetworkType = ADHOC_NETWORK;
10084 + break;
10085 + default:
10086 + return -EINVAL;
10087 + }
10088 +
10089 + return 0;
10090 +}
10091 +
10092 +/*
10093 + * SIOCGIWMODE
10094 + */
10095 +int
10096 +ar6000_ioctl_giwmode(struct net_device *dev,
10097 + struct iw_request_info *info,
10098 + __u32 *mode, char *extra)
10099 +{
10100 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10101 +
10102 + if (ar->arWlanState == WLAN_DISABLED) {
10103 + return -EIO;
10104 + }
10105 +
10106 + switch (ar->arNetworkType) {
10107 + case INFRA_NETWORK:
10108 + *mode = IW_MODE_INFRA;
10109 + break;
10110 + case ADHOC_NETWORK:
10111 + *mode = IW_MODE_ADHOC;
10112 + break;
10113 + default:
10114 + return -EIO;
10115 + }
10116 + return 0;
10117 +}
10118 +
10119 +/*
10120 + * SIOCSIWSENS
10121 + */
10122 +int
10123 +ar6000_ioctl_siwsens(struct net_device *dev,
10124 + struct iw_request_info *info,
10125 + struct iw_param *sens, char *extra)
10126 +{
10127 + return 0;
10128 +}
10129 +
10130 +/*
10131 + * SIOCGIWSENS
10132 + */
10133 +int
10134 +ar6000_ioctl_giwsens(struct net_device *dev,
10135 + struct iw_request_info *info,
10136 + struct iw_param *sens, char *extra)
10137 +{
10138 + sens->value = 0;
10139 + sens->fixed = 1;
10140 +
10141 + return 0;
10142 +}
10143 +
10144 +/*
10145 + * SIOCGIWRANGE
10146 + */
10147 +int
10148 +ar6000_ioctl_giwrange(struct net_device *dev,
10149 + struct iw_request_info *info,
10150 + struct iw_point *data, char *extra)
10151 +{
10152 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10153 + struct iw_range *range = (struct iw_range *) extra;
10154 + int i, ret = 0;
10155 +
10156 + if (ar->arWmiReady == FALSE) {
10157 + return -EIO;
10158 + }
10159 +
10160 + if (ar->arWlanState == WLAN_DISABLED) {
10161 + return -EIO;
10162 + }
10163 +
10164 + if (down_interruptible(&ar->arSem)) {
10165 + return -ERESTARTSYS;
10166 + }
10167 + ar->arNumChannels = -1;
10168 + A_MEMZERO(ar->arChannelList, sizeof (ar->arChannelList));
10169 +
10170 + if (wmi_get_channelList_cmd(ar->arWmi) != A_OK) {
10171 + up(&ar->arSem);
10172 + return -EIO;
10173 + }
10174 +
10175 + wait_event_interruptible_timeout(arEvent, ar->arNumChannels != -1, wmitimeout * HZ);
10176 +
10177 + if (signal_pending(current)) {
10178 + up(&ar->arSem);
10179 + return -EINTR;
10180 + }
10181 +
10182 + data->length = sizeof(struct iw_range);
10183 + A_MEMZERO(range, sizeof(struct iw_range));
10184 +
10185 + range->txpower_capa = 0;
10186 +
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;
10194 +
10195 + range->we_version_compiled = WIRELESS_EXT;
10196 + range->we_version_source = 13;
10197 +
10198 + range->retry_capa = IW_RETRY_LIMIT;
10199 + range->retry_flags = IW_RETRY_LIMIT;
10200 + range->min_retry = 0;
10201 + range->max_retry = 255;
10202 +
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;
10208 + /*
10209 + * Linux supports max of 32 channels, bail out once you
10210 + * reach the max.
10211 + */
10212 + if (i == IW_MAX_FREQUENCIES) {
10213 + break;
10214 + }
10215 + }
10216 +
10217 + /* Max quality is max field value minus noise floor */
10218 + range->max_qual.qual = 0xff - 161;
10219 +
10220 + /*
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.
10226 + */
10227 + range->max_qual.level = 0;
10228 + range->max_qual.noise = 0;
10229 +
10230 + range->sensitivity = 3;
10231 +
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 */
10238 +
10239 + range->num_bitrates = 0;
10240 +
10241 + /* estimated maximum TCP throughput values (bps) */
10242 + range->throughput = 22000000;
10243 +
10244 + range->min_rts = 0;
10245 + range->max_rts = 2347;
10246 + range->min_frag = 256;
10247 + range->max_frag = 2346;
10248 +
10249 + up(&ar->arSem);
10250 +
10251 + return ret;
10252 +}
10253 +
10254 +
10255 +/*
10256 + * SIOCSIWAP
10257 + * This ioctl is used to set the desired bssid for the connect command.
10258 + */
10259 +int
10260 +ar6000_ioctl_siwap(struct net_device *dev,
10261 + struct iw_request_info *info,
10262 + struct sockaddr *ap_addr, char *extra)
10263 +{
10264 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10265 +
10266 + if (ar->arWlanState == WLAN_DISABLED) {
10267 + return -EIO;
10268 + }
10269 +
10270 + if (ap_addr->sa_family != ARPHRD_ETHER) {
10271 + return -EIO;
10272 + }
10273 +
10274 + if (A_MEMCMP(&ap_addr->sa_data, bcast_mac, AR6000_ETH_ADDR_LEN) == 0) {
10275 + A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
10276 + } else {
10277 + A_MEMCPY(ar->arReqBssid, &ap_addr->sa_data, sizeof(ar->arReqBssid));
10278 + }
10279 +
10280 + return 0;
10281 +}
10282 +
10283 +/*
10284 + * SIOCGIWAP
10285 + */
10286 +int
10287 +ar6000_ioctl_giwap(struct net_device *dev,
10288 + struct iw_request_info *info,
10289 + struct sockaddr *ap_addr, char *extra)
10290 +{
10291 + AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;
10292 +
10293 + if (ar->arWlanState == WLAN_DISABLED) {
10294 + return -EIO;
10295 + }
10296 +
10297 + if (ar->arConnected != TRUE) {
10298 + return -EINVAL;
10299 + }
10300 +
10301 + A_MEMCPY(&ap_addr->sa_data, ar->arBssid, sizeof(ar->arBssid));
10302 + ap_addr->sa_family = ARPHRD_ETHER;
10303 +
10304 + return 0;
10305 +}
10306 +
10307 +/*
10308 + * SIOCGIWAPLIST
10309 + */
10310 +int
10311 +ar6000_ioctl_iwaplist(struct net_device *dev,
10312 + struct iw_request_info *info,
10313 + struct iw_point *data, char *extra)
10314 +{
10315 + return -EIO; /* for now */
10316 +}
10317 +
10318 +/*
10319 + * SIOCSIWSCAN
10320 + */
10321 +int
10322 +ar6000_ioctl_siwscan(struct net_device *dev,
10323 + struct iw_request_info *info,
10324 + struct iw_point *data, char *extra)
10325 +{
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;
10330 + int ret = 0;
10331 +
10332 + if (ar->arWmiReady == FALSE) {
10333 + return -EIO;
10334 + }
10335 +
10336 + if (ar->arWlanState == WLAN_DISABLED) {
10337 + return -EIO;
10338 + }
10339 +
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");
10343 + ret = -EIO;
10344 + }
10345 +
10346 + if (wmi_startscan_cmd(ar->arWmi, WMI_LONG_SCAN, FALSE, FALSE, \
10347 + HOME_TXDRAIN_TIME, SCAN_INT) != A_OK) {
10348 + ret = -EIO;
10349 + }
10350 +
10351 + ar->scan_complete = 0;
10352 + wait_event_interruptible_timeout(ar6000_scan_queue, ar->scan_complete,
10353 + 5 * HZ);
10354 +
10355 + if (wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0) != A_OK) {
10356 + printk("Couldn't set filtering\n");
10357 + ret = -EIO;
10358 + }
10359 +
10360 + return ret;
10361 +#undef ACT_DWELLTIME_DEFAULT
10362 +#undef HOME_TXDRAIN_TIME
10363 +#undef SCAN_INT
10364 +}
10365 +
10366 +
10367 +/*
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.
10371 + *
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.
10379 + *
10380 + * NB: various calculations are based on the orinoco/wavelan
10381 + * drivers for compatibility
10382 + */
10383 +static void
10384 +ar6000_set_quality(struct iw_quality *iq, A_INT8 rssi)
10385 +{
10386 + if (rssi < 0) {
10387 + iq->qual = 0;
10388 + } else {
10389 + iq->qual = rssi;
10390 + }
10391 +
10392 + /* NB: max is 94 because noise is hardcoded to 161 */
10393 + if (iq->qual > 94)
10394 + iq->qual = 94;
10395 +
10396 + iq->noise = 161; /* -95dBm */
10397 + iq->level = iq->noise + iq->qual;
10398 + iq->updated = 7;
10399 +}
10400 +
10401 +
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 */
10459 +};
10460 +
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 */
10471 +};
10472 +
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))
10481 +
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"},
10503 +};
10504 +
10505 +void ar6000_ioctl_iwsetup(struct iw_handler_def *def)
10506 +{
10507 + def->private_args = (struct iw_priv_args *)ar6000_priv_args;
10508 + def->num_private_args = ARRAY_SIZE(ar6000_priv_args);
10509 +}
10510 +
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),
10516 +};
10517 +
10518 +
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
10522 --- /dev/null
10523 +++ b/drivers/sdio/function/wlan/ar6000/bmi/bmi.c
10524 @@ -0,0 +1,657 @@
10525 +/*
10526 + * Copyright (c) 2004-2007 Atheros Communications Inc.
10527 + * All rights reserved.
10528 + *
10529 + *
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;
10533 + *
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.
10538 + *
10539 + *
10540 + *
10541 + */
10542 +
10543 +#include "hif.h"
10544 +#include "bmi.h"
10545 +#include "htc_api.h"
10546 +#include "bmi_internal.h"
10547 +
10548 +/*
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
10555 +*/
10556 +
10557 +/* APIs visible to the driver */
10558 +void
10559 +BMIInit(void)
10560 +{
10561 + bmiDone = FALSE;
10562 +}
10563 +
10564 +A_STATUS
10565 +BMIDone(HIF_DEVICE *device)
10566 +{
10567 + A_STATUS status;
10568 + A_UINT32 cid;
10569 +
10570 + if (bmiDone) {
10571 + AR_DEBUG_PRINTF (ATH_DEBUG_BMI, ("BMIDone skipped\n"));
10572 + return A_OK;
10573 + }
10574 +
10575 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Enter (device: 0x%p)\n", device));
10576 + bmiDone = TRUE;
10577 + cid = BMI_DONE;
10578 +
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"));
10582 + return A_ERROR;
10583 + }
10584 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Exit\n"));
10585 +
10586 + return A_OK;
10587 +}
10588 +
10589 +A_STATUS
10590 +BMIGetTargetInfo(HIF_DEVICE *device, struct bmi_target_info *targ_info)
10591 +{
10592 + A_STATUS status;
10593 + A_UINT32 cid;
10594 +
10595 + if (bmiDone) {
10596 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10597 + return A_ERROR;
10598 + }
10599 +
10600 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Enter (device: 0x%p)\n", device));
10601 + cid = BMI_GET_TARGET_INFO;
10602 +
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"));
10606 + return A_ERROR;
10607 + }
10608 +
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"));
10613 + return A_ERROR;
10614 + }
10615 +
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"));
10622 + return A_ERROR;
10623 + }
10624 +
10625 + /*
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.
10628 + */
10629 + A_ASSERT(targ_info->target_info_byte_count == sizeof(*targ_info));
10630 +
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));
10638 + return A_ERROR;
10639 + }
10640 + } else {
10641 + /*
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.
10645 + */
10646 + targ_info->target_info_byte_count = sizeof(targ_info);
10647 + targ_info->target_type = TARGET_TYPE_AR6001;
10648 + }
10649 +
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);
10654 +
10655 + return A_OK;
10656 +}
10657 +
10658 +A_STATUS
10659 +BMIReadMemory(HIF_DEVICE *device,
10660 + A_UINT32 address,
10661 + A_UCHAR *buffer,
10662 + A_UINT32 length)
10663 +{
10664 + A_UINT32 cid;
10665 + A_STATUS status;
10666 + A_UINT32 offset;
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));
10670 +
10671 + if (bmiDone) {
10672 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10673 + return A_ERROR;
10674 + }
10675 +
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));
10679 +
10680 + cid = BMI_READ_MEMORY;
10681 +
10682 + remaining = length;
10683 +
10684 + while (remaining)
10685 + {
10686 + rxlen = (remaining < BMI_DATASZ_MAX) ? remaining : BMI_DATASZ_MAX;
10687 + offset = 0;
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);
10694 +
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"));
10698 + return A_ERROR;
10699 + }
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"));
10703 + return A_ERROR;
10704 + }
10705 + A_MEMCPY(&buffer[length - remaining], data, rxlen);
10706 + remaining -= rxlen; address += rxlen;
10707 + }
10708 +
10709 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Exit\n"));
10710 + return A_OK;
10711 +}
10712 +
10713 +A_STATUS
10714 +BMIWriteMemory(HIF_DEVICE *device,
10715 + A_UINT32 address,
10716 + A_UCHAR *buffer,
10717 + A_UINT32 length)
10718 +{
10719 + A_UINT32 cid;
10720 + A_STATUS status;
10721 + A_UINT32 offset;
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);
10726 +
10727 + if (bmiDone) {
10728 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10729 + return A_ERROR;
10730 + }
10731 +
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));
10735 +
10736 + cid = BMI_WRITE_MEMORY;
10737 +
10738 + remaining = length;
10739 + while (remaining)
10740 + {
10741 + txlen = (remaining < (BMI_DATASZ_MAX - header)) ?
10742 + remaining : (BMI_DATASZ_MAX - header);
10743 + offset = 0;
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);
10751 + offset += 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"));
10755 + return A_ERROR;
10756 + }
10757 + remaining -= txlen; address += txlen;
10758 + }
10759 +
10760 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Write Memory: Exit\n"));
10761 +
10762 + return A_OK;
10763 +}
10764 +
10765 +A_STATUS
10766 +BMIExecute(HIF_DEVICE *device,
10767 + A_UINT32 address,
10768 + A_UINT32 *param)
10769 +{
10770 + A_UINT32 cid;
10771 + A_STATUS status;
10772 + A_UINT32 offset;
10773 + static A_UCHAR data[sizeof(cid) + sizeof(address) + sizeof(*param)];
10774 + memset (&data, 0, sizeof(cid) + sizeof(address) + sizeof(*param));
10775 +
10776 + if (bmiDone) {
10777 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10778 + return A_ERROR;
10779 + }
10780 +
10781 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10782 + ("BMI Execute: Enter (device: 0x%p, address: 0x%x, param: %d)\n",
10783 + device, address, *param));
10784 +
10785 + cid = BMI_EXECUTE;
10786 +
10787 + offset = 0;
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"));
10797 + return A_ERROR;
10798 + }
10799 +
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"));
10803 + return A_ERROR;
10804 + }
10805 +
10806 + A_MEMCPY(param, data, sizeof(*param));
10807 +
10808 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Exit (param: %d)\n", *param));
10809 + return A_OK;
10810 +}
10811 +
10812 +A_STATUS
10813 +BMISetAppStart(HIF_DEVICE *device,
10814 + A_UINT32 address)
10815 +{
10816 + A_UINT32 cid;
10817 + A_STATUS status;
10818 + A_UINT32 offset;
10819 + static A_UCHAR data[sizeof(cid) + sizeof(address)];
10820 + memset (&data, 0, sizeof(cid) + sizeof(address));
10821 +
10822 + if (bmiDone) {
10823 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10824 + return A_ERROR;
10825 + }
10826 +
10827 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10828 + ("BMI Set App Start: Enter (device: 0x%p, address: 0x%x)\n",
10829 + device, address));
10830 +
10831 + cid = BMI_SET_APP_START;
10832 +
10833 + offset = 0;
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"));
10841 + return A_ERROR;
10842 + }
10843 +
10844 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Set App Start: Exit\n"));
10845 + return A_OK;
10846 +}
10847 +
10848 +A_STATUS
10849 +BMIReadSOCRegister(HIF_DEVICE *device,
10850 + A_UINT32 address,
10851 + A_UINT32 *param)
10852 +{
10853 + A_UINT32 cid;
10854 + A_STATUS status;
10855 + A_UINT32 offset;
10856 + static A_UCHAR data[sizeof(cid) + sizeof(address)];
10857 + memset (&data, 0, sizeof(cid) + sizeof(address));
10858 +
10859 + if (bmiDone) {
10860 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10861 + return A_ERROR;
10862 + }
10863 +
10864 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
10865 + ("BMI Read SOC Register: Enter (device: 0x%p, address: 0x%x)\n",
10866 + device, address));
10867 +
10868 + cid = BMI_READ_SOC_REGISTER;
10869 +
10870 + offset = 0;
10871 + A_MEMCPY(&data[offset], &cid, sizeof(cid));
10872 + offset += sizeof(cid);
10873 + A_MEMCPY(&data[offset], &address, sizeof(address));
10874 + offset += sizeof(address);
10875 +
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"));
10879 + return A_ERROR;
10880 + }
10881 +
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"));
10885 + return A_ERROR;
10886 + }
10887 + A_MEMCPY(param, data, sizeof(*param));
10888 +
10889 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Exit (value: %d)\n", *param));
10890 + return A_OK;
10891 +}
10892 +
10893 +A_STATUS
10894 +BMIWriteSOCRegister(HIF_DEVICE *device,
10895 + A_UINT32 address,
10896 + A_UINT32 param)
10897 +{
10898 + A_UINT32 cid;
10899 + A_STATUS status;
10900 + A_UINT32 offset;
10901 + static A_UCHAR data[sizeof(cid) + sizeof(address) + sizeof(param)];
10902 +
10903 + memset (&data, 0, sizeof(cid) + sizeof(address) + sizeof(param));
10904 +
10905 + if (bmiDone) {
10906 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10907 + return A_ERROR;
10908 + }
10909 +
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));
10913 +
10914 + cid = BMI_WRITE_SOC_REGISTER;
10915 +
10916 + offset = 0;
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], &param, 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"));
10926 + return A_ERROR;
10927 + }
10928 +
10929 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read SOC Register: Exit\n"));
10930 + return A_OK;
10931 +}
10932 +
10933 +A_STATUS
10934 +BMIrompatchInstall(HIF_DEVICE *device,
10935 + A_UINT32 ROM_addr,
10936 + A_UINT32 RAM_addr,
10937 + A_UINT32 nbytes,
10938 + A_UINT32 do_activate,
10939 + A_UINT32 *rompatch_id)
10940 +{
10941 + A_UINT32 cid;
10942 + A_STATUS status;
10943 + A_UINT32 offset;
10944 + static A_UCHAR data[sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) +
10945 + sizeof(nbytes) + sizeof(do_activate)];
10946 +
10947 + memset (&data, 0, sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) +
10948 + sizeof(nbytes) + sizeof(do_activate));
10949 +
10950 + if (bmiDone) {
10951 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
10952 + return A_ERROR;
10953 + }
10954 +
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));
10958 +
10959 + cid = BMI_ROMPATCH_INSTALL;
10960 +
10961 + offset = 0;
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"));
10975 + return A_ERROR;
10976 + }
10977 +
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"));
10981 + return A_ERROR;
10982 + }
10983 +
10984 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Install: (rompatch_id=%d)\n", *rompatch_id));
10985 + return A_OK;
10986 +}
10987 +
10988 +A_STATUS
10989 +BMIrompatchUninstall(HIF_DEVICE *device,
10990 + A_UINT32 rompatch_id)
10991 +{
10992 + A_UINT32 cid;
10993 + A_STATUS status;
10994 + A_UINT32 offset;
10995 + static A_UCHAR data[sizeof(cid) + sizeof(rompatch_id)];
10996 + memset (&data, 0, sizeof(cid) + sizeof(rompatch_id));
10997 +
10998 + if (bmiDone) {
10999 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
11000 + return A_ERROR;
11001 + }
11002 +
11003 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
11004 + ("BMI rompatch Uninstall: Enter (device: 0x%p, rompatch_id: %d)\n",
11005 + device, rompatch_id));
11006 +
11007 + cid = BMI_ROMPATCH_UNINSTALL;
11008 +
11009 + offset = 0;
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"));
11017 + return A_ERROR;
11018 + }
11019 +
11020 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch UNinstall: (rompatch_id=0x%x)\n", rompatch_id));
11021 + return A_OK;
11022 +}
11023 +
11024 +static A_STATUS
11025 +_BMIrompatchChangeActivation(HIF_DEVICE *device,
11026 + A_UINT32 rompatch_count,
11027 + A_UINT32 *rompatch_list,
11028 + A_UINT32 do_activate)
11029 +{
11030 + A_UINT32 cid;
11031 + A_STATUS status;
11032 + A_UINT32 offset;
11033 + static A_UCHAR data[BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count)];
11034 + A_UINT32 length;
11035 +
11036 + memset (&data, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count));
11037 +
11038 + if (bmiDone) {
11039 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n"));
11040 + return A_ERROR;
11041 + }
11042 +
11043 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI,
11044 + ("BMI Change rompatch Activation: Enter (device: 0x%p, count: %d)\n",
11045 + device, rompatch_count));
11046 +
11047 + cid = do_activate ? BMI_ROMPATCH_ACTIVATE : BMI_ROMPATCH_DEACTIVATE;
11048 +
11049 + offset = 0;
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"));
11060 + return A_ERROR;
11061 + }
11062 +
11063 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Exit\n"));
11064 +
11065 + return A_OK;
11066 +}
11067 +
11068 +A_STATUS
11069 +BMIrompatchActivate(HIF_DEVICE *device,
11070 + A_UINT32 rompatch_count,
11071 + A_UINT32 *rompatch_list)
11072 +{
11073 + return _BMIrompatchChangeActivation(device, rompatch_count, rompatch_list, 1);
11074 +}
11075 +
11076 +A_STATUS
11077 +BMIrompatchDeactivate(HIF_DEVICE *device,
11078 + A_UINT32 rompatch_count,
11079 + A_UINT32 *rompatch_list)
11080 +{
11081 + return _BMIrompatchChangeActivation(device, rompatch_count, rompatch_list, 0);
11082 +}
11083 +
11084 +/* BMI Access routines */
11085 +A_STATUS
11086 +bmiBufferSend(HIF_DEVICE *device,
11087 + A_UCHAR *buffer,
11088 + A_UINT32 length)
11089 +{
11090 + A_STATUS status;
11091 + A_UINT32 timeout;
11092 + A_UINT32 address;
11093 + static A_UINT32 cmdCredits;
11094 + A_UINT32 mboxAddress[HTC_MAILBOX_NUM_MAX];
11095 +
11096 + HIFConfigureDevice(device, HIF_DEVICE_GET_MBOX_ADDR,
11097 + &mboxAddress, sizeof(mboxAddress));
11098 +
11099 + cmdCredits = 0;
11100 + timeout = BMI_COMMUNICATION_TIMEOUT;
11101 +
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"));
11112 + return A_ERROR;
11113 + }
11114 + /* the counter is only 8=bits, ignore anything in the upper 3 bytes */
11115 + cmdCredits &= 0xFF;
11116 + }
11117 +
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"));
11124 + return A_ERROR;
11125 + }
11126 + } else {
11127 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Communication timeout\n"));
11128 + return A_ERROR;
11129 + }
11130 +
11131 + return status;
11132 +}
11133 +
11134 +A_STATUS
11135 +bmiBufferReceive(HIF_DEVICE *device,
11136 + A_UCHAR *buffer,
11137 + A_UINT32 length)
11138 +{
11139 + A_STATUS status;
11140 + A_UINT32 address;
11141 + A_UINT32 timeout;
11142 + static A_UINT32 cmdCredits;
11143 + A_UINT32 mboxAddress[HTC_MAILBOX_NUM_MAX];
11144 +
11145 + HIFConfigureDevice(device, HIF_DEVICE_GET_MBOX_ADDR,
11146 + &mboxAddress, sizeof(mboxAddress));
11147 +
11148 + cmdCredits = 0;
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"));
11160 + return A_ERROR;
11161 + }
11162 + /* we did a 4-byte read to the same count register so mask off upper bytes */
11163 + cmdCredits &= 0xFF;
11164 + status = A_ERROR;
11165 + }
11166 +
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"));
11173 + return A_ERROR;
11174 + }
11175 + } else {
11176 + AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Communication timeout\n"));
11177 + return A_ERROR;
11178 + }
11179 +
11180 + return status;
11181 +}
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
11185 --- /dev/null
11186 +++ b/drivers/sdio/function/wlan/ar6000/bmi/bmi_internal.h
11187 @@ -0,0 +1,45 @@
11188 +#ifndef BMI_INTERNAL_H
11189 +#define BMI_INTERNAL_H
11190 +/*
11191 + *
11192 + * Copyright (c) 2004-2007 Atheros Communications Inc.
11193 + * All rights reserved.
11194 + *
11195 + *
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;
11199 + *
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.
11204 + *
11205 + *
11206 + *
11207 + */
11208 +
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"
11216 +
11217 +#define BMI_COMMUNICATION_TIMEOUT 100000
11218 +
11219 +/* ------ Global Variable Declarations ------- */
11220 +A_BOOL bmiDone;
11221 +
11222 +A_STATUS
11223 +bmiBufferSend(HIF_DEVICE *device,
11224 + A_UCHAR *buffer,
11225 + A_UINT32 length);
11226 +
11227 +A_STATUS
11228 +bmiBufferReceive(HIF_DEVICE *device,
11229 + A_UCHAR *buffer,
11230 + A_UINT32 length);
11231 +
11232 +#endif
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
11236 --- /dev/null
11237 +++ b/drivers/sdio/function/wlan/ar6000/hif/hif.c
11238 @@ -0,0 +1,818 @@
11239 +/*
11240 + * @file: hif.c
11241 + *
11242 + * @abstract: HIF layer reference implementation for Atheros SDIO stack
11243 + *
11244 + * @notice: Copyright (c) 2004-2006 Atheros Communications Inc.
11245 + *
11246 + *
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;
11250 + *
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.
11255 + *
11256 + *
11257 + *
11258 + */
11259 +
11260 +#include "hif_internal.h"
11261 +
11262 +/* ------ Static Variables ------ */
11263 +
11264 +/* ------ Global Variable Declarations ------- */
11265 +SD_PNP_INFO Ids[] = {
11266 + {
11267 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6001_BASE | 0xB,
11268 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11269 + .SDIO_FunctionClass = FUNCTION_CLASS,
11270 + .SDIO_FunctionNo = 1
11271 + },
11272 + {
11273 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6001_BASE | 0xA,
11274 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11275 + .SDIO_FunctionClass = FUNCTION_CLASS,
11276 + .SDIO_FunctionNo = 1
11277 + },
11278 + {
11279 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6001_BASE | 0x9,
11280 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11281 + .SDIO_FunctionClass = FUNCTION_CLASS,
11282 + .SDIO_FunctionNo = 1
11283 + },
11284 + {
11285 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6001_BASE | 0x8,
11286 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11287 + .SDIO_FunctionClass = FUNCTION_CLASS,
11288 + .SDIO_FunctionNo = 1
11289 + },
11290 + {
11291 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6002_BASE | 0x0,
11292 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11293 + .SDIO_FunctionClass = FUNCTION_CLASS,
11294 + .SDIO_FunctionNo = 1
11295 + },
11296 + {
11297 + .SDIO_ManufacturerID = MANUFACTURER_ID_AR6002_BASE | 0x1,
11298 + .SDIO_ManufacturerCode = MANUFACTURER_CODE,
11299 + .SDIO_FunctionClass = FUNCTION_CLASS,
11300 + .SDIO_FunctionNo = 1
11301 + },
11302 + {
11303 + } //list is null termintaed
11304 +};
11305 +
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,
11318 +};
11319 +
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;
11328 +
11329 +#ifdef DEBUG
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);\
11337 + }
11338 +#else
11339 +#define AR_DEBUG_PRINTF(lvl, args)
11340 +#endif
11341 +
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);
11346 +
11347 +/* ------ Functions ------ */
11348 +int HIFInit(HTC_CALLBACKS *callbacks)
11349 +{
11350 + SDIO_STATUS status;
11351 + DBG_ASSERT(callbacks != NULL);
11352 +
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;
11361 +
11362 + CriticalSectionInit(&lock);
11363 +
11364 + /* Register with bus driver core */
11365 + status = SDIO_RegisterFunction(&FunctionContext.function);
11366 + DBG_ASSERT(SDIO_SUCCESS(status));
11367 +
11368 + return(0);
11369 +}
11370 +
11371 +A_STATUS
11372 +HIFReadWrite(HIF_DEVICE *device,
11373 + A_UINT32 address,
11374 + A_UCHAR *buffer,
11375 + A_UINT32 length,
11376 + A_UINT32 request,
11377 + void *context)
11378 +{
11379 + A_UINT8 rw;
11380 + A_UINT8 mode;
11381 + A_UINT8 funcNo;
11382 + A_UINT8 opcode;
11383 + A_UINT16 count;
11384 + SDREQUEST *sdrequest;
11385 + SDIO_STATUS sdiostatus;
11386 + BUS_REQUEST *busrequest;
11387 + A_STATUS status = A_OK;
11388 +
11389 + DBG_ASSERT(device != NULL);
11390 + DBG_ASSERT(device->handle != NULL);
11391 +
11392 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Device: %p\n", device));
11393 +
11394 + do {
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;
11399 + break;
11400 + }
11401 +
11402 + sdrequest = busrequest->request;
11403 + busrequest->context = context;
11404 +
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"));
11417 + } else {
11418 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11419 + ("Invalid execution mode: 0x%08x\n", request));
11420 + status = A_EINVAL;
11421 + break;
11422 + }
11423 +
11424 + if (request & HIF_EXTENDED_IO) {
11425 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Command type: CMD53\n"));
11426 + sdrequest->Command = CMD53;
11427 + } else {
11428 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11429 + ("Invalid command type: 0x%08x\n", request));
11430 + status = A_EINVAL;
11431 + break;
11432 + }
11433 +
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));
11450 + } else {
11451 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11452 + ("Invalid data mode: 0x%08x\n", request));
11453 + status = A_EINVAL;
11454 + break;
11455 + }
11456 +
11457 +#if 0
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);
11462 + }
11463 +#endif
11464 +
11465 + if ((address >= HIF_MBOX_START_ADDR(0)) &&
11466 + (address <= HIF_MBOX_END_ADDR(3)))
11467 + {
11468 +
11469 + DBG_ASSERT(length <= HIF_MBOX_WIDTH);
11470 +
11471 + /*
11472 + * Mailbox write. Adjust the address so that the last byte
11473 + * falls on the EOM address.
11474 + */
11475 + address += (HIF_MBOX_WIDTH - length);
11476 + }
11477 +
11478 +
11479 +
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) {
11485 + rw = CMD53_READ;
11486 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Direction: Read\n"));
11487 + } else {
11488 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11489 + ("Invalid direction: 0x%08x\n", request));
11490 + status = A_EINVAL;
11491 + break;
11492 + }
11493 +
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"));
11500 + } else {
11501 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11502 + ("Invalid address mode: 0x%08x\n", request));
11503 + status = A_EINVAL;
11504 + break;
11505 + }
11506 +
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);
11511 +
11512 + /* Send the command out */
11513 + sdiostatus = SDDEVICE_CALL_REQUEST_FUNC(device->handle, sdrequest);
11514 +
11515 + if (!SDIO_SUCCESS(sdiostatus)) {
11516 + status = A_ERROR;
11517 + }
11518 +
11519 + } while (FALSE);
11520 +
11521 + if (A_FAILED(status) || (request & HIF_SYNCHRONOUS)) {
11522 + if (busrequest != NULL) {
11523 + hifFreeBusRequest(busrequest);
11524 + }
11525 + }
11526 +
11527 + if (A_FAILED(status) && (request & HIF_ASYNCHRONOUS)) {
11528 + /* call back async handler on failure */
11529 + htcCallbacks.rwCompletionHandler(context, status);
11530 + }
11531 +
11532 + return status;
11533 +}
11534 +
11535 +A_STATUS
11536 +HIFConfigureDevice(HIF_DEVICE *device, HIF_DEVICE_CONFIG_OPCODE opcode,
11537 + void *config, A_UINT32 configLen)
11538 +{
11539 + A_UINT32 count;
11540 +
11541 + switch(opcode) {
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;
11547 + break;
11548 +
11549 + case HIF_DEVICE_GET_MBOX_ADDR:
11550 + for (count = 0; count < 4; count ++) {
11551 + ((A_UINT32 *)config)[count] = HIF_MBOX_START_ADDR(count);
11552 + }
11553 + break;
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;
11557 + break;
11558 + default:
11559 + AR_DEBUG_PRINTF(ATH_DEBUG_WARN,
11560 + ("Unsupported configuration opcode: %d\n", opcode));
11561 + return A_ERROR;
11562 + }
11563 +
11564 + return A_OK;
11565 +}
11566 +
11567 +void
11568 +HIFShutDownDevice(HIF_DEVICE *device)
11569 +{
11570 + A_UINT8 data;
11571 + A_UINT32 count;
11572 + SDIO_STATUS status;
11573 + SDCONFIG_BUS_MODE_DATA busSettings;
11574 + SDCONFIG_FUNC_ENABLE_DISABLE_DATA fData;
11575 +
11576 + if (device != NULL) {
11577 + DBG_ASSERT(device->handle != NULL);
11578 +
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));
11583 +
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));
11590 +
11591 + /* Perform a soft I/O reset */
11592 + data = SDIO_IO_RESET;
11593 + status = SDLIB_IssueCMD52(device->handle, 0, SDIO_IO_ABORT_REG,
11594 + &data, 1, 1);
11595 + DBG_ASSERT(SDIO_SUCCESS(status));
11596 +
11597 + /*
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.
11603 + */
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);
11609 +
11610 + /* Issue config request to change the bus width to 4 bit */
11611 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_BUS_MODE_CTRL,
11612 + &busSettings,
11613 + sizeof(SDCONFIG_BUS_MODE_DATA));
11614 + DBG_ASSERT(SDIO_SUCCESS(status));
11615 + }
11616 +
11617 + /* Free the bus requests */
11618 + for (count = 0; count < BUS_REQUEST_MAX_NUM; count ++) {
11619 + SDDeviceFreeRequest(device->handle, busRequest[count].request);
11620 + }
11621 + /* Clean up the queue */
11622 + s_busRequestFreeQueue = NULL;
11623 + } else {
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
11627 + * enumerated */
11628 + ResetAllCards();
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));
11634 + }
11635 +}
11636 +
11637 +void
11638 +hifRWCompletionHandler(SDREQUEST *request)
11639 +{
11640 + A_STATUS status;
11641 + void *context;
11642 + BUS_REQUEST *busrequest;
11643 +
11644 + if (SDIO_SUCCESS(request->Status)) {
11645 + status = A_OK;
11646 + } else {
11647 + status = A_ERROR;
11648 + }
11649 +
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
11656 + * is invoked */
11657 + hifFreeBusRequest(busrequest);
11658 + htcCallbacks.rwCompletionHandler(context, status);
11659 +}
11660 +
11661 +void
11662 +hifIRQHandler(void *context)
11663 +{
11664 + A_STATUS status;
11665 + HIF_DEVICE *device;
11666 +
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);
11671 +}
11672 +
11673 +BOOL
11674 +hifDeviceInserted(SDFUNCTION *function, SDDEVICE *handle)
11675 +{
11676 + BOOL enabled;
11677 + A_UINT8 data;
11678 + A_UINT32 count;
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;
11688 +
11689 + DBG_ASSERT(function != NULL);
11690 + DBG_ASSERT(handle != NULL);
11691 +
11692 + device = addHifDevice(handle);
11693 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Device: %p\n", device));
11694 + functionContext = (TARGET_FUNCTION_CONTEXT *)function->pContext;
11695 +
11696 + /*
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.
11704 + */
11705 +
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"));
11713 + return FALSE;
11714 + }
11715 + }
11716 +
11717 + /* Get current bus flags */
11718 + ZERO_OBJECT(busSettings);
11719 +
11720 + busSettings.BusModeFlags = SDDEVICE_GET_BUSMODE_FLAGS(handle);
11721 + if (onebitmode) {
11722 + SDCONFIG_SET_BUS_WIDTH(busSettings.BusModeFlags,
11723 + SDCONFIG_BUS_WIDTH_1_BIT);
11724 + }
11725 +
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
11729 + * down */
11730 + currentBusClock = SDDEVICE_GET_OPER_CLOCK(handle);
11731 + busSettings.ClockRate = currentBusClock;
11732 +
11733 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11734 + ("HIF currently running at: %d \n",currentBusClock));
11735 +
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));
11742 + }
11743 +
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"));
11750 + return FALSE;
11751 + } else {
11752 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11753 + ("Configured clock: %d, Maximum clock: %d\n",
11754 + busSettings.ActualClockRate,
11755 + SDDEVICE_GET_MAX_CLOCK(handle)));
11756 + }
11757 +
11758 + /*
11759 + * Check if the target supports block mode. This result of this check
11760 + * can be used to implement the HIFReadWrite API.
11761 + */
11762 + if (SDDEVICE_GET_SDIO_FUNC_MAXBLKSIZE(handle)) {
11763 + /* Limit block size to operational block limit or card function
11764 + capability */
11765 + maxBlockSize = min(SDDEVICE_GET_OPER_BLOCK_LEN(handle),
11766 + SDDEVICE_GET_SDIO_FUNC_MAXBLKSIZE(handle));
11767 +
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"));
11771 +
11772 + /* Limit block size to max byte basis */
11773 + maxBlockSize = min(maxBlockSize,
11774 + (A_UINT16)SDIO_MAX_LENGTH_BYTE_BASIS);
11775 + maxBlocks = 1;
11776 + } else {
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));
11783 + return FALSE;
11784 + }
11785 + }
11786 +
11787 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
11788 + ("Bytes Per Block: %d bytes, Block Count:%d \n",
11789 + maxBlockSize, maxBlocks));
11790 + } else {
11791 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11792 + ("Function does not support Block Mode!\n"));
11793 + return FALSE;
11794 + }
11795 +
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));
11806 + return FALSE;
11807 + }
11808 + }
11809 +
11810 + /* Enable the dragon function */
11811 + count = 0;
11812 + enabled = FALSE;
11813 + fData.TimeOut = 1;
11814 + fData.EnableFlags = SDCONFIG_ENABLE_FUNC;
11815 + while ((count++ < SDWLAN_ENABLE_DISABLE_TIMEOUT) && !enabled)
11816 + {
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"));
11823 + continue;
11824 + }
11825 +
11826 + /* Mark the status as enabled */
11827 + enabled = TRUE;
11828 + }
11829 +
11830 + /* Check if we were succesful in enabling the target */
11831 + if (!enabled) {
11832 + AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
11833 + ("Failed to communicate with the target\n"));
11834 + return FALSE;
11835 + }
11836 +
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 */
11843 + return FALSE;
11844 + }
11845 + hifFreeBusRequest(&busRequest[count]);
11846 +
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));
11851 + }
11852 +
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
11857 + *
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.
11861 + * */
11862 +
11863 + if (SDIO_SUCCESS(SDLIB_OSCreateHelper(&device->insert_helper,
11864 + insert_helper_func,
11865 + device))) {
11866 + device->helper_started = TRUE;
11867 + }
11868 +
11869 + return TRUE;
11870 +}
11871 +
11872 +static THREAD_RETURN insert_helper_func(POSKERNEL_HELPER pHelper)
11873 +{
11874 +
11875 + /*
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
11886 + */
11887 +
11888 + A_MDELAY(1000);
11889 + /* Inform HTC */
11890 + if ((htcCallbacks.deviceInsertedHandler(SD_GET_OS_HELPER_CONTEXT(pHelper))) != A_OK) {
11891 + AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("Device rejected\n"));
11892 + }
11893 +
11894 + return 0;
11895 +}
11896 +
11897 +void
11898 +HIFAckInterrupt(HIF_DEVICE *device)
11899 +{
11900 + SDIO_STATUS status;
11901 + DBG_ASSERT(device != NULL);
11902 + DBG_ASSERT(device->handle != NULL);
11903 +
11904 + /* Acknowledge our function IRQ */
11905 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_FUNC_ACK_IRQ,
11906 + NULL, 0);
11907 + DBG_ASSERT(SDIO_SUCCESS(status));
11908 +}
11909 +
11910 +void
11911 +HIFUnMaskInterrupt(HIF_DEVICE *device)
11912 +{
11913 + SDIO_STATUS status;
11914 +
11915 + DBG_ASSERT(device != NULL);
11916 + DBG_ASSERT(device->handle != NULL);
11917 +
11918 + /* Register the IRQ Handler */
11919 + SDDEVICE_SET_IRQ_HANDLER(device->handle, hifIRQHandler, device);
11920 +
11921 + /* Unmask our function IRQ */
11922 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_FUNC_UNMASK_IRQ,
11923 + NULL, 0);
11924 + DBG_ASSERT(SDIO_SUCCESS(status));
11925 +}
11926 +
11927 +void HIFMaskInterrupt(HIF_DEVICE *device)
11928 +{
11929 + SDIO_STATUS status;
11930 + DBG_ASSERT(device != NULL);
11931 + DBG_ASSERT(device->handle != NULL);
11932 +
11933 + /* Mask our function IRQ */
11934 + status = SDLIB_IssueConfig(device->handle, SDCONFIG_FUNC_MASK_IRQ,
11935 + NULL, 0);
11936 + DBG_ASSERT(SDIO_SUCCESS(status));
11937 +
11938 + /* Unregister the IRQ Handler */
11939 + SDDEVICE_SET_IRQ_HANDLER(device->handle, NULL, NULL);
11940 +}
11941 +
11942 +static BUS_REQUEST *hifAllocateBusRequest(void)
11943 +{
11944 + BUS_REQUEST *busrequest;
11945 +
11946 + /* Acquire lock */
11947 + CriticalSectionAcquire(&lock);
11948 +
11949 + /* Remove first in list */
11950 + if((busrequest = s_busRequestFreeQueue) != NULL)
11951 + {
11952 + s_busRequestFreeQueue = busrequest->next;
11953 + }
11954 +
11955 + /* Release lock */
11956 + CriticalSectionRelease(&lock);
11957 +
11958 + return busrequest;
11959 +}
11960 +
11961 +static void
11962 +hifFreeBusRequest(BUS_REQUEST *busrequest)
11963 +{
11964 + DBG_ASSERT(busrequest != NULL);
11965 +
11966 + /* Acquire lock */
11967 + CriticalSectionAcquire(&lock);
11968 +
11969 + /* Insert first in list */
11970 + busrequest->next = s_busRequestFreeQueue;
11971 + s_busRequestFreeQueue = busrequest;
11972 +
11973 + /* Release lock */
11974 + CriticalSectionRelease(&lock);
11975 +}
11976 +
11977 +void
11978 +hifDeviceRemoved(SDFUNCTION *function, SDDEVICE *handle)
11979 +{
11980 + A_STATUS status;
11981 + HIF_DEVICE *device;
11982 + DBG_ASSERT(function != NULL);
11983 + DBG_ASSERT(handle != NULL);
11984 +
11985 + device = getHifDevice(handle);
11986 + status = htcCallbacks.deviceRemovedHandler(device->htc_handle, A_OK);
11987 +
11988 + /* cleanup the helper thread */
11989 + if (device->helper_started) {
11990 + SDLIB_OSDeleteHelper(&device->insert_helper);
11991 + device->helper_started = FALSE;
11992 + }
11993 +
11994 + delHifDevice(handle);
11995 + DBG_ASSERT(status == A_OK);
11996 +}
11997 +
11998 +HIF_DEVICE *
11999 +addHifDevice(SDDEVICE *handle)
12000 +{
12001 + DBG_ASSERT(handle != NULL);
12002 + hifDevice[0].handle = handle;
12003 + return &hifDevice[0];
12004 +}
12005 +
12006 +HIF_DEVICE *
12007 +getHifDevice(SDDEVICE *handle)
12008 +{
12009 + DBG_ASSERT(handle != NULL);
12010 + return &hifDevice[0];
12011 +}
12012 +
12013 +void
12014 +delHifDevice(SDDEVICE *handle)
12015 +{
12016 + DBG_ASSERT(handle != NULL);
12017 + hifDevice[0].handle = NULL;
12018 +}
12019 +
12020 +static void ResetAllCards(void)
12021 +{
12022 + UINT8 data;
12023 + SDIO_STATUS status;
12024 + int i;
12025 +
12026 + data = SDIO_IO_RESET;
12027 +
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,
12041 + &data,
12042 + 1, /* 1 byte */
12043 + TRUE); /* write */
12044 + }
12045 + }
12046 +
12047 +}
12048 +
12049 +void HIFSetHandle(void *hif_handle, void *handle)
12050 +{
12051 + HIF_DEVICE *device = (HIF_DEVICE *) hif_handle;
12052 +
12053 + device->htc_handle = handle;
12054 +
12055 + return;
12056 +}
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
12060 --- /dev/null
12061 +++ b/drivers/sdio/function/wlan/ar6000/hif/hif_internal.h
12062 @@ -0,0 +1,102 @@
12063 +/*
12064 + * @file: hif_internal.h
12065 + *
12066 + * @abstract: internal header file for hif layer
12067 + *
12068 + * @notice: Copyright (c) 2004-2006 Atheros Communications Inc.
12069 + *
12070 + *
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;
12074 + *
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.
12079 + *
12080 + *
12081 + *
12082 + */
12083 +
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"
12092 +#include "hif.h"
12093 +
12094 +#define MANUFACTURER_ID_AR6001_BASE 0x100
12095 +#define MANUFACTURER_ID_AR6002_BASE 0x200
12096 +#define FUNCTION_CLASS 0x0
12097 +#define MANUFACTURER_CODE 0x271
12098 +
12099 +#define BUS_REQUEST_MAX_NUM 64
12100 +
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
12105 +
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
12113 +
12114 +#define HIF_MBOX_START_ADDR(mbox) \
12115 + HIF_MBOX_BASE_ADDR + mbox * HIF_MBOX_WIDTH
12116 +
12117 +#define HIF_MBOX_END_ADDR(mbox) \
12118 + HIF_MBOX_START_ADDR(mbox) + HIF_MBOX_WIDTH - 1
12119 +
12120 +struct hif_device {
12121 + SDDEVICE *handle;
12122 + void *htc_handle;
12123 + OSKERNEL_HELPER insert_helper;
12124 + BOOL helper_started;
12125 +};
12126 +
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;
12132 +
12133 +typedef struct bus_request {
12134 + struct bus_request *next;
12135 + SDREQUEST *request;
12136 + void *context;
12137 +} BUS_REQUEST;
12138 +
12139 +BOOL
12140 +hifDeviceInserted(SDFUNCTION *function, SDDEVICE *device);
12141 +
12142 +void
12143 +hifDeviceRemoved(SDFUNCTION *function, SDDEVICE *device);
12144 +
12145 +SDREQUEST *
12146 +hifAllocateDeviceRequest(SDDEVICE *device);
12147 +
12148 +void
12149 +hifFreeDeviceRequest(SDREQUEST *request);
12150 +
12151 +void
12152 +hifRWCompletionHandler(SDREQUEST *request);
12153 +
12154 +void
12155 +hifIRQHandler(void *context);
12156 +
12157 +HIF_DEVICE *
12158 +addHifDevice(SDDEVICE *handle);
12159 +
12160 +HIF_DEVICE *
12161 +getHifDevice(SDDEVICE *handle);
12162 +
12163 +void
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
12168 --- /dev/null
12169 +++ b/drivers/sdio/function/wlan/ar6000/htc/ar6k.c
12170 @@ -0,0 +1,991 @@
12171 +/*
12172 + * AR6K device layer that handles register level I/O
12173 + *
12174 + * Copyright (c) 2007 Atheros Communications Inc.
12175 + * All rights reserved.
12176 + *
12177 + *
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;
12181 + *
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.
12186 + *
12187 + *
12188 + *
12189 + */
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"
12196 +#include "hif.h"
12197 +#include "htc_packet.h"
12198 +#include "ar6k.h"
12199 +
12200 +#define MAILBOX_FOR_BLOCK_SIZE 1
12201 +
12202 +extern A_UINT32 resetok;
12203 +
12204 +static A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev);
12205 +static A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev);
12206 +
12207 +#define LOCK_AR6K(p) A_MUTEX_LOCK(&(p)->Lock);
12208 +#define UNLOCK_AR6K(p) A_MUTEX_UNLOCK(&(p)->Lock);
12209 +
12210 +void AR6KFreeIOPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket)
12211 +{
12212 + LOCK_AR6K(pDev);
12213 + HTC_PACKET_ENQUEUE(&pDev->RegisterIOList,pPacket);
12214 + UNLOCK_AR6K(pDev);
12215 +}
12216 +
12217 +HTC_PACKET *AR6KAllocIOPacket(AR6K_DEVICE *pDev)
12218 +{
12219 + HTC_PACKET *pPacket;
12220 +
12221 + LOCK_AR6K(pDev);
12222 + pPacket = HTC_PACKET_DEQUEUE(&pDev->RegisterIOList);
12223 + UNLOCK_AR6K(pDev);
12224 +
12225 + return pPacket;
12226 +}
12227 +
12228 +A_STATUS DevSetup(AR6K_DEVICE *pDev)
12229 +{
12230 + A_UINT32 mailboxaddrs[AR6K_MAILBOXES];
12231 + A_UINT32 blocksizes[AR6K_MAILBOXES];
12232 + A_STATUS status = A_OK;
12233 + int i;
12234 +
12235 + AR_DEBUG_ASSERT(AR6K_IRQ_PROC_REGS_SIZE == 16);
12236 + AR_DEBUG_ASSERT(AR6K_IRQ_ENABLE_REGS_SIZE == 4);
12237 +
12238 + do {
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);
12244 +
12245 + /* get the addresses for all 4 mailboxes */
12246 + status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR,
12247 + mailboxaddrs, sizeof(mailboxaddrs));
12248 +
12249 + if (status != A_OK) {
12250 + AR_DEBUG_ASSERT(FALSE);
12251 + break;
12252 + }
12253 +
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,
12259 + pDev,
12260 + pDev->RegIOBuffers[i].Buffer,
12261 + AR6K_REG_IO_BUFFER_SIZE,
12262 + 0); /* don't care */
12263 + AR6KFreeIOPacket(pDev,pIOPacket);
12264 + }
12265 +
12266 + /* get the address of the mailbox we are using */
12267 + pDev->MailboxAddress = mailboxaddrs[HTC_MAILBOX];
12268 +
12269 + /* get the block sizes */
12270 + status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
12271 + blocksizes, sizeof(blocksizes));
12272 +
12273 + if (status != A_OK) {
12274 + AR_DEBUG_ASSERT(FALSE);
12275 + break;
12276 + }
12277 +
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);
12284 +
12285 + /* assemble mask, used for padding to a block */
12286 + pDev->BlockMask = pDev->BlockSize - 1;
12287 +
12288 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("BlockSize: %d, MailboxAddress:0x%X \n",
12289 + pDev->BlockSize, pDev->MailboxAddress));
12290 +
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));
12297 +
12298 + /* assume we can process HIF interrupt events asynchronously */
12299 + pDev->HifIRQProcessingMode = HIF_DEVICE_IRQ_ASYNC_SYNC;
12300 +
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));
12306 +
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"));
12310 + break;
12311 + case HIF_DEVICE_IRQ_ASYNC_SYNC:
12312 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("HIF Interrupt processing is ASYNC and SYNC\n"));
12313 + break;
12314 + default:
12315 + AR_DEBUG_ASSERT(FALSE);
12316 + }
12317 +
12318 + pDev->HifMaskUmaskRecvEvent = NULL;
12319 +
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));
12325 +
12326 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("HIF special overrides : 0x%X , 0x%X\n",
12327 + (A_UINT32)pDev->GetPendingEventsFunc, (A_UINT32)pDev->HifMaskUmaskRecvEvent));
12328 +
12329 + status = DevDisableInterrupts(pDev);
12330 +
12331 + } while (FALSE);
12332 +
12333 + if (A_FAILED(status)) {
12334 + /* make sure handle is cleared */
12335 + HIFSetHandle(pDev->HIFDevice, NULL);
12336 + }
12337 +
12338 + return status;
12339 +
12340 +}
12341 +
12342 +static A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev)
12343 +{
12344 + A_STATUS status;
12345 + AR6K_IRQ_ENABLE_REGISTERS regs;
12346 +
12347 + LOCK_AR6K(pDev);
12348 +
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);
12353 +
12354 + if (NULL == pDev->GetPendingEventsFunc) {
12355 + pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_MBOX_DATA_SET(0x01);
12356 + } else {
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
12362 + * masked */
12363 + pDev->IrqEnableRegisters.int_status_enable &= ~INT_STATUS_ENABLE_MBOX_DATA_SET(0x01);
12364 + }
12365 +
12366 +
12367 + /* Set up the CPU Interrupt Status Register */
12368 + pDev->IrqEnableRegisters.cpu_int_status_enable = CPU_INT_STATUS_ENABLE_BIT_SET(0x00);
12369 +
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);
12374 +
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);
12378 +
12379 + /* copy into our temp area */
12380 + A_MEMCPY(&regs,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE);
12381 +
12382 + UNLOCK_AR6K(pDev);
12383 +
12384 + /* always synchronous */
12385 + status = HIFReadWrite(pDev->HIFDevice,
12386 + INT_STATUS_ENABLE_ADDRESS,
12387 + &regs.int_status_enable,
12388 + AR6K_IRQ_ENABLE_REGS_SIZE,
12389 + HIF_WR_SYNC_BYTE_INC,
12390 + NULL);
12391 +
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));
12396 +
12397 + }
12398 +
12399 + return status;
12400 +}
12401 +
12402 +static A_STATUS DevDisableInterrupts(AR6K_DEVICE *pDev)
12403 +{
12404 + AR6K_IRQ_ENABLE_REGISTERS regs;
12405 +
12406 + LOCK_AR6K(pDev);
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(&regs,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE);
12414 +
12415 + UNLOCK_AR6K(pDev);
12416 +
12417 + /* always synchronous */
12418 + return HIFReadWrite(pDev->HIFDevice,
12419 + INT_STATUS_ENABLE_ADDRESS,
12420 + &regs.int_status_enable,
12421 + AR6K_IRQ_ENABLE_REGS_SIZE,
12422 + HIF_WR_SYNC_BYTE_INC,
12423 + NULL);
12424 +}
12425 +
12426 +/* enable device interrupts */
12427 +A_STATUS DevUnmaskInterrupts(AR6K_DEVICE *pDev)
12428 +{
12429 + /* Unmask the host controller interrupts */
12430 + HIFUnMaskInterrupt(pDev->HIFDevice);
12431 +
12432 + return DevEnableInterrupts(pDev);
12433 +}
12434 +
12435 +/* disable all device interrupts */
12436 +A_STATUS DevMaskInterrupts(AR6K_DEVICE *pDev)
12437 +{
12438 + A_STATUS status;
12439 +
12440 + status = DevDisableInterrupts(pDev);
12441 +
12442 + if (A_SUCCESS(status)) {
12443 + /* Disable the interrupt at the HIF layer */
12444 + HIFMaskInterrupt(pDev->HIFDevice);
12445 + }
12446 +
12447 + return status;
12448 +}
12449 +
12450 +/* callback when our fetch to enable/disable completes */
12451 +static void DevDoEnableDisableRecvAsyncHandler(void *Context, HTC_PACKET *pPacket)
12452 +{
12453 + AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context;
12454 +
12455 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevDoEnableDisableRecvAsyncHandler: (dev: 0x%X)\n", (A_UINT32)pDev));
12456 +
12457 + if (A_FAILED(pPacket->Status)) {
12458 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
12459 + (" Failed to disable receiver, status:%d \n", pPacket->Status));
12460 + }
12461 + /* free this IO packet */
12462 + AR6KFreeIOPacket(pDev,pPacket);
12463 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevDoEnableDisableRecvAsyncHandler \n"));
12464 +}
12465 +
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)
12470 +{
12471 + A_STATUS status = A_OK;
12472 + HTC_PACKET *pIOPacket = NULL;
12473 +
12474 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("DevDoEnableDisableRecvOverride: Enable:%d Mode:%d\n",
12475 + EnableRecv,AsyncMode));
12476 +
12477 + do {
12478 +
12479 + if (AsyncMode) {
12480 +
12481 + pIOPacket = AR6KAllocIOPacket(pDev);
12482 +
12483 + if (NULL == pIOPacket) {
12484 + status = A_NO_MEMORY;
12485 + AR_DEBUG_ASSERT(FALSE);
12486 + break;
12487 + }
12488 +
12489 + /* stick in our completion routine when the I/O operation completes */
12490 + pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler;
12491 + pIOPacket->pContext = pDev;
12492 +
12493 + /* call the HIF layer override and do this asynchronously */
12494 + status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice,
12495 + EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV,
12496 + pIOPacket);
12497 + break;
12498 + }
12499 +
12500 + /* if we get here we are doing it synchronously */
12501 + status = pDev->HifMaskUmaskRecvEvent(pDev->HIFDevice,
12502 + EnableRecv ? HIF_UNMASK_RECV : HIF_MASK_RECV,
12503 + NULL);
12504 +
12505 + } while (FALSE);
12506 +
12507 + if (A_FAILED(status) && (pIOPacket != NULL)) {
12508 + AR6KFreeIOPacket(pDev,pIOPacket);
12509 + }
12510 +
12511 + return status;
12512 +}
12513 +
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)
12518 +{
12519 + A_STATUS status = A_OK;
12520 + HTC_PACKET *pIOPacket = NULL;
12521 + AR6K_IRQ_ENABLE_REGISTERS regs;
12522 +
12523 + /* take the lock to protect interrupt enable shadows */
12524 + LOCK_AR6K(pDev);
12525 +
12526 + if (EnableRecv) {
12527 + pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_MBOX_DATA_SET(0x01);
12528 + } else {
12529 + pDev->IrqEnableRegisters.int_status_enable &= ~INT_STATUS_ENABLE_MBOX_DATA_SET(0x01);
12530 + }
12531 +
12532 + /* copy into our temp area */
12533 + A_MEMCPY(&regs,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE);
12534 + UNLOCK_AR6K(pDev);
12535 +
12536 + do {
12537 +
12538 + if (AsyncMode) {
12539 +
12540 + pIOPacket = AR6KAllocIOPacket(pDev);
12541 +
12542 + if (NULL == pIOPacket) {
12543 + status = A_NO_MEMORY;
12544 + AR_DEBUG_ASSERT(FALSE);
12545 + break;
12546 + }
12547 +
12548 + /* copy values to write to our async I/O buffer */
12549 + A_MEMCPY(pIOPacket->pBuffer,&regs,AR6K_IRQ_ENABLE_REGS_SIZE);
12550 +
12551 + /* stick in our completion routine when the I/O operation completes */
12552 + pIOPacket->Completion = DevDoEnableDisableRecvAsyncHandler;
12553 + pIOPacket->pContext = pDev;
12554 +
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,
12561 + pIOPacket);
12562 + break;
12563 + }
12564 +
12565 + /* if we get here we are doing it synchronously */
12566 +
12567 + status = HIFReadWrite(pDev->HIFDevice,
12568 + INT_STATUS_ENABLE_ADDRESS,
12569 + &regs.int_status_enable,
12570 + AR6K_IRQ_ENABLE_REGS_SIZE,
12571 + HIF_WR_SYNC_BYTE_INC,
12572 + NULL);
12573 +
12574 + } while (FALSE);
12575 +
12576 + if (A_FAILED(status) && (pIOPacket != NULL)) {
12577 + AR6KFreeIOPacket(pDev,pIOPacket);
12578 + }
12579 +
12580 + return status;
12581 +}
12582 +
12583 +
12584 +A_STATUS DevStopRecv(AR6K_DEVICE *pDev, A_BOOL AsyncMode)
12585 +{
12586 + if (NULL == pDev->HifMaskUmaskRecvEvent) {
12587 + return DevDoEnableDisableRecvNormal(pDev,FALSE,AsyncMode);
12588 + } else {
12589 + return DevDoEnableDisableRecvOverride(pDev,FALSE,AsyncMode);
12590 + }
12591 +}
12592 +
12593 +A_STATUS DevEnableRecv(AR6K_DEVICE *pDev, A_BOOL AsyncMode)
12594 +{
12595 + if (NULL == pDev->HifMaskUmaskRecvEvent) {
12596 + return DevDoEnableDisableRecvNormal(pDev,TRUE,AsyncMode);
12597 + } else {
12598 + return DevDoEnableDisableRecvOverride(pDev,TRUE,AsyncMode);
12599 + }
12600 +}
12601 +
12602 +void DevDumpRegisters(AR6K_IRQ_PROC_REGISTERS *pIrqProcRegs,
12603 + AR6K_IRQ_ENABLE_REGISTERS *pIrqEnableRegs)
12604 +{
12605 +
12606 + AR_DEBUG_PRINTF(ATH_DEBUG_DUMP, ("\n<------- Register Table -------->\n"));
12607 +
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]));
12625 + }
12626 +
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"));
12633 + }
12634 +}
12635 +
12636 +
12637 +#ifdef MBOXHW_UNIT_TEST
12638 +
12639 +
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
12643 + *
12644 + * the unit test has the following constraints:
12645 + *
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 :
12648 + *
12649 + * 1 buffer - 128 bytes
12650 + * 1 buffer - 256 bytes
12651 + * 1 buffer - 512 bytes
12652 + * 1 buffer - 1024 bytes
12653 + *
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.
12657 + *
12658 + *
12659 + * Note: To simplifythe test , we assume that the chosen buffer sizes
12660 + * will fall on a nice block pad
12661 + *
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.
12665 + *
12666 + * */
12667 +
12668 +#define A_ROUND_UP_PWR2(x, align) (((int) (x) + ((align)-1)) & ~((align)-1))
12669 +
12670 +#define BUFFER_BLOCK_PAD 128
12671 +
12672 +#if 0
12673 +#define BUFFER1 128
12674 +#define BUFFER2 256
12675 +#define BUFFER3 512
12676 +#define BUFFER4 1024
12677 +#endif
12678 +
12679 +#if 1
12680 +#define BUFFER1 80
12681 +#define BUFFER2 200
12682 +#define BUFFER3 444
12683 +#define BUFFER4 800
12684 +#endif
12685 +
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) )
12690 +
12691 +#define TEST_BYTES (BUFFER1 + BUFFER2 + BUFFER3 + BUFFER4)
12692 +
12693 +#define TEST_CREDITS_RECV_TIMEOUT 100
12694 +
12695 +static A_UINT8 g_Buffer[TOTAL_BYTES];
12696 +static A_UINT32 g_MailboxAddrs[AR6K_MAILBOXES];
12697 +static A_UINT32 g_BlockSizes[AR6K_MAILBOXES];
12698 +
12699 +#define BUFFER_PROC_LIST_DEPTH 4
12700 +
12701 +typedef struct _BUFFER_PROC_LIST{
12702 + A_UINT8 *pBuffer;
12703 + A_UINT32 length;
12704 +}BUFFER_PROC_LIST;
12705 +
12706 +
12707 +#define PUSH_BUFF_PROC_ENTRY(pList,len,pCurrpos) \
12708 +{ \
12709 + (pList)->pBuffer = (pCurrpos); \
12710 + (pList)->length = (len); \
12711 + (pCurrpos) += (len); \
12712 + (pList)++; \
12713 +}
12714 +
12715 +/* a simple and crude way to send different "message" sizes */
12716 +static void AssembleBufferList(BUFFER_PROC_LIST *pList)
12717 +{
12718 + A_UINT8 *pBuffer = g_Buffer;
12719 +
12720 +#if BUFFER_PROC_LIST_DEPTH < 4
12721 +#error "Buffer processing list depth is not deep enough!!"
12722 +#endif
12723 +
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);
12728 +
12729 +}
12730 +
12731 +#define FILL_ZERO TRUE
12732 +#define FILL_COUNTING FALSE
12733 +static void InitBuffers(A_BOOL Zero)
12734 +{
12735 + A_UINT16 *pBuffer16 = (A_UINT16 *)g_Buffer;
12736 + int i;
12737 +
12738 + /* fill buffer with 16 bit counting pattern or zeros */
12739 + for (i = 0; i < (TOTAL_BYTES / 2) ; i++) {
12740 + if (!Zero) {
12741 + pBuffer16[i] = (A_UINT16)i;
12742 + } else {
12743 + pBuffer16[i] = 0;
12744 + }
12745 + }
12746 +}
12747 +
12748 +
12749 +static A_BOOL CheckOneBuffer(A_UINT16 *pBuffer16, int Length)
12750 +{
12751 + int i;
12752 + A_UINT16 startCount;
12753 + A_BOOL success = TRUE;
12754 +
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) {
12763 + success = FALSE;
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]));
12768 + break;
12769 + }
12770 + }
12771 +
12772 + return success;
12773 +}
12774 +
12775 +static A_BOOL CheckBuffers(void)
12776 +{
12777 + int i;
12778 + A_BOOL success = TRUE;
12779 + BUFFER_PROC_LIST checkList[BUFFER_PROC_LIST_DEPTH];
12780 +
12781 + /* assemble the list */
12782 + AssembleBufferList(checkList);
12783 +
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);
12787 + if (!success) {
12788 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Buffer : 0x%X, Length:%d failed verify \n",
12789 + (A_UINT32)checkList[i].pBuffer, checkList[i].length));
12790 + break;
12791 + }
12792 + }
12793 +
12794 + return success;
12795 +}
12796 +
12797 + /* find the end marker for the last buffer we will be sending */
12798 +static A_UINT16 GetEndMarker(void)
12799 +{
12800 + A_UINT8 *pBuffer;
12801 + BUFFER_PROC_LIST checkList[BUFFER_PROC_LIST_DEPTH];
12802 +
12803 + /* fill up buffers with the normal counting pattern */
12804 + InitBuffers(FILL_COUNTING);
12805 +
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]);
12810 +
12811 + /* the last count in the last buffer is the marker */
12812 + return (A_UINT16)pBuffer[0] | ((A_UINT16)pBuffer[1] << 8);
12813 +}
12814 +
12815 +#define ATH_PRINT_OUT_ZONE ATH_DEBUG_ERR
12816 +
12817 +/* send the ordered buffers to the target */
12818 +static A_STATUS SendBuffers(AR6K_DEVICE *pDev, int mbox)
12819 +{
12820 + A_STATUS status = A_OK;
12821 + A_UINT32 request = HIF_WR_SYNC_BLOCK_INC;
12822 + BUFFER_PROC_LIST sendList[BUFFER_PROC_LIST_DEPTH];
12823 + int i;
12824 + int totalBytes = 0;
12825 + int paddedLength;
12826 + int totalwPadding = 0;
12827 +
12828 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Sending buffers on mailbox : %d \n",mbox));
12829 +
12830 + /* fill buffer with counting pattern */
12831 + InitBuffers(FILL_COUNTING);
12832 +
12833 + /* assemble the order in which we send */
12834 + AssembleBufferList(sendList);
12835 +
12836 + for (i = 0; i < BUFFER_PROC_LIST_DEPTH; i++) {
12837 +
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));
12841 +
12842 + /* send each buffer synchronously */
12843 + status = HIFReadWrite(pDev->HIFDevice,
12844 + g_MailboxAddrs[mbox],
12845 + sendList[i].pBuffer,
12846 + paddedLength,
12847 + request,
12848 + NULL);
12849 + if (status != A_OK) {
12850 + break;
12851 + }
12852 + totalBytes += sendList[i].length;
12853 + totalwPadding += paddedLength;
12854 + }
12855 +
12856 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Sent %d bytes (%d padded bytes) to mailbox : %d \n",totalBytes,totalwPadding,mbox));
12857 +
12858 + return status;
12859 +}
12860 +
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)
12863 +{
12864 + A_STATUS status = A_OK;
12865 + int timeout = TEST_CREDITS_RECV_TIMEOUT;
12866 + A_UINT8 credits = 0;
12867 + A_UINT32 address;
12868 +
12869 + while (TRUE) {
12870 +
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;
12879 + break;
12880 + }
12881 +
12882 + if (credits) {
12883 + break;
12884 + }
12885 +
12886 + timeout--;
12887 +
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;
12892 + break;
12893 + }
12894 +
12895 + /* delay a little, target may not be ready */
12896 + A_MDELAY(1000);
12897 +
12898 + }
12899 +
12900 + if (status == A_OK) {
12901 + *pCredits = credits;
12902 + }
12903 +
12904 + return status;
12905 +}
12906 +
12907 +
12908 +/* wait for the buffers to come back */
12909 +static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox)
12910 +{
12911 + A_STATUS status = A_OK;
12912 + A_UINT32 request = HIF_RD_SYNC_BLOCK_INC;
12913 + BUFFER_PROC_LIST recvList[BUFFER_PROC_LIST_DEPTH];
12914 + int curBuffer;
12915 + int credits;
12916 + int i;
12917 + int totalBytes = 0;
12918 + int paddedLength;
12919 + int totalwPadding = 0;
12920 +
12921 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Waiting for buffers on mailbox : %d \n",mbox));
12922 +
12923 + /* zero the buffers */
12924 + InitBuffers(FILL_ZERO);
12925 +
12926 + /* assemble the order in which we should receive */
12927 + AssembleBufferList(recvList);
12928 +
12929 + curBuffer = 0;
12930 +
12931 + while (curBuffer < BUFFER_PROC_LIST_DEPTH) {
12932 +
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);
12936 +
12937 + if (status != A_OK) {
12938 + break;
12939 + }
12940 +
12941 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Got %d messages on mailbox : %d \n",credits, mbox));
12942 +
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));
12950 +
12951 + status = HIFReadWrite(pDev->HIFDevice,
12952 + g_MailboxAddrs[mbox],
12953 + recvList[curBuffer].pBuffer,
12954 + paddedLength,
12955 + request,
12956 + NULL);
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]));
12960 + break;
12961 + }
12962 +
12963 + totalwPadding += paddedLength;
12964 + totalBytes += recvList[curBuffer].length;
12965 + curBuffer++;
12966 + }
12967 +
12968 + if (status != A_OK) {
12969 + break;
12970 + }
12971 + /* go back and get some more */
12972 + credits = 0;
12973 + }
12974 +
12975 + if (totalBytes != TEST_BYTES) {
12976 + AR_DEBUG_ASSERT(FALSE);
12977 + } else {
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));
12980 + }
12981 +
12982 + return status;
12983 +
12984 +
12985 +}
12986 +
12987 +static A_STATUS DoOneMboxHWTest(AR6K_DEVICE *pDev, int mbox)
12988 +{
12989 + A_STATUS status;
12990 +
12991 + do {
12992 + /* send out buffers */
12993 + status = SendBuffers(pDev,mbox);
12994 +
12995 + if (status != A_OK) {
12996 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Sending buffers Failed : %d mbox:%d\n",status,mbox));
12997 + break;
12998 + }
12999 +
13000 + /* go get them, this will block */
13001 + status = RecvBuffers(pDev, mbox);
13002 +
13003 + if (status != A_OK) {
13004 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Recv buffers Failed : %d mbox:%d\n",status,mbox));
13005 + break;
13006 + }
13007 +
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;
13012 + break;
13013 + }
13014 +
13015 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" Send/Recv success! mailbox : %d \n",mbox));
13016 +
13017 + } while (FALSE);
13018 +
13019 + return status;
13020 +}
13021 +
13022 +/* here is where the test starts */
13023 +A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev)
13024 +{
13025 + int i;
13026 + A_STATUS status;
13027 + int credits = 0;
13028 + A_UINT8 params[4];
13029 + int numBufs;
13030 + int bufferSize;
13031 + A_UINT16 temp;
13032 +
13033 +
13034 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest START - \n"));
13035 +
13036 + do {
13037 + /* get the addresses for all 4 mailboxes */
13038 + status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR,
13039 + g_MailboxAddrs, sizeof(g_MailboxAddrs));
13040 +
13041 + if (status != A_OK) {
13042 + AR_DEBUG_ASSERT(FALSE);
13043 + break;
13044 + }
13045 +
13046 + /* get the block sizes */
13047 + status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
13048 + g_BlockSizes, sizeof(g_BlockSizes));
13049 +
13050 + if (status != A_OK) {
13051 + AR_DEBUG_ASSERT(FALSE);
13052 + break;
13053 + }
13054 +
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
13057 + * the same. */
13058 + g_BlockSizes[0] = g_BlockSizes[1];
13059 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Block Size to use: %d \n",g_BlockSizes[0]));
13060 +
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));
13064 + break;
13065 + }
13066 +
13067 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Waiting for target.... \n"));
13068 +
13069 + /* the target lets us know it is ready by giving us 1 credit on
13070 + * mailbox 0 */
13071 + status = GetCredits(pDev, 0, &credits);
13072 +
13073 + if (status != A_OK) {
13074 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait for target ready \n"));
13075 + break;
13076 + }
13077 +
13078 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Target is ready ...\n"));
13079 +
13080 + /* read the first 4 scratch registers */
13081 + status = HIFReadWrite(pDev->HIFDevice,
13082 + SCRATCH_ADDRESS,
13083 + params,
13084 + 4,
13085 + HIF_RD_SYNC_BYTE_INC,
13086 + NULL);
13087 +
13088 + if (status != A_OK) {
13089 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait get parameters \n"));
13090 + break;
13091 + }
13092 +
13093 + numBufs = params[0];
13094 + bufferSize = (int)(((A_UINT16)params[2] << 8) | (A_UINT16)params[1]);
13095 +
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));
13099 +
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;
13104 + break;
13105 + }
13106 +
13107 + temp = GetEndMarker();
13108 +
13109 + status = HIFReadWrite(pDev->HIFDevice,
13110 + SCRATCH_ADDRESS + 4,
13111 + (A_UINT8 *)&temp,
13112 + 2,
13113 + HIF_WR_SYNC_BYTE_INC,
13114 + NULL);
13115 +
13116 + if (status != A_OK) {
13117 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write end marker \n"));
13118 + break;
13119 + }
13120 +
13121 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("End Marker: 0x%X \n",temp));
13122 +
13123 + temp = (A_UINT16)g_BlockSizes[1];
13124 + /* convert to a mask */
13125 + temp = temp - 1;
13126 + status = HIFReadWrite(pDev->HIFDevice,
13127 + SCRATCH_ADDRESS + 6,
13128 + (A_UINT8 *)&temp,
13129 + 2,
13130 + HIF_WR_SYNC_BYTE_INC,
13131 + NULL);
13132 +
13133 + if (status != A_OK) {
13134 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write block mask \n"));
13135 + break;
13136 + }
13137 +
13138 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Set Block Mask: 0x%X \n",temp));
13139 +
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) {
13144 + break;
13145 + }
13146 + }
13147 +
13148 + } while (FALSE);
13149 +
13150 + if (status == A_OK) {
13151 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - SUCCESS! - \n"));
13152 + } else {
13153 + AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - FAILED! - \n"));
13154 + }
13155 + /* don't let HTC_Start continue, the target is actually not running any HTC code */
13156 + return A_ERROR;
13157 +}
13158 +#endif
13159 +
13160 +
13161 +
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
13165 --- /dev/null
13166 +++ b/drivers/sdio/function/wlan/ar6000/htc/ar6k.h
13167 @@ -0,0 +1,191 @@
13168 +/*
13169 + *
13170 + * Copyright (c) 2007 Atheros Communications Inc.
13171 + * All rights reserved.
13172 + *
13173 + *
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;
13177 + *
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.
13182 + *
13183 + *
13184 + *
13185 + */
13186 +
13187 +#ifndef AR6K_H_
13188 +#define AR6K_H_
13189 +
13190 +#define AR6K_MAILBOXES 4
13191 +
13192 +/* HTC runs over mailbox 0 */
13193 +#define HTC_MAILBOX 0
13194 +
13195 +#define AR6K_TARGET_DEBUG_INTR_MASK 0x01
13196 +
13197 +#define OTHER_INTS_ENABLED (INT_STATUS_ENABLE_ERROR_MASK | \
13198 + INT_STATUS_ENABLE_CPU_MASK | \
13199 + INT_STATUS_ENABLE_COUNTER_MASK)
13200 +
13201 +//#define MBOXHW_UNIT_TEST 1
13202 +
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;
13211 + A_UINT8 hole[2];
13212 + A_UINT32 rx_lookahead[2];
13213 +} POSTPACK AR6K_IRQ_PROC_REGISTERS;
13214 +
13215 +#define AR6K_IRQ_PROC_REGS_SIZE sizeof(AR6K_IRQ_PROC_REGISTERS)
13216 +
13217 +
13218 +
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;
13225 +
13226 +#include "athendpack.h"
13227 +
13228 +#define AR6K_IRQ_ENABLE_REGS_SIZE sizeof(AR6K_IRQ_ENABLE_REGISTERS)
13229 +
13230 +#define AR6K_REG_IO_BUFFER_SIZE 32
13231 +#define AR6K_MAX_REG_IO_BUFFERS 8
13232 +
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;
13238 +
13239 +typedef struct _AR6K_DEVICE {
13240 + A_MUTEX_T Lock;
13241 + AR6K_IRQ_PROC_REGISTERS IrqProcRegisters;
13242 + AR6K_IRQ_ENABLE_REGISTERS IrqEnableRegisters;
13243 + void *HIFDevice;
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;
13255 +} AR6K_DEVICE;
13256 +
13257 +#define IS_DEV_IRQ_PROCESSING_ASYNC_ALLOWED(pDev) ((pDev)->HifIRQProcessingMode != HIF_DEVICE_IRQ_SYNC_ONLY)
13258 +
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,
13264 + int TimeoutMS);
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);
13270 +
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);
13277 +
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;
13281 + A_STATUS status;
13282 +
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);
13291 + }
13292 + return A_EINVAL;
13293 + }
13294 +#endif
13295 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,
13296 + ("DevSendPacket, Padded Length: %d Mbox:0x%X (mode:%s)\n",
13297 + paddedLength,
13298 + pDev->MailboxAddress,
13299 + sync ? "SYNC" : "ASYNC"));
13300 +
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 */
13307 +
13308 + if (sync) {
13309 + pPacket->Status = status;
13310 + }
13311 +
13312 + return status;
13313 +}
13314 +
13315 +static INLINE A_STATUS DevRecvPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket, A_UINT32 RecvLength) {
13316 + A_UINT32 paddedLength;
13317 + A_STATUS status;
13318 + A_BOOL sync = (pPacket->Completion == NULL) ? TRUE : FALSE;
13319 +
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);
13330 + }
13331 + return A_EINVAL;
13332 + }
13333 +
13334 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
13335 + ("DevRecvPacket, Padded Length: %d Mbox:0x%X (mode:%s)\n",
13336 + paddedLength,
13337 + pDev->MailboxAddress,
13338 + sync ? "SYNC" : "ASYNC"));
13339 +
13340 + status = HIFReadWrite(pDev->HIFDevice,
13341 + pDev->MailboxAddress,
13342 + pPacket->pBuffer,
13343 + paddedLength,
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 */
13346 +
13347 + if (sync) {
13348 + pPacket->Status = status;
13349 + }
13350 +
13351 + return status;
13352 +}
13353 +
13354 +#ifdef MBOXHW_UNIT_TEST
13355 +A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev);
13356 +#endif
13357 +
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
13362 --- /dev/null
13363 +++ b/drivers/sdio/function/wlan/ar6000/htc/ar6k_events.c
13364 @@ -0,0 +1,638 @@
13365 +/*
13366 + * AR6K Driver layer event handling (i.e. interrupts, message polling)
13367 + *
13368 + * Copyright (c) 2007 Atheros Communications Inc.
13369 + * All rights reserved.
13370 + *
13371 + *
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;
13375 + *
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.
13380 + *
13381 + *
13382 + *
13383 + */
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"
13390 +#include "hif.h"
13391 +#include "htc_packet.h"
13392 +#include "ar6k.h"
13393 +
13394 +extern void AR6KFreeIOPacket(AR6K_DEVICE *pDev, HTC_PACKET *pPacket);
13395 +extern HTC_PACKET *AR6KAllocIOPacket(AR6K_DEVICE *pDev);
13396 +
13397 +static A_STATUS DevServiceDebugInterrupt(AR6K_DEVICE *pDev);
13398 +
13399 +#define DELAY_PER_INTERVAL_MS 10 /* 10 MS delay per polling interval */
13400 +
13401 +/* completion routine for ALL HIF layer async I/O */
13402 +A_STATUS DevRWCompletionHandler(void *context, A_STATUS status)
13403 +{
13404 + HTC_PACKET *pPacket = (HTC_PACKET *)context;
13405 +
13406 + COMPLETE_HTC_PACKET(pPacket,status);
13407 +
13408 + return A_OK;
13409 +}
13410 +
13411 +/* mailbox recv message polling */
13412 +A_STATUS DevPollMboxMsgRecv(AR6K_DEVICE *pDev,
13413 + A_UINT32 *pLookAhead,
13414 + int TimeoutMS)
13415 +{
13416 + A_STATUS status = A_OK;
13417 + int timeout = TimeoutMS/DELAY_PER_INTERVAL_MS;
13418 +
13419 + AR_DEBUG_ASSERT(timeout > 0);
13420 +
13421 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+DevPollMboxMsgRecv \n"));
13422 +
13423 + while (TRUE) {
13424 +
13425 + if (pDev->GetPendingEventsFunc != NULL)
13426 + {
13427 +
13428 + HIF_PENDING_EVENTS_INFO events;
13429 +
13430 + /* the HIF layer uses a special mechanism to get events, do this
13431 + * synchronously */
13432 + status = pDev->GetPendingEventsFunc(pDev->HIFDevice,
13433 + &events,
13434 + NULL);
13435 + if (A_FAILED(status))
13436 + {
13437 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to get pending events \n"));
13438 + break;
13439 + }
13440 +
13441 + if (events.Events & HIF_RECV_MSG_AVAIL)
13442 + {
13443 + /* there is a message available, the lookahead should be valid now */
13444 + *pLookAhead = events.LookAhead;
13445 +
13446 + break;
13447 + }
13448 + }
13449 + else
13450 + {
13451 +
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,
13459 + NULL);
13460 +
13461 + if (A_FAILED(status))
13462 + {
13463 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to read register table \n"));
13464 + break;
13465 + }
13466 +
13467 + /* check for MBOX data and valid lookahead */
13468 + if (pDev->IrqProcRegisters.host_int_status & (1 << HTC_MAILBOX))
13469 + {
13470 + if (pDev->IrqProcRegisters.rx_lookahead_valid & (1 << HTC_MAILBOX))
13471 + {
13472 + /* mailbox has a message and the look ahead is valid */
13473 + *pLookAhead = pDev->IrqProcRegisters.rx_lookahead[HTC_MAILBOX];
13474 + break;
13475 + }
13476 + }
13477 +
13478 + }
13479 +
13480 + timeout--;
13481 +
13482 + if (timeout <= 0)
13483 + {
13484 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" Timeout waiting for recv message \n"));
13485 + status = A_ERROR;
13486 +
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);
13492 + }
13493 +
13494 + break;
13495 + }
13496 +
13497 + /* delay a little */
13498 + A_MDELAY(DELAY_PER_INTERVAL_MS);
13499 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,(" Retry Mbox Poll : %d \n",timeout));
13500 + }
13501 +
13502 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-DevPollMboxMsgRecv \n"));
13503 +
13504 + return status;
13505 +}
13506 +
13507 +static A_STATUS DevServiceCPUInterrupt(AR6K_DEVICE *pDev)
13508 +{
13509 + A_STATUS status;
13510 + A_UINT8 cpu_int_status;
13511 + A_UINT8 regBuffer[4];
13512 +
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));
13520 +
13521 + /* Clear the interrupt */
13522 + pDev->IrqProcRegisters.cpu_int_status &= ~cpu_int_status; /* W1C */
13523 +
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 */
13527 +
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;
13534 +
13535 + status = HIFReadWrite(pDev->HIFDevice,
13536 + CPU_INT_STATUS_ADDRESS,
13537 + regBuffer,
13538 + 4,
13539 + HIF_WR_SYNC_BYTE_FIX,
13540 + NULL);
13541 +
13542 + AR_DEBUG_ASSERT(status == A_OK);
13543 + return status;
13544 +}
13545 +
13546 +
13547 +static A_STATUS DevServiceErrorInterrupt(AR6K_DEVICE *pDev)
13548 +{
13549 + A_STATUS status;
13550 + A_UINT8 error_int_status;
13551 + A_UINT8 regBuffer[4];
13552 +
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));
13559 +
13560 + if (ERROR_INT_STATUS_WAKEUP_GET(error_int_status)) {
13561 + /* Wakeup */
13562 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Error : Wakeup\n"));
13563 + }
13564 +
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"));
13568 + }
13569 +
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"));
13573 + }
13574 +
13575 + /* Clear the interrupt */
13576 + pDev->IrqProcRegisters.error_int_status &= ~error_int_status; /* W1C */
13577 +
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 */
13581 +
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;
13588 +
13589 + status = HIFReadWrite(pDev->HIFDevice,
13590 + ERROR_INT_STATUS_ADDRESS,
13591 + regBuffer,
13592 + 4,
13593 + HIF_WR_SYNC_BYTE_FIX,
13594 + NULL);
13595 +
13596 + AR_DEBUG_ASSERT(status == A_OK);
13597 + return status;
13598 +}
13599 +
13600 +static A_STATUS DevServiceDebugInterrupt(AR6K_DEVICE *pDev)
13601 +{
13602 + A_UINT32 dummy;
13603 + A_STATUS status;
13604 +
13605 + /* Send a target failure event to the application */
13606 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Target debug interrupt\n"));
13607 +
13608 + if (pDev->TargetFailureCallback != NULL) {
13609 + pDev->TargetFailureCallback(pDev->HTCContext);
13610 + }
13611 +
13612 + /* clear the interrupt , the debug error interrupt is
13613 + * counter 0 */
13614 + /* read counter to clear interrupt */
13615 + status = HIFReadWrite(pDev->HIFDevice,
13616 + COUNT_DEC_ADDRESS,
13617 + (A_UINT8 *)&dummy,
13618 + 4,
13619 + HIF_RD_SYNC_BYTE_INC,
13620 + NULL);
13621 +
13622 + AR_DEBUG_ASSERT(status == A_OK);
13623 + return status;
13624 +}
13625 +
13626 +static A_STATUS DevServiceCounterInterrupt(AR6K_DEVICE *pDev)
13627 +{
13628 + A_UINT8 counter_int_status;
13629 +
13630 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ, ("Counter Interrupt\n"));
13631 +
13632 + counter_int_status = pDev->IrqProcRegisters.counter_int_status &
13633 + pDev->IrqEnableRegisters.counter_int_status_enable;
13634 +
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));
13639 +
13640 + /* Check if the debug interrupt is pending */
13641 + if (counter_int_status & AR6K_TARGET_DEBUG_INTR_MASK) {
13642 + return DevServiceDebugInterrupt(pDev);
13643 + }
13644 +
13645 + return A_OK;
13646 +}
13647 +
13648 +/* callback when our fetch to get interrupt status registers completes */
13649 +static void DevGetEventAsyncHandler(void *Context, HTC_PACKET *pPacket)
13650 +{
13651 + AR6K_DEVICE *pDev = (AR6K_DEVICE *)Context;
13652 + A_UINT32 lookAhead = 0;
13653 + A_BOOL otherInts = FALSE;
13654 +
13655 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevGetEventAsyncHandler: (dev: 0x%X)\n", (A_UINT32)pDev));
13656 +
13657 + do {
13658 +
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 */
13663 + break;
13664 + }
13665 +
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"));
13673 + }
13674 + }
13675 + if (pEvents->Events & HIF_OTHER_EVENTS) {
13676 + otherInts = TRUE;
13677 + }
13678 + } else {
13679 + /* standard interrupt table handling.... */
13680 + AR6K_IRQ_PROC_REGISTERS *pReg = (AR6K_IRQ_PROC_REGISTERS *)pPacket->pBuffer;
13681 + A_UINT8 host_int_status;
13682 +
13683 + host_int_status = pReg->host_int_status & pDev->IrqEnableRegisters.int_status_enable;
13684 +
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"));
13692 + }
13693 + }
13694 + }
13695 +
13696 + if (host_int_status) {
13697 + /* there are other interrupts to handle */
13698 + otherInts = TRUE;
13699 + }
13700 + }
13701 +
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);
13710 + } else {
13711 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,
13712 + (" DevGetEventAsyncHandler : detected another message, lookahead :0x%X \n",
13713 + lookAhead));
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);
13717 + }
13718 +
13719 + } while (FALSE);
13720 +
13721 + /* free this IO packet */
13722 + AR6KFreeIOPacket(pDev,pPacket);
13723 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevGetEventAsyncHandler \n"));
13724 +}
13725 +
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)
13729 +{
13730 + AR6K_DEVICE *pDev = (AR6K_DEVICE *)context;
13731 + A_STATUS status = A_OK;
13732 + HTC_PACKET *pIOPacket;
13733 +
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 */
13736 +
13737 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevCheckPendingRecvMsgsAsync: (dev: 0x%X)\n", (A_UINT32)pDev));
13738 +
13739 + do {
13740 +
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 */
13745 + break;
13746 + }
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);
13751 +
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);
13757 + break;
13758 + }
13759 +
13760 + /* stick in our completion routine when the I/O operation completes */
13761 + pIOPacket->Completion = DevGetEventAsyncHandler;
13762 + pIOPacket->pContext = pDev;
13763 +
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,
13768 + pIOPacket);
13769 +
13770 + } else {
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,
13777 + pIOPacket);
13778 + }
13779 +
13780 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,(" Async IO issued to get interrupt status...\n"));
13781 + } while (FALSE);
13782 +
13783 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevCheckPendingRecvMsgsAsync \n"));
13784 +
13785 + return status;
13786 +}
13787 +
13788 +/* process pending interrupts synchronously */
13789 +static A_STATUS ProcessPendingIRQs(AR6K_DEVICE *pDev, A_BOOL *pDone, A_BOOL *pASyncProcessing)
13790 +{
13791 + A_STATUS status = A_OK;
13792 + A_UINT8 host_int_status = 0;
13793 + A_UINT32 lookAhead = 0;
13794 +
13795 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+ProcessPendingIRQs: (dev: 0x%X)\n", (A_UINT32)pDev));
13796 +
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.
13801 + * */
13802 + do {
13803 +
13804 + if (pDev->GetPendingEventsFunc != NULL) {
13805 + HIF_PENDING_EVENTS_INFO events;
13806 +
13807 + /* the HIF layer uses a special mechanism to get events
13808 + * get this synchronously */
13809 + status = pDev->GetPendingEventsFunc(pDev->HIFDevice,
13810 + &events,
13811 + NULL);
13812 +
13813 + if (A_FAILED(status)) {
13814 + break;
13815 + }
13816 +
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"));
13821 + }
13822 + }
13823 +
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 */
13829 + break;
13830 + }
13831 +
13832 + /* otherwise fall through and read the register table */
13833 + }
13834 +
13835 + /*
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
13838 + * registers.
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);
13846 + *
13847 + */
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,
13853 + NULL);
13854 +
13855 + if (A_FAILED(status)) {
13856 + break;
13857 + }
13858 +
13859 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_IRQ)) {
13860 + DevDumpRegisters(&pDev->IrqProcRegisters,
13861 + &pDev->IrqEnableRegisters);
13862 + }
13863 +
13864 + /* Update only those registers that are enabled */
13865 + host_int_status = pDev->IrqProcRegisters.host_int_status &
13866 + pDev->IrqEnableRegisters.int_status_enable;
13867 +
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"));
13880 + }
13881 + }
13882 + }
13883 + } else {
13884 + /* not valid to check if the HIF has another mechanism for reading mailbox pending status*/
13885 + host_int_status &= ~(1 << HTC_MAILBOX);
13886 + }
13887 +
13888 + } while (FALSE);
13889 +
13890 +
13891 + do {
13892 +
13893 + /* did the interrupt status fetches succeed? */
13894 + if (A_FAILED(status)) {
13895 + break;
13896 + }
13897 +
13898 + if ((0 == host_int_status) && (0 == lookAhead)) {
13899 + /* nothing to process, the caller can use this to break out of a loop */
13900 + *pDone = TRUE;
13901 + break;
13902 + }
13903 +
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
13907 + * mailbox...
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)) {
13913 + break;
13914 + }
13915 + }
13916 +
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));
13921 +
13922 + if (HOST_INT_STATUS_CPU_GET(host_int_status)) {
13923 + /* CPU Interrupt */
13924 + status = DevServiceCPUInterrupt(pDev);
13925 + if (A_FAILED(status)){
13926 + break;
13927 + }
13928 + }
13929 +
13930 + if (HOST_INT_STATUS_ERROR_GET(host_int_status)) {
13931 + /* Error Interrupt */
13932 + status = DevServiceErrorInterrupt(pDev);
13933 + if (A_FAILED(status)){
13934 + break;
13935 + }
13936 + }
13937 +
13938 + if (HOST_INT_STATUS_COUNTER_GET(host_int_status)) {
13939 + /* Counter Interrupt */
13940 + status = DevServiceCounterInterrupt(pDev);
13941 + if (A_FAILED(status)){
13942 + break;
13943 + }
13944 + }
13945 +
13946 + } while (FALSE);
13947 +
13948 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-ProcessPendingIRQs: (done:%d, async:%d) status=%d \n",
13949 + *pDone, *pASyncProcessing, status));
13950 +
13951 + return status;
13952 +}
13953 +
13954 +
13955 +/* Synchronousinterrupt handler, this handler kicks off all interrupt processing.*/
13956 +A_STATUS DevDsrHandler(void *context)
13957 +{
13958 + AR6K_DEVICE *pDev = (AR6K_DEVICE *)context;
13959 + A_STATUS status = A_OK;
13960 + A_BOOL done = FALSE;
13961 + A_BOOL asyncProc = FALSE;
13962 +
13963 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("+DevDsrHandler: (dev: 0x%X)\n", (A_UINT32)pDev));
13964 +
13965 +
13966 + while (!done) {
13967 + status = ProcessPendingIRQs(pDev, &done, &asyncProc);
13968 + if (A_FAILED(status)) {
13969 + break;
13970 + }
13971 +
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) */
13979 + }
13980 +
13981 + if (asyncProc) {
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 */
13985 + break;
13986 + }
13987 +
13988 + }
13989 +
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);
13996 + }
13997 +
13998 + AR_DEBUG_PRINTF(ATH_DEBUG_IRQ,("-DevDsrHandler \n"));
13999 + return A_OK;
14000 +}
14001 +
14002 +
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
14006 --- /dev/null
14007 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc.c
14008 @@ -0,0 +1,507 @@
14009 +/*
14010 + *
14011 + * Copyright (c) 2007 Atheros Communications Inc.
14012 + * All rights reserved.
14013 + *
14014 + *
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;
14018 + *
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.
14023 + *
14024 + *
14025 + *
14026 + */
14027 +
14028 +#include "htc_internal.h"
14029 +
14030 +
14031 +static HTC_INIT_INFO HTCInitInfo = {NULL,NULL,NULL};
14032 +static A_BOOL HTCInitialized = FALSE;
14033 +
14034 +static A_STATUS HTCTargetInsertedHandler(void *hif_handle);
14035 +static A_STATUS HTCTargetRemovedHandler(void *handle, A_STATUS status);
14036 +static void HTCReportFailure(void *Context);
14037 +
14038 +/* Initializes the HTC layer */
14039 +A_STATUS HTCInit(HTC_INIT_INFO *pInitInfo)
14040 +{
14041 + HTC_CALLBACKS htcCallbacks;
14042 +
14043 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Enter\n"));
14044 + if (HTCInitialized) {
14045 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Exit\n"));
14046 + return A_OK;
14047 + }
14048 +
14049 + A_MEMCPY(&HTCInitInfo,pInitInfo,sizeof(HTC_INIT_INFO));
14050 +
14051 + A_MEMZERO(&htcCallbacks, sizeof(HTC_CALLBACKS));
14052 +
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;
14061 +
14062 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Exit\n"));
14063 + return A_OK;
14064 +}
14065 +
14066 +void HTCFreeControlBuffer(HTC_TARGET *target, HTC_PACKET *pPacket, HTC_PACKET_QUEUE *pList)
14067 +{
14068 + LOCK_HTC(target);
14069 + HTC_PACKET_ENQUEUE(pList,pPacket);
14070 + UNLOCK_HTC(target);
14071 +}
14072 +
14073 +HTC_PACKET *HTCAllocControlBuffer(HTC_TARGET *target, HTC_PACKET_QUEUE *pList)
14074 +{
14075 + HTC_PACKET *pPacket;
14076 +
14077 + LOCK_HTC(target);
14078 + pPacket = HTC_PACKET_DEQUEUE(pList);
14079 + UNLOCK_HTC(target);
14080 +
14081 + return pPacket;
14082 +}
14083 +
14084 +/* cleanup the HTC instance */
14085 +static void HTCCleanup(HTC_TARGET *target)
14086 +{
14087 + if (A_IS_MUTEX_VALID(&target->HTCLock)) {
14088 + A_MUTEX_DELETE(&target->HTCLock);
14089 + }
14090 +
14091 + if (A_IS_MUTEX_VALID(&target->HTCRxLock)) {
14092 + A_MUTEX_DELETE(&target->HTCRxLock);
14093 + }
14094 +
14095 + if (A_IS_MUTEX_VALID(&target->HTCTxLock)) {
14096 + A_MUTEX_DELETE(&target->HTCTxLock);
14097 + }
14098 + /* free our instance */
14099 + A_FREE(target);
14100 +}
14101 +
14102 +/* registered target arrival callback from the HIF layer */
14103 +static A_STATUS HTCTargetInsertedHandler(void *hif_handle)
14104 +{
14105 + HTC_TARGET *target = NULL;
14106 + A_STATUS status;
14107 + int i;
14108 +
14109 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("htcTargetInserted - Enter\n"));
14110 +
14111 + do {
14112 +
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;
14117 + break;
14118 + }
14119 +
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);
14126 +
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;
14138 +
14139 + /* setup device layer */
14140 + status = DevSetup(&target->Device);
14141 +
14142 + if (A_FAILED(status)) {
14143 + break;
14144 + }
14145 +
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,
14151 + target,
14152 + target->HTCControlBuffers[i].Buffer,
14153 + HTC_CONTROL_BUFFER_SIZE,
14154 + ENDPOINT_0);
14155 + HTC_FREE_CONTROL_RX(target,pControlPacket);
14156 + }
14157 +
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);
14165 + }
14166 +
14167 + } while (FALSE);
14168 +
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);
14173 + } else {
14174 + if (target != NULL) {
14175 + HTCCleanup(target);
14176 + }
14177 + }
14178 +
14179 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("htcTargetInserted - Exit\n"));
14180 +
14181 + return status;
14182 +}
14183 +
14184 +/* registered removal callback from the HIF layer */
14185 +static A_STATUS HTCTargetRemovedHandler(void *handle, A_STATUS status)
14186 +{
14187 + HTC_TARGET *target;
14188 +
14189 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCTargetRemovedHandler handle:0x%X \n",(A_UINT32)handle));
14190 +
14191 + if (NULL == handle) {
14192 + /* this could be NULL in the event that target initialization failed */
14193 + return A_OK;
14194 + }
14195 +
14196 + target = ((AR6K_DEVICE *)handle)->HTCContext;
14197 +
14198 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, (" removing target:0x%X instance:0x%X ... \n",
14199 + (A_UINT32)target, (A_UINT32)target->pInstanceContext));
14200 +
14201 + if (target->pInstanceContext != NULL) {
14202 + /* let upper layer know, it needs to call HTCStop() */
14203 + HTCInitInfo.DeleteInstance(target->pInstanceContext);
14204 + }
14205 +
14206 + HIFShutDownDevice(target->Device.HIFDevice);
14207 +
14208 + HTCCleanup(target);
14209 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCTargetRemovedHandler \n"));
14210 + return A_OK;
14211 +}
14212 +
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)
14216 +{
14217 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14218 + return target->Device.HIFDevice;
14219 +}
14220 +
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)
14224 +{
14225 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14226 +
14227 + target->pInstanceContext = Instance;
14228 +}
14229 +
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)
14233 +{
14234 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14235 + A_STATUS status;
14236 + HTC_PACKET *pPacket = NULL;
14237 + HTC_READY_MSG *pRdyMsg;
14238 + HTC_SERVICE_CONNECT_REQ connect;
14239 + HTC_SERVICE_CONNECT_RESP resp;
14240 +
14241 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Enter (target:0x%X) \n", (A_UINT32)target));
14242 +
14243 + do {
14244 +
14245 +#ifdef MBOXHW_UNIT_TEST
14246 +
14247 + status = DoMboxHWTest(&target->Device);
14248 +
14249 + if (status != A_OK) {
14250 + break;
14251 + }
14252 +
14253 +#endif
14254 +
14255 + /* we should be getting 1 control message that the target is ready */
14256 + status = HTCWaitforControlMessage(target, &pPacket);
14257 +
14258 + if (A_FAILED(status)) {
14259 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" Target Not Available!!\n"));
14260 + break;
14261 + }
14262 +
14263 + /* we controlled the buffer creation so it has to be properly aligned */
14264 + pRdyMsg = (HTC_READY_MSG *)pPacket->pBuffer;
14265 +
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;
14271 + break;
14272 + }
14273 +
14274 + if (pRdyMsg->CreditCount == 0 || pRdyMsg->CreditSize == 0) {
14275 + /* this message is not valid */
14276 + AR_DEBUG_ASSERT(FALSE);
14277 + status = A_EPROTO;
14278 + break;
14279 + }
14280 +
14281 + target->TargetCredits = pRdyMsg->CreditCount;
14282 + target->TargetCreditSize = pRdyMsg->CreditSize;
14283 +
14284 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, (" Target Ready: credits: %d credit size: %d\n",
14285 + target->TargetCredits, target->TargetCreditSize));
14286 +
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;
14297 +
14298 + /* connect fake service */
14299 + status = HTCConnectService((HTC_HANDLE)target,
14300 + &connect,
14301 + &resp);
14302 +
14303 + if (!A_FAILED(status)) {
14304 + break;
14305 + }
14306 +
14307 + } while (FALSE);
14308 +
14309 + if (pPacket != NULL) {
14310 + HTC_FREE_CONTROL_RX(target,pPacket);
14311 + }
14312 +
14313 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Exit\n"));
14314 +
14315 + return status;
14316 +}
14317 +
14318 +
14319 +
14320 +/* Start HTC, enable interrupts and let the target know host has finished setup */
14321 +A_STATUS HTCStart(HTC_HANDLE HTCHandle)
14322 +{
14323 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14324 + HTC_PACKET *pPacket;
14325 + A_STATUS status;
14326 +
14327 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Enter\n"));
14328 +
14329 + /* now that we are starting, push control receive buffers into the
14330 + * HTC control endpoint */
14331 +
14332 + while (1) {
14333 + pPacket = HTC_ALLOC_CONTROL_RX(target);
14334 + if (NULL == pPacket) {
14335 + break;
14336 + }
14337 + HTCAddReceivePkt((HTC_HANDLE)target,pPacket);
14338 + }
14339 +
14340 + do {
14341 +
14342 + AR_DEBUG_ASSERT(target->InitCredits != NULL);
14343 + AR_DEBUG_ASSERT(target->EpCreditDistributionListHead != NULL);
14344 + AR_DEBUG_ASSERT(target->EpCreditDistributionListHead->pNext != NULL);
14345 +
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);
14352 +
14353 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_TRC)) {
14354 + DumpCreditDistStates(target);
14355 + }
14356 +
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);
14360 +
14361 + if (A_FAILED(status)) {
14362 + break;
14363 + }
14364 +
14365 + /* unmask interrupts */
14366 + status = DevUnmaskInterrupts(&target->Device);
14367 +
14368 + if (A_FAILED(status)) {
14369 + HTCStop(target);
14370 + }
14371 +
14372 + } while (FALSE);
14373 +
14374 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCStart Exit\n"));
14375 + return status;
14376 +}
14377 +
14378 +
14379 +/* stop HTC communications, i.e. stop interrupt reception, and flush all queued buffers */
14380 +void HTCStop(HTC_HANDLE HTCHandle)
14381 +{
14382 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14383 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCStop \n"));
14384 +
14385 + /* mark that we are shutting down .. */
14386 + target->HTCStateFlags |= HTC_STATE_STOPPING;
14387 +
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);
14391 +
14392 + /* flush all send packets */
14393 + HTCFlushSendPkts(target);
14394 + /* flush all recv buffers */
14395 + HTCFlushRecvBuffers(target);
14396 +
14397 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCStop \n"));
14398 +}
14399 +
14400 +/* undo what was done in HTCInit() */
14401 +void HTCShutDown(void)
14402 +{
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"));
14408 +}
14409 +
14410 +void HTCDumpCreditStates(HTC_HANDLE HTCHandle)
14411 +{
14412 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
14413 +
14414 + LOCK_HTC_TX(target);
14415 +
14416 + DumpCreditDistStates(target);
14417 +
14418 + UNLOCK_HTC_TX(target);
14419 +}
14420 +
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)
14424 +{
14425 + HTC_TARGET *target = (HTC_TARGET *)Context;
14426 +
14427 + target->TargetFailure = TRUE;
14428 +
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);
14432 + }
14433 +}
14434 +
14435 +void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescription)
14436 +{
14437 + A_CHAR stream[60];
14438 + A_UINT32 i;
14439 + A_UINT16 offset, count;
14440 +
14441 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("<---------Dumping %d Bytes : %s ------>\n", length, pDescription));
14442 +
14443 + count = 0;
14444 + offset = 0;
14445 + for(i = 0; i < length; i++) {
14446 + sprintf(stream + offset, "%2.2X ", buffer[i]);
14447 + count ++;
14448 + offset += 3;
14449 +
14450 + if(count == 16) {
14451 + count = 0;
14452 + offset = 0;
14453 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("[H]: %s\n", stream));
14454 + A_MEMZERO(stream, 60);
14455 + }
14456 + }
14457 +
14458 + if(offset != 0) {
14459 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("[H]: %s\n", stream));
14460 + }
14461 +
14462 + AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("<------------------------------------------------->\n"));
14463 +}
14464 +
14465 +A_BOOL HTCGetEndpointStatistics(HTC_HANDLE HTCHandle,
14466 + HTC_ENDPOINT_ID Endpoint,
14467 + HTC_ENDPOINT_STAT_ACTION Action,
14468 + HTC_ENDPOINT_STATS *pStats)
14469 +{
14470 +
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;
14475 +
14476 + switch (Action) {
14477 + case HTC_EP_STAT_SAMPLE :
14478 + sample = TRUE;
14479 + break;
14480 + case HTC_EP_STAT_SAMPLE_AND_CLEAR :
14481 + sample = TRUE;
14482 + clearStats = TRUE;
14483 + break;
14484 + case HTC_EP_STAT_CLEAR :
14485 + clearStats = TRUE;
14486 + break;
14487 + default:
14488 + break;
14489 + }
14490 +
14491 + A_ASSERT(Endpoint < ENDPOINT_MAX);
14492 +
14493 + /* lock out TX and RX while we sample and/or clear */
14494 + LOCK_HTC_TX(target);
14495 + LOCK_HTC_RX(target);
14496 +
14497 + if (sample) {
14498 + A_ASSERT(pStats != NULL);
14499 + /* return the stats to the caller */
14500 + A_MEMCPY(pStats, &target->EndPoint[Endpoint].EndPointStats, sizeof(HTC_ENDPOINT_STATS));
14501 + }
14502 +
14503 + if (clearStats) {
14504 + /* reset stats */
14505 + A_MEMZERO(&target->EndPoint[Endpoint].EndPointStats, sizeof(HTC_ENDPOINT_STATS));
14506 + }
14507 +
14508 + UNLOCK_HTC_RX(target);
14509 + UNLOCK_HTC_TX(target);
14510 +
14511 + return TRUE;
14512 +#else
14513 + return FALSE;
14514 +#endif
14515 +}
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
14519 --- /dev/null
14520 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_debug.h
14521 @@ -0,0 +1,65 @@
14522 +#ifndef HTC_DEBUG_H_
14523 +#define HTC_DEBUG_H_
14524 +/*
14525 + *
14526 + * Copyright (c) 2004-2007 Atheros Communications Inc.
14527 + * All rights reserved.
14528 + *
14529 + *
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;
14533 + *
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.
14538 + *
14539 + *
14540 + *
14541 + */
14542 +
14543 +/* ------- Debug related stuff ------- */
14544 +enum {
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,
14554 +};
14555 +
14556 +#ifdef DEBUG
14557 +
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); \
14563 + } \
14564 +} while(0)
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); \
14569 + } \
14570 +} while (0)
14571 +#define AR_DEBUG_ASSERT(test) do { \
14572 + if (!(test)) { \
14573 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Debug Assert Caught, File %s, Line: %d, Test:%s \n",__FILE__, __LINE__,#test)); \
14574 + } \
14575 +} while(0)
14576 +extern int debughtc;
14577 +#else
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
14582 +#endif
14583 +
14584 +void DebugDumpBytes(A_UCHAR *buffer, A_UINT16 length, char *pDescription);
14585 +
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
14590 --- /dev/null
14591 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_internal.h
14592 @@ -0,0 +1,168 @@
14593 +/*
14594 + *
14595 + * Copyright (c) 2007 Atheros Communications Inc.
14596 + * All rights reserved.
14597 + *
14598 + *
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;
14602 + *
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.
14607 + *
14608 + *
14609 + *
14610 + */
14611 +
14612 +#ifndef _HTC_INTERNAL_H_
14613 +#define _HTC_INTERNAL_H_
14614 +
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
14618 +
14619 +//#define HTC_EP_STAT_PROFILING
14620 +
14621 +#ifdef __cplusplus
14622 +extern "C" {
14623 +#endif /* __cplusplus */
14624 +
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"
14631 +#include "htc.h"
14632 +#include "htc_api.h"
14633 +#include "bmi_msg.h"
14634 +#include "hif.h"
14635 +#include "ar6k.h"
14636 +
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
14641 +
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 */
14655 +#endif
14656 +} HTC_ENDPOINT;
14657 +
14658 +#ifdef HTC_EP_STAT_PROFILING
14659 +#define INC_HTC_EP_STAT(p,stat,count) (p)->EndPointStats.stat += (count);
14660 +#else
14661 +#define INC_HTC_EP_STAT(p,stat,count)
14662 +#endif
14663 +
14664 +#define HTC_SERVICE_TX_PACKET_TAG HTC_TX_PACKET_TAG_INTERNAL
14665 +
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)
14669 +
14670 +#define HTC_CONTROL_BUFFER_SIZE (HTC_MAX_CONTROL_MESSAGE_LENGTH + HTC_HDR_LENGTH)
14671 +
14672 +typedef struct HTC_CONTROL_BUFFER {
14673 + HTC_PACKET HtcPacket;
14674 + A_UINT8 Buffer[HTC_CONTROL_BUFFER_SIZE];
14675 +} HTC_CONTROL_BUFFER;
14676 +
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;
14703 +#endif
14704 +} HTC_TARGET;
14705 +
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);
14713 +
14714 +#define GET_HTC_TARGET_FROM_HANDLE(hnd) ((HTC_TARGET *)(hnd))
14715 +#define HTC_RECYCLE_RX_PKT(target,p) \
14716 +{ \
14717 + HTC_PACKET_RESET_RX(pPacket); \
14718 + HTCAddReceivePkt((HTC_HANDLE)(target),(p)); \
14719 +}
14720 +
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);
14738 +
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;
14744 + }
14745 + return pPacket;
14746 +}
14747 +
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) \
14751 +{ \
14752 + HTC_PACKET_RESET_RX(p); \
14753 + HTCFreeControlBuffer((t),(p),&(t)->ControlBufferRXFreeList); \
14754 +}
14755 +
14756 +#ifdef __cplusplus
14757 +}
14758 +#endif
14759 +
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
14764 --- /dev/null
14765 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_recv.c
14766 @@ -0,0 +1,703 @@
14767 +/*
14768 + *
14769 + * Copyright (c) 2007 Atheros Communications Inc.
14770 + * All rights reserved.
14771 + *
14772 + *
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;
14776 + *
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.
14781 + *
14782 + *
14783 + *
14784 + */
14785 +
14786 +#include "htc_internal.h"
14787 +
14788 +#define HTCIssueRecv(t, p) \
14789 + DevRecvPacket(&(t)->Device, \
14790 + (p), \
14791 + (p)->ActualLength)
14792 +
14793 +#define DO_RCV_COMPLETION(t,p,e) \
14794 +{ \
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, \
14799 + (p)); \
14800 + } else { \
14801 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" recycling empty packet \n")); \
14802 + HTC_RECYCLE_RX_PKT((t), (p)); \
14803 + } \
14804 +}
14805 +
14806 +#ifdef HTC_EP_STAT_PROFILING
14807 +#define HTC_RX_STAT_PROFILE(t,ep,lookAhead) \
14808 +{ \
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); \
14813 + } \
14814 + UNLOCK_HTC_RX((t)); \
14815 +}
14816 +#else
14817 +#define HTC_RX_STAT_PROFILE(t,ep,lookAhead)
14818 +#endif
14819 +
14820 +static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target,
14821 + A_UINT8 *pBuffer,
14822 + int Length,
14823 + A_UINT32 *pNextLookAhead,
14824 + HTC_ENDPOINT_ID FromEndpoint)
14825 +{
14826 + HTC_RECORD_HDR *pRecord;
14827 + A_UINT8 *pRecordBuf;
14828 + HTC_LOOKAHEAD_REPORT *pLookAhead;
14829 + A_UINT8 *pOrigBuffer;
14830 + int origLength;
14831 + A_STATUS status;
14832 +
14833 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCProcessTrailer (length:%d) \n", Length));
14834 +
14835 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) {
14836 + AR_DEBUG_PRINTBUF(pBuffer,Length,"Recv Trailer");
14837 + }
14838 +
14839 + pOrigBuffer = pBuffer;
14840 + origLength = Length;
14841 + status = A_OK;
14842 +
14843 + while (Length > 0) {
14844 +
14845 + if (Length < sizeof(HTC_RECORD_HDR)) {
14846 + status = A_EPROTO;
14847 + break;
14848 + }
14849 + /* these are byte aligned structs */
14850 + pRecord = (HTC_RECORD_HDR *)pBuffer;
14851 + Length -= sizeof(HTC_RECORD_HDR);
14852 + pBuffer += sizeof(HTC_RECORD_HDR);
14853 +
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;
14860 + break;
14861 + }
14862 + /* start of record follows the header */
14863 + pRecordBuf = pBuffer;
14864 +
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)),
14871 + FromEndpoint);
14872 + break;
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)) {
14878 +
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));
14883 +
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];
14889 +
14890 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) {
14891 + DebugDumpBytes((A_UINT8 *)pNextLookAhead,4,"Next Look Ahead");
14892 + }
14893 + }
14894 + break;
14895 + default:
14896 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, (" unhandled record: id:%d length:%d \n",
14897 + pRecord->RecordID, pRecord->Length));
14898 + break;
14899 + }
14900 +
14901 + if (A_FAILED(status)) {
14902 + break;
14903 + }
14904 +
14905 + /* advance buffer past this record for next time around */
14906 + pBuffer += pRecord->Length;
14907 + Length -= pRecord->Length;
14908 + }
14909 +
14910 + if (A_FAILED(status)) {
14911 + DebugDumpBytes(pOrigBuffer,origLength,"BAD Recv Trailer");
14912 + }
14913 +
14914 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCProcessTrailer \n"));
14915 + return status;
14916 +
14917 +}
14918 +
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)
14922 +{
14923 + A_UINT8 temp;
14924 + A_UINT8 *pBuf;
14925 + A_STATUS status = A_OK;
14926 + A_UINT16 payloadLen;
14927 + A_UINT32 lookAhead;
14928 +
14929 + pBuf = pPacket->pBuffer;
14930 +
14931 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCProcessRecvHeader \n"));
14932 +
14933 + if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) {
14934 + AR_DEBUG_PRINTBUF(pBuf,pPacket->ActualLength,"HTC Recv PKT");
14935 + }
14936 +
14937 + do {
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);
14941 +
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];
14946 +
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,
14959 + "Last trailer");
14960 + }
14961 +#endif
14962 + status = A_EPROTO;
14963 + break;
14964 + }
14965 +
14966 + /* get flags */
14967 + temp = A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, Flags);
14968 +
14969 + if (temp & HTC_FLAGS_RECV_TRAILER) {
14970 + /* this packet has a trailer */
14971 +
14972 + /* extract the trailer length in control byte 0 */
14973 + temp = A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, ControlBytes[0]);
14974 +
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;
14980 + break;
14981 + }
14982 +
14983 + /* process trailer data that follows HDR + application payload */
14984 + status = HTCProcessTrailer(target,
14985 + (pBuf + HTC_HDR_LENGTH + payloadLen - temp),
14986 + temp,
14987 + pNextLookAhead,
14988 + pPacket->Endpoint);
14989 +
14990 + if (A_FAILED(status)) {
14991 + break;
14992 + }
14993 +
14994 +#ifdef HTC_CAPTURE_LAST_FRAME
14995 + A_MEMCPY(target->LastTrailer, (pBuf + HTC_HDR_LENGTH + payloadLen - temp), temp);
14996 + target->LastTrailerLength = temp;
14997 +#endif
14998 + /* trim length by trailer bytes */
14999 + pPacket->ActualLength -= temp;
15000 + }
15001 +#ifdef HTC_CAPTURE_LAST_FRAME
15002 + else {
15003 + target->LastTrailerLength = 0;
15004 + }
15005 +#endif
15006 +
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;
15011 +
15012 + } while (FALSE);
15013 +
15014 + if (A_FAILED(status)) {
15015 + /* dump the whole packet */
15016 + DebugDumpBytes(pBuf,pPacket->ActualLength,"BAD HTC Recv PKT");
15017 + } else {
15018 +#ifdef HTC_CAPTURE_LAST_FRAME
15019 + A_MEMCPY(&target->LastFrameHdr,pBuf,sizeof(HTC_FRAME_HDR));
15020 +#endif
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");
15024 + }
15025 + }
15026 + }
15027 +
15028 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCProcessRecvHeader \n"));
15029 + return status;
15030 +}
15031 +
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)
15035 +{
15036 + HTC_TARGET *target = (HTC_TARGET *)Context;
15037 + HTC_ENDPOINT *pEndpoint;
15038 + A_UINT32 nextLookAhead = 0;
15039 + A_STATUS status;
15040 +
15041 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCRecvCompleteHandler (status:%d, ep:%d) \n",
15042 + pPacket->Status, pPacket->Endpoint));
15043 +
15044 + AR_DEBUG_ASSERT(pPacket->Endpoint < ENDPOINT_MAX);
15045 + pEndpoint = &target->EndPoint[pPacket->Endpoint];
15046 + pPacket->Completion = NULL;
15047 +
15048 + /* get completion status */
15049 + status = pPacket->Status;
15050 +
15051 + do {
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));
15055 + break;
15056 + }
15057 + /* process the header for any trailer data */
15058 + status = HTCProcessRecvHeader(target,pPacket,&nextLookAhead);
15059 +
15060 + if (A_FAILED(status)) {
15061 + break;
15062 + }
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",
15068 + nextLookAhead));
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,
15076 + 4,
15077 + "BAD lookahead from lookahead report");
15078 + }
15079 + } else {
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);
15087 + }
15088 +
15089 + HTC_RX_STAT_PROFILE(target,pEndpoint,nextLookAhead);
15090 + DO_RCV_COMPLETION(target,pPacket,pEndpoint);
15091 +
15092 + } while (FALSE);
15093 +
15094 + if (A_FAILED(status)) {
15095 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15096 + ("HTCRecvCompleteHandler , message fetch failed (status = %d) \n",
15097 + status));
15098 + /* recyle this packet */
15099 + HTC_RECYCLE_RX_PKT(target, pPacket);
15100 + }
15101 +
15102 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCRecvCompleteHandler\n"));
15103 +}
15104 +
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)
15109 +{
15110 + A_STATUS status;
15111 + A_UINT32 lookAhead;
15112 + HTC_PACKET *pPacket = NULL;
15113 + HTC_FRAME_HDR *pHdr;
15114 +
15115 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCWaitforControlMessage \n"));
15116 +
15117 + do {
15118 +
15119 + *ppControlPacket = NULL;
15120 +
15121 + /* call the polling function to see if we have a message */
15122 + status = DevPollMboxMsgRecv(&target->Device,
15123 + &lookAhead,
15124 + HTC_TARGET_RESPONSE_TIMEOUT);
15125 +
15126 + if (A_FAILED(status)) {
15127 + break;
15128 + }
15129 +
15130 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
15131 + ("HTCWaitforControlMessage : lookAhead : 0x%X \n", lookAhead));
15132 +
15133 + /* check the lookahead */
15134 + pHdr = (HTC_FRAME_HDR *)&lookAhead;
15135 +
15136 + if (pHdr->EndpointID != ENDPOINT_0) {
15137 + /* unexpected endpoint number, should be zero */
15138 + AR_DEBUG_ASSERT(FALSE);
15139 + status = A_EPROTO;
15140 + break;
15141 + }
15142 +
15143 + if (A_FAILED(status)) {
15144 + /* bad message */
15145 + AR_DEBUG_ASSERT(FALSE);
15146 + status = A_EPROTO;
15147 + break;
15148 + }
15149 +
15150 + pPacket = HTC_ALLOC_CONTROL_RX(target);
15151 +
15152 + if (pPacket == NULL) {
15153 + AR_DEBUG_ASSERT(FALSE);
15154 + status = A_NO_MEMORY;
15155 + break;
15156 + }
15157 +
15158 + pPacket->HTCReserved = lookAhead;
15159 + pPacket->ActualLength = pHdr->PayloadLen + HTC_HDR_LENGTH;
15160 +
15161 + if (pPacket->ActualLength > pPacket->BufferLength) {
15162 + AR_DEBUG_ASSERT(FALSE);
15163 + status = A_EPROTO;
15164 + break;
15165 + }
15166 +
15167 + /* we want synchronous operation */
15168 + pPacket->Completion = NULL;
15169 +
15170 + /* get the message from the device, this will block */
15171 + status = HTCIssueRecv(target, pPacket);
15172 +
15173 + if (A_FAILED(status)) {
15174 + break;
15175 + }
15176 +
15177 + /* process receive header */
15178 + status = HTCProcessRecvHeader(target,pPacket,NULL);
15179 +
15180 + pPacket->Status = status;
15181 +
15182 + if (A_FAILED(status)) {
15183 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
15184 + ("HTCWaitforControlMessage, HTCProcessRecvHeader failed (status = %d) \n",
15185 + status));
15186 + break;
15187 + }
15188 +
15189 + /* give the caller this control message packet, they are responsible to free */
15190 + *ppControlPacket = pPacket;
15191 +
15192 + } while (FALSE);
15193 +
15194 + if (A_FAILED(status)) {
15195 + if (pPacket != NULL) {
15196 + /* cleanup buffer on error */
15197 + HTC_FREE_CONTROL_RX(target,pPacket);
15198 + }
15199 + }
15200 +
15201 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCWaitforControlMessage \n"));
15202 +
15203 + return status;
15204 +}
15205 +
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)
15208 +{
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;
15215 +
15216 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("+HTCRecvMessagePendingHandler LookAhead:0x%X \n",LookAhead));
15217 +
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;
15223 + }
15224 +
15225 + if (pAsyncProc != NULL) {
15226 + /* indicate to caller how we decided to process this */
15227 + *pAsyncProc = asyncProc;
15228 + }
15229 +
15230 + while (TRUE) {
15231 +
15232 + pHdr = (HTC_FRAME_HDR *)&LookAhead;
15233 +
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;
15238 + break;
15239 + }
15240 +
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;
15245 + break;
15246 + }
15247 +
15248 + pEndpoint = &target->EndPoint[pHdr->EndpointID];
15249 +
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;
15254 + break;
15255 + }
15256 +
15257 + /* lock RX to get a buffer */
15258 + LOCK_HTC_RX(target);
15259 +
15260 + /* get a packet from the endpoint recv queue */
15261 + pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->RxBuffers);
15262 +
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 */
15274 + }
15275 + }
15276 +
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;
15282 + }
15283 +
15284 + UNLOCK_HTC_RX(target);
15285 +
15286 + if (A_FAILED(status)) {
15287 + /* no buffers */
15288 + break;
15289 + }
15290 +
15291 + AR_DEBUG_ASSERT(pPacket->Endpoint == pHdr->EndpointID);
15292 +
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;
15299 + break;
15300 + }
15301 +
15302 + pPacket->HTCReserved = LookAhead; /* set expected look ahead */
15303 + /* set the amount of data to fetch */
15304 + pPacket->ActualLength = pHdr->PayloadLen + HTC_HDR_LENGTH;
15305 +
15306 + if (asyncProc) {
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;
15311 + } else {
15312 + /* fully synchronous */
15313 + pPacket->Completion = NULL;
15314 + }
15315 +
15316 + /* go fetch the packet */
15317 + status = HTCIssueRecv(target, pPacket);
15318 +
15319 + if (A_FAILED(status)) {
15320 + break;
15321 + }
15322 +
15323 + if (asyncProc) {
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 */
15327 + break;
15328 + }
15329 +
15330 + /* in the sync case, we process the packet, check lookaheads and then repeat */
15331 +
15332 + LookAhead = 0;
15333 + status = HTCProcessRecvHeader(target,pPacket,&LookAhead);
15334 +
15335 + if (A_FAILED(status)) {
15336 + break;
15337 + }
15338 +
15339 + HTC_RX_STAT_PROFILE(target,pEndpoint,LookAhead);
15340 + DO_RCV_COMPLETION(target,pPacket,pEndpoint);
15341 +
15342 + pPacket = NULL;
15343 +
15344 + if (0 == LookAhead) {
15345 + break;
15346 + }
15347 +
15348 + }
15349 +
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);
15356 + status = A_OK;
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);
15364 + }
15365 + }
15366 +
15367 + AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HTCRecvMessagePendingHandler \n"));
15368 +
15369 + return status;
15370 +}
15371 +
15372 +/* Makes a buffer available to the HTC module */
15373 +A_STATUS HTCAddReceivePkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket)
15374 +{
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;
15379 +
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));
15383 +
15384 + do {
15385 +
15386 + if (HTC_STOPPING(target)) {
15387 + status = A_ECANCELED;
15388 + break;
15389 + }
15390 +
15391 + AR_DEBUG_ASSERT(pPacket->Endpoint < ENDPOINT_MAX);
15392 +
15393 + pEndpoint = &target->EndPoint[pPacket->Endpoint];
15394 +
15395 + LOCK_HTC_RX(target);
15396 +
15397 + /* store receive packet */
15398 + HTC_PACKET_ENQUEUE(&pEndpoint->RxBuffers, pPacket);
15399 +
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;
15408 + }
15409 + }
15410 +
15411 + UNLOCK_HTC_RX(target);
15412 +
15413 + if (unblockRecv && !HTC_STOPPING(target)) {
15414 + /* TODO : implement a buffer threshold count? */
15415 + DevEnableRecv(&target->Device,DEV_ENABLE_RECV_SYNC);
15416 + }
15417 +
15418 + } while (FALSE);
15419 +
15420 + return status;
15421 +}
15422 +
15423 +static void HTCFlushEndpointRX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint)
15424 +{
15425 + HTC_PACKET *pPacket;
15426 +
15427 + LOCK_HTC_RX(target);
15428 +
15429 + while (1) {
15430 + pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->RxBuffers);
15431 + if (NULL == pPacket) {
15432 + break;
15433 + }
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,
15441 + pPacket);
15442 + LOCK_HTC_RX(target);
15443 + }
15444 +
15445 + UNLOCK_HTC_RX(target);
15446 +
15447 +
15448 +}
15449 +
15450 +void HTCFlushRecvBuffers(HTC_TARGET *target)
15451 +{
15452 + HTC_ENDPOINT *pEndpoint;
15453 + int i;
15454 +
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.. */
15461 + continue;
15462 + }
15463 + HTCFlushEndpointRX(target,pEndpoint);
15464 + }
15465 +
15466 +
15467 +}
15468 +
15469 +
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
15473 --- /dev/null
15474 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_send.c
15475 @@ -0,0 +1,541 @@
15476 +/*
15477 + *
15478 + * Copyright (c) 2007 Atheros Communications Inc.
15479 + * All rights reserved.
15480 + *
15481 + *
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;
15485 + *
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.
15490 + *
15491 + *
15492 + *
15493 + */
15494 +
15495 +#include "htc_internal.h"
15496 +
15497 +#define DO_EP_TX_COMPLETION(ep,p) \
15498 +{ \
15499 + (p)->Completion = NULL; \
15500 + (ep)->EpCallBacks.EpTxComplete((ep)->EpCallBacks.pContext,(p)); \
15501 +}
15502 +
15503 +
15504 +/* call the distribute credits callback with the distribution */
15505 +#define DO_DISTRIBUTION(t,reason,description,pList) \
15506 +{ \
15507 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, \
15508 + (" calling distribute function (%s) (dfn:0x%X, ctxt:0x%X, dist:0x%X) \n", \
15509 + (description), \
15510 + (A_UINT32)(t)->DistributeCredits, \
15511 + (A_UINT32)(t)->pCredDistContext, \
15512 + (A_UINT32)pList)); \
15513 + (t)->DistributeCredits((t)->pCredDistContext, \
15514 + (pList), \
15515 + (reason)); \
15516 +}
15517 +
15518 +/* our internal send packet completion handler when packets are submited to the AR6K device
15519 + * layer */
15520 +static void HTCSendPktCompletionHandler(void *Context, HTC_PACKET *pPacket)
15521 +{
15522 + HTC_TARGET *target = (HTC_TARGET *)Context;
15523 + HTC_ENDPOINT *pEndpoint = &target->EndPoint[pPacket->Endpoint];
15524 +
15525 +
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));
15530 + }
15531 + /* first, fixup the head room we allocated */
15532 + pPacket->pBuffer += HTC_HDR_LENGTH;
15533 + /* do completion */
15534 + DO_EP_TX_COMPLETION(pEndpoint,pPacket);
15535 +}
15536 +
15537 +A_STATUS HTCIssueSend(HTC_TARGET *target, HTC_PACKET *pPacket, A_UINT8 SendFlags)
15538 +{
15539 + A_STATUS status;
15540 + A_UINT8 *pHdrBuf;
15541 + A_BOOL sync = FALSE;
15542 +
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);
15550 +
15551 + if (pPacket->Completion == NULL) {
15552 + /* mark that this request was synchronously issued */
15553 + sync = TRUE;
15554 + }
15555 +
15556 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,
15557 + ("+-HTCIssueSend: transmit length : %d (%s) \n",
15558 + pPacket->ActualLength + HTC_HDR_LENGTH,
15559 + sync ? "SYNC" : "ASYNC" ));
15560 +
15561 + /* send message to device */
15562 + status = DevSendPacket(&target->Device,
15563 + pPacket,
15564 + pPacket->ActualLength + HTC_HDR_LENGTH);
15565 +
15566 + if (sync) {
15567 + /* use local sync variable. If this was issued asynchronously, pPacket is no longer
15568 + * safe to access. */
15569 + pPacket->pBuffer += HTC_HDR_LENGTH;
15570 + }
15571 +
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 */
15574 +
15575 + return status;
15576 +}
15577 +
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)
15585 +{
15586 + HTC_PACKET *pPacket;
15587 + int creditsRequired;
15588 + int remainder;
15589 + A_UINT8 sendFlags;
15590 + A_BOOL epFull = FALSE;
15591 +
15592 + LOCK_HTC_TX(target);
15593 +
15594 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HTCTrySend (pPkt:0x%X)\n",(A_UINT32)pPacketToSend));
15595 +
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++;
15601 + }
15602 +
15603 + /* now drain the TX queue for transmission as long as we have enough
15604 + * credits */
15605 +
15606 + while (1) {
15607 +
15608 + if (HTC_QUEUE_EMPTY(&pEndpoint->TxQueue)) {
15609 + /* nothing in the queue */
15610 + break;
15611 + }
15612 +
15613 + sendFlags = 0;
15614 +
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));
15619 +
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;
15623 +
15624 + if (remainder) {
15625 + creditsRequired++;
15626 + }
15627 +
15628 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,(" Creds Required:%d Got:%d\n",
15629 + creditsRequired, pEndpoint->CreditDist.TxCredits));
15630 +
15631 + if (pEndpoint->CreditDist.TxCredits < creditsRequired) {
15632 +
15633 + /* not enough credits */
15634 +
15635 + if (pPacket->Endpoint == ENDPOINT_0) {
15636 + /* leave it in the queue */
15637 + break;
15638 + }
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
15642 + * */
15643 +
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,
15649 + "Seek Credits",
15650 + &pEndpoint->CreditDist);
15651 +
15652 + pEndpoint->CreditDist.TxCreditsSeek = 0;
15653 +
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));
15659 + break;
15660 + }
15661 +
15662 + }
15663 +
15664 + pEndpoint->CreditDist.TxCredits -= creditsRequired;
15665 + INC_HTC_EP_STAT(pEndpoint, TxCreditsConsummed, creditsRequired);
15666 +
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"));
15672 + }
15673 +
15674 + /* now we can fully dequeue */
15675 + pPacket = HTC_PACKET_DEQUEUE(&pEndpoint->TxQueue);
15676 + pEndpoint->CurrentTxQueueDepth--;
15677 +
15678 + INC_HTC_EP_STAT(pEndpoint, TxIssued, 1);
15679 +
15680 + UNLOCK_HTC_TX(target);
15681 +
15682 + HTCIssueSend(target, pPacket, sendFlags);
15683 +
15684 + LOCK_HTC_TX(target);
15685 +
15686 + /* go back and check for more messages */
15687 + }
15688 +
15689 + if (pEndpoint->CurrentTxQueueDepth >= pEndpoint->MaxTxQueueDepth) {
15690 + /* let caller know that this endpoint has reached the maximum depth */
15691 + epFull = TRUE;
15692 + }
15693 +
15694 + UNLOCK_HTC_TX(target);
15695 +
15696 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("-HTCTrySend: \n"));
15697 + return epFull;
15698 +}
15699 +
15700 +/* HTC API - HTCSendPkt */
15701 +A_STATUS HTCSendPkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket)
15702 +{
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;
15707 +
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));
15711 +
15712 + ep = pPacket->Endpoint;
15713 + AR_DEBUG_ASSERT(ep < ENDPOINT_MAX);
15714 + pEndpoint = &target->EndPoint[ep];
15715 +
15716 + do {
15717 +
15718 + if (HTC_STOPPING(target)) {
15719 + status = A_ECANCELED;
15720 + pPacket->Status = status;
15721 + DO_EP_TX_COMPLETION(pEndpoint,pPacket);
15722 + break;
15723 + }
15724 + /* everything sent through this interface is asynchronous */
15725 + /* fill in HTC completion routines */
15726 + pPacket->Completion = HTCSendPktCompletionHandler;
15727 + pPacket->pContext = target;
15728 +
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,
15736 + ep);
15737 + }
15738 + }
15739 +
15740 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCSendPkt \n"));
15741 + } while (FALSE);
15742 +
15743 + return status;
15744 +}
15745 +
15746 +
15747 +/* check TX queues to drain because of credit distribution update */
15748 +static INLINE void HTCCheckEndpointTxQueues(HTC_TARGET *target)
15749 +{
15750 + HTC_ENDPOINT *pEndpoint;
15751 + HTC_ENDPOINT_CREDIT_DIST *pDistItem;
15752 +
15753 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCCheckEndpointTxQueues \n"));
15754 + pDistItem = target->EpCreditDistributionListHead;
15755 +
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;
15762 +
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
15769 + * ones */
15770 + HTCTrySend(target, pEndpoint, NULL);
15771 + }
15772 +
15773 + pDistItem = pDistItem->pNext;
15774 + }
15775 +
15776 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCCheckEndpointTxQueues \n"));
15777 +}
15778 +
15779 +/* process credit reports and call distribution function */
15780 +void HTCProcessCreditRpt(HTC_TARGET *target, HTC_CREDIT_REPORT *pRpt, int NumEntries, HTC_ENDPOINT_ID FromEndpoint)
15781 +{
15782 + int i;
15783 + HTC_ENDPOINT *pEndpoint;
15784 + int totalCredits = 0;
15785 + A_BOOL doDist = FALSE;
15786 +
15787 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("+HTCProcessCreditRpt, Credit Report Entries:%d \n", NumEntries));
15788 +
15789 + /* lock out TX while we update credits */
15790 + LOCK_HTC_TX(target);
15791 +
15792 + for (i = 0; i < NumEntries; i++, pRpt++) {
15793 + if (pRpt->EndpointID >= ENDPOINT_MAX) {
15794 + AR_DEBUG_ASSERT(FALSE);
15795 + break;
15796 + }
15797 +
15798 + pEndpoint = &target->EndPoint[pRpt->EndpointID];
15799 +
15800 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Endpoint %d got %d credits \n",
15801 + pRpt->EndpointID, pRpt->Credits));
15802 +
15803 +
15804 +#ifdef HTC_EP_STAT_PROFILING
15805 +
15806 + INC_HTC_EP_STAT(pEndpoint, TxCreditRpts, 1);
15807 + INC_HTC_EP_STAT(pEndpoint, TxCreditsReturned, pRpt->Credits);
15808 +
15809 + if (FromEndpoint == pRpt->EndpointID) {
15810 + /* this credit report arrived on the same endpoint indicating it arrived in an RX
15811 + * packet */
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);
15818 + } else {
15819 + /* arrived on another endpoint */
15820 + INC_HTC_EP_STAT(pEndpoint, TxCreditsFromOther, pRpt->Credits);
15821 + INC_HTC_EP_STAT(pEndpoint, TxCreditRptsFromOther, 1);
15822 + }
15823 +
15824 +#endif
15825 +
15826 + if (ENDPOINT_0 == pRpt->EndpointID) {
15827 + /* always give endpoint 0 credits back */
15828 + pEndpoint->CreditDist.TxCredits += pRpt->Credits;
15829 + } else {
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 */
15834 + doDist = TRUE;
15835 + }
15836 +
15837 + totalCredits += pRpt->Credits;
15838 + }
15839 +
15840 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, (" Report indicated %d credits to distribute \n", totalCredits));
15841 +
15842 + if (doDist) {
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,
15847 + "Send Complete",
15848 + target->EpCreditDistributionListHead->pNext);
15849 + }
15850 +
15851 + UNLOCK_HTC_TX(target);
15852 +
15853 + if (totalCredits) {
15854 + HTCCheckEndpointTxQueues(target);
15855 + }
15856 +
15857 + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-HTCProcessCreditRpt \n"));
15858 +}
15859 +
15860 +/* flush endpoint TX queue */
15861 +static void HTCFlushEndpointTX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint, HTC_TX_TAG Tag)
15862 +{
15863 + HTC_PACKET *pPacket;
15864 + HTC_PACKET_QUEUE discardQueue;
15865 +
15866 + /* initialize the discard queue */
15867 + INIT_HTC_PACKET_QUEUE(&discardQueue);
15868 +
15869 + LOCK_HTC_TX(target);
15870 +
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) {
15873 +
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--;
15881 + }
15882 +
15883 + } ITERATE_END;
15884 +
15885 + UNLOCK_HTC_TX(target);
15886 +
15887 + /* empty the discard queue */
15888 + while (1) {
15889 + pPacket = HTC_PACKET_DEQUEUE(&discardQueue);
15890 + if (NULL == pPacket) {
15891 + break;
15892 + }
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);
15897 + }
15898 +
15899 +}
15900 +
15901 +void DumpCreditDist(HTC_ENDPOINT_CREDIT_DIST *pEPDist)
15902 +{
15903 + HTC_ENDPOINT *pEndpoint = (HTC_ENDPOINT *)pEPDist->pHTCReserved;
15904 +
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"));
15920 +}
15921 +
15922 +void DumpCreditDistStates(HTC_TARGET *target)
15923 +{
15924 + HTC_ENDPOINT_CREDIT_DIST *pEPList = target->EpCreditDistributionListHead;
15925 +
15926 + while (pEPList != NULL) {
15927 + DumpCreditDist(pEPList);
15928 + pEPList = pEPList->pNext;
15929 + }
15930 +
15931 + if (target->DistributeCredits != NULL) {
15932 + DO_DISTRIBUTION(target,
15933 + HTC_DUMP_CREDIT_STATE,
15934 + "Dump State",
15935 + NULL);
15936 + }
15937 +}
15938 +
15939 +/* flush all send packets from all endpoint queues */
15940 +void HTCFlushSendPkts(HTC_TARGET *target)
15941 +{
15942 + HTC_ENDPOINT *pEndpoint;
15943 + int i;
15944 +
15945 + DumpCreditDistStates(target);
15946 +
15947 + for (i = ENDPOINT_0; i < ENDPOINT_MAX; i++) {
15948 + pEndpoint = &target->EndPoint[i];
15949 + if (pEndpoint->ServiceID == 0) {
15950 + /* not in use.. */
15951 + continue;
15952 + }
15953 + HTCFlushEndpointTX(target,pEndpoint,HTC_TX_PACKET_TAG_ALL);
15954 + }
15955 +
15956 +
15957 +}
15958 +
15959 +/* HTC API to flush an endpoint's TX queue*/
15960 +void HTCFlushEndpoint(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint, HTC_TX_TAG Tag)
15961 +{
15962 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
15963 + HTC_ENDPOINT *pEndpoint = &target->EndPoint[Endpoint];
15964 +
15965 + if (pEndpoint->ServiceID == 0) {
15966 + AR_DEBUG_ASSERT(FALSE);
15967 + /* not in use.. */
15968 + return;
15969 + }
15970 +
15971 + HTCFlushEndpointTX(target, pEndpoint, Tag);
15972 +}
15973 +
15974 +/* HTC API to indicate activity to the credit distribution function */
15975 +void HTCIndicateActivityChange(HTC_HANDLE HTCHandle,
15976 + HTC_ENDPOINT_ID Endpoint,
15977 + A_BOOL Active)
15978 +{
15979 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
15980 + HTC_ENDPOINT *pEndpoint = &target->EndPoint[Endpoint];
15981 + A_BOOL doDist = FALSE;
15982 +
15983 + if (pEndpoint->ServiceID == 0) {
15984 + AR_DEBUG_ASSERT(FALSE);
15985 + /* not in use.. */
15986 + return;
15987 + }
15988 +
15989 + LOCK_HTC_TX(target);
15990 +
15991 + if (Active) {
15992 + if (!(pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE)) {
15993 + /* mark active now */
15994 + pEndpoint->CreditDist.DistFlags |= HTC_EP_ACTIVE;
15995 + doDist = TRUE;
15996 + }
15997 + } else {
15998 + if (pEndpoint->CreditDist.DistFlags & HTC_EP_ACTIVE) {
15999 + /* mark inactive now */
16000 + pEndpoint->CreditDist.DistFlags &= ~HTC_EP_ACTIVE;
16001 + doDist = TRUE;
16002 + }
16003 + }
16004 +
16005 + if (doDist) {
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);
16012 + }
16013 +
16014 + UNLOCK_HTC_TX(target);
16015 +
16016 +}
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
16020 --- /dev/null
16021 +++ b/drivers/sdio/function/wlan/ar6000/htc/htc_services.c
16022 @@ -0,0 +1,403 @@
16023 +/*
16024 + *
16025 + * Copyright (c) 2007 Atheros Communications Inc.
16026 + * All rights reserved.
16027 + *
16028 + *
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;
16032 + *
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.
16037 + *
16038 + *
16039 + *
16040 + */
16041 +
16042 +#include "htc_internal.h"
16043 +
16044 +void HTCControlTxComplete(void *Context, HTC_PACKET *pPacket)
16045 +{
16046 + /* not implemented
16047 + * we do not send control TX frames during normal runtime, only during setup */
16048 + AR_DEBUG_ASSERT(FALSE);
16049 +}
16050 +
16051 + /* callback when a control message arrives on this endpoint */
16052 +void HTCControlRecv(void *Context, HTC_PACKET *pPacket)
16053 +{
16054 + AR_DEBUG_ASSERT(pPacket->Endpoint == ENDPOINT_0);
16055 +
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));
16061 +
16062 + /* dump header and message */
16063 + DebugDumpBytes(pPacket->pBuffer - HTC_HDR_LENGTH,
16064 + pPacket->ActualLength + HTC_HDR_LENGTH,
16065 + "Unexpected ENDPOINT 0 Message");
16066 +
16067 + HTC_RECYCLE_RX_PKT((HTC_TARGET*)Context,pPacket);
16068 +}
16069 +
16070 +A_STATUS HTCSendSetupComplete(HTC_TARGET *target)
16071 +{
16072 + HTC_PACKET *pSendPacket = NULL;
16073 + A_STATUS status;
16074 + HTC_SETUP_COMPLETE_MSG *pSetupComplete;
16075 +
16076 + do {
16077 + /* allocate a packet to send to the target */
16078 + pSendPacket = HTC_ALLOC_CONTROL_TX(target);
16079 +
16080 + if (NULL == pSendPacket) {
16081 + status = A_NO_MEMORY;
16082 + break;
16083 + }
16084 +
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;
16089 +
16090 + SET_HTC_PACKET_INFO_TX(pSendPacket,
16091 + NULL,
16092 + (A_UINT8 *)pSetupComplete,
16093 + sizeof(HTC_SETUP_COMPLETE_MSG),
16094 + ENDPOINT_0,
16095 + HTC_SERVICE_TX_PACKET_TAG);
16096 +
16097 + /* we want synchronous operation */
16098 + pSendPacket->Completion = NULL;
16099 + /* send the message */
16100 + status = HTCIssueSend(target,pSendPacket,0);
16101 +
16102 + } while (FALSE);
16103 +
16104 + if (pSendPacket != NULL) {
16105 + HTC_FREE_CONTROL_TX(target,pSendPacket);
16106 + }
16107 +
16108 + return status;
16109 +}
16110 +
16111 +
16112 +A_STATUS HTCConnectService(HTC_HANDLE HTCHandle,
16113 + HTC_SERVICE_CONNECT_REQ *pConnectReq,
16114 + HTC_SERVICE_CONNECT_RESP *pConnectResp)
16115 +{
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;
16125 +
16126 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCConnectService, target:0x%X SvcID:0x%X \n",
16127 + (A_UINT32)target, pConnectReq->ServiceID));
16128 +
16129 + do {
16130 +
16131 + AR_DEBUG_ASSERT(pConnectReq->ServiceID != 0);
16132 +
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;
16137 + } else {
16138 + /* allocate a packet to send to the target */
16139 + pSendPacket = HTC_ALLOC_CONTROL_TX(target);
16140 +
16141 + if (NULL == pSendPacket) {
16142 + AR_DEBUG_ASSERT(FALSE);
16143 + status = A_NO_MEMORY;
16144 + break;
16145 + }
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;
16161 + }
16162 +
16163 + SET_HTC_PACKET_INFO_TX(pSendPacket,
16164 + NULL,
16165 + (A_UINT8 *)pConnectMsg,
16166 + sizeof(HTC_CONNECT_SERVICE_MSG) + pConnectMsg->ServiceMetaLength,
16167 + ENDPOINT_0,
16168 + HTC_SERVICE_TX_PACKET_TAG);
16169 +
16170 + /* we want synchronous operation */
16171 + pSendPacket->Completion = NULL;
16172 +
16173 + status = HTCIssueSend(target,pSendPacket,0);
16174 +
16175 + if (A_FAILED(status)) {
16176 + break;
16177 + }
16178 +
16179 + /* wait for response */
16180 + status = HTCWaitforControlMessage(target, &pRecvPacket);
16181 +
16182 + if (A_FAILED(status)) {
16183 + break;
16184 + }
16185 + /* we controlled the buffer creation so it has to be properly aligned */
16186 + pResponseMsg = (HTC_CONNECT_SERVICE_RESPONSE_MSG *)pRecvPacket->pBuffer;
16187 +
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;
16193 + break;
16194 + }
16195 +
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;
16203 + break;
16204 + }
16205 +
16206 + assignedEndpoint = pResponseMsg->EndpointID;
16207 + maxMsgSize = pResponseMsg->MaxMsgSize;
16208 +
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),
16217 + copyLength);
16218 + pConnectResp->ActualLength = copyLength;
16219 + }
16220 +
16221 + }
16222 +
16223 + /* the rest of these are parameter checks so set the error status */
16224 + status = A_EPROTO;
16225 +
16226 + if (assignedEndpoint >= ENDPOINT_MAX) {
16227 + AR_DEBUG_ASSERT(FALSE);
16228 + break;
16229 + }
16230 +
16231 + if (0 == maxMsgSize) {
16232 + AR_DEBUG_ASSERT(FALSE);
16233 + break;
16234 + }
16235 +
16236 + pEndpoint = &target->EndPoint[assignedEndpoint];
16237 +
16238 + if (pEndpoint->ServiceID != 0) {
16239 + /* endpoint already in use! */
16240 + AR_DEBUG_ASSERT(FALSE);
16241 + break;
16242 + }
16243 +
16244 + /* return assigned endpoint to caller */
16245 + pConnectResp->Endpoint = assignedEndpoint;
16246 + pConnectResp->MaxMsgLength = maxMsgSize;
16247 +
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;
16263 +
16264 + if (0 == pEndpoint->CreditDist.TxCreditsPerMaxMsg) {
16265 + pEndpoint->CreditDist.TxCreditsPerMaxMsg = 1;
16266 + }
16267 +
16268 + status = A_OK;
16269 +
16270 + } while (FALSE);
16271 +
16272 + if (pSendPacket != NULL) {
16273 + HTC_FREE_CONTROL_TX(target,pSendPacket);
16274 + }
16275 +
16276 + if (pRecvPacket != NULL) {
16277 + HTC_FREE_CONTROL_RX(target,pRecvPacket);
16278 + }
16279 +
16280 + AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCConnectService \n"));
16281 +
16282 + return status;
16283 +}
16284 +
16285 +static void AddToEndpointDistList(HTC_TARGET *target, HTC_ENDPOINT_CREDIT_DIST *pEpDist)
16286 +{
16287 + HTC_ENDPOINT_CREDIT_DIST *pCurEntry,*pLastEntry;
16288 +
16289 + if (NULL == target->EpCreditDistributionListHead) {
16290 + target->EpCreditDistributionListHead = pEpDist;
16291 + pEpDist->pNext = NULL;
16292 + pEpDist->pPrev = NULL;
16293 + return;
16294 + }
16295 +
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;
16299 +
16300 + while (pCurEntry) {
16301 + pLastEntry = pCurEntry;
16302 + pCurEntry = pCurEntry->pNext;
16303 + }
16304 +
16305 + pLastEntry->pNext = pEpDist;
16306 + pEpDist->pPrev = pLastEntry;
16307 + pEpDist->pNext = NULL;
16308 +}
16309 +
16310 +
16311 +
16312 +/* default credit init callback */
16313 +static void HTCDefaultCreditInit(void *Context,
16314 + HTC_ENDPOINT_CREDIT_DIST *pEPList,
16315 + int TotalCredits)
16316 +{
16317 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
16318 + int totalEps = 0;
16319 + int creditsPerEndpoint;
16320 +
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;
16325 + totalEps++;
16326 + }
16327 +
16328 + /* even distribution */
16329 + creditsPerEndpoint = TotalCredits/totalEps;
16330 +
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) {
16335 +
16336 + if (creditsPerEndpoint < pCurEpDist->TxCreditsPerMaxMsg) {
16337 + /* too many endpoints and not enough credits */
16338 + AR_DEBUG_ASSERT(FALSE);
16339 + break;
16340 + }
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;
16351 + }
16352 +
16353 +}
16354 +
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)
16359 +{
16360 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
16361 +
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;
16370 + }
16371 + pCurEpDist = pCurEpDist->pNext;
16372 + }
16373 + }
16374 +
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 */
16377 +}
16378 +
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[],
16384 + int ListLength)
16385 +{
16386 + HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
16387 + int i;
16388 + int ep;
16389 +
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;
16396 + } else {
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;
16404 + }
16405 +
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);
16409 +
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);
16419 + break;
16420 + }
16421 + }
16422 + AR_DEBUG_ASSERT(ep < ENDPOINT_MAX);
16423 + }
16424 +
16425 +}
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
16429 --- /dev/null
16430 +++ b/drivers/sdio/function/wlan/ar6000/include/AR6001_regdump.h
16431 @@ -0,0 +1,100 @@
16432 +/*
16433 + * Copyright (c) 2006 Atheros Communications Inc.
16434 + * All rights reserved.
16435 + *
16436 + * $ATH_LICENSE_HOSTSDK0_C$
16437 + *
16438 + */
16439 +
16440 +#ifndef __AR6000_REGDUMP_H__
16441 +#define __AR6000_REGDUMP_H__
16442 +
16443 +#if !defined(__ASSEMBLER__)
16444 +/*
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.
16448 + */
16449 +
16450 +struct MIPS_exception_frame_s {
16451 + A_UINT32 pc; /* Program Counter */
16452 + A_UINT32 at; /* MIPS General Purpose registers */
16453 + A_UINT32 v0;
16454 + A_UINT32 v1;
16455 + A_UINT32 a0;
16456 + A_UINT32 a1;
16457 + A_UINT32 a2;
16458 + A_UINT32 a3;
16459 + A_UINT32 t0;
16460 + A_UINT32 t1;
16461 + A_UINT32 t2;
16462 + A_UINT32 t3;
16463 + A_UINT32 t4;
16464 + A_UINT32 t5;
16465 + A_UINT32 t6;
16466 + A_UINT32 t7;
16467 + A_UINT32 s0;
16468 + A_UINT32 s1;
16469 + A_UINT32 s2;
16470 + A_UINT32 s3;
16471 + A_UINT32 s4;
16472 + A_UINT32 s5;
16473 + A_UINT32 s6;
16474 + A_UINT32 s7;
16475 + A_UINT32 t8;
16476 + A_UINT32 t9;
16477 + A_UINT32 k0;
16478 + A_UINT32 k1;
16479 + A_UINT32 gp;
16480 + A_UINT32 sp;
16481 + A_UINT32 s8;
16482 + A_UINT32 ra;
16483 + A_UINT32 cause; /* Selected coprocessor regs */
16484 + A_UINT32 status;
16485 +};
16486 +typedef struct MIPS_exception_frame_s CPU_exception_frame_t;
16487 +
16488 +#endif
16489 +
16490 +/*
16491 + * Offsets into MIPS_exception_frame structure, for use in assembler code
16492 + * MUST MATCH C STRUCTURE ABOVE
16493 + */
16494 +#define RD_pc 0
16495 +#define RD_at 1
16496 +#define RD_v0 2
16497 +#define RD_v1 3
16498 +#define RD_a0 4
16499 +#define RD_a1 5
16500 +#define RD_a2 6
16501 +#define RD_a3 7
16502 +#define RD_t0 8
16503 +#define RD_t1 9
16504 +#define RD_t2 10
16505 +#define RD_t3 11
16506 +#define RD_t4 12
16507 +#define RD_t5 13
16508 +#define RD_t6 14
16509 +#define RD_t7 15
16510 +#define RD_s0 16
16511 +#define RD_s1 17
16512 +#define RD_s2 18
16513 +#define RD_s3 19
16514 +#define RD_s4 20
16515 +#define RD_s5 21
16516 +#define RD_s6 22
16517 +#define RD_s7 23
16518 +#define RD_t8 24
16519 +#define RD_t9 25
16520 +#define RD_k0 26
16521 +#define RD_k1 27
16522 +#define RD_gp 28
16523 +#define RD_sp 29
16524 +#define RD_s8 30
16525 +#define RD_ra 31
16526 +#define RD_cause 32
16527 +#define RD_status 33
16528 +
16529 +#define RD_SIZE (34*4) /* Space for this number of words */
16530 +
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
16535 --- /dev/null
16536 +++ b/drivers/sdio/function/wlan/ar6000/include/AR6K_version.h
16537 @@ -0,0 +1,36 @@
16538 +#define __VER_MAJOR_ 2
16539 +#define __VER_MINOR_ 0
16540 +#define __VER_PATCH_ 0
16541 +
16542 +
16543 +/*
16544 + * Copyright (c) 2004-2007 Atheros Communications Inc.
16545 + * All rights reserved.
16546 + *
16547 + * $ATH_LICENSE_HOSTSDK0_C$
16548 + *
16549 + * The makear6ksdk script (used for release builds) modifies the following line.
16550 + */
16551 +#define __BUILD_NUMBER_ 18
16552 +
16553 +
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
16559 +
16560 +
16561 +/*
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.
16568 + *
16569 + * DO NOT split the following macro into multiple lines as this may confuse the build scripts.
16570 + */
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 ) )
16572 +
16573 +
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
16577 --- /dev/null
16578 +++ b/drivers/sdio/function/wlan/ar6000/include/AR6K_version.h.NEW
16579 @@ -0,0 +1,36 @@
16580 +#define __VER_MAJOR_ 2
16581 +#define __VER_MINOR_ 0
16582 +#define __VER_PATCH_ 0
16583 +
16584 +
16585 +/*
16586 + * Copyright (c) 2004-2007 Atheros Communications Inc.
16587 + * All rights reserved.
16588 + *
16589 + * $ATH_LICENSE_HOSTSDK0_C$
16590 + *
16591 + * The makear6ksdk script (used for release builds) modifies the following line.
16592 + */
16593 +#define __BUILD_NUMBER_ 18
16594 +
16595 +
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
16601 +
16602 +
16603 +/*
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.
16610 + *
16611 + * DO NOT split the following macro into multiple lines as this may confuse the build scripts.
16612 + */
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 ) )
16614 +
16615 +
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
16619 --- /dev/null
16620 +++ b/drivers/sdio/function/wlan/ar6000/include/AR6Khwreg.h
16621 @@ -0,0 +1,147 @@
16622 +/*
16623 + * Copyright (c) 2004-2007 Atheros Communications Inc.
16624 + * All rights reserved.
16625 + *
16626 + * $ATH_LICENSE_HOSTSDK0_C$
16627 + *
16628 + * This file contains the definitions for AR6001 registers
16629 + * that may be directly manipulated by Host software.
16630 + */
16631 +
16632 +#ifndef __AR6KHWREG_H__
16633 +#define __AR6KHWREG_H__
16634 +
16635 +#ifdef __cplusplus
16636 +extern "C" {
16637 +#endif
16638 +
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
16650 +
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
16659 +
16660 +
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)
16666 +
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)
16672 +
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)
16678 +
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)
16684 +
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)
16690 +
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)
16696 +
16697 +
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)
16703 +
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)
16709 +
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)
16715 +
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)
16721 +
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)
16727 +
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)
16733 +
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)
16739 +
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)
16745 +
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)
16751 +
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)
16757 +
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)
16763 +
16764 +#ifdef __cplusplus
16765 +}
16766 +#endif
16767 +
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
16772 --- /dev/null
16773 +++ b/drivers/sdio/function/wlan/ar6000/include/a_config.h
16774 @@ -0,0 +1,27 @@
16775 +#ifndef _A_CONFIG_H_
16776 +#define _A_CONFIG_H_
16777 +/*
16778 + * Copyright (c) 2004-2005 Atheros Communications Inc.
16779 + * All rights reserved.
16780 + *
16781 + *
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;
16785 + *
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.
16790 + *
16791 + *
16792 + *
16793 + */
16794 +
16795 +/*
16796 + * This file contains software configuration options that enables
16797 + * specific software "features"
16798 + */
16799 +#include "../ar6000/config_linux.h"
16800 +
16801 +#endif
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
16805 --- /dev/null
16806 +++ b/drivers/sdio/function/wlan/ar6000/include/a_debug.h
16807 @@ -0,0 +1,41 @@
16808 +#ifndef _A_DEBUG_H_
16809 +#define _A_DEBUG_H_
16810 +/*
16811 + * Copyright (c) 2004-2006 Atheros Communications Inc.
16812 + * All rights reserved.
16813 + *
16814 + * Copyright (c) 2004-2007 Atheros Communications Inc.
16815 + * All rights reserved.
16816 + *
16817 + *
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;
16821 + *
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.
16826 + *
16827 + *
16828 + *
16829 + */
16830 +
16831 +#include <a_types.h>
16832 +#include <a_osapi.h>
16833 +
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
16843 +
16844 +#define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING)
16845 +
16846 +#include "../ar6000/debug_linux.h"
16847 +
16848 +#endif
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
16852 --- /dev/null
16853 +++ b/drivers/sdio/function/wlan/ar6000/include/a_drv.h
16854 @@ -0,0 +1,28 @@
16855 +#ifndef _A_DRV_H_
16856 +#define _A_DRV_H_
16857 +/*
16858 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/a_drv.h#1 $
16859 + *
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
16862 + * type.
16863 + *
16864 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
16865 + *
16866 + *
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;
16870 + *
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.
16875 + *
16876 + *
16877 + *
16878 + */
16879 +
16880 +#include "../ar6000/athdrv_linux.h"
16881 +
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
16886 --- /dev/null
16887 +++ b/drivers/sdio/function/wlan/ar6000/include/a_drv_api.h
16888 @@ -0,0 +1,185 @@
16889 +#ifndef _A_DRV_API_H_
16890 +#define _A_DRV_API_H_
16891 +/*
16892 + * Copyright (c) 2004-2006 Atheros Communications Inc.
16893 + * All rights reserved.
16894 + *
16895 + *
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;
16899 + *
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.
16904 + *
16905 + *
16906 + *
16907 + */
16908 +
16909 +#ifdef __cplusplus
16910 +extern "C" {
16911 +#endif
16912 +
16913 +/****************************************************************************/
16914 +/****************************************************************************/
16915 +/** **/
16916 +/** WMI related hooks **/
16917 +/** **/
16918 +/****************************************************************************/
16919 +/****************************************************************************/
16920 +
16921 +#include <ar6000_api.h>
16922 +
16923 +#define A_WMI_CHANNELLIST_RX(devt, numChan, chanList) \
16924 + ar6000_channelList_rx((devt), (numChan), (chanList))
16925 +
16926 +#define A_WMI_SET_NUMDATAENDPTS(devt, num) \
16927 + ar6000_set_numdataendpts((devt), (num))
16928 +
16929 +#define A_WMI_CONTROL_TX(devt, osbuf, streamID) \
16930 + ar6000_control_tx((devt), (osbuf), (streamID))
16931 +
16932 +#define A_WMI_TARGETSTATS_EVENT(devt, pStats) \
16933 + ar6000_targetStats_event((devt), (pStats))
16934 +
16935 +#define A_WMI_SCANCOMPLETE_EVENT(devt, status) \
16936 + ar6000_scanComplete_event((devt), (status))
16937 +
16938 +#ifdef CONFIG_HOST_DSET_SUPPORT
16939 +
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))
16942 +
16943 +#define A_WMI_DSET_CLOSE(devt, access_cookie) \
16944 + ar6000_dset_close((devt), (access_cookie))
16945 +
16946 +#endif
16947 +
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))
16950 +
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))
16953 +
16954 +#define A_WMI_REGDOMAIN_EVENT(devt, regCode) \
16955 + ar6000_regDomain_event((devt), (regCode))
16956 +
16957 +#define A_WMI_NEIGHBORREPORT_EVENT(devt, numAps, info) \
16958 + ar6000_neighborReport_event((devt), (numAps), (info))
16959 +
16960 +#define A_WMI_DISCONNECT_EVENT(devt, reason, bssid, assocRespLen, assocInfo, protocolReasonStatus) \
16961 + ar6000_disconnect_event((devt), (reason), (bssid), (assocRespLen), (assocInfo), (protocolReasonStatus))
16962 +
16963 +#define A_WMI_TKIP_MICERR_EVENT(devt, keyid, ismcast) \
16964 + ar6000_tkip_micerr_event((devt), (keyid), (ismcast))
16965 +
16966 +#define A_WMI_BITRATE_RX(devt, rateKbps) \
16967 + ar6000_bitrate_rx((devt), (rateKbps))
16968 +
16969 +#define A_WMI_TXPWR_RX(devt, txPwr) \
16970 + ar6000_txPwr_rx((devt), (txPwr))
16971 +
16972 +#define A_WMI_READY_EVENT(devt, datap, phyCap) \
16973 + ar6000_ready_event((devt), (datap), (phyCap))
16974 +
16975 +#define A_WMI_DBGLOG_INIT_DONE(ar) \
16976 + ar6000_dbglog_init_done(ar);
16977 +
16978 +#define A_WMI_RSSI_THRESHOLD_EVENT(devt, newThreshold, rssi) \
16979 + ar6000_rssiThreshold_event((devt), (newThreshold), (rssi))
16980 +
16981 +#define A_WMI_REPORT_ERROR_EVENT(devt, errorVal) \
16982 + ar6000_reportError_event((devt), (errorVal))
16983 +
16984 +#define A_WMI_ROAM_TABLE_EVENT(devt, pTbl) \
16985 + ar6000_roam_tbl_event((devt), (pTbl))
16986 +
16987 +#define A_WMI_ROAM_DATA_EVENT(devt, p) \
16988 + ar6000_roam_data_event((devt), (p))
16989 +
16990 +#define A_WMI_WOW_LIST_EVENT(devt, num_filters, wow_filters) \
16991 + ar6000_wow_list_event((devt), (num_filters), (wow_filters))
16992 +
16993 +#define A_WMI_CAC_EVENT(devt, ac, cac_indication, statusCode, tspecSuggestion) \
16994 + ar6000_cac_event((devt), (ac), (cac_indication), (statusCode), (tspecSuggestion))
16995 +
16996 +#define A_WMI_IPTOS_TO_USERPRIORITY(pkt) \
16997 + ar6000_iptos_to_userPriority((pkt))
16998 +
16999 +#define A_WMI_PMKID_LIST_EVENT(devt, num_pmkid, pmkid_list) \
17000 + ar6000_pmkid_list_event((devt), (num_pmkid), (pmkid_list))
17001 +
17002 +#ifdef CONFIG_HOST_GPIO_SUPPORT
17003 +
17004 +#define A_WMI_GPIO_INTR_RX(intr_mask, input_values) \
17005 + ar6000_gpio_intr_rx((intr_mask), (input_values))
17006 +
17007 +#define A_WMI_GPIO_DATA_RX(reg_id, value) \
17008 + ar6000_gpio_data_rx((reg_id), (value))
17009 +
17010 +#define A_WMI_GPIO_ACK_RX() \
17011 + ar6000_gpio_ack_rx()
17012 +
17013 +#endif
17014 +
17015 +#ifdef SEND_EVENT_TO_APP
17016 +
17017 +#define A_WMI_SEND_EVENT_TO_APP(ar, eventId, datap, len) \
17018 + ar6000_send_event_to_app((ar), (eventId), (datap), (len))
17019 +
17020 +#else
17021 +
17022 +#define A_WMI_SEND_EVENT_TO_APP(ar, eventId, datap, len)
17023 +
17024 +#endif
17025 +
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))
17029 +#endif
17030 +
17031 +#define A_WMI_HBCHALLENGERESP_EVENT(devt, cookie, source) \
17032 + ar6000_hbChallengeResp_event((devt), (cookie), (source))
17033 +
17034 +#define A_WMI_TX_RETRY_ERR_EVENT(devt) \
17035 + ar6000_tx_retry_err_event((devt))
17036 +
17037 +#define A_WMI_SNR_THRESHOLD_EVENT_RX(devt, newThreshold, snr) \
17038 + ar6000_snrThresholdEvent_rx((devt), (newThreshold), (snr))
17039 +
17040 +#define A_WMI_LQ_THRESHOLD_EVENT_RX(devt, range, lqVal) \
17041 + ar6000_lqThresholdEvent_rx((devt), (range), (lqVal))
17042 +
17043 +#define A_WMI_RATEMASK_RX(devt, ratemask) \
17044 + ar6000_ratemask_rx((devt), (ratemask))
17045 +
17046 +#define A_WMI_KEEPALIVE_RX(devt, configured) \
17047 + ar6000_keepalive_rx((devt), (configured))
17048 +
17049 +#define A_WMI_BSSINFO_EVENT_RX(ar, datp, len) \
17050 + ar6000_bssInfo_event_rx((ar), (datap), (len))
17051 +
17052 +#define A_WMI_DBGLOG_EVENT(ar, dropped, buffer, length) \
17053 + ar6000_dbglog_event((ar), (dropped), (buffer), (length));
17054 +
17055 +#define A_WMI_STREAM_TX_ACTIVE(devt,trafficClass) \
17056 + ar6000_indicate_tx_activity((devt),(trafficClass), TRUE)
17057 +
17058 +#define A_WMI_STREAM_TX_INACTIVE(devt,trafficClass) \
17059 + ar6000_indicate_tx_activity((devt),(trafficClass), FALSE)
17060 +
17061 +/****************************************************************************/
17062 +/****************************************************************************/
17063 +/** **/
17064 +/** HTC related hooks **/
17065 +/** **/
17066 +/****************************************************************************/
17067 +/****************************************************************************/
17068 +
17069 +#ifdef __cplusplus
17070 +}
17071 +#endif
17072 +
17073 +#endif
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
17077 --- /dev/null
17078 +++ b/drivers/sdio/function/wlan/ar6000/include/a_osapi.h
17079 @@ -0,0 +1,28 @@
17080 +#ifndef _A_OSAPI_H_
17081 +#define _A_OSAPI_H_
17082 +/*
17083 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/a_osapi.h#1 $
17084 + *
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
17087 + * type.
17088 + *
17089 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
17090 + *
17091 + *
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;
17095 + *
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.
17100 + *
17101 + *
17102 + *
17103 + */
17104 +
17105 +#include "../ar6000/osapi_linux.h"
17106 +
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
17111 --- /dev/null
17112 +++ b/drivers/sdio/function/wlan/ar6000/include/a_types.h
17113 @@ -0,0 +1,28 @@
17114 +#ifndef _A_TYPES_H_
17115 +#define _A_TYPES_H_
17116 +/*
17117 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/a_types.h#1 $
17118 + *
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
17121 + * type.
17122 + *
17123 + * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
17124 + *
17125 + *
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;
17129 + *
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.
17134 + *
17135 + *
17136 + *
17137 + */
17138 +
17139 +#include "../ar6000/athtypes_linux.h"
17140 +
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
17145 --- /dev/null
17146 +++ b/drivers/sdio/function/wlan/ar6000/include/ar6000_api.h
17147 @@ -0,0 +1,29 @@
17148 +#ifndef _AR6000_API_H_
17149 +#define _AR6000_API_H_
17150 +/*
17151 + * Copyright (c) 2004-2005 Atheros Communications Inc.
17152 + * All rights reserved.
17153 + *
17154 + * This file contains the API to access the OS dependent atheros host driver
17155 + * by the WMI or WLAN generic modules.
17156 + *
17157 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/ar6000_api.h#1 $
17158 + *
17159 + *
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;
17163 + *
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.
17168 + *
17169 + *
17170 + *
17171 + */
17172 +
17173 +#include "../ar6000/ar6xapi_linux.h"
17174 +
17175 +#endif /* _AR6000_API_H */
17176 +
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
17180 --- /dev/null
17181 +++ b/drivers/sdio/function/wlan/ar6000/include/ar6000_diag.h
17182 @@ -0,0 +1,38 @@
17183 +/*
17184 + *
17185 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17186 + * All rights reserved.
17187 + *
17188 + *
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;
17192 + *
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.
17197 + *
17198 + *
17199 + *
17200 + */
17201 +
17202 +#ifndef AR6000_DIAG_H_
17203 +#define AR6000_DIAG_H_
17204 +
17205 +
17206 +A_STATUS
17207 +ar6000_ReadRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
17208 +
17209 +A_STATUS
17210 +ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
17211 +
17212 +A_STATUS
17213 +ar6000_ReadDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address,
17214 + A_UCHAR *data, A_UINT32 length);
17215 +
17216 +A_STATUS
17217 +ar6000_WriteDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address,
17218 + A_UCHAR *data, A_UINT32 length);
17219 +
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
17224 --- /dev/null
17225 +++ b/drivers/sdio/function/wlan/ar6000/include/athdefs.h
17226 @@ -0,0 +1,85 @@
17227 +#ifndef __ATHDEFS_H__
17228 +#define __ATHDEFS_H__
17229 +
17230 +/*
17231 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17232 + * All rights reserved.
17233 + *
17234 + * $ATH_LICENSE_HOSTSDK0_C$
17235 + *
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.
17239 + */
17240 +
17241 +/*
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.
17245 + */
17246 +
17247 +typedef enum {
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 */
17280 +} A_STATUS;
17281 +
17282 +#define A_SUCCESS(x) (x == A_OK)
17283 +#define A_FAILED(x) (!A_SUCCESS(x))
17284 +
17285 +#ifndef TRUE
17286 +#define TRUE 1
17287 +#endif
17288 +
17289 +#ifndef FALSE
17290 +#define FALSE 0
17291 +#endif
17292 +
17293 +/*
17294 + * The following definition is WLAN specific definition
17295 + */
17296 +typedef enum {
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,
17302 + MODE_MAX = 4
17303 +} WLAN_PHY_MODE;
17304 +
17305 +typedef enum {
17306 + WLAN_11A_CAPABILITY = 1,
17307 + WLAN_11G_CAPABILITY = 2,
17308 + WLAN_11AG_CAPABILITY = 3,
17309 +}WLAN_CAPABILITY;
17310 +
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
17315 --- /dev/null
17316 +++ b/drivers/sdio/function/wlan/ar6000/include/athdrv.h
17317 @@ -0,0 +1,32 @@
17318 +/*
17319 + * Copyright (c) 2004-2006 Atheros Communications Inc.
17320 + * All rights reserved.
17321 + *
17322 + *
17323 + *
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;
17327 + *
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.
17332 + *
17333 + *
17334 + *
17335 + */
17336 +
17337 +#ifndef _ATHDRV_H_
17338 +#define _ATHDRV_H_
17339 +
17340 +#ifdef __cplusplus
17341 +extern "C" {
17342 +#endif
17343 +
17344 +
17345 +#ifdef __cplusplus
17346 +}
17347 +#endif
17348 +
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
17353 --- /dev/null
17354 +++ b/drivers/sdio/function/wlan/ar6000/include/athendpack.h
17355 @@ -0,0 +1,41 @@
17356 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17357 + * @file: athendpack.h
17358 + *
17359 + * @abstract: end compiler-specific structure packing
17360 + *
17361 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17362 + * All rights reserved.
17363 + *
17364 + *
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;
17368 + *
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.
17373 + *
17374 + *
17375 + *
17376 + */
17377 +#ifdef VXWORKS
17378 +#endif /* VXWORKS */
17379 +
17380 +#ifdef LINUX
17381 +#endif /* LINUX */
17382 +
17383 +#ifdef QNX
17384 +#endif /* QNX */
17385 +
17386 +#ifdef INTEGRITY
17387 +#include "integrity/athendpack_integrity.h"
17388 +#endif /* INTEGRITY */
17389 +
17390 +#ifdef NUCLEUS
17391 +#endif /* NUCLEUS */
17392 +
17393 +#ifdef UNDER_CE
17394 +#include "../os/wince/include/athendpack_wince.h"
17395 +#endif /* WINCE */
17396 +
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
17400 --- /dev/null
17401 +++ b/drivers/sdio/function/wlan/ar6000/include/athstartpack.h
17402 @@ -0,0 +1,42 @@
17403 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17404 + * @file: athstartpack.h
17405 + *
17406 + * @abstract: start compiler-specific structure packing
17407 + *
17408 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17409 + * All rights reserved.
17410 + *
17411 + *
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;
17415 + *
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.
17420 + *
17421 + *
17422 + *
17423 + */
17424 +
17425 +#ifdef VXWORKS
17426 +#endif /* VXWORKS */
17427 +
17428 +#ifdef LINUX
17429 +#endif /* LINUX */
17430 +
17431 +#ifdef QNX
17432 +#endif /* QNX */
17433 +
17434 +#ifdef INTEGRITY
17435 +#include "integrity/athstartpack_integrity.h"
17436 +#endif /* INTEGRITY */
17437 +
17438 +#ifdef NUCLEUS
17439 +#endif /* NUCLEUS */
17440 +
17441 +#ifdef UNDER_CE
17442 +#include "../os/wince/include/athstartpack_wince.h"
17443 +#endif /* WINCE */
17444 +
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
17448 --- /dev/null
17449 +++ b/drivers/sdio/function/wlan/ar6000/include/bmi.h
17450 @@ -0,0 +1,100 @@
17451 +#ifndef _BMI_H_
17452 +#define _BMI_H_
17453 +/*
17454 + * Copyright (c) 2004-2005 Atheros Communications Inc.
17455 + * All rights reserved.
17456 + *
17457 + *
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;
17461 + *
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.
17466 + *
17467 + *
17468 + *
17469 + * BMI declarations and prototypes
17470 + */
17471 +
17472 +#ifdef __cplusplus
17473 +extern "C" {
17474 +#endif /* __cplusplus */
17475 +
17476 +/* Header files */
17477 +#include "a_config.h"
17478 +#include "athdefs.h"
17479 +#include "a_types.h"
17480 +#include "hif.h"
17481 +#include "a_osapi.h"
17482 +#include "bmi_msg.h"
17483 +
17484 +void
17485 +BMIInit(void);
17486 +
17487 +A_STATUS
17488 +BMIDone(HIF_DEVICE *device);
17489 +
17490 +A_STATUS
17491 +BMIGetTargetInfo(HIF_DEVICE *device, struct bmi_target_info *targ_info);
17492 +
17493 +A_STATUS
17494 +BMIReadMemory(HIF_DEVICE *device,
17495 + A_UINT32 address,
17496 + A_UCHAR *buffer,
17497 + A_UINT32 length);
17498 +
17499 +A_STATUS
17500 +BMIWriteMemory(HIF_DEVICE *device,
17501 + A_UINT32 address,
17502 + A_UCHAR *buffer,
17503 + A_UINT32 length);
17504 +
17505 +A_STATUS
17506 +BMIExecute(HIF_DEVICE *device,
17507 + A_UINT32 address,
17508 + A_UINT32 *param);
17509 +
17510 +A_STATUS
17511 +BMISetAppStart(HIF_DEVICE *device,
17512 + A_UINT32 address);
17513 +
17514 +A_STATUS
17515 +BMIReadSOCRegister(HIF_DEVICE *device,
17516 + A_UINT32 address,
17517 + A_UINT32 *param);
17518 +
17519 +A_STATUS
17520 +BMIWriteSOCRegister(HIF_DEVICE *device,
17521 + A_UINT32 address,
17522 + A_UINT32 param);
17523 +
17524 +A_STATUS
17525 +BMIrompatchInstall(HIF_DEVICE *device,
17526 + A_UINT32 ROM_addr,
17527 + A_UINT32 RAM_addr,
17528 + A_UINT32 nbytes,
17529 + A_UINT32 do_activate,
17530 + A_UINT32 *patch_id);
17531 +
17532 +A_STATUS
17533 +BMIrompatchUninstall(HIF_DEVICE *device,
17534 + A_UINT32 rompatch_id);
17535 +
17536 +A_STATUS
17537 +BMIrompatchActivate(HIF_DEVICE *device,
17538 + A_UINT32 rompatch_count,
17539 + A_UINT32 *rompatch_list);
17540 +
17541 +A_STATUS
17542 +BMIrompatchDeactivate(HIF_DEVICE *device,
17543 + A_UINT32 rompatch_count,
17544 + A_UINT32 *rompatch_list);
17545 +
17546 +#ifdef __cplusplus
17547 +}
17548 +#endif
17549 +
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
17554 --- /dev/null
17555 +++ b/drivers/sdio/function/wlan/ar6000/include/bmi_msg.h
17556 @@ -0,0 +1,199 @@
17557 +#ifndef __BMI_MSG_H__
17558 +#define __BMI_MSG_H__
17559 +/*
17560 + *
17561 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17562 + * All rights reserved.
17563 + *
17564 + *
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;
17568 + *
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.
17573 + *
17574 + *
17575 + *
17576 + */
17577 +
17578 +/*
17579 + * Bootloader Messaging Interface (BMI)
17580 + *
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.
17584 + *
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.
17590 + *
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.
17595 + *
17596 + * Flow control:
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).
17601 + *
17602 + * BMI handles all required Target-side cache flushing.
17603 + */
17604 +
17605 +
17606 +/* Maximum data size used for BMI transfers */
17607 +#define BMI_DATASZ_MAX 32
17608 +
17609 +/* BMI Commands */
17610 +
17611 +#define BMI_NO_COMMAND 0
17612 +
17613 +#define BMI_DONE 1
17614 + /*
17615 + * Semantics: Host is done using BMI
17616 + * Request format:
17617 + * A_UINT32 command (BMI_DONE)
17618 + * Response format: none
17619 + */
17620 +
17621 +#define BMI_READ_MEMORY 2
17622 + /*
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]
17630 + */
17631 +
17632 +#define BMI_WRITE_MEMORY 3
17633 + /*
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
17641 + */
17642 +
17643 +#define BMI_EXECUTE 4
17644 + /*
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
17652 + */
17653 +
17654 +#define BMI_SET_APP_START 5
17655 + /*
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
17661 + */
17662 +
17663 +#define BMI_READ_SOC_REGISTER 6
17664 + /*
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:
17670 + * A_UINT32 value
17671 + */
17672 +
17673 +#define BMI_WRITE_SOC_REGISTER 7
17674 + /*
17675 + * Semantics: Write a 32-bit Target SOC register.
17676 + * Request format:
17677 + * A_UINT32 command (BMI_WRITE_REGISTER)
17678 + * A_UINT32 address
17679 + * A_UINT32 value
17680 + *
17681 + * Response format: none
17682 + */
17683 +
17684 +#define BMI_GET_TARGET_ID 8
17685 +#define BMI_GET_TARGET_INFO 8
17686 + /*
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;
17695 + */
17696 +
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 */
17701 +};
17702 +#define TARGET_VERSION_SENTINAL 0xffffffff
17703 +#define TARGET_TYPE_AR6001 1
17704 +#define TARGET_TYPE_AR6002 2
17705 +
17706 +
17707 +#define BMI_ROMPATCH_INSTALL 9
17708 + /*
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
17719 + */
17720 +
17721 +#define BMI_ROMPATCH_UNINSTALL 10
17722 + /*
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
17728 + *
17729 + * Response format: none
17730 + */
17731 +
17732 +#define BMI_ROMPATCH_ACTIVATE 11
17733 + /*
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]
17739 + *
17740 + * Response format: none
17741 + */
17742 +
17743 +#define BMI_ROMPATCH_DEACTIVATE 12
17744 + /*
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]
17750 + *
17751 + * Response format: none
17752 + */
17753 +
17754 +
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
17759 --- /dev/null
17760 +++ b/drivers/sdio/function/wlan/ar6000/include/common_drv.h
17761 @@ -0,0 +1,61 @@
17762 +/*
17763 + *
17764 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17765 + * All rights reserved.
17766 + *
17767 + *
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;
17771 + *
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.
17776 + *
17777 + *
17778 + *
17779 + */
17780 +
17781 +
17782 +#ifndef COMMON_DRV_H_
17783 +#define COMMON_DRV_H_
17784 +
17785 +#include "hif.h"
17786 +#include "htc_packet.h"
17787 +
17788 +
17789 +
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;
17799 +
17800 +
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)
17804 +
17805 +#ifdef __cplusplus
17806 +extern "C" {
17807 +#endif
17808 +
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);
17817 +
17818 +#ifdef __cplusplus
17819 +}
17820 +#endif
17821 +
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
17826 --- /dev/null
17827 +++ b/drivers/sdio/function/wlan/ar6000/include/dbglog.h
17828 @@ -0,0 +1,107 @@
17829 +/*
17830 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17831 + * All rights reserved.
17832 + *
17833 + * $ATH_LICENSE_HOSTSDK0_C$
17834 + *
17835 + * This file contains the definitions and data structures associated with
17836 + * the log based debug mechanism.
17837 + *
17838 + */
17839 +
17840 +#ifndef _DBGLOG_H_
17841 +#define _DBGLOG_H_
17842 +
17843 +#ifdef __cplusplus
17844 +extern "C" {
17845 +#endif
17846 +
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 */
17853 +
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 */
17857 +
17858 +/*
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.
17863 + */
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
17875 +
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 */
17879 +
17880 +#define DBGLOG_MODULE_LOG_ENABLE_OFFSET 0
17881 +#define DBGLOG_MODULE_LOG_ENABLE_MASK 0x0000FFFF
17882 +
17883 +#define DBGLOG_REPORTING_ENABLED_OFFSET 16
17884 +#define DBGLOG_REPORTING_ENABLED_MASK 0x00010000
17885 +
17886 +#define DBGLOG_TIMESTAMP_RESOLUTION_OFFSET 17
17887 +#define DBGLOG_TIMESTAMP_RESOLUTION_MASK 0x000E0000
17888 +
17889 +#define DBGLOG_REPORT_SIZE_OFFSET 20
17890 +#define DBGLOG_REPORT_SIZE_MASK 0x3FF00000
17891 +
17892 +#define DBGLOG_LOG_BUFFER_SIZE 1500
17893 +#define DBGLOG_DBGID_DEFINITION_LEN_MAX 64
17894 +
17895 +struct dbglog_buf_s {
17896 + struct dbglog_buf_s *next;
17897 + A_INT8 *buffer;
17898 + A_UINT32 bufsize;
17899 + A_UINT32 length;
17900 + A_UINT32 count;
17901 + A_UINT32 free;
17902 +};
17903 +
17904 +struct dbglog_hdr_s {
17905 + struct dbglog_buf_s *dbuf;
17906 + A_UINT32 dropped;
17907 +};
17908 +
17909 +struct dbglog_config_s {
17910 + A_UINT32 cfgvalid; /* Mask with valid config bits */
17911 + union {
17912 + /* TODO: Take care of endianness */
17913 + struct {
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;
17919 + } dbglog_config;
17920 +
17921 + A_UINT32 value;
17922 + } u;
17923 +};
17924 +
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
17930 +
17931 +#ifdef __cplusplus
17932 +}
17933 +#endif
17934 +
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
17939 --- /dev/null
17940 +++ b/drivers/sdio/function/wlan/ar6000/include/dbglog_api.h
17941 @@ -0,0 +1,46 @@
17942 +#ifndef _DBGLOG_API_H_
17943 +#define _DBGLOG_API_H_
17944 +/*
17945 + * Copyright (c) 2004-2006 Atheros Communications Inc.
17946 + * All rights reserved.
17947 + *
17948 + *
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;
17952 + *
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.
17957 + *
17958 + *
17959 + *
17960 + * This file contains host side debug primitives.
17961 + */
17962 +
17963 +#ifdef __cplusplus
17964 +extern "C" {
17965 +#endif
17966 +
17967 +#include "dbglog.h"
17968 +
17969 +#define DBGLOG_HOST_LOG_BUFFER_SIZE DBGLOG_LOG_BUFFER_SIZE
17970 +
17971 +#define DBGLOG_GET_DBGID(arg) \
17972 + ((arg & DBGLOG_DBGID_MASK) >> DBGLOG_DBGID_OFFSET)
17973 +
17974 +#define DBGLOG_GET_MODULEID(arg) \
17975 + ((arg & DBGLOG_MODULEID_MASK) >> DBGLOG_MODULEID_OFFSET)
17976 +
17977 +#define DBGLOG_GET_NUMARGS(arg) \
17978 + ((arg & DBGLOG_NUM_ARGS_MASK) >> DBGLOG_NUM_ARGS_OFFSET)
17979 +
17980 +#define DBGLOG_GET_TIMESTAMP(arg) \
17981 + ((arg & DBGLOG_TIMESTAMP_MASK) >> DBGLOG_TIMESTAMP_OFFSET)
17982 +
17983 +#ifdef __cplusplus
17984 +}
17985 +#endif
17986 +
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
17991 --- /dev/null
17992 +++ b/drivers/sdio/function/wlan/ar6000/include/dbglog_id.h
17993 @@ -0,0 +1,307 @@
17994 +/*
17995 + *
17996 + * Copyright (c) 2004-2007 Atheros Communications Inc.
17997 + * All rights reserved.
17998 + *
17999 + * $ATH_LICENSE_HOSTSDK0_C$
18000 + *
18001 + * This file contains the definitions of the debug identifiers for different
18002 + * modules.
18003 + *
18004 + */
18005 +
18006 +#ifndef _DBGLOG_ID_H_
18007 +#define _DBGLOG_ID_H_
18008 +
18009 +#ifdef __cplusplus
18010 +extern "C" {
18011 +#endif
18012 +
18013 +/*
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.
18019 + */
18020 +
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
18026 +
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
18074 +
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
18161 +
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
18175 +
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
18187 +
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
18207 +
18208 +/* PM (Power Module) debug identifier definitions */
18209 +#define PM_DBGID_DEFINITION_START
18210 +#define PM_INIT 1
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
18226 +
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
18263 +
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
18295 +
18296 +#ifdef __cplusplus
18297 +}
18298 +#endif
18299 +
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
18304 --- /dev/null
18305 +++ b/drivers/sdio/function/wlan/ar6000/include/dl_list.h
18306 @@ -0,0 +1,114 @@
18307 +/*
18308 + *
18309 + * Double-link list definitions (adapted from Atheros SDIO stack)
18310 + *
18311 + * Copyright (c) 2007 Atheros Communications Inc.
18312 + * All rights reserved.
18313 + *
18314 + *
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;
18318 + *
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.
18323 + *
18324 + *
18325 + *
18326 + */
18327 +#ifndef __DL_LIST_H___
18328 +#define __DL_LIST_H___
18329 +
18330 +#define A_CONTAINING_STRUCT(address, struct_type, field_name)\
18331 + ((struct_type *)((A_UINT32)(address) - (A_UINT32)(&((struct_type *)0)->field_name)))
18332 +
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;
18339 +/*
18340 + * DL_LIST_INIT , initialize doubly linked list
18341 +*/
18342 +#define DL_LIST_INIT(pList)\
18343 + {(pList)->pPrev = pList; (pList)->pNext = pList;}
18344 +
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
18348 +/*
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
18351 + * iteration loop
18352 +*/
18353 +#define ITERATE_OVER_LIST(pStart, pTemp) \
18354 + for((pTemp) =(pStart)->pNext; pTemp != (pStart); (pTemp) = (pTemp)->pNext)
18355 +
18356 +
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
18359 + */
18360 +#define ITERATE_OVER_LIST_ALLOW_REMOVE(pStart,pItem,st,offset) \
18361 +{ \
18362 + PDL_LIST pTemp; \
18363 + pTemp = (pStart)->pNext; \
18364 + while (pTemp != (pStart)) { \
18365 + (pItem) = A_CONTAINING_STRUCT(pTemp,st,offset); \
18366 + pTemp = pTemp->pNext; \
18367 +
18368 +#define ITERATE_END }}
18369 +
18370 +/*
18371 + * DL_ListInsertTail - insert pAdd to the end of the list
18372 +*/
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;
18379 + return pAdd;
18380 +}
18381 +
18382 +/*
18383 + * DL_ListInsertHead - insert pAdd into the head of the list
18384 +*/
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;
18391 + return pAdd;
18392 +}
18393 +
18394 +#define DL_ListAdd(pList,pItem) DL_ListInsertHead((pList),(pItem))
18395 +/*
18396 + * DL_ListRemove - remove pDel from list
18397 +*/
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;
18404 + return pDel;
18405 +}
18406 +
18407 +/*
18408 + * DL_ListRemoveItemFromHead - get a list item from the head
18409 +*/
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);
18416 + }
18417 + return pItem;
18418 +}
18419 +
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
18424 --- /dev/null
18425 +++ b/drivers/sdio/function/wlan/ar6000/include/dset_api.h
18426 @@ -0,0 +1,63 @@
18427 +/*
18428 + * Copyright (c) 2004-2006 Atheros Communications Inc.
18429 + * All rights reserved.
18430 + *
18431 + *
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;
18435 + *
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.
18440 + *
18441 + *
18442 + *
18443 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/dset_api.h#1 $
18444 + *
18445 + * Host-side DataSet API.
18446 + *
18447 + */
18448 +
18449 +#ifndef _DSET_API_H_
18450 +#define _DSET_API_H_
18451 +
18452 +#ifdef __cplusplus
18453 +extern "C" {
18454 +#endif /* __cplusplus */
18455 +
18456 +/*
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.
18460 + */
18461 +#ifndef CONFIG_HOST_DSET_SUPPORT
18462 +#define CONFIG_HOST_DSET_SUPPORT 1
18463 +#endif
18464 +
18465 +/* Called to send a DataSet Open Reply back to the Target. */
18466 +A_STATUS wmi_dset_open_reply(struct wmi_t *wmip,
18467 + A_UINT32 status,
18468 + A_UINT32 access_cookie,
18469 + A_UINT32 size,
18470 + A_UINT32 version,
18471 + A_UINT32 targ_handle,
18472 + A_UINT32 targ_reply_fn,
18473 + A_UINT32 targ_reply_arg);
18474 +
18475 +/* Called to send a DataSet Data Reply back to the Target. */
18476 +A_STATUS wmi_dset_data_reply(struct wmi_t *wmip,
18477 + A_UINT32 status,
18478 + A_UINT8 *host_buf,
18479 + A_UINT32 length,
18480 + A_UINT32 targ_buf,
18481 + A_UINT32 targ_reply_fn,
18482 + A_UINT32 targ_reply_arg);
18483 +
18484 +#ifdef __cplusplus
18485 +}
18486 +#endif /* __cplusplus */
18487 +
18488 +
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
18493 --- /dev/null
18494 +++ b/drivers/sdio/function/wlan/ar6000/include/dset_internal.h
18495 @@ -0,0 +1,39 @@
18496 +/*
18497 + * Copyright (c) 2007 Atheros Communications Inc.
18498 + * All rights reserved.
18499 + *
18500 + * $ATH_LICENSE_HOSTSDK0_C$
18501 + *
18502 + */
18503 +
18504 +#ifndef __DSET_INTERNAL_H__
18505 +#define __DSET_INTERNAL_H__
18506 +
18507 +/*
18508 + * Internal dset definitions, common for DataSet layer.
18509 + */
18510 +
18511 +#define DSET_TYPE_STANDARD 0
18512 +#define DSET_TYPE_BPATCHED 1
18513 +#define DSET_TYPE_COMPRESSED 2
18514 +
18515 +/* Dataset descriptor */
18516 +
18517 +typedef struct dset_descriptor_s {
18518 + struct dset_descriptor_s *next; /* List link. NULL only at the last
18519 + descriptor */
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
18525 + DataSet */
18526 + A_UINT32 data_type; /* DSET_TYPE_*, above */
18527 +
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;
18533 +
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
18538 --- /dev/null
18539 +++ b/drivers/sdio/function/wlan/ar6000/include/dsetid.h
18540 @@ -0,0 +1,110 @@
18541 +/*
18542 + * Copyright (c) 2004-2007 Atheros Communications Inc.
18543 + * All rights reserved.
18544 + *
18545 + * $ATH_LICENSE_HOSTSDK0_C$
18546 + *
18547 + */
18548 +
18549 +#ifndef __DSETID_H__
18550 +#define __DSETID_H__
18551 +
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 */
18558 +
18559 +#define DSETID_ANALOG_CONTROL_DATA_START 0x00000005
18560 +#define DSETID_ANALOG_CONTROL_DATA_END 0x00000025
18561 +/*
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.
18567 + */
18568 +#define ANALOG_CONTROL_DATA_DSETID(refclk) \
18569 + (DSETID_ANALOG_CONTROL_DATA_START + 3*refclk)
18570 +
18571 +/*
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.
18576 + */
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
18581 +
18582 +#define DSETID_WOW_CONFIG 0x00000090 /* WoW Configuration */
18583 +
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
18588 +
18589 +#define DSETID_VENDOR_START 0x00010000 /* Vendor-defined DataSets */
18590 +
18591 +#define DSETID_INDEX_END 0xfffffffe /* Reserved to indicate the
18592 + end of a memory-based
18593 + DataSet Index */
18594 +#define DSETID_INDEX_FREE 0xffffffff /* An unused index entry */
18595 +
18596 +/*
18597 + * PATCH DataSet format:
18598 + * A list of patches, terminated by a patch with
18599 + * address=PATCH_END.
18600 + *
18601 + * This allows for patches to be stored in flash.
18602 + */
18603 +struct patch_s {
18604 + A_UINT32 *address;
18605 + A_UINT32 data;
18606 +};
18607 +
18608 +/*
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.
18614 + */
18615 +#define PATCH_SKIP ((A_UINT32 *)0x00000000)
18616 +
18617 +/*
18618 + * Execute code at the address specified by "data".
18619 + * The address of the patch structure is passed as
18620 + * the one parameter.
18621 + */
18622 +#define PATCH_CODE_ABS ((A_UINT32 *)0x00000001)
18623 +
18624 +/*
18625 + * Same as PATCH_CODE_ABS, but treat "data" as an
18626 + * offset from the start of the patch word.
18627 + */
18628 +#define PATCH_CODE_REL ((A_UINT32 *)0x00000002)
18629 +
18630 +/* Mark the end of this patch DataSet. */
18631 +#define PATCH_END ((A_UINT32 *)0xffffffff)
18632 +
18633 +/*
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.
18639 + *
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".
18644 + *
18645 + * NB: There are some implementation-induced restrictions
18646 + * on which DataSets can be BPatched.
18647 + */
18648 +#define DSETID_BPATCH_FLAG 0x80000000
18649 +
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
18654 --- /dev/null
18655 +++ b/drivers/sdio/function/wlan/ar6000/include/gpio.h
18656 @@ -0,0 +1,34 @@
18657 +/*
18658 + * Copyright (c) 2005 Atheros Communications Inc.
18659 + * All rights reserved.
18660 + *
18661 + * $ATH_LICENSE_HOSTSDK0_C$
18662 + *
18663 + */
18664 +
18665 +#if defined(AR6001)
18666 +#define GPIO_PIN_COUNT 18
18667 +#else
18668 +#define GPIO_PIN_COUNT 18
18669 +#endif
18670 +
18671 +/*
18672 + * Possible values for WMIX_GPIO_SET_REGISTER_CMDID.
18673 + * NB: These match hardware order, so that addresses can
18674 + * easily be computed.
18675 + */
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))
18688 +
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
18694 --- /dev/null
18695 +++ b/drivers/sdio/function/wlan/ar6000/include/gpio_api.h
18696 @@ -0,0 +1,57 @@
18697 +#ifndef _GPIO_API_H_
18698 +#define _GPIO_API_H_
18699 +/*
18700 + * Copyright 2005 Atheros Communications, Inc., All Rights Reserved.
18701 + *
18702 + *
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;
18706 + *
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.
18711 + *
18712 + *
18713 + *
18714 + */
18715 +
18716 +/*
18717 + * Host-side General Purpose I/O API.
18718 + *
18719 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/gpio_api.h#1 $
18720 + */
18721 +
18722 +/*
18723 + * Send a command to the Target in order to change output on GPIO pins.
18724 + */
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);
18730 +
18731 +/*
18732 + * Send a command to the Target requesting input state of GPIO pins.
18733 + */
18734 +A_STATUS wmi_gpio_input_get(struct wmi_t *wmip);
18735 +
18736 +/*
18737 + * Send a command to the Target to change the value of a GPIO register.
18738 + */
18739 +A_STATUS wmi_gpio_register_set(struct wmi_t *wmip,
18740 + A_UINT32 gpioreg_id,
18741 + A_UINT32 value);
18742 +
18743 +/*
18744 + * Send a command to the Target to fetch the value of a GPIO register.
18745 + */
18746 +A_STATUS wmi_gpio_register_get(struct wmi_t *wmip, A_UINT32 gpioreg_id);
18747 +
18748 +/*
18749 + * Send a command to the Target, acknowledging some GPIO interrupts.
18750 + */
18751 +A_STATUS wmi_gpio_intr_ack(struct wmi_t *wmip, A_UINT32 ack_mask);
18752 +
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
18757 --- /dev/null
18758 +++ b/drivers/sdio/function/wlan/ar6000/include/hif.h
18759 @@ -0,0 +1,291 @@
18760 +/*
18761 + * Copyright (c) 2004-2007 Atheros Communications Inc.
18762 + * All rights reserved.
18763 + *
18764 + *
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;
18768 + *
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.
18773 + *
18774 + *
18775 + *
18776 + * HIF specific declarations and prototypes
18777 + */
18778 +
18779 +#ifndef _HIF_H_
18780 +#define _HIF_H_
18781 +
18782 +#ifdef __cplusplus
18783 +extern "C" {
18784 +#endif /* __cplusplus */
18785 +
18786 +/* Header files */
18787 +#include "a_config.h"
18788 +#include "athdefs.h"
18789 +#include "a_types.h"
18790 +#include "a_osapi.h"
18791 +
18792 +typedef struct htc_callbacks HTC_CALLBACKS;
18793 +typedef struct hif_device HIF_DEVICE;
18794 +
18795 +/*
18796 + * direction - Direction of transfer (HIF_READ/HIF_WRITE).
18797 + */
18798 +#define HIF_READ 0x00000001
18799 +#define HIF_WRITE 0x00000002
18800 +#define HIF_DIR_MASK (HIF_READ | HIF_WRITE)
18801 +
18802 +/*
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.
18806 + */
18807 +#define HIF_BASIC_IO 0x00000004
18808 +#define HIF_EXTENDED_IO 0x00000008
18809 +#define HIF_TYPE_MASK (HIF_BASIC_IO | HIF_EXTENDED_IO)
18810 +
18811 +/*
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.
18821 + */
18822 +#define HIF_SYNCHRONOUS 0x00000010
18823 +#define HIF_ASYNCHRONOUS 0x00000020
18824 +#define HIF_EMODE_MASK (HIF_SYNCHRONOUS | HIF_ASYNCHRONOUS)
18825 +
18826 +/*
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.
18835 + */
18836 +#define HIF_BYTE_BASIS 0x00000040
18837 +#define HIF_BLOCK_BASIS 0x00000080
18838 +#define HIF_DMODE_MASK (HIF_BYTE_BASIS | HIF_BLOCK_BASIS)
18839 +
18840 +/*
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).
18844 + */
18845 +#define HIF_FIXED_ADDRESS 0x00000100
18846 +#define HIF_INCREMENTAL_ADDRESS 0x00000200
18847 +#define HIF_AMODE_MASK (HIF_FIXED_ADDRESS | HIF_INCREMENTAL_ADDRESS)
18848 +
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)
18875 +
18876 +
18877 +typedef enum {
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;
18885 +
18886 +/*
18887 + * HIF CONFIGURE definitions:
18888 + *
18889 + * HIF_DEVICE_GET_MBOX_BLOCK_SIZE
18890 + * input : none
18891 + * output : array of 4 A_UINT32s
18892 + * notes: block size is returned for each mailbox (4)
18893 + *
18894 + * HIF_DEVICE_GET_MBOX_ADDR
18895 + * input : none
18896 + * output : array of 4 A_UINT32
18897 + * notes: address is returned for each mailbox (4) in the array
18898 + *
18899 + * HIF_DEVICE_GET_PENDING_EVENTS_FUNC
18900 + * input : none
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.
18906 + *
18907 + * HIF_DEVICE_GET_IRQ_PROC_MODE
18908 + * input : none
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).
18913 + *
18914 + * HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC
18915 + * input :
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).
18920 + *
18921 + *
18922 + */
18923 +
18924 +typedef enum {
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
18929 + later time */
18930 +} HIF_DEVICE_IRQ_PROCESSING_MODE;
18931 +
18932 +#define HIF_MAX_DEVICES 1
18933 +
18934 +struct htc_callbacks {
18935 + A_UCHAR *name;
18936 + A_UINT32 id;
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);
18944 +};
18945 +
18946 +
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 */
18950 +
18951 +typedef struct _HIF_PENDING_EVENTS_INFO {
18952 + A_UINT32 Events;
18953 + A_UINT32 LookAhead;
18954 +} HIF_PENDING_EVENTS_INFO;
18955 +
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);
18961 +
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,
18966 + A_BOOL Mask,
18967 + void *AsyncContext);
18968 +
18969 +
18970 +/*
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.
18978 + */
18979 +int HIFInit(HTC_CALLBACKS *callbacks);
18980 +
18981 +/*
18982 + * This API is used to provide the read/write interface over the specific bus
18983 + * interface.
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
18989 + * received.
18990 + * length - Amount of data to be transmitted or received.
18991 + * request - Characterizes the attributes of the command.
18992 + */
18993 +A_STATUS
18994 +HIFReadWrite(HIF_DEVICE *device,
18995 + A_UINT32 address,
18996 + A_UCHAR *buffer,
18997 + A_UINT32 length,
18998 + A_UINT32 request,
18999 + void *context);
19000 +
19001 +/*
19002 + * This can be initiated from the unload driver context ie when the HTCShutdown
19003 + * routine is called.
19004 + */
19005 +void HIFShutDownDevice(HIF_DEVICE *device);
19006 +
19007 +/*
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.
19013 + */
19014 +void HIFAckInterrupt(HIF_DEVICE *device);
19015 +
19016 +void HIFMaskInterrupt(HIF_DEVICE *device);
19017 +
19018 +void HIFUnMaskInterrupt(HIF_DEVICE *device);
19019 +
19020 +/*
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.
19025 + */
19026 +int HIFInsertEventNotify(void);
19027 +
19028 +int HIFRemoveEventNotify(void);
19029 +
19030 +int HIFIRQEventNotify(void);
19031 +
19032 +int HIFRWCompleteEventNotify(void);
19033 +
19034 +/*
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.
19038 + */
19039 +void HIFSetHandle(void *hif_handle, void *handle);
19040 +
19041 +A_STATUS
19042 +HIFConfigureDevice(HIF_DEVICE *device, HIF_DEVICE_CONFIG_OPCODE opcode,
19043 + void *config, A_UINT32 configLen);
19044 +
19045 +
19046 +#ifdef __cplusplus
19047 +}
19048 +#endif
19049 +
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
19054 --- /dev/null
19055 +++ b/drivers/sdio/function/wlan/ar6000/include/host_version.h
19056 @@ -0,0 +1,49 @@
19057 +#ifndef _HOST_VERSION_H_
19058 +#define _HOST_VERSION_H_
19059 +/*
19060 + * Copyright (c) 2004-2005 Atheros Communications Inc.
19061 + * All rights reserved.
19062 + *
19063 + * This file contains version information for the sample host driver for the
19064 + * AR6000 chip
19065 + *
19066 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/host_version.h#2 $
19067 + *
19068 + *
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;
19072 + *
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.
19077 + *
19078 + *
19079 + *
19080 + */
19081 +
19082 +#ifdef __cplusplus
19083 +extern "C" {
19084 +#endif
19085 +
19086 +#include <AR6K_version.h>
19087 +
19088 +/*
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
19093 + * identifiable.
19094 + */
19095 +
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
19100 +
19101 +#ifdef __cplusplus
19102 +}
19103 +#endif
19104 +
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
19109 --- /dev/null
19110 +++ b/drivers/sdio/function/wlan/ar6000/include/htc.h
19111 @@ -0,0 +1,190 @@
19112 +/*
19113 + * Copyright (c) 2007 Atheros Communications Inc.
19114 + * All rights reserved.
19115 + *
19116 + * $ATH_LICENSE_HOSTSDK0_C$
19117 + *
19118 + */
19119 +
19120 +
19121 +#ifndef __HTC_H__
19122 +#define __HTC_H__
19123 +
19124 +#ifndef ATH_TARGET
19125 +#include "athstartpack.h"
19126 +#endif
19127 +
19128 +#define A_OFFSETOF(type,field) (int)(&(((type *)NULL)->field))
19129 +
19130 +#define ASSEMBLE_UNALIGNED_UINT16(p,highbyte,lowbyte) \
19131 + (((A_UINT16)(((A_UINT8 *)(p))[(highbyte)])) << 8 | (A_UINT16)(((A_UINT8 *)(p))[(lowbyte)]))
19132 +
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))
19140 +
19141 +#define A_SET_UINT16_FIELD(p,type,field,value) \
19142 +{ \
19143 + ((A_UINT8 *)(p))[A_OFFSETOF(type,field)] = (A_UINT8)(value); \
19144 + ((A_UINT8 *)(p))[A_OFFSETOF(type,field) + 1] = (A_UINT8)((value) >> 8); \
19145 +}
19146 +
19147 +#define A_GET_UINT8_FIELD(p,type,field) \
19148 + ((A_UINT8 *)(p))[A_OFFSETOF(type,field)]
19149 +
19150 +#define A_SET_UINT8_FIELD(p,type,field,value) \
19151 + ((A_UINT8 *)(p))[A_OFFSETOF(type,field)] = (value)
19152 +
19153 +/****** DANGER DANGER ***************
19154 + *
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.
19158 + *
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.
19162 + *
19163 + */
19164 +
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;
19170 + A_UINT8 Flags;
19171 + A_UINT16 PayloadLen; /* length of data (including trailer) that follows the header */
19172 +
19173 + /***** end of 4-byte lookahead ****/
19174 +
19175 + A_UINT8 ControlBytes[2];
19176 +
19177 + /* message payload starts after the header */
19178 +
19179 +} POSTPACK HTC_FRAME_HDR;
19180 +
19181 +/* frame header flags */
19182 +#define HTC_FLAGS_NEED_CREDIT_UPDATE (1 << 0)
19183 +#define HTC_FLAGS_RECV_TRAILER (1 << 1)
19184 +
19185 +
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))
19189 +
19190 +/* HTC control message IDs */
19191 +typedef enum {
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,
19196 +} HTC_MSG_IDS;
19197 +
19198 +#define HTC_MAX_CONTROL_MESSAGE_LENGTH 256
19199 +
19200 +/* base message ID header */
19201 +typedef PREPACK struct {
19202 + A_UINT16 MessageID;
19203 +} POSTPACK HTC_UNKNOWN_MSG;
19204 +
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 */
19212 + A_UINT8 _Pad1;
19213 +} POSTPACK HTC_READY_MSG;
19214 +
19215 +#define HTC_SERVICE_META_DATA_MAX_LENGTH 128
19216 +
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 */
19223 +
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
19231 +
19232 + A_UINT8 ServiceMetaLength; /* length of meta data that follows */
19233 + A_UINT8 _Pad1;
19234 +
19235 + /* service-specific meta data starts after the header */
19236 +
19237 +} POSTPACK HTC_CONNECT_SERVICE_MSG;
19238 +
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 */
19248 + A_UINT8 _Pad1;
19249 +
19250 + /* service-specific meta data starts after the header */
19251 +
19252 +} POSTPACK HTC_CONNECT_SERVICE_RESPONSE_MSG;
19253 +
19254 +typedef PREPACK struct {
19255 + A_UINT16 MessageID;
19256 + /* currently, no other fields */
19257 +} POSTPACK HTC_SETUP_COMPLETE_MSG;
19258 +
19259 +
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
19266 + endpoints */
19267 +
19268 +/* report record IDs */
19269 +typedef enum {
19270 + HTC_RECORD_NULL = 0,
19271 + HTC_RECORD_CREDITS = 1,
19272 + HTC_RECORD_LOOKAHEAD = 2,
19273 +} HTC_RPT_IDS;
19274 +
19275 +typedef PREPACK struct {
19276 + A_UINT8 RecordID; /* Record ID */
19277 + A_UINT8 Length; /* Length of record */
19278 +} POSTPACK HTC_RECORD_HDR;
19279 +
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;
19284 +
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 */
19289 +
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 */
19292 +
19293 +} POSTPACK HTC_LOOKAHEAD_REPORT;
19294 +
19295 +#ifndef ATH_TARGET
19296 +#include "athendpack.h"
19297 +#endif
19298 +
19299 +
19300 +#endif /* __HTC_H__ */
19301 +
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
19305 --- /dev/null
19306 +++ b/drivers/sdio/function/wlan/ar6000/include/htc_api.h
19307 @@ -0,0 +1,436 @@
19308 +/*
19309 + *
19310 + * Copyright (c) 2007 Atheros Communications Inc.
19311 + * All rights reserved.
19312 + *
19313 + *
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;
19317 + *
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.
19322 + *
19323 + *
19324 + *
19325 + */
19326 +
19327 +#ifndef _HTC_API_H_
19328 +#define _HTC_API_H_
19329 +
19330 +#include <htc.h>
19331 +#include <htc_services.h>
19332 +#include "htc_packet.h"
19333 +
19334 +#ifdef __cplusplus
19335 +extern "C" {
19336 +#endif /* __cplusplus */
19337 +
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
19342 +
19343 +
19344 +/* ------ Endpoint IDS ------ */
19345 +typedef enum
19346 +{
19347 + ENDPOINT_UNUSED = -1,
19348 + ENDPOINT_0 = 0,
19349 + ENDPOINT_1 = 1,
19350 + ENDPOINT_2 = 2,
19351 + ENDPOINT_3,
19352 + ENDPOINT_4,
19353 + ENDPOINT_5,
19354 + ENDPOINT_6,
19355 + ENDPOINT_7,
19356 + ENDPOINT_8,
19357 + ENDPOINT_MAX,
19358 +} HTC_ENDPOINT_ID;
19359 +
19360 +/* this is the amount of header room required by users of HTC */
19361 +#define HTC_HEADER_LEN HTC_HDR_LENGTH
19362 +
19363 +typedef void *HTC_HANDLE;
19364 +
19365 +typedef A_UINT16 HTC_SERVICE_ID;
19366 +
19367 +typedef struct _HTC_INIT_INFO {
19368 + void (*AddInstance)(HTC_HANDLE);
19369 + void (*DeleteInstance)(void *Instance);
19370 + void (*TargetFailure)(void *Instance, A_STATUS Status);
19371 +} HTC_INIT_INFO;
19372 +
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 *);
19377 +
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.
19382 + *
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
19385 + * unnecessary */
19386 +typedef void (*HTC_EP_RECV_REFILL)(void *, HTC_ENDPOINT_ID Endpoint);
19387 +
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);
19396 +
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;
19404 +
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;
19414 +
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;
19424 +
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;
19454 +
19455 +#define HTC_EP_ACTIVE (1 << 31)
19456 +
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
19461 +
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;
19472 +
19473 +typedef void (*HTC_CREDIT_DIST_CALLBACK)(void *Context,
19474 + HTC_ENDPOINT_CREDIT_DIST *pEPList,
19475 + HTC_CREDIT_DIST_REASON Reason);
19476 +
19477 +typedef void (*HTC_CREDIT_INIT_CALLBACK)(void *Context,
19478 + HTC_ENDPOINT_CREDIT_DIST *pEPList,
19479 + int TotalCredits);
19480 +
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;
19487 +
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
19491 + this endpoint */
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;
19506 +
19507 +/* ------ Function Prototypes ------ */
19508 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19509 + @desc: Initialize HTC
19510 + @function name: HTCInit
19511 + @input: pInfo - initialization information
19512 + @output:
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).
19516 +
19517 + @example:
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
19525 + @output:
19526 + @return: opaque HIF device handle usable in HIF API calls.
19527 + @notes:
19528 + @example:
19529 + @see also:
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
19537 + @output:
19538 + @return:
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.
19542 + @example:
19543 + @see also:
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
19554 + priority
19555 + ListLength - number of elements in ServicePriorityOrder
19556 + @output:
19557 + @return:
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.
19562 +
19563 + @example:
19564 + @see also:
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[],
19571 + int ListLength);
19572 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19573 + @desc: Wait for the target to indicate the HTC layer is ready
19574 + @function name: HTCWaitTarget
19575 + @input: HTCHandle - HTC handle
19576 + @output:
19577 + @return:
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
19580 + ready.
19581 + @example:
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
19589 + @output:
19590 + @return:
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.
19596 + @example:
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
19605 + @output:
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()
19609 + macro.
19610 + @example:
19611 + @see also:
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
19620 + @return:
19621 + @notes: Service connections must be performed before HTCStart. User provides callback handlers
19622 + for various endpoint events.
19623 + @example:
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
19634 + @output:
19635 + @return: A_OK
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.
19639 + @example:
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
19647 + @output:
19648 + @return:
19649 + @notes: HTC communications is halted. All receive and pending TX packets will
19650 + be flushed.
19651 + @example:
19652 + @see also:
19653 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19654 +void HTCStop(HTC_HANDLE HTCHandle);
19655 +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19656 + @desc: Shutdown HTC
19657 + @function name: HTCShutdown
19658 + @input:
19659 + @output:
19660 + @return:
19661 + @notes: This cleans up all resources allocated by HTCInit().
19662 + @example:
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
19671 + Tag - flush tag
19672 + @output:
19673 + @return:
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.
19676 + @example:
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
19684 + @output:
19685 + @return:
19686 + @notes: This dumps all credit distribution information to the debugger
19687 + @example:
19688 + @see also:
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
19697 + @output:
19698 + @return:
19699 + @notes: This triggers the registered credit distribution function to
19700 + re-adjust credits for active/inactive endpoints.
19701 + @example:
19702 + @see also:
19703 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19704 +void HTCIndicateActivityChange(HTC_HANDLE HTCHandle,
19705 + HTC_ENDPOINT_ID Endpoint,
19706 + A_BOOL Active);
19707 +
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
19714 + @output:
19715 + pStats - statistics that were sampled (can be NULL if Action is HTC_EP_STAT_CLEAR)
19716 +
19717 + @return: TRUE if statistics profiling is enabled, otherwise FALSE.
19718 +
19719 + @notes: Statistics is a compile-time option and this function may return FALSE
19720 + if HTC is not compiled with profiling.
19721 +
19722 + The caller can specify the statistic "action" to take when sampling
19723 + the statistics. This includes:
19724 +
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
19727 + are cleared.
19728 + HTC_EP_STAT_CLEA : the statistics are cleared, the called can pass a NULL value for
19729 + pStats
19730 +
19731 + @example:
19732 + @see also:
19733 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
19734 +A_BOOL HTCGetEndpointStatistics(HTC_HANDLE HTCHandle,
19735 + HTC_ENDPOINT_ID Endpoint,
19736 + HTC_ENDPOINT_STAT_ACTION Action,
19737 + HTC_ENDPOINT_STATS *pStats);
19738 +
19739 +#ifdef __cplusplus
19740 +}
19741 +#endif
19742 +
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
19747 --- /dev/null
19748 +++ b/drivers/sdio/function/wlan/ar6000/include/htc_packet.h
19749 @@ -0,0 +1,138 @@
19750 +/*
19751 + *
19752 + * Copyright (c) 2007 Atheros Communications Inc.
19753 + * All rights reserved.
19754 + *
19755 + *
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;
19759 + *
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.
19764 + *
19765 + *
19766 + *
19767 + */
19768 +
19769 +#ifndef HTC_PACKET_H_
19770 +#define HTC_PACKET_H_
19771 +
19772 +
19773 +#include "dl_list.h"
19774 +
19775 +struct _HTC_PACKET;
19776 +
19777 +typedef void (* HTC_PACKET_COMPLETION)(void *,struct _HTC_PACKET *);
19778 +
19779 +typedef A_UINT16 HTC_TX_TAG;
19780 +
19781 +typedef struct _HTC_TX_PACKET_INFO {
19782 + HTC_TX_TAG Tag; /* tag used to selective flush packets */
19783 +} HTC_TX_PACKET_INFO;
19784 +
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 */
19788 +
19789 +typedef struct _HTC_RX_PACKET_INFO {
19790 + A_UINT32 Unused; /* for future use and to make compilers happy */
19791 +} HTC_RX_PACKET_INFO;
19792 +
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 */
19797 +
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 */
19804 + /*
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
19810 + */
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 */
19816 + union {
19817 + HTC_TX_PACKET_INFO AsTx; /* Tx Packet specific info */
19818 + HTC_RX_PACKET_INFO AsRx; /* Rx Packet specific info */
19819 + } PktInfo;
19820 +
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 */
19825 +} HTC_PACKET;
19826 +
19827 +
19828 +
19829 +#define COMPLETE_HTC_PACKET(p,status) \
19830 +{ \
19831 + (p)->Status = (status); \
19832 + (p)->Completion((p)->pContext,(p)); \
19833 +}
19834 +
19835 +#define INIT_HTC_PACKET_INFO(p,b,len) \
19836 +{ \
19837 + (p)->pBufferStart = (b); \
19838 + (p)->BufferLength = (len); \
19839 +}
19840 +
19841 +/* macro to set an initial RX packet for refilling HTC */
19842 +#define SET_HTC_PACKET_INFO_RX_REFILL(p,c,b,len,ep) \
19843 +{ \
19844 + (p)->pPktContext = (c); \
19845 + (p)->pBuffer = (b); \
19846 + (p)->pBufferStart = (b); \
19847 + (p)->BufferLength = (len); \
19848 + (p)->Endpoint = (ep); \
19849 +}
19850 +
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
19854 +
19855 +/* macro to set packet parameters for TX */
19856 +#define SET_HTC_PACKET_INFO_TX(p,c,b,len,ep,tag) \
19857 +{ \
19858 + (p)->pPktContext = (c); \
19859 + (p)->pBuffer = (b); \
19860 + (p)->ActualLength = (len); \
19861 + (p)->Endpoint = (ep); \
19862 + (p)->PktInfo.AsTx.Tag = (tag); \
19863 +}
19864 +
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)
19877 +
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);
19883 + }
19884 + return NULL;
19885 +}
19886 +
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
19891 --- /dev/null
19892 +++ b/drivers/sdio/function/wlan/ar6000/include/htc_services.h
19893 @@ -0,0 +1,37 @@
19894 +/*
19895 + * Copyright (c) 2007 Atheros Communications Inc.
19896 + * All rights reserved.
19897 + *
19898 + * $ATH_LICENSE_HOSTSDK0_C$
19899 + *
19900 + */
19901 +
19902 +#ifndef __HTC_SERVICES_H__
19903 +#define __HTC_SERVICES_H__
19904 +
19905 +/* Current service IDs */
19906 +
19907 +typedef enum {
19908 + RSVD_SERVICE_GROUP = 0,
19909 + WMI_SERVICE_GROUP = 1,
19910 +
19911 + HTC_TEST_GROUP = 254,
19912 + HTC_SERVICE_GROUP_LAST = 255
19913 +}HTC_SERVICE_GROUP_IDS;
19914 +
19915 +#define MAKE_SERVICE_ID(group,index) \
19916 + (int)(((int)group << 8) | (int)(index))
19917 +
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
19926 +
19927 +/* raw stream service (i.e. flash, tcmd, calibration apps) */
19928 +#define HTC_RAW_STREAMS_SVC MAKE_SERVICE_ID(HTC_TEST_GROUP,0)
19929 +
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
19934 --- /dev/null
19935 +++ b/drivers/sdio/function/wlan/ar6000/include/ieee80211.h
19936 @@ -0,0 +1,342 @@
19937 +/*-
19938 + * Copyright (c) 2001 Atsushi Onoe
19939 + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
19940 + * Copyright (c) 2006 Atheros Communications, Inc.
19941 + *
19942 + * Wireless Network driver for Atheros AR6001
19943 + * All rights reserved.
19944 + *
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.
19955 + *
19956 + */
19957 +#ifndef _NET80211_IEEE80211_H_
19958 +#define _NET80211_IEEE80211_H_
19959 +
19960 +#include "athstartpack.h"
19961 +
19962 +/*
19963 + * 802.11 protocol definitions.
19964 + */
19965 +
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)
19971 +
19972 +#define IEEE80211_KEYBUF_SIZE 16
19973 +#define IEEE80211_MICBUF_SIZE (8+8) /* space for both tx and rx */
19974 +
19975 +/*
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.
19979 + */
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 */
19987 +
19988 +#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1)
19989 +
19990 +#define IEEE80211_IS_VALID_WEP_CIPHER_LEN(len) \
19991 + (((len) == 5) || ((len) == 13) || ((len) == 16))
19992 +
19993 +
19994 +
19995 +/*
19996 + * generic definitions for IEEE 802.11 frames
19997 + */
19998 +PREPACK struct ieee80211_frame {
19999 + A_UINT8 i_fc[2];
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]; */
20006 + /* see below */
20007 +} POSTPACK;
20008 +
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
20017 +
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
20050 +
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 */
20056 +
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
20063 +
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
20068 +
20069 +#define IEEE80211_NWID_LEN 32
20070 +
20071 +/*
20072 + * 802.11 rate set.
20073 + */
20074 +#define IEEE80211_RATE_SIZE 8 /* 802.11 standard */
20075 +#define IEEE80211_RATE_MAXSIZE 15 /* max rates we'll handle */
20076 +
20077 +#define WMM_NUM_AC 4 /* 4 AC categories */
20078 +
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 */
20087 +
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 : \
20092 + 0)
20093 +
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 : \
20098 + WMM_AC_VO)
20099 +/*
20100 + * Management information element payloads.
20101 + */
20102 +
20103 +enum {
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 */
20130 +};
20131 +
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
20136 +
20137 +#define WPA_OUI 0xf25000
20138 +#define WPA_OUI_TYPE 0x01
20139 +#define WPA_VERSION 1 /* current supported version */
20140 +
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
20146 +
20147 +#define WPA_ASE_NONE 0x00
20148 +#define WPA_ASE_8021X_UNSPEC 0x01
20149 +#define WPA_ASE_8021X_PSK 0x02
20150 +
20151 +#define RSN_OUI 0xac0f00
20152 +#define RSN_VERSION 1 /* current supported version */
20153 +
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
20160 +
20161 +#define RSN_ASE_NONE 0x00
20162 +#define RSN_ASE_8021X_UNSPEC 0x01
20163 +#define RSN_ASE_8021X_PSK 0x02
20164 +
20165 +#define RSN_CAP_PREAUTH 0x01
20166 +
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
20172 +
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 */
20179 +
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
20185 +
20186 +typedef enum {
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;
20197 +
20198 +/*
20199 + * WMM/802.11e Tspec Element
20200 + */
20201 +typedef PREPACK struct wmm_tspec_ie_t {
20202 + A_UINT8 elementId;
20203 + A_UINT8 len;
20204 + A_UINT8 oui[3];
20205 + A_UINT8 ouiType;
20206 + A_UINT8 ouiSubType;
20207 + A_UINT8 version;
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;
20223 + A_UINT16 sba;
20224 + A_UINT16 mediumTime;
20225 +} POSTPACK WMM_TSPEC_IE;
20226 +
20227 +
20228 +/*
20229 + * BEACON management packets
20230 + *
20231 + * octet timestamp[8]
20232 + * octet beacon interval[2]
20233 + * octet capability information[2]
20234 + * information element
20235 + * octet elemid
20236 + * octet length
20237 + * octet information[length]
20238 + */
20239 +
20240 +#define IEEE80211_BEACON_INTERVAL(beacon) \
20241 + ((beacon)[8] | ((beacon)[9] << 8))
20242 +#define IEEE80211_BEACON_CAPABILITY(beacon) \
20243 + ((beacon)[10] | ((beacon)[11] << 8))
20244 +
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 */
20259 +
20260 +/*
20261 + * Authentication Modes
20262 + */
20263 +
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 */
20274 +};
20275 +
20276 +#include "athendpack.h"
20277 +
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
20282 --- /dev/null
20283 +++ b/drivers/sdio/function/wlan/ar6000/include/ieee80211_ioctl.h
20284 @@ -0,0 +1,163 @@
20285 +/*
20286 + * Copyright (c) 2004-2005 Atheros Communications Inc.
20287 + * All rights reserved.
20288 + *
20289 + *
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;
20293 + *
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.
20298 + *
20299 + *
20300 + *
20301 + *
20302 + * $Id: //depot/sw/releases/olca2.0-GPL/host/os/linux/include/ieee80211_ioctl.h#1 $
20303 + */
20304 +
20305 +#ifndef _IEEE80211_IOCTL_H_
20306 +#define _IEEE80211_IOCTL_H_
20307 +
20308 +#ifdef __cplusplus
20309 +extern "C" {
20310 +#endif
20311 +
20312 +/*
20313 + * Extracted from the MADWIFI net80211/ieee80211_ioctl.h
20314 + */
20315 +
20316 +/*
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.
20325 + */
20326 +struct ieee80211req_key {
20327 + u_int8_t ik_type; /* key/cipher type */
20328 + u_int8_t ik_pad;
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];
20339 +};
20340 +/*
20341 + * Delete a key either by index or address. Set the index
20342 + * to IEEE80211_KEYIX_NONE when deleting a unicast key.
20343 + */
20344 +struct ieee80211req_del_key {
20345 + u_int8_t idk_keyix; /* key index */
20346 + u_int8_t idk_macaddr[IEEE80211_ADDR_LEN];
20347 +};
20348 +/*
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).
20353 + */
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];
20363 +};
20364 +
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];
20369 +};
20370 +
20371 +#define AUTH_ALG_OPEN_SYSTEM 0x01
20372 +#define AUTH_ALG_SHARED_KEY 0x02
20373 +#define AUTH_ALG_LEAP 0x04
20374 +
20375 +struct ieee80211req_authalg {
20376 + u_int8_t auth_alg;
20377 +};
20378 +
20379 +/*
20380 + * Request to add an IE to a Management Frame
20381 + */
20382 +enum{
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
20389 +};
20390 +
20391 +/*
20392 + * The Maximum length of the IE that can be added to a Management frame
20393 + */
20394 +#define IEEE80211_APPIE_FRAME_MAX_LEN 78
20395 +
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[];
20400 +};
20401 +
20402 +/*
20403 + * The following definitions are used by an application to set filter
20404 + * for receiving management frames
20405 + */
20406 +enum {
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 */
20416 +};
20417 +
20418 +struct ieee80211req_set_filter {
20419 + u_int32_t app_filterype; /* management frame filter type */
20420 +};
20421 +
20422 +enum {
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 */
20433 +};
20434 +
20435 +/*
20436 + * Values for IEEE80211_PARAM_WPA
20437 + */
20438 +#define WPA_MODE_WPA1 1
20439 +#define WPA_MODE_WPA2 2
20440 +#define WPA_MODE_AUTO 3
20441 +#define WPA_MODE_NONE 4
20442 +
20443 +#ifdef __cplusplus
20444 +}
20445 +#endif
20446 +
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
20451 --- /dev/null
20452 +++ b/drivers/sdio/function/wlan/ar6000/include/ieee80211_node.h
20453 @@ -0,0 +1,77 @@
20454 +/*-
20455 + * Copyright (c) 2001 Atsushi Onoe
20456 + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
20457 + * Copyright (c) 2006 Atheros Communications, Inc.
20458 + *
20459 + * Wireless Network driver for Atheros AR6001
20460 + * All rights reserved.
20461 + *
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.
20472 + *
20473 + */
20474 +#ifndef _IEEE80211_NODE_H_
20475 +#define _IEEE80211_NODE_H_
20476 +
20477 +/*
20478 + * Node locking definitions.
20479 + */
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)
20487 +
20488 +/*
20489 + * Node reference counting definitions.
20490 + *
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)
20497 + */
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)
20503 +
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)
20509 +
20510 +/*
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.
20515 + */
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 */
20526 +};
20527 +
20528 +#define WLAN_NODE_INACT_TIMEOUT_MSEC 10000
20529 +
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
20534 --- /dev/null
20535 +++ b/drivers/sdio/function/wlan/ar6000/include/ini_dset.h
20536 @@ -0,0 +1,40 @@
20537 +/*
20538 + * Copyright (c) 2004-2007 Atheros Communications Inc.
20539 + * All rights reserved.
20540 + *
20541 + * $ATH_LICENSE_HOSTSDK0_C$
20542 + *
20543 + */
20544 +#ifndef _INI_DSET_H_
20545 +#define _INI_DSET_H_
20546 +
20547 +/*
20548 + * Each of these represents a WHAL INI table, which consists
20549 + * of an "address column" followed by 1 or more "value columns".
20550 + *
20551 + * Software uses the base WHAL_INI_DATA_ID+column to access a
20552 + * DataSet that holds a particular column of data.
20553 + */
20554 +typedef enum {
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 */
20566 +
20567 + WHAL_INI_DATA_ID_MAX =25
20568 +} WHAL_INI_DATA_ID;
20569 +
20570 +typedef PREPACK struct {
20571 + A_UINT16 freqIndex; // 1 - A mode 2 - B or G mode 0 - common
20572 + A_UINT16 offset;
20573 + A_UINT32 newValue;
20574 +} POSTPACK INI_DSET_REG_OVERRIDE;
20575 +
20576 +#endif
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
20580 --- /dev/null
20581 +++ b/drivers/sdio/function/wlan/ar6000/include/regDb.h
20582 @@ -0,0 +1,19 @@
20583 +/*
20584 + * Copyright (c) 2005 Atheros Communications, Inc.
20585 + * All rights reserved.
20586 + *
20587 + *
20588 + * $ATH_LICENSE_HOSTSDK0_C$
20589 + *
20590 + * This module contains the header files for regulatory module,
20591 + * which include the DB schema and DB values.
20592 + * $Id:
20593 + */
20594 +
20595 +#ifndef __REG_DB_H__
20596 +#define __REG_DB_H__
20597 +
20598 +#include "./regulatory/reg_dbschema.h"
20599 +#include "./regulatory/reg_dbvalues.h"
20600 +
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
20605 --- /dev/null
20606 +++ b/drivers/sdio/function/wlan/ar6000/include/regdump.h
20607 @@ -0,0 +1,33 @@
20608 +#ifndef __REGDUMP_H__
20609 +#define __REGDUMP_H__
20610 +/*
20611 + * Copyright (c) 2004-2007 Atheros Communications Inc.
20612 + * All rights reserved.
20613 + *
20614 + * $ATH_LICENSE_HOSTSDK0_C$
20615 + *
20616 + */
20617 +#if defined(AR6001)
20618 +#include "AR6001/AR6001_regdump.h"
20619 +#endif
20620 +#if defined(AR6002)
20621 +#include "AR6002/AR6002_regdump.h"
20622 +#endif
20623 +
20624 +#if !defined(__ASSEMBLER__)
20625 +/*
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.
20629 + */
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 */
20636 +
20637 + /* Could copy top of stack here, too.... */
20638 +};
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
20644 --- /dev/null
20645 +++ b/drivers/sdio/function/wlan/ar6000/include/targaddrs.h
20646 @@ -0,0 +1,158 @@
20647 +/*
20648 + * Copyright (c) 2004-2007 Atheros Communications Inc.
20649 + * All rights reserved.
20650 + *
20651 + * $ATH_LICENSE_HOSTSDK0_C$
20652 + *
20653 + */
20654 +
20655 +#ifndef __TARGADDRS_H__
20656 +#define __TARGADDRS_H__
20657 +#if defined(AR6001)
20658 +#include "AR6001/addrs.h"
20659 +#endif
20660 +#if defined(AR6002)
20661 +#include "AR6002/addrs.h"
20662 +#endif
20663 +
20664 +/*
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.
20668 + */
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 */
20677 +
20678 +/*
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).
20682 + *
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.
20686 + */
20687 +#define AR6001_HOST_INTEREST_ADDRESS 0x80000600
20688 +#define AR6002_HOST_INTEREST_ADDRESS 0x00500400
20689 +
20690 +#define HOST_INTEREST_MAX_SIZE 0x100
20691 +
20692 +#if !defined(__ASSEMBLER__)
20693 +struct register_dump_s;
20694 +struct dbglog_hdr_s;
20695 +
20696 +/*
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!
20701 + *
20702 + * Types for each item must be fixed size across
20703 + * target and host platforms.
20704 + *
20705 + * More items may be added at the end.
20706 + */
20707 +struct host_interest_s {
20708 + /*
20709 + * Pointer to application-defined area, if any.
20710 + * Set by Target application during startup.
20711 + */
20712 + A_UINT32 hi_app_host_interest; /* 0x00 */
20713 +
20714 + /* Pointer to register dump area, valid after Target crash. */
20715 + A_UINT32 hi_failure_state; /* 0x04 */
20716 +
20717 + /* Pointer to debug logging header */
20718 + A_UINT32 hi_dbglog_hdr; /* 0x08 */
20719 +
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
20726 + * of data.
20727 + */
20728 + A_UINT32 hi_flash_is_present; /* 0x0c */
20729 +
20730 + /*
20731 + * General-purpose flag bits, similar to AR6000_OPTION_* flags.
20732 + * Can be used by application rather than by OS.
20733 + */
20734 + A_UINT32 hi_option_flag; /* 0x10 */
20735 +
20736 + /*
20737 + * Boolean that determines whether or not to
20738 + * display messages on the serial port.
20739 + */
20740 + A_UINT32 hi_serial_enable; /* 0x14 */
20741 +
20742 + /* Start address of Flash DataSet index, if any */
20743 + A_UINT32 hi_dset_list_head; /* 0x18 */
20744 +
20745 + /* Override Target application start address */
20746 + A_UINT32 hi_app_start; /* 0x1c */
20747 +
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 */
20758 +
20759 + /*
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.)
20764 + */
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 */
20769 +
20770 + /* Pointer to Board Data */
20771 + A_UINT32 hi_board_data; /* 0x54 */
20772 + A_UINT32 hi_board_data_initialized; /* 0x58 */
20773 +
20774 + A_UINT32 hi_dset_RAM_index_table; /* 0x5c */
20775 +
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 */
20780 +
20781 + A_UINT32 hi_num_bpatch_streams; /* 0x70 */
20782 + A_UINT32 hi_mbox_isr_yield_limit; /* 0x74 */
20783 +
20784 + A_UINT32 hi_refclk_hz; /* 0x78 */
20785 +};
20786 +
20787 +/* Bits defined in hi_option_flag */
20788 +#define HI_OPTION_TIMER_WAR 1 /* not really used */
20789 +
20790 +/*
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);
20794 + */
20795 +#define AR6001_HOST_INTEREST_ITEM_ADDRESS(item) \
20796 + ((A_UINT32)&((((struct host_interest_s *)(AR6001_HOST_INTEREST_ADDRESS))->item)))
20797 +
20798 +#define AR6002_HOST_INTEREST_ITEM_ADDRESS(item) \
20799 + ((A_UINT32)&((((struct host_interest_s *)(AR6002_HOST_INTEREST_ADDRESS))->item)))
20800 +
20801 +
20802 +#endif /* !__ASSEMBLER__ */
20803 +
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
20808 --- /dev/null
20809 +++ b/drivers/sdio/function/wlan/ar6000/include/testcmd.h
20810 @@ -0,0 +1,144 @@
20811 +/*
20812 + * Copyright (c) 2004-2005 Atheros Communications Inc.
20813 + * All rights reserved.
20814 + *
20815 + *
20816 + * $ATH_LICENSE_HOSTSDK0_C$
20817 + *
20818 + */
20819 +
20820 +#ifndef TESTCMD_H_
20821 +#define TESTCMD_H_
20822 +
20823 +#ifdef __cplusplus
20824 +extern "C" {
20825 +#endif
20826 +
20827 +typedef enum {
20828 + ZEROES_PATTERN = 0,
20829 + ONES_PATTERN,
20830 + REPEATING_10,
20831 + PN7_PATTERN,
20832 + PN9_PATTERN,
20833 + PN15_PATTERN
20834 +}TX_DATA_PATTERN;
20835 +
20836 +/* Continous tx
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
20842 + 1 - 2 Mbps
20843 + 2 - 5.5 Mbps
20844 + 3 - 11 Mbps
20845 + 4 - 6 Mbps
20846 + 5 - 9 Mbps
20847 + 6 - 12 Mbps
20848 + 7 - 18 Mbps
20849 + 8 - 24 Mbps
20850 + 9 - 36 Mbps
20851 + 10 - 28 Mbps
20852 + 11 - 54 Mbps
20853 + txPwr: Tx power in dBm[5 -11] for unmod Tx, [5-14] for mod Tx
20854 +antenna: 1 - one antenna
20855 + 2 - two antenna
20856 +Note : Enable/disable continuous tx test cmd works only when target is awake.
20857 +*/
20858 +
20859 +typedef enum {
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;
20866 +
20867 +typedef PREPACK struct {
20868 + A_UINT32 testCmdId;
20869 + A_UINT32 mode;
20870 + A_UINT32 freq;
20871 + A_UINT32 dataRate;
20872 + A_INT32 txPwr;
20873 + A_UINT32 antenna;
20874 + A_UINT32 enANI;
20875 + A_UINT32 scramblerOff;
20876 + A_UINT32 aifsn;
20877 + A_UINT16 pktSz;
20878 + A_UINT16 txPattern;
20879 +} POSTPACK TCMD_CONT_TX;
20880 +
20881 +#define TCMD_TXPATTERN_ZERONE 0x1
20882 +#define TCMD_TXPATTERN_ZERONE_DIS_SCRAMBLE 0x2
20883 +
20884 +/* Continuous Rx
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
20891 + Rx test)
20892 +
20893 + TCMD_CONT_RX_SETMAC - set MacAddr mode (sets the MAC address for the
20894 + target. This Overrides
20895 + the default MAC address.)
20896 +
20897 +*/
20898 +typedef enum {
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;
20904 +
20905 +typedef PREPACK struct {
20906 + A_UINT32 testCmdId;
20907 + A_UINT32 act;
20908 + A_UINT32 enANI;
20909 + PREPACK union {
20910 + struct PREPACK TCMD_CONT_RX_PARA {
20911 + A_UINT32 freq;
20912 + A_UINT32 antenna;
20913 + } POSTPACK para;
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];
20920 + } POSTPACK mac;
20921 + } POSTPACK u;
20922 +} POSTPACK TCMD_CONT_RX;
20923 +
20924 +/* Force sleep/wake test cmd
20925 + mode: TCMD_PM_WAKEUP - Wakeup the target
20926 + TCMD_PM_SLEEP - Force the target to sleep.
20927 + */
20928 +typedef enum {
20929 + TCMD_PM_WAKEUP = 1, /* be consistent with target */
20930 + TCMD_PM_SLEEP
20931 +} TCMD_PM_MODE;
20932 +
20933 +typedef PREPACK struct {
20934 + A_UINT32 testCmdId;
20935 + A_UINT32 mode;
20936 +} POSTPACK TCMD_PM;
20937 +
20938 +typedef enum{
20939 + TCMD_CONT_TX_ID,
20940 + TCMD_CONT_RX_ID,
20941 + TCMD_PM_ID
20942 + } TCMD_ID;
20943 +
20944 +typedef PREPACK union {
20945 + TCMD_CONT_TX contTx;
20946 + TCMD_CONT_RX contRx;
20947 + TCMD_PM pm ;
20948 +} POSTPACK TEST_CMD;
20949 +
20950 +#ifdef __cplusplus
20951 +}
20952 +#endif
20953 +
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
20958 --- /dev/null
20959 +++ b/drivers/sdio/function/wlan/ar6000/include/wlan_api.h
20960 @@ -0,0 +1,101 @@
20961 +#ifndef _HOST_WLAN_API_H_
20962 +#define _HOST_WLAN_API_H_
20963 +/*
20964 + * Copyright (c) 2004-2005 Atheros Communications Inc.
20965 + * All rights reserved.
20966 + *
20967 + * This file contains the API for the host wlan module
20968 + *
20969 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/wlan_api.h#1 $
20970 + *
20971 + *
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;
20975 + *
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.
20980 + *
20981 + *
20982 + *
20983 + */
20984 +
20985 +#ifdef __cplusplus
20986 +extern "C" {
20987 +#endif
20988 +
20989 +struct ieee80211_node_table;
20990 +struct ieee80211_frame;
20991 +
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;
20999 + A_UINT8 *ie_wpa;
21000 + A_UINT8 *ie_rsn;
21001 + A_UINT8 *ie_wmm;
21002 + A_UINT8 *ie_ath;
21003 + A_UINT16 ie_capInfo;
21004 + A_UINT16 ie_beaconInt;
21005 + A_UINT8 *ie_tim;
21006 + A_UINT8 *ie_chswitch;
21007 + A_UINT8 ie_erp;
21008 + A_UINT8 *ie_wsc;
21009 +};
21010 +
21011 +typedef struct bss {
21012 + A_UINT8 ni_macaddr[6];
21013 + A_UINT8 ni_snr;
21014 + A_INT16 ni_rssi;
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;
21020 + A_UINT8 *ni_buf;
21021 + struct ieee80211_node_table *ni_table;
21022 + A_UINT32 ni_refcnt;
21023 + int ni_scangen;
21024 + A_UINT32 ni_tstamp;
21025 +} bss_t;
21026 +
21027 +typedef void wlan_node_iter_func(void *arg, bss_t *);
21028 +
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,
21037 + void *arg);
21038 +
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);
21042 +
21043 +A_STATUS wlan_parse_beacon(A_UINT8 *buf, int framelen,
21044 + struct ieee80211_common_ie *cie);
21045 +
21046 +A_UINT16 wlan_ieee2freq(int chan);
21047 +A_UINT32 wlan_freq2ieee(A_UINT16 freq);
21048 +
21049 +
21050 +bss_t *
21051 +wlan_find_Ssidnode (struct ieee80211_node_table *nt, A_UCHAR *pSsid,
21052 + A_UINT32 ssidLength, A_BOOL bIsWPA2);
21053 +
21054 +void
21055 +wlan_node_return (struct ieee80211_node_table *nt, bss_t *ni);
21056 +
21057 +#ifdef __cplusplus
21058 +}
21059 +#endif
21060 +
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
21065 --- /dev/null
21066 +++ b/drivers/sdio/function/wlan/ar6000/include/wlan_dset.h
21067 @@ -0,0 +1,20 @@
21068 +/*
21069 + * Copyright (c) 2007 Atheros Communications, Inc.
21070 + * All rights reserved.
21071 + *
21072 + *
21073 + * $ATH_LICENSE_HOSTSDK0_C$
21074 + *
21075 + */
21076 +
21077 +#ifndef __WLAN_DSET_H__
21078 +#define __WKAN_DSET_H__
21079 +
21080 +typedef PREPACK struct wow_config_dset {
21081 +
21082 + A_UINT8 valid_dset;
21083 + A_UINT8 gpio_enable;
21084 + A_UINT16 gpio_pin;
21085 +} POSTPACK WOW_CONFIG_DSET;
21086 +
21087 +#endif
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
21091 --- /dev/null
21092 +++ b/drivers/sdio/function/wlan/ar6000/include/wmi.h
21093 @@ -0,0 +1,1743 @@
21094 +/*
21095 + * Copyright (c) 2004-2006 Atheros Communications Inc.
21096 + * All rights reserved.
21097 + *
21098 + *
21099 + * $ATH_LICENSE_HOSTSDK0_C$
21100 + *
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.
21105 + *
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.
21109 + *
21110 + */
21111 +
21112 +#ifndef _WMI_H_
21113 +#define _WMI_H_
21114 +
21115 +#ifndef ATH_TARGET
21116 +#include "athstartpack.h"
21117 +#endif
21118 +
21119 +#include "wmix.h"
21120 +
21121 +#ifdef __cplusplus
21122 +extern "C" {
21123 +#endif
21124 +
21125 +#define WMI_PROTOCOL_VERSION 0x0002
21126 +#define WMI_PROTOCOL_REVISION 0x0000
21127 +
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}
21134 +
21135 +#define IP_ETHERTYPE 0x0800
21136 +
21137 +#define WMI_IMPLICIT_PSTREAM 0xFF
21138 +#define WMI_MAX_THINSTREAM 15
21139 +
21140 +struct host_app_area_s {
21141 + A_UINT32 wmi_protocol_ver;
21142 +};
21143 +
21144 +/*
21145 + * Data Path
21146 + */
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;
21152 +
21153 +typedef PREPACK struct {
21154 + A_UINT8 dsap;
21155 + A_UINT8 ssap;
21156 + A_UINT8 cntl;
21157 + A_UINT8 orgCode[3];
21158 + A_UINT16 etherType;
21159 +} POSTPACK ATH_LLC_SNAP_HDR;
21160 +
21161 +typedef enum {
21162 + DATA_MSGTYPE = 0x0,
21163 + CNTL_MSGTYPE,
21164 + SYNC_MSGTYPE
21165 +} WMI_MSG_TYPE;
21166 +
21167 +
21168 +typedef PREPACK struct {
21169 + A_INT8 rssi;
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;
21178 +
21179 +
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))
21182 +
21183 +/*
21184 + * Control Path
21185 + */
21186 +typedef PREPACK struct {
21187 + A_UINT16 commandId;
21188 +} POSTPACK WMI_CMD_HDR; /* used for commands and events */
21189 +
21190 +/*
21191 + * List of Commnands
21192 + */
21193 +typedef enum {
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,
21251 + WMI_TEST_CMDID,
21252 + WMI_SET_BT_STATUS_CMDID,
21253 + WMI_SET_BT_PARAMS_CMDID,
21254 +
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,
21260 +
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,
21271 +
21272 + /*
21273 + * Developer commands starts at 0xF000
21274 + */
21275 + WMI_SET_BITRATE_CMDID = 0xF000,
21276 + WMI_GET_BITRATE_CMDID,
21277 + WMI_SET_WHALPARAM_CMDID,
21278 +
21279 +} WMI_COMMAND_ID;
21280 +
21281 +/*
21282 + * Frame Types
21283 + */
21284 +typedef enum {
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;
21292 +
21293 +/*
21294 + * Connect Command
21295 + */
21296 +typedef enum {
21297 + INFRA_NETWORK = 0x01,
21298 + ADHOC_NETWORK = 0x02,
21299 + ADHOC_CREATOR = 0x04,
21300 +} NETWORK_TYPE;
21301 +
21302 +typedef enum {
21303 + OPEN_AUTH = 0x01,
21304 + SHARED_AUTH = 0x02,
21305 + LEAP_AUTH = 0x04, /* different from IEEE_AUTH_MODE definitions */
21306 +} DOT11_AUTH_MODE;
21307 +
21308 +typedef enum {
21309 + NONE_AUTH = 0x01,
21310 + WPA_AUTH = 0x02,
21311 + WPA_PSK_AUTH = 0x03,
21312 + WPA2_AUTH = 0x04,
21313 + WPA2_PSK_AUTH = 0x05,
21314 + WPA_AUTH_CCKM = 0x06,
21315 + WPA2_AUTH_CCKM = 0x07,
21316 +} AUTH_MODE;
21317 +
21318 +typedef enum {
21319 + NONE_CRYPT = 0x01,
21320 + WEP_CRYPT = 0x02,
21321 + TKIP_CRYPT = 0x03,
21322 + AES_CRYPT = 0x04,
21323 +} CRYPTO_TYPE;
21324 +
21325 +#define WMI_MIN_CRYPTO_TYPE NONE_CRYPT
21326 +#define WMI_MAX_CRYPTO_TYPE (AES_CRYPT + 1)
21327 +
21328 +#define WMI_MIN_KEY_INDEX 0
21329 +#define WMI_MAX_KEY_INDEX 3
21330 +
21331 +#define WMI_MAX_KEY_LEN 32
21332 +
21333 +#define WMI_MAX_SSID_LEN 32
21334 +
21335 +typedef enum {
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;
21343 +
21344 +#define DEFAULT_CONNECT_CTRL_FLAGS (CONNECT_CSA_FOLLOW_BSS)
21345 +
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;
21360 +
21361 +/*
21362 + * WMI_RECONNECT_CMDID
21363 + */
21364 +typedef PREPACK struct {
21365 + A_UINT16 channel; /* hint */
21366 + A_UINT8 bssid[ATH_MAC_LEN]; /* mandatory if set */
21367 +} POSTPACK WMI_RECONNECT_CMD;
21368 +
21369 +/*
21370 + * WMI_ADD_CIPHER_KEY_CMDID
21371 + */
21372 +typedef enum {
21373 + PAIRWISE_USAGE = 0x00,
21374 + GROUP_USAGE = 0x01,
21375 + TX_USAGE = 0x02, /* default Tx Key - Static WEP only */
21376 +} KEY_USAGE;
21377 +
21378 +/*
21379 + * Bit Flag
21380 + * Bit 0 - Initialise TSC - default is Initialize
21381 + */
21382 +#define KEY_OP_INIT_TSC 0x01
21383 +#define KEY_OP_INIT_RSC 0x02
21384 +
21385 +#define KEY_OP_INIT_VAL 0x03 /* Default Initialise the TSC & RSC */
21386 +#define KEY_OP_VALID_MASK 0x03
21387 +
21388 +typedef PREPACK struct {
21389 + A_UINT8 keyIndex;
21390 + A_UINT8 keyType;
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;
21397 +
21398 +/*
21399 + * WMI_DELETE_CIPHER_KEY_CMDID
21400 + */
21401 +typedef PREPACK struct {
21402 + A_UINT8 keyIndex;
21403 +} POSTPACK WMI_DELETE_CIPHER_KEY_CMD;
21404 +
21405 +#define WMI_KRK_LEN 16
21406 +/*
21407 + * WMI_ADD_KRK_CMDID
21408 + */
21409 +typedef PREPACK struct {
21410 + A_UINT8 krk[WMI_KRK_LEN];
21411 +} POSTPACK WMI_ADD_KRK_CMD;
21412 +
21413 +/*
21414 + * WMI_SET_TKIP_COUNTERMEASURES_CMDID
21415 + */
21416 +typedef enum {
21417 + WMI_TKIP_CM_DISABLE = 0x0,
21418 + WMI_TKIP_CM_ENABLE = 0x1,
21419 +} WMI_TKIP_CM_CONTROL;
21420 +
21421 +typedef PREPACK struct {
21422 + A_UINT8 cm_en; /* WMI_TKIP_CM_CONTROL */
21423 +} POSTPACK WMI_SET_TKIP_COUNTERMEASURES_CMD;
21424 +
21425 +/*
21426 + * WMI_SET_PMKID_CMDID
21427 + */
21428 +
21429 +#define WMI_PMKID_LEN 16
21430 +
21431 +typedef enum {
21432 + PMKID_DISABLE = 0,
21433 + PMKID_ENABLE = 1,
21434 +} PMKID_ENABLE_FLG;
21435 +
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;
21441 +
21442 +/*
21443 + * WMI_START_SCAN_CMD
21444 + */
21445 +typedef enum {
21446 + WMI_LONG_SCAN = 0,
21447 + WMI_SHORT_SCAN = 1,
21448 +} WMI_SCAN_TYPE;
21449 +
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;
21457 +
21458 +/*
21459 + * WMI_SET_SCAN_PARAMS_CMDID
21460 + */
21461 +#define WMI_SHORTSCANRATIO_DEFAULT 3
21462 +typedef enum {
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 */
21472 +
21473 +} WMI_SCAN_CTRL_FLAGS_BITS;
21474 +
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)
21482 +
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)
21484 +
21485 +
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;
21497 +
21498 +/*
21499 + * WMI_SET_BSS_FILTER_CMDID
21500 + */
21501 +typedef enum {
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 */
21510 +} WMI_BSS_FILTER;
21511 +
21512 +typedef PREPACK struct {
21513 + A_UINT8 bssFilter; /* see WMI_BSS_FILTER */
21514 + A_UINT32 ieMask;
21515 +} POSTPACK WMI_BSS_FILTER_CMD;
21516 +
21517 +/*
21518 + * WMI_SET_PROBED_SSID_CMDID
21519 + */
21520 +#define MAX_PROBED_SSID_INDEX 5
21521 +
21522 +typedef enum {
21523 + DISABLE_SSID_FLAG = 0, /* disables entry */
21524 + SPECIFIC_SSID_FLAG = 0x01, /* probes specified ssid */
21525 + ANY_SSID_FLAG = 0x02, /* probes for any ssid */
21526 +} WMI_SSID_FLAG;
21527 +
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;
21534 +
21535 +/*
21536 + * WMI_SET_LISTEN_INT_CMDID
21537 + * The Listen interval is between 15 and 3000 TUs
21538 + */
21539 +#define MIN_LISTEN_INTERVAL 15
21540 +#define MAX_LISTEN_INTERVAL 5000
21541 +#define MIN_LISTEN_BEACONS 1
21542 +#define MAX_LISTEN_BEACONS 50
21543 +
21544 +typedef PREPACK struct {
21545 + A_UINT16 listenInterval;
21546 + A_UINT16 numBeacons;
21547 +} POSTPACK WMI_LISTEN_INT_CMD;
21548 +
21549 +/*
21550 + * WMI_SET_BEACON_INT_CMDID
21551 + */
21552 +typedef PREPACK struct {
21553 + A_UINT16 beaconInterval;
21554 +} POSTPACK WMI_BEACON_INT_CMD;
21555 +
21556 +/*
21557 + * WMI_SET_BMISS_TIME_CMDID
21558 + * valid values are between 1000 and 5000 TUs
21559 + */
21560 +
21561 +#define MIN_BMISS_TIME 1000
21562 +#define MAX_BMISS_TIME 5000
21563 +#define MIN_BMISS_BEACONS 1
21564 +#define MAX_BMISS_BEACONS 50
21565 +
21566 +typedef PREPACK struct {
21567 + A_UINT16 bmissTime;
21568 + A_UINT16 numBeacons;
21569 +} POSTPACK WMI_BMISS_TIME_CMD;
21570 +
21571 +/*
21572 + * WMI_SET_POWER_MODE_CMDID
21573 + */
21574 +typedef enum {
21575 + REC_POWER = 0x01,
21576 + MAX_PERF_POWER,
21577 +} WMI_POWER_MODE;
21578 +
21579 +typedef PREPACK struct {
21580 + A_UINT8 powerMode; /* WMI_POWER_MODE */
21581 +} POSTPACK WMI_POWER_MODE_CMD;
21582 +
21583 +/*
21584 + * WMI_SET_POWER_PARAMS_CMDID
21585 + */
21586 +typedef enum {
21587 + IGNORE_DTIM = 0x01,
21588 + NORMAL_DTIM = 0x02,
21589 + STICK_DTIM = 0x03,
21590 +} WMI_DTIM_POLICY;
21591 +
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;
21597 +
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;
21604 +
21605 +/*
21606 + * WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID
21607 + */
21608 +typedef enum {
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;
21614 +
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;
21621 +
21622 +/*
21623 + * WMI_SET_VOICE_PKT_SIZE_CMDID
21624 + */
21625 +typedef PREPACK struct {
21626 + A_UINT16 voicePktSize;
21627 +} POSTPACK WMI_SET_VOICE_PKT_SIZE_CMD;
21628 +
21629 +/*
21630 + * WMI_SET_MAX_SP_LEN_CMDID
21631 + */
21632 +typedef enum {
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;
21638 +
21639 +typedef PREPACK struct {
21640 + A_UINT8 maxSPLen;
21641 +} POSTPACK WMI_SET_MAX_SP_LEN_CMD;
21642 +
21643 +/*
21644 + * WMI_SET_DISC_TIMEOUT_CMDID
21645 + */
21646 +typedef PREPACK struct {
21647 + A_UINT8 disconnectTimeout; /* seconds */
21648 +} POSTPACK WMI_DISC_TIMEOUT_CMD;
21649 +
21650 +typedef enum {
21651 + UPLINK_TRAFFIC = 0,
21652 + DNLINK_TRAFFIC = 1,
21653 + BIDIR_TRAFFIC = 2,
21654 +} DIR_TYPE;
21655 +
21656 +typedef enum {
21657 + DISABLE_FOR_THIS_AC = 0,
21658 + ENABLE_FOR_THIS_AC = 1,
21659 + ENABLE_FOR_ALL_AC = 2,
21660 +} VOICEPS_CAP_TYPE;
21661 +
21662 +typedef enum {
21663 + TRAFFIC_TYPE_APERIODIC = 0,
21664 + TRAFFIC_TYPE_PERIODIC = 1,
21665 +}TRAFFIC_TYPE;
21666 +
21667 +/*
21668 + * WMI_CREATE_PSTREAM_CMDID
21669 + */
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 */
21682 + A_UINT32 sba;
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 */
21690 + A_UINT8 tsid;
21691 + A_UINT8 userPriority; /* 802.1D user priority */
21692 +} POSTPACK WMI_CREATE_PSTREAM_CMD;
21693 +
21694 +/*
21695 + * WMI_DELETE_PSTREAM_CMDID
21696 + */
21697 +typedef PREPACK struct {
21698 + A_UINT8 trafficClass;
21699 + A_UINT8 tsid;
21700 +} POSTPACK WMI_DELETE_PSTREAM_CMD;
21701 +
21702 +/*
21703 + * WMI_SET_CHANNEL_PARAMS_CMDID
21704 + */
21705 +typedef enum {
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,
21711 +} WMI_PHY_MODE;
21712 +
21713 +#define WMI_MAX_CHANNELS 32
21714 +
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;
21722 +
21723 +
21724 +/*
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)
21730 + */
21731 +
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;
21749 +
21750 +/*
21751 + * WMI_SNR_THRESHOLD_PARAMS_CMDID
21752 + * Setting the polltime to 0 would disable polling.
21753 + */
21754 +
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;
21768 +
21769 +/*
21770 + * WMI_LQ_THRESHOLD_PARAMS_CMDID
21771 + */
21772 +typedef PREPACK struct WMI_LQ_THRESHOLD_PARAMS {
21773 + A_UINT8 enable;
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;
21784 +
21785 +typedef enum {
21786 + WMI_LPREAMBLE_DISABLED = 0,
21787 + WMI_LPREAMBLE_ENABLED
21788 +} WMI_LPREAMBLE_STATUS;
21789 +
21790 +typedef PREPACK struct {
21791 + A_UINT8 status;
21792 +}POSTPACK WMI_SET_LPREAMBLE_CMD;
21793 +
21794 +typedef PREPACK struct {
21795 + A_UINT16 threshold;
21796 +}POSTPACK WMI_SET_RTS_CMD;
21797 +
21798 +/*
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.
21803 + */
21804 +typedef PREPACK struct {
21805 + A_UINT32 bitmask;
21806 +} POSTPACK WMI_TARGET_ERROR_REPORT_BITMASK;
21807 +
21808 +/*
21809 + * WMI_SET_TX_PWR_CMDID
21810 + */
21811 +typedef PREPACK struct {
21812 + A_UINT8 dbM; /* in dbM units */
21813 +} POSTPACK WMI_SET_TX_PWR_CMD, WMI_TX_PWR_REPLY;
21814 +
21815 +/*
21816 + * WMI_SET_ASSOC_INFO_CMDID
21817 + *
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.
21820 + */
21821 +#define WMI_MAX_ASSOC_INFO_TYPE 2
21822 +#define WMI_CCX_VER_IE 2 /* ieType to set CCX Version IE */
21823 +
21824 +#define WMI_MAX_ASSOC_INFO_LEN 240
21825 +
21826 +typedef PREPACK struct {
21827 + A_UINT8 ieType;
21828 + A_UINT8 bufferSize;
21829 + A_UINT8 assocInfo[1]; /* up to WMI_MAX_ASSOC_INFO_LEN */
21830 +} POSTPACK WMI_SET_ASSOC_INFO_CMD;
21831 +
21832 +
21833 +/*
21834 + * WMI_GET_TX_PWR_CMDID does not take any parameters
21835 + */
21836 +
21837 +/*
21838 + * WMI_ADD_BAD_AP_CMDID
21839 + */
21840 +#define WMI_MAX_BAD_AP_INDEX 1
21841 +
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;
21846 +
21847 +/*
21848 + * WMI_DELETE_BAD_AP_CMDID
21849 + */
21850 +typedef PREPACK struct {
21851 + A_UINT8 badApIndex; /* 0 to WMI_MAX_BAD_AP_INDEX */
21852 +} POSTPACK WMI_DELETE_BAD_AP_CMD;
21853 +
21854 +/*
21855 + * WMI_SET_ACCESS_PARAMS_CMDID
21856 + */
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 */
21865 + A_UINT8 eCWmin;
21866 + A_UINT8 eCWmax;
21867 + A_UINT8 aifsn;
21868 +} POSTPACK WMI_SET_ACCESS_PARAMS_CMD;
21869 +
21870 +
21871 +/*
21872 + * WMI_SET_RETRY_LIMITS_CMDID
21873 + *
21874 + * This command is used to customize the number of retries the
21875 + * wlan device will perform on a given frame.
21876 + */
21877 +#define WMI_MIN_RETRIES 2
21878 +#define WMI_MAX_RETRIES 13
21879 +typedef enum {
21880 + MGMT_FRAMETYPE = 0,
21881 + CONTROL_FRAMETYPE = 1,
21882 + DATA_FRAMETYPE = 2
21883 +} WMI_FRAMETYPE;
21884 +
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;
21891 +
21892 +/*
21893 + * WMI_SET_ROAM_CTRL_CMDID
21894 + *
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
21897 + * based.
21898 + */
21899 +
21900 +/*
21901 + * Different types of Roam Control
21902 + */
21903 +
21904 +typedef enum {
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;
21910 +
21911 +#define WMI_MIN_ROAM_CTRL_TYPE WMI_FORCE_ROAM
21912 +#define WMI_MAX_ROAM_CTRL_TYPE WMI_SET_LOWRSSI_SCAN_PARAMS
21913 +
21914 +/*
21915 + * ROAM MODES
21916 + */
21917 +
21918 +typedef enum {
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 */
21922 +} WMI_ROAM_MODE;
21923 +
21924 +/*
21925 + * BSS HOST BIAS INFO
21926 + */
21927 +
21928 +typedef PREPACK struct {
21929 + A_UINT8 bssid[ATH_MAC_LEN];
21930 + A_INT8 bias;
21931 +} POSTPACK WMI_BSS_BIAS;
21932 +
21933 +typedef PREPACK struct {
21934 + A_UINT8 numBss;
21935 + WMI_BSS_BIAS bssBias[1];
21936 +} POSTPACK WMI_BSS_BIAS_INFO;
21937 +
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;
21945 +
21946 +typedef PREPACK struct {
21947 + PREPACK union {
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;
21952 + } POSTPACK info;
21953 + A_UINT8 roamCtrlType ;
21954 +} POSTPACK WMI_SET_ROAM_CTRL_CMD;
21955 +
21956 +/*
21957 + * WMI_ENABLE_RM_CMDID
21958 + */
21959 +typedef PREPACK struct {
21960 + A_BOOL enable_radio_measurements;
21961 +} POSTPACK WMI_ENABLE_RM_CMD;
21962 +
21963 +/*
21964 + * WMI_SET_MAX_OFFHOME_DURATION_CMDID
21965 + */
21966 +typedef PREPACK struct {
21967 + A_UINT8 max_offhome_duration;
21968 +} POSTPACK WMI_SET_MAX_OFFHOME_DURATION_CMD;
21969 +
21970 +typedef PREPACK struct {
21971 + A_UINT32 frequency;
21972 + A_UINT8 threshold;
21973 +} POSTPACK WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD;
21974 +
21975 +typedef enum {
21976 + BT_STREAM_UNDEF = 0,
21977 + BT_STREAM_SCO, /* SCO stream */
21978 + BT_STREAM_A2DP, /* A2DP stream */
21979 + BT_STREAM_MAX
21980 +} BT_STREAM_TYPE;
21981 +
21982 +typedef enum {
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 */
21987 + BT_PARAM_MAX
21988 +} BT_PARAM_TYPE;
21989 +
21990 +typedef enum {
21991 + BT_STATUS_UNDEF = 0,
21992 + BT_STATUS_START,
21993 + BT_STATUS_STOP,
21994 + BT_STATUS_RESUME,
21995 + BT_STATUS_SUSPEND,
21996 + BT_STATUS_MAX
21997 +} BT_STREAM_STATUS;
21998 +
21999 +typedef PREPACK struct {
22000 + A_UINT8 streamType;
22001 + A_UINT8 status;
22002 +} POSTPACK WMI_SET_BT_STATUS_CMD;
22003 +
22004 +typedef PREPACK struct {
22005 + A_UINT8 noSCOPkts;
22006 + A_UINT8 pspollTimeout;
22007 + A_UINT8 stompbt;
22008 +} POSTPACK BT_PARAMS_SCO;
22009 +
22010 +typedef PREPACK struct {
22011 + A_UINT32 period;
22012 + A_UINT32 dutycycle;
22013 + A_UINT8 stompbt;
22014 +} POSTPACK BT_PARAMS_A2DP;
22015 +
22016 +typedef PREPACK struct {
22017 + A_UINT32 mode;
22018 + A_UINT32 scoWghts;
22019 + A_UINT32 a2dpWghts;
22020 + A_UINT32 genWghts;
22021 + A_UINT32 mode2;
22022 + A_UINT8 setVal;
22023 +} POSTPACK BT_COEX_REGS;
22024 +
22025 +typedef enum {
22026 + WLAN_PROTECT_POLICY = 1,
22027 + WLAN_COEX_CTRL_FLAGS
22028 +} BT_PARAMS_MISC_TYPE;
22029 +
22030 +typedef enum {
22031 + WLAN_PROTECT_PER_STREAM = 0x01, /* default */
22032 + WLAN_PROTECT_ANY_TX = 0x02
22033 +} WLAN_PROTECT_FLAGS;
22034 +
22035 +
22036 +#define WLAN_DISABLE_COEX_IN_DISCONNECT 0x01 /* default */
22037 +#define WLAN_KEEP_COEX_IN_DISCONNECT 0x02
22038 +#define WLAN_STOMPBT_IN_DISCONNECT 0x04
22039 +
22040 +#define WLAN_DISABLE_COEX_IN_ROAM 0x10 /* default */
22041 +#define WLAN_KEEP_COEX_IN_ROAM 0x20
22042 +#define WLAN_STOMPBT_IN_ROAM 0x40
22043 +
22044 +#define WLAN_DISABLE_COEX_IN_SCAN 0x100 /* default */
22045 +#define WLAN_KEEP_COEX_IN_SCAN 0x200
22046 +#define WLAN_STOMPBT_IN_SCAN 0x400
22047 +
22048 +#define WLAN_DISABLE_COEX_BT_OFF 0x1000 /* default */
22049 +#define WLAN_KEEP_COEX_BT_OFF 0x2000
22050 +#define WLAN_STOMPBT_BT_OFF 0x4000
22051 +
22052 +typedef PREPACK struct {
22053 + A_UINT32 period;
22054 + A_UINT32 dutycycle;
22055 + A_UINT8 stompbt;
22056 + A_UINT8 policy;
22057 +} POSTPACK WLAN_PROTECT_POLICY_TYPE;
22058 +
22059 +typedef PREPACK struct {
22060 + PREPACK union {
22061 + WLAN_PROTECT_POLICY_TYPE protectParams;
22062 + A_UINT16 wlanCtrlFlags;
22063 + } POSTPACK info;
22064 + A_UINT8 paramType;
22065 +} POSTPACK BT_PARAMS_MISC;
22066 +
22067 +typedef PREPACK struct {
22068 + PREPACK union {
22069 + BT_PARAMS_SCO scoParams;
22070 + BT_PARAMS_A2DP a2dpParams;
22071 + BT_PARAMS_MISC miscParams;
22072 + BT_COEX_REGS regs;
22073 + } POSTPACK info;
22074 + A_UINT8 paramType;
22075 +} POSTPACK WMI_SET_BT_PARAMS_CMD;
22076 +
22077 +/*
22078 + * Command Replies
22079 + */
22080 +
22081 +/*
22082 + * WMI_GET_CHANNEL_LIST_CMDID reply
22083 + */
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;
22089 +
22090 +typedef enum {
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;
22098 +
22099 +/*
22100 + * List of Events (target to host)
22101 + */
22102 +typedef enum {
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,
22119 + WMI_CAC_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
22128 +} WMI_EVENT_ID;
22129 +
22130 +typedef enum {
22131 + WMI_11A_CAPABILITY = 1,
22132 + WMI_11G_CAPABILITY = 2,
22133 + WMI_11AG_CAPABILITY = 3,
22134 +} WMI_PHY_CAPABILITY;
22135 +
22136 +typedef PREPACK struct {
22137 + A_UINT8 macaddr[ATH_MAC_LEN];
22138 + A_UINT8 phyCapability; /* WMI_PHY_CAPABILITY */
22139 +} POSTPACK WMI_READY_EVENT;
22140 +
22141 +/*
22142 + * Connect Event
22143 + */
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;
22155 +
22156 +/*
22157 + * Disconnect Event
22158 + */
22159 +typedef enum {
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;
22171 +
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;
22179 +
22180 +/*
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.
22185 + */
22186 +typedef enum {
22187 + BEACON_FTYPE = 0x1,
22188 + PROBERESP_FTYPE,
22189 + ACTION_MGMT_FTYPE,
22190 +} WMI_BI_FTYPE;
22191 +
22192 +enum {
22193 + BSS_ELEMID_CHANSWITCH = 0x01,
22194 + BSS_ELEMID_ATHEROS = 0x02,
22195 +};
22196 +
22197 +typedef PREPACK struct {
22198 + A_UINT16 channel;
22199 + A_UINT8 frameType; /* see WMI_BI_FTYPE */
22200 + A_UINT8 snr;
22201 + A_INT16 rssi;
22202 + A_UINT8 bssid[ATH_MAC_LEN];
22203 + A_UINT32 ieMask;
22204 +} POSTPACK WMI_BSS_INFO_HDR;
22205 +
22206 +/*
22207 + * Command Error Event
22208 + */
22209 +typedef enum {
22210 + INVALID_PARAM = 0x01,
22211 + ILLEGAL_STATE = 0x02,
22212 + INTERNAL_ERROR = 0x03,
22213 +} WMI_ERROR_CODE;
22214 +
22215 +typedef PREPACK struct {
22216 + A_UINT16 commandId;
22217 + A_UINT8 errorCode;
22218 +} POSTPACK WMI_CMD_ERROR_EVENT;
22219 +
22220 +/*
22221 + * New Regulatory Domain Event
22222 + */
22223 +typedef PREPACK struct {
22224 + A_UINT32 regDomain;
22225 +} POSTPACK WMI_REG_DOMAIN_EVENT;
22226 +
22227 +typedef PREPACK struct {
22228 + A_UINT8 trafficClass;
22229 +} POSTPACK WMI_PSTREAM_TIMEOUT_EVENT;
22230 +
22231 +/*
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
22236 + * BSS.
22237 + * The bssid and bssFlags information repeats according to the number
22238 + * or APs reported.
22239 + */
22240 +typedef enum {
22241 + WMI_DEFAULT_BSS_FLAGS = 0x00,
22242 + WMI_PREAUTH_CAPABLE_BSS = 0x01,
22243 + WMI_PMKID_VALID_BSS = 0x02,
22244 +} WMI_BSS_FLAGS;
22245 +
22246 +typedef PREPACK struct {
22247 + A_UINT8 bssid[ATH_MAC_LEN];
22248 + A_UINT8 bssFlags; /* see WMI_BSS_FLAGS */
22249 +} POSTPACK WMI_NEIGHBOR_INFO;
22250 +
22251 +typedef PREPACK struct {
22252 + A_INT8 numberOfAps;
22253 + WMI_NEIGHBOR_INFO neighbor[1];
22254 +} POSTPACK WMI_NEIGHBOR_REPORT_EVENT;
22255 +
22256 +/*
22257 + * TKIP MIC Error Event
22258 + */
22259 +typedef PREPACK struct {
22260 + A_UINT8 keyid;
22261 + A_UINT8 ismcast;
22262 +} POSTPACK WMI_TKIP_MICERR_EVENT;
22263 +
22264 +/*
22265 + * WMI_SCAN_COMPLETE_EVENTID - no parameters (old), staus parameter (new)
22266 + */
22267 +typedef PREPACK struct {
22268 + A_STATUS status;
22269 +} POSTPACK WMI_SCAN_COMPLETE_EVENT;
22270 +
22271 +#define MAX_OPT_DATA_LEN 1400
22272 +
22273 +/*
22274 + * WMI_SET_ADHOC_BSSID_CMDID
22275 + */
22276 +typedef PREPACK struct {
22277 + A_UINT8 bssid[ATH_MAC_LEN];
22278 +} POSTPACK WMI_SET_ADHOC_BSSID_CMD;
22279 +
22280 +/*
22281 + * WMI_SET_OPT_MODE_CMDID
22282 + */
22283 +typedef enum {
22284 + SPECIAL_OFF,
22285 + SPECIAL_ON,
22286 +} OPT_MODE_TYPE;
22287 +
22288 +typedef PREPACK struct {
22289 + A_UINT8 optMode;
22290 +} POSTPACK WMI_SET_OPT_MODE_CMD;
22291 +
22292 +/*
22293 + * WMI_TX_OPT_FRAME_CMDID
22294 + */
22295 +typedef enum {
22296 + OPT_PROBE_REQ = 0x01,
22297 + OPT_PROBE_RESP = 0x02,
22298 + OPT_CPPP_START = 0x03,
22299 + OPT_CPPP_STOP = 0x04,
22300 +} WMI_OPT_FTYPE;
22301 +
22302 +typedef PREPACK struct {
22303 + A_UINT16 optIEDataLen;
22304 + A_UINT8 frmType;
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;
22310 +
22311 +/*
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.
22316 + */
22317 +typedef PREPACK struct {
22318 + A_UINT16 channel;
22319 + A_UINT8 frameType; /* see WMI_OPT_FTYPE */
22320 + A_INT8 snr;
22321 + A_UINT8 srcAddr[ATH_MAC_LEN];
22322 + A_UINT8 bssid[ATH_MAC_LEN];
22323 +} POSTPACK WMI_OPT_RX_INFO_HDR;
22324 +
22325 +/*
22326 + * Reporting statistics.
22327 + */
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];
22340 +
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;
22347 +
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;
22358 +
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;
22366 +
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;
22375 +
22376 +typedef PREPACK struct {
22377 + A_UINT32 power_save_failure_cnt;
22378 +}POSTPACK pm_stats_t;
22379 +
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;
22388 + A_UINT8 cs_snr;
22389 + A_UINT8 cs_aveBeacon_snr;
22390 + A_UINT8 cs_lastRoam_msec;
22391 +} POSTPACK cserv_stats_t;
22392 +
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;
22398 +
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;
22405 +
22406 +typedef PREPACK struct {
22407 + A_UINT32 lqVal;
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;
22414 +
22415 +/*
22416 + * WMI_RSSI_THRESHOLD_EVENTID.
22417 + * Indicate the RSSI events to host. Events are indicated when we breach a
22418 + * thresold value.
22419 + */
22420 +typedef enum{
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;
22434 +
22435 +typedef PREPACK struct {
22436 + A_INT16 rssi;
22437 + A_UINT8 range;
22438 +}POSTPACK WMI_RSSI_THRESHOLD_EVENT;
22439 +
22440 +/*
22441 + * WMI_ERROR_REPORT_EVENTID
22442 + */
22443 +typedef enum{
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;
22452 +
22453 +typedef PREPACK struct {
22454 + A_UINT32 errorVal;
22455 +}POSTPACK WMI_TARGET_ERROR_REPORT_EVENT;
22456 +
22457 +typedef PREPACK struct {
22458 + A_UINT8 retrys;
22459 +}POSTPACK WMI_TX_RETRY_ERR_EVENT;
22460 +
22461 +typedef enum{
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;
22471 +
22472 +typedef PREPACK struct {
22473 + A_UINT8 range; /* WMI_SNR_THRESHOLD_VAL */
22474 + A_UINT8 snr;
22475 +}POSTPACK WMI_SNR_THRESHOLD_EVENT;
22476 +
22477 +typedef enum{
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;
22487 +
22488 +typedef PREPACK struct {
22489 + A_INT32 lq;
22490 + A_UINT8 range; /* WMI_LQ_THRESHOLD_VAL */
22491 +}POSTPACK WMI_LQ_THRESHOLD_EVENT;
22492 +/*
22493 + * WMI_REPORT_ROAM_TBL_EVENTID
22494 + */
22495 +#define MAX_ROAM_TBL_CAND 5
22496 +
22497 +typedef PREPACK struct {
22498 + A_INT32 roam_util;
22499 + A_UINT8 bssid[ATH_MAC_LEN];
22500 + A_INT8 rssi;
22501 + A_INT8 rssidt;
22502 + A_INT8 last_rssi;
22503 + A_INT8 util;
22504 + A_INT8 bias;
22505 + A_UINT8 reserved; /* For alignment */
22506 +} POSTPACK WMI_BSS_ROAM_INFO;
22507 +
22508 +
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;
22514 +
22515 +/*
22516 + * WMI_CAC_EVENTID
22517 + */
22518 +typedef enum {
22519 + CAC_INDICATION_ADMISSION = 0x00,
22520 + CAC_INDICATION_ADMISSION_RESP = 0x01,
22521 + CAC_INDICATION_DELETE = 0x02,
22522 + CAC_INDICATION_NO_RESP = 0x03,
22523 +}CAC_INDICATION;
22524 +
22525 +#define WMM_TSPEC_IE_LEN 63
22526 +
22527 +typedef PREPACK struct {
22528 + A_UINT8 ac;
22529 + A_UINT8 cac_indication;
22530 + A_UINT8 statusCode;
22531 + A_UINT8 tspecSuggestion[WMM_TSPEC_IE_LEN];
22532 +}POSTPACK WMI_CAC_EVENT;
22533 +
22534 +/*
22535 + * WMI_APLIST_EVENTID
22536 + */
22537 +
22538 +typedef enum {
22539 + APLIST_VER1 = 1,
22540 +} APLIST_VER;
22541 +
22542 +typedef PREPACK struct {
22543 + A_UINT8 bssid[ATH_MAC_LEN];
22544 + A_UINT16 channel;
22545 +} POSTPACK WMI_AP_INFO_V1;
22546 +
22547 +typedef PREPACK union {
22548 + WMI_AP_INFO_V1 apInfoV1;
22549 +} POSTPACK WMI_AP_INFO;
22550 +
22551 +typedef PREPACK struct {
22552 + A_UINT8 apListVer;
22553 + A_UINT8 numAP;
22554 + WMI_AP_INFO apList[1];
22555 +} POSTPACK WMI_APLIST_EVENT;
22556 +
22557 +/*
22558 + * developer commands
22559 + */
22560 +
22561 +/*
22562 + * WMI_SET_BITRATE_CMDID
22563 + *
22564 + * Get bit rate cmd uses same definition as set bit rate cmd
22565 + */
22566 +typedef enum {
22567 + RATE_AUTO = -1,
22568 + RATE_1Mb = 0,
22569 + RATE_2Mb = 1,
22570 + RATE_5_5Mb = 2,
22571 + RATE_11Mb = 3,
22572 + RATE_6Mb = 4,
22573 + RATE_9Mb = 5,
22574 + RATE_12Mb = 6,
22575 + RATE_18Mb = 7,
22576 + RATE_24Mb = 8,
22577 + RATE_36Mb = 9,
22578 + RATE_48Mb = 10,
22579 + RATE_54Mb = 11,
22580 +} WMI_BIT_RATE;
22581 +
22582 +typedef PREPACK struct {
22583 + A_INT8 rateIndex; /* see WMI_BIT_RATE */
22584 +} POSTPACK WMI_BIT_RATE_CMD, WMI_BIT_RATE_REPLY;
22585 +
22586 +/*
22587 + * WMI_SET_FIXRATES_CMDID
22588 + *
22589 + * Get fix rates cmd uses same definition as set fix rates cmd
22590 + */
22591 +typedef enum {
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;
22605 +
22606 +typedef PREPACK struct {
22607 + A_UINT16 fixRateMask; /* see WMI_BIT_RATE */
22608 +} POSTPACK WMI_FIX_RATES_CMD, WMI_FIX_RATES_REPLY;
22609 +
22610 +/*
22611 + * WMI_SET_RECONNECT_AUTH_MODE_CMDID
22612 + *
22613 + * Set authentication mode
22614 + */
22615 +typedef enum {
22616 + RECONN_DO_AUTH = 0x00,
22617 + RECONN_NOT_AUTH = 0x01
22618 +} WMI_AUTH_MODE;
22619 +
22620 +typedef PREPACK struct {
22621 + A_UINT8 mode;
22622 +} POSTPACK WMI_SET_AUTH_MODE_CMD;
22623 +
22624 +/*
22625 + * WMI_SET_REASSOC_MODE_CMDID
22626 + *
22627 + * Set authentication mode
22628 + */
22629 +typedef enum {
22630 + REASSOC_DO_DISASSOC = 0x00,
22631 + REASSOC_DONOT_DISASSOC = 0x01
22632 +} WMI_REASSOC_MODE;
22633 +
22634 +typedef PREPACK struct {
22635 + A_UINT8 mode;
22636 +}POSTPACK WMI_SET_REASSOC_MODE_CMD;
22637 +
22638 +typedef enum {
22639 + ROAM_DATA_TIME = 1, /* Get The Roam Time Data */
22640 +} ROAM_DATA_TYPE;
22641 +
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;
22654 +
22655 +typedef PREPACK struct {
22656 + PREPACK union {
22657 + WMI_TARGET_ROAM_TIME roamTime;
22658 + } POSTPACK u;
22659 + A_UINT8 roamDataType ;
22660 +} POSTPACK WMI_TARGET_ROAM_DATA;
22661 +
22662 +typedef enum {
22663 + WMI_WMM_DISABLED = 0,
22664 + WMI_WMM_ENABLED
22665 +} WMI_WMM_STATUS;
22666 +
22667 +typedef PREPACK struct {
22668 + A_UINT8 status;
22669 +}POSTPACK WMI_SET_WMM_CMD;
22670 +
22671 +typedef enum {
22672 + WMI_TXOP_DISABLED = 0,
22673 + WMI_TXOP_ENABLED
22674 +} WMI_TXOP_CFG;
22675 +
22676 +typedef PREPACK struct {
22677 + A_UINT8 txopEnable;
22678 +}POSTPACK WMI_SET_WMM_TXOP_CMD;
22679 +
22680 +typedef PREPACK struct {
22681 + A_UINT8 keepaliveInterval;
22682 +} POSTPACK WMI_SET_KEEPALIVE_CMD;
22683 +
22684 +typedef PREPACK struct {
22685 + A_BOOL configured;
22686 + A_UINT8 keepaliveInterval;
22687 +} POSTPACK WMI_GET_KEEPALIVE_CMD;
22688 +
22689 +/*
22690 + * Add Application specified IE to a management frame
22691 + */
22692 +#define WMI_MAX_IE_LEN 78
22693 +
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;
22699 +
22700 +/*
22701 + * Notify the WSC registration status to the target
22702 + */
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 */
22707 +typedef enum {
22708 + WHAL_SETCABTO_CMDID = 1,
22709 +}WHAL_CMDID;
22710 +
22711 +typedef PREPACK struct {
22712 + A_UINT8 cabTimeOut;
22713 +} POSTPACK WHAL_SETCABTO_PARAM;
22714 +
22715 +typedef PREPACK struct {
22716 + A_UINT8 whalCmdId;
22717 + A_UINT8 data[1];
22718 +} POSTPACK WHAL_PARAMCMD;
22719 +
22720 +
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
22725 +
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;
22734 +
22735 +
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;
22743 +
22744 +typedef PREPACK struct {
22745 + A_BOOL awake;
22746 + A_BOOL asleep;
22747 +} POSTPACK WMI_SET_HOST_SLEEP_MODE_CMD;
22748 +
22749 +typedef PREPACK struct {
22750 + A_BOOL enable_wow;
22751 +} POSTPACK WMI_SET_WOW_MODE_CMD;
22752 +
22753 +typedef PREPACK struct {
22754 + A_UINT8 filter_list_id;
22755 +} POSTPACK WMI_GET_WOW_LIST_CMD;
22756 +
22757 +/*
22758 + * WMI_GET_WOW_LIST_CMD reply
22759 + */
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;
22767 +
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;
22774 +
22775 +typedef PREPACK struct {
22776 + A_UINT16 filter_list_id;
22777 + A_UINT16 filter_id;
22778 +} POSTPACK WMI_DEL_WOW_PATTERN_CMD;
22779 +
22780 +typedef PREPACK struct {
22781 + A_UINT8 macaddr[ATH_MAC_LEN];
22782 +} POSTPACK WMI_SET_MAC_ADDRESS_CMD;
22783 +
22784 +/*
22785 + * WMI_SET_AKMP_PARAMS_CMD
22786 + */
22787 +
22788 +#define WMI_AKMP_MULTI_PMKID_EN 0x000001
22789 +
22790 +typedef PREPACK struct {
22791 + A_UINT32 akmpInfo;
22792 +} POSTPACK WMI_SET_AKMP_PARAMS_CMD;
22793 +
22794 +typedef PREPACK struct {
22795 + A_UINT8 pmkid[WMI_PMKID_LEN];
22796 +} POSTPACK WMI_PMKID;
22797 +
22798 +/*
22799 + * WMI_SET_PMKID_LIST_CMD
22800 + */
22801 +#define WMI_MAX_PMKID_CACHE 8
22802 +
22803 +typedef PREPACK struct {
22804 + A_UINT32 numPMKID;
22805 + WMI_PMKID pmkidList[WMI_MAX_PMKID_CACHE];
22806 +} POSTPACK WMI_SET_PMKID_LIST_CMD;
22807 +
22808 +/*
22809 + * WMI_GET_PMKID_LIST_CMD Reply
22810 + * Following the Number of PMKIDs is the list of PMKIDs
22811 + */
22812 +typedef PREPACK struct {
22813 + A_UINT32 numPMKID;
22814 + WMI_PMKID pmkidList[1];
22815 +} POSTPACK WMI_PMKID_LIST_REPLY;
22816 +
22817 +/* index used for priority streams */
22818 +typedef enum {
22819 + WMI_NOT_MAPPED = -1,
22820 + WMI_CONTROL_PRI = 0,
22821 + WMI_BEST_EFFORT_PRI = 1,
22822 + WMI_LOW_PRI = 2,
22823 + WMI_HIGH_PRI = 3,
22824 + WMI_HIGHEST_PRI,
22825 + WMI_PRI_MAX_COUNT
22826 +} WMI_PRI_STREAM_ID;
22827 +
22828 +#ifndef ATH_TARGET
22829 +#include "athendpack.h"
22830 +#endif
22831 +
22832 +#ifdef __cplusplus
22833 +}
22834 +#endif
22835 +
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
22840 --- /dev/null
22841 +++ b/drivers/sdio/function/wlan/ar6000/include/wmi_api.h
22842 @@ -0,0 +1,259 @@
22843 +#ifndef _WMI_API_H_
22844 +#define _WMI_API_H_
22845 +/*
22846 + * Copyright (c) 2004-2006 Atheros Communications Inc.
22847 + * All rights reserved.
22848 + *
22849 + * This file contains the definitions for the Wireless Module Interface (WMI).
22850 + *
22851 + * $Id: //depot/sw/releases/olca2.0-GPL/host/include/wmi_api.h#2 $
22852 + *
22853 + *
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;
22857 + *
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.
22862 + *
22863 + *
22864 + *
22865 + */
22866 +
22867 +#ifdef __cplusplus
22868 +extern "C" {
22869 +#endif
22870 +
22871 +/*
22872 + * IP QoS Field definitions according to 802.1p
22873 + */
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
22882 +
22883 +#define UNDEFINED_PRI (0xff)
22884 +
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
22888 + *
22889 + * */
22890 +#define IP_TOS_TO_WMI_PRI(tos) \
22891 + ((WMI_PRI_STREAM_ID)(((tos) >> 1) & 0x03))
22892 +
22893 +#define WMI_IMPLICIT_PSTREAM_INACTIVITY_INT 5000 /* 5 seconds */
22894 +
22895 +
22896 +struct wmi_t;
22897 +
22898 +void *wmi_init(void *devt);
22899 +
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);
22911 +
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);
22916 +
22917 +
22918 +typedef enum {
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 */
22924 +} WMI_SYNC_FLAG;
22925 +
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,
22936 + int ssidLength,
22937 + A_UCHAR *ssid,
22938 + A_UINT8 *bssid,
22939 + A_UINT16 channel,
22940 + A_UINT32 ctrl_flags);
22941 +A_STATUS wmi_reconnect_cmd(struct wmi_t *wmip,
22942 + A_UINT8 *bssid,
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);
22979 +
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);
22989 +
22990 +A_STATUS wmi_set_error_report_bitmask(struct wmi_t *wmip, A_UINT32 bitmask);
22991 +
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,
22996 + A_UINT32 valid);
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,
23017 + A_BOOL set);
23018 +A_STATUS wmi_set_access_params_cmd(struct wmi_t *wmip, A_UINT16 txop,
23019 + A_UINT8 eCWmin, A_UINT8 eCWmax,
23020 + A_UINT8 aifsn);
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);
23024 +
23025 +void wmi_get_current_bssid(struct wmi_t *wmip, A_UINT8 *bssid);
23026 +
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,
23030 + A_UINT8 size);
23031 +A_STATUS wmi_set_powersave_timers_cmd(struct wmi_t *wmip,
23032 + WMI_POWERSAVE_TIMERS_POLICY_CMD *pCmd,
23033 + A_UINT8 size);
23034 +
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,
23037 + A_UINT8 frmType,
23038 + A_UINT8 *dstMacAddr,
23039 + A_UINT8 *bssid,
23040 + A_UINT16 optIEDataLen,
23041 + A_UINT8 *optIEData);
23042 +
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);
23049 +
23050 +#ifdef CONFIG_HOST_TCMD_SUPPORT
23051 +A_STATUS wmi_test_cmd(struct wmi_t *wmip, A_UINT8 *buf, A_UINT32 len);
23052 +#endif
23053 +
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);
23056 +
23057 +
23058 +/*
23059 + * This function is used to configure the fix rates mask to the target.
23060 + */
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);
23063 +
23064 +A_STATUS wmi_set_authmode_cmd(struct wmi_t *wmip, A_UINT8 mode);
23065 +
23066 +A_STATUS wmi_set_reassocmode_cmd(struct wmi_t *wmip, A_UINT8 mode);
23067 +
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);
23070 +
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);
23074 +
23075 +A_STATUS wmi_set_appie_cmd(struct wmi_t *wmip, A_UINT8 mgmtFrmType,
23076 + A_UINT8 ieLen,A_UINT8 *ieInfo);
23077 +
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);
23080 +
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);
23090 +
23091 +bss_t *
23092 +wmi_find_Ssidnode (struct wmi_t *wmip, A_UCHAR *pSsid,
23093 + A_UINT32 ssidLength, A_BOOL bIsWPA2);
23094 +
23095 +void
23096 +wmi_node_return (struct wmi_t *wmip, bss_t *bss);
23097 +#ifdef __cplusplus
23098 +}
23099 +#endif
23100 +
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
23105 --- /dev/null
23106 +++ b/drivers/sdio/function/wlan/ar6000/include/wmix.h
23107 @@ -0,0 +1,233 @@
23108 +/*
23109 + * Copyright (c) 2004-2005 Atheros Communications Inc.
23110 + * All rights reserved.
23111 + *
23112 + *
23113 + * $ATH_LICENSE_HOSTSDK0_C$
23114 + *
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.
23121 + *
23122 + * Extended WMIX commands are encapsulated in a WMI message with
23123 + * cmd=WMI_EXTENSION_CMD.
23124 + *
23125 + */
23126 +
23127 +#ifndef _WMIX_H_
23128 +#define _WMIX_H_
23129 +
23130 +#ifdef __cplusplus
23131 +extern "C" {
23132 +#endif
23133 +
23134 +#ifndef ATH_TARGET
23135 +#include "athstartpack.h"
23136 +#endif
23137 +
23138 +#include "dbglog.h"
23139 +
23140 +/*
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.
23147 + */
23148 +typedef PREPACK struct {
23149 + A_UINT32 commandId;
23150 +} POSTPACK WMIX_CMD_HDR;
23151 +
23152 +typedef enum {
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;
23163 +
23164 +typedef enum {
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,
23173 +} WMIX_EVENT_ID;
23174 +
23175 +/*
23176 + * =============DataSet support=================
23177 + */
23178 +
23179 +/*
23180 + * WMIX_DSETOPENREQ_EVENTID
23181 + * DataSet Open Request Event
23182 + */
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;
23189 +
23190 +/*
23191 + * WMIX_DSETCLOSE_EVENTID
23192 + * DataSet Close Event
23193 + */
23194 +typedef PREPACK struct {
23195 + A_UINT32 access_cookie;
23196 +} POSTPACK WMIX_DSETCLOSE_EVENT;
23197 +
23198 +/*
23199 + * WMIX_DSETDATAREQ_EVENTID
23200 + * DataSet Data Request Event
23201 + */
23202 +typedef PREPACK struct {
23203 + A_UINT32 access_cookie;
23204 + A_UINT32 offset;
23205 + A_UINT32 length;
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;
23210 +
23211 +typedef PREPACK struct {
23212 + A_UINT32 status;
23213 + A_UINT32 targ_dset_handle;
23214 + A_UINT32 targ_reply_fn;
23215 + A_UINT32 targ_reply_arg;
23216 + A_UINT32 access_cookie;
23217 + A_UINT32 size;
23218 + A_UINT32 version;
23219 +} POSTPACK WMIX_DSETOPEN_REPLY_CMD;
23220 +
23221 +typedef PREPACK struct {
23222 + A_UINT32 status;
23223 + A_UINT32 targ_buf;
23224 + A_UINT32 targ_reply_fn;
23225 + A_UINT32 targ_reply_arg;
23226 + A_UINT32 length;
23227 + A_UINT8 buf[1];
23228 +} POSTPACK WMIX_DSETDATA_REPLY_CMD;
23229 +
23230 +
23231 +/*
23232 + * =============GPIO support=================
23233 + * All masks are 18-bit masks with bit N operating on GPIO pin N.
23234 + */
23235 +
23236 +#include "gpio.h"
23237 +
23238 +/*
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.
23243 + *
23244 + * If a request is made to simultaneously set/clear or set/disable or
23245 + * clear/disable or disable/enable, results are undefined.
23246 + */
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;
23253 +
23254 +/*
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.
23258 + */
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;
23263 +
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;
23268 +
23269 +/*
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.
23273 + */
23274 +typedef PREPACK struct {
23275 + A_UINT32 ack_mask; /* interrupts to acknowledge */
23276 +} POSTPACK WMIX_GPIO_INTR_ACK_CMD;
23277 +
23278 +/*
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.
23283 + */
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;
23288 +
23289 +/*
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
23294 + *
23295 + *
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.
23303 + */
23304 +typedef PREPACK struct {
23305 + A_UINT32 value;
23306 + A_UINT32 reg_id;
23307 +} POSTPACK WMIX_GPIO_DATA_EVENT;
23308 +
23309 +/*
23310 + * =============Error Detection support=================
23311 + */
23312 +
23313 +/*
23314 + * WMIX_HB_CHALLENGE_RESP_CMDID
23315 + * Heartbeat Challenge Response command
23316 + */
23317 +typedef PREPACK struct {
23318 + A_UINT32 cookie;
23319 + A_UINT32 source;
23320 +} POSTPACK WMIX_HB_CHALLENGE_RESP_CMD;
23321 +
23322 +/*
23323 + * WMIX_HB_CHALLENGE_RESP_EVENTID
23324 + * Heartbeat Challenge Response Event
23325 + */
23326 +#define WMIX_HB_CHALLENGE_RESP_EVENT WMIX_HB_CHALLENGE_RESP_CMD
23327 +
23328 +typedef PREPACK struct {
23329 + struct dbglog_config_s config;
23330 +} POSTPACK WMIX_DBGLOG_CFG_MODULE_CMD;
23331 +
23332 +#ifndef ATH_TARGET
23333 +#include "athendpack.h"
23334 +#endif
23335 +
23336 +#ifdef __cplusplus
23337 +}
23338 +#endif
23339 +
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
23344 --- /dev/null
23345 +++ b/drivers/sdio/function/wlan/ar6000/miscdrv/common_drv.c
23346 @@ -0,0 +1,467 @@
23347 +
23348 +/*
23349 + *
23350 + * Copyright (c) 2004-2007 Atheros Communications Inc.
23351 + * All rights reserved.
23352 + *
23353 + *
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;
23357 + *
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.
23362 + *
23363 + *
23364 + *
23365 + */
23366 +
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"
23373 +#include "hif.h"
23374 +#include "htc_api.h"
23375 +#include "bmi.h"
23376 +#include "bmi_msg.h"
23377 +#include "common_drv.h"
23378 +#include "a_debug.h"
23379 +#include "targaddrs.h"
23380 +
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))
23385 +
23386 +
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. */
23392 +
23393 +#ifdef USE_4BYTE_REGISTER_ACCESS
23394 +
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)
23397 +{
23398 + A_STATUS status;
23399 + A_UINT8 addrValue[4];
23400 + int i;
23401 +
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 */
23404 +
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];
23411 +
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,
23415 + RegisterAddr+i,
23416 + addrValue,
23417 + 4,
23418 + HIF_WR_SYNC_BYTE_FIX,
23419 + NULL);
23420 + if (status != A_OK) {
23421 + break;
23422 + }
23423 + }
23424 +
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));
23428 + return status;
23429 + }
23430 +
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,
23435 + RegisterAddr,
23436 + (A_UCHAR *)(&Address),
23437 + 4,
23438 + HIF_WR_SYNC_BYTE_INC,
23439 + NULL);
23440 +
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));
23444 + return status;
23445 + }
23446 +
23447 + return A_OK;
23448 +
23449 +
23450 +
23451 +}
23452 +
23453 +
23454 +#else
23455 +
23456 + /* set the window address register */
23457 +A_STATUS ar6000_SetAddressWindowRegister(HIF_DEVICE *hifDevice, A_UINT32 RegisterAddr, A_UINT32 Address)
23458 +{
23459 + A_STATUS status;
23460 +
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,
23468 + NULL);
23469 +
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));
23473 + return status;
23474 + }
23475 +
23476 + /* write the LSB of the register, this initiates the operation */
23477 + status = HIFReadWrite(hifDevice,
23478 + RegisterAddr,
23479 + (A_UCHAR *)(&Address),
23480 + sizeof(A_UINT8),
23481 + HIF_WR_SYNC_BYTE_INC,
23482 + NULL);
23483 +
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));
23487 + return status;
23488 + }
23489 +
23490 + return A_OK;
23491 +}
23492 +
23493 +#endif
23494 +
23495 +/*
23496 + * Read from the AR6000 through its diagnostic window.
23497 + * No cooperation from the Target is required for this.
23498 + */
23499 +A_STATUS
23500 +ar6000_ReadRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data)
23501 +{
23502 + A_STATUS status;
23503 +
23504 + /* set window register to start read cycle */
23505 + status = ar6000_SetAddressWindowRegister(hifDevice,
23506 + WINDOW_READ_ADDR_ADDRESS,
23507 + *address);
23508 +
23509 + if (status != A_OK) {
23510 + return status;
23511 + }
23512 +
23513 + /* read the data */
23514 + status = HIFReadWrite(hifDevice,
23515 + WINDOW_DATA_ADDRESS,
23516 + (A_UCHAR *)data,
23517 + sizeof(A_UINT32),
23518 + HIF_RD_SYNC_BYTE_INC,
23519 + NULL);
23520 + if (status != A_OK) {
23521 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot read from WINDOW_DATA_ADDRESS\n"));
23522 + return status;
23523 + }
23524 +
23525 + return status;
23526 +}
23527 +
23528 +
23529 +/*
23530 + * Write to the AR6000 through its diagnostic window.
23531 + * No cooperation from the Target is required for this.
23532 + */
23533 +A_STATUS
23534 +ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data)
23535 +{
23536 + A_STATUS status;
23537 +
23538 + /* set write data */
23539 + status = HIFReadWrite(hifDevice,
23540 + WINDOW_DATA_ADDRESS,
23541 + (A_UCHAR *)data,
23542 + sizeof(A_UINT32),
23543 + HIF_WR_SYNC_BYTE_INC,
23544 + NULL);
23545 + if (status != A_OK) {
23546 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot write 0x%x to WINDOW_DATA_ADDRESS\n", *data));
23547 + return status;
23548 + }
23549 +
23550 + /* set window register, which starts the write cycle */
23551 + return ar6000_SetAddressWindowRegister(hifDevice,
23552 + WINDOW_WRITE_ADDR_ADDRESS,
23553 + *address);
23554 +}
23555 +
23556 +A_STATUS
23557 +ar6000_ReadDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address,
23558 + A_UCHAR *data, A_UINT32 length)
23559 +{
23560 + A_UINT32 count;
23561 + A_STATUS status = A_OK;
23562 +
23563 + for (count = 0; count < length; count += 4, address += 4) {
23564 + if ((status = ar6000_ReadRegDiag(hifDevice, &address,
23565 + (A_UINT32 *)&data[count])) != A_OK)
23566 + {
23567 + break;
23568 + }
23569 + }
23570 +
23571 + return status;
23572 +}
23573 +
23574 +A_STATUS
23575 +ar6000_WriteDataDiag(HIF_DEVICE *hifDevice, A_UINT32 address,
23576 + A_UCHAR *data, A_UINT32 length)
23577 +{
23578 + A_UINT32 count;
23579 + A_STATUS status = A_OK;
23580 +
23581 + for (count = 0; count < length; count += 4, address += 4) {
23582 + if ((status = ar6000_WriteRegDiag(hifDevice, &address,
23583 + (A_UINT32 *)&data[count])) != A_OK)
23584 + {
23585 + break;
23586 + }
23587 + }
23588 +
23589 + return status;
23590 +}
23591 +
23592 +A_STATUS
23593 +ar6000_reset_device_skipflash(HIF_DEVICE *hifDevice)
23594 +{
23595 + int i;
23596 + struct forceROM_s {
23597 + A_UINT32 addr;
23598 + A_UINT32 data;
23599 + };
23600 + struct forceROM_s *ForceROM;
23601 + int szForceROM;
23602 + A_UINT32 instruction;
23603 +
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 */
23608 +
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 */
23613 +
23614 + {LOCAL_COUNT_ADDRESS+0x10, 0}, /* clear BMI credit counter */
23615 +
23616 + {RESET_CONTROL_ADDRESS, RESET_CONTROL_WARM_RST_MASK},
23617 + };
23618 +
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},
23624 + };
23625 +
23626 + /*
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.
23631 + */
23632 + (void)ar6000_ReadDataDiag(hifDevice, 0x01000040,
23633 + (A_UCHAR *)&instruction, 4);
23634 +
23635 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("instruction=0x%x\n", instruction));
23636 +
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"));
23642 + } else {
23643 + ForceROM = ForceROM_NEW;
23644 + szForceROM = sizeof(ForceROM_NEW)/sizeof(*ForceROM);
23645 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Using NEW method\n"));
23646 + }
23647 +
23648 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Force Target to execute from ROM....\n"));
23649 + for (i = 0; i < szForceROM; i++)
23650 + {
23651 + if (ar6000_WriteRegDiag(hifDevice,
23652 + &ForceROM[i].addr,
23653 + &ForceROM[i].data) != A_OK)
23654 + {
23655 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Cannot force Target to execute ROM!\n"));
23656 + return A_ERROR;
23657 + }
23658 + }
23659 +
23660 + A_MDELAY(50); /* delay to allow dragon to come to BMI phase */
23661 + return A_OK;
23662 +}
23663 +
23664 +/* reset device */
23665 +A_STATUS ar6000_reset_device(HIF_DEVICE *hifDevice, A_UINT32 TargetType)
23666 +{
23667 +
23668 +#if !defined(DWSIM)
23669 + A_STATUS status = A_OK;
23670 + A_UINT32 address;
23671 + A_UINT32 data;
23672 +
23673 + do {
23674 +
23675 + // address = RESET_CONTROL_ADDRESS;
23676 + data = RESET_CONTROL_COLD_RST_MASK;
23677 +
23678 + /* Hardcode the address of RESET_CONTROL_ADDRESS based on the target type */
23679 + if (TargetType == TARGET_TYPE_AR6001) {
23680 + address = 0x0C000000;
23681 + } else {
23682 + if (TargetType == TARGET_TYPE_AR6002) {
23683 + address = 0x00004000;
23684 + } else {
23685 + A_ASSERT(0);
23686 + }
23687 + }
23688 +
23689 + status = ar6000_WriteRegDiag(hifDevice, &address, &data);
23690 +
23691 + if (A_FAILED(status)) {
23692 + break;
23693 + }
23694 +
23695 + /*
23696 + * Read back the RESET CAUSE register to ensure that the cold reset
23697 + * went through.
23698 + */
23699 + A_MDELAY(2000); /* 2 second delay to allow things to settle down */
23700 +
23701 +
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;
23706 + } else {
23707 + if (TargetType == TARGET_TYPE_AR6002) {
23708 + address = 0x000040C0;
23709 + } else {
23710 + A_ASSERT(0);
23711 + }
23712 + }
23713 +
23714 + data = 0;
23715 + status = ar6000_ReadRegDiag(hifDevice, &address, &data);
23716 +
23717 + if (A_FAILED(status)) {
23718 + break;
23719 + }
23720 +
23721 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Reset Cause readback: 0x%X \n",data));
23722 + data &= RESET_CAUSE_LAST_MASK;
23723 + if (data != 2) {
23724 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Unable to cold reset the target \n"));
23725 + }
23726 +
23727 + } while (FALSE);
23728 +
23729 + if (A_FAILED(status)) {
23730 + AR_DEBUG_PRINTF(ATH_LOG_ERR, ("Failed to reset target \n"));
23731 + }
23732 +#endif
23733 + return A_OK;
23734 +}
23735 +
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 */
23738 +
23739 +
23740 +#if REG_DUMP_COUNT_AR6001 <= REG_DUMP_COUNT_AR6002
23741 +#define REGISTER_DUMP_LEN_MAX REG_DUMP_COUNT_AR6002
23742 +#else
23743 +#define REGISTER_DUMP_LEN_MAX REG_DUMP_COUNT_AR6001
23744 +#endif
23745 +
23746 +void ar6000_dump_target_assert_info(HIF_DEVICE *hifDevice, A_UINT32 TargetType)
23747 +{
23748 + A_UINT32 address;
23749 + A_UINT32 regDumpArea = 0;
23750 + A_STATUS status;
23751 + A_UINT32 regDumpValues[REGISTER_DUMP_LEN_MAX];
23752 + A_UINT32 regDumpCount = 0;
23753 + A_UINT32 i;
23754 +
23755 + do {
23756 +
23757 + /* the reg dump pointer is copied to the host interest area */
23758 + address = HOST_INTEREST_ITEM_ADDRESS(TargetType, hi_failure_state);
23759 +
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;
23765 +
23766 + } else if (TargetType == TARGET_TYPE_AR6002) {
23767 +
23768 + regDumpCount = REG_DUMP_COUNT_AR6002;
23769 +
23770 + } else {
23771 + A_ASSERT(0);
23772 + }
23773 +
23774 + /* read RAM location through diagnostic window */
23775 + status = ar6000_ReadRegDiag(hifDevice, &address, &regDumpArea);
23776 +
23777 + if (A_FAILED(status)) {
23778 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Failed to get ptr to register dump area \n"));
23779 + break;
23780 + }
23781 +
23782 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Location of register dump data: 0x%X \n",regDumpArea));
23783 +
23784 + if (regDumpArea == 0) {
23785 + /* no reg dump */
23786 + break;
23787 + }
23788 +
23789 + if (TargetType == TARGET_TYPE_AR6001) {
23790 + regDumpArea &= 0x0FFFFFFF; /* convert to physical address in target memory */
23791 + }
23792 +
23793 + /* fetch register dump data */
23794 + status = ar6000_ReadDataDiag(hifDevice,
23795 + regDumpArea,
23796 + (A_UCHAR *)&regDumpValues[0],
23797 + regDumpCount * (sizeof(A_UINT32)));
23798 +
23799 + if (A_FAILED(status)) {
23800 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Failed to get register dump \n"));
23801 + break;
23802 + }
23803 +
23804 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("AR6K: Register Dump: \n"));
23805 +
23806 + for (i = 0; i < regDumpCount; i++) {
23807 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" %d : 0x%8.8X \n",i, regDumpValues[i]));
23808 + }
23809 +
23810 + } while (FALSE);
23811 +
23812 +}
23813 +
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
23817 --- /dev/null
23818 +++ b/drivers/sdio/function/wlan/ar6000/miscdrv/credit_dist.c
23819 @@ -0,0 +1,346 @@
23820 +
23821 +/*
23822 + *
23823 + * Copyright (c) 2004-2007 Atheros Communications Inc.
23824 + * All rights reserved.
23825 + *
23826 + *
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;
23830 + *
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.
23835 + *
23836 + *
23837 + *
23838 + */
23839 +
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"
23847 +
23848 +/********* CREDIT DISTRIBUTION FUNCTIONS ******************************************/
23849 +
23850 +#define NO_VO_SERVICE 1 /* currently WMI only uses 3 data streams, so we leave VO service inactive */
23851 +
23852 +#ifdef NO_VO_SERVICE
23853 +#define DATA_SVCS_USED 3
23854 +#else
23855 +#define DATA_SVCS_USED 4
23856 +#endif
23857 +
23858 +static void RedistributeCredits(COMMON_CREDIT_STATE_INFO *pCredInfo,
23859 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList);
23860 +
23861 +static void SeekCredits(COMMON_CREDIT_STATE_INFO *pCredInfo,
23862 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList);
23863 +
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,
23867 + int Limit)
23868 +{
23869 + int credits;
23870 +
23871 + /* set the new limit */
23872 + pEpDist->TxCreditsAssigned = Limit;
23873 +
23874 + if (pEpDist->TxCredits <= Limit) {
23875 + return;
23876 + }
23877 +
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;
23883 +}
23884 +
23885 +/* give an endpoint some credits from the free credit pool */
23886 +#define GiveCredits(pCredInfo,pEpDist,credits) \
23887 +{ \
23888 + (pEpDist)->TxCredits += (credits); \
23889 + (pEpDist)->TxCreditsAssigned += (credits); \
23890 + (pCredInfo)->CurrentFreeCredits -= (credits); \
23891 +}
23892 +
23893 +
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)
23900 +{
23901 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
23902 + int count;
23903 + COMMON_CREDIT_STATE_INFO *pCredInfo = (COMMON_CREDIT_STATE_INFO *)Context;
23904 +
23905 + pCredInfo->CurrentFreeCredits = TotalCredits;
23906 + pCredInfo->TotalAvailableCredits = TotalCredits;
23907 +
23908 + pCurEpDist = pEPList;
23909 +
23910 + /* run through the list and initialize */
23911 + while (pCurEpDist != NULL) {
23912 +
23913 + /* set minimums for each endpoint */
23914 + pCurEpDist->TxCreditsMin = pCurEpDist->TxCreditsPerMaxMsg;
23915 +
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;
23924 + }
23925 +
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.
23930 + */
23931 +
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;
23935 + }
23936 +
23937 + if (pCredInfo->CurrentFreeCredits <= 0) {
23938 + AR_DEBUG_PRINTF(ATH_LOG_INF, ("Not enough credits (%d) to do credit distributions \n", TotalCredits));
23939 + A_ASSERT(FALSE);
23940 + return;
23941 + }
23942 +
23943 + /* reset list */
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;
23950 + } else {
23951 + /* for the remaining data endpoints, we assume that each TxCreditsPerMaxMsg are
23952 + * the same.
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.
23956 + * */
23957 + count = (pCredInfo->CurrentFreeCredits/pCurEpDist->TxCreditsPerMaxMsg) * pCurEpDist->TxCreditsPerMaxMsg;
23958 + count = count >> 1;
23959 + count = max(count,pCurEpDist->TxCreditsPerMaxMsg);
23960 + /* set normal */
23961 + pCurEpDist->TxCreditsNorm = count;
23962 +
23963 + }
23964 + pCurEpDist = pCurEpDist->pNext;
23965 + }
23966 +
23967 +}
23968 +
23969 +
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.
23975 + *
23976 + */
23977 +static void ar6000_credit_distribute(void *Context,
23978 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList,
23979 + HTC_CREDIT_DIST_REASON Reason)
23980 +{
23981 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
23982 + COMMON_CREDIT_STATE_INFO *pCredInfo = (COMMON_CREDIT_STATE_INFO *)Context;
23983 +
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) {
23991 +
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;
23997 +
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);
24002 + }
24003 +
24004 + if (pCurEpDist->TxCredits > pCurEpDist->TxCreditsNorm) {
24005 + /* oversubscribed endpoints need to reduce back to normal */
24006 + ReduceCredits(pCredInfo, pCurEpDist, pCurEpDist->TxCreditsNorm);
24007 + }
24008 + }
24009 +
24010 + pCurEpDist = pCurEpDist->pNext;
24011 + }
24012 +
24013 + A_ASSERT(pCredInfo->CurrentFreeCredits <= pCredInfo->TotalAvailableCredits);
24014 +
24015 + break;
24016 +
24017 + case HTC_CREDIT_DIST_ACTIVITY_CHANGE :
24018 + RedistributeCredits(pCredInfo,pEPDistList);
24019 + break;
24020 + case HTC_CREDIT_DIST_SEEK_CREDITS :
24021 + SeekCredits(pCredInfo,pEPDistList);
24022 + break;
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));
24026 + break;
24027 + default:
24028 + break;
24029 +
24030 + }
24031 +
24032 +}
24033 +
24034 +/* redistribute credits based on activity change */
24035 +static void RedistributeCredits(COMMON_CREDIT_STATE_INFO *pCredInfo,
24036 + HTC_ENDPOINT_CREDIT_DIST *pEPDistList)
24037 +{
24038 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist = pEPDistList;
24039 +
24040 + /* walk through the list and remove credits from inactive endpoints */
24041 + while (pCurEpDist != NULL) {
24042 +
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);
24047 + }
24048 + }
24049 +
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 */
24053 +
24054 + pCurEpDist = pCurEpDist->pNext;
24055 + }
24056 +
24057 + A_ASSERT(pCredInfo->CurrentFreeCredits <= pCredInfo->TotalAvailableCredits);
24058 +
24059 +}
24060 +
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)
24064 +{
24065 + HTC_ENDPOINT_CREDIT_DIST *pCurEpDist;
24066 + int credits = 0;
24067 + int need;
24068 +
24069 + do {
24070 +
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 */
24075 + break;
24076 + }
24077 +
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 */
24081 +
24082 + if (pCredInfo->CurrentFreeCredits >= 2 * pEPDist->TxCreditsSeek) {
24083 + /* try to give more credits than it needs */
24084 + credits = 2 * pEPDist->TxCreditsSeek;
24085 + } else {
24086 + /* give what we can */
24087 + credits = min(pCredInfo->CurrentFreeCredits,pEPDist->TxCreditsSeek);
24088 + }
24089 +
24090 + if (credits >= pEPDist->TxCreditsSeek) {
24091 + /* we found some to fullfill the seek request */
24092 + break;
24093 + }
24094 +
24095 + /* we don't have enough in the free pool, try taking away from lower priority services
24096 + *
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.
24101 + *
24102 + * */
24103 +
24104 + /* starting at the lowest priority */
24105 + pCurEpDist = pCredInfo->pLowestPriEpDist;
24106 +
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;
24111 +
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,
24117 + pCurEpDist,
24118 + pCurEpDist->TxCreditsAssigned - need);
24119 +
24120 + if (pCredInfo->CurrentFreeCredits >= pEPDist->TxCreditsSeek) {
24121 + /* we have enough */
24122 + break;
24123 + }
24124 + }
24125 +
24126 + pCurEpDist = pCurEpDist->pPrev;
24127 + }
24128 +
24129 + /* return what we can get */
24130 + credits = min(pCredInfo->CurrentFreeCredits,pEPDist->TxCreditsSeek);
24131 +
24132 + } while (FALSE);
24133 +
24134 + /* did we find some credits? */
24135 + if (credits) {
24136 + /* give what we can */
24137 + GiveCredits(pCredInfo, pEPDist, credits);
24138 + }
24139 +
24140 +}
24141 +
24142 +/* initialize and setup credit distribution */
24143 +A_STATUS ar6000_setup_credit_dist(HTC_HANDLE HTCHandle, COMMON_CREDIT_STATE_INFO *pCredInfo)
24144 +{
24145 + HTC_SERVICE_ID servicepriority[5];
24146 +
24147 + A_MEMZERO(pCredInfo,sizeof(COMMON_CREDIT_STATE_INFO));
24148 +
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 */
24154 +
24155 + /* set callbacks and priority list */
24156 + HTCSetCreditDistribution(HTCHandle,
24157 + pCredInfo,
24158 + ar6000_credit_distribute,
24159 + ar6000_credit_init,
24160 + servicepriority,
24161 + 5);
24162 +
24163 + return A_OK;
24164 +}
24165 +
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
24169 --- /dev/null
24170 +++ b/drivers/sdio/function/wlan/ar6000/wlan/wlan_node.c
24171 @@ -0,0 +1,371 @@
24172 +/*-
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.
24177 + *
24178 + * Redistribution and use in source and binary forms, with or without
24179 + * modification, are permitted provided that the following conditions
24180 + * are met:
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.
24188 + *
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.
24192 + *
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.
24203 + *
24204 + * $Id: //depot/sw/releases/olca2.0-GPL/host/wlan/src/wlan_node.c#1 $
24205 + */
24206 +/*
24207 + * IEEE 802.11 node handling support.
24208 + */
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>
24218 +#include <wmi.h>
24219 +#include <wmi_api.h>
24220 +
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);
24224 +
24225 +bss_t *
24226 +wlan_node_alloc(struct ieee80211_node_table *nt, int wh_size)
24227 +{
24228 + bss_t *ni;
24229 +
24230 + ni = A_MALLOC_NOWAIT(sizeof(bss_t));
24231 +
24232 + if (ni != NULL) {
24233 + ni->ni_buf = A_MALLOC_NOWAIT(wh_size);
24234 + if (ni->ni_buf == NULL) {
24235 + A_FREE(ni);
24236 + ni = NULL;
24237 + return ni;
24238 + }
24239 + } else {
24240 + return ni;
24241 + }
24242 +
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;
24248 +
24249 + //
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
24252 + //
24253 + ni->ni_scangen = 0;
24254 +
24255 + return ni;
24256 +}
24257 +
24258 +void
24259 +wlan_node_free(bss_t *ni)
24260 +{
24261 + if (ni->ni_buf != NULL) {
24262 + A_FREE(ni->ni_buf);
24263 + }
24264 + A_FREE(ni);
24265 +}
24266 +
24267 +void
24268 +wlan_setup_node(struct ieee80211_node_table *nt, bss_t *ni,
24269 + const A_UINT8 *macaddr)
24270 +{
24271 + int hash;
24272 +
24273 + A_MEMCPY(ni->ni_macaddr, macaddr, IEEE80211_ADDR_LEN);
24274 + hash = IEEE80211_NODE_HASH(macaddr);
24275 + ieee80211_node_initref(ni); /* mark referenced */
24276 +
24277 + ni->ni_tstamp = A_GET_MS(WLAN_NODE_INACT_TIMEOUT_MSEC);
24278 + IEEE80211_NODE_LOCK_BH(nt);
24279 +
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)
24284 + {
24285 + nt->nt_node_last->ni_list_next = ni;
24286 + }
24287 + nt->nt_node_last = ni;
24288 + if(nt->nt_node_first == NULL)
24289 + {
24290 + nt->nt_node_first = ni;
24291 + }
24292 +
24293 + /* Insert into the hash list i.e. the bucket */
24294 + if((ni->ni_hash_next = nt->nt_hash[hash]) != NULL)
24295 + {
24296 + nt->nt_hash[hash]->ni_hash_prev = ni;
24297 + }
24298 + ni->ni_hash_prev = NULL;
24299 + nt->nt_hash[hash] = ni;
24300 +
24301 + if (!nt->isTimerArmed) {
24302 + A_TIMEOUT_MS(&nt->nt_inact_timer, WLAN_NODE_INACT_TIMEOUT_MSEC, 0);
24303 + nt->isTimerArmed = TRUE;
24304 + }
24305 +
24306 + IEEE80211_NODE_UNLOCK_BH(nt);
24307 +}
24308 +
24309 +static bss_t *
24310 +_ieee80211_find_node(struct ieee80211_node_table *nt,
24311 + const A_UINT8 *macaddr)
24312 +{
24313 + bss_t *ni;
24314 + int hash;
24315 +
24316 + IEEE80211_NODE_LOCK_ASSERT(nt);
24317 +
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 */
24322 + return ni;
24323 + }
24324 + }
24325 + return NULL;
24326 +}
24327 +
24328 +bss_t *
24329 +wlan_find_node(struct ieee80211_node_table *nt, const A_UINT8 *macaddr)
24330 +{
24331 + bss_t *ni;
24332 +
24333 + IEEE80211_NODE_LOCK(nt);
24334 + ni = _ieee80211_find_node(nt, macaddr);
24335 + IEEE80211_NODE_UNLOCK(nt);
24336 + return ni;
24337 +}
24338 +
24339 +/*
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.
24343 + */
24344 +void
24345 +wlan_node_reclaim(struct ieee80211_node_table *nt, bss_t *ni)
24346 +{
24347 + IEEE80211_NODE_LOCK(nt);
24348 +
24349 + if(ni->ni_list_prev == NULL)
24350 + {
24351 + /* First in list so fix the list head */
24352 + nt->nt_node_first = ni->ni_list_next;
24353 + }
24354 + else
24355 + {
24356 + ni->ni_list_prev->ni_list_next = ni->ni_list_next;
24357 + }
24358 +
24359 + if(ni->ni_list_next == NULL)
24360 + {
24361 + /* Last in list so fix list tail */
24362 + nt->nt_node_last = ni->ni_list_prev;
24363 + }
24364 + else
24365 + {
24366 + ni->ni_list_next->ni_list_prev = ni->ni_list_prev;
24367 + }
24368 +
24369 + if(ni->ni_hash_prev == NULL)
24370 + {
24371 + /* First in list so fix the list head */
24372 + int hash;
24373 + hash = IEEE80211_NODE_HASH(ni->ni_macaddr);
24374 + nt->nt_hash[hash] = ni->ni_hash_next;
24375 + }
24376 + else
24377 + {
24378 + ni->ni_hash_prev->ni_hash_next = ni->ni_hash_next;
24379 + }
24380 +
24381 + if(ni->ni_hash_next != NULL)
24382 + {
24383 + ni->ni_hash_next->ni_hash_prev = ni->ni_hash_prev;
24384 + }
24385 + wlan_node_free(ni);
24386 +
24387 + IEEE80211_NODE_UNLOCK(nt);
24388 +}
24389 +
24390 +static void
24391 +wlan_node_dec_free(bss_t *ni)
24392 +{
24393 + if (ieee80211_node_dectestref(ni)) {
24394 + wlan_node_free(ni);
24395 + }
24396 +}
24397 +
24398 +void
24399 +wlan_free_allnodes(struct ieee80211_node_table *nt)
24400 +{
24401 + bss_t *ni;
24402 +
24403 + while ((ni = nt->nt_node_first) != NULL) {
24404 + wlan_node_reclaim(nt, ni);
24405 + }
24406 +}
24407 +
24408 +void
24409 +wlan_iterate_nodes(struct ieee80211_node_table *nt, wlan_node_iter_func *f,
24410 + void *arg)
24411 +{
24412 + bss_t *ni;
24413 + A_UINT32 gen;
24414 +
24415 + gen = ++nt->nt_scangen;
24416 +
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);
24422 + (*f)(arg, ni);
24423 + wlan_node_dec_free(ni);
24424 + }
24425 + }
24426 + IEEE80211_NODE_UNLOCK(nt);
24427 +}
24428 +
24429 +/*
24430 + * Node table support.
24431 + */
24432 +void
24433 +wlan_node_table_init(void *wmip, struct ieee80211_node_table *nt)
24434 +{
24435 + int i;
24436 +
24437 + AR_DEBUG_PRINTF(ATH_DEBUG_WLAN, ("node table = 0x%x\n", (A_UINT32)nt));
24438 + IEEE80211_NODE_LOCK_INIT(nt);
24439 +
24440 + nt->nt_node_first = nt->nt_node_last = NULL;
24441 + for(i = 0; i < IEEE80211_NODE_HASHSIZE; i++)
24442 + {
24443 + nt->nt_hash[i] = NULL;
24444 + }
24445 + A_INIT_TIMER(&nt->nt_inact_timer, wlan_node_timeout, nt);
24446 + nt->isTimerArmed = FALSE;
24447 + nt->nt_wmip = wmip;
24448 +}
24449 +
24450 +static void
24451 +wlan_node_timeout(A_ATH_TIMER arg)
24452 +{
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;
24456 +
24457 + wmi_get_current_bssid(nt->nt_wmip, myBssid);
24458 +
24459 + bss = nt->nt_node_first;
24460 + while (bss != NULL)
24461 + {
24462 + nextBss = bss->ni_list_next;
24463 + if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0)
24464 + {
24465 +
24466 + if (bss->ni_tstamp <= A_GET_MS(0))
24467 + {
24468 + /*
24469 + * free up all but the current bss - if set
24470 + */
24471 + wlan_node_reclaim(nt, bss);
24472 + }
24473 + else
24474 + {
24475 + /*
24476 + * Re-arm timer, only when we have a bss other than
24477 + * current bss AND it is not aged-out.
24478 + */
24479 + reArmTimer = TRUE;
24480 + }
24481 + }
24482 + bss = nextBss;
24483 + }
24484 +
24485 + if(reArmTimer)
24486 + A_TIMEOUT_MS(&nt->nt_inact_timer, WLAN_NODE_INACT_TIMEOUT_MSEC, 0);
24487 +
24488 + nt->isTimerArmed = reArmTimer;
24489 +}
24490 +
24491 +void
24492 +wlan_node_table_cleanup(struct ieee80211_node_table *nt)
24493 +{
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);
24498 +}
24499 +
24500 +bss_t *
24501 +wlan_find_Ssidnode (struct ieee80211_node_table *nt, A_UCHAR *pSsid,
24502 + A_UINT32 ssidLength, A_BOOL bIsWPA2)
24503 +{
24504 + bss_t *ni = NULL;
24505 + A_UCHAR *pIESsid = NULL;
24506 +
24507 + IEEE80211_NODE_LOCK (nt);
24508 +
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) {
24512 +
24513 + // Step 1 : Check SSID
24514 + if (0x00 == memcmp (pSsid, &pIESsid[2], ssidLength)) {
24515 +
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);
24520 + return ni;
24521 + }
24522 + if (FALSE == bIsWPA2 && NULL != ni->ni_cie.ie_wpa) {
24523 + ieee80211_node_incref(ni); /* mark referenced */
24524 + IEEE80211_NODE_UNLOCK (nt);
24525 + return ni;
24526 + }
24527 + }
24528 + }
24529 + }
24530 +
24531 + IEEE80211_NODE_UNLOCK (nt);
24532 +
24533 + return NULL;
24534 +}
24535 +
24536 +void
24537 +wlan_node_return (struct ieee80211_node_table *nt, bss_t *ni)
24538 +{
24539 + IEEE80211_NODE_LOCK (nt);
24540 + wlan_node_dec_free (ni);
24541 + IEEE80211_NODE_UNLOCK (nt);
24542 +}
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
24546 --- /dev/null
24547 +++ b/drivers/sdio/function/wlan/ar6000/wlan/wlan_recv_beacon.c
24548 @@ -0,0 +1,192 @@
24549 +/*-
24550 + * Copyright (c) 2001 Atsushi Onoe
24551 + * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
24552 + * All rights reserved.
24553 + *
24554 + * Redistribution and use in source and binary forms, with or without
24555 + * modification, are permitted provided that the following conditions
24556 + * are met:
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.
24564 + *
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.
24568 + *
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.
24579 + */
24580 +/*
24581 + * IEEE 802.11 input handling.
24582 + */
24583 +
24584 +#include "a_config.h"
24585 +#include "athdefs.h"
24586 +#include "a_types.h"
24587 +#include "a_osapi.h"
24588 +#include <wmi.h>
24589 +#include <ieee80211.h>
24590 +#include <wlan_api.h>
24591 +
24592 +#define IEEE80211_VERIFY_LENGTH(_len, _minlen) do { \
24593 + if ((_len) < (_minlen)) { \
24594 + return A_EINVAL; \
24595 + } \
24596 +} while (0)
24597 +
24598 +#define IEEE80211_VERIFY_ELEMENT(__elem, __maxlen) do { \
24599 + if ((__elem) == NULL) { \
24600 + return A_EINVAL; \
24601 + } \
24602 + if ((__elem)[1] > (__maxlen)) { \
24603 + return A_EINVAL; \
24604 + } \
24605 +} while (0)
24606 +
24607 +
24608 +/* unaligned little endian access */
24609 +#define LE_READ_2(p) \
24610 + ((A_UINT16) \
24611 + ((((A_UINT8 *)(p))[0] ) | (((A_UINT8 *)(p))[1] << 8)))
24612 +
24613 +#define LE_READ_4(p) \
24614 + ((A_UINT32) \
24615 + ((((A_UINT8 *)(p))[0] ) | (((A_UINT8 *)(p))[1] << 8) | \
24616 + (((A_UINT8 *)(p))[2] << 16) | (((A_UINT8 *)(p))[3] << 24)))
24617 +
24618 +
24619 +static int __inline
24620 +iswpaoui(const A_UINT8 *frm)
24621 +{
24622 + return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI);
24623 +}
24624 +
24625 +static int __inline
24626 +iswmmoui(const A_UINT8 *frm)
24627 +{
24628 + return frm[1] > 3 && LE_READ_4(frm+2) == ((WMM_OUI_TYPE<<24)|WMM_OUI);
24629 +}
24630 +
24631 +static int __inline
24632 +iswmmparam(const A_UINT8 *frm)
24633 +{
24634 + return frm[1] > 5 && frm[6] == WMM_PARAM_OUI_SUBTYPE;
24635 +}
24636 +
24637 +static int __inline
24638 +iswmminfo(const A_UINT8 *frm)
24639 +{
24640 + return frm[1] > 5 && frm[6] == WMM_INFO_OUI_SUBTYPE;
24641 +}
24642 +
24643 +static int __inline
24644 +isatherosoui(const A_UINT8 *frm)
24645 +{
24646 + return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI);
24647 +}
24648 +
24649 +static int __inline
24650 +iswscoui(const A_UINT8 *frm)
24651 +{
24652 + return frm[1] > 3 && LE_READ_4(frm+2) == ((0x04<<24)|WPA_OUI);
24653 +}
24654 +
24655 +A_STATUS
24656 +wlan_parse_beacon(A_UINT8 *buf, int framelen, struct ieee80211_common_ie *cie)
24657 +{
24658 + A_UINT8 *frm, *efrm;
24659 +
24660 + frm = buf;
24661 + efrm = (A_UINT8 *) (frm + framelen);
24662 +
24663 + /*
24664 + * beacon/probe response frame format
24665 + * [8] time stamp
24666 + * [2] beacon interval
24667 + * [2] capability information
24668 + * [tlv] ssid
24669 + * [tlv] supported rates
24670 + * [tlv] country information
24671 + * [tlv] parameter set (FH/DS)
24672 + * [tlv] erp information
24673 + * [tlv] extended supported rates
24674 + * [tlv] WMM
24675 + * [tlv] WPA or RSN
24676 + * [tlv] Atheros Advanced Capabilities
24677 + */
24678 + IEEE80211_VERIFY_LENGTH(efrm - frm, 12);
24679 + A_MEMZERO(cie, sizeof(*cie));
24680 +
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;
24685 +
24686 + while (frm < efrm) {
24687 + switch (*frm) {
24688 + case IEEE80211_ELEMID_SSID:
24689 + cie->ie_ssid = frm;
24690 + break;
24691 + case IEEE80211_ELEMID_RATES:
24692 + cie->ie_rates = frm;
24693 + break;
24694 + case IEEE80211_ELEMID_COUNTRY:
24695 + cie->ie_country = frm;
24696 + break;
24697 + case IEEE80211_ELEMID_FHPARMS:
24698 + break;
24699 + case IEEE80211_ELEMID_DSPARMS:
24700 + cie->ie_chan = frm[2];
24701 + break;
24702 + case IEEE80211_ELEMID_TIM:
24703 + cie->ie_tim = frm;
24704 + break;
24705 + case IEEE80211_ELEMID_IBSSPARMS:
24706 + break;
24707 + case IEEE80211_ELEMID_XRATES:
24708 + cie->ie_xrates = frm;
24709 + break;
24710 + case IEEE80211_ELEMID_ERP:
24711 + if (frm[1] != 1) {
24712 + //A_PRINTF("Discarding ERP Element - Bad Len\n");
24713 + return A_EINVAL;
24714 + }
24715 + cie->ie_erp = frm[2];
24716 + break;
24717 + case IEEE80211_ELEMID_RSN:
24718 + cie->ie_rsn = frm;
24719 + break;
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;
24729 + }
24730 + break;
24731 + default:
24732 + break;
24733 + }
24734 + frm += frm[1] + 2;
24735 + }
24736 + IEEE80211_VERIFY_ELEMENT(cie->ie_rates, IEEE80211_RATE_MAXSIZE);
24737 + IEEE80211_VERIFY_ELEMENT(cie->ie_ssid, IEEE80211_NWID_LEN);
24738 +
24739 + return A_OK;
24740 +}
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
24744 --- /dev/null
24745 +++ b/drivers/sdio/function/wlan/ar6000/wlan/wlan_utils.c
24746 @@ -0,0 +1,59 @@
24747 +/*
24748 + * Copyright (c) 2004-2005 Atheros Communications Inc.
24749 + * All rights reserved.
24750 + *
24751 + * This module implements frequently used wlan utilies
24752 + *
24753 + * $Id: //depot/sw/releases/olca2.0-GPL/host/wlan/src/wlan_utils.c#1 $
24754 + *
24755 + *
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;
24759 + *
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.
24764 + *
24765 + *
24766 + *
24767 + */
24768 +
24769 +#include <a_config.h>
24770 +#include <athdefs.h>
24771 +#include <a_types.h>
24772 +#include <a_osapi.h>
24773 +
24774 +/*
24775 + * converts ieee channel number to frequency
24776 + */
24777 +A_UINT16
24778 +wlan_ieee2freq(int chan)
24779 +{
24780 + if (chan == 14) {
24781 + return 2484;
24782 + }
24783 + if (chan < 14) { /* 0-13 */
24784 + return (2407 + (chan*5));
24785 + }
24786 + if (chan < 27) { /* 15-26 */
24787 + return (2512 + ((chan-15)*20));
24788 + }
24789 + return (5000 + (chan*5));
24790 +}
24791 +
24792 +/*
24793 + * Converts MHz frequency to IEEE channel number.
24794 + */
24795 +A_UINT32
24796 +wlan_freq2ieee(A_UINT16 freq)
24797 +{
24798 + if (freq == 2484)
24799 + return 14;
24800 + if (freq < 2484)
24801 + return (freq - 2407) / 5;
24802 + if (freq < 5000)
24803 + return 15 + ((freq - 2512) / 20);
24804 + return (freq - 5000) / 5;
24805 +}
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
24809 --- /dev/null
24810 +++ b/drivers/sdio/function/wlan/ar6000/wmi/wmi.c
24811 @@ -0,0 +1,3921 @@
24812 +/*
24813 + * Copyright (c) 2004-2007 Atheros Communications Inc.
24814 + * All rights reserved.
24815 + *
24816 + * This module implements the hardware independent layer of the
24817 + * Wireless Module Interface (WMI) protocol.
24818 + *
24819 + * $Id: //depot/sw/releases/olca2.0-GPL/host/wmi/wmi.c#3 $
24820 + *
24821 + *
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;
24825 + *
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.
24830 + *
24831 + *
24832 + *
24833 + */
24834 +
24835 +#include <a_config.h>
24836 +#include <athdefs.h>
24837 +#include <a_types.h>
24838 +#include <a_osapi.h>
24839 +#include "htc.h"
24840 +#include "htc_api.h"
24841 +#include "wmi.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"
24853 +
24854 +static A_STATUS wmi_ready_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24855 +
24856 +static A_STATUS wmi_connect_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24857 + int len);
24858 +static A_STATUS wmi_disconnect_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24859 + int len);
24860 +static A_STATUS wmi_tkip_micerr_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24861 + int len);
24862 +static A_STATUS wmi_bssInfo_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24863 + int len);
24864 +static A_STATUS wmi_opt_frame_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24865 + int len);
24866 +static A_STATUS wmi_pstream_timeout_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24867 + int len);
24868 +static A_STATUS wmi_sync_point(struct wmi_t *wmip);
24869 +
24870 +static A_STATUS wmi_bitrate_reply_rx(struct wmi_t *wmip, A_UINT8 *datap,
24871 + int len);
24872 +static A_STATUS wmi_ratemask_reply_rx(struct wmi_t *wmip, A_UINT8 *datap,
24873 + int len);
24874 +static A_STATUS wmi_channelList_reply_rx(struct wmi_t *wmip, A_UINT8 *datap,
24875 + int len);
24876 +static A_STATUS wmi_regDomain_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24877 + int len);
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,
24880 + int len);
24881 +
24882 +static A_STATUS wmi_dset_open_req_rx(struct wmi_t *wmip, A_UINT8 *datap,
24883 + int len);
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,
24887 + int len);
24888 +#endif /* CONFIG_HOST_DSET_SUPPORT */
24889 +
24890 +
24891 +static A_STATUS wmi_scanComplete_rx(struct wmi_t *wmip, A_UINT8 *datap,
24892 + int len);
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,
24900 + int len);
24901 +static A_STATUS wmi_roam_data_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24902 + int len);
24903 +static A_STATUS wmi_get_wow_list_event_rx(struct wmi_t *wmip, A_UINT8 *datap,
24904 + int len);
24905 +static A_STATUS
24906 +wmi_get_pmkid_list_event_rx(struct wmi_t *wmip, A_UINT8 *datap, A_UINT32 len);
24907 +
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 */
24913 +
24914 +#ifdef CONFIG_HOST_TCMD_SUPPORT
24915 +static A_STATUS
24916 +wmi_tcmd_test_report_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24917 +#endif
24918 +
24919 +static A_STATUS
24920 +wmi_txRetryErrEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24921 +
24922 +static A_STATUS
24923 +wmi_snrThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24924 +
24925 +static A_STATUS
24926 +wmi_lqThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24927 +
24928 +static A_BOOL
24929 +wmi_is_bitrate_index_valid(struct wmi_t *wmip, A_UINT32 rateIndex);
24930 +
24931 +static A_STATUS
24932 +wmi_aplistEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24933 +
24934 +static A_STATUS
24935 +wmi_dbglog_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24936 +
24937 +static A_STATUS wmi_keepalive_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len);
24938 +
24939 +int wps_enable;
24940 +static const A_INT32 wmi_rateTable[] = {
24941 + 1000,
24942 + 2000,
24943 + 5500,
24944 + 11000,
24945 + 6000,
24946 + 9000,
24947 + 12000,
24948 + 18000,
24949 + 24000,
24950 + 36000,
24951 + 48000,
24952 + 54000,
24953 + 0};
24954 +
24955 +#define MODE_A_SUPPORT_RATE_START 4
24956 +#define MODE_A_SUPPORT_RATE_STOP 11
24957 +
24958 +#define MODE_GONLY_SUPPORT_RATE_START MODE_A_SUPPORT_RATE_START
24959 +#define MODE_GONLY_SUPPORT_RATE_STOP MODE_A_SUPPORT_RATE_STOP
24960 +
24961 +#define MODE_B_SUPPORT_RATE_START 0
24962 +#define MODE_B_SUPPORT_RATE_STOP 3
24963 +
24964 +#define MODE_G_SUPPORT_RATE_START 0
24965 +#define MODE_G_SUPPORT_RATE_STOP 11
24966 +
24967 +#define MAX_NUMBER_OF_SUPPORT_RATES (MODE_G_SUPPORT_RATE_STOP + 1)
24968 +
24969 +/* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
24970 +const A_UINT8 up_to_ac[]= {
24971 + WMM_AC_BE,
24972 + WMM_AC_BK,
24973 + WMM_AC_BK,
24974 + WMM_AC_BE,
24975 + WMM_AC_VI,
24976 + WMM_AC_VI,
24977 + WMM_AC_VO,
24978 + WMM_AC_VO,
24979 + };
24980 +
24981 +void *
24982 +wmi_init(void *devt)
24983 +{
24984 + struct wmi_t *wmip;
24985 +
24986 + wmip = A_MALLOC(sizeof(struct wmi_t));
24987 + if (wmip == NULL) {
24988 + return (NULL);
24989 + }
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;
24997 +
24998 + return (wmip);
24999 +}
25000 +
25001 +void
25002 +wmi_qos_state_init(struct wmi_t *wmip)
25003 +{
25004 + A_UINT8 i;
25005 +
25006 + if (wmip == NULL) {
25007 + return;
25008 + }
25009 + LOCK_WMI(wmip);
25010 +
25011 + /* Initialize QoS States */
25012 + wmip->wmi_numQoSStream = 0;
25013 +
25014 + wmip->wmi_fatPipeExists = 0;
25015 +
25016 + for (i=0; i < WMM_NUM_AC; i++) {
25017 + wmip->wmi_streamExistsForAC[i]=0;
25018 + }
25019 +
25020 + /* Initialize the static Wmi stream Pri to WMM AC mappings Arrays */
25021 + WMI_INIT_WMISTREAM_AC_MAP(wmip);
25022 +
25023 + UNLOCK_WMI(wmip);
25024 +
25025 + A_WMI_SET_NUMDATAENDPTS(wmip->wmi_devt, 1);
25026 +}
25027 +
25028 +void
25029 +wmi_shutdown(struct wmi_t *wmip)
25030 +{
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);
25035 + }
25036 + A_FREE(wmip);
25037 + }
25038 +}
25039 +
25040 +/*
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.
25045 + */
25046 +A_STATUS
25047 +wmi_dix_2_dot3(struct wmi_t *wmip, void *osbuf)
25048 +{
25049 + A_UINT8 *datap;
25050 + A_UINT16 typeorlen;
25051 + ATH_MAC_HDR macHdr;
25052 + ATH_LLC_SNAP_HDR *llcHdr;
25053 +
25054 + A_ASSERT(osbuf != NULL);
25055 +
25056 + if (A_NETBUF_HEADROOM(osbuf) <
25057 + (sizeof(ATH_LLC_SNAP_HDR) + sizeof(WMI_DATA_HDR)))
25058 + {
25059 + return A_NO_MEMORY;
25060 + }
25061 +
25062 + datap = A_NETBUF_DATA(osbuf);
25063 +
25064 + typeorlen = *(A_UINT16 *)(datap + ATH_MAC_LEN + ATH_MAC_LEN);
25065 +
25066 + if (!IS_ETHERTYPE(A_BE2CPU16(typeorlen))) {
25067 + /*
25068 + * packet is already in 802.3 format - return success
25069 + */
25070 + A_DPRINTF(DBG_WMI, (DBGFMT "packet already 802.3\n", DBGARG));
25071 + return (A_OK);
25072 + }
25073 +
25074 + /*
25075 + * Save mac fields and length to be inserted later
25076 + */
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));
25081 +
25082 + /*
25083 + * Make room for LLC+SNAP headers
25084 + */
25085 + if (A_NETBUF_PUSH(osbuf, sizeof(ATH_LLC_SNAP_HDR)) != A_OK) {
25086 + return A_NO_MEMORY;
25087 + }
25088 +
25089 + datap = A_NETBUF_DATA(osbuf);
25090 +
25091 + A_MEMCPY(datap, &macHdr, sizeof (ATH_MAC_HDR));
25092 +
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;
25101 +
25102 + return (A_OK);
25103 +}
25104 +
25105 +/*
25106 + * Adds a WMI data header
25107 + * Assumes there is enough room in the buffer to add header.
25108 + */
25109 +A_STATUS
25110 +wmi_data_hdr_add(struct wmi_t *wmip, void *osbuf, A_UINT8 msgType)
25111 +{
25112 + WMI_DATA_HDR *dtHdr;
25113 +
25114 + A_ASSERT(osbuf != NULL);
25115 +
25116 + if (A_NETBUF_PUSH(osbuf, sizeof(WMI_DATA_HDR)) != A_OK) {
25117 + return A_NO_MEMORY;
25118 + }
25119 +
25120 + dtHdr = (WMI_DATA_HDR *)A_NETBUF_DATA(osbuf);
25121 + dtHdr->info = msgType;
25122 + dtHdr->rssi = 0;
25123 +
25124 + return (A_OK);
25125 +}
25126 +
25127 +A_UINT8 wmi_implicit_create_pstream(struct wmi_t *wmip, void *osbuf, A_UINT8 dir, A_UINT8 up)
25128 +{
25129 + A_UINT8 *datap;
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;
25136 +
25137 + A_ASSERT(osbuf != NULL);
25138 +
25139 + datap = A_NETBUF_DATA(osbuf);
25140 +
25141 + if (up == UNDEFINED_PRI) {
25142 + llcHdr = (ATH_LLC_SNAP_HDR *)(datap + sizeof(WMI_DATA_HDR) +
25143 + sizeof(ATH_MAC_HDR));
25144 +
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));
25148 + }
25149 + }
25150 +
25151 + if (userPriority < MAX_NUM_PRI) {
25152 + trafficClass = convert_userPriority_to_trafficClass(userPriority);
25153 + }
25154 +
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 */
25158 +
25159 + LOCK_WMI(wmip);
25160 + streamExists = wmip->wmi_fatPipeExists;
25161 + UNLOCK_WMI(wmip);
25162 +
25163 + if (!(streamExists & (1 << trafficClass))) {
25164 +
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);
25172 + }
25173 +
25174 + return trafficClass;
25175 +}
25176 +
25177 +WMI_PRI_STREAM_ID
25178 +wmi_get_stream_id(struct wmi_t *wmip, A_UINT8 trafficClass)
25179 +{
25180 + return WMI_ACCESSCATEGORY_WMISTREAM(wmip, trafficClass);
25181 +}
25182 +
25183 +/*
25184 + * performs 802.3 to DIX encapsulation for received packets.
25185 + * Assumes the entire 802.3 header is contigous.
25186 + */
25187 +A_STATUS
25188 +wmi_dot3_2_dix(struct wmi_t *wmip, void *osbuf)
25189 +{
25190 + A_UINT8 *datap;
25191 + ATH_MAC_HDR macHdr;
25192 + ATH_LLC_SNAP_HDR *llcHdr;
25193 +
25194 + A_ASSERT(osbuf != NULL);
25195 + datap = A_NETBUF_DATA(osbuf);
25196 +
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;
25200 +
25201 + if (A_NETBUF_PULL(osbuf, sizeof(ATH_LLC_SNAP_HDR)) != A_OK) {
25202 + return A_NO_MEMORY;
25203 + }
25204 +
25205 + datap = A_NETBUF_DATA(osbuf);
25206 +
25207 + A_MEMCPY(datap, &macHdr, sizeof (ATH_MAC_HDR));
25208 +
25209 + return (A_OK);
25210 +}
25211 +
25212 +/*
25213 + * Removes a WMI data header
25214 + */
25215 +A_STATUS
25216 +wmi_data_hdr_remove(struct wmi_t *wmip, void *osbuf)
25217 +{
25218 + A_ASSERT(osbuf != NULL);
25219 +
25220 + return (A_NETBUF_PULL(osbuf, sizeof(WMI_DATA_HDR)));
25221 +}
25222 +
25223 +void
25224 +wmi_iterate_nodes(struct wmi_t *wmip, wlan_node_iter_func *f, void *arg)
25225 +{
25226 + wlan_iterate_nodes(&wmip->wmi_scan_table, f, arg);
25227 +}
25228 +
25229 +/*
25230 + * WMI Extended Event received from Target.
25231 + */
25232 +A_STATUS
25233 +wmi_control_rx_xtnd(struct wmi_t *wmip, void *osbuf)
25234 +{
25235 + WMIX_CMD_HDR *cmd;
25236 + A_UINT16 id;
25237 + A_UINT8 *datap;
25238 + A_UINT32 len;
25239 + A_STATUS status = A_OK;
25240 +
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);
25245 + return A_ERROR;
25246 + }
25247 +
25248 + cmd = (WMIX_CMD_HDR *)A_NETBUF_DATA(osbuf);
25249 + id = cmd->commandId;
25250 +
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);
25255 + return A_ERROR;
25256 + }
25257 +
25258 + datap = A_NETBUF_DATA(osbuf);
25259 + len = A_NETBUF_LEN(osbuf);
25260 +
25261 + switch (id) {
25262 + case (WMIX_DSETOPENREQ_EVENTID):
25263 + status = wmi_dset_open_req_rx(wmip, datap, len);
25264 + break;
25265 +#ifdef CONFIG_HOST_DSET_SUPPORT
25266 + case (WMIX_DSETCLOSE_EVENTID):
25267 + status = wmi_dset_close_rx(wmip, datap, len);
25268 + break;
25269 + case (WMIX_DSETDATAREQ_EVENTID):
25270 + status = wmi_dset_data_req_rx(wmip, datap, len);
25271 + break;
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);
25276 + break;
25277 + case (WMIX_GPIO_DATA_EVENTID):
25278 + wmi_gpio_data_rx(wmip, datap, len);
25279 + break;
25280 + case (WMIX_GPIO_ACK_EVENTID):
25281 + wmi_gpio_ack_rx(wmip, datap, len);
25282 + break;
25283 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
25284 + case (WMIX_HB_CHALLENGE_RESP_EVENTID):
25285 + wmi_hbChallengeResp_rx(wmip, datap, len);
25286 + break;
25287 + case (WMIX_DBGLOG_EVENTID):
25288 + wmi_dbglog_event_rx(wmip, datap, len);
25289 + break;
25290 + default:
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;
25295 + break;
25296 + }
25297 +
25298 + return status;
25299 +}
25300 +
25301 +/*
25302 + * Control Path
25303 + */
25304 +A_UINT32 cmdRecvNum;
25305 +
25306 +A_STATUS
25307 +wmi_control_rx(struct wmi_t *wmip, void *osbuf)
25308 +{
25309 + WMI_CMD_HDR *cmd;
25310 + A_UINT16 id;
25311 + A_UINT8 *datap;
25312 + A_UINT32 len, i, loggingReq;
25313 + A_STATUS status = A_OK;
25314 +
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);
25320 + return A_ERROR;
25321 + }
25322 +
25323 + cmd = (WMI_CMD_HDR *)A_NETBUF_DATA(osbuf);
25324 + id = cmd->commandId;
25325 +
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);
25330 + return A_ERROR;
25331 + }
25332 +
25333 + datap = A_NETBUF_DATA(osbuf);
25334 + len = A_NETBUF_LEN(osbuf);
25335 +
25336 + ar6000_get_driver_cfg(wmip->wmi_devt,
25337 + AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS,
25338 + &loggingReq);
25339 +
25340 + if(loggingReq) {
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"));
25346 + }
25347 +
25348 + LOCK_WMI(wmip);
25349 + cmdRecvNum++;
25350 + UNLOCK_WMI(wmip);
25351 +
25352 + switch (id) {
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);
25356 + break;
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);
25360 + break;
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);
25364 + break;
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);
25370 + break;
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);
25375 + break;
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);
25380 + break;
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);
25384 + break;
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);
25389 + break;
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);
25393 + break;
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.
25402 + */
25403 + A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
25404 + break;
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);
25408 + break;
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);
25413 + break;
25414 + case (WMI_CMDERROR_EVENTID):
25415 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CMDERROR_EVENTID\n", DBGARG));
25416 + status = wmi_errorEvent_rx(wmip, datap, len);
25417 + break;
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);
25421 + break;
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);
25425 + break;
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);
25430 + break;
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);
25434 + break;
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);
25438 + break;
25439 + case (WMI_EXTENSION_EVENTID):
25440 + A_DPRINTF(DBG_WMI, (DBGFMT "WMI_EXTENSION_EVENTID\n", DBGARG));
25441 + status = wmi_control_rx_xtnd(wmip, osbuf);
25442 + break;
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);
25446 + break;
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);
25450 + break;
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);
25455 + break;
25456 +#endif
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);
25460 + break;
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);
25465 + break;
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);
25470 + break;
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);
25475 + break;
25476 + case (WMI_APLIST_EVENTID):
25477 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Received APLIST Event\n"));
25478 + status = wmi_aplistEvent_rx(wmip, datap, len);
25479 + break;
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);
25483 + break;
25484 + case (WMI_GET_WOW_LIST_EVENTID):
25485 + status = wmi_get_wow_list_event_rx(wmip, datap, len);
25486 + break;
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);
25490 + break;
25491 + default:
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;
25496 + break;
25497 + }
25498 +
25499 + A_NETBUF_FREE(osbuf);
25500 +
25501 + return status;
25502 +}
25503 +
25504 +static A_STATUS
25505 +wmi_ready_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25506 +{
25507 + WMI_READY_EVENT *ev = (WMI_READY_EVENT *)datap;
25508 +
25509 + if (len < sizeof(WMI_READY_EVENT)) {
25510 + return A_EINVAL;
25511 + }
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);
25515 +
25516 + return A_OK;
25517 +}
25518 +
25519 +static A_STATUS
25520 +wmi_connect_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25521 +{
25522 + WMI_CONNECT_EVENT *ev;
25523 +
25524 + if (len < sizeof(WMI_CONNECT_EVENT)) {
25525 + return A_EINVAL;
25526 + }
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]));
25533 +
25534 + A_MEMCPY(wmip->wmi_bssid, ev->bssid, ATH_MAC_LEN);
25535 +
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,
25540 + ev->assocInfo);
25541 +
25542 + return A_OK;
25543 +}
25544 +
25545 +static A_STATUS
25546 +wmi_regDomain_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25547 +{
25548 + WMI_REG_DOMAIN_EVENT *ev;
25549 +
25550 + if (len < sizeof(*ev)) {
25551 + return A_EINVAL;
25552 + }
25553 + ev = (WMI_REG_DOMAIN_EVENT *)datap;
25554 +
25555 + A_WMI_REGDOMAIN_EVENT(wmip->wmi_devt, ev->regDomain);
25556 +
25557 + return A_OK;
25558 +}
25559 +
25560 +static A_STATUS
25561 +wmi_neighborReport_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25562 +{
25563 + WMI_NEIGHBOR_REPORT_EVENT *ev;
25564 + int numAps;
25565 +
25566 + if (len < sizeof(*ev)) {
25567 + return A_EINVAL;
25568 + }
25569 + ev = (WMI_NEIGHBOR_REPORT_EVENT *)datap;
25570 + numAps = ev->numberOfAps;
25571 +
25572 + if (len < (int)(sizeof(*ev) + ((numAps - 1) * sizeof(WMI_NEIGHBOR_INFO)))) {
25573 + return A_EINVAL;
25574 + }
25575 +
25576 + A_WMI_NEIGHBORREPORT_EVENT(wmip->wmi_devt, numAps, ev->neighbor);
25577 +
25578 + return A_OK;
25579 +}
25580 +
25581 +static A_STATUS
25582 +wmi_disconnect_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25583 +{
25584 + WMI_DISCONNECT_EVENT *ev;
25585 +
25586 + if (len < sizeof(WMI_DISCONNECT_EVENT)) {
25587 + return A_EINVAL;
25588 + }
25589 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25590 +
25591 + ev = (WMI_DISCONNECT_EVENT *)datap;
25592 +
25593 + A_MEMZERO(wmip->wmi_bssid, sizeof(wmip->wmi_bssid));
25594 +
25595 + A_WMI_DISCONNECT_EVENT(wmip->wmi_devt, ev->disconnectReason, ev->bssid,
25596 + ev->assocRespLen, ev->assocInfo, ev->protocolReasonStatus);
25597 +
25598 + return A_OK;
25599 +}
25600 +
25601 +static A_STATUS
25602 +wmi_tkip_micerr_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25603 +{
25604 + WMI_TKIP_MICERR_EVENT *ev;
25605 +
25606 + if (len < sizeof(*ev)) {
25607 + return A_EINVAL;
25608 + }
25609 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25610 +
25611 + ev = (WMI_TKIP_MICERR_EVENT *)datap;
25612 + A_WMI_TKIP_MICERR_EVENT(wmip->wmi_devt, ev->keyid, ev->ismcast);
25613 +
25614 + return A_OK;
25615 +}
25616 +
25617 +static A_STATUS
25618 +wmi_bssInfo_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25619 +{
25620 + bss_t *bss;
25621 + WMI_BSS_INFO_HDR *bih;
25622 + A_UINT8 *buf;
25623 + A_UINT32 nodeCachingAllowed;
25624 +
25625 + if (len <= sizeof(WMI_BSS_INFO_HDR)) {
25626 + return A_EINVAL;
25627 + }
25628 +
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) {
25634 + return A_EINVAL;
25635 + }
25636 +
25637 + if(!nodeCachingAllowed) {
25638 + return A_OK;
25639 + }
25640 +
25641 +
25642 + bih = (WMI_BSS_INFO_HDR *)datap;
25643 + buf = datap + sizeof(WMI_BSS_INFO_HDR);
25644 + len -= sizeof(WMI_BSS_INFO_HDR);
25645 +
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],
25650 + bih->bssid[5]));
25651 +
25652 + if(wps_enable && (bih->frameType == PROBERESP_FTYPE) ) {
25653 + printk("%s() A_OK 2\n", __FUNCTION__);
25654 + return A_OK;
25655 + }
25656 +
25657 + bss = wlan_find_node(&wmip->wmi_scan_table, bih->bssid);
25658 + if (bss != NULL) {
25659 + /*
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
25662 + * adequate.
25663 + */
25664 + wlan_node_reclaim(&wmip->wmi_scan_table, bss);
25665 + }
25666 +
25667 + bss = wlan_node_alloc(&wmip->wmi_scan_table, len);
25668 + if (bss == NULL) {
25669 + return A_NO_MEMORY;
25670 + }
25671 +
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);
25676 +
25677 + if (wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie) != A_OK) {
25678 + wlan_node_free(bss);
25679 + return A_EINVAL;
25680 + }
25681 +
25682 + /*
25683 + * Update the frequency in ie_chan, overwriting of channel number
25684 + * which is done in wlan_parse_beacon
25685 + */
25686 + bss->ni_cie.ie_chan = bih->channel;
25687 + wlan_setup_node(&wmip->wmi_scan_table, bss, bih->bssid);
25688 +
25689 + return A_OK;
25690 +}
25691 +
25692 +static A_STATUS
25693 +wmi_opt_frame_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25694 +{
25695 + bss_t *bss;
25696 + WMI_OPT_RX_INFO_HDR *bih;
25697 + A_UINT8 *buf;
25698 +
25699 + if (len <= sizeof(WMI_OPT_RX_INFO_HDR)) {
25700 + return A_EINVAL;
25701 + }
25702 +
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);
25706 +
25707 + A_DPRINTF(DBG_WMI2, (DBGFMT "opt frame event %2.2x:%2.2x\n", DBGARG,
25708 + bih->bssid[4], bih->bssid[5]));
25709 +
25710 + bss = wlan_find_node(&wmip->wmi_scan_table, bih->bssid);
25711 + if (bss != NULL) {
25712 + /*
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
25715 + * adequate.
25716 + */
25717 + wlan_node_reclaim(&wmip->wmi_scan_table, bss);
25718 + }
25719 +
25720 + bss = wlan_node_alloc(&wmip->wmi_scan_table, len);
25721 + if (bss == NULL) {
25722 + return A_NO_MEMORY;
25723 + }
25724 +
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);
25730 +
25731 + return A_OK;
25732 +}
25733 +
25734 + /* This event indicates inactivity timeout of a fatpipe(pstream)
25735 + * at the target
25736 + */
25737 +static A_STATUS
25738 +wmi_pstream_timeout_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25739 +{
25740 + WMI_PSTREAM_TIMEOUT_EVENT *ev;
25741 +
25742 + if (len < sizeof(WMI_PSTREAM_TIMEOUT_EVENT)) {
25743 + return A_EINVAL;
25744 + }
25745 +
25746 + A_DPRINTF(DBG_WMI, (DBGFMT "wmi_pstream_timeout_event_rx\n", DBGARG));
25747 +
25748 + ev = (WMI_PSTREAM_TIMEOUT_EVENT *)datap;
25749 +
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.
25754 + */
25755 + /* Set the activeTsids for this AC to 0 */
25756 + LOCK_WMI(wmip);
25757 + wmip->wmi_streamExistsForAC[ev->trafficClass]=0;
25758 + wmip->wmi_fatPipeExists &= ~(1 << ev->trafficClass);
25759 + UNLOCK_WMI(wmip);
25760 +
25761 + /*Indicate inactivity to driver layer for this fatpipe (pstream)*/
25762 + A_WMI_STREAM_TX_INACTIVE(wmip->wmi_devt, ev->trafficClass);
25763 +
25764 + return A_OK;
25765 +}
25766 +
25767 +static A_STATUS
25768 +wmi_bitrate_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25769 +{
25770 + WMI_BIT_RATE_CMD *reply;
25771 + A_INT32 rate;
25772 +
25773 + if (len < sizeof(WMI_BIT_RATE_CMD)) {
25774 + return A_EINVAL;
25775 + }
25776 + reply = (WMI_BIT_RATE_CMD *)datap;
25777 + A_DPRINTF(DBG_WMI,
25778 + (DBGFMT "Enter - rateindex %d\n", DBGARG, reply->rateIndex));
25779 +
25780 + if (reply->rateIndex == RATE_AUTO) {
25781 + rate = RATE_AUTO;
25782 + } else {
25783 + rate = wmi_rateTable[(A_UINT32) reply->rateIndex];
25784 + }
25785 +
25786 + A_WMI_BITRATE_RX(wmip->wmi_devt, rate);
25787 +
25788 + return A_OK;
25789 +}
25790 +
25791 +static A_STATUS
25792 +wmi_ratemask_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25793 +{
25794 + WMI_FIX_RATES_CMD *reply;
25795 +
25796 + if (len < sizeof(WMI_BIT_RATE_CMD)) {
25797 + return A_EINVAL;
25798 + }
25799 + reply = (WMI_FIX_RATES_CMD *)datap;
25800 + A_DPRINTF(DBG_WMI,
25801 + (DBGFMT "Enter - fixed rate mask %x\n", DBGARG, reply->fixRateMask));
25802 +
25803 + A_WMI_RATEMASK_RX(wmip->wmi_devt, reply->fixRateMask);
25804 +
25805 + return A_OK;
25806 +}
25807 +
25808 +static A_STATUS
25809 +wmi_channelList_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25810 +{
25811 + WMI_CHANNEL_LIST_REPLY *reply;
25812 +
25813 + if (len < sizeof(WMI_CHANNEL_LIST_REPLY)) {
25814 + return A_EINVAL;
25815 + }
25816 + reply = (WMI_CHANNEL_LIST_REPLY *)datap;
25817 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25818 +
25819 + A_WMI_CHANNELLIST_RX(wmip->wmi_devt, reply->numChannels,
25820 + reply->channelList);
25821 +
25822 + return A_OK;
25823 +}
25824 +
25825 +static A_STATUS
25826 +wmi_txPwr_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25827 +{
25828 + WMI_TX_PWR_REPLY *reply;
25829 +
25830 + if (len < sizeof(*reply)) {
25831 + return A_EINVAL;
25832 + }
25833 + reply = (WMI_TX_PWR_REPLY *)datap;
25834 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25835 +
25836 + A_WMI_TXPWR_RX(wmip->wmi_devt, reply->dbM);
25837 +
25838 + return A_OK;
25839 +}
25840 +static A_STATUS
25841 +wmi_keepalive_reply_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25842 +{
25843 + WMI_GET_KEEPALIVE_CMD *reply;
25844 +
25845 + if (len < sizeof(*reply)) {
25846 + return A_EINVAL;
25847 + }
25848 + reply = (WMI_GET_KEEPALIVE_CMD *)datap;
25849 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25850 +
25851 + A_WMI_KEEPALIVE_RX(wmip->wmi_devt, reply->configured);
25852 +
25853 + return A_OK;
25854 +}
25855 +
25856 +
25857 +static A_STATUS
25858 +wmi_dset_open_req_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25859 +{
25860 + WMIX_DSETOPENREQ_EVENT *dsetopenreq;
25861 +
25862 + if (len < sizeof(WMIX_DSETOPENREQ_EVENT)) {
25863 + return A_EINVAL;
25864 + }
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);
25873 +
25874 + return A_OK;
25875 +}
25876 +
25877 +#ifdef CONFIG_HOST_DSET_SUPPORT
25878 +static A_STATUS
25879 +wmi_dset_close_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25880 +{
25881 + WMIX_DSETCLOSE_EVENT *dsetclose;
25882 +
25883 + if (len < sizeof(WMIX_DSETCLOSE_EVENT)) {
25884 + return A_EINVAL;
25885 + }
25886 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25887 +
25888 + dsetclose = (WMIX_DSETCLOSE_EVENT *)datap;
25889 + A_WMI_DSET_CLOSE(wmip->wmi_devt, dsetclose->access_cookie);
25890 +
25891 + return A_OK;
25892 +}
25893 +
25894 +static A_STATUS
25895 +wmi_dset_data_req_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25896 +{
25897 + WMIX_DSETDATAREQ_EVENT *dsetdatareq;
25898 +
25899 + if (len < sizeof(WMIX_DSETDATAREQ_EVENT)) {
25900 + return A_EINVAL;
25901 + }
25902 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25903 +
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);
25912 +
25913 + return A_OK;
25914 +}
25915 +#endif /* CONFIG_HOST_DSET_SUPPORT */
25916 +
25917 +static A_STATUS
25918 +wmi_scanComplete_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25919 +{
25920 + WMI_SCAN_COMPLETE_EVENT *ev;
25921 +
25922 + ev = (WMI_SCAN_COMPLETE_EVENT *)datap;
25923 + A_WMI_SCANCOMPLETE_EVENT(wmip->wmi_devt, ev->status);
25924 +
25925 + return A_OK;
25926 +}
25927 +
25928 +/*
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.
25934 + */
25935 +static A_STATUS
25936 +wmi_errorEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25937 +{
25938 + WMI_CMD_ERROR_EVENT *ev;
25939 +
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"));
25945 + break;
25946 + case (ILLEGAL_STATE):
25947 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Illegal State\n"));
25948 + break;
25949 + case (INTERNAL_ERROR):
25950 + AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Internal Error\n"));
25951 + break;
25952 + }
25953 +
25954 + return A_OK;
25955 +}
25956 +
25957 +
25958 +static A_STATUS
25959 +wmi_statsEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25960 +{
25961 + WMI_TARGET_STATS *reply;
25962 +
25963 + if (len < sizeof(*reply)) {
25964 + return A_EINVAL;
25965 + }
25966 + reply = (WMI_TARGET_STATS *)datap;
25967 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25968 +
25969 + A_WMI_TARGETSTATS_EVENT(wmip->wmi_devt, reply);
25970 +
25971 + return A_OK;
25972 +}
25973 +
25974 +static A_STATUS
25975 +wmi_rssiThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25976 +{
25977 + WMI_RSSI_THRESHOLD_EVENT *reply;
25978 +
25979 + if (len < sizeof(*reply)) {
25980 + return A_EINVAL;
25981 + }
25982 + reply = (WMI_RSSI_THRESHOLD_EVENT *)datap;
25983 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
25984 +
25985 + A_WMI_RSSI_THRESHOLD_EVENT(wmip->wmi_devt, reply->range, reply->rssi);
25986 +
25987 + return A_OK;
25988 +}
25989 +
25990 +
25991 +static A_STATUS
25992 +wmi_reportErrorEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
25993 +{
25994 + WMI_TARGET_ERROR_REPORT_EVENT *reply;
25995 +
25996 + if (len < sizeof(*reply)) {
25997 + return A_EINVAL;
25998 + }
25999 + reply = (WMI_TARGET_ERROR_REPORT_EVENT *)datap;
26000 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26001 +
26002 + A_WMI_REPORT_ERROR_EVENT(wmip->wmi_devt, reply->errorVal);
26003 +
26004 + return A_OK;
26005 +}
26006 +
26007 +static A_STATUS
26008 +wmi_cac_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26009 +{
26010 + WMI_CAC_EVENT *reply;
26011 +
26012 + if (len < sizeof(*reply)) {
26013 + return A_EINVAL;
26014 + }
26015 + reply = (WMI_CAC_EVENT *)datap;
26016 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26017 +
26018 + A_WMI_CAC_EVENT(wmip->wmi_devt, reply->ac,
26019 + reply->cac_indication, reply->statusCode,
26020 + reply->tspecSuggestion);
26021 +
26022 + return A_OK;
26023 +}
26024 +
26025 +static A_STATUS
26026 +wmi_hbChallengeResp_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26027 +{
26028 + WMIX_HB_CHALLENGE_RESP_EVENT *reply;
26029 +
26030 + if (len < sizeof(*reply)) {
26031 + return A_EINVAL;
26032 + }
26033 + reply = (WMIX_HB_CHALLENGE_RESP_EVENT *)datap;
26034 + A_DPRINTF(DBG_WMI, (DBGFMT "wmi: challenge response event\n", DBGARG));
26035 +
26036 + A_WMI_HBCHALLENGERESP_EVENT(wmip->wmi_devt, reply->cookie, reply->source);
26037 +
26038 + return A_OK;
26039 +}
26040 +
26041 +static A_STATUS
26042 +wmi_roam_tbl_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26043 +{
26044 + WMI_TARGET_ROAM_TBL *reply;
26045 +
26046 + if (len < sizeof(*reply)) {
26047 + return A_EINVAL;
26048 + }
26049 + reply = (WMI_TARGET_ROAM_TBL *)datap;
26050 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26051 +
26052 + A_WMI_ROAM_TABLE_EVENT(wmip->wmi_devt, reply);
26053 +
26054 + return A_OK;
26055 +}
26056 +
26057 +static A_STATUS
26058 +wmi_roam_data_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26059 +{
26060 + WMI_TARGET_ROAM_DATA *reply;
26061 +
26062 + if (len < sizeof(*reply)) {
26063 + return A_EINVAL;
26064 + }
26065 + reply = (WMI_TARGET_ROAM_DATA *)datap;
26066 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26067 +
26068 + A_WMI_ROAM_DATA_EVENT(wmip->wmi_devt, reply);
26069 +
26070 + return A_OK;
26071 +}
26072 +
26073 +static A_STATUS
26074 +wmi_txRetryErrEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26075 +{
26076 + WMI_TX_RETRY_ERR_EVENT *reply;
26077 +
26078 + if (len < sizeof(*reply)) {
26079 + return A_EINVAL;
26080 + }
26081 + reply = (WMI_TX_RETRY_ERR_EVENT *)datap;
26082 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26083 +
26084 + A_WMI_TX_RETRY_ERR_EVENT(wmip->wmi_devt);
26085 +
26086 + return A_OK;
26087 +}
26088 +
26089 +static A_STATUS
26090 +wmi_snrThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26091 +{
26092 + WMI_SNR_THRESHOLD_EVENT *reply;
26093 +
26094 + if (len < sizeof(*reply)) {
26095 + return A_EINVAL;
26096 + }
26097 + reply = (WMI_SNR_THRESHOLD_EVENT *)datap;
26098 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26099 +
26100 + A_WMI_SNR_THRESHOLD_EVENT_RX(wmip->wmi_devt, reply->range, reply->snr);
26101 +
26102 + return A_OK;
26103 +}
26104 +
26105 +static A_STATUS
26106 +wmi_lqThresholdEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26107 +{
26108 + WMI_LQ_THRESHOLD_EVENT *reply;
26109 +
26110 + if (len < sizeof(*reply)) {
26111 + return A_EINVAL;
26112 + }
26113 + reply = (WMI_LQ_THRESHOLD_EVENT *)datap;
26114 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26115 +
26116 + A_WMI_LQ_THRESHOLD_EVENT_RX(wmip->wmi_devt, reply->range, reply->lq);
26117 +
26118 + return A_OK;
26119 +}
26120 +
26121 +static A_STATUS
26122 +wmi_aplistEvent_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26123 +{
26124 + A_UINT16 ap_info_entry_size;
26125 + WMI_APLIST_EVENT *ev = (WMI_APLIST_EVENT *)datap;
26126 + WMI_AP_INFO_V1 *ap_info_v1;
26127 + A_UINT8 i;
26128 +
26129 + if (len < sizeof(WMI_APLIST_EVENT)) {
26130 + return A_EINVAL;
26131 + }
26132 +
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;
26136 + } else {
26137 + return A_EINVAL;
26138 + }
26139 +
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))
26143 + {
26144 + return A_EINVAL;
26145 + }
26146 +
26147 + /*
26148 + * AP List Ver1 Contents
26149 + */
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));
26157 + ap_info_v1++;
26158 + }
26159 + return A_OK;
26160 +}
26161 +
26162 +static A_STATUS
26163 +wmi_dbglog_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26164 +{
26165 + A_UINT32 dropped;
26166 +
26167 + dropped = *((A_UINT32 *)datap);
26168 + datap += sizeof(dropped);
26169 + len -= sizeof(dropped);
26170 + A_WMI_DBGLOG_EVENT(wmip->wmi_devt, dropped, datap, len);
26171 + return A_OK;
26172 +}
26173 +
26174 +#ifdef CONFIG_HOST_GPIO_SUPPORT
26175 +static A_STATUS
26176 +wmi_gpio_intr_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26177 +{
26178 + WMIX_GPIO_INTR_EVENT *gpio_intr = (WMIX_GPIO_INTR_EVENT *)datap;
26179 +
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));
26183 +
26184 + A_WMI_GPIO_INTR_RX(gpio_intr->intr_mask, gpio_intr->input_values);
26185 +
26186 + return A_OK;
26187 +}
26188 +
26189 +static A_STATUS
26190 +wmi_gpio_data_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26191 +{
26192 + WMIX_GPIO_DATA_EVENT *gpio_data = (WMIX_GPIO_DATA_EVENT *)datap;
26193 +
26194 + A_DPRINTF(DBG_WMI,
26195 + (DBGFMT "Enter - reg=%d value=0x%x\n", DBGARG,
26196 + gpio_data->reg_id, gpio_data->value));
26197 +
26198 + A_WMI_GPIO_DATA_RX(gpio_data->reg_id, gpio_data->value);
26199 +
26200 + return A_OK;
26201 +}
26202 +
26203 +static A_STATUS
26204 +wmi_gpio_ack_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
26205 +{
26206 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26207 +
26208 + A_WMI_GPIO_ACK_RX();
26209 +
26210 + return A_OK;
26211 +}
26212 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
26213 +
26214 +/*
26215 + * Called to send a wmi command. Command specific data is already built
26216 + * on osbuf and current osbuf->data points to it.
26217 + */
26218 +A_STATUS
26219 +wmi_cmd_send(struct wmi_t *wmip, void *osbuf, WMI_COMMAND_ID cmdId,
26220 + WMI_SYNC_FLAG syncflag)
26221 +{
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;
26225 +
26226 + A_ASSERT(osbuf != NULL);
26227 +
26228 + if (syncflag >= END_WMIFLAG) {
26229 + return A_EINVAL;
26230 + }
26231 +
26232 + if ((syncflag == SYNC_BEFORE_WMIFLAG) || (syncflag == SYNC_BOTH_WMIFLAG)) {
26233 + /*
26234 + * We want to make sure all data currently queued is transmitted before
26235 + * the cmd execution. Establish a new sync point.
26236 + */
26237 + wmi_sync_point(wmip);
26238 + }
26239 +
26240 + if (A_NETBUF_PUSH(osbuf, sizeof(WMI_CMD_HDR)) != A_OK) {
26241 + return A_NO_MEMORY;
26242 + }
26243 +
26244 + cHdr = (WMI_CMD_HDR *)A_NETBUF_DATA(osbuf);
26245 + cHdr->commandId = cmdId;
26246 +
26247 + /*
26248 + * Send cmd, some via control pipe, others via data pipe
26249 + */
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;
26254 + }
26255 + A_WMI_CONTROL_TX(wmip->wmi_devt, osbuf, streamID);
26256 +
26257 + if ((syncflag == SYNC_AFTER_WMIFLAG) || (syncflag == SYNC_BOTH_WMIFLAG)) {
26258 + /*
26259 + * We want to make sure all new data queued waits for the command to
26260 + * execute. Establish a new sync point.
26261 + */
26262 + wmi_sync_point(wmip);
26263 + }
26264 + return (A_OK);
26265 +#undef IS_LONG_CMD
26266 +}
26267 +
26268 +A_STATUS
26269 +wmi_cmd_send_xtnd(struct wmi_t *wmip, void *osbuf, WMI_COMMAND_ID cmdId,
26270 + WMI_SYNC_FLAG syncflag)
26271 +{
26272 + WMIX_CMD_HDR *cHdr;
26273 +
26274 + if (A_NETBUF_PUSH(osbuf, sizeof(WMIX_CMD_HDR)) != A_OK) {
26275 + return A_NO_MEMORY;
26276 + }
26277 +
26278 + cHdr = (WMIX_CMD_HDR *)A_NETBUF_DATA(osbuf);
26279 + cHdr->commandId = cmdId;
26280 +
26281 + return wmi_cmd_send(wmip, osbuf, WMI_EXTENSION_CMDID, syncflag);
26282 +}
26283 +
26284 +A_STATUS
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)
26291 +{
26292 + void *osbuf;
26293 + WMI_CONNECT_CMD *cc;
26294 +
26295 + if ((pairwiseCrypto == NONE_CRYPT) && (groupCrypto != NONE_CRYPT)) {
26296 + return A_EINVAL;
26297 + }
26298 + if ((pairwiseCrypto != NONE_CRYPT) && (groupCrypto == NONE_CRYPT)) {
26299 + return A_EINVAL;
26300 + }
26301 +
26302 + osbuf = A_NETBUF_ALLOC(sizeof(WMI_CONNECT_CMD));
26303 + if (osbuf == NULL) {
26304 + return A_NO_MEMORY;
26305 + }
26306 +
26307 + A_NETBUF_PUT(osbuf, sizeof(WMI_CONNECT_CMD));
26308 +
26309 + cc = (WMI_CONNECT_CMD *)(A_NETBUF_DATA(osbuf));
26310 + A_MEMZERO(cc, sizeof(*cc));
26311 +
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;
26323 +
26324 + if (bssid != NULL) {
26325 + A_MEMCPY(cc->bssid, bssid, ATH_MAC_LEN);
26326 + }
26327 + if (wmi_set_keepalive_cmd(wmip, wmip->wmi_keepaliveInterval) != A_OK) {
26328 + return(A_ERROR);
26329 + }
26330 +
26331 + return (wmi_cmd_send(wmip, osbuf, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG));
26332 +}
26333 +
26334 +A_STATUS
26335 +wmi_reconnect_cmd(struct wmi_t *wmip, A_UINT8 *bssid, A_UINT16 channel)
26336 +{
26337 + void *osbuf;
26338 + WMI_RECONNECT_CMD *cc;
26339 +
26340 + osbuf = A_NETBUF_ALLOC(sizeof(WMI_RECONNECT_CMD));
26341 + if (osbuf == NULL) {
26342 + return A_NO_MEMORY;
26343 + }
26344 +
26345 + A_NETBUF_PUT(osbuf, sizeof(WMI_RECONNECT_CMD));
26346 +
26347 + cc = (WMI_RECONNECT_CMD *)(A_NETBUF_DATA(osbuf));
26348 + A_MEMZERO(cc, sizeof(*cc));
26349 +
26350 + cc->channel = channel;
26351 +
26352 + if (bssid != NULL) {
26353 + A_MEMCPY(cc->bssid, bssid, ATH_MAC_LEN);
26354 + }
26355 +
26356 + return (wmi_cmd_send(wmip, osbuf, WMI_RECONNECT_CMDID, NO_SYNC_WMIFLAG));
26357 +}
26358 +
26359 +A_STATUS
26360 +wmi_disconnect_cmd(struct wmi_t *wmip)
26361 +{
26362 + void *osbuf;
26363 + A_STATUS status;
26364 +
26365 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
26366 + if (osbuf == NULL) {
26367 + return A_NO_MEMORY;
26368 + }
26369 +
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));
26374 +
26375 + return status;
26376 +}
26377 +
26378 +A_STATUS
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)
26382 +{
26383 + void *osbuf;
26384 + WMI_START_SCAN_CMD *sc;
26385 +
26386 + if ((scanType != WMI_LONG_SCAN) && (scanType != WMI_SHORT_SCAN)) {
26387 + return A_EINVAL;
26388 + }
26389 +
26390 + osbuf = A_NETBUF_ALLOC(sizeof(*sc));
26391 + if (osbuf == NULL) {
26392 + return A_NO_MEMORY;
26393 + }
26394 +
26395 + A_NETBUF_PUT(osbuf, sizeof(*sc));
26396 +
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;
26403 +
26404 + return (wmi_cmd_send(wmip, osbuf, WMI_START_SCAN_CMDID, NO_SYNC_WMIFLAG));
26405 +}
26406 +
26407 +A_STATUS
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)
26414 +{
26415 + void *osbuf;
26416 + WMI_SCAN_PARAMS_CMD *sc;
26417 +
26418 + osbuf = A_NETBUF_ALLOC(sizeof(*sc));
26419 + if (osbuf == NULL) {
26420 + return A_NO_MEMORY;
26421 + }
26422 +
26423 + A_NETBUF_PUT(osbuf, sizeof(*sc));
26424 +
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;
26436 +
26437 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_SCAN_PARAMS_CMDID,
26438 + NO_SYNC_WMIFLAG));
26439 +}
26440 +
26441 +A_STATUS
26442 +wmi_bssfilter_cmd(struct wmi_t *wmip, A_UINT8 filter, A_UINT32 ieMask)
26443 +{
26444 + void *osbuf;
26445 + WMI_BSS_FILTER_CMD *cmd;
26446 +
26447 + if (filter >= LAST_BSS_FILTER) {
26448 + return A_EINVAL;
26449 + }
26450 +
26451 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26452 + if (osbuf == NULL) {
26453 + return A_NO_MEMORY;
26454 + }
26455 +
26456 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26457 +
26458 + cmd = (WMI_BSS_FILTER_CMD *)(A_NETBUF_DATA(osbuf));
26459 + A_MEMZERO(cmd, sizeof(*cmd));
26460 + cmd->bssFilter = filter;
26461 + cmd->ieMask = ieMask;
26462 +
26463 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BSS_FILTER_CMDID,
26464 + NO_SYNC_WMIFLAG));
26465 +}
26466 +
26467 +A_STATUS
26468 +wmi_probedSsid_cmd(struct wmi_t *wmip, A_UINT8 index, A_UINT8 flag,
26469 + A_UINT8 ssidLength, A_UCHAR *ssid)
26470 +{
26471 + void *osbuf;
26472 + WMI_PROBED_SSID_CMD *cmd;
26473 +
26474 + if (index > MAX_PROBED_SSID_INDEX) {
26475 + return A_EINVAL;
26476 + }
26477 + if (ssidLength > sizeof(cmd->ssid)) {
26478 + return A_EINVAL;
26479 + }
26480 + if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssidLength > 0)) {
26481 + return A_EINVAL;
26482 + }
26483 + if ((flag & SPECIFIC_SSID_FLAG) && !ssidLength) {
26484 + return A_EINVAL;
26485 + }
26486 +
26487 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26488 + if (osbuf == NULL) {
26489 + return A_NO_MEMORY;
26490 + }
26491 +
26492 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26493 +
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);
26500 +
26501 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_PROBED_SSID_CMDID,
26502 + NO_SYNC_WMIFLAG));
26503 +}
26504 +
26505 +A_STATUS
26506 +wmi_listeninterval_cmd(struct wmi_t *wmip, A_UINT16 listenInterval, A_UINT16 listenBeacons)
26507 +{
26508 + void *osbuf;
26509 + WMI_LISTEN_INT_CMD *cmd;
26510 +
26511 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26512 + if (osbuf == NULL) {
26513 + return A_NO_MEMORY;
26514 + }
26515 +
26516 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26517 +
26518 + cmd = (WMI_LISTEN_INT_CMD *)(A_NETBUF_DATA(osbuf));
26519 + A_MEMZERO(cmd, sizeof(*cmd));
26520 + cmd->listenInterval = listenInterval;
26521 + cmd->numBeacons = listenBeacons;
26522 +
26523 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_LISTEN_INT_CMDID,
26524 + NO_SYNC_WMIFLAG));
26525 +}
26526 +
26527 +A_STATUS
26528 +wmi_bmisstime_cmd(struct wmi_t *wmip, A_UINT16 bmissTime, A_UINT16 bmissBeacons)
26529 +{
26530 + void *osbuf;
26531 + WMI_BMISS_TIME_CMD *cmd;
26532 +
26533 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26534 + if (osbuf == NULL) {
26535 + return A_NO_MEMORY;
26536 + }
26537 +
26538 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26539 +
26540 + cmd = (WMI_BMISS_TIME_CMD *)(A_NETBUF_DATA(osbuf));
26541 + A_MEMZERO(cmd, sizeof(*cmd));
26542 + cmd->bmissTime = bmissTime;
26543 + cmd->numBeacons = bmissBeacons;
26544 +
26545 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BMISS_TIME_CMDID,
26546 + NO_SYNC_WMIFLAG));
26547 +}
26548 +
26549 +A_STATUS
26550 +wmi_associnfo_cmd(struct wmi_t *wmip, A_UINT8 ieType,
26551 + A_UINT8 ieLen, A_UINT8 *ieInfo)
26552 +{
26553 + void *osbuf;
26554 + WMI_SET_ASSOC_INFO_CMD *cmd;
26555 + A_UINT16 cmdLen;
26556 +
26557 + cmdLen = sizeof(*cmd) + ieLen - 1;
26558 + osbuf = A_NETBUF_ALLOC(cmdLen);
26559 + if (osbuf == NULL) {
26560 + return A_NO_MEMORY;
26561 + }
26562 +
26563 + A_NETBUF_PUT(osbuf, cmdLen);
26564 +
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);
26570 +
26571 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_ASSOC_INFO_CMDID,
26572 + NO_SYNC_WMIFLAG));
26573 +}
26574 +
26575 +A_STATUS
26576 +wmi_powermode_cmd(struct wmi_t *wmip, A_UINT8 powerMode)
26577 +{
26578 + void *osbuf;
26579 + WMI_POWER_MODE_CMD *cmd;
26580 +
26581 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26582 + if (osbuf == NULL) {
26583 + return A_NO_MEMORY;
26584 + }
26585 +
26586 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26587 +
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;
26592 +
26593 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWER_MODE_CMDID,
26594 + NO_SYNC_WMIFLAG));
26595 +}
26596 +
26597 +A_STATUS
26598 +wmi_ibsspmcaps_cmd(struct wmi_t *wmip, A_UINT8 pmEnable, A_UINT8 ttl,
26599 + A_UINT16 atim_windows, A_UINT16 timeout_value)
26600 +{
26601 + void *osbuf;
26602 + WMI_IBSS_PM_CAPS_CMD *cmd;
26603 +
26604 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26605 + if (osbuf == NULL) {
26606 + return A_NO_MEMORY;
26607 + }
26608 +
26609 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26610 +
26611 + cmd = (WMI_IBSS_PM_CAPS_CMD *)(A_NETBUF_DATA(osbuf));
26612 + A_MEMZERO(cmd, sizeof(*cmd));
26613 + cmd->power_saving = pmEnable;
26614 + cmd->ttl = ttl;
26615 + cmd->atim_windows = atim_windows;
26616 + cmd->timeout_value = timeout_value;
26617 +
26618 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_IBSS_PM_CAPS_CMDID,
26619 + NO_SYNC_WMIFLAG));
26620 +}
26621 +
26622 +A_STATUS
26623 +wmi_pmparams_cmd(struct wmi_t *wmip, A_UINT16 idlePeriod,
26624 + A_UINT16 psPollNum, A_UINT16 dtimPolicy)
26625 +{
26626 + void *osbuf;
26627 + WMI_POWER_PARAMS_CMD *pm;
26628 +
26629 + osbuf = A_NETBUF_ALLOC(sizeof(*pm));
26630 + if (osbuf == NULL) {
26631 + return A_NO_MEMORY;
26632 + }
26633 +
26634 + A_NETBUF_PUT(osbuf, sizeof(*pm));
26635 +
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;
26641 +
26642 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWER_PARAMS_CMDID,
26643 + NO_SYNC_WMIFLAG));
26644 +}
26645 +
26646 +A_STATUS
26647 +wmi_disctimeout_cmd(struct wmi_t *wmip, A_UINT8 timeout)
26648 +{
26649 + void *osbuf;
26650 + WMI_DISC_TIMEOUT_CMD *cmd;
26651 +
26652 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26653 + if (osbuf == NULL) {
26654 + return A_NO_MEMORY;
26655 + }
26656 +
26657 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26658 +
26659 + cmd = (WMI_DISC_TIMEOUT_CMD *)(A_NETBUF_DATA(osbuf));
26660 + A_MEMZERO(cmd, sizeof(*cmd));
26661 + cmd->disconnectTimeout = timeout;
26662 +
26663 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_DISC_TIMEOUT_CMDID,
26664 + NO_SYNC_WMIFLAG));
26665 +}
26666 +
26667 +A_STATUS
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)
26672 +{
26673 + void *osbuf;
26674 + WMI_ADD_CIPHER_KEY_CMD *cmd;
26675 +
26676 + if ((keyIndex > WMI_MAX_KEY_INDEX) || (keyLength > WMI_MAX_KEY_LEN) ||
26677 + (keyMaterial == NULL))
26678 + {
26679 + return A_EINVAL;
26680 + }
26681 +
26682 + if ((WEP_CRYPT != keyType) && (NULL == keyRSC)) {
26683 + return A_EINVAL;
26684 + }
26685 +
26686 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26687 + if (osbuf == NULL) {
26688 + return A_NO_MEMORY;
26689 + }
26690 +
26691 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26692 +
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));
26702 + }
26703 + cmd->key_op_ctrl = key_op_ctrl;
26704 +
26705 + return (wmi_cmd_send(wmip, osbuf, WMI_ADD_CIPHER_KEY_CMDID, sync_flag));
26706 +}
26707 +
26708 +A_STATUS
26709 +wmi_add_krk_cmd(struct wmi_t *wmip, A_UINT8 *krk)
26710 +{
26711 + void *osbuf;
26712 + WMI_ADD_KRK_CMD *cmd;
26713 +
26714 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26715 +
26716 + if (osbuf == NULL) {
26717 + return A_NO_MEMORY;
26718 + }
26719 +
26720 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26721 +
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);
26725 +
26726 + return (wmi_cmd_send(wmip, osbuf, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG));
26727 +}
26728 +
26729 +A_STATUS
26730 +wmi_delete_krk_cmd(struct wmi_t *wmip)
26731 +{
26732 + void *osbuf;
26733 +
26734 + osbuf = A_NETBUF_ALLOC(0);
26735 +
26736 + if (osbuf == NULL) {
26737 + return A_NO_MEMORY;
26738 + }
26739 +
26740 + return (wmi_cmd_send(wmip, osbuf, WMI_DELETE_KRK_CMDID, NO_SYNC_WMIFLAG));
26741 +}
26742 +
26743 +A_STATUS
26744 +wmi_deleteKey_cmd(struct wmi_t *wmip, A_UINT8 keyIndex)
26745 +{
26746 + void *osbuf;
26747 + WMI_DELETE_CIPHER_KEY_CMD *cmd;
26748 +
26749 + if (keyIndex > WMI_MAX_KEY_INDEX) {
26750 + return A_EINVAL;
26751 + }
26752 +
26753 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26754 + if (osbuf == NULL) {
26755 + return A_NO_MEMORY;
26756 + }
26757 +
26758 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26759 +
26760 + cmd = (WMI_DELETE_CIPHER_KEY_CMD *)(A_NETBUF_DATA(osbuf));
26761 + A_MEMZERO(cmd, sizeof(*cmd));
26762 + cmd->keyIndex = keyIndex;
26763 +
26764 + return (wmi_cmd_send(wmip, osbuf, WMI_DELETE_CIPHER_KEY_CMDID,
26765 + NO_SYNC_WMIFLAG));
26766 +}
26767 +
26768 +A_STATUS
26769 +wmi_setPmkid_cmd(struct wmi_t *wmip, A_UINT8 *bssid, A_UINT8 *pmkId,
26770 + A_BOOL set)
26771 +{
26772 + void *osbuf;
26773 + WMI_SET_PMKID_CMD *cmd;
26774 +
26775 + if (bssid == NULL) {
26776 + return A_EINVAL;
26777 + }
26778 +
26779 + if ((set == TRUE) && (pmkId == NULL)) {
26780 + return A_EINVAL;
26781 + }
26782 +
26783 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26784 + if (osbuf == NULL) {
26785 + return A_NO_MEMORY;
26786 + }
26787 +
26788 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26789 +
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;
26795 + } else {
26796 + A_MEMZERO(cmd->pmkid, sizeof(cmd->pmkid));
26797 + cmd->enable = PMKID_DISABLE;
26798 + }
26799 +
26800 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_PMKID_CMDID, NO_SYNC_WMIFLAG));
26801 +}
26802 +
26803 +A_STATUS
26804 +wmi_set_tkip_countermeasures_cmd(struct wmi_t *wmip, A_BOOL en)
26805 +{
26806 + void *osbuf;
26807 + WMI_SET_TKIP_COUNTERMEASURES_CMD *cmd;
26808 +
26809 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26810 + if (osbuf == NULL) {
26811 + return A_NO_MEMORY;
26812 + }
26813 +
26814 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26815 +
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;
26818 +
26819 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_TKIP_COUNTERMEASURES_CMDID,
26820 + NO_SYNC_WMIFLAG));
26821 +}
26822 +
26823 +A_STATUS
26824 +wmi_set_akmp_params_cmd(struct wmi_t *wmip,
26825 + WMI_SET_AKMP_PARAMS_CMD *akmpParams)
26826 +{
26827 + void *osbuf;
26828 + WMI_SET_AKMP_PARAMS_CMD *cmd;
26829 +
26830 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
26831 + if (osbuf == NULL) {
26832 + return A_NO_MEMORY;
26833 + }
26834 +
26835 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
26836 + cmd = (WMI_SET_AKMP_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
26837 + cmd->akmpInfo = akmpParams->akmpInfo;
26838 +
26839 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_AKMP_PARAMS_CMDID,
26840 + NO_SYNC_WMIFLAG));
26841 +}
26842 +
26843 +A_STATUS
26844 +wmi_set_pmkid_list_cmd(struct wmi_t *wmip,
26845 + WMI_SET_PMKID_LIST_CMD *pmkInfo)
26846 +{
26847 + void *osbuf;
26848 + WMI_SET_PMKID_LIST_CMD *cmd;
26849 + A_UINT16 cmdLen;
26850 + A_UINT8 i;
26851 +
26852 + cmdLen = sizeof(pmkInfo->numPMKID) +
26853 + pmkInfo->numPMKID * sizeof(WMI_PMKID);
26854 +
26855 + osbuf = A_NETBUF_ALLOC(cmdLen);
26856 +
26857 + if (osbuf == NULL) {
26858 + return A_NO_MEMORY;
26859 + }
26860 +
26861 + A_NETBUF_PUT(osbuf, cmdLen);
26862 + cmd = (WMI_SET_PMKID_LIST_CMD *)(A_NETBUF_DATA(osbuf));
26863 + cmd->numPMKID = pmkInfo->numPMKID;
26864 +
26865 + for (i = 0; i < cmd->numPMKID; i++) {
26866 + A_MEMCPY(&cmd->pmkidList[i], &pmkInfo->pmkidList[i],
26867 + WMI_PMKID_LEN);
26868 + }
26869 +
26870 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_PMKID_LIST_CMDID,
26871 + NO_SYNC_WMIFLAG));
26872 +}
26873 +
26874 +A_STATUS
26875 +wmi_get_pmkid_list_cmd(struct wmi_t *wmip)
26876 +{
26877 + void *osbuf;
26878 +
26879 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
26880 + if (osbuf == NULL) {
26881 + return A_NO_MEMORY;
26882 + }
26883 +
26884 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_PMKID_LIST_CMDID,
26885 + NO_SYNC_WMIFLAG));
26886 +}
26887 +
26888 +A_STATUS
26889 +wmi_dataSync_send(struct wmi_t *wmip, void *osbuf, WMI_PRI_STREAM_ID streamID)
26890 +{
26891 + WMI_DATA_HDR *dtHdr;
26892 +
26893 + A_ASSERT(streamID != WMI_CONTROL_PRI);
26894 + A_ASSERT(osbuf != NULL);
26895 +
26896 + if (A_NETBUF_PUSH(osbuf, sizeof(WMI_DATA_HDR)) != A_OK) {
26897 + return A_NO_MEMORY;
26898 + }
26899 +
26900 + dtHdr = (WMI_DATA_HDR *)A_NETBUF_DATA(osbuf);
26901 + dtHdr->info =
26902 + (SYNC_MSGTYPE & WMI_DATA_HDR_MSG_TYPE_MASK) << WMI_DATA_HDR_MSG_TYPE_SHIFT;
26903 +
26904 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter - streamID %d\n", DBGARG, streamID));
26905 +
26906 + return (A_WMI_CONTROL_TX(wmip->wmi_devt, osbuf, streamID));
26907 +}
26908 +
26909 +typedef struct _WMI_DATA_SYNC_BUFS {
26910 + A_UINT8 trafficClass;
26911 + void *osbuf;
26912 +}WMI_DATA_SYNC_BUFS;
26913 +
26914 +static A_STATUS
26915 +wmi_sync_point(struct wmi_t *wmip)
26916 +{
26917 + void *cmd_osbuf;
26918 + WMI_DATA_SYNC_BUFS dataSyncBufs[WMM_NUM_AC];
26919 + A_UINT8 i,numPriStreams=0;
26920 + A_STATUS status;
26921 +
26922 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
26923 +
26924 + memset(dataSyncBufs,0,sizeof(dataSyncBufs));
26925 +
26926 + /* lock out while we walk through the priority list and assemble our local array */
26927 + LOCK_WMI(wmip);
26928 +
26929 + for (i=0; i < WMM_NUM_AC ; i++) {
26930 + if (wmip->wmi_fatPipeExists & (1 << i)) {
26931 + numPriStreams++;
26932 + dataSyncBufs[numPriStreams-1].trafficClass = i;
26933 + }
26934 + }
26935 +
26936 + UNLOCK_WMI(wmip);
26937 +
26938 + /* dataSyncBufs is now filled with entries (starting at index 0) containing valid streamIDs */
26939 +
26940 + do {
26941 + /*
26942 + * We allocate all network buffers needed so we will be able to
26943 + * send all required frames.
26944 + */
26945 + cmd_osbuf = A_NETBUF_ALLOC(0); /* no payload */
26946 + if (cmd_osbuf == NULL) {
26947 + status = A_NO_MEMORY;
26948 + break;
26949 + }
26950 +
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;
26955 + break;
26956 + }
26957 + } //end for
26958 +
26959 + /*
26960 + * Send sync cmd followed by sync data messages on all endpoints being
26961 + * used
26962 + */
26963 + status = wmi_cmd_send(wmip, cmd_osbuf, WMI_SYNCHRONIZE_CMDID,
26964 + NO_SYNC_WMIFLAG);
26965 +
26966 + if (A_FAILED(status)) {
26967 + break;
26968 + }
26969 + /* cmd buffer sent, we no longer own it */
26970 + cmd_osbuf = NULL;
26971 +
26972 + for(i=0; i < numPriStreams; i++) {
26973 + A_ASSERT(dataSyncBufs[i].osbuf != NULL);
26974 +
26975 + status = wmi_dataSync_send(wmip, dataSyncBufs[i].osbuf,
26976 + WMI_ACCESSCATEGORY_WMISTREAM(wmip,dataSyncBufs[i].trafficClass));
26977 +
26978 + if (A_FAILED(status)) {
26979 + break;
26980 + }
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;
26984 + } //end for
26985 +
26986 + } while(FALSE);
26987 +
26988 + /* free up any resources left over (possibly due to an error) */
26989 +
26990 + if (cmd_osbuf != NULL) {
26991 + A_NETBUF_FREE(cmd_osbuf);
26992 + }
26993 +
26994 + for (i = 0; i < numPriStreams; i++) {
26995 + if (dataSyncBufs[i].osbuf != NULL) {
26996 + A_NETBUF_FREE(dataSyncBufs[i].osbuf);
26997 + }
26998 + }
26999 +
27000 + return (status);
27001 +}
27002 +
27003 +A_STATUS
27004 +wmi_create_pstream_cmd(struct wmi_t *wmip, WMI_CREATE_PSTREAM_CMD *params)
27005 +{
27006 + void *osbuf;
27007 + WMI_CREATE_PSTREAM_CMD *cmd;
27008 + A_UINT16 activeTsids=0;
27009 + A_UINT8 fatPipeExistsForAC=0;
27010 +
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)) )
27024 + {
27025 + return A_EINVAL;
27026 + }
27027 +
27028 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27029 + if (osbuf == NULL) {
27030 + return A_NO_MEMORY;
27031 + }
27032 +
27033 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27034 +
27035 + A_DPRINTF(DBG_WMI,
27036 + (DBGFMT "Sending create_pstream_cmd: ac=%d tsid:%d\n", DBGARG,
27037 + params->trafficClass, params->tsid));
27038 +
27039 + cmd = (WMI_CREATE_PSTREAM_CMD *)(A_NETBUF_DATA(osbuf));
27040 + A_MEMZERO(cmd, sizeof(*cmd));
27041 + A_MEMCPY(cmd, params, sizeof(*cmd));
27042 +
27043 + /* this is an implicitly created Fat pipe */
27044 + if (params->tsid == WMI_IMPLICIT_PSTREAM) {
27045 + LOCK_WMI(wmip);
27046 + fatPipeExistsForAC = (wmip->wmi_fatPipeExists & (1 << params->trafficClass));
27047 + wmip->wmi_fatPipeExists |= (1<<params->trafficClass);
27048 + UNLOCK_WMI(wmip);
27049 + } else {
27050 + /* this is an explicitly created thin stream within a fat pipe */
27051 + LOCK_WMI(wmip);
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
27056 + * becomes active
27057 + */
27058 + wmip->wmi_fatPipeExists |= (1<<params->trafficClass);
27059 + UNLOCK_WMI(wmip);
27060 + }
27061 +
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.
27065 + */
27066 + if (!fatPipeExistsForAC) {
27067 + A_WMI_STREAM_TX_ACTIVE(wmip->wmi_devt, params->trafficClass);
27068 + }
27069 +
27070 + /* mike: should be SYNC_BEFORE_WMIFLAG */
27071 + return (wmi_cmd_send(wmip, osbuf, WMI_CREATE_PSTREAM_CMDID,
27072 + NO_SYNC_WMIFLAG));
27073 +}
27074 +
27075 +A_STATUS
27076 +wmi_delete_pstream_cmd(struct wmi_t *wmip, A_UINT8 trafficClass, A_UINT8 tsid)
27077 +{
27078 + void *osbuf;
27079 + WMI_DELETE_PSTREAM_CMD *cmd;
27080 + A_STATUS status;
27081 + A_UINT16 activeTsids=0;
27082 +
27083 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27084 + if (osbuf == NULL) {
27085 + return A_NO_MEMORY;
27086 + }
27087 +
27088 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27089 +
27090 + cmd = (WMI_DELETE_PSTREAM_CMD *)(A_NETBUF_DATA(osbuf));
27091 + A_MEMZERO(cmd, sizeof(*cmd));
27092 +
27093 + cmd->trafficClass = trafficClass;
27094 + cmd->tsid = tsid;
27095 +
27096 + LOCK_WMI(wmip);
27097 + activeTsids = wmip->wmi_streamExistsForAC[trafficClass];
27098 + UNLOCK_WMI(wmip);
27099 +
27100 + /* Check if the tsid was created & exists */
27101 + if (!(activeTsids & (1<<tsid))) {
27102 +
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 */
27106 + return A_ERROR;
27107 + }
27108 +
27109 + A_DPRINTF(DBG_WMI,
27110 + (DBGFMT "Sending delete_pstream_cmd: trafficClass: %d tsid=%d\n", DBGARG, trafficClass, tsid));
27111 +
27112 + status = (wmi_cmd_send(wmip, osbuf, WMI_DELETE_PSTREAM_CMDID,
27113 + SYNC_BEFORE_WMIFLAG));
27114 +
27115 + LOCK_WMI(wmip);
27116 + wmip->wmi_streamExistsForAC[trafficClass] &= ~(1<<tsid);
27117 + activeTsids = wmip->wmi_streamExistsForAC[trafficClass];
27118 + UNLOCK_WMI(wmip);
27119 +
27120 +
27121 + /* Indicate stream inactivity to driver layer only if all tsids
27122 + * within this AC are deleted.
27123 + */
27124 + if(!activeTsids) {
27125 + A_WMI_STREAM_TX_INACTIVE(wmip->wmi_devt, trafficClass);
27126 + wmip->wmi_fatPipeExists &= ~(1<<trafficClass);
27127 + }
27128 +
27129 + return status;
27130 +}
27131 +
27132 +/*
27133 + * used to set the bit rate. rate is in Kbps. If rate == -1
27134 + * then auto selection is used.
27135 + */
27136 +A_STATUS
27137 +wmi_set_bitrate_cmd(struct wmi_t *wmip, A_INT32 rate)
27138 +{
27139 + void *osbuf;
27140 + WMI_BIT_RATE_CMD *cmd;
27141 + A_INT8 index;
27142 +
27143 + if (rate != -1) {
27144 + index = wmi_validate_bitrate(wmip, rate);
27145 + if(index == A_EINVAL){
27146 + return A_EINVAL;
27147 + }
27148 + } else {
27149 + index = -1;
27150 + }
27151 +
27152 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27153 + if (osbuf == NULL) {
27154 + return A_NO_MEMORY;
27155 + }
27156 +
27157 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27158 +
27159 + cmd = (WMI_BIT_RATE_CMD *)(A_NETBUF_DATA(osbuf));
27160 + A_MEMZERO(cmd, sizeof(*cmd));
27161 +
27162 + cmd->rateIndex = index;
27163 +
27164 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BITRATE_CMDID, NO_SYNC_WMIFLAG));
27165 +}
27166 +
27167 +A_STATUS
27168 +wmi_get_bitrate_cmd(struct wmi_t *wmip)
27169 +{
27170 + void *osbuf;
27171 +
27172 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27173 + if (osbuf == NULL) {
27174 + return A_NO_MEMORY;
27175 + }
27176 +
27177 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_BITRATE_CMDID, NO_SYNC_WMIFLAG));
27178 +}
27179 +
27180 +/*
27181 + * Returns TRUE iff the given rate index is legal in the current PHY mode.
27182 + */
27183 +A_BOOL
27184 +wmi_is_bitrate_index_valid(struct wmi_t *wmip, A_UINT32 rateIndex)
27185 +{
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)) {
27191 + isValid = FALSE;
27192 + }
27193 + break;
27194 +
27195 + case WMI_11B_MODE:
27196 + if ((rateIndex < MODE_B_SUPPORT_RATE_START) || (rateIndex > MODE_B_SUPPORT_RATE_STOP)) {
27197 + isValid = FALSE;
27198 + }
27199 + break;
27200 +
27201 + case WMI_11GONLY_MODE:
27202 + if ((rateIndex < MODE_GONLY_SUPPORT_RATE_START) || (rateIndex > MODE_GONLY_SUPPORT_RATE_STOP)) {
27203 + isValid = FALSE;
27204 + }
27205 + break;
27206 +
27207 + case WMI_11G_MODE:
27208 + case WMI_11AG_MODE:
27209 + if ((rateIndex < MODE_G_SUPPORT_RATE_START) || (rateIndex > MODE_G_SUPPORT_RATE_STOP)) {
27210 + isValid = FALSE;
27211 + }
27212 + break;
27213 +
27214 + default:
27215 + A_ASSERT(FALSE);
27216 + break;
27217 + }
27218 +
27219 + return isValid;
27220 +}
27221 +
27222 +A_INT8
27223 +wmi_validate_bitrate(struct wmi_t *wmip, A_INT32 rate)
27224 +{
27225 + A_INT8 i;
27226 + if (rate != -1)
27227 + {
27228 + for (i=0;;i++)
27229 + {
27230 + if (wmi_rateTable[(A_UINT32) i] == 0) {
27231 + return A_EINVAL;
27232 + }
27233 + if (wmi_rateTable[(A_UINT32) i] == rate) {
27234 + break;
27235 + }
27236 + }
27237 + }
27238 + else{
27239 + i = -1;
27240 + }
27241 +
27242 + if(wmi_is_bitrate_index_valid(wmip, i) != TRUE) {
27243 + return A_EINVAL;
27244 + }
27245 +
27246 + return i;
27247 +}
27248 +
27249 +A_STATUS
27250 +wmi_set_fixrates_cmd(struct wmi_t *wmip, A_INT16 fixRatesMask)
27251 +{
27252 + void *osbuf;
27253 + WMI_FIX_RATES_CMD *cmd;
27254 + A_UINT32 rateIndex;
27255 +
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));
27261 + return A_EINVAL;
27262 + }
27263 + }
27264 + }
27265 +
27266 +
27267 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27268 + if (osbuf == NULL) {
27269 + return A_NO_MEMORY;
27270 + }
27271 +
27272 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27273 +
27274 + cmd = (WMI_FIX_RATES_CMD *)(A_NETBUF_DATA(osbuf));
27275 + A_MEMZERO(cmd, sizeof(*cmd));
27276 +
27277 + cmd->fixRateMask = fixRatesMask;
27278 +
27279 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_FIXRATES_CMDID, NO_SYNC_WMIFLAG));
27280 +}
27281 +
27282 +A_STATUS
27283 +wmi_get_ratemask_cmd(struct wmi_t *wmip)
27284 +{
27285 + void *osbuf;
27286 +
27287 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27288 + if (osbuf == NULL) {
27289 + return A_NO_MEMORY;
27290 + }
27291 +
27292 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_FIXRATES_CMDID, NO_SYNC_WMIFLAG));
27293 +}
27294 +
27295 +A_STATUS
27296 +wmi_get_channelList_cmd(struct wmi_t *wmip)
27297 +{
27298 + void *osbuf;
27299 +
27300 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27301 + if (osbuf == NULL) {
27302 + return A_NO_MEMORY;
27303 + }
27304 +
27305 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_CHANNEL_LIST_CMDID,
27306 + NO_SYNC_WMIFLAG));
27307 +}
27308 +
27309 +/*
27310 + * used to generate a wmi sey channel Parameters cmd.
27311 + * mode should always be specified and corresponds to the phy mode of the
27312 + * wlan.
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.
27318 + */
27319 +A_STATUS
27320 +wmi_set_channelParams_cmd(struct wmi_t *wmip, A_UINT8 scanParam,
27321 + WMI_PHY_MODE mode, A_INT8 numChan,
27322 + A_UINT16 *channelList)
27323 +{
27324 + void *osbuf;
27325 + WMI_CHANNEL_PARAMS_CMD *cmd;
27326 + A_INT8 size;
27327 +
27328 + size = sizeof (*cmd);
27329 +
27330 + if (numChan) {
27331 + if (numChan > WMI_MAX_CHANNELS) {
27332 + return A_EINVAL;
27333 + }
27334 + size += sizeof(A_UINT16) * (numChan - 1);
27335 + }
27336 +
27337 + osbuf = A_NETBUF_ALLOC(size);
27338 + if (osbuf == NULL) {
27339 + return A_NO_MEMORY;
27340 + }
27341 +
27342 + A_NETBUF_PUT(osbuf, size);
27343 +
27344 + cmd = (WMI_CHANNEL_PARAMS_CMD *)(A_NETBUF_DATA(osbuf));
27345 + A_MEMZERO(cmd, size);
27346 +
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));
27352 +
27353 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_CHANNEL_PARAMS_CMDID,
27354 + NO_SYNC_WMIFLAG));
27355 +}
27356 +
27357 +A_STATUS
27358 +wmi_set_rssi_threshold_params(struct wmi_t *wmip,
27359 + WMI_RSSI_THRESHOLD_PARAMS_CMD *rssiCmd)
27360 +{
27361 + void *osbuf;
27362 + A_INT8 size;
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) {
27375 +
27376 + return A_EINVAL;
27377 + }
27378 +
27379 + size = sizeof (*cmd);
27380 +
27381 + osbuf = A_NETBUF_ALLOC(size);
27382 + if (osbuf == NULL) {
27383 + return A_NO_MEMORY;
27384 + }
27385 +
27386 + A_NETBUF_PUT(osbuf, size);
27387 +
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));
27391 +
27392 + return (wmi_cmd_send(wmip, osbuf, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
27393 + NO_SYNC_WMIFLAG));
27394 +}
27395 +
27396 +A_STATUS
27397 +wmi_set_host_sleep_mode_cmd(struct wmi_t *wmip,
27398 + WMI_SET_HOST_SLEEP_MODE_CMD *hostModeCmd)
27399 +{
27400 + void *osbuf;
27401 + A_INT8 size;
27402 + WMI_SET_HOST_SLEEP_MODE_CMD *cmd;
27403 +
27404 + if( hostModeCmd->awake == hostModeCmd->asleep) {
27405 + return A_EINVAL;
27406 + }
27407 +
27408 + size = sizeof (*cmd);
27409 +
27410 + osbuf = A_NETBUF_ALLOC(size);
27411 + if (osbuf == NULL) {
27412 + return A_NO_MEMORY;
27413 + }
27414 +
27415 + A_NETBUF_PUT(osbuf, size);
27416 +
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));
27420 +
27421 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_HOST_SLEEP_MODE_CMDID,
27422 + NO_SYNC_WMIFLAG));
27423 +}
27424 +
27425 +A_STATUS
27426 +wmi_set_wow_mode_cmd(struct wmi_t *wmip,
27427 + WMI_SET_WOW_MODE_CMD *wowModeCmd)
27428 +{
27429 + void *osbuf;
27430 + A_INT8 size;
27431 + WMI_SET_WOW_MODE_CMD *cmd;
27432 +
27433 + size = sizeof (*cmd);
27434 +
27435 + osbuf = A_NETBUF_ALLOC(size);
27436 + if (osbuf == NULL) {
27437 + return A_NO_MEMORY;
27438 + }
27439 +
27440 + A_NETBUF_PUT(osbuf, size);
27441 +
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));
27445 +
27446 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WOW_MODE_CMDID,
27447 + NO_SYNC_WMIFLAG));
27448 +
27449 +}
27450 +
27451 +A_STATUS
27452 +wmi_get_wow_list_cmd(struct wmi_t *wmip,
27453 + WMI_GET_WOW_LIST_CMD *wowListCmd)
27454 +{
27455 + void *osbuf;
27456 + A_INT8 size;
27457 + WMI_GET_WOW_LIST_CMD *cmd;
27458 +
27459 + size = sizeof (*cmd);
27460 +
27461 + osbuf = A_NETBUF_ALLOC(size);
27462 + if (osbuf == NULL) {
27463 + return A_NO_MEMORY;
27464 + }
27465 +
27466 + A_NETBUF_PUT(osbuf, size);
27467 +
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));
27471 +
27472 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_WOW_LIST_CMDID,
27473 + NO_SYNC_WMIFLAG));
27474 +
27475 +}
27476 +
27477 +static A_STATUS
27478 +wmi_get_wow_list_event_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
27479 +{
27480 + WMI_GET_WOW_LIST_REPLY *reply;
27481 +
27482 + if (len < sizeof(WMI_GET_WOW_LIST_REPLY)) {
27483 + return A_EINVAL;
27484 + }
27485 + reply = (WMI_GET_WOW_LIST_REPLY *)datap;
27486 +
27487 + A_WMI_WOW_LIST_EVENT(wmip->wmi_devt, reply->num_filters,
27488 + reply);
27489 +
27490 + return A_OK;
27491 +}
27492 +
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)
27497 +{
27498 + void *osbuf;
27499 + A_INT8 size;
27500 + WMI_ADD_WOW_PATTERN_CMD *cmd;
27501 + A_UINT8 *filter_mask = NULL;
27502 +
27503 + size = sizeof (*cmd);
27504 +
27505 + size += ((2 * addWowCmd->filter_size)* sizeof(A_UINT8));
27506 + osbuf = A_NETBUF_ALLOC(size);
27507 + if (osbuf == NULL) {
27508 + return A_NO_MEMORY;
27509 + }
27510 +
27511 + A_NETBUF_PUT(osbuf, size);
27512 +
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;
27517 +
27518 + A_MEMCPY(cmd->filter, pattern, addWowCmd->filter_size);
27519 +
27520 + filter_mask = (A_UINT8*)(cmd->filter + cmd->filter_size);
27521 + A_MEMCPY(filter_mask, mask, addWowCmd->filter_size);
27522 +
27523 +
27524 + return (wmi_cmd_send(wmip, osbuf, WMI_ADD_WOW_PATTERN_CMDID,
27525 + NO_SYNC_WMIFLAG));
27526 +}
27527 +
27528 +A_STATUS
27529 +wmi_del_wow_pattern_cmd(struct wmi_t *wmip,
27530 + WMI_DEL_WOW_PATTERN_CMD *delWowCmd)
27531 +{
27532 + void *osbuf;
27533 + A_INT8 size;
27534 + WMI_DEL_WOW_PATTERN_CMD *cmd;
27535 +
27536 + size = sizeof (*cmd);
27537 +
27538 + osbuf = A_NETBUF_ALLOC(size);
27539 + if (osbuf == NULL) {
27540 + return A_NO_MEMORY;
27541 + }
27542 +
27543 + A_NETBUF_PUT(osbuf, size);
27544 +
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));
27548 +
27549 + return (wmi_cmd_send(wmip, osbuf, WMI_DEL_WOW_PATTERN_CMDID,
27550 + NO_SYNC_WMIFLAG));
27551 +
27552 +}
27553 +
27554 +A_STATUS
27555 +wmi_set_snr_threshold_params(struct wmi_t *wmip,
27556 + WMI_SNR_THRESHOLD_PARAMS_CMD *snrCmd)
27557 +{
27558 + void *osbuf;
27559 + A_INT8 size;
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) {
27568 +
27569 + return A_EINVAL;
27570 + }
27571 +
27572 + size = sizeof (*cmd);
27573 +
27574 + osbuf = A_NETBUF_ALLOC(size);
27575 + if (osbuf == NULL) {
27576 + return A_NO_MEMORY;
27577 + }
27578 +
27579 + A_NETBUF_PUT(osbuf, size);
27580 +
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));
27584 +
27585 + return (wmi_cmd_send(wmip, osbuf, WMI_SNR_THRESHOLD_PARAMS_CMDID,
27586 + NO_SYNC_WMIFLAG));
27587 +}
27588 +
27589 +A_STATUS
27590 +wmi_clr_rssi_snr(struct wmi_t *wmip)
27591 +{
27592 + void *osbuf;
27593 +
27594 + osbuf = A_NETBUF_ALLOC(sizeof(int));
27595 + if (osbuf == NULL) {
27596 + return A_NO_MEMORY;
27597 + }
27598 +
27599 + return (wmi_cmd_send(wmip, osbuf, WMI_CLR_RSSI_SNR_CMDID,
27600 + NO_SYNC_WMIFLAG));
27601 +}
27602 +
27603 +A_STATUS
27604 +wmi_set_lq_threshold_params(struct wmi_t *wmip,
27605 + WMI_LQ_THRESHOLD_PARAMS_CMD *lqCmd)
27606 +{
27607 + void *osbuf;
27608 + A_INT8 size;
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 ) {
27617 +
27618 + return A_EINVAL;
27619 + }
27620 +
27621 + size = sizeof (*cmd);
27622 +
27623 + osbuf = A_NETBUF_ALLOC(size);
27624 + if (osbuf == NULL) {
27625 + return A_NO_MEMORY;
27626 + }
27627 +
27628 + A_NETBUF_PUT(osbuf, size);
27629 +
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));
27633 +
27634 + return (wmi_cmd_send(wmip, osbuf, WMI_LQ_THRESHOLD_PARAMS_CMDID,
27635 + NO_SYNC_WMIFLAG));
27636 +}
27637 +
27638 +A_STATUS
27639 +wmi_set_error_report_bitmask(struct wmi_t *wmip, A_UINT32 mask)
27640 +{
27641 + void *osbuf;
27642 + A_INT8 size;
27643 + WMI_TARGET_ERROR_REPORT_BITMASK *cmd;
27644 +
27645 + size = sizeof (*cmd);
27646 +
27647 + osbuf = A_NETBUF_ALLOC(size);
27648 + if (osbuf == NULL) {
27649 + return A_NO_MEMORY;
27650 + }
27651 +
27652 + A_NETBUF_PUT(osbuf, size);
27653 +
27654 + cmd = (WMI_TARGET_ERROR_REPORT_BITMASK *)(A_NETBUF_DATA(osbuf));
27655 + A_MEMZERO(cmd, size);
27656 +
27657 + cmd->bitmask = mask;
27658 +
27659 + return (wmi_cmd_send(wmip, osbuf, WMI_TARGET_ERROR_REPORT_BITMASK_CMDID,
27660 + NO_SYNC_WMIFLAG));
27661 +}
27662 +
27663 +A_STATUS
27664 +wmi_get_challenge_resp_cmd(struct wmi_t *wmip, A_UINT32 cookie, A_UINT32 source)
27665 +{
27666 + void *osbuf;
27667 + WMIX_HB_CHALLENGE_RESP_CMD *cmd;
27668 +
27669 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27670 + if (osbuf == NULL) {
27671 + return A_NO_MEMORY;
27672 + }
27673 +
27674 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27675 +
27676 + cmd = (WMIX_HB_CHALLENGE_RESP_CMD *)(A_NETBUF_DATA(osbuf));
27677 + cmd->cookie = cookie;
27678 + cmd->source = source;
27679 +
27680 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_HB_CHALLENGE_RESP_CMDID,
27681 + NO_SYNC_WMIFLAG));
27682 +}
27683 +
27684 +A_STATUS
27685 +wmi_config_debug_module_cmd(struct wmi_t *wmip, A_UINT16 mmask,
27686 + A_UINT16 tsr, A_BOOL rep, A_UINT16 size,
27687 + A_UINT32 valid)
27688 +{
27689 + void *osbuf;
27690 + WMIX_DBGLOG_CFG_MODULE_CMD *cmd;
27691 +
27692 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27693 + if (osbuf == NULL) {
27694 + return A_NO_MEMORY;
27695 + }
27696 +
27697 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27698 +
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;
27705 +
27706 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DBGLOG_CFG_MODULE_CMDID,
27707 + NO_SYNC_WMIFLAG));
27708 +}
27709 +
27710 +A_STATUS
27711 +wmi_get_stats_cmd(struct wmi_t *wmip)
27712 +{
27713 + void *osbuf;
27714 +
27715 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27716 + if (osbuf == NULL) {
27717 + return A_NO_MEMORY;
27718 + }
27719 +
27720 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_STATISTICS_CMDID,
27721 + NO_SYNC_WMIFLAG));
27722 +}
27723 +
27724 +A_STATUS
27725 +wmi_addBadAp_cmd(struct wmi_t *wmip, A_UINT8 apIndex, A_UINT8 *bssid)
27726 +{
27727 + void *osbuf;
27728 + WMI_ADD_BAD_AP_CMD *cmd;
27729 +
27730 + if ((bssid == NULL) || (apIndex > WMI_MAX_BAD_AP_INDEX)) {
27731 + return A_EINVAL;
27732 + }
27733 +
27734 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27735 + if (osbuf == NULL) {
27736 + return A_NO_MEMORY;
27737 + }
27738 +
27739 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27740 +
27741 + cmd = (WMI_ADD_BAD_AP_CMD *)(A_NETBUF_DATA(osbuf));
27742 + cmd->badApIndex = apIndex;
27743 + A_MEMCPY(cmd->bssid, bssid, sizeof(cmd->bssid));
27744 +
27745 + return (wmi_cmd_send(wmip, osbuf, WMI_ADD_BAD_AP_CMDID, NO_SYNC_WMIFLAG));
27746 +}
27747 +
27748 +A_STATUS
27749 +wmi_deleteBadAp_cmd(struct wmi_t *wmip, A_UINT8 apIndex)
27750 +{
27751 + void *osbuf;
27752 + WMI_DELETE_BAD_AP_CMD *cmd;
27753 +
27754 + if (apIndex > WMI_MAX_BAD_AP_INDEX) {
27755 + return A_EINVAL;
27756 + }
27757 +
27758 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27759 + if (osbuf == NULL) {
27760 + return A_NO_MEMORY;
27761 + }
27762 +
27763 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27764 +
27765 + cmd = (WMI_DELETE_BAD_AP_CMD *)(A_NETBUF_DATA(osbuf));
27766 + cmd->badApIndex = apIndex;
27767 +
27768 + return (wmi_cmd_send(wmip, osbuf, WMI_DELETE_BAD_AP_CMDID,
27769 + NO_SYNC_WMIFLAG));
27770 +}
27771 +
27772 +A_STATUS
27773 +wmi_set_txPwr_cmd(struct wmi_t *wmip, A_UINT8 dbM)
27774 +{
27775 + void *osbuf;
27776 + WMI_SET_TX_PWR_CMD *cmd;
27777 +
27778 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
27779 + if (osbuf == NULL) {
27780 + return A_NO_MEMORY;
27781 + }
27782 +
27783 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
27784 +
27785 + cmd = (WMI_SET_TX_PWR_CMD *)(A_NETBUF_DATA(osbuf));
27786 + cmd->dbM = dbM;
27787 +
27788 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_TX_PWR_CMDID, NO_SYNC_WMIFLAG));
27789 +}
27790 +
27791 +A_STATUS
27792 +wmi_get_txPwr_cmd(struct wmi_t *wmip)
27793 +{
27794 + void *osbuf;
27795 +
27796 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27797 + if (osbuf == NULL) {
27798 + return A_NO_MEMORY;
27799 + }
27800 +
27801 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_TX_PWR_CMDID, NO_SYNC_WMIFLAG));
27802 +}
27803 +
27804 +A_UINT16
27805 +wmi_get_mapped_qos_queue(struct wmi_t *wmip, A_UINT8 trafficClass)
27806 +{
27807 + A_UINT16 activeTsids=0;
27808 +
27809 + LOCK_WMI(wmip);
27810 + activeTsids = wmip->wmi_streamExistsForAC[trafficClass];
27811 + UNLOCK_WMI(wmip);
27812 +
27813 + return activeTsids;
27814 +}
27815 +
27816 +A_STATUS
27817 +wmi_get_roam_tbl_cmd(struct wmi_t *wmip)
27818 +{
27819 + void *osbuf;
27820 +
27821 + osbuf = A_NETBUF_ALLOC(0); /* no payload */
27822 + if (osbuf == NULL) {
27823 + return A_NO_MEMORY;
27824 + }
27825 +
27826 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_ROAM_TBL_CMDID,
27827 + NO_SYNC_WMIFLAG));
27828 +}
27829 +
27830 +A_STATUS
27831 +wmi_get_roam_data_cmd(struct wmi_t *wmip, A_UINT8 roamDataType)
27832 +{
27833 + void *osbuf;
27834 + A_UINT32 size = sizeof(A_UINT8);
27835 + WMI_TARGET_ROAM_DATA *cmd;
27836 +
27837 + osbuf = A_NETBUF_ALLOC(size); /* no payload */
27838 + if (osbuf == NULL) {
27839 + return A_NO_MEMORY;
27840 + }
27841 +
27842 + A_NETBUF_PUT(osbuf, size);
27843 +
27844 + cmd = (WMI_TARGET_ROAM_DATA *)(A_NETBUF_DATA(osbuf));
27845 + cmd->roamDataType = roamDataType;
27846 +
27847 + return (wmi_cmd_send(wmip, osbuf, WMI_GET_ROAM_DATA_CMDID,
27848 + NO_SYNC_WMIFLAG));
27849 +}
27850 +
27851 +A_STATUS
27852 +wmi_set_roam_ctrl_cmd(struct wmi_t *wmip, WMI_SET_ROAM_CTRL_CMD *p,
27853 + A_UINT8 size)
27854 +{
27855 + void *osbuf;
27856 + WMI_SET_ROAM_CTRL_CMD *cmd;
27857 +
27858 + osbuf = A_NETBUF_ALLOC(size);
27859 + if (osbuf == NULL) {
27860 + return A_NO_MEMORY;
27861 + }
27862 +
27863 + A_NETBUF_PUT(osbuf, size);
27864 +
27865 + cmd = (WMI_SET_ROAM_CTRL_CMD *)(A_NETBUF_DATA(osbuf));
27866 + A_MEMZERO(cmd, size);
27867 +
27868 + A_MEMCPY(cmd, p, size);
27869 +
27870 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_ROAM_CTRL_CMDID,
27871 + NO_SYNC_WMIFLAG));
27872 +}
27873 +
27874 +A_STATUS
27875 +wmi_set_powersave_timers_cmd(struct wmi_t *wmip,
27876 + WMI_POWERSAVE_TIMERS_POLICY_CMD *pCmd,
27877 + A_UINT8 size)
27878 +{
27879 + void *osbuf;
27880 + WMI_POWERSAVE_TIMERS_POLICY_CMD *cmd;
27881 +
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))
27888 + return A_EINVAL;
27889 +
27890 + osbuf = A_NETBUF_ALLOC(size);
27891 + if (osbuf == NULL) {
27892 + return A_NO_MEMORY;
27893 + }
27894 +
27895 + A_NETBUF_PUT(osbuf, size);
27896 +
27897 + cmd = (WMI_POWERSAVE_TIMERS_POLICY_CMD *)(A_NETBUF_DATA(osbuf));
27898 + A_MEMZERO(cmd, size);
27899 +
27900 + A_MEMCPY(cmd, pCmd, size);
27901 +
27902 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID,
27903 + NO_SYNC_WMIFLAG));
27904 +}
27905 +
27906 +#ifdef CONFIG_HOST_GPIO_SUPPORT
27907 +/* Send a command to Target to change GPIO output pins. */
27908 +A_STATUS
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)
27914 +{
27915 + void *osbuf;
27916 + WMIX_GPIO_OUTPUT_SET_CMD *output_set;
27917 + int size;
27918 +
27919 + size = sizeof(*output_set);
27920 +
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));
27924 +
27925 + osbuf = A_NETBUF_ALLOC(size);
27926 + if (osbuf == NULL) {
27927 + return A_NO_MEMORY;
27928 + }
27929 + A_NETBUF_PUT(osbuf, size);
27930 + output_set = (WMIX_GPIO_OUTPUT_SET_CMD *)(A_NETBUF_DATA(osbuf));
27931 +
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;
27936 +
27937 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_OUTPUT_SET_CMDID,
27938 + NO_SYNC_WMIFLAG));
27939 +}
27940 +
27941 +/* Send a command to the Target requesting state of the GPIO input pins */
27942 +A_STATUS
27943 +wmi_gpio_input_get(struct wmi_t *wmip)
27944 +{
27945 + void *osbuf;
27946 +
27947 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
27948 +
27949 + osbuf = A_NETBUF_ALLOC(0);
27950 + if (osbuf == NULL) {
27951 + return A_NO_MEMORY;
27952 + }
27953 +
27954 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_INPUT_GET_CMDID,
27955 + NO_SYNC_WMIFLAG));
27956 +}
27957 +
27958 +/* Send a command to the Target that changes the value of a GPIO register. */
27959 +A_STATUS
27960 +wmi_gpio_register_set(struct wmi_t *wmip,
27961 + A_UINT32 gpioreg_id,
27962 + A_UINT32 value)
27963 +{
27964 + void *osbuf;
27965 + WMIX_GPIO_REGISTER_SET_CMD *register_set;
27966 + int size;
27967 +
27968 + size = sizeof(*register_set);
27969 +
27970 + A_DPRINTF(DBG_WMI,
27971 + (DBGFMT "Enter - reg=%d value=0x%x\n", DBGARG, gpioreg_id, value));
27972 +
27973 + osbuf = A_NETBUF_ALLOC(size);
27974 + if (osbuf == NULL) {
27975 + return A_NO_MEMORY;
27976 + }
27977 + A_NETBUF_PUT(osbuf, size);
27978 + register_set = (WMIX_GPIO_REGISTER_SET_CMD *)(A_NETBUF_DATA(osbuf));
27979 +
27980 + register_set->gpioreg_id = gpioreg_id;
27981 + register_set->value = value;
27982 +
27983 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_REGISTER_SET_CMDID,
27984 + NO_SYNC_WMIFLAG));
27985 +}
27986 +
27987 +/* Send a command to the Target to fetch the value of a GPIO register. */
27988 +A_STATUS
27989 +wmi_gpio_register_get(struct wmi_t *wmip,
27990 + A_UINT32 gpioreg_id)
27991 +{
27992 + void *osbuf;
27993 + WMIX_GPIO_REGISTER_GET_CMD *register_get;
27994 + int size;
27995 +
27996 + size = sizeof(*register_get);
27997 +
27998 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter - reg=%d\n", DBGARG, gpioreg_id));
27999 +
28000 + osbuf = A_NETBUF_ALLOC(size);
28001 + if (osbuf == NULL) {
28002 + return A_NO_MEMORY;
28003 + }
28004 + A_NETBUF_PUT(osbuf, size);
28005 + register_get = (WMIX_GPIO_REGISTER_GET_CMD *)(A_NETBUF_DATA(osbuf));
28006 +
28007 + register_get->gpioreg_id = gpioreg_id;
28008 +
28009 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_REGISTER_GET_CMDID,
28010 + NO_SYNC_WMIFLAG));
28011 +}
28012 +
28013 +/* Send a command to the Target acknowledging some GPIO interrupts. */
28014 +A_STATUS
28015 +wmi_gpio_intr_ack(struct wmi_t *wmip,
28016 + A_UINT32 ack_mask)
28017 +{
28018 + void *osbuf;
28019 + WMIX_GPIO_INTR_ACK_CMD *intr_ack;
28020 + int size;
28021 +
28022 + size = sizeof(*intr_ack);
28023 +
28024 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter ack_mask=0x%x\n", DBGARG, ack_mask));
28025 +
28026 + osbuf = A_NETBUF_ALLOC(size);
28027 + if (osbuf == NULL) {
28028 + return A_NO_MEMORY;
28029 + }
28030 + A_NETBUF_PUT(osbuf, size);
28031 + intr_ack = (WMIX_GPIO_INTR_ACK_CMD *)(A_NETBUF_DATA(osbuf));
28032 +
28033 + intr_ack->ack_mask = ack_mask;
28034 +
28035 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_INTR_ACK_CMDID,
28036 + NO_SYNC_WMIFLAG));
28037 +}
28038 +#endif /* CONFIG_HOST_GPIO_SUPPORT */
28039 +
28040 +A_STATUS
28041 +wmi_set_access_params_cmd(struct wmi_t *wmip, A_UINT16 txop, A_UINT8 eCWmin,
28042 + A_UINT8 eCWmax, A_UINT8 aifsn)
28043 +{
28044 + void *osbuf;
28045 + WMI_SET_ACCESS_PARAMS_CMD *cmd;
28046 +
28047 + if ((eCWmin > WMI_MAX_CW_ACPARAM) || (eCWmax > WMI_MAX_CW_ACPARAM) ||
28048 + (aifsn > WMI_MAX_AIFSN_ACPARAM))
28049 + {
28050 + return A_EINVAL;
28051 + }
28052 +
28053 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28054 + if (osbuf == NULL) {
28055 + return A_NO_MEMORY;
28056 + }
28057 +
28058 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28059 +
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;
28065 +
28066 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_ACCESS_PARAMS_CMDID,
28067 + NO_SYNC_WMIFLAG));
28068 +}
28069 +
28070 +A_STATUS
28071 +wmi_set_retry_limits_cmd(struct wmi_t *wmip, A_UINT8 frameType,
28072 + A_UINT8 trafficClass, A_UINT8 maxRetries,
28073 + A_UINT8 enableNotify)
28074 +{
28075 + void *osbuf;
28076 + WMI_SET_RETRY_LIMITS_CMD *cmd;
28077 +
28078 + if ((frameType != MGMT_FRAMETYPE) && (frameType != CONTROL_FRAMETYPE) &&
28079 + (frameType != DATA_FRAMETYPE))
28080 + {
28081 + return A_EINVAL;
28082 + }
28083 +
28084 + if (maxRetries > WMI_MAX_RETRIES) {
28085 + return A_EINVAL;
28086 + }
28087 +
28088 + if (frameType != DATA_FRAMETYPE) {
28089 + trafficClass = 0;
28090 + }
28091 +
28092 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28093 + if (osbuf == NULL) {
28094 + return A_NO_MEMORY;
28095 + }
28096 +
28097 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28098 +
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;
28104 +
28105 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_RETRY_LIMITS_CMDID,
28106 + NO_SYNC_WMIFLAG));
28107 +}
28108 +
28109 +void
28110 +wmi_get_current_bssid(struct wmi_t *wmip, A_UINT8 *bssid)
28111 +{
28112 + if (bssid != NULL) {
28113 + A_MEMCPY(bssid, wmip->wmi_bssid, ATH_MAC_LEN);
28114 + }
28115 +}
28116 +
28117 +A_STATUS
28118 +wmi_set_opt_mode_cmd(struct wmi_t *wmip, A_UINT8 optMode)
28119 +{
28120 + void *osbuf;
28121 + WMI_SET_OPT_MODE_CMD *cmd;
28122 +
28123 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28124 + if (osbuf == NULL) {
28125 + return A_NO_MEMORY;
28126 + }
28127 +
28128 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28129 +
28130 + cmd = (WMI_SET_OPT_MODE_CMD *)(A_NETBUF_DATA(osbuf));
28131 + A_MEMZERO(cmd, sizeof(*cmd));
28132 + cmd->optMode = optMode;
28133 +
28134 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_OPT_MODE_CMDID,
28135 + SYNC_BOTH_WMIFLAG));
28136 +}
28137 +
28138 +A_STATUS
28139 +wmi_opt_tx_frame_cmd(struct wmi_t *wmip,
28140 + A_UINT8 frmType,
28141 + A_UINT8 *dstMacAddr,
28142 + A_UINT8 *bssid,
28143 + A_UINT16 optIEDataLen,
28144 + A_UINT8 *optIEData)
28145 +{
28146 + void *osbuf;
28147 + WMI_OPT_TX_FRAME_CMD *cmd;
28148 + osbuf = A_NETBUF_ALLOC(optIEDataLen + sizeof(*cmd));
28149 + if (osbuf == NULL) {
28150 + return A_NO_MEMORY;
28151 + }
28152 +
28153 + A_NETBUF_PUT(osbuf, (optIEDataLen + sizeof(*cmd)));
28154 +
28155 + cmd = (WMI_OPT_TX_FRAME_CMD *)(A_NETBUF_DATA(osbuf));
28156 + A_MEMZERO(cmd, (optIEDataLen + sizeof(*cmd)-1));
28157 +
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);
28164 +
28165 + return (wmi_cmd_send(wmip, osbuf, WMI_OPT_TX_FRAME_CMDID,
28166 + NO_SYNC_WMIFLAG));
28167 +}
28168 +
28169 +A_STATUS
28170 +wmi_set_adhoc_bconIntvl_cmd(struct wmi_t *wmip, A_UINT16 intvl)
28171 +{
28172 + void *osbuf;
28173 + WMI_BEACON_INT_CMD *cmd;
28174 +
28175 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28176 + if (osbuf == NULL) {
28177 + return A_NO_MEMORY;
28178 + }
28179 +
28180 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28181 +
28182 + cmd = (WMI_BEACON_INT_CMD *)(A_NETBUF_DATA(osbuf));
28183 + A_MEMZERO(cmd, sizeof(*cmd));
28184 + cmd->beaconInterval = intvl;
28185 +
28186 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BEACON_INT_CMDID,
28187 + NO_SYNC_WMIFLAG));
28188 +}
28189 +
28190 +
28191 +A_STATUS
28192 +wmi_set_voice_pkt_size_cmd(struct wmi_t *wmip, A_UINT16 voicePktSize)
28193 +{
28194 + void *osbuf;
28195 + WMI_SET_VOICE_PKT_SIZE_CMD *cmd;
28196 +
28197 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28198 + if (osbuf == NULL) {
28199 + return A_NO_MEMORY;
28200 + }
28201 +
28202 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28203 +
28204 + cmd = (WMI_SET_VOICE_PKT_SIZE_CMD *)(A_NETBUF_DATA(osbuf));
28205 + A_MEMZERO(cmd, sizeof(*cmd));
28206 + cmd->voicePktSize = voicePktSize;
28207 +
28208 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_VOICE_PKT_SIZE_CMDID,
28209 + NO_SYNC_WMIFLAG));
28210 +}
28211 +
28212 +
28213 +A_STATUS
28214 +wmi_set_max_sp_len_cmd(struct wmi_t *wmip, A_UINT8 maxSPLen)
28215 +{
28216 + void *osbuf;
28217 + WMI_SET_MAX_SP_LEN_CMD *cmd;
28218 +
28219 + /* maxSPLen is a two-bit value. If user trys to set anything
28220 + * other than this, then its invalid
28221 + */
28222 + if(maxSPLen & ~0x03)
28223 + return A_EINVAL;
28224 +
28225 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28226 + if (osbuf == NULL) {
28227 + return A_NO_MEMORY;
28228 + }
28229 +
28230 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28231 +
28232 + cmd = (WMI_SET_MAX_SP_LEN_CMD *)(A_NETBUF_DATA(osbuf));
28233 + A_MEMZERO(cmd, sizeof(*cmd));
28234 + cmd->maxSPLen = maxSPLen;
28235 +
28236 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_MAX_SP_LEN_CMDID,
28237 + NO_SYNC_WMIFLAG));
28238 +}
28239 +
28240 +A_UINT8
28241 +convert_userPriority_to_trafficClass(A_UINT8 userPriority)
28242 +{
28243 + return (up_to_ac[userPriority & 0x7]);
28244 +}
28245 +
28246 +A_UINT8
28247 +wmi_get_power_mode_cmd(struct wmi_t *wmip)
28248 +{
28249 + return wmip->wmi_powerMode;
28250 +}
28251 +
28252 +A_STATUS
28253 +wmi_verify_tspec_params(WMI_CREATE_PSTREAM_CMD *pCmd, A_BOOL tspecCompliance)
28254 +{
28255 + return A_OK;
28256 +}
28257 +
28258 +#ifdef CONFIG_HOST_TCMD_SUPPORT
28259 +static A_STATUS
28260 +wmi_tcmd_test_report_rx(struct wmi_t *wmip, A_UINT8 *datap, int len)
28261 +{
28262 +
28263 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
28264 +
28265 + A_WMI_TCMD_RX_REPORT_EVENT(wmip->wmi_devt, datap, len);
28266 +
28267 + return A_OK;
28268 +}
28269 +
28270 +#endif /* CONFIG_HOST_TCMD_SUPPORT*/
28271 +
28272 +A_STATUS
28273 +wmi_set_authmode_cmd(struct wmi_t *wmip, A_UINT8 mode)
28274 +{
28275 + void *osbuf;
28276 + WMI_SET_AUTH_MODE_CMD *cmd;
28277 +
28278 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28279 + if (osbuf == NULL) {
28280 + return A_NO_MEMORY;
28281 + }
28282 +
28283 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28284 +
28285 + cmd = (WMI_SET_AUTH_MODE_CMD *)(A_NETBUF_DATA(osbuf));
28286 + A_MEMZERO(cmd, sizeof(*cmd));
28287 + cmd->mode = mode;
28288 +
28289 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_AUTH_MODE_CMDID,
28290 + NO_SYNC_WMIFLAG));
28291 +}
28292 +
28293 +A_STATUS
28294 +wmi_set_reassocmode_cmd(struct wmi_t *wmip, A_UINT8 mode)
28295 +{
28296 + void *osbuf;
28297 + WMI_SET_REASSOC_MODE_CMD *cmd;
28298 +
28299 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28300 + if (osbuf == NULL) {
28301 + return A_NO_MEMORY;
28302 + }
28303 +
28304 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28305 +
28306 + cmd = (WMI_SET_REASSOC_MODE_CMD *)(A_NETBUF_DATA(osbuf));
28307 + A_MEMZERO(cmd, sizeof(*cmd));
28308 + cmd->mode = mode;
28309 +
28310 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_REASSOC_MODE_CMDID,
28311 + NO_SYNC_WMIFLAG));
28312 +}
28313 +
28314 +A_STATUS
28315 +wmi_set_lpreamble_cmd(struct wmi_t *wmip, A_UINT8 status)
28316 +{
28317 + void *osbuf;
28318 + WMI_SET_LPREAMBLE_CMD *cmd;
28319 +
28320 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28321 + if (osbuf == NULL) {
28322 + return A_NO_MEMORY;
28323 + }
28324 +
28325 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28326 +
28327 + cmd = (WMI_SET_LPREAMBLE_CMD *)(A_NETBUF_DATA(osbuf));
28328 + A_MEMZERO(cmd, sizeof(*cmd));
28329 + cmd->status = status;
28330 +
28331 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_LPREAMBLE_CMDID,
28332 + NO_SYNC_WMIFLAG));
28333 +}
28334 +
28335 +A_STATUS
28336 +wmi_set_rts_cmd(struct wmi_t *wmip, A_UINT16 threshold)
28337 +{
28338 + void *osbuf;
28339 + WMI_SET_RTS_CMD *cmd;
28340 +
28341 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28342 + if (osbuf == NULL) {
28343 + return A_NO_MEMORY;
28344 + }
28345 +
28346 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28347 +
28348 + cmd = (WMI_SET_RTS_CMD*)(A_NETBUF_DATA(osbuf));
28349 + A_MEMZERO(cmd, sizeof(*cmd));
28350 + cmd->threshold = threshold;
28351 +
28352 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_RTS_CMDID,
28353 + NO_SYNC_WMIFLAG));
28354 +}
28355 +
28356 +A_STATUS
28357 +wmi_set_wmm_cmd(struct wmi_t *wmip, WMI_WMM_STATUS status)
28358 +{
28359 + void *osbuf;
28360 + WMI_SET_WMM_CMD *cmd;
28361 +
28362 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28363 + if (osbuf == NULL) {
28364 + return A_NO_MEMORY;
28365 + }
28366 +
28367 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28368 +
28369 + cmd = (WMI_SET_WMM_CMD*)(A_NETBUF_DATA(osbuf));
28370 + A_MEMZERO(cmd, sizeof(*cmd));
28371 + cmd->status = status;
28372 +
28373 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WMM_CMDID,
28374 + NO_SYNC_WMIFLAG));
28375 +
28376 +}
28377 +
28378 +A_STATUS
28379 +wmi_set_wmm_txop(struct wmi_t *wmip, WMI_TXOP_CFG cfg)
28380 +{
28381 + void *osbuf;
28382 + WMI_SET_WMM_TXOP_CMD *cmd;
28383 +
28384 + if( !((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)) )
28385 + return A_EINVAL;
28386 +
28387 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28388 + if (osbuf == NULL) {
28389 + return A_NO_MEMORY;
28390 + }
28391 +
28392 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28393 +
28394 + cmd = (WMI_SET_WMM_TXOP_CMD *)(A_NETBUF_DATA(osbuf));
28395 + A_MEMZERO(cmd, sizeof(*cmd));
28396 + cmd->txopEnable = cfg;
28397 +
28398 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WMM_TXOP_CMDID,
28399 + NO_SYNC_WMIFLAG));
28400 +
28401 +}
28402 +
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
28407 + */
28408 +A_STATUS
28409 +wmi_test_cmd(struct wmi_t *wmip, A_UINT8 *buf, A_UINT32 len)
28410 +{
28411 + void *osbuf;
28412 + char *data;
28413 +
28414 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
28415 +
28416 + osbuf= A_NETBUF_ALLOC(len);
28417 + if(osbuf == NULL)
28418 + {
28419 + return A_NO_MEMORY;
28420 + }
28421 + A_NETBUF_PUT(osbuf, len);
28422 + data = A_NETBUF_DATA(osbuf);
28423 + A_MEMCPY(data, buf, len);
28424 +
28425 + return(wmi_cmd_send(wmip, osbuf, WMI_TEST_CMDID,
28426 + NO_SYNC_WMIFLAG));
28427 +}
28428 +
28429 +#endif
28430 +
28431 +A_STATUS
28432 +wmi_set_bt_status_cmd(struct wmi_t *wmip, A_UINT8 streamType, A_UINT8 status)
28433 +{
28434 + void *osbuf;
28435 + WMI_SET_BT_STATUS_CMD *cmd;
28436 +
28437 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28438 + if (osbuf == NULL) {
28439 + return A_NO_MEMORY;
28440 + }
28441 +
28442 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28443 +
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;
28448 +
28449 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BT_STATUS_CMDID,
28450 + NO_SYNC_WMIFLAG));
28451 +}
28452 +
28453 +A_STATUS
28454 +wmi_set_bt_params_cmd(struct wmi_t *wmip, WMI_SET_BT_PARAMS_CMD* cmd)
28455 +{
28456 + void *osbuf;
28457 + WMI_SET_BT_PARAMS_CMD* alloc_cmd;
28458 +
28459 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28460 + if (osbuf == NULL) {
28461 + return A_NO_MEMORY;
28462 + }
28463 +
28464 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28465 +
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));
28469 +
28470 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_BT_PARAMS_CMDID,
28471 + NO_SYNC_WMIFLAG));
28472 +}
28473 +
28474 +A_STATUS
28475 +wmi_get_keepalive_configured(struct wmi_t *wmip)
28476 +{
28477 + void *osbuf;
28478 + WMI_GET_KEEPALIVE_CMD *cmd;
28479 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28480 + if (osbuf == NULL) {
28481 + return A_NO_MEMORY;
28482 + }
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));
28488 +}
28489 +
28490 +A_UINT8
28491 +wmi_get_keepalive_cmd(struct wmi_t *wmip)
28492 +{
28493 + return wmip->wmi_keepaliveInterval;
28494 +}
28495 +
28496 +A_STATUS
28497 +wmi_set_keepalive_cmd(struct wmi_t *wmip, A_UINT8 keepaliveInterval)
28498 +{
28499 + void *osbuf;
28500 + WMI_SET_KEEPALIVE_CMD *cmd;
28501 +
28502 + osbuf = A_NETBUF_ALLOC(sizeof(*cmd));
28503 + if (osbuf == NULL) {
28504 + return A_NO_MEMORY;
28505 + }
28506 +
28507 + A_NETBUF_PUT(osbuf, sizeof(*cmd));
28508 +
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;
28513 +
28514 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_KEEPALIVE_CMDID,
28515 + NO_SYNC_WMIFLAG));
28516 +}
28517 +
28518 +A_STATUS
28519 +wmi_set_appie_cmd(struct wmi_t *wmip, A_UINT8 mgmtFrmType, A_UINT8 ieLen,
28520 + A_UINT8 *ieInfo)
28521 +{
28522 + void *osbuf;
28523 + WMI_SET_APPIE_CMD *cmd;
28524 + A_UINT16 cmdLen;
28525 +
28526 + if (ieLen > WMI_MAX_IE_LEN) {
28527 + return A_ERROR;
28528 + }
28529 + cmdLen = sizeof(*cmd) + ieLen - 1;
28530 + osbuf = A_NETBUF_ALLOC(cmdLen);
28531 + if (osbuf == NULL) {
28532 + return A_NO_MEMORY;
28533 + }
28534 +
28535 + A_NETBUF_PUT(osbuf, cmdLen);
28536 +
28537 + cmd = (WMI_SET_APPIE_CMD *)(A_NETBUF_DATA(osbuf));
28538 + A_MEMZERO(cmd, cmdLen);
28539 +
28540 + cmd->mgmtFrmType = mgmtFrmType;
28541 + cmd->ieLen = ieLen;
28542 + A_MEMCPY(cmd->ieInfo, ieInfo, ieLen);
28543 +
28544 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_APPIE_CMDID, NO_SYNC_WMIFLAG));
28545 +}
28546 +
28547 +A_STATUS
28548 +wmi_set_halparam_cmd(struct wmi_t *wmip, A_UINT8 *cmd, A_UINT16 dataLen)
28549 +{
28550 + void *osbuf;
28551 + A_UINT8 *data;
28552 +
28553 + osbuf = A_NETBUF_ALLOC(dataLen);
28554 + if (osbuf == NULL) {
28555 + return A_NO_MEMORY;
28556 + }
28557 +
28558 + A_NETBUF_PUT(osbuf, dataLen);
28559 +
28560 + data = A_NETBUF_DATA(osbuf);
28561 +
28562 + A_MEMCPY(data, cmd, dataLen);
28563 +
28564 + return (wmi_cmd_send(wmip, osbuf, WMI_SET_WHALPARAM_CMDID, NO_SYNC_WMIFLAG));
28565 +}
28566 +
28567 +A_INT32
28568 +wmi_get_rate(A_INT8 rateindex)
28569 +{
28570 + if (rateindex == RATE_AUTO) {
28571 + return 0;
28572 + } else {
28573 + return(wmi_rateTable[(A_UINT32) rateindex]);
28574 + }
28575 +}
28576 +
28577 +void
28578 +wmi_node_return (struct wmi_t *wmip, bss_t *bss)
28579 +{
28580 + if (NULL != bss)
28581 + {
28582 + wlan_node_return (&wmip->wmi_scan_table, bss);
28583 + }
28584 +}
28585 +
28586 +bss_t *
28587 +wmi_find_Ssidnode (struct wmi_t *wmip, A_UCHAR *pSsid,
28588 + A_UINT32 ssidLength, A_BOOL bIsWPA2)
28589 +{
28590 + bss_t *node = NULL;
28591 + node = wlan_find_Ssidnode (&wmip->wmi_scan_table, pSsid,
28592 + ssidLength, bIsWPA2);
28593 + return node;
28594 +}
28595 +
28596 +void
28597 +wmi_free_allnodes(struct wmi_t *wmip)
28598 +{
28599 + wlan_free_allnodes(&wmip->wmi_scan_table);
28600 +}
28601 +
28602 +bss_t *
28603 +wmi_find_node(struct wmi_t *wmip, const A_UINT8 *macaddr)
28604 +{
28605 + bss_t *ni=NULL;
28606 + ni=wlan_find_node(&wmip->wmi_scan_table,macaddr);
28607 + return ni;
28608 +}
28609 +
28610 +A_STATUS
28611 +wmi_dset_open_reply(struct wmi_t *wmip,
28612 + A_UINT32 status,
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)
28619 +{
28620 + void *osbuf;
28621 + WMIX_DSETOPEN_REPLY_CMD *open_reply;
28622 +
28623 + A_DPRINTF(DBG_WMI, (DBGFMT "Enter - wmip=0x%x\n", DBGARG, (int)wmip));
28624 +
28625 + osbuf = A_NETBUF_ALLOC(sizeof(*open_reply));
28626 + if (osbuf == NULL) {
28627 + return A_NO_MEMORY;
28628 + }
28629 +
28630 + A_NETBUF_PUT(osbuf, sizeof(*open_reply));
28631 + open_reply = (WMIX_DSETOPEN_REPLY_CMD *)(A_NETBUF_DATA(osbuf));
28632 +
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;
28640 +
28641 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DSETOPEN_REPLY_CMDID,
28642 + NO_SYNC_WMIFLAG));
28643 +}
28644 +
28645 +static A_STATUS
28646 +wmi_get_pmkid_list_event_rx(struct wmi_t *wmip, A_UINT8 *datap, A_UINT32 len)
28647 +{
28648 + WMI_PMKID_LIST_REPLY *reply;
28649 + A_UINT32 expected_len;
28650 +
28651 + if (len < sizeof(WMI_PMKID_LIST_REPLY)) {
28652 + return A_EINVAL;
28653 + }
28654 + reply = (WMI_PMKID_LIST_REPLY *)datap;
28655 + expected_len = sizeof(reply->numPMKID) + reply->numPMKID * WMI_PMKID_LEN;
28656 +
28657 + if (len < expected_len) {
28658 + return A_EINVAL;
28659 + }
28660 +
28661 + A_WMI_PMKID_LIST_EVENT(wmip->wmi_devt, reply->numPMKID,
28662 + reply->pmkidList);
28663 +
28664 + return A_OK;
28665 +}
28666 +
28667 +#ifdef CONFIG_HOST_DSET_SUPPORT
28668 +A_STATUS
28669 +wmi_dset_data_reply(struct wmi_t *wmip,
28670 + A_UINT32 status,
28671 + A_UINT8 *user_buf,
28672 + A_UINT32 length,
28673 + A_UINT32 targ_buf,
28674 + A_UINT32 targ_reply_fn,
28675 + A_UINT32 targ_reply_arg)
28676 +{
28677 + void *osbuf;
28678 + WMIX_DSETDATA_REPLY_CMD *data_reply;
28679 + int size;
28680 +
28681 + size = sizeof(*data_reply) + length;
28682 +
28683 + A_DPRINTF(DBG_WMI,
28684 + (DBGFMT "Enter - length=%d status=%d\n", DBGARG, length, status));
28685 +
28686 + osbuf = A_NETBUF_ALLOC(size);
28687 + if (osbuf == NULL) {
28688 + return A_NO_MEMORY;
28689 + }
28690 + A_NETBUF_PUT(osbuf, size);
28691 + data_reply = (WMIX_DSETDATA_REPLY_CMD *)(A_NETBUF_DATA(osbuf));
28692 +
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;
28698 +
28699 + if (status == A_OK) {
28700 + if (a_copy_from_user(data_reply->buf, user_buf, length)) {
28701 + return A_ERROR;
28702 + }
28703 + }
28704 +
28705 + return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_DSETDATA_REPLY_CMDID,
28706 + NO_SYNC_WMIFLAG));
28707 +}
28708 +#endif /* CONFIG_HOST_DSET_SUPPORT */
28709 +
28710 +A_STATUS
28711 +wmi_set_wsc_status_cmd(struct wmi_t *wmip, A_UINT32 status)
28712 +{
28713 + void *osbuf;
28714 + char *cmd;
28715 +
28716 + wps_enable = status;
28717 +
28718 + osbuf = a_netbuf_alloc(sizeof(1));
28719 + if (osbuf == NULL) {
28720 + return A_NO_MEMORY;
28721 + }
28722 +
28723 + a_netbuf_put(osbuf, sizeof(1));
28724 +
28725 + cmd = (char *)(a_netbuf_to_data(osbuf));
28726 +
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));
28731 +}
28732 +
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
28736 --- /dev/null
28737 +++ b/drivers/sdio/function/wlan/ar6000/wmi/wmi_doc.h
28738 @@ -0,0 +1,4421 @@
28739 +/*
28740 + *
28741 + * Copyright (c) 2004-2007 Atheros Communications Inc.
28742 + * All rights reserved.
28743 + *
28744 + *
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;
28748 + *
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.
28753 + *
28754 + *
28755 + *
28756 + */
28757 +
28758 +
28759 +#if 0
28760 +Wireless Module Interface (WMI) Documentaion
28761 +
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.
28766 +
28767 +Data Frames
28768 +
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.
28774 +
28775 +WMI Message Structure
28776 +
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:
28781 +
28782 + {
28783 + INT8 rssi
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.
28786 + UINT8 info
28787 + Contains information on message type and user priority. Message type
28788 + differentiates between a data packet and a synchronization message.
28789 + } WMI_DATA_HDR
28790 +
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).
28796 +
28797 +Data Endpoints
28798 +
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.
28802 +
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.
28807 +
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.
28813 +
28814 +Connection States
28815 +
28816 + Table B-1 describes the AR6000 WLAN connection states:
28817 +
28818 + Table B-1. AR6000 Connection States
28819 +
28820 +Connection State
28821 + Description
28822 +
28823 + DISCONNECTED
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
28830 + event.
28831 +
28832 +CONNECTED
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.
28838 +
28839 +
28840 +Message Types
28841 +
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:
28845 +
28846 +Table B-2. AR6000 Message Types
28847 +
28848 +Message Type
28849 + Description
28850 +
28851 +Commands
28852 + Control messages that flow from the host to the device
28853 +
28854 +Replies/Events
28855 + Control messages that flow from the device to the host.
28856 +
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.
28861 +
28862 +
28863 +WMI Message Format
28864 +
28865 + All WMI control commands, replies and events use the header format:
28866 +
28867 + WMI_CMD_HDR Header Format
28868 + {
28869 + UINT16 id
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.
28872 + WMI_CMD_HDR
28873 + }
28874 +
28875 +
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.
28884 +
28885 +Command Restrictions
28886 +
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.
28892 +
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.
28896 +
28897 +Command and Data Synchronization
28898 +
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.
28902 +
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.
28909 +
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
28916 + command.
28917 +
28918 +
28919 +
28920 +WMI Commands
28921 +
28922 + ADD_BAD_AP
28923 + Cause the AR6000 device to avoid a particular AP
28924 + ADD_CIPHER_KEY
28925 + Add or replace any of the four AR6000 encryption keys
28926 + ADD_WOW_PATTERN
28927 + Used to add a pattern to the WoW pattern list
28928 + CLR_RSSI_SNR
28929 + Clear the current calculated RSSI and SNR value
28930 + CONNECT_CMD
28931 + Request that the AR6000 device establish a wireless connection
28932 + with the specified SSID
28933 + CREATE_PSTREAM
28934 + Create prioritized data endpoint between the host and device
28935 + DELETE_BAD_AP
28936 + Clear an entry in the bad AP table
28937 + DELETE_CIPHER_KEY
28938 + Delete a previously added cipher key
28939 + DELETE_PSTREAM
28940 + Delete a prioritized data endpoint
28941 + DELETE_WOW_PATTERN
28942 + Remove a pre-specified pattern from the WoW pattern list
28943 + EXTENSION
28944 + WMI message interface command
28945 + GET_BIT_RATE
28946 + Retrieve rate most recently used by the AR6000
28947 + GET_CHANNEL_LIST
28948 + Retrieve list of channels used by the AR6000
28949 + GET_FIXRATES
28950 + Retrieves the rate-mask set via the SET_FIXRATES command.
28951 + GET_PMKID_LIST_CMD
28952 + Retrieve the firmware list of PMKIDs
28953 + GET_ROAM_DATA
28954 + Internal use for data collection; available in special build only
28955 + GET_ROAM_TBL
28956 + Retrieve the roaming table maintained on the target
28957 + GET_TARGET_STATS
28958 + Request that the target send the statistics it maintains
28959 + GET_TX_PWR
28960 + Retrieve the current AR6000 device Tx power levels
28961 + GET_WOW_LIST
28962 + Retrieve the current list of WoW patterns
28963 + LQ_THRESHOLD_PARAMS
28964 + Set the link quality thresholds
28965 + OPT_TX_FRAME
28966 + Send a special frame (special feature)
28967 + RECONNECT
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
28972 + SCAN_PARAMS
28973 + Determine dwell time and changes scanned channels
28974 + SET_ACCESS_PARAMS
28975 + Set access parameters for the wireless network
28976 + SET_ADHOC_BSSID
28977 + Set the BSSID for an ad hoc network
28978 + SET_AKMP_PARAMS
28979 + Set multiPMKID mode
28980 + SET_APPIE
28981 + Add application-specified IE to a management frame
28982 + SET_ASSOC_INFO
28983 + Specify the IEs the device should add to association or
28984 + reassociation requests
28985 + SET_AUTH_MODE
28986 + Set 802.11 authentication mode of reconnection
28987 + SET_BEACON_INT
28988 + Set the beacon interval for an ad hoc network
28989 + SET_BIT_RATE
28990 + Set the AR6000 to a specific fixed bit rate
28991 + SET_BMISS_TIME
28992 + Set the beacon miss time
28993 + SET_BSS_FILTER
28994 + Inform the AR6000 of network types about which it wants to
28995 + receive information using a \93BSSINFO\94 event
28996 + SET_BT_PARAMS
28997 + Set the status of a Bluetooth stream (SCO or A2DP) or set
28998 + Bluetooth coexistence register parameters
28999 + SET_BT_STATUS
29000 + Set the status of a Bluetooth stream (SCO or A2DP)
29001 + SET_CHANNEL_PARAMETERS
29002 + Configure WLAN channel parameters
29003 + SET_DISC_TIMEOUT
29004 + Set the amount of time the AR6000 spends attempting to
29005 + reestablish a connection
29006 + SET_FIXRATES
29007 + Set the device to a specific fixed PHY rate (supported subset)
29008 + SET_HALPARAM
29009 + Internal AR6000 command to set certain hardware parameters
29010 + SET_HOST_SLEEP_MODE
29011 + Set the host mode to asleep or awake
29012 + SET_IBSS_PM_CAPS
29013 + Support a non-standard power management scheme for an
29014 + ad hoc network
29015 + SET_LISTEN_INT
29016 + Request a listen interval
29017 + SET_LPREAMBLE
29018 + Override the short preamble capability of the AR6000 device
29019 + SET_MAX_SP_LEN
29020 + Set the maximum service period
29021 + SET_OPT_MODE
29022 + Set the special mode on/off (special feature)
29023 + SET_PMKID
29024 + Set the pairwise master key ID (PMKID)
29025 + SET_PMKID_LIST_CMD
29026 + Configure the firmware list of PMKIDs
29027 + SET_POWER_MODE
29028 + Set guidelines on trade-off between power utilization
29029 + SET_POWER_PARAMS
29030 + Configure power parameters
29031 + SET_POWERSAVE_PARAMS
29032 + Set the two AR6000 power save timers
29033 + SET_PROBED_SSID
29034 + Provide list of SSIDs the device should seek
29035 + SET_REASSOC_MODE
29036 + Specify whether the disassociated frame should be sent upon
29037 + reassociation
29038 + SET_RETRY_LIMITS
29039 + Limit how many times the device tries to send a frame
29040 + SET_ROAM_CTRL
29041 + Control roaming behavior
29042 + SET_RTS
29043 + Determine when RTS should be sent
29044 + SET_SCAN_PARAMS
29045 + Set the AR6000 scan parameters
29046 + SET_TKIP_COUNTERMEASURES
29047 + Enable/disable reports of TKIP MIC errors
29048 + SET_TX_PWR
29049 + Specify the AR6000 device Tx power levels
29050 + SET_VOICE_PKT_SIZE
29051 + Set voice packet size
29052 + SET_WMM
29053 + Override the AR6000 WMM capability
29054 + SET_WMM_TXOP
29055 + Configure TxOP bursting when sending traffic to a WMM-
29056 + capable AP
29057 + SET_WOW_MODE
29058 + Enable/disable WoW mode
29059 + SET_WSC_STATUS
29060 + Enable/disable profile check in cserv when the WPS protocol
29061 + is in progress
29062 + SNR_THRESHOLD_PARAMS
29063 + Configure how the device monitors and reports SNR of BSS
29064 + START_SCAN
29065 + Start a long or short channel scan
29066 + SYNCHRONIZE
29067 + Force a synchronization point between command and data
29068 + paths
29069 + TARGET_REPORT_ERROR_BITMASK
29070 + Control \93ERROR_REPORT\94 events from the AR6000
29071 +
29072 +
29073 +
29074 +
29075 +Name
29076 + ADD_BAD_AP
29077 +
29078 +Synopsis
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.
29082 +
29083 + If the AR6000 are currently connected to the AP specified in this command, they
29084 + disassociate.
29085 +
29086 +Command
29087 + wmiconfig eth1 --badap <bssid> <badApIndex>
29088 +
29089 +Command Parameters
29090 + UINT8 badApIndex Index [0...1] that identifies which entry in the
29091 + bad AP table to use
29092 +
29093 +
29094 + UINT8 bssid[6] MAC address of the AP to avoid
29095 +
29096 +Command Values
29097 + badApIndex = 0, 1 Entry in the bad AP table to use
29098 +
29099 +Reset Value
29100 + The bad AP table is cleared
29101 +
29102 +Restrictions
29103 + None
29104 +
29105 +See Also
29106 + \93DELETE_BAD_AP\94 on page B-13
29107 +
29108 +=====================================================================
29109 +Name
29110 + ADD_CIPHER_KEY
29111 +
29112 +Synopsis
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.
29118 +
29119 +Command
29120 + wmiconfig eth1 --cipherkey <keyIndex> <keyType> <keyUsage>
29121 + <keyLength> <keyopctrl> <keyRSC> <key>
29122 +
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
29135 + Command Values
29136 + {
29137 + NONE_CRYPT = 1
29138 + WEP_CRYPT = 2
29139 + TKIP_CRYPT = 3
29140 + AES_CRYPT = 4
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
29147 + } CRYPTO_TYPE
29148 +
29149 + {
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
29155 + } KEY_USAGE
29156 +
29157 +Reset Value
29158 + The four available keys are disabled.
29159 +
29160 +Restrictions
29161 + The cipher should correspond to the encryption mode specified in the \93CONNECT\94
29162 + command.
29163 +
29164 +See Also
29165 + \93DELETE_CIPHER_KEY\94
29166 +
29167 +=====================================================================
29168 +
29169 +
29170 +Name
29171 + ADD_WOW_PATTERN
29172 +
29173 +Synopsis
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.
29179 +
29180 +Command
29181 + wmiconfig \96addwowpattern <list-id> <filter-size> <filter-offset>
29182 + <pattern> <mask>
29183 +
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
29191 +
29192 +Reply Parameters
29193 + None
29194 +
29195 +Reset Value
29196 + None defined (default host mode is awake)
29197 +
29198 +Restrictions
29199 + None
29200 +
29201 +See Also
29202 + \93DELETE_WOW_PATTERN\94
29203 +
29204 +=====================================================================
29205 +
29206 +
29207 +Name
29208 + CLR_RSSI_SNR
29209 +
29210 +Synopsis
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.
29214 +
29215 +Command
29216 + wmiconfig eth1 --cleanRssiSnr
29217 +
29218 +Command Parameters
29219 + None
29220 +
29221 +Reply Parameters
29222 + None
29223 +
29224 +Reset Value
29225 + None defined
29226 +
29227 +Restrictions
29228 + None
29229 +
29230 +=====================================================================
29231 +
29232 +Name
29233 + CONNECT_CMD
29234 +
29235 +Synopsis
29236 + New connect control information (connectCtrl) is added, with 32 possible modifiers.
29237 +
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
29242 + sent to the AP.
29243 +
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.
29249 +
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.
29260 +
29261 + CONNECT_IGNORE_AAC_BEACON
29262 + Ignore the Admission Capacity information in the
29263 + beacon of the AP
29264 +
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
29268 +
29269 +Command
29270 + wmiconfig --setconnectctrl <ctrl flags bitmask>
29271 +
29272 +Command Parameters
29273 + typedef struct{
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;
29287 +
29288 + ctrl flags bitmask
29289 + = 0x0001 CONNECT_ASSOC_POLICY_USER
29290 + Assoc frames are sent using the policy specified by
29291 + the flag
29292 + = 0x0002 CONNECT_SEND_REASSOC
29293 + Send Reassoc frame while connecting, otherwise send
29294 + assoc frames
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
29301 + beacon
29302 + ... CONNECT_CMD, continued
29303 + Command Values
29304 + typedef enum {
29305 + INFRA_NETWORK = 0x01,
29306 + ADHOC_NETWORK = 0x02,
29307 + ADHOC_CREATOR = 0x04,
29308 + } NETWORK_TYPE;
29309 +
29310 + typedef enum {
29311 + OPEN_AUTH = 0x01,
29312 + SHARED_AUTH = 0x02,
29313 + LEAP_AUTH = 0x04,
29314 + } DOT11_AUTH_MODE;
29315 + typedef enum {
29316 + NONE_AUTH = 0x01,
29317 + WPA_AUTH = 0x02,
29318 + WPA_PSK_AUTH = 0x03,
29319 + WPA2_AUTH = 0x04,
29320 + WPA2_PSK_AUTH = 0x05,
29321 + WPA_AUTH_CCKM = 0x06,
29322 + WPA2_AUTH_CCKM = 0x07,
29323 + } AUTH_MODE;
29324 + typedef enum {
29325 + NONE_CRYPT = 0x01,
29326 + WEP_CRYPT = 0x02,
29327 + TKIP_CRYPT = 0x03,
29328 + AES_CRYPT = 0x04,
29329 + } CRYPTO_TYPE;
29330 + typedef enum {
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;
29337 +
29338 + pairwiseCryptoLen and groupCryptoLen are valid when the respective
29339 + CryptoTypesis WEP_CRYPT, otherwise this value should be 0. This is the length in
29340 + bytes.
29341 +
29342 +Reset Value
29343 + None defined
29344 +
29345 +Restrictions
29346 + None
29347 +
29348 +=====================================================================
29349 +
29350 +
29351 +Name
29352 + CREATE_PSTREAM
29353 +
29354 +Synopsis
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.
29363 +
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
29375 +
29376 +Command
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:
29383 +
29384 + <user priority>
29385 + 802.1D user priority range (0\967)
29386 + <direction>
29387 + = 0 Tx (uplink) traffic
29388 + = 1 Rx (downlink) traffic
29389 + = 2 Bi-directional traffic
29390 + <traffic class>
29391 + = 1 BK
29392 + = 2 VI
29393 + = 3 VO
29394 + <trafficType>
29395 + = 0 Aperiodic
29396 + = 1 Periodic
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>
29405 + (In ms)
29406 + <max service interval>
29407 + Inactivity interval (in ms) (0 = Infinite)
29408 + <suspension interval>
29409 + (In ms)
29410 + <service start time>
29411 + Service start time
29412 + <tsid>
29413 + TSID range (0\9615)
29414 + <nominal MSDU>
29415 + Nominal MAC SDU size
29416 + <max MSDU>
29417 + Maximum MAC SDU size
29418 + <min data rate>
29419 + Minimum data rate (in bps)
29420 + <mean data rate>
29421 + Mean data rate (in bps)
29422 + <peak data rate>
29423 + Peak data rate (in bps)
29424 + <max burst size>
29425 + Maximum burst size (in bps)
29426 + <delay bound>
29427 + Delay bound
29428 + <min phy rate>
29429 + Minimum PHY rate (in bps)
29430 + <sba>
29431 + Surplus bandwidth allowance
29432 + <medium time>
29433 + Medium time in TU of 32-ms periods per sec
29434 + ... CREATE_PSTREAM (continued)
29435 +
29436 +Command Parameters
29437 + UINT8 trafficClass TRAFFIC_CLASS value
29438 + UINT8 traffic
29439 + Direction
29440 + DIR_TYPE value
29441 + UINT8 rxQueueNum
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
29447 + UINT8 voicePS
29448 +Capability
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)
29472 +Command Values
29473 + {
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
29479 + } TRAFFIC_CLASS
29480 + {
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
29485 + } DIR_TYPE
29486 + {
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
29492 +
29493 + ... CREATE_PSTREAM (continued)
29494 +
29495 +
29496 + VI BE BK Supported, Y/N?
29497 + 0 0 0 0 Y
29498 + 0 0 0 1 Y
29499 + 0 0 1 0 N
29500 + 0 0 1 1 N
29501 + 0 1 0 0 Y
29502 + 0 1 0 1 Y
29503 + 0 1 1 0 N
29504 + 0 1 1 1 N
29505 + 1 0 0 0 Y
29506 + 1 0 0 1 Y
29507 + 1 0 1 0 N
29508 + 1 1 0 0 N
29509 + 1 1 0 1 Y
29510 + 1 1 0 0 N
29511 + 1 1 1 0 N
29512 + 1 1 1 1 Y
29513 +
29514 +Reset Value
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)
29517 +
29518 +Restrictions
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
29522 + each AC.
29523 +
29524 +See Also
29525 + \93DELETE_PSTREAM\94
29526 +=====================================================================
29527 +
29528 +Name
29529 + DELETE_BAD_AP
29530 +
29531 +Synopsis
29532 + The host uses this command to clear a particular entry in the bad AP table
29533 +
29534 +Command
29535 + wmiconfig eth1 --rmAP [--num=<index>] // used to clear a badAP
29536 + entry. num is index from 0-3
29537 +
29538 +Command Parameters
29539 + UINT8 badApIndex Index [0...n] that identifies the entry in the bad
29540 + AP table to delete
29541 +
29542 +Command Values
29543 + badApIndex = 0, 1, 2, 3
29544 + Entry in the bad AP table
29545 +
29546 +Reset Value
29547 + None defined
29548 +
29549 +Restrictions
29550 + None
29551 +
29552 +See Also
29553 + \93ADD_BAD_AP\94
29554 +
29555 +=====================================================================
29556 +
29557 +
29558 +Name
29559 + DELETE_CIPHER_KEY
29560 +
29561 +Synopsis
29562 + The host uses this command to delete a key that was previously added with the
29563 + \93ADD_CIPHER_KEY\94 command.
29564 +
29565 +Command
29566 + TBD
29567 +
29568 +Command Parameters
29569 + UINT8 keyIndex Index (0...3) of the key to be deleted
29570 +
29571 +Command Values
29572 + keyIndex = 0, 1,2, 3 Key to delete
29573 +
29574 +Reset Value
29575 + None
29576 +
29577 +Restrictions
29578 + The host should not delete a key that is currently in use by the AR6000.
29579 +
29580 +See Also
29581 + \93ADD_CIPHER_KEY\94
29582 +
29583 +=====================================================================
29584 +
29585 +Name
29586 + DELETE_PSTREAM
29587 +
29588 +Synopsis
29589 + The host uses this command to delete a prioritized data endpoint created by a
29590 + previous \93CREATE_PSTREAM\94 command
29591 +
29592 +Command
29593 + --deleteqos <trafficClass> <tsid>, where:
29594 +
29595 + <traffic class>
29596 + = 0 BE
29597 + = 1 BK
29598 + = 2 VI
29599 + = 3 VO
29600 + <tsid>
29601 + The TSpec ID; use the -qosqueue option
29602 + to get the active TSpec IDs for each traffic class
29603 +
29604 +Command Parameters
29605 + A_UINT8 trafficClass Indicate the traffic class of the stream
29606 + being deleted
29607 +
29608 +Command Values
29609 + {
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
29614 + } TRAFFIC CLASS
29615 +
29616 + 0-15 for TSID
29617 +
29618 +Reply Values
29619 + N/A
29620 +
29621 +Restrictions
29622 + This command should only be issued after a \93CREATE_PSTREAM\94 command has
29623 + successfully created a prioritized stream
29624 +
29625 +See Also
29626 + \93CREATE_PSTREAM\94
29627 +
29628 +=====================================================================
29629 +
29630 +
29631 +Name
29632 + DELETE_WOW_PATTERN
29633 +
29634 +Synopsis
29635 + The host uses this command to remove a pre-specified pattern from the
29636 + WoW pattern list.
29637 +
29638 +Command
29639 + wmiconfig \96delwowpattern <list-id> <pattern-id>
29640 +
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
29645 +
29646 +Reply Parameters
29647 + None
29648 +
29649 +
29650 +
29651 +Reset Value
29652 + None defined
29653 +
29654 +Restrictions
29655 + None
29656 +
29657 +See Also
29658 + \93ADD_WOW_PATTERN\94
29659 +
29660 +=====================================================================
29661 +
29662 +
29663 +Name
29664 + EXTENSION
29665 +
29666 +Synopsis
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.
29672 +
29673 +Command
29674 + N/A
29675 +
29676 +Command Parameters
29677 + Command-specific
29678 +
29679 +Command Values
29680 + Command-specific
29681 +
29682 +Reply Parameters
29683 + Command-specific
29684 +
29685 +Reset Values
29686 + None defined
29687 +
29688 +Restrictions
29689 + None defined
29690 +
29691 +=====================================================================
29692 +
29693 +
29694 +Name
29695 + GET_BIT_RATE
29696 +
29697 +Synopsis
29698 + Used by the host to obtain the rate most recently used by the AR6000 device
29699 +
29700 +Command
29701 + wmiconfig eth1 --getfixrates
29702 +
29703 +Command Parameters
29704 + None
29705 +
29706 +
29707 +
29708 +Reply Parameters
29709 + INT8
29710 + rateIndex
29711 + See the \93SET_BIT_RATE\94 command
29712 +
29713 +Reset Values
29714 + None
29715 +
29716 +Restrictions
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
29719 +
29720 +See Also
29721 + \93SET_BIT_RATE\94
29722 +
29723 +=====================================================================
29724 +
29725 +
29726 +Name
29727 + GET_CHANNEL_LIST
29728 +
29729 +Synopsis
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.
29732 +
29733 +Command
29734 + TBD
29735 +
29736 +Command Parameters
29737 + None
29738 +
29739 +Reply Parameters
29740 + UINT8 reserved Reserved
29741 + UINT8 numberOfChannels Number of channels the reply contains
29742 + UINT16 channelList[numberOfChannels] Array of channel frequencies (in MHz)
29743 +
29744 +Reset Values
29745 + None defined
29746 +
29747 +Restrictions
29748 + The maximum number of channels that can be reported are 32
29749 +
29750 +=====================================================================
29751 +
29752 +
29753 +Name
29754 + GET_FIXRATES
29755 +
29756 +Synopsis
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.
29760 +
29761 +Synopsis
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.
29764 +
29765 +Command
29766 + wmiconfig eth1 --getfixrates
29767 +
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
29773 +
29774 +Reply Parameters
29775 + None
29776 +
29777 +Reset Value
29778 + None defined
29779 +
29780 +Restrictions
29781 + None
29782 +
29783 +See Also
29784 + \93SET_FIXRATES\94
29785 +
29786 +=====================================================================
29787 +
29788 +
29789 +
29790 +Name
29791 + GET_PMKID_LIST_CMD
29792 +
29793 +Synopsis
29794 + Retrieves the list of PMKIDs on the firmware. The
29795 + WMI_GET_PMKID_LIST_EVENT is generated by the firmware.
29796 +
29797 +Command
29798 + TBD
29799 +
29800 +Command Parameters
29801 +
29802 +Reset Values
29803 + None
29804 +
29805 +Restrictions
29806 + None
29807 +
29808 +See Also
29809 + SET_PMKID_LIST_CMD GET_PMKID_LIST_EVENT
29810 +
29811 +=====================================================================
29812 +
29813 +
29814 +Name
29815 + GET_ROAM_TBL
29816 +
29817 +Synopsis
29818 + Retrieve the roaming table maintained on the target. The response is reported
29819 + asynchronously through the ROAM_TBL_EVENT.
29820 +
29821 +Command
29822 + wmiconfig --getroamtable <roamctrl> <info>
29823 +
29824 +Command Parameters
29825 + A_UINT8 roamCtrlType;
29826 + A_UINT16 roamMode
29827 + A_UINT16 numEntries
29828 + WMI_BSS_ROAM_INFO bssRoamInfo[1]
29829 +
29830 +Reply Value
29831 + Reported asynchronously through the ROAM_TBL_EVENT
29832 +
29833 +Reset Value
29834 + None defined
29835 +
29836 +Restrictions
29837 + None
29838 +
29839 +See Also
29840 + SET_KEEPALIVE
29841 +
29842 +=====================================================================
29843 +
29844 +
29845 +Name
29846 + GET_TARGET_STATS
29847 +
29848 +Synopsis
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.
29853 +
29854 +Command
29855 + wmiconfig --getTargetStats --clearStats
29856 +
29857 +Command Parameters
29858 + TARGET_STATS targetStats
29859 + WMI_TARGET_STATS
29860 + UINT8 clearStats
29861 +
29862 +
29863 +Reply Value
29864 + RSSI return value (0\96100)
29865 +
29866 +Reset Values
29867 + All statistics are cleared (zeroed)
29868 +
29869 +Restrictions
29870 + The --getTargetStats option must be used; the --clearStats option is also available also
29871 +
29872 +
29873 +=====================================================================
29874 +
29875 +Name
29876 + GET_TX_PWR
29877 +
29878 +Synopsis
29879 + The host uses this command to retrieve the current Tx power level
29880 +
29881 +Command
29882 + wmiconfig -i eth1 --getpower
29883 +
29884 +Command Parameters
29885 + None
29886 +
29887 +Reply Parameters
29888 + UINT16 dbM The current Tx power level specified in dbM
29889 +
29890 +Reset Values
29891 + The maximum permitted by the regulatory domain
29892 +
29893 +Restrictions
29894 + None
29895 +
29896 +See Also
29897 + \93SET_TX_PWR\94
29898 +
29899 +=====================================================================
29900 +
29901 +
29902 +Name
29903 + GET_WOW_LIST
29904 +
29905 +Synopsis
29906 + The host uses this command to retrieve the current list of WoW patterns.
29907 +
29908 +Command
29909 + wmiconfig \96getwowlist <list-id>
29910 +
29911 +Command Parameters
29912 + A_UINT8 filter_list_id ID of the list of WoW patterns to retrieve
29913 +
29914 +Reply Value(s)
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)
29922 +
29923 +Reset Value
29924 + None defined
29925 +
29926 +Restrictions
29927 + None
29928 +
29929 +See Also
29930 + \93SET_WSC_STATUS\94
29931 +
29932 +=====================================================================
29933 +
29934 +
29935 +Name
29936 + LQ_THRESHOLD_PARAMS
29937 +
29938 +Synopsis
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.
29941 +
29942 +Command
29943 + --lqThreshold <enable> <upper_threshold_1> ...
29944 + <upper_threshold_4> <lower_threshold_1> ... <lower_threshold_4>
29945 +
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
29950 + ascending order
29951 + <lower_threshold_x> Below thresholds (value in [0,100]), in
29952 + ascending order
29953 +
29954 +Command Values
29955 + See command parameters
29956 +
29957 +Reset Value
29958 + None defined
29959 +
29960 +Restrictions
29961 + None
29962 +
29963 +=====================================================================
29964 +
29965 +
29966 +Name
29967 + OPT_TX_FRAME
29968 +
29969 +Synopsis
29970 + Special feature, sends a special frame.
29971 +
29972 +Command
29973 + wmiconfig --sendframe <frmType> <dstaddr> <bssid> <optIEDatalen>
29974 + <optIEData>
29975 +
29976 +Command Parameters
29977 + {
29978 + A_UINT16 optIEDataLen;
29979 + A_UINT8 frmType;
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;
29984 +
29985 +Command Values
29986 + <frmtype> = 1 Probe request frame
29987 + = 2 Probe response frame
29988 + = 3 CPPP start
29989 + = 4 CPPP stop
29990 +
29991 +Reset Value
29992 + None defined
29993 +
29994 +Restrictions
29995 + Send a special frame only when special mode is on.
29996 +
29997 +=====================================================================
29998 +
29999 +
30000 +Name
30001 + RECONNECT
30002 +
30003 +Synopsis
30004 + This command requests a reconnection to a BSS to which the AR6000 device was
30005 + formerly connected
30006 +
30007 +Command
30008 + TBD
30009 +
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
30014 +
30015 +Command Values
30016 + None
30017 +
30018 +Reset Values
30019 + None
30020 +
30021 +Restrictions
30022 + None
30023 +
30024 +See Also
30025 + \93CONNECT_CMD\94
30026 +
30027 +=====================================================================
30028 +
30029 +
30030 +Name
30031 + RSSI_THRESHOLD_PARAMS
30032 +
30033 +Synopsis
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).
30040 +
30041 +Command
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>
30047 +
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)
30054 +
30055 +Command Values
30056 + None defined
30057 +
30058 +Reset Values
30059 + pollTime is 0, and sampling is disabled
30060 +
30061 +Restrictions
30062 + Can only be issued if the AR6000 device is connected
30063 +
30064 +
30065 +=====================================================================
30066 +
30067 +Name
30068 + SCAN_PARAMS
30069 +
30070 +Synopsis
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.
30075 +
30076 +Command
30077 + wmiconfig -scan -minact=<ms> --maxact=<ms>
30078 +
30079 +Command Parameters
30080 + UINT16 maxact Channel dwell time (in ms), default = 0
30081 + UINT16 minact Channel dwell time (in ms), default = 105
30082 +
30083 +Command Values
30084 + See channel parameters
30085 +
30086 +Reset Values
30087 + None defined
30088 +
30089 +Restrictions
30090 + The minact value should be greater than 0; maxact should be between 5\9665535 ms
30091 + and greater than minact
30092 +
30093 +=====================================================================
30094 +
30095 +
30096 +Name
30097 + SET_ACCESS_PARAMS
30098 +
30099 +Synopsis
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.
30102 +
30103 +Command
30104 + wmiconfig eth1 --acparams --txop <limit> --cwmin <0-15>
30105 + --cwmax <0-15> --aifsn<0-15>
30106 +
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
30114 +
30115 +Command Values
30116 + None
30117 +
30118 +Reset Values
30119 + Reasonable defaults that vary, between endpoints (prioritized streams)
30120 +
30121 +Restrictions
30122 + None
30123 +
30124 +=====================================================================
30125 +
30126 +
30127 +Name
30128 + SET_ADHOC_BSSID
30129 +
30130 +Synopsis
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).
30134 +
30135 +Command
30136 + wmiconfig eth1 --adhocbssid <bssid>
30137 +
30138 +Command Parameters
30139 + A_UINT8 bssid[ATH_MAC_LEN] BSSID is specified in xx:xx:xx:xx:xx:xx format
30140 +
30141 +Command Values
30142 + None
30143 +
30144 +Reset Values
30145 + None
30146 +
30147 +Restrictions
30148 + None
30149 +
30150 +=====================================================================
30151 +
30152 +
30153 +Name
30154 + SET_AKMP_PARAMS
30155 +
30156 +Synopsis
30157 + Enables or disables multi PMKID mode.
30158 +
30159 +Command
30160 + wmiconfig eth1 --setakmp --multipmkid=<on/off>
30161 +
30162 +Command Parameters
30163 + typedef struct {
30164 + A_UINT32 akmpInfo;
30165 + } WMI_SET_AKMP_PARAMS_CMD;
30166 +
30167 +Command Values
30168 + akmpInfo;
30169 + bit[0] = 0
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.
30173 + bit[0] = 1
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.
30177 +
30178 +Reset Values
30179 + MultiPMKID mode is disabled
30180 +
30181 +Restrictions
30182 + None
30183 +
30184 +=====================================================================
30185 +
30186 +
30187 +Name
30188 + SET_APPIE
30189 +
30190 +Synopsis
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.
30193 +
30194 +Command
30195 + wmiconfig --setappie <frame> <IE>, where:
30196 +
30197 + frame
30198 + One of beacon, probe, respon, assoc
30199 +
30200 + IE
30201 + A hex string beginning with DD (if = 0, no
30202 + IE is sent in the management frame)
30203 +
30204 +Command Parameters
30205 + mgmtFrmType;
30206 + A WMI_MGMT_FRAME_TYPE
30207 +
30208 + ieLen;
30209 + Length of the IE to add to the GMT frame
30210 +
30211 +Command Values
30212 + None
30213 +
30214 +Reset Value
30215 + None defined
30216 +
30217 +Restrictions
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.
30220 +
30221 +=====================================================================
30222 +
30223 +
30224 +Name
30225 + SET_ASSOC_INFO
30226 +
30227 +Synopsis
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.
30232 +
30233 +Command
30234 + wmiconfig eth1 --setAssocIe <IE>
30235 +
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
30241 +
30242 +Command Values
30243 + None
30244 +
30245 +Reset Values
30246 + IEs are cleared
30247 +
30248 +Restrictions
30249 + This command can only be issued in the DISCONNECTED state
30250 +
30251 +=====================================================================
30252 +
30253 +
30254 +Name
30255 + SET_AUTHMODE
30256 +
30257 +Synopsis
30258 + Sets the 802.11 authentication mode of reconnection
30259 +
30260 +Command
30261 + wmiconfig eth1 --setauthmode <mode>
30262 +
30263 +Command Parameters
30264 + UINT8 mode
30265 +
30266 +Command Values
30267 + mode = 0x00 Proceed with authentication during reconnect
30268 + = 0x01 Do not proceed with authentication during reconnect
30269 +
30270 +Reset Values
30271 + Authentication
30272 +
30273 +Restrictions
30274 + None
30275 +
30276 +=====================================================================
30277 +
30278 +
30279 +Name
30280 + SET_BEACON_INT
30281 +
30282 +Synopsis
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.
30287 +
30288 +Command
30289 + wmiconfig eth1 --ibssconintv
30290 +
30291 +Command Parameters
30292 + UINT16 beaconInterval Specifies the beacon interval in TU units (1024 ms)
30293 +
30294 +Command Values
30295 + None
30296 +
30297 +Reset Values
30298 + The default beacon interval is 100 TUs (102.4 ms)
30299 +
30300 +Restrictions
30301 + This command can only be issued before the AR6000 device starts an ad hoc network
30302 +
30303 +See Also
30304 + \93SET_IBSS_PM_CAPS\94
30305 +
30306 +=====================================================================
30307 +
30308 +
30309 +Name
30310 + SET_BIT_RATE
30311 +
30312 +Synopsis
30313 + The host uses this command to set the AR6000 device to a specific fixed rate.
30314 +
30315 +Command
30316 + wmiconfig eth1 --setfixrates <rate_0> ... <rate_n>
30317 +
30318 +Command Parameters
30319 + INT8 rateIndex
30320 + A WMI_BIT_RATE value
30321 + {
30322 + RATE_AUTO = -1
30323 + RATE_1Mb = 0
30324 + RATE_2Mb = 1
30325 + RATE_5_5M = 2
30326 + RATE_11Mb = 3
30327 + RATE_6Mb = 4
30328 + RATE_9Mb = 5
30329 + RATE_12Mb = 6
30330 + RATE_18Mb = 7
30331 + RATE_24Mb = 8
30332 + RATE_36Mb = 9
30333 + RATE_48Mb = 10
30334 + RATE_54Mb = 11
30335 + } WMI_BIT_RATE
30336 +
30337 +
30338 +Command Values
30339 + See command parameters
30340 +
30341 +Reset Values
30342 + The dynamic rate is determined by the AR6000 device
30343 +
30344 +Restrictions
30345 + This command is intended for use only during development/debug; it is not
30346 +intended for use in production
30347 +
30348 +See Also
30349 + \93GET_BIT_RATE\94
30350 +
30351 +=====================================================================
30352 +
30353 +
30354 +Name
30355 + SET_BMISS_TIME
30356 +
30357 +Synopsis
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.
30362 +
30363 +Command(s)
30364 + wmiconfig eth1 --setbmissbeacons=<val>
30365 + wmiconfig eth1 --setbmisstime=<val>
30366 +
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]
30371 +
30372 +Command Values
30373 + None
30374 +
30375 +Reset Values
30376 + bmissTime is 1500 TUs (1536 ms)
30377 +
30378 +Restrictions
30379 + None
30380 +
30381 +=====================================================================
30382 +
30383 +
30384 +Name
30385 + SET_BSS_FILTER
30386 +
30387 +Synopsis
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.
30395 +
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.
30398 +
30399 +Command
30400 + wmiconfig eth1 \96filter = <filter> --ieMask 0x<mask>
30401 +
30402 +Command Parameters
30403 + UINT8 BssFilter
30404 +
30405 + Command Values
30406 + typedef struct {
30407 + A_UINT8 bssFilter; See WMI_BSS_FILTER
30408 + A_UINT32 ieMask;
30409 + } __ATTRIB_PACK WMI_BSS_FILTER_CMD;
30410 +
30411 + The ieMask can take this combination of values:
30412 +
30413 + enum {
30414 + BSS_ELEMID_CHANSWITCH = 0x01
30415 + BSS_ELEMID_ATHEROS = 0x02,
30416 + }
30417 +
30418 +Reply Value
30419 + None
30420 +
30421 +Reset Value
30422 + BssFilter = NONE_BSS_FILTER (0)
30423 +
30424 +Restrictions
30425 + None
30426 +
30427 +See Also
30428 + \93CONNECT_CMD\94
30429 +
30430 +=====================================================================
30431 +
30432 +
30433 +Name
30434 + SET_BT_PARAMS
30435 +
30436 +Synopsis
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.
30440 +
30441 +Command
30442 + wmiconfig \96setBTparams <paramType> <params>
30443 +
30444 +Command Parameters
30445 + struct {
30446 + union {
30447 + BT_PARAMS_SCO scoParams;
30448 + BT_PARAMS_A2DP a2dpParams;
30449 + BT_PARAMS_MISC miscParams;
30450 + BT_COEX_REGS regs;
30451 + } info;
30452 + A_UINT8 paramType;
30453 + struct {
30454 + A_UINT8 noSCOPkts; Number of SCO packets between consecutive PS-POLLs
30455 + A_UINT8 pspollTimeout;
30456 + A_UINT8 stompbt;
30457 + } BT_PARAMS_SCO;
30458 + struct {
30459 + A2DP BT stream parameters
30460 + A_UINT32 period;
30461 + A_UINT32 dutycycle;
30462 + A_UINT8 stompbt;
30463 + } BT_PARAMS_A2DP;
30464 + struct {
30465 + union {
30466 + WLAN_PROTECT_POLICY_TYPE protectParams;
30467 + A_UINT16 wlanCtrlFlags;
30468 + }info;
30469 + A_UINT8 paramType;
30470 + } BT_PARAMS_MISC;
30471 + struct {
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
30478 + A_UINT8 setVal;
30479 + } BT_COEX_REGS;
30480 +
30481 +Command Values
30482 + None defined
30483 +
30484 +Reset Value
30485 + None
30486 +
30487 +Restrictions
30488 + None
30489 +
30490 +=====================================================================
30491 +
30492 +
30493 +Name
30494 + SET_BT_STATUS
30495 +
30496 +Synopsis
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.
30499 +
30500 +Command
30501 + wmiconfig \96setBTstatus <streamType> <status>
30502 +
30503 +Command Parameters
30504 + {
30505 + A_UINT8 streamType; Stream type
30506 + A_UINT8 status; Stream status
30507 + }WMI_SET_BT_STATUS_CMD;
30508 +
30509 +Command Values
30510 + {
30511 + BT_STREAM_UNDEF = 0
30512 + BT_STREAM_SCO
30513 + SCO stream
30514 + BT_STREAM_A2DP
30515 + A2DP stream
30516 + BT_STREAM_MAX
30517 + } BT_STREAM_TYPE;
30518 +
30519 + {
30520 + BT_STATUS_UNDEF = 0
30521 + BT_STATUS_START
30522 + BT_STATUS_STOP
30523 + BT_STATUS_RESUME
30524 + BT_STATUS_SUSPEND
30525 + BT_STATUS_MAX
30526 + } BT_STREAM_STATUS;
30527 +
30528 +Reset Value
30529 + None defined
30530 +
30531 +Restrictions
30532 + None
30533 +
30534 +=====================================================================
30535 +
30536 +
30537 +Name
30538 + SET_CHANNEL_PARAMETERS
30539 +
30540 +Synopsis
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.
30546 +
30547 +Command
30548 + wmiconfig eth1 --wmode <mode> <list>
30549 +
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.
30563 +
30564 +Command Values
30565 + phyMode = {
30566 + Wireless mode
30567 + 11a = 0x01
30568 + 11g = 0x02
30569 + 11ag = 0x03
30570 + 11b = 0x04
30571 + 11g only = 0x05
30572 + }
30573 +
30574 +Reset Values
30575 + phyMode
30576 + 11ag
30577 + 802.11a/g modules
30578 + 11g
30579 + 802.11g module
30580 + channels
30581 + Defaults to all channels permitted by the
30582 + current regulatory domain.
30583 +
30584 +Restrictions
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.
30587 +
30588 +=====================================================================
30589 +
30590 +
30591 +Name
30592 + SET_DISC_TIMEOUT
30593 +
30594 +Synopsis
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.
30601 +
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.
30606 +
30607 +Command
30608 + wmiconfig eth1 --disc=<timeout in seconds>
30609 +
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
30615 +
30616 +Command Values
30617 + None
30618 +
30619 +Reset Values
30620 + disconnectTimeout is 10 seconds
30621 +
30622 +Restrictions
30623 + This command can only be issued while in a DISCONNECTED state
30624 +
30625 +=====================================================================
30626 +
30627 +
30628 +Name
30629 + SET_FIXRATES
30630 +
30631 +Synopsis
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.
30637 +
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.
30643 +
30644 +Command
30645 + TBD
30646 +
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.
30653 +
30654 +Command Values
30655 + None
30656 +
30657 +Reset Value
30658 + None defined
30659 +
30660 +Restrictions
30661 + None
30662 +
30663 +See Also
30664 + \93GET_FIXRATES\94
30665 +
30666 +=====================================================================
30667 +
30668 +
30669 +Name
30670 + SET_WHAL_PARAM
30671 +
30672 +Synopsis
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.
30675 +
30676 +Command
30677 + TBD
30678 +
30679 +Command Parameters
30680 + ATH_HAL_SETCABTO_CMDID
30681 + Sets the timeout waiting for the multicast
30682 + traffic after a DTIM beacon (in TUs).
30683 +
30684 +Command Values
30685 + None
30686 +
30687 +Reset Value
30688 + Default = 10 TUs
30689 +
30690 +Restrictions
30691 + This command should be executed before issuing a connect command.
30692 +
30693 +=====================================================================
30694 +
30695 +
30696 +Name
30697 + SET_HOST_SLEEP_MODE
30698 +
30699 +Synopsis
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.
30705 +
30706 +Command
30707 + wmiconfig \96sethostmode=<asleep/awake>
30708 +
30709 +Command Parameters
30710 + A_BOOL awake Set the host mode to awake
30711 + A_BOOL asleep Set the host mode to asleep
30712 +
30713 +Command Values
30714 + 1 = awake, 0 = asleep
30715 +
30716 +Reset Value
30717 + None defined (default host mode is awake)
30718 +
30719 +Restrictions
30720 + None
30721 +
30722 +
30723 +=====================================================================
30724 +
30725 +Name
30726 + SET_IBSS_PM_CAPS
30727 +
30728 +Synopsis
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.
30733 +
30734 +Command
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>
30739 +
30740 +Command Parameters
30741 + UINT8 power_saving
30742 + = 0
30743 + The non-standard power saving scheme is
30744 + disabled and maximum throughput (with no
30745 + power saving) is obtained.
30746 +
30747 + = 1
30748 + Ad hoc power saving scheme is enabled (but
30749 + throughput may be decreased)
30750 +
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.
30756 +
30757 + The duration is communicated between wireless
30758 + STAs through an IE in beacons and probe responses.
30759 +
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.
30766 +
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
30770 + each.
30771 +
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.
30783 + Default = 10 ms
30784 +
30785 + UINT8 ttl
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
30790 +
30791 +Command Values
30792 + None
30793 +
30794 +Reset Values
30795 + By default, power_saving is enabled with atim_window = 20 ms
30796 +
30797 +Restrictions
30798 + Can only be issued before the AR6000 starts an ad hoc network
30799 +
30800 +See Also
30801 + \93SET_BEACON_INT\94
30802 +
30803 +=====================================================================
30804 +
30805 +
30806 +
30807 +Name
30808 + SET_LISTEN_INT
30809 +
30810 +Synopsis
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.
30817 +
30818 +Command
30819 + wmiconfig eth1 --listen=<#of TUs, can range from 15 to 3000>
30820 +
30821 + --listenbeacons=<#of beacons, can range from 1 to 50>
30822 +
30823 +Command Parameters
30824 + UINT16 listenInterval
30825 + Specifies the listen interval in Kms
30826 + (1024 ms), ranging from 100 to 1000
30827 +
30828 + UINT16 listenbeacons
30829 + Specifies the listen interval in beacons,
30830 + ranging from 1 to 50
30831 +
30832 +Command Values
30833 + None
30834 +
30835 +Reset Values
30836 + The device sets the listen interval equal to the beacon interval of the AP it associates
30837 + to.
30838 +
30839 +Restrictions
30840 + None
30841 +
30842 +=====================================================================
30843 +
30844 +
30845 +Name
30846 + SET_LPREAMBLE
30847 +
30848 +Synopsis
30849 + Overrides the short preamble capability of the AR6000 device
30850 +
30851 +Command
30852 + TBD
30853 +
30854 +Command Parameters
30855 + WMI_LPREAMBLE_DISABLED
30856 + The device is short-preamble capable
30857 +
30858 + WMI_LPREAMBLE_ENABLED
30859 + The device supports only the long-
30860 + preamble mode
30861 +
30862 +Command Values
30863 + None
30864 +
30865 +Reset Value
30866 + None defined
30867 +
30868 +Restrictions
30869 + None
30870 +
30871 +
30872 +=====================================================================
30873 +
30874 +Name
30875 + SET_MAX_SP_LEN
30876 +
30877 +Synopsis
30878 + Set the maximum service period; indicates the number of packets the AR6001 can
30879 + receive from the AP when triggered
30880 +
30881 +Command
30882 + wmiconfig eth1 --setMaxSPLength <maxSPLen>
30883 +
30884 +Command Parameters
30885 + UINT8 maxSPLen
30886 + An APSD_SP_LEN_TYPE value
30887 +
30888 +Command Values
30889 + {
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
30895 +
30896 +
30897 +Reset Values
30898 + maxSPLen is DELIVER_ALL_PKT
30899 +
30900 +Restrictions
30901 + None
30902 +
30903 +=====================================================================
30904 +
30905 +
30906 +Name
30907 + SET_OPT_MODE
30908 +
30909 +Synopsis
30910 + Special feature, sets the special mode on/off
30911 +
30912 +Command
30913 + wmiconfig eth1 --mode <mode>
30914 + Set the optional mode, where mode is special or off
30915 +
30916 +Command Parameters
30917 + enum {
30918 + SPECIAL_OFF
30919 + SPECIAL_ON
30920 + } OPT_MODE_TYPE;
30921 +
30922 +Command Values
30923 +
30924 +Reset Value
30925 + Mode = Off
30926 +
30927 +Restrictions
30928 + None
30929 +
30930 +=====================================================================
30931 +
30932 +
30933 +Name
30934 + SET_PMKID
30935 +
30936 +Synopsis
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.
30941 +
30942 +Command
30943 + wmiconfig eth1 --setbsspmkid --bssid=<aabbccddeeff>
30944 + --bsspmkid=<pmkid>
30945 +
30946 +Command Parameters
30947 + UINT8 bssid[6]
30948 + The MAC address of the AP that the
30949 + PMKID corresponds to (6 bytes in hex
30950 + format)
30951 +
30952 + UINT8 enable
30953 + Either PMKID_DISABLE (0) to disable
30954 + the PMKID or PMKID_ENABLE (1) to
30955 + enable it (16 bytes in hex format)
30956 +
30957 + UINT8 pmkid[16]
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
30962 +
30963 +Command Values
30964 + enable
30965 + = 0 (disable), 1 (enable)
30966 + PKMID enabled/disabled
30967 +
30968 +Reset Values
30969 + None defined
30970 +
30971 +Restrictions
30972 + Only supported in infrastructure networks
30973 +
30974 +=====================================================================
30975 +
30976 +
30977 +Name
30978 + SET_PMKID_LIST_CMD
30979 +
30980 +Synopsis
30981 + Configures the list of PMKIDs on the firmware.
30982 +
30983 +Command
30984 + wmiconfig --setpmkidlist --numpmkid=<n> --pmkid=<pmkid_1>
30985 + ... --pmkid=<pmkid_n>
30986 +
30987 + Where n is the number of pmkids (maximum = 8) and pmkid_i is the ith pmkid (16
30988 + bytes in hex format)
30989 +
30990 +Command Parameters
30991 + {
30992 + A_UINT8 pmkid[WMI_PMKID_LEN];
30993 + } __ATTRIB_PACK WMI_PMKID;
30994 +
30995 + {
30996 + A_UINT32 numPMKID;
30997 + WMI_PMKID pmkidList[WMI_MAX_PMKID_CACHE];
30998 + } __ATTRIB_PACK WMI_SET_PMKID_LIST_CMD;
30999 +
31000 +Command Values
31001 + None
31002 +
31003 +Reset Values
31004 + None
31005 +
31006 +Restrictions
31007 + Supported only in infrastructure modes
31008 +
31009 +=====================================================================
31010 +
31011 +
31012 +Name
31013 + SET_POWER_MODE
31014 +
31015 +Synopsis
31016 + The host uses this command to provide the AR6000 device with guidelines on the
31017 + desired trade-off between power utilization and performance.
31018 +
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.
31022 +
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
31025 + performance.
31026 +
31027 +Command
31028 + TBD
31029 +
31030 +Command Parameters
31031 + UINT8 powerMode
31032 + WMI_POWER_MODE value
31033 + {
31034 + REC_POWER = 1
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
31040 +
31041 + All other values are reserved
31042 + } WMI_POWER_MODE
31043 +
31044 +Command Values
31045 + See command parameters
31046 +
31047 +Reset Values
31048 + powerMode is REC_POWER
31049 +
31050 +Restrictions
31051 + This command should only be issued in the DISCONNECTED state for the
31052 + infrastructure network.
31053 +
31054 + For a PM-disabled ad hoc network, the power mode should remain in
31055 + MAX_PERF_POWER.
31056 +
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.
31060 +
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.
31063 +
31064 +=====================================================================
31065 +
31066 +
31067 +Name
31068 + SET_POWER_PARAMS
31069 +
31070 +Synopsis
31071 + The host uses this command to configure power parameters
31072 +
31073 +Command
31074 + wmiconfig eth1 --pmparams --it=<ms> --np=<number of PS POLL>
31075 + --dp=<DTIM policy: ignore/normal/stick>
31076 +
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
31081 + to SLEEP state
31082 +
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
31087 +
31088 + UINT16 dtim_policy
31089 + A WMI_POWER_PARAMS_CMD value
31090 +
31091 + {
31092 + IGNORE_DTIM =1
31093 + The device does not listen to any content after
31094 + beacon (CAB) traffic
31095 + NORMAL_DTIM = 2
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)
31099 + STICK_DTIM = 3
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
31104 +
31105 +Command Parameters
31106 + See command parameters
31107 +
31108 +Reset Values
31109 + idle_period
31110 + 200 ms
31111 +
31112 + pspoll_number
31113 + = 1
31114 +
31115 + dtim_policy
31116 + = NORMAL_DTIM
31117 +
31118 +Restrictions
31119 + None
31120 +
31121 +=====================================================================
31122 +
31123 +
31124 +Name
31125 + SET_POWERSAVE_PARAMS
31126 +
31127 +Synopsis
31128 + Set the two AR6000 power save timers (PS-POLL timer and APSD trigger timer) and
31129 + the two ASPD TIM policies
31130 +
31131 +Command
31132 + wmiconfig eth1--psparams --psPollTimer=<psPollTimeout in ms>
31133 + --triggerTimer=<triggerTimeout in ms> --apsdTimPolicy=<ignore/
31134 + adhere> --simulatedAPSDTimPolicy=<ignore/adhere>
31135 +
31136 +Command Parameters
31137 + typedef struct {
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
31142 +
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
31147 +
31148 + APSD_TIM_POLICY apsdTimPolicy;
31149 + TIM behavior with queue APSD enabled
31150 +
31151 + APSD_TIM_POLICY simulatedAPSD
31152 +
31153 + TimPolicy;
31154 + TIM behavior with simulated APSD
31155 + enabled
31156 +
31157 + typedef enum {
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;
31163 +
31164 +Command Values
31165 + None
31166 +
31167 +Reset Values
31168 + psPollTimeout is 50 ms; triggerTimeout is 10 ms;
31169 + apsdTimPolicy = IGNORE_TIM_ALL_QUEUES_APSD;
31170 + simulatedAPSDTimPolicy = POWERSAVE_TIMERS_POLICY
31171 +
31172 +Restrictions
31173 + When this command is used, all parameters must be set; this command does not
31174 + allow setting only one parameter.
31175 +
31176 +=====================================================================
31177 +
31178 +
31179 +Name
31180 + SET_PROBED_SSID
31181 +
31182 +Synopsis
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.
31188 +
31189 +Command
31190 + wmiconfig eth1 --ssid=<ssid> [--num=<index>]
31191 +
31192 +Command Parameters
31193 + {
31194 + A_UINT8 numSsids
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)
31201 +
31202 + WMI_PROBED_SSID_INFO probedSSID[1]
31203 + } WMI_PROBED_SSID_CMD
31204 +
31205 + {
31206 + A_UINT8 flag
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
31212 + index is erased
31213 + A_UINT8 ssid[32]
31214 + SSID string actively probed for when
31215 + permitted by the regulatory domain
31216 + } WMI_PROBED_SSID_INFO
31217 +
31218 +Command Values
31219 + WMI_SSID_FLAG
31220 + {
31221 + DISABLE_SSID_FLAG = 0
31222 + Disables entry
31223 + SPECIFIC_SSID_FLAG = 1
31224 + Probes specified SSID
31225 + ANY_SSID_FLAG = 2
31226 + Probes for any SSID
31227 + } WMI_SSID_FLAG
31228 +
31229 +Reset Value
31230 + The entries are unused.
31231 +
31232 +Restrictions
31233 + None
31234 +
31235 +=====================================================================
31236 +
31237 +
31238 +Name
31239 + SET_REASSOC_MODE
31240 +
31241 +Synopsis
31242 + Specify whether the disassociated frame should be sent or not upon reassociation.
31243 +
31244 +Command
31245 + wmiconfig eth1 --setreassocmode <mode>
31246 +
31247 +Command Parameters
31248 + UINT8 mode
31249 +
31250 +Command Values
31251 + mode
31252 + = 0x00
31253 + Send disassoc to a previously connected AP
31254 + upon reassociation
31255 + = 0x01
31256 + Do not send disassoc to previously connected
31257 + AP upon reassociation
31258 +
31259 +Reset Values
31260 + None defined
31261 +
31262 +Restrictions
31263 + None
31264 +
31265 +
31266 +=====================================================================
31267 +
31268 +Name
31269 + SET_RETRY_LIMITS
31270 +
31271 +Synopsis
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.
31274 +
31275 +Command
31276 + wmiconfig --setretrylimits <frameType> <trafficClass> <maxRetries>
31277 + <enableNotify>
31278 +
31279 +Command Parameters
31280 + {
31281 + UINT8 frameType
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.
31289 + UINT8 maxRetries
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
31299 +
31300 + {
31301 + A_UINT8 numEntries
31302 + WMI_RETRY_LIMIT_INFO retryLimitInfo[1]
31303 + } WMI_SET_RETRY_LIMITS_CMD
31304 +
31305 +Command Values
31306 + {
31307 + MGMT_FRAMETYPE = 0 Management frame
31308 + CONTROL_FRAMETYPE = 1 Control frame
31309 + DATA_FRAMETYPE = 2 Data frame
31310 + } WMI_FRAMETYPE
31311 +
31312 +Reset Values
31313 + Retries are set to 15
31314 +
31315 +Restrictions
31316 + None
31317 +
31318 +=====================================================================
31319 +
31320 +
31321 +Name
31322 + SET_ROAM_CTRL
31323 +
31324 +Synopsis
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.
31329 +
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.
31335 +
31336 +Command
31337 + wmiconfig --roam <roamctrl> <info>, where info is <scan period>
31338 + <scan threshold> <roam threshold> <roam rssi floor>
31339 +
31340 +Command Parameters
31341 + A_UINT8 roamCtrlType;
31342 +
31343 +Command Values
31344 + WMI_FORCE_ROAM = 1
31345 + Roam to the specified BSSID
31346 +
31347 + WMI_SET_ROAM_MODE = 2
31348 + Default, progd bias, no roam
31349 +
31350 + WMI_SET_HOST_BIAS = 3
31351 + Set the host bias
31352 +
31353 + WMI_SET_LOWRSSI_SCAN_PARAMS = 4
31354 + Info parameters
31355 +
31356 + A_UINT8 bssid[ATH_MAC_LEN];
31357 + WMI_FORCE_ROAM
31358 +
31359 + A_UINT8 roamMode;
31360 + WMI_SET_ROAM_MODE
31361 +
31362 + A_UINT8 bssBiasInfo;
31363 + WMI_SET_HOST_BIAS
31364 +
31365 + A_UINT16 lowrssi_scan_period;
31366 + WMI_SET_LOWRSSI_SCAN_PARAMS
31367 +
31368 + A_INT16
31369 + lowrssi_scan_threshold;
31370 + WMI_SET_LOWRSSI_SCAN_PARAMS
31371 +
31372 + A_INT16 lowrssi_roam_threshold;
31373 + WMI_SET_LOWRSSI_SCAN_PARAMS
31374 +
31375 + A_UINT8 roam_rssi_floor;
31376 + WMI_SET_LOWRSSI_SCAN_PARAMS
31377 +
31378 +Reset Value
31379 + None defined (default lowrssi scan is disabled. Enabled only when scan period is set.)
31380 +
31381 +Restrictions
31382 + None
31383 +
31384 +=====================================================================
31385 +
31386 +
31387 +Name
31388 + SET_RTS
31389 +
31390 +Synopsis
31391 + Decides when RTS should be sent.
31392 +
31393 +Command
31394 + wmiconfig eth1 --setRTS <pkt length threshold>
31395 +
31396 +Command Parameters
31397 + A_UINT16
31398 + threshold;
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.
31402 +
31403 +Command Values
31404 + None
31405 +
31406 +Reset Value
31407 + Not to send RTS.
31408 +
31409 +Restrictions
31410 + None
31411 +
31412 +
31413 +=====================================================================
31414 +
31415 +Name
31416 + SET_SCAN_PARAMS
31417 +
31418 +Synopsis
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.
31426 +
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.
31432 +
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.
31441 +
31442 +Command
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>
31446 +
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
31454 + scanning.
31455 +
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.
31461 +
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.
31467 +
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.
31473 +
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.
31479 +
31480 + UINT8 shortScanRatio
31481 + Number of short scans to perform for each
31482 + long scan.
31483 +
31484 + UINT8 scanCtrlFlasgs
31485 +
31486 + UINT16 minactChDwellTime
31487 + Specified in ms
31488 +
31489 + UINT32 maxDFSchActTime
31490 + The maximum time a DFS channel can stay
31491 + active before being marked passive, specified in
31492 + ms.
31493 +
31494 +Command Values
31495 + None
31496 +
31497 +Reset Values
31498 + ForegroundScanStart
31499 +Period
31500 + 1 sec
31501 +
31502 + ForegroundScanEndPeriod
31503 + 60 sec
31504 +
31505 + BackgroundScanPeriod
31506 + 60 sec
31507 +
31508 + ActiveChannelDwellTime
31509 + 105 ms
31510 +
31511 +=====================================================================
31512 +
31513 +
31514 +Name
31515 + SET_TKIP_COUNTERMEASURES
31516 +
31517 +Synopsis
31518 + The host issues this command to tell the target whether to enable or disable TKIP
31519 + countermeasures.
31520 +
31521 +Command
31522 + TBD
31523 +
31524 +Command Parameters
31525 + UINT8 WMI_TKIP_CM_ENABLE
31526 + Enables the countermeasures
31527 +
31528 +
31529 + UINT8 TKIP_CM_DISABLE
31530 + Disables the countermeasures
31531 +
31532 +Command Values
31533 + None
31534 +
31535 +Reset Values
31536 + By default, TKIP MIC reporting is disabled
31537 +
31538 +Restrictions
31539 + None
31540 +
31541 +=====================================================================
31542 +
31543 +
31544 +Name
31545 + SET_TX_PWR
31546 +
31547 +Synopsis
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.
31551 +
31552 +Command
31553 + wmiconfig --power <dbM>
31554 +
31555 +Command Parameters
31556 + UINT8 dbM
31557 + The desired Tx power specified in dbM.
31558 + If = 0, the device chooses the maximum
31559 + permitted by the regulatory domain.
31560 +
31561 +Command Values
31562 + None
31563 +
31564 +Reset Values
31565 + The maximum permitted by the regulatory domain
31566 +
31567 +Restrictions
31568 + None
31569 +
31570 +See Also
31571 + \93GET_TX_PWR\94
31572 +
31573 +
31574 +=====================================================================
31575 +
31576 +Name
31577 + SET_VOICE_PKT_SIZE
31578 +
31579 +Synopsis
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.
31583 +
31584 +Command
31585 + wmiconfig eth1 --setVoicePktSize <size-in-bytes>
31586 +
31587 +Command Parameters
31588 + UINT16 voicePktSize
31589 + Packet size in octets
31590 +
31591 +Command Values
31592 + None
31593 +
31594 +Reset Values
31595 + voicePktSize default is 400 bytes
31596 +
31597 +Restrictions
31598 + No effect if WMM is unavailable
31599 +
31600 +
31601 +=====================================================================
31602 +
31603 +Name
31604 + SET_WMM
31605 +
31606 +Synopsis
31607 + Overrides the AR6000 device WMM capability
31608 +
31609 +Command
31610 + wmiconfig eth1 --setwmm <enable>
31611 +
31612 +Command Parameters
31613 + WMI_WMM_ENABLED
31614 + Enables WMM
31615 +
31616 + WMI_WMM_DISABLED
31617 + Disables WMM support
31618 +
31619 +Command Values
31620 + 0 = disabled
31621 + 1 = enabled
31622 +
31623 +Reset Value
31624 + WMM Disabled
31625 +
31626 +Restrictions
31627 + None
31628 +
31629 +
31630 +=====================================================================
31631 +
31632 +Name
31633 + SET_WMM_TXOP
31634 +
31635 +Synopsis
31636 + Configures TxOP Bursting when sending traffic to a WMM capable AP
31637 +
31638 +Command
31639 + wmiconfig eth1 --txopbursting <burstEnable>
31640 +
31641 + <burstEnable>
31642 + = 0
31643 + Disallow TxOp bursting
31644 +
31645 + = 1
31646 + Allow TxOp bursting
31647 +
31648 +Command Parameters
31649 + txopEnable
31650 + = WMI_TXOP_DISABLED
31651 + Disabled
31652 +
31653 + = WMI_TXOP_ENABLED
31654 + Enabled
31655 +
31656 +Command Values
31657 + txopEnable
31658 + = 0 Disabled
31659 +
31660 + = 1 Enabled
31661 +
31662 +Reset Value
31663 + Bursting is off by default
31664 +
31665 +Restrictions
31666 + None
31667 +
31668 +=====================================================================
31669 +
31670 +
31671 +Name
31672 + SET_WOW_MODE
31673 +
31674 +Synopsis
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.
31680 +
31681 +Command
31682 + wmiconfig \96setwowmode <enable/disable>
31683 +
31684 +Command Parameters
31685 + A_BOOL enable_wow
31686 + Enable or disable WoW:
31687 +
31688 +Command Values
31689 + = 0
31690 + Disable WoW
31691 +
31692 + = 1
31693 + Enable WoW
31694 +
31695 +Reset Value
31696 + None defined (default WoW mode is disabled).
31697 +
31698 +Restrictions
31699 + None
31700 +
31701 +See Also
31702 + \93GET_WOW_LIST\94
31703 +
31704 +
31705 +=====================================================================
31706 +
31707 +Name
31708 + SET_WSC_STATUS
31709 +
31710 +Synopsis
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
31714 + flag is reset.
31715 +
31716 +Command
31717 + N/A
31718 +
31719 +Command Parameters
31720 + A_BOOL status
31721 + = 1 WSC registration in progress
31722 + = 0 WSC protocol not running
31723 +
31724 +Reply Parameters
31725 + None
31726 +
31727 +Reset Value
31728 + None defined (default = 0)
31729 +
31730 +Restrictions
31731 + None
31732 +
31733 +
31734 +=====================================================================
31735 +
31736 +Name
31737 + SNR_THRESHOLD_PARAMS
31738 +
31739 +Synopsis
31740 + Configures how the AR6000 device monitors and reports SNR of the connected BSS,
31741 + used as a link quality metric.
31742 +
31743 +Command
31744 + --snrThreshold <weight> <upper_threshold_1> ...
31745 + <upper_threshold_4> <lower_threshold_1> ... <lower_threshold_4>
31746 + <pollTimer>
31747 +
31748 +Command Parameters
31749 + <weight>
31750 + Share with rssiThreshold. Range in [1, 16], used
31751 + in the formula to calculate average RSSI
31752 +
31753 + <upper_threshold_x>
31754 + Above thresholds expressed in db, in ascending
31755 + order
31756 +
31757 + <lower_threshold_x>
31758 + Below thresholds expressed in db, in ascending
31759 + order
31760 +
31761 + <pollTimer>
31762 + The signal strength sampling frequency in
31763 + seconds. If polltime = 0, signal strength
31764 + sampling is disabled
31765 +
31766 +Command Values
31767 + None
31768 +
31769 +Reset Value
31770 + None defined
31771 +
31772 +Restrictions
31773 + None
31774 +
31775 +=====================================================================
31776 +
31777 +
31778 +Name
31779 + START_SCAN
31780 +
31781 +Synopsis
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
31789 +
31790 +Command
31791 + wmiconfig eth1 --startscan <scan type> <forcefgscan> 0
31792 + <homeDwellTime> <forceScanInterval>
31793 +
31794 +Command Parameters
31795 + UINT8 scanType
31796 + WMI_SCAN_TYPE
31797 +
31798 +Command Values
31799 + {
31800 + WMI_LONG_SCAN =0x0
31801 + Requests a full scan
31802 + WMI_SHORT_SCAN =0x1
31803 + Requests a short scan
31804 + } WMI_SCAN_TYPE
31805 +
31806 + A_BOOL forceFgScan
31807 + forceFgScan
31808 + = 0
31809 + Disable the foreground scan
31810 +
31811 + forceFgScan
31812 + = 1
31813 + Forces a foreground scan
31814 +
31815 + A_UINT32 homeDwellTime
31816 + Maximum duration in the home
31817 + channel (in ms)
31818 +
31819 + A_UINT32 forceScanInterval
31820 + Time interval between scans (in ms)
31821 +
31822 + A_UINT32 scanType
31823 + WMI_SCAN_TYPE
31824 +
31825 +Reset Value
31826 + Disable forcing foreground scan
31827 +
31828 +Restrictions
31829 + isLegacy field will no longer be supported (pass as 0 for now)
31830 +
31831 +
31832 +=====================================================================
31833 +
31834 +Name
31835 + SYNCHRONIZE
31836 +
31837 +Synopsis
31838 + The host uses this command to force a synchronization point between the command
31839 + and data paths
31840 +
31841 +Command
31842 + TBD
31843 +
31844 +Command Parameters
31845 + None
31846 +
31847 +
31848 +
31849 +Command Values
31850 + None
31851 +
31852 +
31853 +
31854 +Reset Values
31855 + None
31856 +
31857 +
31858 +
31859 +Restrictions
31860 + None
31861 +
31862 +
31863 +=====================================================================
31864 +
31865 +Name
31866 + TARGET_ERROR_REPORT_BITMASK
31867 +
31868 +Synopsis
31869 + Allows the host to control \93ERROR_REPORT\94 events from the AR6000 device.
31870 +
31871 + If error reporting is disabled for an error type, a count of errors of that type is
31872 + maintained by the device.
31873 +
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.
31876 +
31877 + Error counts for each error type are available through the \93GET_TARGET_STATS\94
31878 + command.
31879 +
31880 +Command
31881 + wmiconfig eth1 --setErrorReportingBitmask
31882 +
31883 +Command Parameters
31884 + UINT32 bitmask
31885 + Represents the set of
31886 + WMI_TARGET_ERROR_VAL error types
31887 + enabled for reporting
31888 +
31889 +Command Values
31890 + {
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
31895 + indication'
31896 + Host changes the PS setting when
31897 + STA is off home channel
31898 +
31899 + WMI_TARGET_KEY_NOT_FOUND = 0x00000002
31900 + No cipher key
31901 + WMI_TARGET_DECRYPTION_ERR = 0x00000004
31902 + Decryption error
31903 + WMI_TARGET_BMISS = 0x00000008
31904 + Beacon miss
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
31911 + Fatal error
31912 + } WMI_TARGET_ERROR_VAL
31913 +
31914 +Reset Values
31915 + Bitmask is 0, and all error reporting is disabled
31916 +
31917 +Restrictions
31918 + None
31919 +
31920 +
31921 +=====================================================================
31922 +WMI Events
31923 +
31924 +Event
31925 + Description
31926 + Page
31927 +
31928 +
31929 +BSSINFO
31930 + Contains information describing BSSs collected during a scan
31931 +
31932 +CAC_EVENTID
31933 + Indicates signalling events in admission control
31934 +
31935 +CMDERROR
31936 + The AR6000 device encounters an error while attempting to process
31937 + a command
31938 +
31939 +CONNECT
31940 + The device has connected to a wireless network
31941 +
31942 +DISCONNECT
31943 + The device lost connectivity with a wireless network
31944 +
31945 +ERROR_REPORT
31946 + An error has occurred for which the host previously requested
31947 + notification with the command
31948 + \93TARGET_ERROR_REPORT_BITMASK\94
31949 +
31950 +EXTENSION
31951 + WMI extension event
31952 +
31953 +GET_PMKID_LIST_EVENT
31954 + Created in response to a \93GET_PMKID_LIST_CMD\94 command
31955 +
31956 +GET_WOW_LIST_EVENT
31957 + Response to the wmiconfig \93GET_WOW_LIST\94 command to
31958 + retrieve the configured WoW patterns
31959 +
31960 +NEIGHBOR_REPORT
31961 + Neighbor APs that match the current profile were detected
31962 +
31963 +OPT_RX_FRAME_EVENT
31964 + (Special feature) informs the host of the reception of a special frame
31965 +
31966 +PSTREAM_TIMEOUT
31967 + A prioritized stream has been idle for a specified interval
31968 +
31969 +READY
31970 + The AR6000 device is ready to accept commands
31971 +
31972 +REGDOMAIN
31973 + The regulatory domain has changed
31974 +
31975 +REPORT_ROAM_DATA_EVENT
31976 + Reports the roam time calculations made by the device
31977 + (generated with a special build)
31978 + \97
31979 +
31980 +REPORT_STATISTICS
31981 + Reply to a \93GET_TARGET_STATS\94 command
31982 +
31983 +ROAM_TBL_EVENT
31984 + Reports the roam table
31985 +
31986 +RSSI_THRESHOLD
31987 + Signal strength from the connected AP has crossed the threshold
31988 + defined in the \93RSSI_THRESHOLD_PARAMS\94 command
31989 +
31990 +SCAN_COMPLETE_EVENT
31991 + A scan has completed (added status SCAN_ABORTED in release 2.0)
31992 +
31993 +TEST_EVENT
31994 + Event generated by the TCMD
31995 +
31996 +TKIP_MICERROR
31997 + TKIP MIC errors were detected
31998 +
31999 +=====================================================================
32000 +
32001 +Name
32002 + BSSINFO
32003 +
32004 +Synopsis
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.
32012 +
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.
32019 +
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.
32025 +
32026 +Event ID
32027 + 0x1004
32028 +
32029 +Event Parameters
32030 + typedef struct {
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
32036 + A_UINT8 snr;
32037 + A_INT16 rssi;
32038 + Indicates signal strength
32039 + A_UINT8 bssid[ATH_MAC_LEN];
32040 + A_UINT32 ieMask;
32041 + } _ATTRIB_PACK_WMI_BSS_INFO_HDR;
32042 +
32043 + Beacon or Probe Response Frame
32044 +
32045 +Event Values
32046 + {
32047 + BEACON_FTYPE = 0x1
32048 + Indicates a beacon frame
32049 + PROBERESP_FTYPE
32050 + Indicates a probe response frame
32051 + ACTION_MGMT_FTYPE
32052 + } WMI_BI_FTYPE
32053 +
32054 +=====================================================================
32055 +
32056 +Name
32057 + CAC_EVENTID
32058 +
32059 +Synopsis
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.
32064 +
32065 +Event ID
32066 + 0x1011
32067 +
32068 +Event Parameters
32069 + UINT8
32070 + ac
32071 + Access class pertaining to the
32072 +signalling
32073 +
32074 + UINT8 cac_indication
32075 + Type of indication; indications are
32076 + listed in WMI_CAC_INDICATION
32077 +
32078 + UINT8 statusCode
32079 + AP response status code for a
32080 + request
32081 +
32082 + UINT8 tspecSuggestion[63]
32083 + Suggested TSPEC from AP
32084 +
32085 +Event Values
32086 + {
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
32092 +
32093 +
32094 +=====================================================================
32095 +
32096 +
32097 +Name
32098 + CMDERROR
32099 +
32100 +Synopsis
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.
32103 +
32104 +Event ID
32105 + 0x1005
32106 +
32107 +Event Parameters
32108 + UINT16 commandId
32109 + Corresponds to the command which generated
32110 + the error
32111 + UINT8 errorCode
32112 + A WMI_ERROR_CODE value
32113 +
32114 +Event Values
32115 + {
32116 + INVALID_PARAM = 1
32117 + Invalid parameter
32118 + ILLEGAL_STATE = 2
32119 + Illegal state
32120 + INTERNAL_ERROR = 3
32121 + Internal Error
32122 + All other values reserved
32123 + } WMI_ERROR_CODE
32124 +
32125 +
32126 +=====================================================================
32127 +
32128 +
32129 +Name
32130 + CONNECT
32131 +
32132 +Synopsis
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.
32136 +
32137 +Event ID
32138 + 0x1002
32139 +
32140 +Event Parameters
32141 + UINT16 channel
32142 + Channel frequency (in MHz) of the network the
32143 + AR6000 are connected to
32144 +
32145 + UINT8 bssid[6]
32146 + MAC address of the AP the AR6000 are
32147 + connected to or the BSSID of the ad hoc
32148 + network
32149 +
32150 + UINT16 listenInterval
32151 + Listen interval (in Kms) that the AR6000 are
32152 + using
32153 +
32154 + UINT 8 beaconIeLen
32155 + Length (in bytes) of the beacon IEs
32156 +
32157 + UINT8 assocInfo
32158 + Pointer to an array containing beacon IEs,
32159 + followed first by association request IEs then by
32160 + association response IEs
32161 +
32162 + UINT8 assocReqLen
32163 + Length (in bytes) of the assocReqIEs array
32164 +
32165 + UINT8 assocRespLen
32166 + Length (in bytes) of the assocRespIEs array
32167 +
32168 +Event Values
32169 + None defined
32170 +
32171 +=====================================================================
32172 +
32173 +
32174 +Name
32175 + DISCONNECT
32176 +
32177 +Synopsis
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.
32181 +
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.
32185 +
32186 +Event ID
32187 + 0x1003
32188 +
32189 +Event Parameters
32190 + UINT8 disconnect
32191 + Reason
32192 + A WMI_DISCONNECT_REASON value
32193 +
32194 + UINT8 bssid[6]
32195 + Indicates which BSS the device was connected to
32196 +
32197 + UINT8 assocRespLen
32198 + Length of the 802.11 association response frame
32199 + that triggered this event, or 0 if not applicable
32200 +
32201 + UINT8 assocInfo[assocRespLen]
32202 + Copy of the 802.11 association response frame
32203 +
32204 +Event Values
32205 + {
32206 + NO_NETWORK_AVAIL =0x01
32207 + Indicates that the device was unable to
32208 + establish or find the desired network
32209 + LOST_LINK =0x02
32210 + Indicates the devices is no longer receiving
32211 + beacons from the BSS it was previously
32212 + connected to
32213 +
32214 + DISCONNECT_CMD =0x03
32215 + Indicates a \93DISCONNECT\94 command was
32216 + processed
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
32222 + messages).
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
32232 + connection
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
32238 + bad AP).
32239 + INVALID_PROFILE =0x0A
32240 + Indicates that an attempt was made to
32241 + reconnect to a BSS that no longer matches the
32242 + current profile
32243 + All other values are reserved
32244 + } WMI_DISCONNECT_REASON
32245 +
32246 +
32247 +=====================================================================
32248 +
32249 +
32250 +Name
32251 + ERROR_REPORT
32252 +
32253 +Synopsis
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.
32256 +
32257 +Event ID
32258 + 0x100D
32259 +
32260 +Event Parameters
32261 + UINT32 errorVal
32262 + WMI_TARGET_ERROR_VAL value. See
32263 + \93TARGET_ERROR_REPORT_BITMASK\94.
32264 +
32265 +Event Values
32266 + errorVal
32267 + = 0x00000001
32268 + Power save fails
32269 +
32270 + = 0x00000002
32271 + No cipher key
32272 +
32273 + = 0x00000004
32274 + Decryption error
32275 +
32276 + = 0x00000008
32277 + Beacon miss
32278 +
32279 + = 0x00000010
32280 + A non-power save disabled node has joined
32281 + the PS-enabled network
32282 +
32283 +
32284 +=====================================================================
32285 +
32286 +
32287 +Name
32288 + EXTENSION
32289 +
32290 +Synopsis
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
32296 +
32297 +
32298 +Event ID
32299 + 0x1010
32300 +
32301 +
32302 +=====================================================================
32303 +
32304 +
32305 +Name
32306 + GET_PMKID_LIST_EVENT
32307 +
32308 +Synopsis
32309 + Generated by firmware in response to a \93GET_PMKID_LIST_CMD\94 command.
32310 +
32311 +Event Parameters
32312 + typedef struct {
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;
32317 +
32318 +Event Values
32319 + None
32320 +
32321 +
32322 +=====================================================================
32323 +
32324 +
32325 +Name
32326 + GET_WOW_LIST_EVENT
32327 +
32328 +Synopsis
32329 + Response to the wmiconfig \96getwowlist command to retrieve the configured Wake on
32330 + Wireless patterns
32331 +
32332 +Event ID
32333 + 0x10018
32334 +
32335 +Event Parameters
32336 + {
32337 +
32338 + A_UINT8 num_filters
32339 + Total number of patterns in the list
32340 + A_UINT8 this_filter_num
32341 + The filter number
32342 + A_UINT8 wow_mode
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;
32349 +
32350 + {
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
32364 + } WOW_FILTER
32365 +
32366 +Event Values
32367 + None
32368 +
32369 +=====================================================================
32370 +
32371 +
32372 +
32373 +Name
32374 + NEIGHBOR_REPORT
32375 +
32376 +Synopsis
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.
32380 +
32381 + A total of numberOfAps pairs of bssid/bssFlags exist, one pair for each AP.
32382 +
32383 +Event ID
32384 + 0x1008
32385 +
32386 +Event Parameters
32387 + UINT8 numberOfAps
32388 + The number of APs reported about in
32389 + this event
32390 + {
32391 + UINT8 bssid[6]
32392 + MAC address of a neighbor AP
32393 + UINT8 bssFlags
32394 + A WMI_BSS_FLAGS value
32395 + }[numberOfAps]
32396 +
32397 +
32398 +Event Values
32399 + {
32400 + WMI_DEFAULT_BSS_FLAGS = 0
32401 + Logical OR of 1 or more
32402 + WMI_BSS_FLAGS
32403 + WMI_PREAUTH_CAPABLE_BSS
32404 + = 1
32405 + Indicates that this AP is capable of
32406 + preauthentication
32407 + WMI_PMKID_VALID_BSS
32408 + = 2
32409 + Indicates that the AR6000 have a
32410 + valid pairwise master key for this AP
32411 + } WMI_BSS_FLAGS
32412 +
32413 +
32414 +=====================================================================
32415 +
32416 +
32417 +
32418 +Name
32419 + OPT_RX_FRAME_EVENT
32420 +
32421 +Synopsis
32422 + Special feature, informs host of the reception of a special frame.
32423 +
32424 +Event ID
32425 + 0x100E
32426 +
32427 +Event Parameters
32428 + {
32429 + A_UINT16 channel;
32430 + A_UINT8 frameType;
32431 + A_INT8 snr;
32432 + A_UINT8 srcAddr[ATH_MAC_LEN];
32433 + A_UINT8 bssid[ATH_MAC_LEN];
32434 + }WMI_OPT_RX_INFO_HDR
32435 +
32436 +Event Values
32437 + None
32438 +
32439 +=====================================================================
32440 +
32441 +
32442 +
32443 +Name
32444 + PSTREAM_TIMEOUT
32445 +
32446 +Synopsis
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.
32453 +
32454 +Event ID
32455 + 0x1007
32456 +
32457 +Event Parameters
32458 + A_UINT8
32459 + trafficClass
32460 + Indicated the traffic class of priority
32461 + stream that timed out
32462 +
32463 +Event Values
32464 + {
32465 + WMM_AC_BE = 0
32466 + Best effort
32467 + WMM_AC_BK = 1
32468 + Background
32469 + WMM_AC_VI = 2
32470 + Video
32471 + WMM_AC_VO = 3
32472 + Voice
32473 + } TRAFFIC CLASS
32474 +
32475 +
32476 +=====================================================================
32477 +
32478 +Name
32479 + READY
32480 +
32481 +Synopsis
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.
32484 +
32485 +Event ID
32486 + 0x1001
32487 +
32488 +Event Parameters
32489 + UINT8 macAddr[6]
32490 + Device MAC address
32491 + UINT8 phyCapability
32492 + A WMI_PHY_CAPABILITY value. Indicates the
32493 + capabilities of the device wireless module\92s radio
32494 +
32495 +Event Values
32496 + {
32497 + WMI_11A_CAPABILITY = 1
32498 + WMI_11G_CAPABILITY = 2
32499 + WMI_11AG_CAPABILITY = 3
32500 + } WMI_PHY_CAPABILITY
32501 +
32502 +
32503 +=====================================================================
32504 +
32505 +Name
32506 + REGDOMAIN
32507 +
32508 +Synopsis
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.
32516 +
32517 +Event ID
32518 + 0x1006
32519 +
32520 +Event Parameters
32521 + UINT32 regDomain
32522 + The range of 0x0000 \96 0x00FF
32523 + corresponds to an ISO country code.
32524 +
32525 + Other regCodes are reserved for world
32526 + mode settings and specific regulatory
32527 + domains.
32528 +
32529 +Event Values
32530 + None
32531 +
32532 +
32533 +=====================================================================
32534 +
32535 +
32536 +
32537 +Name
32538 + REPORT_STATISTICS
32539 +
32540 +Synopsis
32541 + A reply to a \93GET_TARGET_STATS\94 command.
32542 +
32543 +Event ID
32544 + 0x100B
32545 +
32546 +Event Parameters
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.
32549 +
32550 + UINT32 tx_packets
32551 + UINT32 tx_bytes
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
32562 + UINT32 tx_errors
32563 + Number of packets which failed Tx, due
32564 + to all failures
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
32573 + UINT32 rx_bytes
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
32582 + UINT32 rx_errors
32583 + Number of Rx errors due to all failures
32584 + UINT32 rx_crcerr
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
32588 + being plumbed
32589 + UINT32 rx_decrypt_err
32590 + Number of Rx errors due to decryption
32591 + failure
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
32598 + were invoked
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
32616 + connection
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.
32631 +
32632 +Event Values
32633 + None defined
32634 +
32635 +
32636 +=====================================================================
32637 +
32638 +Name
32639 + ROAM_TBL_EVENT
32640 +
32641 +Synopsis
32642 + Reports the roam table, which contains the current roam mode and this information
32643 + for every BSS:
32644 +
32645 +Event ID
32646 + 0x100F
32647 +
32648 +Event Parameters
32649 + A_UINT8 bssid[ATH_MAC_LEN];
32650 + BSSID
32651 + A_UINT8 rssi
32652 + Averaged RSSI
32653 + A_UINT8 rssidt
32654 + Change in RSSI
32655 + A_UINT8 last_rssi
32656 + Last recorded RSSI
32657 + A_UINT8 roam_util
32658 + Utility value used in roaming decision
32659 + A_UINT8 util
32660 + Base utility with the BSS
32661 + A_UINT8 bias
32662 + Host configured for this BSS
32663 +
32664 +Event Values
32665 + roamMode
32666 + Current roam mode
32667 +
32668 + = 1
32669 + RSSI based roam
32670 +
32671 + = 2
32672 + Host bias-based roam
32673 +
32674 + = 3
32675 + Lock to the current BSS
32676 +
32677 + = 4
32678 + Autonomous roaming disabled
32679 +
32680 +
32681 +=====================================================================
32682 +
32683 +Name
32684 + RSSI_THRESHOLD
32685 +
32686 +Synopsis
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
32689 + command.
32690 +
32691 +Event ID
32692 + 0x100C
32693 +
32694 +Event Parameters
32695 + UINT8 range
32696 + A WMI_RSSI_THRESHOLD_VAL
32697 + value, which indicates the range of
32698 + the average signal strength
32699 +
32700 +Event Values
32701 + {
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
32708 +
32709 +
32710 +=====================================================================
32711 +
32712 +Name
32713 + SCAN_COMPLETE_EVENT
32714 +
32715 +Synopsis
32716 + Indicates the scan status. if the Scan was not completed, this event is generated with
32717 + the status A_ECANCELED.
32718 +
32719 +Event ID
32720 + 0x100A
32721 +
32722 +Event Parameters
32723 + A_UINT8 scanStatus
32724 +
32725 +Event Values
32726 + {
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;
32732 +
32733 +
32734 +=====================================================================
32735 +
32736 +Name
32737 + TEST_EVENT
32738 +
32739 +Synopsis
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.
32743 +
32744 +Event ID
32745 + 0x1016
32746 +
32747 +Event Parameters
32748 + WMI_TEST_EVENTID
32749 +
32750 +
32751 +Event Values
32752 + None
32753 +
32754 +
32755 +=====================================================================
32756 +
32757 +
32758 +
32759 +Name
32760 + TKIP_MICERR
32761 +
32762 +Synopsis
32763 + Indicates that TKIP MIC errors were detected.
32764 +
32765 +Event ID
32766 + 0x1009
32767 +
32768 +Event Parameters
32769 + UINT8 keyid
32770 + Indicates the TKIP key ID
32771 +
32772 + UINT8 ismcast
32773 + 0 = Unicast
32774 + 1 = Multicast
32775 +
32776 +Event Values
32777 + See event parameters
32778 +
32779 +=====================================================================
32780 +
32781 +WMI Extension Commands
32782 +
32783 +The WMI EXTENSION command is used to multiplex a collection of
32784 +commands that:
32785 +
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
32790 +
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.
32796 +
32797 +All extensions (subcommandIds) are listed in the header file include/wmix.h.
32798 +See also \93WMI Extension Events\94 on page B-58.
32799 +
32800 +
32801 +WMI Extension Commands
32802 +
32803 +
32804 +GPIO_INPUT_GET
32805 + Read GPIO pins configured for input
32806 +
32807 +GPIO_INTR_ACK
32808 + Acknowledge and re-arm GPIO interrupts reported earlier
32809 +
32810 +GPIO_OUTPUT_SET
32811 + Manage output on GPIO pins configured for output
32812 +
32813 +GPIO_REGISTER_GET
32814 + Read an arbitrary GPIO register
32815 +
32816 +GPIO_REGISTER_SET
32817 + Dynamically change GPIO configuration
32818 +
32819 +SET_LQTHRESHOLD
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
32823 +
32824 +
32825 +=====================================================================
32826 +
32827 +Name
32828 + GPIO_INPUT_GET
32829 +
32830 +Synopsis
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.
32833 +
32834 +NOTE: Support for GPIO is optional.
32835 +
32836 +Command
32837 + N/A
32838 +
32839 +Command Parameters
32840 + None
32841 +
32842 +
32843 +
32844 +Reply Parameters
32845 + None
32846 +
32847 +
32848 +Reset Value
32849 + None
32850 +
32851 +
32852 +
32853 +Restrictions
32854 + None
32855 +
32856 +=====================================================================
32857 +
32858 +
32859 +Name
32860 + GPIO_INTR_ACK
32861 +
32862 +Synopsis
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).
32868 +
32869 +NOTE: Support for GPIO is optional.
32870 +
32871 +Command
32872 + N/A
32873 +
32874 +Command Parameters
32875 + UINT32 ack_mask
32876 + A mask of interrupting GPIO pins (e.g., ack_mask
32877 + bit [3] acknowledges an interrupt from the pin GPIO3).
32878 +
32879 +Command Values
32880 + None
32881 +
32882 +Reset Value
32883 + None
32884 +
32885 +Restrictions
32886 + The host should acknowledge only interrupts about which it was notified.
32887 +
32888 +
32889 +=====================================================================
32890 +
32891 +Name
32892 + GPIO_OUTPUT_SET
32893 +
32894 +Synopsis
32895 + Manages output on GPIO pins configured for output.
32896 +
32897 + Conflicts between set_mask and clear_mask or enable_mask and disable_mask result
32898 + in undefined behavior.
32899 +
32900 +NOTE: Support for GPIO is optional.
32901 +
32902 +Command
32903 + N/A
32904 +
32905 +Command Parameters
32906 + UINT32 set_mask
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
32914 +
32915 +Command Values
32916 + None
32917 +
32918 +
32919 +Reset Value
32920 + None
32921 +
32922 +
32923 +Restrictions
32924 + None
32925 +
32926 +
32927 +
32928 +=====================================================================
32929 +
32930 +
32931 +Name
32932 + GPIO_REGISTER_GET
32933 +
32934 +Synopsis
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.
32937 +
32938 +NOTE: Support for GPIO is optional.
32939 +
32940 +Command
32941 + N/A
32942 +
32943 +Command Parameters
32944 + UINT32
32945 + gpioreg_id
32946 + Specifies a GPIO register identifier, as defined
32947 +in include/AR6000/AR6000_gpio.h
32948 +
32949 +Reply Parameters
32950 + None
32951 +
32952 +Reset Value
32953 + N/A
32954 +
32955 +Restrictions
32956 + None
32957 +
32958 +
32959 +=====================================================================
32960 +
32961 +Name
32962 + GPIO_REGISTER_SET
32963 +
32964 +Synopsis
32965 + Allows the host to dynamically change GPIO configuration (usually handled
32966 + statically through the GPIO configuration DataSet).
32967 +
32968 +NOTE: Support for GPIO is optional.
32969 +
32970 +Command
32971 + N/A
32972 +
32973 +Command Parameters
32974 + UINT32 gpioreg_id
32975 + Specifies a GPIO register identifier, as defined in
32976 + include/AR6000/AR6000_gpio.h
32977 + UINT32 value
32978 + Specifies a value to write to the specified
32979 + GPIO register
32980 +
32981 +Command Values
32982 + None
32983 +
32984 +
32985 +Reset Value
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.
32989 +
32990 +Restrictions
32991 + None
32992 +
32993 +
32994 +=====================================================================
32995 +
32996 +
32997 +Name
32998 + SET_LQTHRESHOLD
32999 +
33000 +Synopsis
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.
33003 +
33004 +Command
33005 + wmiconfig eth1 --lqThreshold <enable> <upper_threshold_1>...
33006 + <upper_threshold_4> <lower_threshold_1>... <lower_threshold_4>
33007 +
33008 +Command Parameters
33009 + A_UINT8 enable;
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;
33018 +
33019 +Command Values
33020 + enable
33021 + = 0
33022 + Disable link quality sampling
33023 +
33024 + = 1
33025 + Enable link quality sampling
33026 +
33027 +
33028 + thresholdAbove_Val
33029 + [1...4]
33030 + Above thresholds (value in [0,100]), in ascending
33031 + order threshold
33032 +
33033 + Below_Val [1...4] = below thresholds (value
33034 + in [0,100]), in ascending order
33035 +
33036 +Reset Values
33037 + None
33038 +
33039 +Restrictions
33040 + None
33041 +
33042 +=====================================================================
33043 +WMI Extension Events
33044 +
33045 +The WMI EXTENSION event is used for a collection of events that:
33046 +
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
33051 +
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
33057 +subcommandId.
33058 +
33059 +All extensions (subcommandIds) are listed in the header file include/wmix.h.
33060 +See also \93WMI Extension Commands\94 on page B-55.
33061 +
33062 +
33063 +WMI Extension Events
33064 +
33065 +
33066 +GPIO_ACK
33067 + Acknowledges a host set command has been processed by the device
33068 +
33069 +GPIO_DATA
33070 + Response to a host\92s request for data
33071 +
33072 +GPIO_INTR
33073 + Signals that GPIO interrupts are pending
33074 +
33075 +
33076 +=====================================================================
33077 +
33078 +Name
33079 + GPIO_ACK
33080 +
33081 +Synopsis
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.
33084 +
33085 +NOTE: Support for GPIO is optional.
33086 +
33087 +Event ID
33088 + N/A
33089 +
33090 +Event Parameters
33091 + None
33092 +
33093 +
33094 +Event Values
33095 + None
33096 +
33097 +=====================================================================
33098 +
33099 +
33100 +Name
33101 + GPIO_DATA
33102 +
33103 +Synopsis
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).
33106 +
33107 +NOTE: Support for GPIO is optional.
33108 +
33109 +Event ID
33110 + N/A
33111 +
33112 +Event Parameters
33113 + UINT32 value
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).
33117 + UINT32 reg_id
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)
33121 +
33122 +Event Values
33123 + None
33124 +
33125 +
33126 +=====================================================================
33127 +
33128 +
33129 +
33130 +Name
33131 + GPIO_INTR
33132 +
33133 +Synopsis
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.
33139 +
33140 +NOTE: Support for GPIO is optional.
33141 +
33142 +Event ID
33143 + N/A
33144 +
33145 +Event Parameters
33146 + UINT32 intr_mask
33147 + Indicates which GPIO interrupts are currently pending
33148 +
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
33152 +
33153 +Event Values
33154 + None
33155 +
33156 +
33157 +
33158 +=====================================================================
33159 +#endif
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
33163 --- /dev/null
33164 +++ b/drivers/sdio/function/wlan/ar6000/wmi/wmi_host.h
33165 @@ -0,0 +1,71 @@
33166 +#ifndef _WMI_HOST_H_
33167 +#define _WMI_HOST_H_
33168 +/*
33169 + * Copyright (c) 2004-2006 Atheros Communications Inc.
33170 + * All rights reserved.
33171 + *
33172 + * This file contains local definitios for the wmi host module.
33173 + *
33174 + * $Id: //depot/sw/releases/olca2.0-GPL/host/wmi/wmi_host.h#1 $
33175 + *
33176 + *
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;
33180 + *
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.
33185 + *
33186 + *
33187 + *
33188 + */
33189 +
33190 +#ifdef __cplusplus
33191 +extern "C" {
33192 +#endif
33193 +
33194 +struct wmi_stats {
33195 + A_UINT32 cmd_len_err;
33196 + A_UINT32 cmd_id_err;
33197 +};
33198 +
33199 +struct wmi_t {
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;
33206 + void *wmi_devt;
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;
33214 +};
33215 +
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; }
33225 +
33226 +#define WMI_WMISTREAM_ACCESSCATEGORY(w,s) (w)->wmi_wmiStream2AcMapping[s]
33227 +#define WMI_ACCESSCATEGORY_WMISTREAM(w,ac) (w)->wmi_ac2WmiStreamMapping[ac]
33228 +
33229 +#define LOCK_WMI(w) A_MUTEX_LOCK(&(w)->wmi_lock);
33230 +#define UNLOCK_WMI(w) A_MUTEX_UNLOCK(&(w)->wmi_lock);
33231 +
33232 +#ifdef __cplusplus
33233 +}
33234 +#endif
33235 +
33236 +#endif /* _WMI_HOST_H_ */
33237 --
33238 1.5.6.5
33239
This page took 1.758711 seconds and 5 git commands to generate.