]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/suse-2.6.27.31/patches.drivers/0015-Staging-add-wlan-ng-prism2-usb-driver.patch
Add a patch to fix Intel E100 wake-on-lan problems.
[ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.drivers / 0015-Staging-add-wlan-ng-prism2-usb-driver.patch
1 From 00b3ed1685089ff52169a715de11106ed37df087 Mon Sep 17 00:00:00 2001
2 From: Greg Kroah-Hartman <gregkh@suse.de>
3 Date: Thu, 2 Oct 2008 11:29:28 -0700
4 Subject: [PATCH 15/23] Staging: add wlan-ng prism2 usb driver
5 Patch-mainline: 2.6.28
6
7 This adds the wlan-ng prism2 USB driver to the drivers/staging tree.
8
9 The code was originally written by the linux-wlan-ng team, patched by
10 some Novell engineers to properly work on newer kernels, and then hacked
11 into place in order to get it to build properly in a single subdirectory
12 within the kernel tree by me.
13
14 It supports a wide range of older USB prism2 devices, and contains a
15 80211 stack to support this single driver.
16
17 Cc: Christian Zoz <zoz@suse.de>
18 Cc: Andreas Gruenbacher <agruen@suse.de>
19 Cc: linux-wireless <linux-wireless@vger.kernel.org>
20 Cc: John Linville <linville@tuxdriver.com>
21 Cc: Helmut Schaa <helmut.schaa@googlemail.com>
22 Cc: linux-wlan-ng <solomon@linux-wlan.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
24 ---
25 drivers/staging/Kconfig | 2
26 drivers/staging/Makefile | 1
27 drivers/staging/wlan-ng/Kconfig | 10
28 drivers/staging/wlan-ng/Makefile | 8
29 drivers/staging/wlan-ng/README | 7
30 drivers/staging/wlan-ng/hfa384x.h | 2792 +++++++++++++++++
31 drivers/staging/wlan-ng/hfa384x_usb.c | 4690 +++++++++++++++++++++++++++++
32 drivers/staging/wlan-ng/p80211conv.c | 686 ++++
33 drivers/staging/wlan-ng/p80211conv.h | 186 +
34 drivers/staging/wlan-ng/p80211hdr.h | 299 +
35 drivers/staging/wlan-ng/p80211ioctl.h | 123
36 drivers/staging/wlan-ng/p80211meta.h | 169 +
37 drivers/staging/wlan-ng/p80211metadef.h | 757 ++++
38 drivers/staging/wlan-ng/p80211metamib.h | 105
39 drivers/staging/wlan-ng/p80211metamsg.h | 105
40 drivers/staging/wlan-ng/p80211metastruct.h | 285 +
41 drivers/staging/wlan-ng/p80211mgmt.h | 575 +++
42 drivers/staging/wlan-ng/p80211msg.h | 102
43 drivers/staging/wlan-ng/p80211netdev.c | 1209 +++++++
44 drivers/staging/wlan-ng/p80211netdev.h | 254 +
45 drivers/staging/wlan-ng/p80211req.c | 300 +
46 drivers/staging/wlan-ng/p80211req.h | 68
47 drivers/staging/wlan-ng/p80211types.h | 675 ++++
48 drivers/staging/wlan-ng/p80211wep.c | 315 +
49 drivers/staging/wlan-ng/p80211wext.c | 1826 +++++++++++
50 drivers/staging/wlan-ng/prism2mgmt.c | 1363 ++++++++
51 drivers/staging/wlan-ng/prism2mgmt.h | 155
52 drivers/staging/wlan-ng/prism2mib.c | 1135 +++++++
53 drivers/staging/wlan-ng/prism2sta.c | 2212 +++++++++++++
54 drivers/staging/wlan-ng/prism2usb.c | 302 +
55 drivers/staging/wlan-ng/version.h | 56
56 drivers/staging/wlan-ng/wlan_compat.h | 193 +
57 32 files changed, 20965 insertions(+)
58
59 --- a/drivers/staging/Kconfig
60 +++ b/drivers/staging/Kconfig
61 @@ -37,4 +37,6 @@ source "drivers/staging/usbip/Kconfig"
62
63 source "drivers/staging/winbond/Kconfig"
64
65 +source "drivers/staging/wlan-ng/Kconfig"
66 +
67 endif # STAGING
68 --- a/drivers/staging/Makefile
69 +++ b/drivers/staging/Makefile
70 @@ -7,3 +7,4 @@ obj-$(CONFIG_ME4000) += me4000/
71 obj-$(CONFIG_VIDEO_GO7007) += go7007/
72 obj-$(CONFIG_USB_IP_COMMON) += usbip/
73 obj-$(CONFIG_W35UND) += winbond/
74 +obj-$(CONFIG_PRISM2_USB) += wlan-ng/
75 --- /dev/null
76 +++ b/drivers/staging/wlan-ng/hfa384x.h
77 @@ -0,0 +1,2792 @@
78 +/* hfa384x.h
79 +*
80 +* Defines the constants and data structures for the hfa384x
81 +*
82 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
83 +* --------------------------------------------------------------------
84 +*
85 +* linux-wlan
86 +*
87 +* The contents of this file are subject to the Mozilla Public
88 +* License Version 1.1 (the "License"); you may not use this file
89 +* except in compliance with the License. You may obtain a copy of
90 +* the License at http://www.mozilla.org/MPL/
91 +*
92 +* Software distributed under the License is distributed on an "AS
93 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
94 +* implied. See the License for the specific language governing
95 +* rights and limitations under the License.
96 +*
97 +* Alternatively, the contents of this file may be used under the
98 +* terms of the GNU Public License version 2 (the "GPL"), in which
99 +* case the provisions of the GPL are applicable instead of the
100 +* above. If you wish to allow the use of your version of this file
101 +* only under the terms of the GPL and not to allow others to use
102 +* your version of this file under the MPL, indicate your decision
103 +* by deleting the provisions above and replace them with the notice
104 +* and other provisions required by the GPL. If you do not delete
105 +* the provisions above, a recipient may use your version of this
106 +* file under either the MPL or the GPL.
107 +*
108 +* --------------------------------------------------------------------
109 +*
110 +* Inquiries regarding the linux-wlan Open Source project can be
111 +* made directly to:
112 +*
113 +* AbsoluteValue Systems Inc.
114 +* info@linux-wlan.com
115 +* http://www.linux-wlan.com
116 +*
117 +* --------------------------------------------------------------------
118 +*
119 +* Portions of the development of this software were funded by
120 +* Intersil Corporation as part of PRISM(R) chipset product development.
121 +*
122 +* --------------------------------------------------------------------
123 +*
124 +* [Implementation and usage notes]
125 +*
126 +* [References]
127 +* CW10 Programmer's Manual v1.5
128 +* IEEE 802.11 D10.0
129 +*
130 +* --------------------------------------------------------------------
131 +*/
132 +
133 +#ifndef _HFA384x_H
134 +#define _HFA384x_H
135 +
136 +/*=============================================================*/
137 +#define HFA384x_FIRMWARE_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
138 +
139 +#define HFA384x_LEVEL_TO_dBm(v) (0x100 + (v) * 100 / 255 - 100)
140 +
141 +/*------ Constants --------------------------------------------*/
142 +/*--- Mins & Maxs -----------------------------------*/
143 +#define HFA384x_CMD_ALLOC_LEN_MIN ((u16)4)
144 +#define HFA384x_CMD_ALLOC_LEN_MAX ((u16)2400)
145 +#define HFA384x_BAP_DATALEN_MAX ((u16)4096)
146 +#define HFA384x_BAP_OFFSET_MAX ((u16)4096)
147 +#define HFA384x_PORTID_MAX ((u16)7)
148 +#define HFA384x_NUMPORTS_MAX ((u16)(HFA384x_PORTID_MAX+1))
149 +#define HFA384x_PDR_LEN_MAX ((u16)512) /* in bytes, from EK */
150 +#define HFA384x_PDA_RECS_MAX ((u16)200) /* a guess */
151 +#define HFA384x_PDA_LEN_MAX ((u16)1024) /* in bytes, from EK */
152 +#define HFA384x_SCANRESULT_MAX ((u16)31)
153 +#define HFA384x_HSCANRESULT_MAX ((u16)31)
154 +#define HFA384x_CHINFORESULT_MAX ((u16)16)
155 +#define HFA384x_DRVR_FIDSTACKLEN_MAX (10)
156 +#define HFA384x_DRVR_TXBUF_MAX (sizeof(hfa384x_tx_frame_t) + \
157 + WLAN_DATA_MAXLEN - \
158 + WLAN_WEP_IV_LEN - \
159 + WLAN_WEP_ICV_LEN + 2)
160 +#define HFA384x_DRVR_MAGIC (0x4a2d)
161 +#define HFA384x_INFODATA_MAXLEN (sizeof(hfa384x_infodata_t))
162 +#define HFA384x_INFOFRM_MAXLEN (sizeof(hfa384x_InfFrame_t))
163 +#define HFA384x_RID_GUESSING_MAXLEN 2048 /* I'm not really sure */
164 +#define HFA384x_RIDDATA_MAXLEN HFA384x_RID_GUESSING_MAXLEN
165 +#define HFA384x_USB_RWMEM_MAXLEN 2048
166 +
167 +/*--- Support Constants -----------------------------*/
168 +#define HFA384x_BAP_PROC ((u16)0)
169 +#define HFA384x_BAP_int ((u16)1)
170 +#define HFA384x_PORTTYPE_IBSS ((u16)0)
171 +#define HFA384x_PORTTYPE_BSS ((u16)1)
172 +#define HFA384x_PORTTYPE_WDS ((u16)2)
173 +#define HFA384x_PORTTYPE_PSUEDOIBSS ((u16)3)
174 +#define HFA384x_PORTTYPE_HOSTAP ((u16)6)
175 +#define HFA384x_WEPFLAGS_PRIVINVOKED ((u16)BIT0)
176 +#define HFA384x_WEPFLAGS_EXCLUDE ((u16)BIT1)
177 +#define HFA384x_WEPFLAGS_DISABLE_TXCRYPT ((u16)BIT4)
178 +#define HFA384x_WEPFLAGS_DISABLE_RXCRYPT ((u16)BIT7)
179 +#define HFA384x_WEPFLAGS_DISALLOW_MIXED ((u16)BIT11)
180 +#define HFA384x_WEPFLAGS_IV_intERVAL1 ((u16)0)
181 +#define HFA384x_WEPFLAGS_IV_intERVAL10 ((u16)BIT5)
182 +#define HFA384x_WEPFLAGS_IV_intERVAL50 ((u16)BIT6)
183 +#define HFA384x_WEPFLAGS_IV_intERVAL100 ((u16)(BIT5 | BIT6))
184 +#define HFA384x_WEPFLAGS_FIRMWARE_WPA ((u16)BIT8)
185 +#define HFA384x_WEPFLAGS_HOST_MIC ((u16)BIT9)
186 +#define HFA384x_ROAMMODE_FWSCAN_FWROAM ((u16)1)
187 +#define HFA384x_ROAMMODE_FWSCAN_HOSTROAM ((u16)2)
188 +#define HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM ((u16)3)
189 +#define HFA384x_PORTSTATUS_DISABLED ((u16)1)
190 +#define HFA384x_PORTSTATUS_INITSRCH ((u16)2)
191 +#define HFA384x_PORTSTATUS_CONN_IBSS ((u16)3)
192 +#define HFA384x_PORTSTATUS_CONN_ESS ((u16)4)
193 +#define HFA384x_PORTSTATUS_OOR_ESS ((u16)5)
194 +#define HFA384x_PORTSTATUS_CONN_WDS ((u16)6)
195 +#define HFA384x_PORTSTATUS_HOSTAP ((u16)8)
196 +#define HFA384x_RATEBIT_1 ((u16)1)
197 +#define HFA384x_RATEBIT_2 ((u16)2)
198 +#define HFA384x_RATEBIT_5dot5 ((u16)4)
199 +#define HFA384x_RATEBIT_11 ((u16)8)
200 +
201 +/*--- Just some symbolic names for legibility -------*/
202 +#define HFA384x_TXCMD_NORECL ((u16)0)
203 +#define HFA384x_TXCMD_RECL ((u16)1)
204 +
205 +/*--- MAC Internal memory constants and macros ------*/
206 +/* masks and macros used to manipulate MAC internal memory addresses. */
207 +/* MAC internal memory addresses are 23 bit quantities. The MAC uses
208 + * a paged address space where the upper 16 bits are the page number
209 + * and the lower 7 bits are the offset. There are various Host API
210 + * elements that require two 16-bit quantities to specify a MAC
211 + * internal memory address. Unfortunately, some of the API's use a
212 + * page/offset format where the offset value is JUST the lower seven
213 + * bits and the page is the remaining 16 bits. Some of the API's
214 + * assume that the 23 bit address has been split at the 16th bit. We
215 + * refer to these two formats as AUX format and CMD format. The
216 + * macros below help handle some of this.
217 + */
218 +
219 +/* Handy constant */
220 +#define HFA384x_ADDR_AUX_OFF_MAX ((u16)0x007f)
221 +
222 +/* Mask bits for discarding unwanted pieces in a flat address */
223 +#define HFA384x_ADDR_FLAT_AUX_PAGE_MASK (0x007fff80)
224 +#define HFA384x_ADDR_FLAT_AUX_OFF_MASK (0x0000007f)
225 +#define HFA384x_ADDR_FLAT_CMD_PAGE_MASK (0xffff0000)
226 +#define HFA384x_ADDR_FLAT_CMD_OFF_MASK (0x0000ffff)
227 +
228 +/* Mask bits for discarding unwanted pieces in AUX format 16-bit address parts */
229 +#define HFA384x_ADDR_AUX_PAGE_MASK (0xffff)
230 +#define HFA384x_ADDR_AUX_OFF_MASK (0x007f)
231 +
232 +/* Mask bits for discarding unwanted pieces in CMD format 16-bit address parts */
233 +#define HFA384x_ADDR_CMD_PAGE_MASK (0x007f)
234 +#define HFA384x_ADDR_CMD_OFF_MASK (0xffff)
235 +
236 +/* Make a 32-bit flat address from AUX format 16-bit page and offset */
237 +#define HFA384x_ADDR_AUX_MKFLAT(p,o) \
238 + (((u32)(((u16)(p))&HFA384x_ADDR_AUX_PAGE_MASK)) <<7) | \
239 + ((u32)(((u16)(o))&HFA384x_ADDR_AUX_OFF_MASK))
240 +
241 +/* Make a 32-bit flat address from CMD format 16-bit page and offset */
242 +#define HFA384x_ADDR_CMD_MKFLAT(p,o) \
243 + (((u32)(((u16)(p))&HFA384x_ADDR_CMD_PAGE_MASK)) <<16) | \
244 + ((u32)(((u16)(o))&HFA384x_ADDR_CMD_OFF_MASK))
245 +
246 +/* Make AUX format offset and page from a 32-bit flat address */
247 +#define HFA384x_ADDR_AUX_MKPAGE(f) \
248 + ((u16)((((u32)(f))&HFA384x_ADDR_FLAT_AUX_PAGE_MASK)>>7))
249 +#define HFA384x_ADDR_AUX_MKOFF(f) \
250 + ((u16)(((u32)(f))&HFA384x_ADDR_FLAT_AUX_OFF_MASK))
251 +
252 +/* Make CMD format offset and page from a 32-bit flat address */
253 +#define HFA384x_ADDR_CMD_MKPAGE(f) \
254 + ((u16)((((u32)(f))&HFA384x_ADDR_FLAT_CMD_PAGE_MASK)>>16))
255 +#define HFA384x_ADDR_CMD_MKOFF(f) \
256 + ((u16)(((u32)(f))&HFA384x_ADDR_FLAT_CMD_OFF_MASK))
257 +
258 +/*--- Aux register masks/tests ----------------------*/
259 +/* Some of the upper bits of the AUX offset register are used to */
260 +/* select address space. */
261 +#define HFA384x_AUX_CTL_EXTDS (0x00)
262 +#define HFA384x_AUX_CTL_NV (0x01)
263 +#define HFA384x_AUX_CTL_PHY (0x02)
264 +#define HFA384x_AUX_CTL_ICSRAM (0x03)
265 +
266 +/* Make AUX register offset and page values from a flat address */
267 +#define HFA384x_AUX_MKOFF(f, c) \
268 + (HFA384x_ADDR_AUX_MKOFF(f) | (((u16)(c))<<12))
269 +#define HFA384x_AUX_MKPAGE(f) HFA384x_ADDR_AUX_MKPAGE(f)
270 +
271 +
272 +/*--- Controller Memory addresses -------------------*/
273 +#define HFA3842_PDA_BASE (0x007f0000UL)
274 +#define HFA3841_PDA_BASE (0x003f0000UL)
275 +#define HFA3841_PDA_BOGUS_BASE (0x00390000UL)
276 +
277 +/*--- Driver Download states -----------------------*/
278 +#define HFA384x_DLSTATE_DISABLED 0
279 +#define HFA384x_DLSTATE_RAMENABLED 1
280 +#define HFA384x_DLSTATE_FLASHENABLED 2
281 +#define HFA384x_DLSTATE_FLASHWRITTEN 3
282 +#define HFA384x_DLSTATE_FLASHWRITEPENDING 4
283 +#define HFA384x_DLSTATE_GENESIS 5
284 +
285 +#define HFA384x_CMD_OFF (0x00)
286 +#define HFA384x_PARAM0_OFF (0x04)
287 +#define HFA384x_PARAM1_OFF (0x08)
288 +#define HFA384x_PARAM2_OFF (0x0c)
289 +#define HFA384x_STATUS_OFF (0x10)
290 +#define HFA384x_RESP0_OFF (0x14)
291 +#define HFA384x_RESP1_OFF (0x18)
292 +#define HFA384x_RESP2_OFF (0x1c)
293 +#define HFA384x_INFOFID_OFF (0x20)
294 +#define HFA384x_RXFID_OFF (0x40)
295 +#define HFA384x_ALLOCFID_OFF (0x44)
296 +#define HFA384x_TXCOMPLFID_OFF (0x48)
297 +#define HFA384x_SELECT0_OFF (0x30)
298 +#define HFA384x_OFFSET0_OFF (0x38)
299 +#define HFA384x_DATA0_OFF (0x6c)
300 +#define HFA384x_SELECT1_OFF (0x34)
301 +#define HFA384x_OFFSET1_OFF (0x3c)
302 +#define HFA384x_DATA1_OFF (0x70)
303 +#define HFA384x_EVSTAT_OFF (0x60)
304 +#define HFA384x_intEN_OFF (0x64)
305 +#define HFA384x_EVACK_OFF (0x68)
306 +#define HFA384x_CONTROL_OFF (0x28)
307 +#define HFA384x_SWSUPPORT0_OFF (0x50)
308 +#define HFA384x_SWSUPPORT1_OFF (0x54)
309 +#define HFA384x_SWSUPPORT2_OFF (0x58)
310 +#define HFA384x_AUXPAGE_OFF (0x74)
311 +#define HFA384x_AUXOFFSET_OFF (0x78)
312 +#define HFA384x_AUXDATA_OFF (0x7c)
313 +#define HFA384x_PCICOR_OFF (0x4c)
314 +#define HFA384x_PCIHCR_OFF (0x5c)
315 +#define HFA384x_PCI_M0_ADDRH_OFF (0x80)
316 +#define HFA384x_PCI_M0_ADDRL_OFF (0x84)
317 +#define HFA384x_PCI_M0_LEN_OFF (0x88)
318 +#define HFA384x_PCI_M0_CTL_OFF (0x8c)
319 +#define HFA384x_PCI_STATUS_OFF (0x98)
320 +#define HFA384x_PCI_M1_ADDRH_OFF (0xa0)
321 +#define HFA384x_PCI_M1_ADDRL_OFF (0xa4)
322 +#define HFA384x_PCI_M1_LEN_OFF (0xa8)
323 +#define HFA384x_PCI_M1_CTL_OFF (0xac)
324 +
325 +/*--- Register Field Masks --------------------------*/
326 +#define HFA384x_CMD_BUSY ((u16)BIT15)
327 +#define HFA384x_CMD_AINFO ((u16)(BIT14 | BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8))
328 +#define HFA384x_CMD_MACPORT ((u16)(BIT10 | BIT9 | BIT8))
329 +#define HFA384x_CMD_RECL ((u16)BIT8)
330 +#define HFA384x_CMD_WRITE ((u16)BIT8)
331 +#define HFA384x_CMD_PROGMODE ((u16)(BIT9 | BIT8))
332 +#define HFA384x_CMD_CMDCODE ((u16)(BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0))
333 +
334 +#define HFA384x_STATUS_RESULT ((u16)(BIT14 | BIT13 | BIT12 | BIT11 | BIT10 | BIT9 | BIT8))
335 +#define HFA384x_STATUS_CMDCODE ((u16)(BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0))
336 +
337 +#define HFA384x_OFFSET_BUSY ((u16)BIT15)
338 +#define HFA384x_OFFSET_ERR ((u16)BIT14)
339 +#define HFA384x_OFFSET_DATAOFF ((u16)(BIT11 | BIT10 | BIT9 | BIT8 | BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1))
340 +
341 +#define HFA384x_EVSTAT_TICK ((u16)BIT15)
342 +#define HFA384x_EVSTAT_WTERR ((u16)BIT14)
343 +#define HFA384x_EVSTAT_INFDROP ((u16)BIT13)
344 +#define HFA384x_EVSTAT_INFO ((u16)BIT7)
345 +#define HFA384x_EVSTAT_DTIM ((u16)BIT5)
346 +#define HFA384x_EVSTAT_CMD ((u16)BIT4)
347 +#define HFA384x_EVSTAT_ALLOC ((u16)BIT3)
348 +#define HFA384x_EVSTAT_TXEXC ((u16)BIT2)
349 +#define HFA384x_EVSTAT_TX ((u16)BIT1)
350 +#define HFA384x_EVSTAT_RX ((u16)BIT0)
351 +
352 +#define HFA384x_int_BAP_OP (HFA384x_EVSTAT_INFO|HFA384x_EVSTAT_RX|HFA384x_EVSTAT_TX|HFA384x_EVSTAT_TXEXC)
353 +
354 +#define HFA384x_int_NORMAL (HFA384x_EVSTAT_INFO|HFA384x_EVSTAT_RX|HFA384x_EVSTAT_TX|HFA384x_EVSTAT_TXEXC|HFA384x_EVSTAT_INFDROP|HFA384x_EVSTAT_ALLOC|HFA384x_EVSTAT_DTIM)
355 +
356 +#define HFA384x_intEN_TICK ((u16)BIT15)
357 +#define HFA384x_intEN_WTERR ((u16)BIT14)
358 +#define HFA384x_intEN_INFDROP ((u16)BIT13)
359 +#define HFA384x_intEN_INFO ((u16)BIT7)
360 +#define HFA384x_intEN_DTIM ((u16)BIT5)
361 +#define HFA384x_intEN_CMD ((u16)BIT4)
362 +#define HFA384x_intEN_ALLOC ((u16)BIT3)
363 +#define HFA384x_intEN_TXEXC ((u16)BIT2)
364 +#define HFA384x_intEN_TX ((u16)BIT1)
365 +#define HFA384x_intEN_RX ((u16)BIT0)
366 +
367 +#define HFA384x_EVACK_TICK ((u16)BIT15)
368 +#define HFA384x_EVACK_WTERR ((u16)BIT14)
369 +#define HFA384x_EVACK_INFDROP ((u16)BIT13)
370 +#define HFA384x_EVACK_INFO ((u16)BIT7)
371 +#define HFA384x_EVACK_DTIM ((u16)BIT5)
372 +#define HFA384x_EVACK_CMD ((u16)BIT4)
373 +#define HFA384x_EVACK_ALLOC ((u16)BIT3)
374 +#define HFA384x_EVACK_TXEXC ((u16)BIT2)
375 +#define HFA384x_EVACK_TX ((u16)BIT1)
376 +#define HFA384x_EVACK_RX ((u16)BIT0)
377 +
378 +#define HFA384x_CONTROL_AUXEN ((u16)(BIT15 | BIT14))
379 +
380 +
381 +/*--- Command Code Constants --------------------------*/
382 +/*--- Controller Commands --------------------------*/
383 +#define HFA384x_CMDCODE_INIT ((u16)0x00)
384 +#define HFA384x_CMDCODE_ENABLE ((u16)0x01)
385 +#define HFA384x_CMDCODE_DISABLE ((u16)0x02)
386 +#define HFA384x_CMDCODE_DIAG ((u16)0x03)
387 +
388 +/*--- Buffer Mgmt Commands --------------------------*/
389 +#define HFA384x_CMDCODE_ALLOC ((u16)0x0A)
390 +#define HFA384x_CMDCODE_TX ((u16)0x0B)
391 +#define HFA384x_CMDCODE_CLRPRST ((u16)0x12)
392 +
393 +/*--- Regulate Commands --------------------------*/
394 +#define HFA384x_CMDCODE_NOTIFY ((u16)0x10)
395 +#define HFA384x_CMDCODE_INQ ((u16)0x11)
396 +
397 +/*--- Configure Commands --------------------------*/
398 +#define HFA384x_CMDCODE_ACCESS ((u16)0x21)
399 +#define HFA384x_CMDCODE_DOWNLD ((u16)0x22)
400 +
401 +/*--- Debugging Commands -----------------------------*/
402 +#define HFA384x_CMDCODE_MONITOR ((u16)(0x38))
403 +#define HFA384x_MONITOR_ENABLE ((u16)(0x0b))
404 +#define HFA384x_MONITOR_DISABLE ((u16)(0x0f))
405 +
406 +/*--- Result Codes --------------------------*/
407 +#define HFA384x_SUCCESS ((u16)(0x00))
408 +#define HFA384x_CARD_FAIL ((u16)(0x01))
409 +#define HFA384x_NO_BUFF ((u16)(0x05))
410 +#define HFA384x_CMD_ERR ((u16)(0x7F))
411 +
412 +/*--- Programming Modes --------------------------
413 + MODE 0: Disable programming
414 + MODE 1: Enable volatile memory programming
415 + MODE 2: Enable non-volatile memory programming
416 + MODE 3: Program non-volatile memory section
417 +--------------------------------------------------*/
418 +#define HFA384x_PROGMODE_DISABLE ((u16)0x00)
419 +#define HFA384x_PROGMODE_RAM ((u16)0x01)
420 +#define HFA384x_PROGMODE_NV ((u16)0x02)
421 +#define HFA384x_PROGMODE_NVWRITE ((u16)0x03)
422 +
423 +/*--- AUX register enable --------------------------*/
424 +#define HFA384x_AUXPW0 ((u16)0xfe01)
425 +#define HFA384x_AUXPW1 ((u16)0xdc23)
426 +#define HFA384x_AUXPW2 ((u16)0xba45)
427 +
428 +#define HFA384x_CONTROL_AUX_ISDISABLED ((u16)0x0000)
429 +#define HFA384x_CONTROL_AUX_ISENABLED ((u16)0xc000)
430 +#define HFA384x_CONTROL_AUX_DOENABLE ((u16)0x8000)
431 +#define HFA384x_CONTROL_AUX_DODISABLE ((u16)0x4000)
432 +
433 +/*--- Record ID Constants --------------------------*/
434 +/*--------------------------------------------------------------------
435 +Configuration RIDs: Network Parameters, Static Configuration Entities
436 +--------------------------------------------------------------------*/
437 +#define HFA384x_RID_CNFPORTTYPE ((u16)0xFC00)
438 +#define HFA384x_RID_CNFOWNMACADDR ((u16)0xFC01)
439 +#define HFA384x_RID_CNFDESIREDSSID ((u16)0xFC02)
440 +#define HFA384x_RID_CNFOWNCHANNEL ((u16)0xFC03)
441 +#define HFA384x_RID_CNFOWNSSID ((u16)0xFC04)
442 +#define HFA384x_RID_CNFOWNATIMWIN ((u16)0xFC05)
443 +#define HFA384x_RID_CNFSYSSCALE ((u16)0xFC06)
444 +#define HFA384x_RID_CNFMAXDATALEN ((u16)0xFC07)
445 +#define HFA384x_RID_CNFWDSADDR ((u16)0xFC08)
446 +#define HFA384x_RID_CNFPMENABLED ((u16)0xFC09)
447 +#define HFA384x_RID_CNFPMEPS ((u16)0xFC0A)
448 +#define HFA384x_RID_CNFMULTICASTRX ((u16)0xFC0B)
449 +#define HFA384x_RID_CNFMAXSLEEPDUR ((u16)0xFC0C)
450 +#define HFA384x_RID_CNFPMHOLDDUR ((u16)0xFC0D)
451 +#define HFA384x_RID_CNFOWNNAME ((u16)0xFC0E)
452 +#define HFA384x_RID_CNFOWNDTIMPER ((u16)0xFC10)
453 +#define HFA384x_RID_CNFWDSADDR1 ((u16)0xFC11)
454 +#define HFA384x_RID_CNFWDSADDR2 ((u16)0xFC12)
455 +#define HFA384x_RID_CNFWDSADDR3 ((u16)0xFC13)
456 +#define HFA384x_RID_CNFWDSADDR4 ((u16)0xFC14)
457 +#define HFA384x_RID_CNFWDSADDR5 ((u16)0xFC15)
458 +#define HFA384x_RID_CNFWDSADDR6 ((u16)0xFC16)
459 +#define HFA384x_RID_CNFMCASTPMBUFF ((u16)0xFC17)
460 +
461 +/*--------------------------------------------------------------------
462 +Configuration RID lengths: Network Params, Static Config Entities
463 + This is the length of JUST the DATA part of the RID (does not
464 + include the len or code fields)
465 +--------------------------------------------------------------------*/
466 +/* TODO: fill in the rest of these */
467 +#define HFA384x_RID_CNFPORTTYPE_LEN ((u16)2)
468 +#define HFA384x_RID_CNFOWNMACADDR_LEN ((u16)6)
469 +#define HFA384x_RID_CNFDESIREDSSID_LEN ((u16)34)
470 +#define HFA384x_RID_CNFOWNCHANNEL_LEN ((u16)2)
471 +#define HFA384x_RID_CNFOWNSSID_LEN ((u16)34)
472 +#define HFA384x_RID_CNFOWNATIMWIN_LEN ((u16)2)
473 +#define HFA384x_RID_CNFSYSSCALE_LEN ((u16)0)
474 +#define HFA384x_RID_CNFMAXDATALEN_LEN ((u16)0)
475 +#define HFA384x_RID_CNFWDSADDR_LEN ((u16)6)
476 +#define HFA384x_RID_CNFPMENABLED_LEN ((u16)0)
477 +#define HFA384x_RID_CNFPMEPS_LEN ((u16)0)
478 +#define HFA384x_RID_CNFMULTICASTRX_LEN ((u16)0)
479 +#define HFA384x_RID_CNFMAXSLEEPDUR_LEN ((u16)0)
480 +#define HFA384x_RID_CNFPMHOLDDUR_LEN ((u16)0)
481 +#define HFA384x_RID_CNFOWNNAME_LEN ((u16)34)
482 +#define HFA384x_RID_CNFOWNDTIMPER_LEN ((u16)0)
483 +#define HFA384x_RID_CNFWDSADDR1_LEN ((u16)6)
484 +#define HFA384x_RID_CNFWDSADDR2_LEN ((u16)6)
485 +#define HFA384x_RID_CNFWDSADDR3_LEN ((u16)6)
486 +#define HFA384x_RID_CNFWDSADDR4_LEN ((u16)6)
487 +#define HFA384x_RID_CNFWDSADDR5_LEN ((u16)6)
488 +#define HFA384x_RID_CNFWDSADDR6_LEN ((u16)6)
489 +#define HFA384x_RID_CNFMCASTPMBUFF_LEN ((u16)0)
490 +#define HFA384x_RID_CNFAUTHENTICATION_LEN ((u16)sizeof(u16))
491 +#define HFA384x_RID_CNFMAXSLEEPDUR_LEN ((u16)0)
492 +
493 +/*--------------------------------------------------------------------
494 +Configuration RIDs: Network Parameters, Dynamic Configuration Entities
495 +--------------------------------------------------------------------*/
496 +#define HFA384x_RID_GROUPADDR ((u16)0xFC80)
497 +#define HFA384x_RID_CREATEIBSS ((u16)0xFC81)
498 +#define HFA384x_RID_FRAGTHRESH ((u16)0xFC82)
499 +#define HFA384x_RID_RTSTHRESH ((u16)0xFC83)
500 +#define HFA384x_RID_TXRATECNTL ((u16)0xFC84)
501 +#define HFA384x_RID_PROMISCMODE ((u16)0xFC85)
502 +#define HFA384x_RID_FRAGTHRESH0 ((u16)0xFC90)
503 +#define HFA384x_RID_FRAGTHRESH1 ((u16)0xFC91)
504 +#define HFA384x_RID_FRAGTHRESH2 ((u16)0xFC92)
505 +#define HFA384x_RID_FRAGTHRESH3 ((u16)0xFC93)
506 +#define HFA384x_RID_FRAGTHRESH4 ((u16)0xFC94)
507 +#define HFA384x_RID_FRAGTHRESH5 ((u16)0xFC95)
508 +#define HFA384x_RID_FRAGTHRESH6 ((u16)0xFC96)
509 +#define HFA384x_RID_RTSTHRESH0 ((u16)0xFC97)
510 +#define HFA384x_RID_RTSTHRESH1 ((u16)0xFC98)
511 +#define HFA384x_RID_RTSTHRESH2 ((u16)0xFC99)
512 +#define HFA384x_RID_RTSTHRESH3 ((u16)0xFC9A)
513 +#define HFA384x_RID_RTSTHRESH4 ((u16)0xFC9B)
514 +#define HFA384x_RID_RTSTHRESH5 ((u16)0xFC9C)
515 +#define HFA384x_RID_RTSTHRESH6 ((u16)0xFC9D)
516 +#define HFA384x_RID_TXRATECNTL0 ((u16)0xFC9E)
517 +#define HFA384x_RID_TXRATECNTL1 ((u16)0xFC9F)
518 +#define HFA384x_RID_TXRATECNTL2 ((u16)0xFCA0)
519 +#define HFA384x_RID_TXRATECNTL3 ((u16)0xFCA1)
520 +#define HFA384x_RID_TXRATECNTL4 ((u16)0xFCA2)
521 +#define HFA384x_RID_TXRATECNTL5 ((u16)0xFCA3)
522 +#define HFA384x_RID_TXRATECNTL6 ((u16)0xFCA4)
523 +
524 +/*--------------------------------------------------------------------
525 +Configuration RID Lengths: Network Param, Dynamic Config Entities
526 + This is the length of JUST the DATA part of the RID (does not
527 + include the len or code fields)
528 +--------------------------------------------------------------------*/
529 +/* TODO: fill in the rest of these */
530 +#define HFA384x_RID_GROUPADDR_LEN ((u16)16 * WLAN_ADDR_LEN)
531 +#define HFA384x_RID_CREATEIBSS_LEN ((u16)0)
532 +#define HFA384x_RID_FRAGTHRESH_LEN ((u16)0)
533 +#define HFA384x_RID_RTSTHRESH_LEN ((u16)0)
534 +#define HFA384x_RID_TXRATECNTL_LEN ((u16)4)
535 +#define HFA384x_RID_PROMISCMODE_LEN ((u16)2)
536 +#define HFA384x_RID_FRAGTHRESH0_LEN ((u16)0)
537 +#define HFA384x_RID_FRAGTHRESH1_LEN ((u16)0)
538 +#define HFA384x_RID_FRAGTHRESH2_LEN ((u16)0)
539 +#define HFA384x_RID_FRAGTHRESH3_LEN ((u16)0)
540 +#define HFA384x_RID_FRAGTHRESH4_LEN ((u16)0)
541 +#define HFA384x_RID_FRAGTHRESH5_LEN ((u16)0)
542 +#define HFA384x_RID_FRAGTHRESH6_LEN ((u16)0)
543 +#define HFA384x_RID_RTSTHRESH0_LEN ((u16)0)
544 +#define HFA384x_RID_RTSTHRESH1_LEN ((u16)0)
545 +#define HFA384x_RID_RTSTHRESH2_LEN ((u16)0)
546 +#define HFA384x_RID_RTSTHRESH3_LEN ((u16)0)
547 +#define HFA384x_RID_RTSTHRESH4_LEN ((u16)0)
548 +#define HFA384x_RID_RTSTHRESH5_LEN ((u16)0)
549 +#define HFA384x_RID_RTSTHRESH6_LEN ((u16)0)
550 +#define HFA384x_RID_TXRATECNTL0_LEN ((u16)0)
551 +#define HFA384x_RID_TXRATECNTL1_LEN ((u16)0)
552 +#define HFA384x_RID_TXRATECNTL2_LEN ((u16)0)
553 +#define HFA384x_RID_TXRATECNTL3_LEN ((u16)0)
554 +#define HFA384x_RID_TXRATECNTL4_LEN ((u16)0)
555 +#define HFA384x_RID_TXRATECNTL5_LEN ((u16)0)
556 +#define HFA384x_RID_TXRATECNTL6_LEN ((u16)0)
557 +
558 +/*--------------------------------------------------------------------
559 +Configuration RIDs: Behavior Parameters
560 +--------------------------------------------------------------------*/
561 +#define HFA384x_RID_ITICKTIME ((u16)0xFCE0)
562 +
563 +/*--------------------------------------------------------------------
564 +Configuration RID Lengths: Behavior Parameters
565 + This is the length of JUST the DATA part of the RID (does not
566 + include the len or code fields)
567 +--------------------------------------------------------------------*/
568 +#define HFA384x_RID_ITICKTIME_LEN ((u16)2)
569 +
570 +/*----------------------------------------------------------------------
571 +Information RIDs: NIC Information
572 +--------------------------------------------------------------------*/
573 +#define HFA384x_RID_MAXLOADTIME ((u16)0xFD00)
574 +#define HFA384x_RID_DOWNLOADBUFFER ((u16)0xFD01)
575 +#define HFA384x_RID_PRIIDENTITY ((u16)0xFD02)
576 +#define HFA384x_RID_PRISUPRANGE ((u16)0xFD03)
577 +#define HFA384x_RID_PRI_CFIACTRANGES ((u16)0xFD04)
578 +#define HFA384x_RID_NICSERIALNUMBER ((u16)0xFD0A)
579 +#define HFA384x_RID_NICIDENTITY ((u16)0xFD0B)
580 +#define HFA384x_RID_MFISUPRANGE ((u16)0xFD0C)
581 +#define HFA384x_RID_CFISUPRANGE ((u16)0xFD0D)
582 +#define HFA384x_RID_CHANNELLIST ((u16)0xFD10)
583 +#define HFA384x_RID_REGULATORYDOMAINS ((u16)0xFD11)
584 +#define HFA384x_RID_TEMPTYPE ((u16)0xFD12)
585 +#define HFA384x_RID_CIS ((u16)0xFD13)
586 +#define HFA384x_RID_STAIDENTITY ((u16)0xFD20)
587 +#define HFA384x_RID_STASUPRANGE ((u16)0xFD21)
588 +#define HFA384x_RID_STA_MFIACTRANGES ((u16)0xFD22)
589 +#define HFA384x_RID_STA_CFIACTRANGES ((u16)0xFD23)
590 +#define HFA384x_RID_BUILDSEQ ((u16)0xFFFE)
591 +#define HFA384x_RID_FWID ((u16)0xFFFF)
592 +
593 +/*----------------------------------------------------------------------
594 +Information RID Lengths: NIC Information
595 + This is the length of JUST the DATA part of the RID (does not
596 + include the len or code fields)
597 +--------------------------------------------------------------------*/
598 +#define HFA384x_RID_MAXLOADTIME_LEN ((u16)0)
599 +#define HFA384x_RID_DOWNLOADBUFFER_LEN ((u16)sizeof(hfa384x_downloadbuffer_t))
600 +#define HFA384x_RID_PRIIDENTITY_LEN ((u16)8)
601 +#define HFA384x_RID_PRISUPRANGE_LEN ((u16)10)
602 +#define HFA384x_RID_CFIACTRANGES_LEN ((u16)10)
603 +#define HFA384x_RID_NICSERIALNUMBER_LEN ((u16)12)
604 +#define HFA384x_RID_NICIDENTITY_LEN ((u16)8)
605 +#define HFA384x_RID_MFISUPRANGE_LEN ((u16)10)
606 +#define HFA384x_RID_CFISUPRANGE_LEN ((u16)10)
607 +#define HFA384x_RID_CHANNELLIST_LEN ((u16)0)
608 +#define HFA384x_RID_REGULATORYDOMAINS_LEN ((u16)12)
609 +#define HFA384x_RID_TEMPTYPE_LEN ((u16)0)
610 +#define HFA384x_RID_CIS_LEN ((u16)480)
611 +#define HFA384x_RID_STAIDENTITY_LEN ((u16)8)
612 +#define HFA384x_RID_STASUPRANGE_LEN ((u16)10)
613 +#define HFA384x_RID_MFIACTRANGES_LEN ((u16)10)
614 +#define HFA384x_RID_CFIACTRANGES2_LEN ((u16)10)
615 +#define HFA384x_RID_BUILDSEQ_LEN ((u16)sizeof(hfa384x_BuildSeq_t))
616 +#define HFA384x_RID_FWID_LEN ((u16)sizeof(hfa384x_FWID_t))
617 +
618 +/*--------------------------------------------------------------------
619 +Information RIDs: MAC Information
620 +--------------------------------------------------------------------*/
621 +#define HFA384x_RID_PORTSTATUS ((u16)0xFD40)
622 +#define HFA384x_RID_CURRENTSSID ((u16)0xFD41)
623 +#define HFA384x_RID_CURRENTBSSID ((u16)0xFD42)
624 +#define HFA384x_RID_COMMSQUALITY ((u16)0xFD43)
625 +#define HFA384x_RID_CURRENTTXRATE ((u16)0xFD44)
626 +#define HFA384x_RID_CURRENTBCNint ((u16)0xFD45)
627 +#define HFA384x_RID_CURRENTSCALETHRESH ((u16)0xFD46)
628 +#define HFA384x_RID_PROTOCOLRSPTIME ((u16)0xFD47)
629 +#define HFA384x_RID_SHORTRETRYLIMIT ((u16)0xFD48)
630 +#define HFA384x_RID_LONGRETRYLIMIT ((u16)0xFD49)
631 +#define HFA384x_RID_MAXTXLIFETIME ((u16)0xFD4A)
632 +#define HFA384x_RID_MAXRXLIFETIME ((u16)0xFD4B)
633 +#define HFA384x_RID_CFPOLLABLE ((u16)0xFD4C)
634 +#define HFA384x_RID_AUTHALGORITHMS ((u16)0xFD4D)
635 +#define HFA384x_RID_PRIVACYOPTIMP ((u16)0xFD4F)
636 +#define HFA384x_RID_DBMCOMMSQUALITY ((u16)0xFD51)
637 +#define HFA384x_RID_CURRENTTXRATE1 ((u16)0xFD80)
638 +#define HFA384x_RID_CURRENTTXRATE2 ((u16)0xFD81)
639 +#define HFA384x_RID_CURRENTTXRATE3 ((u16)0xFD82)
640 +#define HFA384x_RID_CURRENTTXRATE4 ((u16)0xFD83)
641 +#define HFA384x_RID_CURRENTTXRATE5 ((u16)0xFD84)
642 +#define HFA384x_RID_CURRENTTXRATE6 ((u16)0xFD85)
643 +#define HFA384x_RID_OWNMACADDRESS ((u16)0xFD86)
644 +// #define HFA384x_RID_PCFINFO ((u16)0xFD87)
645 +#define HFA384x_RID_SCANRESULTS ((u16)0xFD88) // NEW
646 +#define HFA384x_RID_HOSTSCANRESULTS ((u16)0xFD89) // NEW
647 +#define HFA384x_RID_AUTHENTICATIONUSED ((u16)0xFD8A) // NEW
648 +#define HFA384x_RID_ASSOCIATEFAILURE ((u16)0xFD8D) // 1.8.0
649 +
650 +/*--------------------------------------------------------------------
651 +Information RID Lengths: MAC Information
652 + This is the length of JUST the DATA part of the RID (does not
653 + include the len or code fields)
654 +--------------------------------------------------------------------*/
655 +#define HFA384x_RID_PORTSTATUS_LEN ((u16)0)
656 +#define HFA384x_RID_CURRENTSSID_LEN ((u16)34)
657 +#define HFA384x_RID_CURRENTBSSID_LEN ((u16)WLAN_BSSID_LEN)
658 +#define HFA384x_RID_COMMSQUALITY_LEN ((u16)sizeof(hfa384x_commsquality_t))
659 +#define HFA384x_RID_DBMCOMMSQUALITY_LEN ((u16)sizeof(hfa384x_dbmcommsquality_t))
660 +#define HFA384x_RID_CURRENTTXRATE_LEN ((u16)0)
661 +#define HFA384x_RID_CURRENTBCNint_LEN ((u16)0)
662 +#define HFA384x_RID_STACURSCALETHRESH_LEN ((u16)12)
663 +#define HFA384x_RID_APCURSCALETHRESH_LEN ((u16)6)
664 +#define HFA384x_RID_PROTOCOLRSPTIME_LEN ((u16)0)
665 +#define HFA384x_RID_SHORTRETRYLIMIT_LEN ((u16)0)
666 +#define HFA384x_RID_LONGRETRYLIMIT_LEN ((u16)0)
667 +#define HFA384x_RID_MAXTXLIFETIME_LEN ((u16)0)
668 +#define HFA384x_RID_MAXRXLIFETIME_LEN ((u16)0)
669 +#define HFA384x_RID_CFPOLLABLE_LEN ((u16)0)
670 +#define HFA384x_RID_AUTHALGORITHMS_LEN ((u16)4)
671 +#define HFA384x_RID_PRIVACYOPTIMP_LEN ((u16)0)
672 +#define HFA384x_RID_CURRENTTXRATE1_LEN ((u16)0)
673 +#define HFA384x_RID_CURRENTTXRATE2_LEN ((u16)0)
674 +#define HFA384x_RID_CURRENTTXRATE3_LEN ((u16)0)
675 +#define HFA384x_RID_CURRENTTXRATE4_LEN ((u16)0)
676 +#define HFA384x_RID_CURRENTTXRATE5_LEN ((u16)0)
677 +#define HFA384x_RID_CURRENTTXRATE6_LEN ((u16)0)
678 +#define HFA384x_RID_OWNMACADDRESS_LEN ((u16)6)
679 +#define HFA384x_RID_PCFINFO_LEN ((u16)6)
680 +#define HFA384x_RID_CNFAPPCFINFO_LEN ((u16)sizeof(hfa384x_PCFInfo_data_t))
681 +#define HFA384x_RID_SCANREQUEST_LEN ((u16)sizeof(hfa384x_ScanRequest_data_t))
682 +#define HFA384x_RID_JOINREQUEST_LEN ((u16)sizeof(hfa384x_JoinRequest_data_t))
683 +#define HFA384x_RID_AUTHENTICATESTA_LEN ((u16)sizeof(hfa384x_authenticateStation_data_t))
684 +#define HFA384x_RID_CHANNELINFOREQUEST_LEN ((u16)sizeof(hfa384x_ChannelInfoRequest_data_t))
685 +/*--------------------------------------------------------------------
686 +Information RIDs: Modem Information
687 +--------------------------------------------------------------------*/
688 +#define HFA384x_RID_PHYTYPE ((u16)0xFDC0)
689 +#define HFA384x_RID_CURRENTCHANNEL ((u16)0xFDC1)
690 +#define HFA384x_RID_CURRENTPOWERSTATE ((u16)0xFDC2)
691 +#define HFA384x_RID_CCAMODE ((u16)0xFDC3)
692 +#define HFA384x_RID_SUPPORTEDDATARATES ((u16)0xFDC6)
693 +#define HFA384x_RID_LFOSTATUS ((u16)0xFDC7) // 1.7.1
694 +
695 +/*--------------------------------------------------------------------
696 +Information RID Lengths: Modem Information
697 + This is the length of JUST the DATA part of the RID (does not
698 + include the len or code fields)
699 +--------------------------------------------------------------------*/
700 +#define HFA384x_RID_PHYTYPE_LEN ((u16)0)
701 +#define HFA384x_RID_CURRENTCHANNEL_LEN ((u16)0)
702 +#define HFA384x_RID_CURRENTPOWERSTATE_LEN ((u16)0)
703 +#define HFA384x_RID_CCAMODE_LEN ((u16)0)
704 +#define HFA384x_RID_SUPPORTEDDATARATES_LEN ((u16)10)
705 +
706 +/*--------------------------------------------------------------------
707 +API ENHANCEMENTS (NOT ALREADY IMPLEMENTED)
708 +--------------------------------------------------------------------*/
709 +#define HFA384x_RID_CNFWEPDEFAULTKEYID ((u16)0xFC23)
710 +#define HFA384x_RID_CNFWEPDEFAULTKEY0 ((u16)0xFC24)
711 +#define HFA384x_RID_CNFWEPDEFAULTKEY1 ((u16)0xFC25)
712 +#define HFA384x_RID_CNFWEPDEFAULTKEY2 ((u16)0xFC26)
713 +#define HFA384x_RID_CNFWEPDEFAULTKEY3 ((u16)0xFC27)
714 +#define HFA384x_RID_CNFWEPFLAGS ((u16)0xFC28)
715 +#define HFA384x_RID_CNFWEPKEYMAPTABLE ((u16)0xFC29)
716 +#define HFA384x_RID_CNFAUTHENTICATION ((u16)0xFC2A)
717 +#define HFA384x_RID_CNFMAXASSOCSTATIONS ((u16)0xFC2B)
718 +#define HFA384x_RID_CNFTXCONTROL ((u16)0xFC2C)
719 +#define HFA384x_RID_CNFROAMINGMODE ((u16)0xFC2D)
720 +#define HFA384x_RID_CNFHOSTAUTHASSOC ((u16)0xFC2E)
721 +#define HFA384x_RID_CNFRCVCRCERROR ((u16)0xFC30)
722 +// #define HFA384x_RID_CNFMMLIFE ((u16)0xFC31)
723 +#define HFA384x_RID_CNFALTRETRYCNT ((u16)0xFC32)
724 +#define HFA384x_RID_CNFAPBCNint ((u16)0xFC33)
725 +#define HFA384x_RID_CNFAPPCFINFO ((u16)0xFC34)
726 +#define HFA384x_RID_CNFSTAPCFINFO ((u16)0xFC35)
727 +#define HFA384x_RID_CNFPRIORITYQUSAGE ((u16)0xFC37)
728 +#define HFA384x_RID_CNFTIMCTRL ((u16)0xFC40)
729 +#define HFA384x_RID_CNFTHIRTY2TALLY ((u16)0xFC42)
730 +#define HFA384x_RID_CNFENHSECURITY ((u16)0xFC43)
731 +#define HFA384x_RID_CNFDBMADJUST ((u16)0xFC46) // NEW
732 +#define HFA384x_RID_CNFWPADATA ((u16)0xFC48) // 1.7.0
733 +#define HFA384x_RID_CNFPROPOGATIONDELAY ((u16)0xFC49) // 1.7.6
734 +#define HFA384x_RID_CNFSHORTPREAMBLE ((u16)0xFCB0)
735 +#define HFA384x_RID_CNFEXCLONGPREAMBLE ((u16)0xFCB1)
736 +#define HFA384x_RID_CNFAUTHRSPTIMEOUT ((u16)0xFCB2)
737 +#define HFA384x_RID_CNFBASICRATES ((u16)0xFCB3)
738 +#define HFA384x_RID_CNFSUPPRATES ((u16)0xFCB4)
739 +#define HFA384x_RID_CNFFALLBACKCTRL ((u16)0xFCB5) // NEW
740 +#define HFA384x_RID_WEPKEYSTATUS ((u16)0xFCB6) // NEW
741 +#define HFA384x_RID_WEPKEYMAPINDEX ((u16)0xFCB7) // NEW
742 +#define HFA384x_RID_BROADCASTKEYID ((u16)0xFCB8) // NEW
743 +#define HFA384x_RID_ENTSECFLAGEYID ((u16)0xFCB9) // NEW
744 +#define HFA384x_RID_CNFPASSIVESCANCTRL ((u16)0xFCBA) // NEW STA
745 +#define HFA384x_RID_CNFWPAHANDLING ((u16)0xFCBB) // 1.7.0
746 +#define HFA384x_RID_MDCCONTROL ((u16)0xFCBC) // 1.7.0/1.4.0
747 +#define HFA384x_RID_MDCCOUNTRY ((u16)0xFCBD) // 1.7.0/1.4.0
748 +#define HFA384x_RID_TXPOWERMAX ((u16)0xFCBE) // 1.7.0/1.4.0
749 +#define HFA384x_RID_CNFLFOENBLED ((u16)0xFCBF) // 1.6.3
750 +#define HFA384x_RID_CAPINFO ((u16)0xFCC0) // 1.7.0/1.3.7
751 +#define HFA384x_RID_LISTENintERVAL ((u16)0xFCC1) // 1.7.0/1.3.7
752 +#define HFA384x_RID_DIVERSITYENABLED ((u16)0xFCC2) // 1.7.0/1.3.7
753 +#define HFA384x_RID_LED_CONTROL ((u16)0xFCC4) // 1.7.6
754 +#define HFA384x_RID_HFO_DELAY ((u16)0xFCC5) // 1.7.6
755 +#define HFA384x_RID_DISSALOWEDBSSID ((u16)0xFCC6) // 1.8.0
756 +#define HFA384x_RID_SCANREQUEST ((u16)0xFCE1)
757 +#define HFA384x_RID_JOINREQUEST ((u16)0xFCE2)
758 +#define HFA384x_RID_AUTHENTICATESTA ((u16)0xFCE3)
759 +#define HFA384x_RID_CHANNELINFOREQUEST ((u16)0xFCE4)
760 +#define HFA384x_RID_HOSTSCAN ((u16)0xFCE5) // NEW STA
761 +#define HFA384x_RID_ASSOCIATESTA ((u16)0xFCE6)
762 +
763 +#define HFA384x_RID_CNFWEPDEFAULTKEY_LEN ((u16)6)
764 +#define HFA384x_RID_CNFWEP128DEFAULTKEY_LEN ((u16)14)
765 +#define HFA384x_RID_CNFPRIOQUSAGE_LEN ((u16)4)
766 +/*--------------------------------------------------------------------
767 +PD Record codes
768 +--------------------------------------------------------------------*/
769 +#define HFA384x_PDR_PCB_PARTNUM ((u16)0x0001)
770 +#define HFA384x_PDR_PDAVER ((u16)0x0002)
771 +#define HFA384x_PDR_NIC_SERIAL ((u16)0x0003)
772 +#define HFA384x_PDR_MKK_MEASUREMENTS ((u16)0x0004)
773 +#define HFA384x_PDR_NIC_RAMSIZE ((u16)0x0005)
774 +#define HFA384x_PDR_MFISUPRANGE ((u16)0x0006)
775 +#define HFA384x_PDR_CFISUPRANGE ((u16)0x0007)
776 +#define HFA384x_PDR_NICID ((u16)0x0008)
777 +//#define HFA384x_PDR_REFDAC_MEASUREMENTS ((u16)0x0010)
778 +//#define HFA384x_PDR_VGDAC_MEASUREMENTS ((u16)0x0020)
779 +//#define HFA384x_PDR_LEVEL_COMP_MEASUREMENTS ((u16)0x0030)
780 +//#define HFA384x_PDR_MODEM_TRIMDAC_MEASUREMENTS ((u16)0x0040)
781 +//#define HFA384x_PDR_COREGA_HACK ((u16)0x00ff)
782 +#define HFA384x_PDR_MAC_ADDRESS ((u16)0x0101)
783 +//#define HFA384x_PDR_MKK_CALLNAME ((u16)0x0102)
784 +#define HFA384x_PDR_REGDOMAIN ((u16)0x0103)
785 +#define HFA384x_PDR_ALLOWED_CHANNEL ((u16)0x0104)
786 +#define HFA384x_PDR_DEFAULT_CHANNEL ((u16)0x0105)
787 +//#define HFA384x_PDR_PRIVACY_OPTION ((u16)0x0106)
788 +#define HFA384x_PDR_TEMPTYPE ((u16)0x0107)
789 +//#define HFA384x_PDR_REFDAC_SETUP ((u16)0x0110)
790 +//#define HFA384x_PDR_VGDAC_SETUP ((u16)0x0120)
791 +//#define HFA384x_PDR_LEVEL_COMP_SETUP ((u16)0x0130)
792 +//#define HFA384x_PDR_TRIMDAC_SETUP ((u16)0x0140)
793 +#define HFA384x_PDR_IFR_SETTING ((u16)0x0200)
794 +#define HFA384x_PDR_RFR_SETTING ((u16)0x0201)
795 +#define HFA384x_PDR_HFA3861_BASELINE ((u16)0x0202)
796 +#define HFA384x_PDR_HFA3861_SHADOW ((u16)0x0203)
797 +#define HFA384x_PDR_HFA3861_IFRF ((u16)0x0204)
798 +#define HFA384x_PDR_HFA3861_CHCALSP ((u16)0x0300)
799 +#define HFA384x_PDR_HFA3861_CHCALI ((u16)0x0301)
800 +#define HFA384x_PDR_MAX_TX_POWER ((u16)0x0302)
801 +#define HFA384x_PDR_MASTER_CHAN_LIST ((u16)0x0303)
802 +#define HFA384x_PDR_3842_NIC_CONFIG ((u16)0x0400)
803 +#define HFA384x_PDR_USB_ID ((u16)0x0401)
804 +#define HFA384x_PDR_PCI_ID ((u16)0x0402)
805 +#define HFA384x_PDR_PCI_IFCONF ((u16)0x0403)
806 +#define HFA384x_PDR_PCI_PMCONF ((u16)0x0404)
807 +#define HFA384x_PDR_RFENRGY ((u16)0x0406)
808 +#define HFA384x_PDR_USB_POWER_TYPE ((u16)0x0407)
809 +//#define HFA384x_PDR_UNKNOWN408 ((u16)0x0408)
810 +#define HFA384x_PDR_USB_MAX_POWER ((u16)0x0409)
811 +#define HFA384x_PDR_USB_MANUFACTURER ((u16)0x0410)
812 +#define HFA384x_PDR_USB_PRODUCT ((u16)0x0411)
813 +#define HFA384x_PDR_ANT_DIVERSITY ((u16)0x0412)
814 +#define HFA384x_PDR_HFO_DELAY ((u16)0x0413)
815 +#define HFA384x_PDR_SCALE_THRESH ((u16)0x0414)
816 +
817 +#define HFA384x_PDR_HFA3861_MANF_TESTSP ((u16)0x0900)
818 +#define HFA384x_PDR_HFA3861_MANF_TESTI ((u16)0x0901)
819 +#define HFA384x_PDR_END_OF_PDA ((u16)0x0000)
820 +
821 +
822 +/*=============================================================*/
823 +/*------ Macros -----------------------------------------------*/
824 +
825 +/*--- Register ID macros ------------------------*/
826 +
827 +#define HFA384x_CMD HFA384x_CMD_OFF
828 +#define HFA384x_PARAM0 HFA384x_PARAM0_OFF
829 +#define HFA384x_PARAM1 HFA384x_PARAM1_OFF
830 +#define HFA384x_PARAM2 HFA384x_PARAM2_OFF
831 +#define HFA384x_STATUS HFA384x_STATUS_OFF
832 +#define HFA384x_RESP0 HFA384x_RESP0_OFF
833 +#define HFA384x_RESP1 HFA384x_RESP1_OFF
834 +#define HFA384x_RESP2 HFA384x_RESP2_OFF
835 +#define HFA384x_INFOFID HFA384x_INFOFID_OFF
836 +#define HFA384x_RXFID HFA384x_RXFID_OFF
837 +#define HFA384x_ALLOCFID HFA384x_ALLOCFID_OFF
838 +#define HFA384x_TXCOMPLFID HFA384x_TXCOMPLFID_OFF
839 +#define HFA384x_SELECT0 HFA384x_SELECT0_OFF
840 +#define HFA384x_OFFSET0 HFA384x_OFFSET0_OFF
841 +#define HFA384x_DATA0 HFA384x_DATA0_OFF
842 +#define HFA384x_SELECT1 HFA384x_SELECT1_OFF
843 +#define HFA384x_OFFSET1 HFA384x_OFFSET1_OFF
844 +#define HFA384x_DATA1 HFA384x_DATA1_OFF
845 +#define HFA384x_EVSTAT HFA384x_EVSTAT_OFF
846 +#define HFA384x_intEN HFA384x_INTEN_OFF
847 +#define HFA384x_EVACK HFA384x_EVACK_OFF
848 +#define HFA384x_CONTROL HFA384x_CONTROL_OFF
849 +#define HFA384x_SWSUPPORT0 HFA384x_SWSUPPORT0_OFF
850 +#define HFA384x_SWSUPPORT1 HFA384x_SWSUPPORT1_OFF
851 +#define HFA384x_SWSUPPORT2 HFA384x_SWSUPPORT2_OFF
852 +#define HFA384x_AUXPAGE HFA384x_AUXPAGE_OFF
853 +#define HFA384x_AUXOFFSET HFA384x_AUXOFFSET_OFF
854 +#define HFA384x_AUXDATA HFA384x_AUXDATA_OFF
855 +#define HFA384x_PCICOR HFA384x_PCICOR_OFF
856 +#define HFA384x_PCIHCR HFA384x_PCIHCR_OFF
857 +
858 +
859 +/*--- Register Test/Get/Set Field macros ------------------------*/
860 +
861 +#define HFA384x_CMD_ISBUSY(value) ((u16)(((u16)value) & HFA384x_CMD_BUSY))
862 +#define HFA384x_CMD_AINFO_GET(value) ((u16)(((u16)(value) & HFA384x_CMD_AINFO) >> 8))
863 +#define HFA384x_CMD_AINFO_SET(value) ((u16)((u16)(value) << 8))
864 +#define HFA384x_CMD_MACPORT_GET(value) ((u16)(HFA384x_CMD_AINFO_GET((u16)(value) & HFA384x_CMD_MACPORT)))
865 +#define HFA384x_CMD_MACPORT_SET(value) ((u16)HFA384x_CMD_AINFO_SET(value))
866 +#define HFA384x_CMD_ISRECL(value) ((u16)(HFA384x_CMD_AINFO_GET((u16)(value) & HFA384x_CMD_RECL)))
867 +#define HFA384x_CMD_RECL_SET(value) ((u16)HFA384x_CMD_AINFO_SET(value))
868 +#define HFA384x_CMD_QOS_GET(value) ((u16)((((u16)(value))&((u16)0x3000)) >> 12))
869 +#define HFA384x_CMD_QOS_SET(value) ((u16)((((u16)(value)) << 12) & 0x3000))
870 +#define HFA384x_CMD_ISWRITE(value) ((u16)(HFA384x_CMD_AINFO_GET((u16)(value) & HFA384x_CMD_WRITE)))
871 +#define HFA384x_CMD_WRITE_SET(value) ((u16)HFA384x_CMD_AINFO_SET((u16)value))
872 +#define HFA384x_CMD_PROGMODE_GET(value) ((u16)(HFA384x_CMD_AINFO_GET((u16)(value) & HFA384x_CMD_PROGMODE)))
873 +#define HFA384x_CMD_PROGMODE_SET(value) ((u16)HFA384x_CMD_AINFO_SET((u16)value))
874 +#define HFA384x_CMD_CMDCODE_GET(value) ((u16)(((u16)(value)) & HFA384x_CMD_CMDCODE))
875 +#define HFA384x_CMD_CMDCODE_SET(value) ((u16)(value))
876 +
877 +#define HFA384x_STATUS_RESULT_GET(value) ((u16)((((u16)(value)) & HFA384x_STATUS_RESULT) >> 8))
878 +#define HFA384x_STATUS_RESULT_SET(value) (((u16)(value)) << 8)
879 +#define HFA384x_STATUS_CMDCODE_GET(value) (((u16)(value)) & HFA384x_STATUS_CMDCODE)
880 +#define HFA384x_STATUS_CMDCODE_SET(value) ((u16)(value))
881 +
882 +#define HFA384x_OFFSET_ISBUSY(value) ((u16)(((u16)(value)) & HFA384x_OFFSET_BUSY))
883 +#define HFA384x_OFFSET_ISERR(value) ((u16)(((u16)(value)) & HFA384x_OFFSET_ERR))
884 +#define HFA384x_OFFSET_DATAOFF_GET(value) ((u16)(((u16)(value)) & HFA384x_OFFSET_DATAOFF))
885 +#define HFA384x_OFFSET_DATAOFF_SET(value) ((u16)(value))
886 +
887 +#define HFA384x_EVSTAT_ISTICK(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_TICK))
888 +#define HFA384x_EVSTAT_ISWTERR(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_WTERR))
889 +#define HFA384x_EVSTAT_ISINFDROP(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_INFDROP))
890 +#define HFA384x_EVSTAT_ISINFO(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_INFO))
891 +#define HFA384x_EVSTAT_ISDTIM(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_DTIM))
892 +#define HFA384x_EVSTAT_ISCMD(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_CMD))
893 +#define HFA384x_EVSTAT_ISALLOC(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_ALLOC))
894 +#define HFA384x_EVSTAT_ISTXEXC(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_TXEXC))
895 +#define HFA384x_EVSTAT_ISTX(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_TX))
896 +#define HFA384x_EVSTAT_ISRX(value) ((u16)(((u16)(value)) & HFA384x_EVSTAT_RX))
897 +
898 +#define HFA384x_EVSTAT_ISBAP_OP(value) ((u16)(((u16)(value)) & HFA384x_int_BAP_OP))
899 +
900 +#define HFA384x_intEN_ISTICK(value) ((u16)(((u16)(value)) & HFA384x_INTEN_TICK))
901 +#define HFA384x_intEN_TICK_SET(value) ((u16)(((u16)(value)) << 15))
902 +#define HFA384x_intEN_ISWTERR(value) ((u16)(((u16)(value)) & HFA384x_INTEN_WTERR))
903 +#define HFA384x_intEN_WTERR_SET(value) ((u16)(((u16)(value)) << 14))
904 +#define HFA384x_intEN_ISINFDROP(value) ((u16)(((u16)(value)) & HFA384x_INTEN_INFDROP))
905 +#define HFA384x_intEN_INFDROP_SET(value) ((u16)(((u16)(value)) << 13))
906 +#define HFA384x_intEN_ISINFO(value) ((u16)(((u16)(value)) & HFA384x_INTEN_INFO))
907 +#define HFA384x_intEN_INFO_SET(value) ((u16)(((u16)(value)) << 7))
908 +#define HFA384x_intEN_ISDTIM(value) ((u16)(((u16)(value)) & HFA384x_INTEN_DTIM))
909 +#define HFA384x_intEN_DTIM_SET(value) ((u16)(((u16)(value)) << 5))
910 +#define HFA384x_intEN_ISCMD(value) ((u16)(((u16)(value)) & HFA384x_INTEN_CMD))
911 +#define HFA384x_intEN_CMD_SET(value) ((u16)(((u16)(value)) << 4))
912 +#define HFA384x_intEN_ISALLOC(value) ((u16)(((u16)(value)) & HFA384x_INTEN_ALLOC))
913 +#define HFA384x_intEN_ALLOC_SET(value) ((u16)(((u16)(value)) << 3))
914 +#define HFA384x_intEN_ISTXEXC(value) ((u16)(((u16)(value)) & HFA384x_INTEN_TXEXC))
915 +#define HFA384x_intEN_TXEXC_SET(value) ((u16)(((u16)(value)) << 2))
916 +#define HFA384x_intEN_ISTX(value) ((u16)(((u16)(value)) & HFA384x_INTEN_TX))
917 +#define HFA384x_intEN_TX_SET(value) ((u16)(((u16)(value)) << 1))
918 +#define HFA384x_intEN_ISRX(value) ((u16)(((u16)(value)) & HFA384x_INTEN_RX))
919 +#define HFA384x_intEN_RX_SET(value) ((u16)(((u16)(value)) << 0))
920 +
921 +#define HFA384x_EVACK_ISTICK(value) ((u16)(((u16)(value)) & HFA384x_EVACK_TICK))
922 +#define HFA384x_EVACK_TICK_SET(value) ((u16)(((u16)(value)) << 15))
923 +#define HFA384x_EVACK_ISWTERR(value) ((u16)(((u16)(value)) & HFA384x_EVACK_WTERR))
924 +#define HFA384x_EVACK_WTERR_SET(value) ((u16)(((u16)(value)) << 14))
925 +#define HFA384x_EVACK_ISINFDROP(value) ((u16)(((u16)(value)) & HFA384x_EVACK_INFDROP))
926 +#define HFA384x_EVACK_INFDROP_SET(value) ((u16)(((u16)(value)) << 13))
927 +#define HFA384x_EVACK_ISINFO(value) ((u16)(((u16)(value)) & HFA384x_EVACK_INFO))
928 +#define HFA384x_EVACK_INFO_SET(value) ((u16)(((u16)(value)) << 7))
929 +#define HFA384x_EVACK_ISDTIM(value) ((u16)(((u16)(value)) & HFA384x_EVACK_DTIM))
930 +#define HFA384x_EVACK_DTIM_SET(value) ((u16)(((u16)(value)) << 5))
931 +#define HFA384x_EVACK_ISCMD(value) ((u16)(((u16)(value)) & HFA384x_EVACK_CMD))
932 +#define HFA384x_EVACK_CMD_SET(value) ((u16)(((u16)(value)) << 4))
933 +#define HFA384x_EVACK_ISALLOC(value) ((u16)(((u16)(value)) & HFA384x_EVACK_ALLOC))
934 +#define HFA384x_EVACK_ALLOC_SET(value) ((u16)(((u16)(value)) << 3))
935 +#define HFA384x_EVACK_ISTXEXC(value) ((u16)(((u16)(value)) & HFA384x_EVACK_TXEXC))
936 +#define HFA384x_EVACK_TXEXC_SET(value) ((u16)(((u16)(value)) << 2))
937 +#define HFA384x_EVACK_ISTX(value) ((u16)(((u16)(value)) & HFA384x_EVACK_TX))
938 +#define HFA384x_EVACK_TX_SET(value) ((u16)(((u16)(value)) << 1))
939 +#define HFA384x_EVACK_ISRX(value) ((u16)(((u16)(value)) & HFA384x_EVACK_RX))
940 +#define HFA384x_EVACK_RX_SET(value) ((u16)(((u16)(value)) << 0))
941 +
942 +#define HFA384x_CONTROL_AUXEN_SET(value) ((u16)(((u16)(value)) << 14))
943 +#define HFA384x_CONTROL_AUXEN_GET(value) ((u16)(((u16)(value)) >> 14))
944 +
945 +/* Byte Order */
946 +#ifdef __KERNEL__
947 +#define hfa384x2host_16(n) (__le16_to_cpu((u16)(n)))
948 +#define hfa384x2host_32(n) (__le32_to_cpu((u32)(n)))
949 +#define host2hfa384x_16(n) (__cpu_to_le16((u16)(n)))
950 +#define host2hfa384x_32(n) (__cpu_to_le32((u32)(n)))
951 +#endif
952 +
953 +/* Host Maintained State Info */
954 +#define HFA384x_STATE_PREINIT 0
955 +#define HFA384x_STATE_INIT 1
956 +#define HFA384x_STATE_RUNNING 2
957 +
958 +/*=============================================================*/
959 +/*------ Types and their related constants --------------------*/
960 +
961 +#define HFA384x_HOSTAUTHASSOC_HOSTAUTH BIT0
962 +#define HFA384x_HOSTAUTHASSOC_HOSTASSOC BIT1
963 +
964 +#define HFA384x_WHAHANDLING_DISABLED 0
965 +#define HFA384x_WHAHANDLING_PASSTHROUGH BIT1
966 +
967 +/*-------------------------------------------------------------*/
968 +/* Commonly used basic types */
969 +typedef struct hfa384x_bytestr
970 +{
971 + u16 len;
972 + u8 data[0];
973 +} __WLAN_ATTRIB_PACK__ hfa384x_bytestr_t;
974 +
975 +typedef struct hfa384x_bytestr32
976 +{
977 + u16 len;
978 + u8 data[32];
979 +} __WLAN_ATTRIB_PACK__ hfa384x_bytestr32_t;
980 +
981 +/*--------------------------------------------------------------------
982 +Configuration Record Structures:
983 + Network Parameters, Static Configuration Entities
984 +--------------------------------------------------------------------*/
985 +/* Prototype structure: all configuration record structures start with
986 +these members */
987 +
988 +typedef struct hfa384x_record
989 +{
990 + u16 reclen;
991 + u16 rid;
992 +} __WLAN_ATTRIB_PACK__ hfa384x_rec_t;
993 +
994 +typedef struct hfa384x_record16
995 +{
996 + u16 reclen;
997 + u16 rid;
998 + u16 val;
999 +} __WLAN_ATTRIB_PACK__ hfa384x_rec16_t;
1000 +
1001 +typedef struct hfa384x_record32
1002 +{
1003 + u16 reclen;
1004 + u16 rid;
1005 + u32 val;
1006 +} __WLAN_ATTRIB_PACK__ hfa384x_rec32;
1007 +
1008 +/*-- Hardware/Firmware Component Information ----------*/
1009 +typedef struct hfa384x_compident
1010 +{
1011 + u16 id;
1012 + u16 variant;
1013 + u16 major;
1014 + u16 minor;
1015 +} __WLAN_ATTRIB_PACK__ hfa384x_compident_t;
1016 +
1017 +typedef struct hfa384x_caplevel
1018 +{
1019 + u16 role;
1020 + u16 id;
1021 + u16 variant;
1022 + u16 bottom;
1023 + u16 top;
1024 +} __WLAN_ATTRIB_PACK__ hfa384x_caplevel_t;
1025 +
1026 +/*-- Configuration Record: cnfPortType --*/
1027 +typedef struct hfa384x_cnfPortType
1028 +{
1029 + u16 cnfPortType;
1030 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfPortType_t;
1031 +
1032 +/*-- Configuration Record: cnfOwnMACAddress --*/
1033 +typedef struct hfa384x_cnfOwnMACAddress
1034 +{
1035 + u8 cnfOwnMACAddress[6];
1036 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfOwnMACAddress_t;
1037 +
1038 +/*-- Configuration Record: cnfDesiredSSID --*/
1039 +typedef struct hfa384x_cnfDesiredSSID
1040 +{
1041 + u8 cnfDesiredSSID[34];
1042 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfDesiredSSID_t;
1043 +
1044 +/*-- Configuration Record: cnfOwnChannel --*/
1045 +typedef struct hfa384x_cnfOwnChannel
1046 +{
1047 + u16 cnfOwnChannel;
1048 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfOwnChannel_t;
1049 +
1050 +/*-- Configuration Record: cnfOwnSSID --*/
1051 +typedef struct hfa384x_cnfOwnSSID
1052 +{
1053 + u8 cnfOwnSSID[34];
1054 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfOwnSSID_t;
1055 +
1056 +/*-- Configuration Record: cnfOwnATIMWindow --*/
1057 +typedef struct hfa384x_cnfOwnATIMWindow
1058 +{
1059 + u16 cnfOwnATIMWindow;
1060 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfOwnATIMWindow_t;
1061 +
1062 +/*-- Configuration Record: cnfSystemScale --*/
1063 +typedef struct hfa384x_cnfSystemScale
1064 +{
1065 + u16 cnfSystemScale;
1066 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfSystemScale_t;
1067 +
1068 +/*-- Configuration Record: cnfMaxDataLength --*/
1069 +typedef struct hfa384x_cnfMaxDataLength
1070 +{
1071 + u16 cnfMaxDataLength;
1072 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfMaxDataLength_t;
1073 +
1074 +/*-- Configuration Record: cnfWDSAddress --*/
1075 +typedef struct hfa384x_cnfWDSAddress
1076 +{
1077 + u8 cnfWDSAddress[6];
1078 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfWDSAddress_t;
1079 +
1080 +/*-- Configuration Record: cnfPMEnabled --*/
1081 +typedef struct hfa384x_cnfPMEnabled
1082 +{
1083 + u16 cnfPMEnabled;
1084 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfPMEnabled_t;
1085 +
1086 +/*-- Configuration Record: cnfPMEPS --*/
1087 +typedef struct hfa384x_cnfPMEPS
1088 +{
1089 + u16 cnfPMEPS;
1090 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfPMEPS_t;
1091 +
1092 +/*-- Configuration Record: cnfMulticastReceive --*/
1093 +typedef struct hfa384x_cnfMulticastReceive
1094 +{
1095 + u16 cnfMulticastReceive;
1096 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfMulticastReceive_t;
1097 +
1098 +/*-- Configuration Record: cnfAuthentication --*/
1099 +#define HFA384x_CNFAUTHENTICATION_OPENSYSTEM 0x0001
1100 +#define HFA384x_CNFAUTHENTICATION_SHAREDKEY 0x0002
1101 +#define HFA384x_CNFAUTHENTICATION_LEAP 0x0004
1102 +
1103 +/*-- Configuration Record: cnfMaxSleepDuration --*/
1104 +typedef struct hfa384x_cnfMaxSleepDuration
1105 +{
1106 + u16 cnfMaxSleepDuration;
1107 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfMaxSleepDuration_t;
1108 +
1109 +/*-- Configuration Record: cnfPMHoldoverDuration --*/
1110 +typedef struct hfa384x_cnfPMHoldoverDuration
1111 +{
1112 + u16 cnfPMHoldoverDuration;
1113 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfPMHoldoverDuration_t;
1114 +
1115 +/*-- Configuration Record: cnfOwnName --*/
1116 +typedef struct hfa384x_cnfOwnName
1117 +{
1118 + u8 cnfOwnName[34];
1119 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfOwnName_t;
1120 +
1121 +/*-- Configuration Record: cnfOwnDTIMPeriod --*/
1122 +typedef struct hfa384x_cnfOwnDTIMPeriod
1123 +{
1124 + u16 cnfOwnDTIMPeriod;
1125 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfOwnDTIMPeriod_t;
1126 +
1127 +/*-- Configuration Record: cnfWDSAddress --*/
1128 +typedef struct hfa384x_cnfWDSAddressN
1129 +{
1130 + u8 cnfWDSAddress[6];
1131 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfWDSAddressN_t;
1132 +
1133 +/*-- Configuration Record: cnfMulticastPMBuffering --*/
1134 +typedef struct hfa384x_cnfMulticastPMBuffering
1135 +{
1136 + u16 cnfMulticastPMBuffering;
1137 +} __WLAN_ATTRIB_PACK__ hfa384x_cnfMulticastPMBuffering_t;
1138 +
1139 +/*--------------------------------------------------------------------
1140 +Configuration Record Structures:
1141 + Network Parameters, Dynamic Configuration Entities
1142 +--------------------------------------------------------------------*/
1143 +
1144 +/*-- Configuration Record: GroupAddresses --*/
1145 +typedef struct hfa384x_GroupAddresses
1146 +{
1147 + u8 MACAddress[16][6];
1148 +} __WLAN_ATTRIB_PACK__ hfa384x_GroupAddresses_t;
1149 +
1150 +/*-- Configuration Record: CreateIBSS --*/
1151 +typedef struct hfa384x_CreateIBSS
1152 +{
1153 + u16 CreateIBSS;
1154 +} __WLAN_ATTRIB_PACK__ hfa384x_CreateIBSS_t;
1155 +
1156 +#define HFA384x_CREATEIBSS_JOINCREATEIBSS 0
1157 +#define HFA384x_CREATEIBSS_JOINESS_JOINCREATEIBSS 1
1158 +#define HFA384x_CREATEIBSS_JOINIBSS 2
1159 +#define HFA384x_CREATEIBSS_JOINESS_JOINIBSS 3
1160 +
1161 +/*-- Configuration Record: FragmentationThreshold --*/
1162 +typedef struct hfa384x_FragmentationThreshold
1163 +{
1164 + u16 FragmentationThreshold;
1165 +} __WLAN_ATTRIB_PACK__ hfa384x_FragmentationThreshold_t;
1166 +
1167 +/*-- Configuration Record: RTSThreshold --*/
1168 +typedef struct hfa384x_RTSThreshold
1169 +{
1170 + u16 RTSThreshold;
1171 +} __WLAN_ATTRIB_PACK__ hfa384x_RTSThreshold_t;
1172 +
1173 +/*-- Configuration Record: TxRateControl --*/
1174 +typedef struct hfa384x_TxRateControl
1175 +{
1176 + u16 TxRateControl;
1177 +} __WLAN_ATTRIB_PACK__ hfa384x_TxRateControl_t;
1178 +
1179 +/*-- Configuration Record: PromiscuousMode --*/
1180 +typedef struct hfa384x_PromiscuousMode
1181 +{
1182 + u16 PromiscuousMode;
1183 +} __WLAN_ATTRIB_PACK__ hfa384x_PromiscuousMode_t;
1184 +
1185 +/*-- Configuration Record: ScanRequest (data portion only) --*/
1186 +typedef struct hfa384x_ScanRequest_data
1187 +{
1188 + u16 channelList;
1189 + u16 txRate;
1190 +} __WLAN_ATTRIB_PACK__ hfa384x_ScanRequest_data_t;
1191 +
1192 +/*-- Configuration Record: HostScanRequest (data portion only) --*/
1193 +typedef struct hfa384x_HostScanRequest_data
1194 +{
1195 + u16 channelList;
1196 + u16 txRate;
1197 + hfa384x_bytestr32_t ssid;
1198 +} __WLAN_ATTRIB_PACK__ hfa384x_HostScanRequest_data_t;
1199 +
1200 +/*-- Configuration Record: JoinRequest (data portion only) --*/
1201 +typedef struct hfa384x_JoinRequest_data
1202 +{
1203 + u8 bssid[WLAN_BSSID_LEN];
1204 + u16 channel;
1205 +} __WLAN_ATTRIB_PACK__ hfa384x_JoinRequest_data_t;
1206 +
1207 +/*-- Configuration Record: authenticateStation (data portion only) --*/
1208 +typedef struct hfa384x_authenticateStation_data
1209 +{
1210 + u8 address[WLAN_ADDR_LEN];
1211 + u16 status;
1212 + u16 algorithm;
1213 +} __WLAN_ATTRIB_PACK__ hfa384x_authenticateStation_data_t;
1214 +
1215 +/*-- Configuration Record: associateStation (data portion only) --*/
1216 +typedef struct hfa384x_associateStation_data
1217 +{
1218 + u8 address[WLAN_ADDR_LEN];
1219 + u16 status;
1220 + u16 type;
1221 +} __WLAN_ATTRIB_PACK__ hfa384x_associateStation_data_t;
1222 +
1223 +/*-- Configuration Record: ChannelInfoRequest (data portion only) --*/
1224 +typedef struct hfa384x_ChannelInfoRequest_data
1225 +{
1226 + u16 channelList;
1227 + u16 channelDwellTime;
1228 +} __WLAN_ATTRIB_PACK__ hfa384x_ChannelInfoRequest_data_t;
1229 +
1230 +/*-- Configuration Record: WEPKeyMapping (data portion only) --*/
1231 +typedef struct hfa384x_WEPKeyMapping
1232 +{
1233 + u8 address[WLAN_ADDR_LEN];
1234 + u16 key_index;
1235 + u8 key[16];
1236 + u8 mic_transmit_key[4];
1237 + u8 mic_receive_key[4];
1238 +} __WLAN_ATTRIB_PACK__ hfa384x_WEPKeyMapping_t;
1239 +
1240 +/*-- Configuration Record: WPAData (data portion only) --*/
1241 +typedef struct hfa384x_WPAData
1242 +{
1243 + u16 datalen;
1244 + u8 data[0]; // max 80
1245 +} __WLAN_ATTRIB_PACK__ hfa384x_WPAData_t;
1246 +
1247 +/*--------------------------------------------------------------------
1248 +Configuration Record Structures: Behavior Parameters
1249 +--------------------------------------------------------------------*/
1250 +
1251 +/*-- Configuration Record: TickTime --*/
1252 +typedef struct hfa384x_TickTime
1253 +{
1254 + u16 TickTime;
1255 +} __WLAN_ATTRIB_PACK__ hfa384x_TickTime_t;
1256 +
1257 +/*--------------------------------------------------------------------
1258 +Information Record Structures: NIC Information
1259 +--------------------------------------------------------------------*/
1260 +
1261 +/*-- Information Record: MaxLoadTime --*/
1262 +typedef struct hfa384x_MaxLoadTime
1263 +{
1264 + u16 MaxLoadTime;
1265 +} __WLAN_ATTRIB_PACK__ hfa384x_MaxLoadTime_t;
1266 +
1267 +/*-- Information Record: DownLoadBuffer --*/
1268 +/* NOTE: The page and offset are in AUX format */
1269 +typedef struct hfa384x_downloadbuffer
1270 +{
1271 + u16 page;
1272 + u16 offset;
1273 + u16 len;
1274 +} __WLAN_ATTRIB_PACK__ hfa384x_downloadbuffer_t;
1275 +
1276 +/*-- Information Record: PRIIdentity --*/
1277 +typedef struct hfa384x_PRIIdentity
1278 +{
1279 + u16 PRICompID;
1280 + u16 PRIVariant;
1281 + u16 PRIMajorVersion;
1282 + u16 PRIMinorVersion;
1283 +} __WLAN_ATTRIB_PACK__ hfa384x_PRIIdentity_t;
1284 +
1285 +/*-- Information Record: PRISupRange --*/
1286 +typedef struct hfa384x_PRISupRange
1287 +{
1288 + u16 PRIRole;
1289 + u16 PRIID;
1290 + u16 PRIVariant;
1291 + u16 PRIBottom;
1292 + u16 PRITop;
1293 +} __WLAN_ATTRIB_PACK__ hfa384x_PRISupRange_t;
1294 +
1295 +/*-- Information Record: CFIActRanges --*/
1296 +typedef struct hfa384x_CFIActRanges
1297 +{
1298 + u16 CFIRole;
1299 + u16 CFIID;
1300 + u16 CFIVariant;
1301 + u16 CFIBottom;
1302 + u16 CFITop;
1303 +} __WLAN_ATTRIB_PACK__ hfa384x_CFIActRanges_t;
1304 +
1305 +/*-- Information Record: NICSerialNumber --*/
1306 +typedef struct hfa384x_NICSerialNumber
1307 +{
1308 + u8 NICSerialNumber[12];
1309 +} __WLAN_ATTRIB_PACK__ hfa384x_NICSerialNumber_t;
1310 +
1311 +/*-- Information Record: NICIdentity --*/
1312 +typedef struct hfa384x_NICIdentity
1313 +{
1314 + u16 NICCompID;
1315 + u16 NICVariant;
1316 + u16 NICMajorVersion;
1317 + u16 NICMinorVersion;
1318 +} __WLAN_ATTRIB_PACK__ hfa384x_NICIdentity_t;
1319 +
1320 +/*-- Information Record: MFISupRange --*/
1321 +typedef struct hfa384x_MFISupRange
1322 +{
1323 + u16 MFIRole;
1324 + u16 MFIID;
1325 + u16 MFIVariant;
1326 + u16 MFIBottom;
1327 + u16 MFITop;
1328 +} __WLAN_ATTRIB_PACK__ hfa384x_MFISupRange_t;
1329 +
1330 +/*-- Information Record: CFISupRange --*/
1331 +typedef struct hfa384x_CFISupRange
1332 +{
1333 + u16 CFIRole;
1334 + u16 CFIID;
1335 + u16 CFIVariant;
1336 + u16 CFIBottom;
1337 + u16 CFITop;
1338 +} __WLAN_ATTRIB_PACK__ hfa384x_CFISupRange_t;
1339 +
1340 +/*-- Information Record: BUILDSEQ:BuildSeq --*/
1341 +typedef struct hfa384x_BuildSeq {
1342 + u16 primary;
1343 + u16 secondary;
1344 +} __WLAN_ATTRIB_PACK__ hfa384x_BuildSeq_t;
1345 +
1346 +/*-- Information Record: FWID --*/
1347 +#define HFA384x_FWID_LEN 14
1348 +typedef struct hfa384x_FWID {
1349 + u8 primary[HFA384x_FWID_LEN];
1350 + u8 secondary[HFA384x_FWID_LEN];
1351 +} __WLAN_ATTRIB_PACK__ hfa384x_FWID_t;
1352 +
1353 +/*-- Information Record: ChannelList --*/
1354 +typedef struct hfa384x_ChannelList
1355 +{
1356 + u16 ChannelList;
1357 +} __WLAN_ATTRIB_PACK__ hfa384x_ChannelList_t;
1358 +
1359 +/*-- Information Record: RegulatoryDomains --*/
1360 +typedef struct hfa384x_RegulatoryDomains
1361 +{
1362 + u8 RegulatoryDomains[12];
1363 +} __WLAN_ATTRIB_PACK__ hfa384x_RegulatoryDomains_t;
1364 +
1365 +/*-- Information Record: TempType --*/
1366 +typedef struct hfa384x_TempType
1367 +{
1368 + u16 TempType;
1369 +} __WLAN_ATTRIB_PACK__ hfa384x_TempType_t;
1370 +
1371 +/*-- Information Record: CIS --*/
1372 +typedef struct hfa384x_CIS
1373 +{
1374 + u8 CIS[480];
1375 +} __WLAN_ATTRIB_PACK__ hfa384x_CIS_t;
1376 +
1377 +/*-- Information Record: STAIdentity --*/
1378 +typedef struct hfa384x_STAIdentity
1379 +{
1380 + u16 STACompID;
1381 + u16 STAVariant;
1382 + u16 STAMajorVersion;
1383 + u16 STAMinorVersion;
1384 +} __WLAN_ATTRIB_PACK__ hfa384x_STAIdentity_t;
1385 +
1386 +/*-- Information Record: STASupRange --*/
1387 +typedef struct hfa384x_STASupRange
1388 +{
1389 + u16 STARole;
1390 + u16 STAID;
1391 + u16 STAVariant;
1392 + u16 STABottom;
1393 + u16 STATop;
1394 +} __WLAN_ATTRIB_PACK__ hfa384x_STASupRange_t;
1395 +
1396 +/*-- Information Record: MFIActRanges --*/
1397 +typedef struct hfa384x_MFIActRanges
1398 +{
1399 + u16 MFIRole;
1400 + u16 MFIID;
1401 + u16 MFIVariant;
1402 + u16 MFIBottom;
1403 + u16 MFITop;
1404 +} __WLAN_ATTRIB_PACK__ hfa384x_MFIActRanges_t;
1405 +
1406 +/*--------------------------------------------------------------------
1407 +Information Record Structures: NIC Information
1408 +--------------------------------------------------------------------*/
1409 +
1410 +/*-- Information Record: PortStatus --*/
1411 +typedef struct hfa384x_PortStatus
1412 +{
1413 + u16 PortStatus;
1414 +} __WLAN_ATTRIB_PACK__ hfa384x_PortStatus_t;
1415 +
1416 +#define HFA384x_PSTATUS_DISABLED ((u16)1)
1417 +#define HFA384x_PSTATUS_SEARCHING ((u16)2)
1418 +#define HFA384x_PSTATUS_CONN_IBSS ((u16)3)
1419 +#define HFA384x_PSTATUS_CONN_ESS ((u16)4)
1420 +#define HFA384x_PSTATUS_OUTOFRANGE ((u16)5)
1421 +#define HFA384x_PSTATUS_CONN_WDS ((u16)6)
1422 +
1423 +/*-- Information Record: CurrentSSID --*/
1424 +typedef struct hfa384x_CurrentSSID
1425 +{
1426 + u8 CurrentSSID[34];
1427 +} __WLAN_ATTRIB_PACK__ hfa384x_CurrentSSID_t;
1428 +
1429 +/*-- Information Record: CurrentBSSID --*/
1430 +typedef struct hfa384x_CurrentBSSID
1431 +{
1432 + u8 CurrentBSSID[6];
1433 +} __WLAN_ATTRIB_PACK__ hfa384x_CurrentBSSID_t;
1434 +
1435 +/*-- Information Record: commsquality --*/
1436 +typedef struct hfa384x_commsquality
1437 +{
1438 + u16 CQ_currBSS;
1439 + u16 ASL_currBSS;
1440 + u16 ANL_currFC;
1441 +} __WLAN_ATTRIB_PACK__ hfa384x_commsquality_t;
1442 +
1443 +/*-- Information Record: dmbcommsquality --*/
1444 +typedef struct hfa384x_dbmcommsquality
1445 +{
1446 + u16 CQdbm_currBSS;
1447 + u16 ASLdbm_currBSS;
1448 + u16 ANLdbm_currFC;
1449 +} __WLAN_ATTRIB_PACK__ hfa384x_dbmcommsquality_t;
1450 +
1451 +/*-- Information Record: CurrentTxRate --*/
1452 +typedef struct hfa384x_CurrentTxRate
1453 +{
1454 + u16 CurrentTxRate;
1455 +} __WLAN_ATTRIB_PACK__ hfa384x_CurrentTxRate_t;
1456 +
1457 +/*-- Information Record: CurrentBeaconInterval --*/
1458 +typedef struct hfa384x_CurrentBeaconInterval
1459 +{
1460 + u16 CurrentBeaconInterval;
1461 +} __WLAN_ATTRIB_PACK__ hfa384x_CurrentBeaconInterval_t;
1462 +
1463 +/*-- Information Record: CurrentScaleThresholds --*/
1464 +typedef struct hfa384x_CurrentScaleThresholds
1465 +{
1466 + u16 EnergyDetectThreshold;
1467 + u16 CarrierDetectThreshold;
1468 + u16 DeferDetectThreshold;
1469 + u16 CellSearchThreshold; /* Stations only */
1470 + u16 DeadSpotThreshold; /* Stations only */
1471 +} __WLAN_ATTRIB_PACK__ hfa384x_CurrentScaleThresholds_t;
1472 +
1473 +/*-- Information Record: ProtocolRspTime --*/
1474 +typedef struct hfa384x_ProtocolRspTime
1475 +{
1476 + u16 ProtocolRspTime;
1477 +} __WLAN_ATTRIB_PACK__ hfa384x_ProtocolRspTime_t;
1478 +
1479 +/*-- Information Record: ShortRetryLimit --*/
1480 +typedef struct hfa384x_ShortRetryLimit
1481 +{
1482 + u16 ShortRetryLimit;
1483 +} __WLAN_ATTRIB_PACK__ hfa384x_ShortRetryLimit_t;
1484 +
1485 +/*-- Information Record: LongRetryLimit --*/
1486 +typedef struct hfa384x_LongRetryLimit
1487 +{
1488 + u16 LongRetryLimit;
1489 +} __WLAN_ATTRIB_PACK__ hfa384x_LongRetryLimit_t;
1490 +
1491 +/*-- Information Record: MaxTransmitLifetime --*/
1492 +typedef struct hfa384x_MaxTransmitLifetime
1493 +{
1494 + u16 MaxTransmitLifetime;
1495 +} __WLAN_ATTRIB_PACK__ hfa384x_MaxTransmitLifetime_t;
1496 +
1497 +/*-- Information Record: MaxReceiveLifetime --*/
1498 +typedef struct hfa384x_MaxReceiveLifetime
1499 +{
1500 + u16 MaxReceiveLifetime;
1501 +} __WLAN_ATTRIB_PACK__ hfa384x_MaxReceiveLifetime_t;
1502 +
1503 +/*-- Information Record: CFPollable --*/
1504 +typedef struct hfa384x_CFPollable
1505 +{
1506 + u16 CFPollable;
1507 +} __WLAN_ATTRIB_PACK__ hfa384x_CFPollable_t;
1508 +
1509 +/*-- Information Record: AuthenticationAlgorithms --*/
1510 +typedef struct hfa384x_AuthenticationAlgorithms
1511 +{
1512 + u16 AuthenticationType;
1513 + u16 TypeEnabled;
1514 +} __WLAN_ATTRIB_PACK__ hfa384x_AuthenticationAlgorithms_t;
1515 +
1516 +/*-- Information Record: AuthenticationAlgorithms
1517 +(data only --*/
1518 +typedef struct hfa384x_AuthenticationAlgorithms_data
1519 +{
1520 + u16 AuthenticationType;
1521 + u16 TypeEnabled;
1522 +} __WLAN_ATTRIB_PACK__ hfa384x_AuthenticationAlgorithms_data_t;
1523 +
1524 +/*-- Information Record: PrivacyOptionImplemented --*/
1525 +typedef struct hfa384x_PrivacyOptionImplemented
1526 +{
1527 + u16 PrivacyOptionImplemented;
1528 +} __WLAN_ATTRIB_PACK__ hfa384x_PrivacyOptionImplemented_t;
1529 +
1530 +/*-- Information Record: OwnMACAddress --*/
1531 +typedef struct hfa384x_OwnMACAddress
1532 +{
1533 + u8 OwnMACAddress[6];
1534 +} __WLAN_ATTRIB_PACK__ hfa384x_OwnMACAddress_t;
1535 +
1536 +/*-- Information Record: PCFInfo --*/
1537 +typedef struct hfa384x_PCFInfo
1538 +{
1539 + u16 MediumOccupancyLimit;
1540 + u16 CFPPeriod;
1541 + u16 CFPMaxDuration;
1542 + u16 CFPFlags;
1543 +} __WLAN_ATTRIB_PACK__ hfa384x_PCFInfo_t;
1544 +
1545 +/*-- Information Record: PCFInfo (data portion only) --*/
1546 +typedef struct hfa384x_PCFInfo_data
1547 +{
1548 + u16 MediumOccupancyLimit;
1549 + u16 CFPPeriod;
1550 + u16 CFPMaxDuration;
1551 + u16 CFPFlags;
1552 +} __WLAN_ATTRIB_PACK__ hfa384x_PCFInfo_data_t;
1553 +
1554 +/*--------------------------------------------------------------------
1555 +Information Record Structures: Modem Information Records
1556 +--------------------------------------------------------------------*/
1557 +
1558 +/*-- Information Record: PHYType --*/
1559 +typedef struct hfa384x_PHYType
1560 +{
1561 + u16 PHYType;
1562 +} __WLAN_ATTRIB_PACK__ hfa384x_PHYType_t;
1563 +
1564 +/*-- Information Record: CurrentChannel --*/
1565 +typedef struct hfa384x_CurrentChannel
1566 +{
1567 + u16 CurrentChannel;
1568 +} __WLAN_ATTRIB_PACK__ hfa384x_CurrentChannel_t;
1569 +
1570 +/*-- Information Record: CurrentPowerState --*/
1571 +typedef struct hfa384x_CurrentPowerState
1572 +{
1573 + u16 CurrentPowerState;
1574 +} __WLAN_ATTRIB_PACK__ hfa384x_CurrentPowerState_t;
1575 +
1576 +/*-- Information Record: CCAMode --*/
1577 +typedef struct hfa384x_CCAMode
1578 +{
1579 + u16 CCAMode;
1580 +} __WLAN_ATTRIB_PACK__ hfa384x_CCAMode_t;
1581 +
1582 +/*-- Information Record: SupportedDataRates --*/
1583 +typedef struct hfa384x_SupportedDataRates
1584 +{
1585 + u8 SupportedDataRates[10];
1586 +} __WLAN_ATTRIB_PACK__ hfa384x_SupportedDataRates_t;
1587 +
1588 +/*-- Information Record: LFOStatus --*/
1589 +typedef struct hfa384x_LFOStatus
1590 +{
1591 + u16 TestResults;
1592 + u16 LFOResult;
1593 + u16 VRHFOResult;
1594 +} __WLAN_ATTRIB_PACK__ hfa384x_LFOStatus_t;
1595 +
1596 +#define HFA384x_TESTRESULT_ALLPASSED BIT0
1597 +#define HFA384x_TESTRESULT_LFO_FAIL BIT1
1598 +#define HFA384x_TESTRESULT_VR_HF0_FAIL BIT2
1599 +#define HFA384x_HOST_FIRM_COORDINATE BIT7
1600 +#define HFA384x_TESTRESULT_COORDINATE BIT15
1601 +
1602 +/*-- Information Record: LEDControl --*/
1603 +typedef struct hfa384x_LEDControl
1604 +{
1605 + u16 searching_on;
1606 + u16 searching_off;
1607 + u16 assoc_on;
1608 + u16 assoc_off;
1609 + u16 activity;
1610 +} __WLAN_ATTRIB_PACK__ hfa384x_LEDControl_t;
1611 +
1612 +/*--------------------------------------------------------------------
1613 + FRAME DESCRIPTORS AND FRAME STRUCTURES
1614 +
1615 +FRAME DESCRIPTORS: Offsets
1616 +
1617 +----------------------------------------------------------------------
1618 +Control Info (offset 44-51)
1619 +--------------------------------------------------------------------*/
1620 +#define HFA384x_FD_STATUS_OFF ((u16)0x44)
1621 +#define HFA384x_FD_TIME_OFF ((u16)0x46)
1622 +#define HFA384x_FD_SWSUPPORT_OFF ((u16)0x4A)
1623 +#define HFA384x_FD_SILENCE_OFF ((u16)0x4A)
1624 +#define HFA384x_FD_SIGNAL_OFF ((u16)0x4B)
1625 +#define HFA384x_FD_RATE_OFF ((u16)0x4C)
1626 +#define HFA384x_FD_RXFLOW_OFF ((u16)0x4D)
1627 +#define HFA384x_FD_RESERVED_OFF ((u16)0x4E)
1628 +#define HFA384x_FD_TXCONTROL_OFF ((u16)0x50)
1629 +/*--------------------------------------------------------------------
1630 +802.11 Header (offset 52-6B)
1631 +--------------------------------------------------------------------*/
1632 +#define HFA384x_FD_FRAMECONTROL_OFF ((u16)0x52)
1633 +#define HFA384x_FD_DURATIONID_OFF ((u16)0x54)
1634 +#define HFA384x_FD_ADDRESS1_OFF ((u16)0x56)
1635 +#define HFA384x_FD_ADDRESS2_OFF ((u16)0x5C)
1636 +#define HFA384x_FD_ADDRESS3_OFF ((u16)0x62)
1637 +#define HFA384x_FD_SEQCONTROL_OFF ((u16)0x68)
1638 +#define HFA384x_FD_ADDRESS4_OFF ((u16)0x6A)
1639 +#define HFA384x_FD_DATALEN_OFF ((u16)0x70)
1640 +/*--------------------------------------------------------------------
1641 +802.3 Header (offset 72-7F)
1642 +--------------------------------------------------------------------*/
1643 +#define HFA384x_FD_DESTADDRESS_OFF ((u16)0x72)
1644 +#define HFA384x_FD_SRCADDRESS_OFF ((u16)0x78)
1645 +#define HFA384x_FD_DATALENGTH_OFF ((u16)0x7E)
1646 +
1647 +/*--------------------------------------------------------------------
1648 +FRAME STRUCTURES: Communication Frames
1649 +----------------------------------------------------------------------
1650 +Communication Frames: Transmit Frames
1651 +--------------------------------------------------------------------*/
1652 +/*-- Communication Frame: Transmit Frame Structure --*/
1653 +typedef struct hfa384x_tx_frame
1654 +{
1655 + u16 status;
1656 + u16 reserved1;
1657 + u16 reserved2;
1658 + u32 sw_support;
1659 + u8 tx_retrycount;
1660 + u8 tx_rate;
1661 + u16 tx_control;
1662 +
1663 + /*-- 802.11 Header Information --*/
1664 +
1665 + u16 frame_control;
1666 + u16 duration_id;
1667 + u8 address1[6];
1668 + u8 address2[6];
1669 + u8 address3[6];
1670 + u16 sequence_control;
1671 + u8 address4[6];
1672 + u16 data_len; /* little endian format */
1673 +
1674 + /*-- 802.3 Header Information --*/
1675 +
1676 + u8 dest_addr[6];
1677 + u8 src_addr[6];
1678 + u16 data_length; /* big endian format */
1679 +} __WLAN_ATTRIB_PACK__ hfa384x_tx_frame_t;
1680 +/*--------------------------------------------------------------------
1681 +Communication Frames: Field Masks for Transmit Frames
1682 +--------------------------------------------------------------------*/
1683 +/*-- Status Field --*/
1684 +#define HFA384x_TXSTATUS_ACKERR ((u16)BIT5)
1685 +#define HFA384x_TXSTATUS_FORMERR ((u16)BIT3)
1686 +#define HFA384x_TXSTATUS_DISCON ((u16)BIT2)
1687 +#define HFA384x_TXSTATUS_AGEDERR ((u16)BIT1)
1688 +#define HFA384x_TXSTATUS_RETRYERR ((u16)BIT0)
1689 +/*-- Transmit Control Field --*/
1690 +#define HFA384x_TX_CFPOLL ((u16)BIT12)
1691 +#define HFA384x_TX_PRST ((u16)BIT11)
1692 +#define HFA384x_TX_MACPORT ((u16)(BIT10 | BIT9 | BIT8))
1693 +#define HFA384x_TX_NOENCRYPT ((u16)BIT7)
1694 +#define HFA384x_TX_RETRYSTRAT ((u16)(BIT6 | BIT5))
1695 +#define HFA384x_TX_STRUCTYPE ((u16)(BIT4 | BIT3))
1696 +#define HFA384x_TX_TXEX ((u16)BIT2)
1697 +#define HFA384x_TX_TXOK ((u16)BIT1)
1698 +/*--------------------------------------------------------------------
1699 +Communication Frames: Test/Get/Set Field Values for Transmit Frames
1700 +--------------------------------------------------------------------*/
1701 +/*-- Status Field --*/
1702 +#define HFA384x_TXSTATUS_ISERROR(v) \
1703 + (((u16)(v))&\
1704 + (HFA384x_TXSTATUS_ACKERR|HFA384x_TXSTATUS_FORMERR|\
1705 + HFA384x_TXSTATUS_DISCON|HFA384x_TXSTATUS_AGEDERR|\
1706 + HFA384x_TXSTATUS_RETRYERR))
1707 +
1708 +#define HFA384x_TXSTATUS_ISACKERR(v) ((u16)(((u16)(v)) & HFA384x_TXSTATUS_ACKERR))
1709 +#define HFA384x_TXSTATUS_ISFORMERR(v) ((u16)(((u16)(v)) & HFA384x_TXSTATUS_FORMERR))
1710 +#define HFA384x_TXSTATUS_ISDISCON(v) ((u16)(((u16)(v)) & HFA384x_TXSTATUS_DISCON))
1711 +#define HFA384x_TXSTATUS_ISAGEDERR(v) ((u16)(((u16)(v)) & HFA384x_TXSTATUS_AGEDERR))
1712 +#define HFA384x_TXSTATUS_ISRETRYERR(v) ((u16)(((u16)(v)) & HFA384x_TXSTATUS_RETRYERR))
1713 +
1714 +#define HFA384x_TX_GET(v,m,s) ((((u16)(v))&((u16)(m)))>>((u16)(s)))
1715 +#define HFA384x_TX_SET(v,m,s) ((((u16)(v))<<((u16)(s)))&((u16)(m)))
1716 +
1717 +#define HFA384x_TX_CFPOLL_GET(v) HFA384x_TX_GET(v, HFA384x_TX_CFPOLL,12)
1718 +#define HFA384x_TX_CFPOLL_SET(v) HFA384x_TX_SET(v, HFA384x_TX_CFPOLL,12)
1719 +#define HFA384x_TX_PRST_GET(v) HFA384x_TX_GET(v, HFA384x_TX_PRST,11)
1720 +#define HFA384x_TX_PRST_SET(v) HFA384x_TX_SET(v, HFA384x_TX_PRST,11)
1721 +#define HFA384x_TX_MACPORT_GET(v) HFA384x_TX_GET(v, HFA384x_TX_MACPORT, 8)
1722 +#define HFA384x_TX_MACPORT_SET(v) HFA384x_TX_SET(v, HFA384x_TX_MACPORT, 8)
1723 +#define HFA384x_TX_NOENCRYPT_GET(v) HFA384x_TX_GET(v, HFA384x_TX_NOENCRYPT, 7)
1724 +#define HFA384x_TX_NOENCRYPT_SET(v) HFA384x_TX_SET(v, HFA384x_TX_NOENCRYPT, 7)
1725 +#define HFA384x_TX_RETRYSTRAT_GET(v) HFA384x_TX_GET(v, HFA384x_TX_RETRYSTRAT, 5)
1726 +#define HFA384x_TX_RETRYSTRAT_SET(v) HFA384x_TX_SET(v, HFA384x_TX_RETRYSTRAT, 5)
1727 +#define HFA384x_TX_STRUCTYPE_GET(v) HFA384x_TX_GET(v, HFA384x_TX_STRUCTYPE, 3)
1728 +#define HFA384x_TX_STRUCTYPE_SET(v) HFA384x_TX_SET(v, HFA384x_TX_STRUCTYPE, 3)
1729 +#define HFA384x_TX_TXEX_GET(v) HFA384x_TX_GET(v, HFA384x_TX_TXEX, 2)
1730 +#define HFA384x_TX_TXEX_SET(v) HFA384x_TX_SET(v, HFA384x_TX_TXEX, 2)
1731 +#define HFA384x_TX_TXOK_GET(v) HFA384x_TX_GET(v, HFA384x_TX_TXOK, 1)
1732 +#define HFA384x_TX_TXOK_SET(v) HFA384x_TX_SET(v, HFA384x_TX_TXOK, 1)
1733 +/*--------------------------------------------------------------------
1734 +Communication Frames: Receive Frames
1735 +--------------------------------------------------------------------*/
1736 +/*-- Communication Frame: Receive Frame Structure --*/
1737 +typedef struct hfa384x_rx_frame
1738 +{
1739 + /*-- MAC rx descriptor (hfa384x byte order) --*/
1740 + u16 status;
1741 + u32 time;
1742 + u8 silence;
1743 + u8 signal;
1744 + u8 rate;
1745 + u8 rx_flow;
1746 + u16 reserved1;
1747 + u16 reserved2;
1748 +
1749 + /*-- 802.11 Header Information (802.11 byte order) --*/
1750 + u16 frame_control;
1751 + u16 duration_id;
1752 + u8 address1[6];
1753 + u8 address2[6];
1754 + u8 address3[6];
1755 + u16 sequence_control;
1756 + u8 address4[6];
1757 + u16 data_len; /* hfa384x (little endian) format */
1758 +
1759 + /*-- 802.3 Header Information --*/
1760 + u8 dest_addr[6];
1761 + u8 src_addr[6];
1762 + u16 data_length; /* IEEE? (big endian) format */
1763 +} __WLAN_ATTRIB_PACK__ hfa384x_rx_frame_t;
1764 +/*--------------------------------------------------------------------
1765 +Communication Frames: Field Masks for Receive Frames
1766 +--------------------------------------------------------------------*/
1767 +/*-- Offsets --------*/
1768 +#define HFA384x_RX_DATA_LEN_OFF ((u16)44)
1769 +#define HFA384x_RX_80211HDR_OFF ((u16)14)
1770 +#define HFA384x_RX_DATA_OFF ((u16)60)
1771 +
1772 +/*-- Status Fields --*/
1773 +#define HFA384x_RXSTATUS_MSGTYPE ((u16)(BIT15 | BIT14 | BIT13))
1774 +#define HFA384x_RXSTATUS_MACPORT ((u16)(BIT10 | BIT9 | BIT8))
1775 +#define HFA384x_RXSTATUS_UNDECR ((u16)BIT1)
1776 +#define HFA384x_RXSTATUS_FCSERR ((u16)BIT0)
1777 +/*--------------------------------------------------------------------
1778 +Communication Frames: Test/Get/Set Field Values for Receive Frames
1779 +--------------------------------------------------------------------*/
1780 +#define HFA384x_RXSTATUS_MSGTYPE_GET(value) ((u16)((((u16)(value)) & HFA384x_RXSTATUS_MSGTYPE) >> 13))
1781 +#define HFA384x_RXSTATUS_MSGTYPE_SET(value) ((u16)(((u16)(value)) << 13))
1782 +#define HFA384x_RXSTATUS_MACPORT_GET(value) ((u16)((((u16)(value)) & HFA384x_RXSTATUS_MACPORT) >> 8))
1783 +#define HFA384x_RXSTATUS_MACPORT_SET(value) ((u16)(((u16)(value)) << 8))
1784 +#define HFA384x_RXSTATUS_ISUNDECR(value) ((u16)(((u16)(value)) & HFA384x_RXSTATUS_UNDECR))
1785 +#define HFA384x_RXSTATUS_ISFCSERR(value) ((u16)(((u16)(value)) & HFA384x_RXSTATUS_FCSERR))
1786 +/*--------------------------------------------------------------------
1787 + FRAME STRUCTURES: Information Types and Information Frame Structures
1788 +----------------------------------------------------------------------
1789 +Information Types
1790 +--------------------------------------------------------------------*/
1791 +#define HFA384x_IT_HANDOVERADDR ((u16)0xF000UL)
1792 +#define HFA384x_IT_HANDOVERDEAUTHADDRESS ((u16)0xF001UL)//AP 1.3.7
1793 +#define HFA384x_IT_COMMTALLIES ((u16)0xF100UL)
1794 +#define HFA384x_IT_SCANRESULTS ((u16)0xF101UL)
1795 +#define HFA384x_IT_CHINFORESULTS ((u16)0xF102UL)
1796 +#define HFA384x_IT_HOSTSCANRESULTS ((u16)0xF103UL)
1797 +#define HFA384x_IT_LINKSTATUS ((u16)0xF200UL)
1798 +#define HFA384x_IT_ASSOCSTATUS ((u16)0xF201UL)
1799 +#define HFA384x_IT_AUTHREQ ((u16)0xF202UL)
1800 +#define HFA384x_IT_PSUSERCNT ((u16)0xF203UL)
1801 +#define HFA384x_IT_KEYIDCHANGED ((u16)0xF204UL)
1802 +#define HFA384x_IT_ASSOCREQ ((u16)0xF205UL)
1803 +#define HFA384x_IT_MICFAILURE ((u16)0xF206UL)
1804 +
1805 +/*--------------------------------------------------------------------
1806 +Information Frames Structures
1807 +----------------------------------------------------------------------
1808 +Information Frames: Notification Frame Structures
1809 +--------------------------------------------------------------------*/
1810 +/*-- Notification Frame,MAC Mgmt: Handover Address --*/
1811 +typedef struct hfa384x_HandoverAddr
1812 +{
1813 + u16 framelen;
1814 + u16 infotype;
1815 + u8 handover_addr[WLAN_BSSID_LEN];
1816 +} __WLAN_ATTRIB_PACK__ hfa384x_HandoverAddr_t;
1817 +
1818 +/*-- Inquiry Frame, Diagnose: Communication Tallies --*/
1819 +typedef struct hfa384x_CommTallies16
1820 +{
1821 + u16 txunicastframes;
1822 + u16 txmulticastframes;
1823 + u16 txfragments;
1824 + u16 txunicastoctets;
1825 + u16 txmulticastoctets;
1826 + u16 txdeferredtrans;
1827 + u16 txsingleretryframes;
1828 + u16 txmultipleretryframes;
1829 + u16 txretrylimitexceeded;
1830 + u16 txdiscards;
1831 + u16 rxunicastframes;
1832 + u16 rxmulticastframes;
1833 + u16 rxfragments;
1834 + u16 rxunicastoctets;
1835 + u16 rxmulticastoctets;
1836 + u16 rxfcserrors;
1837 + u16 rxdiscardsnobuffer;
1838 + u16 txdiscardswrongsa;
1839 + u16 rxdiscardswepundecr;
1840 + u16 rxmsginmsgfrag;
1841 + u16 rxmsginbadmsgfrag;
1842 +} __WLAN_ATTRIB_PACK__ hfa384x_CommTallies16_t;
1843 +
1844 +typedef struct hfa384x_CommTallies32
1845 +{
1846 + u32 txunicastframes;
1847 + u32 txmulticastframes;
1848 + u32 txfragments;
1849 + u32 txunicastoctets;
1850 + u32 txmulticastoctets;
1851 + u32 txdeferredtrans;
1852 + u32 txsingleretryframes;
1853 + u32 txmultipleretryframes;
1854 + u32 txretrylimitexceeded;
1855 + u32 txdiscards;
1856 + u32 rxunicastframes;
1857 + u32 rxmulticastframes;
1858 + u32 rxfragments;
1859 + u32 rxunicastoctets;
1860 + u32 rxmulticastoctets;
1861 + u32 rxfcserrors;
1862 + u32 rxdiscardsnobuffer;
1863 + u32 txdiscardswrongsa;
1864 + u32 rxdiscardswepundecr;
1865 + u32 rxmsginmsgfrag;
1866 + u32 rxmsginbadmsgfrag;
1867 +} __WLAN_ATTRIB_PACK__ hfa384x_CommTallies32_t;
1868 +
1869 +/*-- Inquiry Frame, Diagnose: Scan Results & Subfields--*/
1870 +typedef struct hfa384x_ScanResultSub
1871 +{
1872 + u16 chid;
1873 + u16 anl;
1874 + u16 sl;
1875 + u8 bssid[WLAN_BSSID_LEN];
1876 + u16 bcnint;
1877 + u16 capinfo;
1878 + hfa384x_bytestr32_t ssid;
1879 + u8 supprates[10]; /* 802.11 info element */
1880 + u16 proberesp_rate;
1881 +} __WLAN_ATTRIB_PACK__ hfa384x_ScanResultSub_t;
1882 +
1883 +typedef struct hfa384x_ScanResult
1884 +{
1885 + u16 rsvd;
1886 + u16 scanreason;
1887 + hfa384x_ScanResultSub_t
1888 + result[HFA384x_SCANRESULT_MAX];
1889 +} __WLAN_ATTRIB_PACK__ hfa384x_ScanResult_t;
1890 +
1891 +/*-- Inquiry Frame, Diagnose: ChInfo Results & Subfields--*/
1892 +typedef struct hfa384x_ChInfoResultSub
1893 +{
1894 + u16 chid;
1895 + u16 anl;
1896 + u16 pnl;
1897 + u16 active;
1898 +} __WLAN_ATTRIB_PACK__ hfa384x_ChInfoResultSub_t;
1899 +
1900 +#define HFA384x_CHINFORESULT_BSSACTIVE BIT0
1901 +#define HFA384x_CHINFORESULT_PCFACTIVE BIT1
1902 +
1903 +typedef struct hfa384x_ChInfoResult
1904 +{
1905 + u16 scanchannels;
1906 + hfa384x_ChInfoResultSub_t
1907 + result[HFA384x_CHINFORESULT_MAX];
1908 +} __WLAN_ATTRIB_PACK__ hfa384x_ChInfoResult_t;
1909 +
1910 +/*-- Inquiry Frame, Diagnose: Host Scan Results & Subfields--*/
1911 +typedef struct hfa384x_HScanResultSub
1912 +{
1913 + u16 chid;
1914 + u16 anl;
1915 + u16 sl;
1916 + u8 bssid[WLAN_BSSID_LEN];
1917 + u16 bcnint;
1918 + u16 capinfo;
1919 + hfa384x_bytestr32_t ssid;
1920 + u8 supprates[10]; /* 802.11 info element */
1921 + u16 proberesp_rate;
1922 + u16 atim;
1923 +} __WLAN_ATTRIB_PACK__ hfa384x_HScanResultSub_t;
1924 +
1925 +typedef struct hfa384x_HScanResult
1926 +{
1927 + u16 nresult;
1928 + u16 rsvd;
1929 + hfa384x_HScanResultSub_t
1930 + result[HFA384x_HSCANRESULT_MAX];
1931 +} __WLAN_ATTRIB_PACK__ hfa384x_HScanResult_t;
1932 +
1933 +/*-- Unsolicited Frame, MAC Mgmt: LinkStatus --*/
1934 +
1935 +#define HFA384x_LINK_NOTCONNECTED ((u16)0)
1936 +#define HFA384x_LINK_CONNECTED ((u16)1)
1937 +#define HFA384x_LINK_DISCONNECTED ((u16)2)
1938 +#define HFA384x_LINK_AP_CHANGE ((u16)3)
1939 +#define HFA384x_LINK_AP_OUTOFRANGE ((u16)4)
1940 +#define HFA384x_LINK_AP_INRANGE ((u16)5)
1941 +#define HFA384x_LINK_ASSOCFAIL ((u16)6)
1942 +
1943 +typedef struct hfa384x_LinkStatus
1944 +{
1945 + u16 linkstatus;
1946 +} __WLAN_ATTRIB_PACK__ hfa384x_LinkStatus_t;
1947 +
1948 +
1949 +/*-- Unsolicited Frame, MAC Mgmt: AssociationStatus (--*/
1950 +
1951 +#define HFA384x_ASSOCSTATUS_STAASSOC ((u16)1)
1952 +#define HFA384x_ASSOCSTATUS_REASSOC ((u16)2)
1953 +#define HFA384x_ASSOCSTATUS_DISASSOC ((u16)3)
1954 +#define HFA384x_ASSOCSTATUS_ASSOCFAIL ((u16)4)
1955 +#define HFA384x_ASSOCSTATUS_AUTHFAIL ((u16)5)
1956 +
1957 +typedef struct hfa384x_AssocStatus
1958 +{
1959 + u16 assocstatus;
1960 + u8 sta_addr[WLAN_ADDR_LEN];
1961 + /* old_ap_addr is only valid if assocstatus == 2 */
1962 + u8 old_ap_addr[WLAN_ADDR_LEN];
1963 + u16 reason;
1964 + u16 reserved;
1965 +} __WLAN_ATTRIB_PACK__ hfa384x_AssocStatus_t;
1966 +
1967 +/*-- Unsolicited Frame, MAC Mgmt: AuthRequest (AP Only) --*/
1968 +
1969 +typedef struct hfa384x_AuthRequest
1970 +{
1971 + u8 sta_addr[WLAN_ADDR_LEN];
1972 + u16 algorithm;
1973 +} __WLAN_ATTRIB_PACK__ hfa384x_AuthReq_t;
1974 +
1975 +/*-- Unsolicited Frame, MAC Mgmt: AssocRequest (AP Only) --*/
1976 +
1977 +typedef struct hfa384x_AssocRequest
1978 +{
1979 + u8 sta_addr[WLAN_ADDR_LEN];
1980 + u16 type;
1981 + u8 wpa_data[80];
1982 +} __WLAN_ATTRIB_PACK__ hfa384x_AssocReq_t;
1983 +
1984 +
1985 +#define HFA384x_ASSOCREQ_TYPE_ASSOC 0
1986 +#define HFA384x_ASSOCREQ_TYPE_REASSOC 1
1987 +
1988 +/*-- Unsolicited Frame, MAC Mgmt: MIC Failure (AP Only) --*/
1989 +
1990 +typedef struct hfa384x_MicFailure
1991 +{
1992 + u8 sender[WLAN_ADDR_LEN];
1993 + u8 dest[WLAN_ADDR_LEN];
1994 +} __WLAN_ATTRIB_PACK__ hfa384x_MicFailure_t;
1995 +
1996 +/*-- Unsolicited Frame, MAC Mgmt: PSUserCount (AP Only) --*/
1997 +
1998 +typedef struct hfa384x_PSUserCount
1999 +{
2000 + u16 usercnt;
2001 +} __WLAN_ATTRIB_PACK__ hfa384x_PSUserCount_t;
2002 +
2003 +typedef struct hfa384x_KeyIDChanged
2004 +{
2005 + u8 sta_addr[WLAN_ADDR_LEN];
2006 + u16 keyid;
2007 +} __WLAN_ATTRIB_PACK__ hfa384x_KeyIDChanged_t;
2008 +
2009 +/*-- Collection of all Inf frames ---------------*/
2010 +typedef union hfa384x_infodata {
2011 + hfa384x_CommTallies16_t commtallies16;
2012 + hfa384x_CommTallies32_t commtallies32;
2013 + hfa384x_ScanResult_t scanresult;
2014 + hfa384x_ChInfoResult_t chinforesult;
2015 + hfa384x_HScanResult_t hscanresult;
2016 + hfa384x_LinkStatus_t linkstatus;
2017 + hfa384x_AssocStatus_t assocstatus;
2018 + hfa384x_AuthReq_t authreq;
2019 + hfa384x_PSUserCount_t psusercnt;
2020 + hfa384x_KeyIDChanged_t keyidchanged;
2021 +} __WLAN_ATTRIB_PACK__ hfa384x_infodata_t;
2022 +
2023 +typedef struct hfa384x_InfFrame
2024 +{
2025 + u16 framelen;
2026 + u16 infotype;
2027 + hfa384x_infodata_t info;
2028 +} __WLAN_ATTRIB_PACK__ hfa384x_InfFrame_t;
2029 +
2030 +/*--------------------------------------------------------------------
2031 +USB Packet structures and constants.
2032 +--------------------------------------------------------------------*/
2033 +
2034 +/* Should be sent to the ctrlout endpoint */
2035 +#define HFA384x_USB_ENBULKIN 6
2036 +
2037 +/* Should be sent to the bulkout endpoint */
2038 +#define HFA384x_USB_TXFRM 0
2039 +#define HFA384x_USB_CMDREQ 1
2040 +#define HFA384x_USB_WRIDREQ 2
2041 +#define HFA384x_USB_RRIDREQ 3
2042 +#define HFA384x_USB_WMEMREQ 4
2043 +#define HFA384x_USB_RMEMREQ 5
2044 +
2045 +/* Received from the bulkin endpoint */
2046 +#define HFA384x_USB_ISFRM(a) (!((a) & 0x8000))
2047 +#define HFA384x_USB_ISTXFRM(a) (((a) & 0x9000) == 0x1000)
2048 +#define HFA384x_USB_ISRXFRM(a) (!((a) & 0x9000))
2049 +#define HFA384x_USB_INFOFRM 0x8000
2050 +#define HFA384x_USB_CMDRESP 0x8001
2051 +#define HFA384x_USB_WRIDRESP 0x8002
2052 +#define HFA384x_USB_RRIDRESP 0x8003
2053 +#define HFA384x_USB_WMEMRESP 0x8004
2054 +#define HFA384x_USB_RMEMRESP 0x8005
2055 +#define HFA384x_USB_BUFAVAIL 0x8006
2056 +#define HFA384x_USB_ERROR 0x8007
2057 +
2058 +/*------------------------------------*/
2059 +/* Request (bulk OUT) packet contents */
2060 +
2061 +typedef struct hfa384x_usb_txfrm {
2062 + hfa384x_tx_frame_t desc;
2063 + u8 data[WLAN_DATA_MAXLEN];
2064 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_txfrm_t;
2065 +
2066 +typedef struct hfa384x_usb_cmdreq {
2067 + u16 type;
2068 + u16 cmd;
2069 + u16 parm0;
2070 + u16 parm1;
2071 + u16 parm2;
2072 + u8 pad[54];
2073 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_cmdreq_t;
2074 +
2075 +typedef struct hfa384x_usb_wridreq {
2076 + u16 type;
2077 + u16 frmlen;
2078 + u16 rid;
2079 + u8 data[HFA384x_RIDDATA_MAXLEN];
2080 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_wridreq_t;
2081 +
2082 +typedef struct hfa384x_usb_rridreq {
2083 + u16 type;
2084 + u16 frmlen;
2085 + u16 rid;
2086 + u8 pad[58];
2087 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_rridreq_t;
2088 +
2089 +typedef struct hfa384x_usb_wmemreq {
2090 + u16 type;
2091 + u16 frmlen;
2092 + u16 offset;
2093 + u16 page;
2094 + u8 data[HFA384x_USB_RWMEM_MAXLEN];
2095 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_wmemreq_t;
2096 +
2097 +typedef struct hfa384x_usb_rmemreq {
2098 + u16 type;
2099 + u16 frmlen;
2100 + u16 offset;
2101 + u16 page;
2102 + u8 pad[56];
2103 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_rmemreq_t;
2104 +
2105 +/*------------------------------------*/
2106 +/* Response (bulk IN) packet contents */
2107 +
2108 +typedef struct hfa384x_usb_rxfrm {
2109 + hfa384x_rx_frame_t desc;
2110 + u8 data[WLAN_DATA_MAXLEN];
2111 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_rxfrm_t;
2112 +
2113 +typedef struct hfa384x_usb_infofrm {
2114 + u16 type;
2115 + hfa384x_InfFrame_t info;
2116 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_infofrm_t;
2117 +
2118 +typedef struct hfa384x_usb_statusresp {
2119 + u16 type;
2120 + u16 status;
2121 + u16 resp0;
2122 + u16 resp1;
2123 + u16 resp2;
2124 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_cmdresp_t;
2125 +
2126 +typedef hfa384x_usb_cmdresp_t hfa384x_usb_wridresp_t;
2127 +
2128 +typedef struct hfa384x_usb_rridresp {
2129 + u16 type;
2130 + u16 frmlen;
2131 + u16 rid;
2132 + u8 data[HFA384x_RIDDATA_MAXLEN];
2133 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_rridresp_t;
2134 +
2135 +typedef hfa384x_usb_cmdresp_t hfa384x_usb_wmemresp_t;
2136 +
2137 +typedef struct hfa384x_usb_rmemresp {
2138 + u16 type;
2139 + u16 frmlen;
2140 + u8 data[HFA384x_USB_RWMEM_MAXLEN];
2141 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_rmemresp_t;
2142 +
2143 +typedef struct hfa384x_usb_bufavail {
2144 + u16 type;
2145 + u16 frmlen;
2146 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_bufavail_t;
2147 +
2148 +typedef struct hfa384x_usb_error {
2149 + u16 type;
2150 + u16 errortype;
2151 +} __WLAN_ATTRIB_PACK__ hfa384x_usb_error_t;
2152 +
2153 +/*----------------------------------------------------------*/
2154 +/* Unions for packaging all the known packet types together */
2155 +
2156 +typedef union hfa384x_usbout {
2157 + u16 type;
2158 + hfa384x_usb_txfrm_t txfrm;
2159 + hfa384x_usb_cmdreq_t cmdreq;
2160 + hfa384x_usb_wridreq_t wridreq;
2161 + hfa384x_usb_rridreq_t rridreq;
2162 + hfa384x_usb_wmemreq_t wmemreq;
2163 + hfa384x_usb_rmemreq_t rmemreq;
2164 +} __WLAN_ATTRIB_PACK__ hfa384x_usbout_t;
2165 +
2166 +typedef union hfa384x_usbin {
2167 + u16 type;
2168 + hfa384x_usb_rxfrm_t rxfrm;
2169 + hfa384x_usb_txfrm_t txfrm;
2170 + hfa384x_usb_infofrm_t infofrm;
2171 + hfa384x_usb_cmdresp_t cmdresp;
2172 + hfa384x_usb_wridresp_t wridresp;
2173 + hfa384x_usb_rridresp_t rridresp;
2174 + hfa384x_usb_wmemresp_t wmemresp;
2175 + hfa384x_usb_rmemresp_t rmemresp;
2176 + hfa384x_usb_bufavail_t bufavail;
2177 + hfa384x_usb_error_t usberror;
2178 + u8 boguspad[3000];
2179 +} __WLAN_ATTRIB_PACK__ hfa384x_usbin_t;
2180 +
2181 +/*--------------------------------------------------------------------
2182 +PD record structures.
2183 +--------------------------------------------------------------------*/
2184 +
2185 +typedef struct hfa384x_pdr_pcb_partnum
2186 +{
2187 + u8 num[8];
2188 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_pcb_partnum_t;
2189 +
2190 +typedef struct hfa384x_pdr_pcb_tracenum
2191 +{
2192 + u8 num[8];
2193 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_pcb_tracenum_t;
2194 +
2195 +typedef struct hfa384x_pdr_nic_serial
2196 +{
2197 + u8 num[12];
2198 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_nic_serial_t;
2199 +
2200 +typedef struct hfa384x_pdr_mkk_measurements
2201 +{
2202 + double carrier_freq;
2203 + double occupied_band;
2204 + double power_density;
2205 + double tx_spur_f1;
2206 + double tx_spur_f2;
2207 + double tx_spur_f3;
2208 + double tx_spur_f4;
2209 + double tx_spur_l1;
2210 + double tx_spur_l2;
2211 + double tx_spur_l3;
2212 + double tx_spur_l4;
2213 + double rx_spur_f1;
2214 + double rx_spur_f2;
2215 + double rx_spur_l1;
2216 + double rx_spur_l2;
2217 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_mkk_measurements_t;
2218 +
2219 +typedef struct hfa384x_pdr_nic_ramsize
2220 +{
2221 + u8 size[12]; /* units of KB */
2222 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_nic_ramsize_t;
2223 +
2224 +typedef struct hfa384x_pdr_mfisuprange
2225 +{
2226 + u16 id;
2227 + u16 variant;
2228 + u16 bottom;
2229 + u16 top;
2230 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_mfisuprange_t;
2231 +
2232 +typedef struct hfa384x_pdr_cfisuprange
2233 +{
2234 + u16 id;
2235 + u16 variant;
2236 + u16 bottom;
2237 + u16 top;
2238 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_cfisuprange_t;
2239 +
2240 +typedef struct hfa384x_pdr_nicid
2241 +{
2242 + u16 id;
2243 + u16 variant;
2244 + u16 major;
2245 + u16 minor;
2246 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_nicid_t;
2247 +
2248 +
2249 +typedef struct hfa384x_pdr_refdac_measurements
2250 +{
2251 + u16 value[0];
2252 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_refdac_measurements_t;
2253 +
2254 +typedef struct hfa384x_pdr_vgdac_measurements
2255 +{
2256 + u16 value[0];
2257 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_vgdac_measurements_t;
2258 +
2259 +typedef struct hfa384x_pdr_level_comp_measurements
2260 +{
2261 + u16 value[0];
2262 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_level_compc_measurements_t;
2263 +
2264 +typedef struct hfa384x_pdr_mac_address
2265 +{
2266 + u8 addr[6];
2267 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_mac_address_t;
2268 +
2269 +typedef struct hfa384x_pdr_mkk_callname
2270 +{
2271 + u8 callname[8];
2272 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_mkk_callname_t;
2273 +
2274 +typedef struct hfa384x_pdr_regdomain
2275 +{
2276 + u16 numdomains;
2277 + u16 domain[5];
2278 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_regdomain_t;
2279 +
2280 +typedef struct hfa384x_pdr_allowed_channel
2281 +{
2282 + u16 ch_bitmap;
2283 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_allowed_channel_t;
2284 +
2285 +typedef struct hfa384x_pdr_default_channel
2286 +{
2287 + u16 channel;
2288 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_default_channel_t;
2289 +
2290 +typedef struct hfa384x_pdr_privacy_option
2291 +{
2292 + u16 available;
2293 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_privacy_option_t;
2294 +
2295 +typedef struct hfa384x_pdr_temptype
2296 +{
2297 + u16 type;
2298 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_temptype_t;
2299 +
2300 +typedef struct hfa384x_pdr_refdac_setup
2301 +{
2302 + u16 ch_value[14];
2303 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_refdac_setup_t;
2304 +
2305 +typedef struct hfa384x_pdr_vgdac_setup
2306 +{
2307 + u16 ch_value[14];
2308 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_vgdac_setup_t;
2309 +
2310 +typedef struct hfa384x_pdr_level_comp_setup
2311 +{
2312 + u16 ch_value[14];
2313 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_level_comp_setup_t;
2314 +
2315 +typedef struct hfa384x_pdr_trimdac_setup
2316 +{
2317 + u16 trimidac;
2318 + u16 trimqdac;
2319 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_trimdac_setup_t;
2320 +
2321 +typedef struct hfa384x_pdr_ifr_setting
2322 +{
2323 + u16 value[3];
2324 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_ifr_setting_t;
2325 +
2326 +typedef struct hfa384x_pdr_rfr_setting
2327 +{
2328 + u16 value[3];
2329 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_rfr_setting_t;
2330 +
2331 +typedef struct hfa384x_pdr_hfa3861_baseline
2332 +{
2333 + u16 value[50];
2334 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_hfa3861_baseline_t;
2335 +
2336 +typedef struct hfa384x_pdr_hfa3861_shadow
2337 +{
2338 + u32 value[32];
2339 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_hfa3861_shadow_t;
2340 +
2341 +typedef struct hfa384x_pdr_hfa3861_ifrf
2342 +{
2343 + u32 value[20];
2344 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_hfa3861_ifrf_t;
2345 +
2346 +typedef struct hfa384x_pdr_hfa3861_chcalsp
2347 +{
2348 + u16 value[14];
2349 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_hfa3861_chcalsp_t;
2350 +
2351 +typedef struct hfa384x_pdr_hfa3861_chcali
2352 +{
2353 + u16 value[17];
2354 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_hfa3861_chcali_t;
2355 +
2356 +typedef struct hfa384x_pdr_hfa3861_nic_config
2357 +{
2358 + u16 config_bitmap;
2359 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_nic_config_t;
2360 +
2361 +typedef struct hfa384x_pdr_hfo_delay
2362 +{
2363 + u8 hfo_delay;
2364 +} __WLAN_ATTRIB_PACK__ hfa384x_hfo_delay_t;
2365 +
2366 +typedef struct hfa384x_pdr_hfa3861_manf_testsp
2367 +{
2368 + u16 value[30];
2369 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_hfa3861_manf_testsp_t;
2370 +
2371 +typedef struct hfa384x_pdr_hfa3861_manf_testi
2372 +{
2373 + u16 value[30];
2374 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_hfa3861_manf_testi_t;
2375 +
2376 +typedef struct hfa384x_end_of_pda
2377 +{
2378 + u16 crc;
2379 +} __WLAN_ATTRIB_PACK__ hfa384x_pdr_end_of_pda_t;
2380 +
2381 +typedef struct hfa384x_pdrec
2382 +{
2383 + u16 len; /* in words */
2384 + u16 code;
2385 + union pdr {
2386 + hfa384x_pdr_pcb_partnum_t pcb_partnum;
2387 + hfa384x_pdr_pcb_tracenum_t pcb_tracenum;
2388 + hfa384x_pdr_nic_serial_t nic_serial;
2389 + hfa384x_pdr_mkk_measurements_t mkk_measurements;
2390 + hfa384x_pdr_nic_ramsize_t nic_ramsize;
2391 + hfa384x_pdr_mfisuprange_t mfisuprange;
2392 + hfa384x_pdr_cfisuprange_t cfisuprange;
2393 + hfa384x_pdr_nicid_t nicid;
2394 + hfa384x_pdr_refdac_measurements_t refdac_measurements;
2395 + hfa384x_pdr_vgdac_measurements_t vgdac_measurements;
2396 + hfa384x_pdr_level_compc_measurements_t level_compc_measurements;
2397 + hfa384x_pdr_mac_address_t mac_address;
2398 + hfa384x_pdr_mkk_callname_t mkk_callname;
2399 + hfa384x_pdr_regdomain_t regdomain;
2400 + hfa384x_pdr_allowed_channel_t allowed_channel;
2401 + hfa384x_pdr_default_channel_t default_channel;
2402 + hfa384x_pdr_privacy_option_t privacy_option;
2403 + hfa384x_pdr_temptype_t temptype;
2404 + hfa384x_pdr_refdac_setup_t refdac_setup;
2405 + hfa384x_pdr_vgdac_setup_t vgdac_setup;
2406 + hfa384x_pdr_level_comp_setup_t level_comp_setup;
2407 + hfa384x_pdr_trimdac_setup_t trimdac_setup;
2408 + hfa384x_pdr_ifr_setting_t ifr_setting;
2409 + hfa384x_pdr_rfr_setting_t rfr_setting;
2410 + hfa384x_pdr_hfa3861_baseline_t hfa3861_baseline;
2411 + hfa384x_pdr_hfa3861_shadow_t hfa3861_shadow;
2412 + hfa384x_pdr_hfa3861_ifrf_t hfa3861_ifrf;
2413 + hfa384x_pdr_hfa3861_chcalsp_t hfa3861_chcalsp;
2414 + hfa384x_pdr_hfa3861_chcali_t hfa3861_chcali;
2415 + hfa384x_pdr_nic_config_t nic_config;
2416 + hfa384x_hfo_delay_t hfo_delay;
2417 + hfa384x_pdr_hfa3861_manf_testsp_t hfa3861_manf_testsp;
2418 + hfa384x_pdr_hfa3861_manf_testi_t hfa3861_manf_testi;
2419 + hfa384x_pdr_end_of_pda_t end_of_pda;
2420 +
2421 + } data;
2422 +} __WLAN_ATTRIB_PACK__ hfa384x_pdrec_t;
2423 +
2424 +
2425 +#ifdef __KERNEL__
2426 +/*--------------------------------------------------------------------
2427 +--- MAC state structure, argument to all functions --
2428 +--- Also, a collection of support types --
2429 +--------------------------------------------------------------------*/
2430 +typedef struct hfa384x_statusresult
2431 +{
2432 + u16 status;
2433 + u16 resp0;
2434 + u16 resp1;
2435 + u16 resp2;
2436 +} hfa384x_cmdresult_t;
2437 +
2438 +/* USB Control Exchange (CTLX):
2439 + * A queue of the structure below is maintained for all of the
2440 + * Request/Response type USB packets supported by Prism2.
2441 + */
2442 +/* The following hfa384x_* structures are arguments to
2443 + * the usercb() for the different CTLX types.
2444 + */
2445 +typedef hfa384x_cmdresult_t hfa384x_wridresult_t;
2446 +typedef hfa384x_cmdresult_t hfa384x_wmemresult_t;
2447 +
2448 +typedef struct hfa384x_rridresult
2449 +{
2450 + u16 rid;
2451 + const void *riddata;
2452 + unsigned int riddata_len;
2453 +} hfa384x_rridresult_t;
2454 +
2455 +enum ctlx_state {
2456 + CTLX_START = 0, /* Start state, not queued */
2457 +
2458 + CTLX_COMPLETE, /* CTLX successfully completed */
2459 + CTLX_REQ_FAILED, /* OUT URB completed w/ error */
2460 +
2461 + CTLX_PENDING, /* Queued, data valid */
2462 + CTLX_REQ_SUBMITTED, /* OUT URB submitted */
2463 + CTLX_REQ_COMPLETE, /* OUT URB complete */
2464 + CTLX_RESP_COMPLETE /* IN URB received */
2465 +};
2466 +typedef enum ctlx_state CTLX_STATE;
2467 +
2468 +struct hfa384x_usbctlx;
2469 +struct hfa384x;
2470 +
2471 +typedef void (*ctlx_cmdcb_t)( struct hfa384x*, const struct hfa384x_usbctlx* );
2472 +
2473 +typedef void (*ctlx_usercb_t)(
2474 + struct hfa384x *hw,
2475 + void *ctlxresult,
2476 + void *usercb_data);
2477 +
2478 +typedef struct hfa384x_usbctlx
2479 +{
2480 + struct list_head list;
2481 +
2482 + size_t outbufsize;
2483 + hfa384x_usbout_t outbuf; /* pkt buf for OUT */
2484 + hfa384x_usbin_t inbuf; /* pkt buf for IN(a copy) */
2485 +
2486 + CTLX_STATE state; /* Tracks running state */
2487 +
2488 + struct completion done;
2489 + volatile int reapable; /* Food for the reaper task */
2490 +
2491 + ctlx_cmdcb_t cmdcb; /* Async command callback */
2492 + ctlx_usercb_t usercb; /* Async user callback, */
2493 + void *usercb_data; /* at CTLX completion */
2494 +
2495 + int variant; /* Identifies cmd variant */
2496 +} hfa384x_usbctlx_t;
2497 +
2498 +typedef struct hfa384x_usbctlxq
2499 +{
2500 + spinlock_t lock;
2501 + struct list_head pending;
2502 + struct list_head active;
2503 + struct list_head completing;
2504 + struct list_head reapable;
2505 +} hfa384x_usbctlxq_t;
2506 +
2507 +typedef struct hfa484x_metacmd
2508 +{
2509 + u16 cmd;
2510 +
2511 + u16 parm0;
2512 + u16 parm1;
2513 + u16 parm2;
2514 +
2515 + hfa384x_cmdresult_t result;
2516 +} hfa384x_metacmd_t;
2517 +
2518 +#define MAX_PRISM2_GRP_ADDR 16
2519 +#define MAX_GRP_ADDR 32
2520 +#define WLAN_COMMENT_MAX 80 /* Max. length of user comment string. */
2521 +
2522 +#define MM_SAT_PCF (BIT14)
2523 +#define MM_GCSD_PCF (BIT15)
2524 +#define MM_GCSD_PCF_EB (BIT14 | BIT15)
2525 +
2526 +#define WLAN_STATE_STOPPED 0 /* Network is not active. */
2527 +#define WLAN_STATE_STARTED 1 /* Network has been started. */
2528 +
2529 +#define WLAN_AUTH_MAX 60 /* Max. # of authenticated stations. */
2530 +#define WLAN_ACCESS_MAX 60 /* Max. # of stations in an access list. */
2531 +#define WLAN_ACCESS_NONE 0 /* No stations may be authenticated. */
2532 +#define WLAN_ACCESS_ALL 1 /* All stations may be authenticated. */
2533 +#define WLAN_ACCESS_ALLOW 2 /* Authenticate only "allowed" stations. */
2534 +#define WLAN_ACCESS_DENY 3 /* Do not authenticate "denied" stations. */
2535 +
2536 +/* XXX These are going away ASAP */
2537 +typedef struct prism2sta_authlist
2538 +{
2539 + unsigned int cnt;
2540 + u8 addr[WLAN_AUTH_MAX][WLAN_ADDR_LEN];
2541 + u8 assoc[WLAN_AUTH_MAX];
2542 +} prism2sta_authlist_t;
2543 +
2544 +typedef struct prism2sta_accesslist
2545 +{
2546 + unsigned int modify;
2547 + unsigned int cnt;
2548 + u8 addr[WLAN_ACCESS_MAX][WLAN_ADDR_LEN];
2549 + unsigned int cnt1;
2550 + u8 addr1[WLAN_ACCESS_MAX][WLAN_ADDR_LEN];
2551 +} prism2sta_accesslist_t;
2552 +
2553 +typedef struct hfa384x
2554 +{
2555 + /* USB support data */
2556 + struct usb_device *usb;
2557 + struct urb rx_urb;
2558 + struct sk_buff *rx_urb_skb;
2559 + struct urb tx_urb;
2560 + struct urb ctlx_urb;
2561 + hfa384x_usbout_t txbuff;
2562 + hfa384x_usbctlxq_t ctlxq;
2563 + struct timer_list reqtimer;
2564 + struct timer_list resptimer;
2565 +
2566 + struct timer_list throttle;
2567 +
2568 + struct tasklet_struct reaper_bh;
2569 + struct tasklet_struct completion_bh;
2570 +
2571 + struct work_struct usb_work;
2572 +
2573 + unsigned long usb_flags;
2574 +#define THROTTLE_RX 0
2575 +#define THROTTLE_TX 1
2576 +#define WORK_RX_HALT 2
2577 +#define WORK_TX_HALT 3
2578 +#define WORK_RX_RESUME 4
2579 +#define WORK_TX_RESUME 5
2580 +
2581 + unsigned short req_timer_done:1;
2582 + unsigned short resp_timer_done:1;
2583 +
2584 + int endp_in;
2585 + int endp_out;
2586 +
2587 + int sniff_fcs;
2588 + int sniff_channel;
2589 + int sniff_truncate;
2590 + int sniffhdr;
2591 +
2592 + wait_queue_head_t cmdq; /* wait queue itself */
2593 +
2594 + /* Controller state */
2595 + u32 state;
2596 + u32 isap;
2597 + u8 port_enabled[HFA384x_NUMPORTS_MAX];
2598 +
2599 + /* Download support */
2600 + unsigned int dlstate;
2601 + hfa384x_downloadbuffer_t bufinfo;
2602 + u16 dltimeout;
2603 +
2604 + int scanflag; /* to signal scan comlete */
2605 + int join_ap; /* are we joined to a specific ap */
2606 + int join_retries; /* number of join retries till we fail */
2607 + hfa384x_JoinRequest_data_t joinreq; /* join request saved data */
2608 +
2609 + wlandevice_t *wlandev;
2610 + /* Timer to allow for the deferred processing of linkstatus messages */
2611 + struct work_struct link_bh;
2612 +
2613 + struct work_struct commsqual_bh;
2614 + hfa384x_commsquality_t qual;
2615 + struct timer_list commsqual_timer;
2616 +
2617 + u16 link_status;
2618 + u16 link_status_new;
2619 + struct sk_buff_head authq;
2620 +
2621 + /* And here we have stuff that used to be in priv */
2622 +
2623 + /* State variables */
2624 + unsigned int presniff_port_type;
2625 + u16 presniff_wepflags;
2626 + u32 dot11_desired_bss_type;
2627 +
2628 + int dbmadjust;
2629 +
2630 + /* Group Addresses - right now, there are up to a total
2631 + of MAX_GRP_ADDR group addresses */
2632 + u8 dot11_grp_addr[MAX_GRP_ADDR][WLAN_ADDR_LEN];
2633 + unsigned int dot11_grpcnt;
2634 +
2635 + /* Component Identities */
2636 + hfa384x_compident_t ident_nic;
2637 + hfa384x_compident_t ident_pri_fw;
2638 + hfa384x_compident_t ident_sta_fw;
2639 + hfa384x_compident_t ident_ap_fw;
2640 + u16 mm_mods;
2641 +
2642 + /* Supplier compatibility ranges */
2643 + hfa384x_caplevel_t cap_sup_mfi;
2644 + hfa384x_caplevel_t cap_sup_cfi;
2645 + hfa384x_caplevel_t cap_sup_pri;
2646 + hfa384x_caplevel_t cap_sup_sta;
2647 + hfa384x_caplevel_t cap_sup_ap;
2648 +
2649 + /* Actor compatibility ranges */
2650 + hfa384x_caplevel_t cap_act_pri_cfi; /* pri f/w to controller interface */
2651 + hfa384x_caplevel_t cap_act_sta_cfi; /* sta f/w to controller interface */
2652 + hfa384x_caplevel_t cap_act_sta_mfi; /* sta f/w to modem interface */
2653 + hfa384x_caplevel_t cap_act_ap_cfi; /* ap f/w to controller interface */
2654 + hfa384x_caplevel_t cap_act_ap_mfi; /* ap f/w to modem interface */
2655 +
2656 + u32 psusercount; /* Power save user count. */
2657 + hfa384x_CommTallies32_t tallies; /* Communication tallies. */
2658 + u8 comment[WLAN_COMMENT_MAX+1]; /* User comment */
2659 +
2660 + /* Channel Info request results (AP only) */
2661 + struct {
2662 + atomic_t done;
2663 + u8 count;
2664 + hfa384x_ChInfoResult_t results;
2665 + } channel_info;
2666 +
2667 + hfa384x_InfFrame_t *scanresults;
2668 +
2669 +
2670 + prism2sta_authlist_t authlist; /* Authenticated station list. */
2671 + unsigned int accessmode; /* Access mode. */
2672 + prism2sta_accesslist_t allow; /* Allowed station list. */
2673 + prism2sta_accesslist_t deny; /* Denied station list. */
2674 +
2675 +} hfa384x_t;
2676 +
2677 +/*=============================================================*/
2678 +/*--- Function Declarations -----------------------------------*/
2679 +/*=============================================================*/
2680 +void
2681 +hfa384x_create(
2682 + hfa384x_t *hw,
2683 + struct usb_device *usb);
2684 +
2685 +void hfa384x_destroy(hfa384x_t *hw);
2686 +
2687 +int
2688 +hfa384x_corereset( hfa384x_t *hw, int holdtime, int settletime, int genesis);
2689 +int
2690 +hfa384x_drvr_chinforesults( hfa384x_t *hw);
2691 +int
2692 +hfa384x_drvr_commtallies( hfa384x_t *hw);
2693 +int
2694 +hfa384x_drvr_disable(hfa384x_t *hw, u16 macport);
2695 +int
2696 +hfa384x_drvr_enable(hfa384x_t *hw, u16 macport);
2697 +int
2698 +hfa384x_drvr_flashdl_enable(hfa384x_t *hw);
2699 +int
2700 +hfa384x_drvr_flashdl_disable(hfa384x_t *hw);
2701 +int
2702 +hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void* buf, u32 len);
2703 +int
2704 +hfa384x_drvr_getconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len);
2705 +int
2706 +hfa384x_drvr_handover( hfa384x_t *hw, u8 *addr);
2707 +int
2708 +hfa384x_drvr_hostscanresults( hfa384x_t *hw);
2709 +int
2710 +hfa384x_drvr_low_level(hfa384x_t *hw, hfa384x_metacmd_t *cmd);
2711 +int
2712 +hfa384x_drvr_mmi_read(hfa384x_t *hw, u32 address, u32 *result);
2713 +int
2714 +hfa384x_drvr_mmi_write(hfa384x_t *hw, u32 address, u32 data);
2715 +int
2716 +hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr);
2717 +int
2718 +hfa384x_drvr_ramdl_disable(hfa384x_t *hw);
2719 +int
2720 +hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void* buf, u32 len);
2721 +int
2722 +hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len);
2723 +int
2724 +hfa384x_drvr_scanresults( hfa384x_t *hw);
2725 +
2726 +int
2727 +hfa384x_drvr_setconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len);
2728 +
2729 +static inline int
2730 +hfa384x_drvr_getconfig16(hfa384x_t *hw, u16 rid, void *val)
2731 +{
2732 + int result = 0;
2733 + result = hfa384x_drvr_getconfig(hw, rid, val, sizeof(u16));
2734 + if ( result == 0 ) {
2735 + *((u16*)val) = hfa384x2host_16(*((u16*)val));
2736 + }
2737 + return result;
2738 +}
2739 +
2740 +static inline int
2741 +hfa384x_drvr_getconfig32(hfa384x_t *hw, u16 rid, void *val)
2742 +{
2743 + int result = 0;
2744 +
2745 + result = hfa384x_drvr_getconfig(hw, rid, val, sizeof(u32));
2746 + if ( result == 0 ) {
2747 + *((u32*)val) = hfa384x2host_32(*((u32*)val));
2748 + }
2749 +
2750 + return result;
2751 +}
2752 +
2753 +static inline int
2754 +hfa384x_drvr_setconfig16(hfa384x_t *hw, u16 rid, u16 val)
2755 +{
2756 + u16 value = host2hfa384x_16(val);
2757 + return hfa384x_drvr_setconfig(hw, rid, &value, sizeof(value));
2758 +}
2759 +
2760 +static inline int
2761 +hfa384x_drvr_setconfig32(hfa384x_t *hw, u16 rid, u32 val)
2762 +{
2763 + u32 value = host2hfa384x_32(val);
2764 + return hfa384x_drvr_setconfig(hw, rid, &value, sizeof(value));
2765 +}
2766 +
2767 +int
2768 +hfa384x_drvr_getconfig_async(hfa384x_t *hw,
2769 + u16 rid,
2770 + ctlx_usercb_t usercb,
2771 + void *usercb_data);
2772 +
2773 +int
2774 +hfa384x_drvr_setconfig_async(hfa384x_t *hw,
2775 + u16 rid,
2776 + void *buf,
2777 + u16 len,
2778 + ctlx_usercb_t usercb,
2779 + void *usercb_data);
2780 +
2781 +static inline int
2782 +hfa384x_drvr_setconfig16_async(hfa384x_t *hw, u16 rid, u16 val)
2783 +{
2784 + u16 value = host2hfa384x_16(val);
2785 + return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value),
2786 + NULL , NULL);
2787 +}
2788 +
2789 +static inline int
2790 +hfa384x_drvr_setconfig32_async(hfa384x_t *hw, u16 rid, u32 val)
2791 +{
2792 + u32 value = host2hfa384x_32(val);
2793 + return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value),
2794 + NULL , NULL);
2795 +}
2796 +
2797 +
2798 +int
2799 +hfa384x_drvr_start(hfa384x_t *hw);
2800 +int
2801 +hfa384x_drvr_stop(hfa384x_t *hw);
2802 +int
2803 +hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
2804 +void
2805 +hfa384x_tx_timeout(wlandevice_t *wlandev);
2806 +
2807 +int
2808 +hfa384x_cmd_initialize(hfa384x_t *hw);
2809 +int
2810 +hfa384x_cmd_enable(hfa384x_t *hw, u16 macport);
2811 +int
2812 +hfa384x_cmd_disable(hfa384x_t *hw, u16 macport);
2813 +int
2814 +hfa384x_cmd_diagnose(hfa384x_t *hw);
2815 +int
2816 +hfa384x_cmd_allocate(hfa384x_t *hw, u16 len);
2817 +int
2818 +hfa384x_cmd_transmit(hfa384x_t *hw, u16 reclaim, u16 qos, u16 fid);
2819 +int
2820 +hfa384x_cmd_clearpersist(hfa384x_t *hw, u16 fid);
2821 +int
2822 +hfa384x_cmd_access(hfa384x_t *hw, u16 write, u16 rid, void *buf, u16 len);
2823 +int
2824 +hfa384x_cmd_monitor(hfa384x_t *hw, u16 enable);
2825 +int
2826 +hfa384x_cmd_download(
2827 + hfa384x_t *hw,
2828 + u16 mode,
2829 + u16 lowaddr,
2830 + u16 highaddr,
2831 + u16 codelen);
2832 +int
2833 +hfa384x_cmd_aux_enable(hfa384x_t *hw, int force);
2834 +int
2835 +hfa384x_cmd_aux_disable(hfa384x_t *hw);
2836 +int
2837 +hfa384x_copy_from_bap(
2838 + hfa384x_t *hw,
2839 + u16 bap,
2840 + u16 id,
2841 + u16 offset,
2842 + void *buf,
2843 + unsigned int len);
2844 +int
2845 +hfa384x_copy_to_bap(
2846 + hfa384x_t *hw,
2847 + u16 bap,
2848 + u16 id,
2849 + u16 offset,
2850 + void *buf,
2851 + unsigned int len);
2852 +void
2853 +hfa384x_copy_from_aux(
2854 + hfa384x_t *hw,
2855 + u32 cardaddr,
2856 + u32 auxctl,
2857 + void *buf,
2858 + unsigned int len);
2859 +void
2860 +hfa384x_copy_to_aux(
2861 + hfa384x_t *hw,
2862 + u32 cardaddr,
2863 + u32 auxctl,
2864 + void *buf,
2865 + unsigned int len);
2866 +
2867 +#endif /* __KERNEL__ */
2868 +
2869 +#endif /* _HFA384x_H */
2870 --- /dev/null
2871 +++ b/drivers/staging/wlan-ng/hfa384x_usb.c
2872 @@ -0,0 +1,4690 @@
2873 +/* src/prism2/driver/hfa384x_usb.c
2874 +*
2875 +* Functions that talk to the USB variantof the Intersil hfa384x MAC
2876 +*
2877 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
2878 +* --------------------------------------------------------------------
2879 +*
2880 +* linux-wlan
2881 +*
2882 +* The contents of this file are subject to the Mozilla Public
2883 +* License Version 1.1 (the "License"); you may not use this file
2884 +* except in compliance with the License. You may obtain a copy of
2885 +* the License at http://www.mozilla.org/MPL/
2886 +*
2887 +* Software distributed under the License is distributed on an "AS
2888 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
2889 +* implied. See the License for the specific language governing
2890 +* rights and limitations under the License.
2891 +*
2892 +* Alternatively, the contents of this file may be used under the
2893 +* terms of the GNU Public License version 2 (the "GPL"), in which
2894 +* case the provisions of the GPL are applicable instead of the
2895 +* above. If you wish to allow the use of your version of this file
2896 +* only under the terms of the GPL and not to allow others to use
2897 +* your version of this file under the MPL, indicate your decision
2898 +* by deleting the provisions above and replace them with the notice
2899 +* and other provisions required by the GPL. If you do not delete
2900 +* the provisions above, a recipient may use your version of this
2901 +* file under either the MPL or the GPL.
2902 +*
2903 +* --------------------------------------------------------------------
2904 +*
2905 +* Inquiries regarding the linux-wlan Open Source project can be
2906 +* made directly to:
2907 +*
2908 +* AbsoluteValue Systems Inc.
2909 +* info@linux-wlan.com
2910 +* http://www.linux-wlan.com
2911 +*
2912 +* --------------------------------------------------------------------
2913 +*
2914 +* Portions of the development of this software were funded by
2915 +* Intersil Corporation as part of PRISM(R) chipset product development.
2916 +*
2917 +* --------------------------------------------------------------------
2918 +*
2919 +* This file implements functions that correspond to the prism2/hfa384x
2920 +* 802.11 MAC hardware and firmware host interface.
2921 +*
2922 +* The functions can be considered to represent several levels of
2923 +* abstraction. The lowest level functions are simply C-callable wrappers
2924 +* around the register accesses. The next higher level represents C-callable
2925 +* prism2 API functions that match the Intersil documentation as closely
2926 +* as is reasonable. The next higher layer implements common sequences
2927 +* of invokations of the API layer (e.g. write to bap, followed by cmd).
2928 +*
2929 +* Common sequences:
2930 +* hfa384x_drvr_xxx Highest level abstractions provided by the
2931 +* hfa384x code. They are driver defined wrappers
2932 +* for common sequences. These functions generally
2933 +* use the services of the lower levels.
2934 +*
2935 +* hfa384x_drvr_xxxconfig An example of the drvr level abstraction. These
2936 +* functions are wrappers for the RID get/set
2937 +* sequence. They call copy_[to|from]_bap() and
2938 +* cmd_access(). These functions operate on the
2939 +* RIDs and buffers without validation. The caller
2940 +* is responsible for that.
2941 +*
2942 +* API wrapper functions:
2943 +* hfa384x_cmd_xxx functions that provide access to the f/w commands.
2944 +* The function arguments correspond to each command
2945 +* argument, even command arguments that get packed
2946 +* into single registers. These functions _just_
2947 +* issue the command by setting the cmd/parm regs
2948 +* & reading the status/resp regs. Additional
2949 +* activities required to fully use a command
2950 +* (read/write from/to bap, get/set int status etc.)
2951 +* are implemented separately. Think of these as
2952 +* C-callable prism2 commands.
2953 +*
2954 +* Lowest Layer Functions:
2955 +* hfa384x_docmd_xxx These functions implement the sequence required
2956 +* to issue any prism2 command. Primarily used by the
2957 +* hfa384x_cmd_xxx functions.
2958 +*
2959 +* hfa384x_bap_xxx BAP read/write access functions.
2960 +* Note: we usually use BAP0 for non-interrupt context
2961 +* and BAP1 for interrupt context.
2962 +*
2963 +* hfa384x_dl_xxx download related functions.
2964 +*
2965 +* Driver State Issues:
2966 +* Note that there are two pairs of functions that manage the
2967 +* 'initialized' and 'running' states of the hw/MAC combo. The four
2968 +* functions are create(), destroy(), start(), and stop(). create()
2969 +* sets up the data structures required to support the hfa384x_*
2970 +* functions and destroy() cleans them up. The start() function gets
2971 +* the actual hardware running and enables the interrupts. The stop()
2972 +* function shuts the hardware down. The sequence should be:
2973 +* create()
2974 +* start()
2975 +* .
2976 +* . Do interesting things w/ the hardware
2977 +* .
2978 +* stop()
2979 +* destroy()
2980 +*
2981 +* Note that destroy() can be called without calling stop() first.
2982 +* --------------------------------------------------------------------
2983 +*/
2984 +
2985 +/*================================================================*/
2986 +/* System Includes */
2987 +#define WLAN_DBVAR prism2_debug
2988 +
2989 +#include <linux/version.h>
2990 +
2991 +#include <linux/module.h>
2992 +#include <linux/kernel.h>
2993 +#include <linux/sched.h>
2994 +#include <linux/types.h>
2995 +#include <linux/slab.h>
2996 +#include <linux/wireless.h>
2997 +#include <linux/netdevice.h>
2998 +#include <linux/timer.h>
2999 +#include <asm/io.h>
3000 +#include <linux/delay.h>
3001 +#include <asm/byteorder.h>
3002 +#include <asm/bitops.h>
3003 +#include <linux/list.h>
3004 +#include <linux/usb.h>
3005 +
3006 +#include "wlan_compat.h"
3007 +
3008 +#define SUBMIT_URB(u,f) usb_submit_urb(u,f)
3009 +
3010 +/*================================================================*/
3011 +/* Project Includes */
3012 +
3013 +#include "p80211types.h"
3014 +#include "p80211hdr.h"
3015 +#include "p80211mgmt.h"
3016 +#include "p80211conv.h"
3017 +#include "p80211msg.h"
3018 +#include "p80211netdev.h"
3019 +#include "p80211req.h"
3020 +#include "p80211metadef.h"
3021 +#include "p80211metastruct.h"
3022 +#include "hfa384x.h"
3023 +#include "prism2mgmt.h"
3024 +
3025 +/*================================================================*/
3026 +/* Local Constants */
3027 +
3028 +enum cmd_mode
3029 +{
3030 + DOWAIT = 0,
3031 + DOASYNC
3032 +};
3033 +typedef enum cmd_mode CMD_MODE;
3034 +
3035 +#define THROTTLE_JIFFIES (HZ/8)
3036 +
3037 +/*================================================================*/
3038 +/* Local Macros */
3039 +
3040 +#define ROUNDUP64(a) (((a)+63)&~63)
3041 +
3042 +/*================================================================*/
3043 +/* Local Types */
3044 +
3045 +/*================================================================*/
3046 +/* Local Static Definitions */
3047 +extern int prism2_debug;
3048 +
3049 +/*================================================================*/
3050 +/* Local Function Declarations */
3051 +
3052 +#ifdef DEBUG_USB
3053 +static void
3054 +dbprint_urb(struct urb* urb);
3055 +#endif
3056 +
3057 +static void
3058 +hfa384x_int_rxmonitor(
3059 + wlandevice_t *wlandev,
3060 + hfa384x_usb_rxfrm_t *rxfrm);
3061 +
3062 +static void
3063 +hfa384x_usb_defer(struct work_struct *data);
3064 +
3065 +static int
3066 +submit_rx_urb(hfa384x_t *hw, gfp_t flags);
3067 +
3068 +static int
3069 +submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t flags);
3070 +
3071 +/*---------------------------------------------------*/
3072 +/* Callbacks */
3073 +static void
3074 +hfa384x_usbout_callback(struct urb *urb);
3075 +static void
3076 +hfa384x_ctlxout_callback(struct urb *urb);
3077 +static void
3078 +hfa384x_usbin_callback(struct urb *urb);
3079 +
3080 +static void
3081 +hfa384x_usbin_txcompl(wlandevice_t *wlandev, hfa384x_usbin_t *usbin);
3082 +
3083 +static void
3084 +hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb);
3085 +
3086 +static void
3087 +hfa384x_usbin_info(wlandevice_t *wlandev, hfa384x_usbin_t *usbin);
3088 +
3089 +static void
3090 +hfa384x_usbout_tx(wlandevice_t *wlandev, hfa384x_usbout_t *usbout);
3091 +
3092 +static void hfa384x_usbin_ctlx(hfa384x_t *hw, hfa384x_usbin_t *usbin,
3093 + int urb_status);
3094 +
3095 +/*---------------------------------------------------*/
3096 +/* Functions to support the prism2 usb command queue */
3097 +
3098 +static void
3099 +hfa384x_usbctlxq_run(hfa384x_t *hw);
3100 +
3101 +static void
3102 +hfa384x_usbctlx_reqtimerfn(unsigned long data);
3103 +
3104 +static void
3105 +hfa384x_usbctlx_resptimerfn(unsigned long data);
3106 +
3107 +static void
3108 +hfa384x_usb_throttlefn(unsigned long data);
3109 +
3110 +static void
3111 +hfa384x_usbctlx_completion_task(unsigned long data);
3112 +
3113 +static void
3114 +hfa384x_usbctlx_reaper_task(unsigned long data);
3115 +
3116 +static int
3117 +hfa384x_usbctlx_submit(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
3118 +
3119 +static void
3120 +unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
3121 +
3122 +struct usbctlx_completor
3123 +{
3124 + int (*complete)(struct usbctlx_completor*);
3125 +};
3126 +typedef struct usbctlx_completor usbctlx_completor_t;
3127 +
3128 +static int
3129 +hfa384x_usbctlx_complete_sync(hfa384x_t *hw,
3130 + hfa384x_usbctlx_t *ctlx,
3131 + usbctlx_completor_t *completor);
3132 +
3133 +static int
3134 +unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
3135 +
3136 +static void
3137 +hfa384x_cb_status(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx);
3138 +
3139 +static void
3140 +hfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx);
3141 +
3142 +static int
3143 +usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp,
3144 + hfa384x_cmdresult_t *result);
3145 +
3146 +static void
3147 +usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp,
3148 + hfa384x_rridresult_t *result);
3149 +
3150 +/*---------------------------------------------------*/
3151 +/* Low level req/resp CTLX formatters and submitters */
3152 +static int
3153 +hfa384x_docmd(
3154 + hfa384x_t *hw,
3155 + CMD_MODE mode,
3156 + hfa384x_metacmd_t *cmd,
3157 + ctlx_cmdcb_t cmdcb,
3158 + ctlx_usercb_t usercb,
3159 + void *usercb_data);
3160 +
3161 +static int
3162 +hfa384x_dorrid(
3163 + hfa384x_t *hw,
3164 + CMD_MODE mode,
3165 + u16 rid,
3166 + void *riddata,
3167 + unsigned int riddatalen,
3168 + ctlx_cmdcb_t cmdcb,
3169 + ctlx_usercb_t usercb,
3170 + void *usercb_data);
3171 +
3172 +static int
3173 +hfa384x_dowrid(
3174 + hfa384x_t *hw,
3175 + CMD_MODE mode,
3176 + u16 rid,
3177 + void *riddata,
3178 + unsigned int riddatalen,
3179 + ctlx_cmdcb_t cmdcb,
3180 + ctlx_usercb_t usercb,
3181 + void *usercb_data);
3182 +
3183 +static int
3184 +hfa384x_dormem(
3185 + hfa384x_t *hw,
3186 + CMD_MODE mode,
3187 + u16 page,
3188 + u16 offset,
3189 + void *data,
3190 + unsigned int len,
3191 + ctlx_cmdcb_t cmdcb,
3192 + ctlx_usercb_t usercb,
3193 + void *usercb_data);
3194 +
3195 +static int
3196 +hfa384x_dowmem(
3197 + hfa384x_t *hw,
3198 + CMD_MODE mode,
3199 + u16 page,
3200 + u16 offset,
3201 + void *data,
3202 + unsigned int len,
3203 + ctlx_cmdcb_t cmdcb,
3204 + ctlx_usercb_t usercb,
3205 + void *usercb_data);
3206 +
3207 +static int
3208 +hfa384x_isgood_pdrcode(u16 pdrcode);
3209 +
3210 +/*================================================================*/
3211 +/* Function Definitions */
3212 +static inline const char* ctlxstr(CTLX_STATE s)
3213 +{
3214 + static const char* ctlx_str[] = {
3215 + "Initial state",
3216 + "Complete",
3217 + "Request failed",
3218 + "Request pending",
3219 + "Request packet submitted",
3220 + "Request packet completed",
3221 + "Response packet completed"
3222 + };
3223 +
3224 + return ctlx_str[s];
3225 +};
3226 +
3227 +
3228 +static inline hfa384x_usbctlx_t*
3229 +get_active_ctlx(hfa384x_t *hw)
3230 +{
3231 + return list_entry(hw->ctlxq.active.next, hfa384x_usbctlx_t, list);
3232 +}
3233 +
3234 +
3235 +#ifdef DEBUG_USB
3236 +void
3237 +dbprint_urb(struct urb* urb)
3238 +{
3239 + WLAN_LOG_DEBUG(3,"urb->pipe=0x%08x\n", urb->pipe);
3240 + WLAN_LOG_DEBUG(3,"urb->status=0x%08x\n", urb->status);
3241 + WLAN_LOG_DEBUG(3,"urb->transfer_flags=0x%08x\n", urb->transfer_flags);
3242 + WLAN_LOG_DEBUG(3,"urb->transfer_buffer=0x%08x\n", (unsigned int)urb->transfer_buffer);
3243 + WLAN_LOG_DEBUG(3,"urb->transfer_buffer_length=0x%08x\n", urb->transfer_buffer_length);
3244 + WLAN_LOG_DEBUG(3,"urb->actual_length=0x%08x\n", urb->actual_length);
3245 + WLAN_LOG_DEBUG(3,"urb->bandwidth=0x%08x\n", urb->bandwidth);
3246 + WLAN_LOG_DEBUG(3,"urb->setup_packet(ctl)=0x%08x\n", (unsigned int)urb->setup_packet);
3247 + WLAN_LOG_DEBUG(3,"urb->start_frame(iso/irq)=0x%08x\n", urb->start_frame);
3248 + WLAN_LOG_DEBUG(3,"urb->interval(irq)=0x%08x\n", urb->interval);
3249 + WLAN_LOG_DEBUG(3,"urb->error_count(iso)=0x%08x\n", urb->error_count);
3250 + WLAN_LOG_DEBUG(3,"urb->timeout=0x%08x\n", urb->timeout);
3251 + WLAN_LOG_DEBUG(3,"urb->context=0x%08x\n", (unsigned int)urb->context);
3252 + WLAN_LOG_DEBUG(3,"urb->complete=0x%08x\n", (unsigned int)urb->complete);
3253 +}
3254 +#endif
3255 +
3256 +
3257 +/*----------------------------------------------------------------
3258 +* submit_rx_urb
3259 +*
3260 +* Listen for input data on the BULK-IN pipe. If the pipe has
3261 +* stalled then schedule it to be reset.
3262 +*
3263 +* Arguments:
3264 +* hw device struct
3265 +* memflags memory allocation flags
3266 +*
3267 +* Returns:
3268 +* error code from submission
3269 +*
3270 +* Call context:
3271 +* Any
3272 +----------------------------------------------------------------*/
3273 +static int
3274 +submit_rx_urb(hfa384x_t *hw, gfp_t memflags)
3275 +{
3276 + struct sk_buff *skb;
3277 + int result;
3278 +
3279 + DBFENTER;
3280 +
3281 + skb = dev_alloc_skb(sizeof(hfa384x_usbin_t));
3282 + if (skb == NULL) {
3283 + result = -ENOMEM;
3284 + goto done;
3285 + }
3286 +
3287 + /* Post the IN urb */
3288 + usb_fill_bulk_urb(&hw->rx_urb, hw->usb,
3289 + hw->endp_in,
3290 + skb->data, sizeof(hfa384x_usbin_t),
3291 + hfa384x_usbin_callback, hw->wlandev);
3292 +
3293 + hw->rx_urb_skb = skb;
3294 +
3295 + result = -ENOLINK;
3296 + if ( !hw->wlandev->hwremoved && !test_bit(WORK_RX_HALT, &hw->usb_flags)) {
3297 + result = SUBMIT_URB(&hw->rx_urb, memflags);
3298 +
3299 + /* Check whether we need to reset the RX pipe */
3300 + if (result == -EPIPE) {
3301 + WLAN_LOG_WARNING("%s rx pipe stalled: requesting reset\n",
3302 + hw->wlandev->netdev->name);
3303 + if ( !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags) )
3304 + schedule_work(&hw->usb_work);
3305 + }
3306 + }
3307 +
3308 + /* Don't leak memory if anything should go wrong */
3309 + if (result != 0) {
3310 + dev_kfree_skb(skb);
3311 + hw->rx_urb_skb = NULL;
3312 + }
3313 +
3314 + done:
3315 +
3316 + DBFEXIT;
3317 + return result;
3318 +}
3319 +
3320 +/*----------------------------------------------------------------
3321 +* submit_tx_urb
3322 +*
3323 +* Prepares and submits the URB of transmitted data. If the
3324 +* submission fails then it will schedule the output pipe to
3325 +* be reset.
3326 +*
3327 +* Arguments:
3328 +* hw device struct
3329 +* tx_urb URB of data for tranmission
3330 +* memflags memory allocation flags
3331 +*
3332 +* Returns:
3333 +* error code from submission
3334 +*
3335 +* Call context:
3336 +* Any
3337 +----------------------------------------------------------------*/
3338 +static int
3339 +submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t memflags)
3340 +{
3341 + struct net_device *netdev = hw->wlandev->netdev;
3342 + int result;
3343 +
3344 + DBFENTER;
3345 +
3346 + result = -ENOLINK;
3347 + if ( netif_running(netdev) ) {
3348 +
3349 + if ( !hw->wlandev->hwremoved && !test_bit(WORK_TX_HALT, &hw->usb_flags) ) {
3350 + result = SUBMIT_URB(tx_urb, memflags);
3351 +
3352 + /* Test whether we need to reset the TX pipe */
3353 + if (result == -EPIPE) {
3354 + WLAN_LOG_WARNING("%s tx pipe stalled: requesting reset\n",
3355 + netdev->name);
3356 + set_bit(WORK_TX_HALT, &hw->usb_flags);
3357 + schedule_work(&hw->usb_work);
3358 + } else if (result == 0) {
3359 + netif_stop_queue(netdev);
3360 + }
3361 + }
3362 + }
3363 +
3364 + DBFEXIT;
3365 +
3366 + return result;
3367 +}
3368 +
3369 +/*----------------------------------------------------------------
3370 +* hfa394x_usb_defer
3371 +*
3372 +* There are some things that the USB stack cannot do while
3373 +* in interrupt context, so we arrange this function to run
3374 +* in process context.
3375 +*
3376 +* Arguments:
3377 +* hw device structure
3378 +*
3379 +* Returns:
3380 +* nothing
3381 +*
3382 +* Call context:
3383 +* process (by design)
3384 +----------------------------------------------------------------*/
3385 +static void
3386 +hfa384x_usb_defer(struct work_struct *data)
3387 +{
3388 + hfa384x_t *hw = container_of(data, struct hfa384x, usb_work);
3389 + struct net_device *netdev = hw->wlandev->netdev;
3390 +
3391 + DBFENTER;
3392 +
3393 + /* Don't bother trying to reset anything if the plug
3394 + * has been pulled ...
3395 + */
3396 + if ( hw->wlandev->hwremoved ) {
3397 + DBFEXIT;
3398 + return;
3399 + }
3400 +
3401 + /* Reception has stopped: try to reset the input pipe */
3402 + if (test_bit(WORK_RX_HALT, &hw->usb_flags)) {
3403 + int ret;
3404 +
3405 + usb_kill_urb(&hw->rx_urb); /* Cannot be holding spinlock! */
3406 +
3407 + ret = usb_clear_halt(hw->usb, hw->endp_in);
3408 + if (ret != 0) {
3409 + printk(KERN_ERR
3410 + "Failed to clear rx pipe for %s: err=%d\n",
3411 + netdev->name, ret);
3412 + } else {
3413 + printk(KERN_INFO "%s rx pipe reset complete.\n",
3414 + netdev->name);
3415 + clear_bit(WORK_RX_HALT, &hw->usb_flags);
3416 + set_bit(WORK_RX_RESUME, &hw->usb_flags);
3417 + }
3418 + }
3419 +
3420 + /* Resume receiving data back from the device. */
3421 + if ( test_bit(WORK_RX_RESUME, &hw->usb_flags) ) {
3422 + int ret;
3423 +
3424 + ret = submit_rx_urb(hw, GFP_KERNEL);
3425 + if (ret != 0) {
3426 + printk(KERN_ERR
3427 + "Failed to resume %s rx pipe.\n", netdev->name);
3428 + } else {
3429 + clear_bit(WORK_RX_RESUME, &hw->usb_flags);
3430 + }
3431 + }
3432 +
3433 + /* Transmission has stopped: try to reset the output pipe */
3434 + if (test_bit(WORK_TX_HALT, &hw->usb_flags)) {
3435 + int ret;
3436 +
3437 + usb_kill_urb(&hw->tx_urb);
3438 + ret = usb_clear_halt(hw->usb, hw->endp_out);
3439 + if (ret != 0) {
3440 + printk(KERN_ERR
3441 + "Failed to clear tx pipe for %s: err=%d\n",
3442 + netdev->name, ret);
3443 + } else {
3444 + printk(KERN_INFO "%s tx pipe reset complete.\n",
3445 + netdev->name);
3446 + clear_bit(WORK_TX_HALT, &hw->usb_flags);
3447 + set_bit(WORK_TX_RESUME, &hw->usb_flags);
3448 +
3449 + /* Stopping the BULK-OUT pipe also blocked
3450 + * us from sending any more CTLX URBs, so
3451 + * we need to re-run our queue ...
3452 + */
3453 + hfa384x_usbctlxq_run(hw);
3454 + }
3455 + }
3456 +
3457 + /* Resume transmitting. */
3458 + if ( test_and_clear_bit(WORK_TX_RESUME, &hw->usb_flags) ) {
3459 + netif_wake_queue(hw->wlandev->netdev);
3460 + }
3461 +
3462 + DBFEXIT;
3463 +}
3464 +
3465 +
3466 +/*----------------------------------------------------------------
3467 +* hfa384x_create
3468 +*
3469 +* Sets up the hfa384x_t data structure for use. Note this
3470 +* does _not_ intialize the actual hardware, just the data structures
3471 +* we use to keep track of its state.
3472 +*
3473 +* Arguments:
3474 +* hw device structure
3475 +* irq device irq number
3476 +* iobase i/o base address for register access
3477 +* membase memory base address for register access
3478 +*
3479 +* Returns:
3480 +* nothing
3481 +*
3482 +* Side effects:
3483 +*
3484 +* Call context:
3485 +* process
3486 +----------------------------------------------------------------*/
3487 +void
3488 +hfa384x_create( hfa384x_t *hw, struct usb_device *usb)
3489 +{
3490 + DBFENTER;
3491 +
3492 + memset(hw, 0, sizeof(hfa384x_t));
3493 + hw->usb = usb;
3494 +
3495 + /* set up the endpoints */
3496 + hw->endp_in = usb_rcvbulkpipe(usb, 1);
3497 + hw->endp_out = usb_sndbulkpipe(usb, 2);
3498 +
3499 + /* Set up the waitq */
3500 + init_waitqueue_head(&hw->cmdq);
3501 +
3502 + /* Initialize the command queue */
3503 + spin_lock_init(&hw->ctlxq.lock);
3504 + INIT_LIST_HEAD(&hw->ctlxq.pending);
3505 + INIT_LIST_HEAD(&hw->ctlxq.active);
3506 + INIT_LIST_HEAD(&hw->ctlxq.completing);
3507 + INIT_LIST_HEAD(&hw->ctlxq.reapable);
3508 +
3509 + /* Initialize the authentication queue */
3510 + skb_queue_head_init(&hw->authq);
3511 +
3512 + tasklet_init(&hw->reaper_bh,
3513 + hfa384x_usbctlx_reaper_task,
3514 + (unsigned long)hw);
3515 + tasklet_init(&hw->completion_bh,
3516 + hfa384x_usbctlx_completion_task,
3517 + (unsigned long)hw);
3518 + INIT_WORK(&hw->link_bh, prism2sta_processing_defer);
3519 + INIT_WORK(&hw->usb_work, hfa384x_usb_defer);
3520 +
3521 + init_timer(&hw->throttle);
3522 + hw->throttle.function = hfa384x_usb_throttlefn;
3523 + hw->throttle.data = (unsigned long)hw;
3524 +
3525 + init_timer(&hw->resptimer);
3526 + hw->resptimer.function = hfa384x_usbctlx_resptimerfn;
3527 + hw->resptimer.data = (unsigned long)hw;
3528 +
3529 + init_timer(&hw->reqtimer);
3530 + hw->reqtimer.function = hfa384x_usbctlx_reqtimerfn;
3531 + hw->reqtimer.data = (unsigned long)hw;
3532 +
3533 + usb_init_urb(&hw->rx_urb);
3534 + usb_init_urb(&hw->tx_urb);
3535 + usb_init_urb(&hw->ctlx_urb);
3536 +
3537 + hw->link_status = HFA384x_LINK_NOTCONNECTED;
3538 + hw->state = HFA384x_STATE_INIT;
3539 +
3540 + INIT_WORK(&hw->commsqual_bh, prism2sta_commsqual_defer);
3541 + init_timer(&hw->commsqual_timer);
3542 + hw->commsqual_timer.data = (unsigned long) hw;
3543 + hw->commsqual_timer.function = prism2sta_commsqual_timer;
3544 +
3545 + DBFEXIT;
3546 +}
3547 +
3548 +
3549 +/*----------------------------------------------------------------
3550 +* hfa384x_destroy
3551 +*
3552 +* Partner to hfa384x_create(). This function cleans up the hw
3553 +* structure so that it can be freed by the caller using a simple
3554 +* kfree. Currently, this function is just a placeholder. If, at some
3555 +* point in the future, an hw in the 'shutdown' state requires a 'deep'
3556 +* kfree, this is where it should be done. Note that if this function
3557 +* is called on a _running_ hw structure, the drvr_stop() function is
3558 +* called.
3559 +*
3560 +* Arguments:
3561 +* hw device structure
3562 +*
3563 +* Returns:
3564 +* nothing, this function is not allowed to fail.
3565 +*
3566 +* Side effects:
3567 +*
3568 +* Call context:
3569 +* process
3570 +----------------------------------------------------------------*/
3571 +void
3572 +hfa384x_destroy( hfa384x_t *hw)
3573 +{
3574 + struct sk_buff *skb;
3575 +
3576 + DBFENTER;
3577 +
3578 + if ( hw->state == HFA384x_STATE_RUNNING ) {
3579 + hfa384x_drvr_stop(hw);
3580 + }
3581 + hw->state = HFA384x_STATE_PREINIT;
3582 +
3583 + if (hw->scanresults) {
3584 + kfree(hw->scanresults);
3585 + hw->scanresults = NULL;
3586 + }
3587 +
3588 + /* Now to clean out the auth queue */
3589 + while ( (skb = skb_dequeue(&hw->authq)) ) {
3590 + dev_kfree_skb(skb);
3591 + }
3592 +
3593 + DBFEXIT;
3594 +}
3595 +
3596 +
3597 +/*----------------------------------------------------------------
3598 + */
3599 +static hfa384x_usbctlx_t* usbctlx_alloc(void)
3600 +{
3601 + hfa384x_usbctlx_t *ctlx;
3602 +
3603 + ctlx = kmalloc(sizeof(*ctlx), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
3604 + if (ctlx != NULL)
3605 + {
3606 + memset(ctlx, 0, sizeof(*ctlx));
3607 + init_completion(&ctlx->done);
3608 + }
3609 +
3610 + return ctlx;
3611 +}
3612 +
3613 +
3614 +/*----------------------------------------------------------------
3615 + *
3616 +----------------------------------------------------------------*/
3617 +static int
3618 +usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp,
3619 + hfa384x_cmdresult_t *result)
3620 +{
3621 + DBFENTER;
3622 +
3623 + result->status = hfa384x2host_16(cmdresp->status);
3624 + result->resp0 = hfa384x2host_16(cmdresp->resp0);
3625 + result->resp1 = hfa384x2host_16(cmdresp->resp1);
3626 + result->resp2 = hfa384x2host_16(cmdresp->resp2);
3627 +
3628 + WLAN_LOG_DEBUG(4, "cmdresult:status=0x%04x "
3629 + "resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
3630 + result->status,
3631 + result->resp0,
3632 + result->resp1,
3633 + result->resp2);
3634 +
3635 + DBFEXIT;
3636 + return (result->status & HFA384x_STATUS_RESULT);
3637 +}
3638 +
3639 +static void
3640 +usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp,
3641 + hfa384x_rridresult_t *result)
3642 +{
3643 + DBFENTER;
3644 +
3645 + result->rid = hfa384x2host_16(rridresp->rid);
3646 + result->riddata = rridresp->data;
3647 + result->riddata_len = ((hfa384x2host_16(rridresp->frmlen) - 1) * 2);
3648 +
3649 + DBFEXIT;
3650 +}
3651 +
3652 +
3653 +/*----------------------------------------------------------------
3654 +* Completor object:
3655 +* This completor must be passed to hfa384x_usbctlx_complete_sync()
3656 +* when processing a CTLX that returns a hfa384x_cmdresult_t structure.
3657 +----------------------------------------------------------------*/
3658 +struct usbctlx_cmd_completor
3659 +{
3660 + usbctlx_completor_t head;
3661 +
3662 + const hfa384x_usb_cmdresp_t *cmdresp;
3663 + hfa384x_cmdresult_t *result;
3664 +};
3665 +typedef struct usbctlx_cmd_completor usbctlx_cmd_completor_t;
3666 +
3667 +static int usbctlx_cmd_completor_fn(usbctlx_completor_t *head)
3668 +{
3669 + usbctlx_cmd_completor_t *complete = (usbctlx_cmd_completor_t*)head;
3670 + return usbctlx_get_status(complete->cmdresp, complete->result);
3671 +}
3672 +
3673 +static inline usbctlx_completor_t*
3674 +init_cmd_completor(usbctlx_cmd_completor_t *completor,
3675 + const hfa384x_usb_cmdresp_t *cmdresp,
3676 + hfa384x_cmdresult_t *result)
3677 +{
3678 + completor->head.complete = usbctlx_cmd_completor_fn;
3679 + completor->cmdresp = cmdresp;
3680 + completor->result = result;
3681 + return &(completor->head);
3682 +}
3683 +
3684 +/*----------------------------------------------------------------
3685 +* Completor object:
3686 +* This completor must be passed to hfa384x_usbctlx_complete_sync()
3687 +* when processing a CTLX that reads a RID.
3688 +----------------------------------------------------------------*/
3689 +struct usbctlx_rrid_completor
3690 +{
3691 + usbctlx_completor_t head;
3692 +
3693 + const hfa384x_usb_rridresp_t *rridresp;
3694 + void *riddata;
3695 + unsigned int riddatalen;
3696 +};
3697 +typedef struct usbctlx_rrid_completor usbctlx_rrid_completor_t;
3698 +
3699 +static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head)
3700 +{
3701 + usbctlx_rrid_completor_t *complete = (usbctlx_rrid_completor_t*)head;
3702 + hfa384x_rridresult_t rridresult;
3703 +
3704 + usbctlx_get_rridresult(complete->rridresp, &rridresult);
3705 +
3706 + /* Validate the length, note body len calculation in bytes */
3707 + if ( rridresult.riddata_len != complete->riddatalen ) {
3708 + WLAN_LOG_WARNING(
3709 + "RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n",
3710 + rridresult.rid,
3711 + complete->riddatalen,
3712 + rridresult.riddata_len);
3713 + return -ENODATA;
3714 + }
3715 +
3716 + memcpy(complete->riddata,
3717 + rridresult.riddata,
3718 + complete->riddatalen);
3719 + return 0;
3720 +}
3721 +
3722 +static inline usbctlx_completor_t*
3723 +init_rrid_completor(usbctlx_rrid_completor_t *completor,
3724 + const hfa384x_usb_rridresp_t *rridresp,
3725 + void *riddata,
3726 + unsigned int riddatalen)
3727 +{
3728 + completor->head.complete = usbctlx_rrid_completor_fn;
3729 + completor->rridresp = rridresp;
3730 + completor->riddata = riddata;
3731 + completor->riddatalen = riddatalen;
3732 + return &(completor->head);
3733 +}
3734 +
3735 +/*----------------------------------------------------------------
3736 +* Completor object:
3737 +* Interprets the results of a synchronous RID-write
3738 +----------------------------------------------------------------*/
3739 +typedef usbctlx_cmd_completor_t usbctlx_wrid_completor_t;
3740 +#define init_wrid_completor init_cmd_completor
3741 +
3742 +/*----------------------------------------------------------------
3743 +* Completor object:
3744 +* Interprets the results of a synchronous memory-write
3745 +----------------------------------------------------------------*/
3746 +typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t;
3747 +#define init_wmem_completor init_cmd_completor
3748 +
3749 +/*----------------------------------------------------------------
3750 +* Completor object:
3751 +* Interprets the results of a synchronous memory-read
3752 +----------------------------------------------------------------*/
3753 +struct usbctlx_rmem_completor
3754 +{
3755 + usbctlx_completor_t head;
3756 +
3757 + const hfa384x_usb_rmemresp_t *rmemresp;
3758 + void *data;
3759 + unsigned int len;
3760 +};
3761 +typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t;
3762 +
3763 +static int usbctlx_rmem_completor_fn(usbctlx_completor_t *head)
3764 +{
3765 + usbctlx_rmem_completor_t *complete = (usbctlx_rmem_completor_t*)head;
3766 +
3767 + WLAN_LOG_DEBUG(4,"rmemresp:len=%d\n", complete->rmemresp->frmlen);
3768 + memcpy(complete->data, complete->rmemresp->data, complete->len);
3769 + return 0;
3770 +}
3771 +
3772 +static inline usbctlx_completor_t*
3773 +init_rmem_completor(usbctlx_rmem_completor_t *completor,
3774 + hfa384x_usb_rmemresp_t *rmemresp,
3775 + void *data,
3776 + unsigned int len)
3777 +{
3778 + completor->head.complete = usbctlx_rmem_completor_fn;
3779 + completor->rmemresp = rmemresp;
3780 + completor->data = data;
3781 + completor->len = len;
3782 + return &(completor->head);
3783 +}
3784 +
3785 +/*----------------------------------------------------------------
3786 +* hfa384x_cb_status
3787 +*
3788 +* Ctlx_complete handler for async CMD type control exchanges.
3789 +* mark the hw struct as such.
3790 +*
3791 +* Note: If the handling is changed here, it should probably be
3792 +* changed in docmd as well.
3793 +*
3794 +* Arguments:
3795 +* hw hw struct
3796 +* ctlx completed CTLX
3797 +*
3798 +* Returns:
3799 +* nothing
3800 +*
3801 +* Side effects:
3802 +*
3803 +* Call context:
3804 +* interrupt
3805 +----------------------------------------------------------------*/
3806 +static void
3807 +hfa384x_cb_status(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx)
3808 +{
3809 + DBFENTER;
3810 +
3811 + if ( ctlx->usercb != NULL ) {
3812 + hfa384x_cmdresult_t cmdresult;
3813 +
3814 + if (ctlx->state != CTLX_COMPLETE) {
3815 + memset(&cmdresult, 0, sizeof(cmdresult));
3816 + cmdresult.status = HFA384x_STATUS_RESULT_SET(HFA384x_CMD_ERR);
3817 + } else {
3818 + usbctlx_get_status(&ctlx->inbuf.cmdresp, &cmdresult);
3819 + }
3820 +
3821 + ctlx->usercb(hw, &cmdresult, ctlx->usercb_data);
3822 + }
3823 +
3824 + DBFEXIT;
3825 +}
3826 +
3827 +
3828 +/*----------------------------------------------------------------
3829 +* hfa384x_cb_rrid
3830 +*
3831 +* CTLX completion handler for async RRID type control exchanges.
3832 +*
3833 +* Note: If the handling is changed here, it should probably be
3834 +* changed in dorrid as well.
3835 +*
3836 +* Arguments:
3837 +* hw hw struct
3838 +* ctlx completed CTLX
3839 +*
3840 +* Returns:
3841 +* nothing
3842 +*
3843 +* Side effects:
3844 +*
3845 +* Call context:
3846 +* interrupt
3847 +----------------------------------------------------------------*/
3848 +static void
3849 +hfa384x_cb_rrid(hfa384x_t *hw, const hfa384x_usbctlx_t *ctlx)
3850 +{
3851 + DBFENTER;
3852 +
3853 + if ( ctlx->usercb != NULL ) {
3854 + hfa384x_rridresult_t rridresult;
3855 +
3856 + if (ctlx->state != CTLX_COMPLETE) {
3857 + memset(&rridresult, 0, sizeof(rridresult));
3858 + rridresult.rid = hfa384x2host_16(ctlx->outbuf.rridreq.rid);
3859 + } else {
3860 + usbctlx_get_rridresult(&ctlx->inbuf.rridresp, &rridresult);
3861 + }
3862 +
3863 + ctlx->usercb(hw, &rridresult, ctlx->usercb_data);
3864 + }
3865 +
3866 + DBFEXIT;
3867 +}
3868 +
3869 +static inline int
3870 +hfa384x_docmd_wait(hfa384x_t *hw, hfa384x_metacmd_t *cmd)
3871 +{
3872 + return hfa384x_docmd(hw, DOWAIT, cmd, NULL, NULL, NULL);
3873 +}
3874 +
3875 +static inline int
3876 +hfa384x_docmd_async(hfa384x_t *hw,
3877 + hfa384x_metacmd_t *cmd,
3878 + ctlx_cmdcb_t cmdcb,
3879 + ctlx_usercb_t usercb,
3880 + void *usercb_data)
3881 +{
3882 + return hfa384x_docmd(hw, DOASYNC, cmd,
3883 + cmdcb, usercb, usercb_data);
3884 +}
3885 +
3886 +static inline int
3887 +hfa384x_dorrid_wait(hfa384x_t *hw, u16 rid, void *riddata, unsigned int riddatalen)
3888 +{
3889 + return hfa384x_dorrid(hw, DOWAIT,
3890 + rid, riddata, riddatalen,
3891 + NULL, NULL, NULL);
3892 +}
3893 +
3894 +static inline int
3895 +hfa384x_dorrid_async(hfa384x_t *hw,
3896 + u16 rid, void *riddata, unsigned int riddatalen,
3897 + ctlx_cmdcb_t cmdcb,
3898 + ctlx_usercb_t usercb,
3899 + void *usercb_data)
3900 +{
3901 + return hfa384x_dorrid(hw, DOASYNC,
3902 + rid, riddata, riddatalen,
3903 + cmdcb, usercb, usercb_data);
3904 +}
3905 +
3906 +static inline int
3907 +hfa384x_dowrid_wait(hfa384x_t *hw, u16 rid, void *riddata, unsigned int riddatalen)
3908 +{
3909 + return hfa384x_dowrid(hw, DOWAIT,
3910 + rid, riddata, riddatalen,
3911 + NULL, NULL, NULL);
3912 +}
3913 +
3914 +static inline int
3915 +hfa384x_dowrid_async(hfa384x_t *hw,
3916 + u16 rid, void *riddata, unsigned int riddatalen,
3917 + ctlx_cmdcb_t cmdcb,
3918 + ctlx_usercb_t usercb,
3919 + void *usercb_data)
3920 +{
3921 + return hfa384x_dowrid(hw, DOASYNC,
3922 + rid, riddata, riddatalen,
3923 + cmdcb, usercb, usercb_data);
3924 +}
3925 +
3926 +static inline int
3927 +hfa384x_dormem_wait(hfa384x_t *hw,
3928 + u16 page, u16 offset, void *data, unsigned int len)
3929 +{
3930 + return hfa384x_dormem(hw, DOWAIT,
3931 + page, offset, data, len,
3932 + NULL, NULL, NULL);
3933 +}
3934 +
3935 +static inline int
3936 +hfa384x_dormem_async(hfa384x_t *hw,
3937 + u16 page, u16 offset, void *data, unsigned int len,
3938 + ctlx_cmdcb_t cmdcb,
3939 + ctlx_usercb_t usercb,
3940 + void *usercb_data)
3941 +{
3942 + return hfa384x_dormem(hw, DOASYNC,
3943 + page, offset, data, len,
3944 + cmdcb, usercb, usercb_data);
3945 +}
3946 +
3947 +static inline int
3948 +hfa384x_dowmem_wait(
3949 + hfa384x_t *hw,
3950 + u16 page,
3951 + u16 offset,
3952 + void *data,
3953 + unsigned int len)
3954 +{
3955 + return hfa384x_dowmem(hw, DOWAIT,
3956 + page, offset, data, len,
3957 + NULL, NULL, NULL);
3958 +}
3959 +
3960 +static inline int
3961 +hfa384x_dowmem_async(
3962 + hfa384x_t *hw,
3963 + u16 page,
3964 + u16 offset,
3965 + void *data,
3966 + unsigned int len,
3967 + ctlx_cmdcb_t cmdcb,
3968 + ctlx_usercb_t usercb,
3969 + void *usercb_data)
3970 +{
3971 + return hfa384x_dowmem(hw, DOASYNC,
3972 + page, offset, data, len,
3973 + cmdcb, usercb, usercb_data);
3974 +}
3975 +
3976 +/*----------------------------------------------------------------
3977 +* hfa384x_cmd_initialize
3978 +*
3979 +* Issues the initialize command and sets the hw->state based
3980 +* on the result.
3981 +*
3982 +* Arguments:
3983 +* hw device structure
3984 +*
3985 +* Returns:
3986 +* 0 success
3987 +* >0 f/w reported error - f/w status code
3988 +* <0 driver reported error
3989 +*
3990 +* Side effects:
3991 +*
3992 +* Call context:
3993 +* process
3994 +----------------------------------------------------------------*/
3995 +int
3996 +hfa384x_cmd_initialize(hfa384x_t *hw)
3997 +{
3998 + int result = 0;
3999 + int i;
4000 + hfa384x_metacmd_t cmd;
4001 +
4002 + DBFENTER;
4003 +
4004 +
4005 + cmd.cmd = HFA384x_CMDCODE_INIT;
4006 + cmd.parm0 = 0;
4007 + cmd.parm1 = 0;
4008 + cmd.parm2 = 0;
4009 +
4010 + result = hfa384x_docmd_wait(hw, &cmd);
4011 +
4012 +
4013 + WLAN_LOG_DEBUG(3,"cmdresp.init: "
4014 + "status=0x%04x, resp0=0x%04x, "
4015 + "resp1=0x%04x, resp2=0x%04x\n",
4016 + cmd.result.status,
4017 + cmd.result.resp0,
4018 + cmd.result.resp1,
4019 + cmd.result.resp2);
4020 + if ( result == 0 ) {
4021 + for ( i = 0; i < HFA384x_NUMPORTS_MAX; i++) {
4022 + hw->port_enabled[i] = 0;
4023 + }
4024 + }
4025 +
4026 + hw->link_status = HFA384x_LINK_NOTCONNECTED;
4027 +
4028 + DBFEXIT;
4029 + return result;
4030 +}
4031 +
4032 +
4033 +/*----------------------------------------------------------------
4034 +* hfa384x_cmd_disable
4035 +*
4036 +* Issues the disable command to stop communications on one of
4037 +* the MACs 'ports'.
4038 +*
4039 +* Arguments:
4040 +* hw device structure
4041 +* macport MAC port number (host order)
4042 +*
4043 +* Returns:
4044 +* 0 success
4045 +* >0 f/w reported failure - f/w status code
4046 +* <0 driver reported error (timeout|bad arg)
4047 +*
4048 +* Side effects:
4049 +*
4050 +* Call context:
4051 +* process
4052 +----------------------------------------------------------------*/
4053 +int hfa384x_cmd_disable(hfa384x_t *hw, u16 macport)
4054 +{
4055 + int result = 0;
4056 + hfa384x_metacmd_t cmd;
4057 +
4058 + DBFENTER;
4059 +
4060 + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE) |
4061 + HFA384x_CMD_MACPORT_SET(macport);
4062 + cmd.parm0 = 0;
4063 + cmd.parm1 = 0;
4064 + cmd.parm2 = 0;
4065 +
4066 + result = hfa384x_docmd_wait(hw, &cmd);
4067 +
4068 + DBFEXIT;
4069 + return result;
4070 +}
4071 +
4072 +
4073 +/*----------------------------------------------------------------
4074 +* hfa384x_cmd_enable
4075 +*
4076 +* Issues the enable command to enable communications on one of
4077 +* the MACs 'ports'.
4078 +*
4079 +* Arguments:
4080 +* hw device structure
4081 +* macport MAC port number
4082 +*
4083 +* Returns:
4084 +* 0 success
4085 +* >0 f/w reported failure - f/w status code
4086 +* <0 driver reported error (timeout|bad arg)
4087 +*
4088 +* Side effects:
4089 +*
4090 +* Call context:
4091 +* process
4092 +----------------------------------------------------------------*/
4093 +int hfa384x_cmd_enable(hfa384x_t *hw, u16 macport)
4094 +{
4095 + int result = 0;
4096 + hfa384x_metacmd_t cmd;
4097 +
4098 + DBFENTER;
4099 +
4100 + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE) |
4101 + HFA384x_CMD_MACPORT_SET(macport);
4102 + cmd.parm0 = 0;
4103 + cmd.parm1 = 0;
4104 + cmd.parm2 = 0;
4105 +
4106 + result = hfa384x_docmd_wait(hw, &cmd);
4107 +
4108 + DBFEXIT;
4109 + return result;
4110 +}
4111 +
4112 +/*----------------------------------------------------------------
4113 +* hfa384x_cmd_monitor
4114 +*
4115 +* Enables the 'monitor mode' of the MAC. Here's the description of
4116 +* monitor mode that I've received thus far:
4117 +*
4118 +* "The "monitor mode" of operation is that the MAC passes all
4119 +* frames for which the PLCP checks are correct. All received
4120 +* MPDUs are passed to the host with MAC Port = 7, with a
4121 +* receive status of good, FCS error, or undecryptable. Passing
4122 +* certain MPDUs is a violation of the 802.11 standard, but useful
4123 +* for a debugging tool." Normal communication is not possible
4124 +* while monitor mode is enabled.
4125 +*
4126 +* Arguments:
4127 +* hw device structure
4128 +* enable a code (0x0b|0x0f) that enables/disables
4129 +* monitor mode. (host order)
4130 +*
4131 +* Returns:
4132 +* 0 success
4133 +* >0 f/w reported failure - f/w status code
4134 +* <0 driver reported error (timeout|bad arg)
4135 +*
4136 +* Side effects:
4137 +*
4138 +* Call context:
4139 +* process
4140 +----------------------------------------------------------------*/
4141 +int hfa384x_cmd_monitor(hfa384x_t *hw, u16 enable)
4142 +{
4143 + int result = 0;
4144 + hfa384x_metacmd_t cmd;
4145 +
4146 + DBFENTER;
4147 +
4148 + cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |
4149 + HFA384x_CMD_AINFO_SET(enable);
4150 + cmd.parm0 = 0;
4151 + cmd.parm1 = 0;
4152 + cmd.parm2 = 0;
4153 +
4154 + result = hfa384x_docmd_wait(hw, &cmd);
4155 +
4156 + DBFEXIT;
4157 + return result;
4158 +}
4159 +
4160 +
4161 +/*----------------------------------------------------------------
4162 +* hfa384x_cmd_download
4163 +*
4164 +* Sets the controls for the MAC controller code/data download
4165 +* process. The arguments set the mode and address associated
4166 +* with a download. Note that the aux registers should be enabled
4167 +* prior to setting one of the download enable modes.
4168 +*
4169 +* Arguments:
4170 +* hw device structure
4171 +* mode 0 - Disable programming and begin code exec
4172 +* 1 - Enable volatile mem programming
4173 +* 2 - Enable non-volatile mem programming
4174 +* 3 - Program non-volatile section from NV download
4175 +* buffer.
4176 +* (host order)
4177 +* lowaddr
4178 +* highaddr For mode 1, sets the high & low order bits of
4179 +* the "destination address". This address will be
4180 +* the execution start address when download is
4181 +* subsequently disabled.
4182 +* For mode 2, sets the high & low order bits of
4183 +* the destination in NV ram.
4184 +* For modes 0 & 3, should be zero. (host order)
4185 +* NOTE: these are CMD format.
4186 +* codelen Length of the data to write in mode 2,
4187 +* zero otherwise. (host order)
4188 +*
4189 +* Returns:
4190 +* 0 success
4191 +* >0 f/w reported failure - f/w status code
4192 +* <0 driver reported error (timeout|bad arg)
4193 +*
4194 +* Side effects:
4195 +*
4196 +* Call context:
4197 +* process
4198 +----------------------------------------------------------------*/
4199 +int hfa384x_cmd_download(hfa384x_t *hw, u16 mode, u16 lowaddr,
4200 + u16 highaddr, u16 codelen)
4201 +{
4202 + int result = 0;
4203 + hfa384x_metacmd_t cmd;
4204 +
4205 + DBFENTER;
4206 + WLAN_LOG_DEBUG(5,
4207 + "mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
4208 + mode, lowaddr, highaddr, codelen);
4209 +
4210 + cmd.cmd = (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) |
4211 + HFA384x_CMD_PROGMODE_SET(mode));
4212 +
4213 + cmd.parm0 = lowaddr;
4214 + cmd.parm1 = highaddr;
4215 + cmd.parm2 = codelen;
4216 +
4217 + result = hfa384x_docmd_wait(hw, &cmd);
4218 +
4219 + DBFEXIT;
4220 + return result;
4221 +}
4222 +
4223 +
4224 +/*----------------------------------------------------------------
4225 +* hfa384x_copy_from_aux
4226 +*
4227 +* Copies a collection of bytes from the controller memory. The
4228 +* Auxiliary port MUST be enabled prior to calling this function.
4229 +* We _might_ be in a download state.
4230 +*
4231 +* Arguments:
4232 +* hw device structure
4233 +* cardaddr address in hfa384x data space to read
4234 +* auxctl address space select
4235 +* buf ptr to destination host buffer
4236 +* len length of data to transfer (in bytes)
4237 +*
4238 +* Returns:
4239 +* nothing
4240 +*
4241 +* Side effects:
4242 +* buf contains the data copied
4243 +*
4244 +* Call context:
4245 +* process
4246 +* interrupt
4247 +----------------------------------------------------------------*/
4248 +void
4249 +hfa384x_copy_from_aux(
4250 + hfa384x_t *hw, u32 cardaddr, u32 auxctl, void *buf, unsigned int len)
4251 +{
4252 + DBFENTER;
4253 + WLAN_LOG_ERROR("not used in USB.\n");
4254 + DBFEXIT;
4255 +}
4256 +
4257 +
4258 +/*----------------------------------------------------------------
4259 +* hfa384x_copy_to_aux
4260 +*
4261 +* Copies a collection of bytes to the controller memory. The
4262 +* Auxiliary port MUST be enabled prior to calling this function.
4263 +* We _might_ be in a download state.
4264 +*
4265 +* Arguments:
4266 +* hw device structure
4267 +* cardaddr address in hfa384x data space to read
4268 +* auxctl address space select
4269 +* buf ptr to destination host buffer
4270 +* len length of data to transfer (in bytes)
4271 +*
4272 +* Returns:
4273 +* nothing
4274 +*
4275 +* Side effects:
4276 +* Controller memory now contains a copy of buf
4277 +*
4278 +* Call context:
4279 +* process
4280 +* interrupt
4281 +----------------------------------------------------------------*/
4282 +void
4283 +hfa384x_copy_to_aux(
4284 + hfa384x_t *hw, u32 cardaddr, u32 auxctl, void *buf, unsigned int len)
4285 +{
4286 + DBFENTER;
4287 + WLAN_LOG_ERROR("not used in USB.\n");
4288 + DBFEXIT;
4289 +}
4290 +
4291 +
4292 +/*----------------------------------------------------------------
4293 +* hfa384x_corereset
4294 +*
4295 +* Perform a reset of the hfa38xx MAC core. We assume that the hw
4296 +* structure is in its "created" state. That is, it is initialized
4297 +* with proper values. Note that if a reset is done after the
4298 +* device has been active for awhile, the caller might have to clean
4299 +* up some leftover cruft in the hw structure.
4300 +*
4301 +* Arguments:
4302 +* hw device structure
4303 +* holdtime how long (in ms) to hold the reset
4304 +* settletime how long (in ms) to wait after releasing
4305 +* the reset
4306 +*
4307 +* Returns:
4308 +* nothing
4309 +*
4310 +* Side effects:
4311 +*
4312 +* Call context:
4313 +* process
4314 +----------------------------------------------------------------*/
4315 +int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis)
4316 +{
4317 + int result = 0;
4318 +
4319 + DBFENTER;
4320 +
4321 + result=usb_reset_device(hw->usb);
4322 + if(result<0) {
4323 + WLAN_LOG_ERROR("usb_reset_device() failed, result=%d.\n",result);
4324 + }
4325 +
4326 + DBFEXIT;
4327 + return result;
4328 +}
4329 +
4330 +
4331 +/*----------------------------------------------------------------
4332 +* hfa384x_usbctlx_complete_sync
4333 +*
4334 +* Waits for a synchronous CTLX object to complete,
4335 +* and then handles the response.
4336 +*
4337 +* Arguments:
4338 +* hw device structure
4339 +* ctlx CTLX ptr
4340 +* completor functor object to decide what to
4341 +* do with the CTLX's result.
4342 +*
4343 +* Returns:
4344 +* 0 Success
4345 +* -ERESTARTSYS Interrupted by a signal
4346 +* -EIO CTLX failed
4347 +* -ENODEV Adapter was unplugged
4348 +* ??? Result from completor
4349 +*
4350 +* Side effects:
4351 +*
4352 +* Call context:
4353 +* process
4354 +----------------------------------------------------------------*/
4355 +static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw,
4356 + hfa384x_usbctlx_t *ctlx,
4357 + usbctlx_completor_t *completor)
4358 +{
4359 + unsigned long flags;
4360 + int result;
4361 +
4362 + DBFENTER;
4363 +
4364 + result = wait_for_completion_interruptible(&ctlx->done);
4365 +
4366 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
4367 +
4368 + /*
4369 + * We can only handle the CTLX if the USB disconnect
4370 + * function has not run yet ...
4371 + */
4372 + cleanup:
4373 + if ( hw->wlandev->hwremoved )
4374 + {
4375 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4376 + result = -ENODEV;
4377 + }
4378 + else if ( result != 0 )
4379 + {
4380 + int runqueue = 0;
4381 +
4382 + /*
4383 + * We were probably interrupted, so delete
4384 + * this CTLX asynchronously, kill the timers
4385 + * and the URB, and then start the next
4386 + * pending CTLX.
4387 + *
4388 + * NOTE: We can only delete the timers and
4389 + * the URB if this CTLX is active.
4390 + */
4391 + if (ctlx == get_active_ctlx(hw))
4392 + {
4393 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4394 +
4395 + del_singleshot_timer_sync(&hw->reqtimer);
4396 + del_singleshot_timer_sync(&hw->resptimer);
4397 + hw->req_timer_done = 1;
4398 + hw->resp_timer_done = 1;
4399 + usb_kill_urb(&hw->ctlx_urb);
4400 +
4401 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
4402 +
4403 + runqueue = 1;
4404 +
4405 + /*
4406 + * This scenario is so unlikely that I'm
4407 + * happy with a grubby "goto" solution ...
4408 + */
4409 + if ( hw->wlandev->hwremoved )
4410 + goto cleanup;
4411 + }
4412 +
4413 + /*
4414 + * The completion task will send this CTLX
4415 + * to the reaper the next time it runs. We
4416 + * are no longer in a hurry.
4417 + */
4418 + ctlx->reapable = 1;
4419 + ctlx->state = CTLX_REQ_FAILED;
4420 + list_move_tail(&ctlx->list, &hw->ctlxq.completing);
4421 +
4422 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4423 +
4424 + if (runqueue)
4425 + hfa384x_usbctlxq_run(hw);
4426 + } else {
4427 + if (ctlx->state == CTLX_COMPLETE) {
4428 + result = completor->complete(completor);
4429 + } else {
4430 + WLAN_LOG_WARNING("CTLX[%d] error: state(%s)\n",
4431 + hfa384x2host_16(ctlx->outbuf.type),
4432 + ctlxstr(ctlx->state));
4433 + result = -EIO;
4434 + }
4435 +
4436 + list_del(&ctlx->list);
4437 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
4438 + kfree(ctlx);
4439 + }
4440 +
4441 + DBFEXIT;
4442 + return result;
4443 +}
4444 +
4445 +/*----------------------------------------------------------------
4446 +* hfa384x_docmd
4447 +*
4448 +* Constructs a command CTLX and submits it.
4449 +*
4450 +* NOTE: Any changes to the 'post-submit' code in this function
4451 +* need to be carried over to hfa384x_cbcmd() since the handling
4452 +* is virtually identical.
4453 +*
4454 +* Arguments:
4455 +* hw device structure
4456 +* mode DOWAIT or DOASYNC
4457 +* cmd cmd structure. Includes all arguments and result
4458 +* data points. All in host order. in host order
4459 +* cmdcb command-specific callback
4460 +* usercb user callback for async calls, NULL for DOWAIT calls
4461 +* usercb_data user supplied data pointer for async calls, NULL
4462 +* for DOASYNC calls
4463 +*
4464 +* Returns:
4465 +* 0 success
4466 +* -EIO CTLX failure
4467 +* -ERESTARTSYS Awakened on signal
4468 +* >0 command indicated error, Status and Resp0-2 are
4469 +* in hw structure.
4470 +*
4471 +* Side effects:
4472 +*
4473 +*
4474 +* Call context:
4475 +* process
4476 +----------------------------------------------------------------*/
4477 +static int
4478 +hfa384x_docmd(
4479 + hfa384x_t *hw,
4480 + CMD_MODE mode,
4481 + hfa384x_metacmd_t *cmd,
4482 + ctlx_cmdcb_t cmdcb,
4483 + ctlx_usercb_t usercb,
4484 + void *usercb_data)
4485 +{
4486 + int result;
4487 + hfa384x_usbctlx_t *ctlx;
4488 +
4489 + DBFENTER;
4490 + ctlx = usbctlx_alloc();
4491 + if ( ctlx == NULL ) {
4492 + result = -ENOMEM;
4493 + goto done;
4494 + }
4495 +
4496 + /* Initialize the command */
4497 + ctlx->outbuf.cmdreq.type = host2hfa384x_16(HFA384x_USB_CMDREQ);
4498 + ctlx->outbuf.cmdreq.cmd = host2hfa384x_16(cmd->cmd);
4499 + ctlx->outbuf.cmdreq.parm0 = host2hfa384x_16(cmd->parm0);
4500 + ctlx->outbuf.cmdreq.parm1 = host2hfa384x_16(cmd->parm1);
4501 + ctlx->outbuf.cmdreq.parm2 = host2hfa384x_16(cmd->parm2);
4502 +
4503 + ctlx->outbufsize = sizeof(ctlx->outbuf.cmdreq);
4504 +
4505 + WLAN_LOG_DEBUG(4, "cmdreq: cmd=0x%04x "
4506 + "parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
4507 + cmd->cmd,
4508 + cmd->parm0,
4509 + cmd->parm1,
4510 + cmd->parm2);
4511 +
4512 + ctlx->reapable = mode;
4513 + ctlx->cmdcb = cmdcb;
4514 + ctlx->usercb = usercb;
4515 + ctlx->usercb_data = usercb_data;
4516 +
4517 + result = hfa384x_usbctlx_submit(hw, ctlx);
4518 + if (result != 0) {
4519 + kfree(ctlx);
4520 + } else if (mode == DOWAIT) {
4521 + usbctlx_cmd_completor_t completor;
4522 +
4523 + result = hfa384x_usbctlx_complete_sync(
4524 + hw, ctlx, init_cmd_completor(&completor,
4525 + &ctlx->inbuf.cmdresp,
4526 + &cmd->result) );
4527 + }
4528 +
4529 +done:
4530 + DBFEXIT;
4531 + return result;
4532 +}
4533 +
4534 +
4535 +/*----------------------------------------------------------------
4536 +* hfa384x_dorrid
4537 +*
4538 +* Constructs a read rid CTLX and issues it.
4539 +*
4540 +* NOTE: Any changes to the 'post-submit' code in this function
4541 +* need to be carried over to hfa384x_cbrrid() since the handling
4542 +* is virtually identical.
4543 +*
4544 +* Arguments:
4545 +* hw device structure
4546 +* mode DOWAIT or DOASYNC
4547 +* rid Read RID number (host order)
4548 +* riddata Caller supplied buffer that MAC formatted RID.data
4549 +* record will be written to for DOWAIT calls. Should
4550 +* be NULL for DOASYNC calls.
4551 +* riddatalen Buffer length for DOWAIT calls. Zero for DOASYNC calls.
4552 +* cmdcb command callback for async calls, NULL for DOWAIT calls
4553 +* usercb user callback for async calls, NULL for DOWAIT calls
4554 +* usercb_data user supplied data pointer for async calls, NULL
4555 +* for DOWAIT calls
4556 +*
4557 +* Returns:
4558 +* 0 success
4559 +* -EIO CTLX failure
4560 +* -ERESTARTSYS Awakened on signal
4561 +* -ENODATA riddatalen != macdatalen
4562 +* >0 command indicated error, Status and Resp0-2 are
4563 +* in hw structure.
4564 +*
4565 +* Side effects:
4566 +*
4567 +* Call context:
4568 +* interrupt (DOASYNC)
4569 +* process (DOWAIT or DOASYNC)
4570 +----------------------------------------------------------------*/
4571 +static int
4572 +hfa384x_dorrid(
4573 + hfa384x_t *hw,
4574 + CMD_MODE mode,
4575 + u16 rid,
4576 + void *riddata,
4577 + unsigned int riddatalen,
4578 + ctlx_cmdcb_t cmdcb,
4579 + ctlx_usercb_t usercb,
4580 + void *usercb_data)
4581 +{
4582 + int result;
4583 + hfa384x_usbctlx_t *ctlx;
4584 +
4585 + DBFENTER;
4586 + ctlx = usbctlx_alloc();
4587 + if ( ctlx == NULL ) {
4588 + result = -ENOMEM;
4589 + goto done;
4590 + }
4591 +
4592 + /* Initialize the command */
4593 + ctlx->outbuf.rridreq.type = host2hfa384x_16(HFA384x_USB_RRIDREQ);
4594 + ctlx->outbuf.rridreq.frmlen =
4595 + host2hfa384x_16(sizeof(ctlx->outbuf.rridreq.rid));
4596 + ctlx->outbuf.rridreq.rid = host2hfa384x_16(rid);
4597 +
4598 + ctlx->outbufsize = sizeof(ctlx->outbuf.rridreq);
4599 +
4600 + ctlx->reapable = mode;
4601 + ctlx->cmdcb = cmdcb;
4602 + ctlx->usercb = usercb;
4603 + ctlx->usercb_data = usercb_data;
4604 +
4605 + /* Submit the CTLX */
4606 + result = hfa384x_usbctlx_submit(hw, ctlx);
4607 + if (result != 0) {
4608 + kfree(ctlx);
4609 + } else if (mode == DOWAIT) {
4610 + usbctlx_rrid_completor_t completor;
4611 +
4612 + result = hfa384x_usbctlx_complete_sync(
4613 + hw, ctlx, init_rrid_completor(&completor,
4614 + &ctlx->inbuf.rridresp,
4615 + riddata,
4616 + riddatalen) );
4617 + }
4618 +
4619 +done:
4620 + DBFEXIT;
4621 + return result;
4622 +}
4623 +
4624 +
4625 +/*----------------------------------------------------------------
4626 +* hfa384x_dowrid
4627 +*
4628 +* Constructs a write rid CTLX and issues it.
4629 +*
4630 +* NOTE: Any changes to the 'post-submit' code in this function
4631 +* need to be carried over to hfa384x_cbwrid() since the handling
4632 +* is virtually identical.
4633 +*
4634 +* Arguments:
4635 +* hw device structure
4636 +* CMD_MODE DOWAIT or DOASYNC
4637 +* rid RID code
4638 +* riddata Data portion of RID formatted for MAC
4639 +* riddatalen Length of the data portion in bytes
4640 +* cmdcb command callback for async calls, NULL for DOWAIT calls
4641 +* usercb user callback for async calls, NULL for DOWAIT calls
4642 +* usercb_data user supplied data pointer for async calls
4643 +*
4644 +* Returns:
4645 +* 0 success
4646 +* -ETIMEDOUT timed out waiting for register ready or
4647 +* command completion
4648 +* >0 command indicated error, Status and Resp0-2 are
4649 +* in hw structure.
4650 +*
4651 +* Side effects:
4652 +*
4653 +* Call context:
4654 +* interrupt (DOASYNC)
4655 +* process (DOWAIT or DOASYNC)
4656 +----------------------------------------------------------------*/
4657 +static int
4658 +hfa384x_dowrid(
4659 + hfa384x_t *hw,
4660 + CMD_MODE mode,
4661 + u16 rid,
4662 + void *riddata,
4663 + unsigned int riddatalen,
4664 + ctlx_cmdcb_t cmdcb,
4665 + ctlx_usercb_t usercb,
4666 + void *usercb_data)
4667 +{
4668 + int result;
4669 + hfa384x_usbctlx_t *ctlx;
4670 +
4671 + DBFENTER;
4672 + ctlx = usbctlx_alloc();
4673 + if ( ctlx == NULL ) {
4674 + result = -ENOMEM;
4675 + goto done;
4676 + }
4677 +
4678 + /* Initialize the command */
4679 + ctlx->outbuf.wridreq.type = host2hfa384x_16(HFA384x_USB_WRIDREQ);
4680 + ctlx->outbuf.wridreq.frmlen = host2hfa384x_16(
4681 + (sizeof(ctlx->outbuf.wridreq.rid) +
4682 + riddatalen + 1) / 2);
4683 + ctlx->outbuf.wridreq.rid = host2hfa384x_16(rid);
4684 + memcpy(ctlx->outbuf.wridreq.data, riddata, riddatalen);
4685 +
4686 + ctlx->outbufsize = sizeof(ctlx->outbuf.wridreq.type) +
4687 + sizeof(ctlx->outbuf.wridreq.frmlen) +
4688 + sizeof(ctlx->outbuf.wridreq.rid) +
4689 + riddatalen;
4690 +
4691 + ctlx->reapable = mode;
4692 + ctlx->cmdcb = cmdcb;
4693 + ctlx->usercb = usercb;
4694 + ctlx->usercb_data = usercb_data;
4695 +
4696 + /* Submit the CTLX */
4697 + result = hfa384x_usbctlx_submit(hw, ctlx);
4698 + if (result != 0) {
4699 + kfree(ctlx);
4700 + } else if (mode == DOWAIT) {
4701 + usbctlx_wrid_completor_t completor;
4702 + hfa384x_cmdresult_t wridresult;
4703 +
4704 + result = hfa384x_usbctlx_complete_sync(
4705 + hw,
4706 + ctlx,
4707 + init_wrid_completor(&completor,
4708 + &ctlx->inbuf.wridresp,
4709 + &wridresult) );
4710 + }
4711 +
4712 +done:
4713 + DBFEXIT;
4714 + return result;
4715 +}
4716 +
4717 +/*----------------------------------------------------------------
4718 +* hfa384x_dormem
4719 +*
4720 +* Constructs a readmem CTLX and issues it.
4721 +*
4722 +* NOTE: Any changes to the 'post-submit' code in this function
4723 +* need to be carried over to hfa384x_cbrmem() since the handling
4724 +* is virtually identical.
4725 +*
4726 +* Arguments:
4727 +* hw device structure
4728 +* mode DOWAIT or DOASYNC
4729 +* page MAC address space page (CMD format)
4730 +* offset MAC address space offset
4731 +* data Ptr to data buffer to receive read
4732 +* len Length of the data to read (max == 2048)
4733 +* cmdcb command callback for async calls, NULL for DOWAIT calls
4734 +* usercb user callback for async calls, NULL for DOWAIT calls
4735 +* usercb_data user supplied data pointer for async calls
4736 +*
4737 +* Returns:
4738 +* 0 success
4739 +* -ETIMEDOUT timed out waiting for register ready or
4740 +* command completion
4741 +* >0 command indicated error, Status and Resp0-2 are
4742 +* in hw structure.
4743 +*
4744 +* Side effects:
4745 +*
4746 +* Call context:
4747 +* interrupt (DOASYNC)
4748 +* process (DOWAIT or DOASYNC)
4749 +----------------------------------------------------------------*/
4750 +static int
4751 +hfa384x_dormem(
4752 + hfa384x_t *hw,
4753 + CMD_MODE mode,
4754 + u16 page,
4755 + u16 offset,
4756 + void *data,
4757 + unsigned int len,
4758 + ctlx_cmdcb_t cmdcb,
4759 + ctlx_usercb_t usercb,
4760 + void *usercb_data)
4761 +{
4762 + int result;
4763 + hfa384x_usbctlx_t *ctlx;
4764 +
4765 + DBFENTER;
4766 + ctlx = usbctlx_alloc();
4767 + if ( ctlx == NULL ) {
4768 + result = -ENOMEM;
4769 + goto done;
4770 + }
4771 +
4772 + /* Initialize the command */
4773 + ctlx->outbuf.rmemreq.type = host2hfa384x_16(HFA384x_USB_RMEMREQ);
4774 + ctlx->outbuf.rmemreq.frmlen = host2hfa384x_16(
4775 + sizeof(ctlx->outbuf.rmemreq.offset) +
4776 + sizeof(ctlx->outbuf.rmemreq.page) +
4777 + len);
4778 + ctlx->outbuf.rmemreq.offset = host2hfa384x_16(offset);
4779 + ctlx->outbuf.rmemreq.page = host2hfa384x_16(page);
4780 +
4781 + ctlx->outbufsize = sizeof(ctlx->outbuf.rmemreq);
4782 +
4783 + WLAN_LOG_DEBUG(4,
4784 + "type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
4785 + ctlx->outbuf.rmemreq.type,
4786 + ctlx->outbuf.rmemreq.frmlen,
4787 + ctlx->outbuf.rmemreq.offset,
4788 + ctlx->outbuf.rmemreq.page);
4789 +
4790 + WLAN_LOG_DEBUG(4,"pktsize=%zd\n",
4791 + ROUNDUP64(sizeof(ctlx->outbuf.rmemreq)));
4792 +
4793 + ctlx->reapable = mode;
4794 + ctlx->cmdcb = cmdcb;
4795 + ctlx->usercb = usercb;
4796 + ctlx->usercb_data = usercb_data;
4797 +
4798 + result = hfa384x_usbctlx_submit(hw, ctlx);
4799 + if (result != 0) {
4800 + kfree(ctlx);
4801 + } else if ( mode == DOWAIT ) {
4802 + usbctlx_rmem_completor_t completor;
4803 +
4804 + result = hfa384x_usbctlx_complete_sync(
4805 + hw, ctlx, init_rmem_completor(&completor,
4806 + &ctlx->inbuf.rmemresp,
4807 + data,
4808 + len) );
4809 + }
4810 +
4811 +done:
4812 + DBFEXIT;
4813 + return result;
4814 +}
4815 +
4816 +
4817 +
4818 +/*----------------------------------------------------------------
4819 +* hfa384x_dowmem
4820 +*
4821 +* Constructs a writemem CTLX and issues it.
4822 +*
4823 +* NOTE: Any changes to the 'post-submit' code in this function
4824 +* need to be carried over to hfa384x_cbwmem() since the handling
4825 +* is virtually identical.
4826 +*
4827 +* Arguments:
4828 +* hw device structure
4829 +* mode DOWAIT or DOASYNC
4830 +* page MAC address space page (CMD format)
4831 +* offset MAC address space offset
4832 +* data Ptr to data buffer containing write data
4833 +* len Length of the data to read (max == 2048)
4834 +* cmdcb command callback for async calls, NULL for DOWAIT calls
4835 +* usercb user callback for async calls, NULL for DOWAIT calls
4836 +* usercb_data user supplied data pointer for async calls.
4837 +*
4838 +* Returns:
4839 +* 0 success
4840 +* -ETIMEDOUT timed out waiting for register ready or
4841 +* command completion
4842 +* >0 command indicated error, Status and Resp0-2 are
4843 +* in hw structure.
4844 +*
4845 +* Side effects:
4846 +*
4847 +* Call context:
4848 +* interrupt (DOWAIT)
4849 +* process (DOWAIT or DOASYNC)
4850 +----------------------------------------------------------------*/
4851 +static int
4852 +hfa384x_dowmem(
4853 + hfa384x_t *hw,
4854 + CMD_MODE mode,
4855 + u16 page,
4856 + u16 offset,
4857 + void *data,
4858 + unsigned int len,
4859 + ctlx_cmdcb_t cmdcb,
4860 + ctlx_usercb_t usercb,
4861 + void *usercb_data)
4862 +{
4863 + int result;
4864 + hfa384x_usbctlx_t *ctlx;
4865 +
4866 + DBFENTER;
4867 + WLAN_LOG_DEBUG(5, "page=0x%04x offset=0x%04x len=%d\n",
4868 + page,offset,len);
4869 +
4870 + ctlx = usbctlx_alloc();
4871 + if ( ctlx == NULL ) {
4872 + result = -ENOMEM;
4873 + goto done;
4874 + }
4875 +
4876 + /* Initialize the command */
4877 + ctlx->outbuf.wmemreq.type = host2hfa384x_16(HFA384x_USB_WMEMREQ);
4878 + ctlx->outbuf.wmemreq.frmlen = host2hfa384x_16(
4879 + sizeof(ctlx->outbuf.wmemreq.offset) +
4880 + sizeof(ctlx->outbuf.wmemreq.page) +
4881 + len);
4882 + ctlx->outbuf.wmemreq.offset = host2hfa384x_16(offset);
4883 + ctlx->outbuf.wmemreq.page = host2hfa384x_16(page);
4884 + memcpy(ctlx->outbuf.wmemreq.data, data, len);
4885 +
4886 + ctlx->outbufsize = sizeof(ctlx->outbuf.wmemreq.type) +
4887 + sizeof(ctlx->outbuf.wmemreq.frmlen) +
4888 + sizeof(ctlx->outbuf.wmemreq.offset) +
4889 + sizeof(ctlx->outbuf.wmemreq.page) +
4890 + len;
4891 +
4892 + ctlx->reapable = mode;
4893 + ctlx->cmdcb = cmdcb;
4894 + ctlx->usercb = usercb;
4895 + ctlx->usercb_data = usercb_data;
4896 +
4897 + result = hfa384x_usbctlx_submit(hw, ctlx);
4898 + if (result != 0) {
4899 + kfree(ctlx);
4900 + } else if ( mode == DOWAIT ) {
4901 + usbctlx_wmem_completor_t completor;
4902 + hfa384x_cmdresult_t wmemresult;
4903 +
4904 + result = hfa384x_usbctlx_complete_sync(
4905 + hw,
4906 + ctlx,
4907 + init_wmem_completor(&completor,
4908 + &ctlx->inbuf.wmemresp,
4909 + &wmemresult) );
4910 + }
4911 +
4912 +done:
4913 + DBFEXIT;
4914 + return result;
4915 +}
4916 +
4917 +
4918 +/*----------------------------------------------------------------
4919 +* hfa384x_drvr_commtallies
4920 +*
4921 +* Send a commtallies inquiry to the MAC. Note that this is an async
4922 +* call that will result in an info frame arriving sometime later.
4923 +*
4924 +* Arguments:
4925 +* hw device structure
4926 +*
4927 +* Returns:
4928 +* zero success.
4929 +*
4930 +* Side effects:
4931 +*
4932 +* Call context:
4933 +* process
4934 +----------------------------------------------------------------*/
4935 +int hfa384x_drvr_commtallies( hfa384x_t *hw )
4936 +{
4937 + hfa384x_metacmd_t cmd;
4938 +
4939 + DBFENTER;
4940 +
4941 + cmd.cmd = HFA384x_CMDCODE_INQ;
4942 + cmd.parm0 = HFA384x_IT_COMMTALLIES;
4943 + cmd.parm1 = 0;
4944 + cmd.parm2 = 0;
4945 +
4946 + hfa384x_docmd_async(hw, &cmd, NULL, NULL, NULL);
4947 +
4948 + DBFEXIT;
4949 + return 0;
4950 +}
4951 +
4952 +
4953 +/*----------------------------------------------------------------
4954 +* hfa384x_drvr_disable
4955 +*
4956 +* Issues the disable command to stop communications on one of
4957 +* the MACs 'ports'. Only macport 0 is valid for stations.
4958 +* APs may also disable macports 1-6. Only ports that have been
4959 +* previously enabled may be disabled.
4960 +*
4961 +* Arguments:
4962 +* hw device structure
4963 +* macport MAC port number (host order)
4964 +*
4965 +* Returns:
4966 +* 0 success
4967 +* >0 f/w reported failure - f/w status code
4968 +* <0 driver reported error (timeout|bad arg)
4969 +*
4970 +* Side effects:
4971 +*
4972 +* Call context:
4973 +* process
4974 +----------------------------------------------------------------*/
4975 +int hfa384x_drvr_disable(hfa384x_t *hw, u16 macport)
4976 +{
4977 + int result = 0;
4978 +
4979 + DBFENTER;
4980 + if ((!hw->isap && macport != 0) ||
4981 + (hw->isap && !(macport <= HFA384x_PORTID_MAX)) ||
4982 + !(hw->port_enabled[macport]) ){
4983 + result = -EINVAL;
4984 + } else {
4985 + result = hfa384x_cmd_disable(hw, macport);
4986 + if ( result == 0 ) {
4987 + hw->port_enabled[macport] = 0;
4988 + }
4989 + }
4990 + DBFEXIT;
4991 + return result;
4992 +}
4993 +
4994 +
4995 +/*----------------------------------------------------------------
4996 +* hfa384x_drvr_enable
4997 +*
4998 +* Issues the enable command to enable communications on one of
4999 +* the MACs 'ports'. Only macport 0 is valid for stations.
5000 +* APs may also enable macports 1-6. Only ports that are currently
5001 +* disabled may be enabled.
5002 +*
5003 +* Arguments:
5004 +* hw device structure
5005 +* macport MAC port number
5006 +*
5007 +* Returns:
5008 +* 0 success
5009 +* >0 f/w reported failure - f/w status code
5010 +* <0 driver reported error (timeout|bad arg)
5011 +*
5012 +* Side effects:
5013 +*
5014 +* Call context:
5015 +* process
5016 +----------------------------------------------------------------*/
5017 +int hfa384x_drvr_enable(hfa384x_t *hw, u16 macport)
5018 +{
5019 + int result = 0;
5020 +
5021 + DBFENTER;
5022 + if ((!hw->isap && macport != 0) ||
5023 + (hw->isap && !(macport <= HFA384x_PORTID_MAX)) ||
5024 + (hw->port_enabled[macport]) ){
5025 + result = -EINVAL;
5026 + } else {
5027 + result = hfa384x_cmd_enable(hw, macport);
5028 + if ( result == 0 ) {
5029 + hw->port_enabled[macport] = 1;
5030 + }
5031 + }
5032 + DBFEXIT;
5033 + return result;
5034 +}
5035 +
5036 +
5037 +/*----------------------------------------------------------------
5038 +* hfa384x_drvr_flashdl_enable
5039 +*
5040 +* Begins the flash download state. Checks to see that we're not
5041 +* already in a download state and that a port isn't enabled.
5042 +* Sets the download state and retrieves the flash download
5043 +* buffer location, buffer size, and timeout length.
5044 +*
5045 +* Arguments:
5046 +* hw device structure
5047 +*
5048 +* Returns:
5049 +* 0 success
5050 +* >0 f/w reported error - f/w status code
5051 +* <0 driver reported error
5052 +*
5053 +* Side effects:
5054 +*
5055 +* Call context:
5056 +* process
5057 +----------------------------------------------------------------*/
5058 +int hfa384x_drvr_flashdl_enable(hfa384x_t *hw)
5059 +{
5060 + int result = 0;
5061 + int i;
5062 +
5063 + DBFENTER;
5064 + /* Check that a port isn't active */
5065 + for ( i = 0; i < HFA384x_PORTID_MAX; i++) {
5066 + if ( hw->port_enabled[i] ) {
5067 + WLAN_LOG_DEBUG(1,"called when port enabled.\n");
5068 + return -EINVAL;
5069 + }
5070 + }
5071 +
5072 + /* Check that we're not already in a download state */
5073 + if ( hw->dlstate != HFA384x_DLSTATE_DISABLED ) {
5074 + return -EINVAL;
5075 + }
5076 +
5077 + /* Retrieve the buffer loc&size and timeout */
5078 + if ( (result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DOWNLOADBUFFER,
5079 + &(hw->bufinfo), sizeof(hw->bufinfo))) ) {
5080 + return result;
5081 + }
5082 + hw->bufinfo.page = hfa384x2host_16(hw->bufinfo.page);
5083 + hw->bufinfo.offset = hfa384x2host_16(hw->bufinfo.offset);
5084 + hw->bufinfo.len = hfa384x2host_16(hw->bufinfo.len);
5085 + if ( (result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_MAXLOADTIME,
5086 + &(hw->dltimeout))) ) {
5087 + return result;
5088 + }
5089 + hw->dltimeout = hfa384x2host_16(hw->dltimeout);
5090 +
5091 + WLAN_LOG_DEBUG(1,"flashdl_enable\n");
5092 +
5093 + hw->dlstate = HFA384x_DLSTATE_FLASHENABLED;
5094 + DBFEXIT;
5095 + return result;
5096 +}
5097 +
5098 +
5099 +/*----------------------------------------------------------------
5100 +* hfa384x_drvr_flashdl_disable
5101 +*
5102 +* Ends the flash download state. Note that this will cause the MAC
5103 +* firmware to restart.
5104 +*
5105 +* Arguments:
5106 +* hw device structure
5107 +*
5108 +* Returns:
5109 +* 0 success
5110 +* >0 f/w reported error - f/w status code
5111 +* <0 driver reported error
5112 +*
5113 +* Side effects:
5114 +*
5115 +* Call context:
5116 +* process
5117 +----------------------------------------------------------------*/
5118 +int hfa384x_drvr_flashdl_disable(hfa384x_t *hw)
5119 +{
5120 + DBFENTER;
5121 + /* Check that we're already in the download state */
5122 + if ( hw->dlstate != HFA384x_DLSTATE_FLASHENABLED ) {
5123 + return -EINVAL;
5124 + }
5125 +
5126 + WLAN_LOG_DEBUG(1,"flashdl_enable\n");
5127 +
5128 + /* There isn't much we can do at this point, so I don't */
5129 + /* bother w/ the return value */
5130 + hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0 , 0);
5131 + hw->dlstate = HFA384x_DLSTATE_DISABLED;
5132 +
5133 + DBFEXIT;
5134 + return 0;
5135 +}
5136 +
5137 +
5138 +/*----------------------------------------------------------------
5139 +* hfa384x_drvr_flashdl_write
5140 +*
5141 +* Performs a FLASH download of a chunk of data. First checks to see
5142 +* that we're in the FLASH download state, then sets the download
5143 +* mode, uses the aux functions to 1) copy the data to the flash
5144 +* buffer, 2) sets the download 'write flash' mode, 3) readback and
5145 +* compare. Lather rinse, repeat as many times an necessary to get
5146 +* all the given data into flash.
5147 +* When all data has been written using this function (possibly
5148 +* repeatedly), call drvr_flashdl_disable() to end the download state
5149 +* and restart the MAC.
5150 +*
5151 +* Arguments:
5152 +* hw device structure
5153 +* daddr Card address to write to. (host order)
5154 +* buf Ptr to data to write.
5155 +* len Length of data (host order).
5156 +*
5157 +* Returns:
5158 +* 0 success
5159 +* >0 f/w reported error - f/w status code
5160 +* <0 driver reported error
5161 +*
5162 +* Side effects:
5163 +*
5164 +* Call context:
5165 +* process
5166 +----------------------------------------------------------------*/
5167 +int
5168 +hfa384x_drvr_flashdl_write(
5169 + hfa384x_t *hw,
5170 + u32 daddr,
5171 + void *buf,
5172 + u32 len)
5173 +{
5174 + int result = 0;
5175 + u32 dlbufaddr;
5176 + int nburns;
5177 + u32 burnlen;
5178 + u32 burndaddr;
5179 + u16 burnlo;
5180 + u16 burnhi;
5181 + int nwrites;
5182 + u8 *writebuf;
5183 + u16 writepage;
5184 + u16 writeoffset;
5185 + u32 writelen;
5186 + int i;
5187 + int j;
5188 +
5189 + DBFENTER;
5190 + WLAN_LOG_DEBUG(5,"daddr=0x%08x len=%d\n", daddr, len);
5191 +
5192 + /* Check that we're in the flash download state */
5193 + if ( hw->dlstate != HFA384x_DLSTATE_FLASHENABLED ) {
5194 + return -EINVAL;
5195 + }
5196 +
5197 + WLAN_LOG_INFO("Download %d bytes to flash @0x%06x\n", len, daddr);
5198 +
5199 + /* Convert to flat address for arithmetic */
5200 + /* NOTE: dlbuffer RID stores the address in AUX format */
5201 + dlbufaddr = HFA384x_ADDR_AUX_MKFLAT(
5202 + hw->bufinfo.page, hw->bufinfo.offset);
5203 + WLAN_LOG_DEBUG(5,
5204 + "dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n",
5205 + hw->bufinfo.page, hw->bufinfo.offset, dlbufaddr);
5206 +
5207 +#if 0
5208 +WLAN_LOG_WARNING("dlbuf@0x%06lx len=%d to=%d\n", dlbufaddr, hw->bufinfo.len, hw->dltimeout);
5209 +#endif
5210 + /* Calculations to determine how many fills of the dlbuffer to do
5211 + * and how many USB wmemreq's to do for each fill. At this point
5212 + * in time, the dlbuffer size and the wmemreq size are the same.
5213 + * Therefore, nwrites should always be 1. The extra complexity
5214 + * here is a hedge against future changes.
5215 + */
5216 +
5217 + /* Figure out how many times to do the flash programming */
5218 + nburns = len / hw->bufinfo.len;
5219 + nburns += (len % hw->bufinfo.len) ? 1 : 0;
5220 +
5221 + /* For each flash program cycle, how many USB wmemreq's are needed? */
5222 + nwrites = hw->bufinfo.len / HFA384x_USB_RWMEM_MAXLEN;
5223 + nwrites += (hw->bufinfo.len % HFA384x_USB_RWMEM_MAXLEN) ? 1 : 0;
5224 +
5225 + /* For each burn */
5226 + for ( i = 0; i < nburns; i++) {
5227 + /* Get the dest address and len */
5228 + burnlen = (len - (hw->bufinfo.len * i)) > hw->bufinfo.len ?
5229 + hw->bufinfo.len :
5230 + (len - (hw->bufinfo.len * i));
5231 + burndaddr = daddr + (hw->bufinfo.len * i);
5232 + burnlo = HFA384x_ADDR_CMD_MKOFF(burndaddr);
5233 + burnhi = HFA384x_ADDR_CMD_MKPAGE(burndaddr);
5234 +
5235 + WLAN_LOG_INFO("Writing %d bytes to flash @0x%06x\n",
5236 + burnlen, burndaddr);
5237 +
5238 + /* Set the download mode */
5239 + result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_NV,
5240 + burnlo, burnhi, burnlen);
5241 + if ( result ) {
5242 + WLAN_LOG_ERROR("download(NV,lo=%x,hi=%x,len=%x) "
5243 + "cmd failed, result=%d. Aborting d/l\n",
5244 + burnlo, burnhi, burnlen, result);
5245 + goto exit_proc;
5246 + }
5247 +
5248 + /* copy the data to the flash download buffer */
5249 + for ( j=0; j < nwrites; j++) {
5250 + writebuf = buf +
5251 + (i*hw->bufinfo.len) +
5252 + (j*HFA384x_USB_RWMEM_MAXLEN);
5253 +
5254 + writepage = HFA384x_ADDR_CMD_MKPAGE(
5255 + dlbufaddr +
5256 + (j*HFA384x_USB_RWMEM_MAXLEN));
5257 + writeoffset = HFA384x_ADDR_CMD_MKOFF(
5258 + dlbufaddr +
5259 + (j*HFA384x_USB_RWMEM_MAXLEN));
5260 +
5261 + writelen = burnlen-(j*HFA384x_USB_RWMEM_MAXLEN);
5262 + writelen = writelen > HFA384x_USB_RWMEM_MAXLEN ?
5263 + HFA384x_USB_RWMEM_MAXLEN :
5264 + writelen;
5265 +
5266 + result = hfa384x_dowmem_wait( hw,
5267 + writepage,
5268 + writeoffset,
5269 + writebuf,
5270 + writelen );
5271 +#if 0
5272 +
5273 +Comment out for debugging, assume the write was successful.
5274 + if (result) {
5275 + WLAN_LOG_ERROR(
5276 + "Write to dl buffer failed, "
5277 + "result=0x%04x. Aborting.\n",
5278 + result);
5279 + goto exit_proc;
5280 + }
5281 +#endif
5282 +
5283 + }
5284 +
5285 + /* set the download 'write flash' mode */
5286 + result = hfa384x_cmd_download(hw,
5287 + HFA384x_PROGMODE_NVWRITE,
5288 + 0,0,0);
5289 + if ( result ) {
5290 + WLAN_LOG_ERROR(
5291 + "download(NVWRITE,lo=%x,hi=%x,len=%x) "
5292 + "cmd failed, result=%d. Aborting d/l\n",
5293 + burnlo, burnhi, burnlen, result);
5294 + goto exit_proc;
5295 + }
5296 +
5297 + /* TODO: We really should do a readback and compare. */
5298 + }
5299 +
5300 +exit_proc:
5301 +
5302 + /* Leave the firmware in the 'post-prog' mode. flashdl_disable will */
5303 + /* actually disable programming mode. Remember, that will cause the */
5304 + /* the firmware to effectively reset itself. */
5305 +
5306 + DBFEXIT;
5307 + return result;
5308 +}
5309 +
5310 +
5311 +/*----------------------------------------------------------------
5312 +* hfa384x_drvr_getconfig
5313 +*
5314 +* Performs the sequence necessary to read a config/info item.
5315 +*
5316 +* Arguments:
5317 +* hw device structure
5318 +* rid config/info record id (host order)
5319 +* buf host side record buffer. Upon return it will
5320 +* contain the body portion of the record (minus the
5321 +* RID and len).
5322 +* len buffer length (in bytes, should match record length)
5323 +*
5324 +* Returns:
5325 +* 0 success
5326 +* >0 f/w reported error - f/w status code
5327 +* <0 driver reported error
5328 +* -ENODATA length mismatch between argument and retrieved
5329 +* record.
5330 +*
5331 +* Side effects:
5332 +*
5333 +* Call context:
5334 +* process
5335 +----------------------------------------------------------------*/
5336 +int hfa384x_drvr_getconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len)
5337 +{
5338 + int result;
5339 + DBFENTER;
5340 +
5341 + result = hfa384x_dorrid_wait(hw, rid, buf, len);
5342 +
5343 + DBFEXIT;
5344 + return result;
5345 +}
5346 +
5347 +/*----------------------------------------------------------------
5348 + * hfa384x_drvr_getconfig_async
5349 + *
5350 + * Performs the sequence necessary to perform an async read of
5351 + * of a config/info item.
5352 + *
5353 + * Arguments:
5354 + * hw device structure
5355 + * rid config/info record id (host order)
5356 + * buf host side record buffer. Upon return it will
5357 + * contain the body portion of the record (minus the
5358 + * RID and len).
5359 + * len buffer length (in bytes, should match record length)
5360 + * cbfn caller supplied callback, called when the command
5361 + * is done (successful or not).
5362 + * cbfndata pointer to some caller supplied data that will be
5363 + * passed in as an argument to the cbfn.
5364 + *
5365 + * Returns:
5366 + * nothing the cbfn gets a status argument identifying if
5367 + * any errors occur.
5368 + * Side effects:
5369 + * Queues an hfa384x_usbcmd_t for subsequent execution.
5370 + *
5371 + * Call context:
5372 + * Any
5373 + ----------------------------------------------------------------*/
5374 +int
5375 +hfa384x_drvr_getconfig_async(
5376 + hfa384x_t *hw,
5377 + u16 rid,
5378 + ctlx_usercb_t usercb,
5379 + void *usercb_data)
5380 +{
5381 + return hfa384x_dorrid_async(hw, rid, NULL, 0,
5382 + hfa384x_cb_rrid, usercb, usercb_data);
5383 +}
5384 +
5385 +/*----------------------------------------------------------------
5386 + * hfa384x_drvr_setconfig_async
5387 + *
5388 + * Performs the sequence necessary to write a config/info item.
5389 + *
5390 + * Arguments:
5391 + * hw device structure
5392 + * rid config/info record id (in host order)
5393 + * buf host side record buffer
5394 + * len buffer length (in bytes)
5395 + * usercb completion callback
5396 + * usercb_data completion callback argument
5397 + *
5398 + * Returns:
5399 + * 0 success
5400 + * >0 f/w reported error - f/w status code
5401 + * <0 driver reported error
5402 + *
5403 + * Side effects:
5404 + *
5405 + * Call context:
5406 + * process
5407 + ----------------------------------------------------------------*/
5408 +int
5409 +hfa384x_drvr_setconfig_async(
5410 + hfa384x_t *hw,
5411 + u16 rid,
5412 + void *buf,
5413 + u16 len,
5414 + ctlx_usercb_t usercb,
5415 + void *usercb_data)
5416 +{
5417 + return hfa384x_dowrid_async(hw, rid, buf, len,
5418 + hfa384x_cb_status, usercb, usercb_data);
5419 +}
5420 +
5421 +/*----------------------------------------------------------------
5422 +* hfa384x_drvr_handover
5423 +*
5424 +* Sends a handover notification to the MAC.
5425 +*
5426 +* Arguments:
5427 +* hw device structure
5428 +* addr address of station that's left
5429 +*
5430 +* Returns:
5431 +* zero success.
5432 +* -ERESTARTSYS received signal while waiting for semaphore.
5433 +* -EIO failed to write to bap, or failed in cmd.
5434 +*
5435 +* Side effects:
5436 +*
5437 +* Call context:
5438 +* process
5439 +----------------------------------------------------------------*/
5440 +int hfa384x_drvr_handover( hfa384x_t *hw, u8 *addr)
5441 +{
5442 + DBFENTER;
5443 + WLAN_LOG_ERROR("Not currently supported in USB!\n");
5444 + DBFEXIT;
5445 + return -EIO;
5446 +}
5447 +
5448 +/*----------------------------------------------------------------
5449 +* hfa384x_drvr_low_level
5450 +*
5451 +* Write test commands to the card. Some test commands don't make
5452 +* sense without prior set-up. For example, continous TX isn't very
5453 +* useful until you set the channel. That functionality should be
5454 +*
5455 +* Side effects:
5456 +*
5457 +* Call context:
5458 +* process thread
5459 +* -----------------------------------------------------------------*/
5460 +int hfa384x_drvr_low_level(hfa384x_t *hw, hfa384x_metacmd_t *cmd)
5461 +{
5462 + int result;
5463 + DBFENTER;
5464 +
5465 + /* Do i need a host2hfa... conversion ? */
5466 +
5467 + result = hfa384x_docmd_wait(hw, cmd);
5468 +
5469 + DBFEXIT;
5470 + return result;
5471 +}
5472 +
5473 +/*----------------------------------------------------------------
5474 +* hfa384x_drvr_ramdl_disable
5475 +*
5476 +* Ends the ram download state.
5477 +*
5478 +* Arguments:
5479 +* hw device structure
5480 +*
5481 +* Returns:
5482 +* 0 success
5483 +* >0 f/w reported error - f/w status code
5484 +* <0 driver reported error
5485 +*
5486 +* Side effects:
5487 +*
5488 +* Call context:
5489 +* process
5490 +----------------------------------------------------------------*/
5491 +int
5492 +hfa384x_drvr_ramdl_disable(hfa384x_t *hw)
5493 +{
5494 + DBFENTER;
5495 + /* Check that we're already in the download state */
5496 + if ( hw->dlstate != HFA384x_DLSTATE_RAMENABLED ) {
5497 + return -EINVAL;
5498 + }
5499 +
5500 + WLAN_LOG_DEBUG(3,"ramdl_disable()\n");
5501 +
5502 + /* There isn't much we can do at this point, so I don't */
5503 + /* bother w/ the return value */
5504 + hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0 , 0);
5505 + hw->dlstate = HFA384x_DLSTATE_DISABLED;
5506 +
5507 + DBFEXIT;
5508 + return 0;
5509 +}
5510 +
5511 +
5512 +/*----------------------------------------------------------------
5513 +* hfa384x_drvr_ramdl_enable
5514 +*
5515 +* Begins the ram download state. Checks to see that we're not
5516 +* already in a download state and that a port isn't enabled.
5517 +* Sets the download state and calls cmd_download with the
5518 +* ENABLE_VOLATILE subcommand and the exeaddr argument.
5519 +*
5520 +* Arguments:
5521 +* hw device structure
5522 +* exeaddr the card execution address that will be
5523 +* jumped to when ramdl_disable() is called
5524 +* (host order).
5525 +*
5526 +* Returns:
5527 +* 0 success
5528 +* >0 f/w reported error - f/w status code
5529 +* <0 driver reported error
5530 +*
5531 +* Side effects:
5532 +*
5533 +* Call context:
5534 +* process
5535 +----------------------------------------------------------------*/
5536 +int
5537 +hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr)
5538 +{
5539 + int result = 0;
5540 + u16 lowaddr;
5541 + u16 hiaddr;
5542 + int i;
5543 + DBFENTER;
5544 + /* Check that a port isn't active */
5545 + for ( i = 0; i < HFA384x_PORTID_MAX; i++) {
5546 + if ( hw->port_enabled[i] ) {
5547 + WLAN_LOG_ERROR(
5548 + "Can't download with a macport enabled.\n");
5549 + return -EINVAL;
5550 + }
5551 + }
5552 +
5553 + /* Check that we're not already in a download state */
5554 + if ( hw->dlstate != HFA384x_DLSTATE_DISABLED ) {
5555 + WLAN_LOG_ERROR(
5556 + "Download state not disabled.\n");
5557 + return -EINVAL;
5558 + }
5559 +
5560 + WLAN_LOG_DEBUG(3,"ramdl_enable, exeaddr=0x%08x\n", exeaddr);
5561 +
5562 + /* Call the download(1,addr) function */
5563 + lowaddr = HFA384x_ADDR_CMD_MKOFF(exeaddr);
5564 + hiaddr = HFA384x_ADDR_CMD_MKPAGE(exeaddr);
5565 +
5566 + result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_RAM,
5567 + lowaddr, hiaddr, 0);
5568 +
5569 + if ( result == 0) {
5570 + /* Set the download state */
5571 + hw->dlstate = HFA384x_DLSTATE_RAMENABLED;
5572 + } else {
5573 + WLAN_LOG_DEBUG(1,
5574 + "cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
5575 + lowaddr,
5576 + hiaddr,
5577 + result);
5578 + }
5579 +
5580 + DBFEXIT;
5581 + return result;
5582 +}
5583 +
5584 +
5585 +/*----------------------------------------------------------------
5586 +* hfa384x_drvr_ramdl_write
5587 +*
5588 +* Performs a RAM download of a chunk of data. First checks to see
5589 +* that we're in the RAM download state, then uses the [read|write]mem USB
5590 +* commands to 1) copy the data, 2) readback and compare. The download
5591 +* state is unaffected. When all data has been written using
5592 +* this function, call drvr_ramdl_disable() to end the download state
5593 +* and restart the MAC.
5594 +*
5595 +* Arguments:
5596 +* hw device structure
5597 +* daddr Card address to write to. (host order)
5598 +* buf Ptr to data to write.
5599 +* len Length of data (host order).
5600 +*
5601 +* Returns:
5602 +* 0 success
5603 +* >0 f/w reported error - f/w status code
5604 +* <0 driver reported error
5605 +*
5606 +* Side effects:
5607 +*
5608 +* Call context:
5609 +* process
5610 +----------------------------------------------------------------*/
5611 +int
5612 +hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void* buf, u32 len)
5613 +{
5614 + int result = 0;
5615 + int nwrites;
5616 + u8 *data = buf;
5617 + int i;
5618 + u32 curraddr;
5619 + u16 currpage;
5620 + u16 curroffset;
5621 + u16 currlen;
5622 + DBFENTER;
5623 + /* Check that we're in the ram download state */
5624 + if ( hw->dlstate != HFA384x_DLSTATE_RAMENABLED ) {
5625 + return -EINVAL;
5626 + }
5627 +
5628 + WLAN_LOG_INFO("Writing %d bytes to ram @0x%06x\n", len, daddr);
5629 +
5630 + /* How many dowmem calls? */
5631 + nwrites = len / HFA384x_USB_RWMEM_MAXLEN;
5632 + nwrites += len % HFA384x_USB_RWMEM_MAXLEN ? 1 : 0;
5633 +
5634 + /* Do blocking wmem's */
5635 + for(i=0; i < nwrites; i++) {
5636 + /* make address args */
5637 + curraddr = daddr + (i * HFA384x_USB_RWMEM_MAXLEN);
5638 + currpage = HFA384x_ADDR_CMD_MKPAGE(curraddr);
5639 + curroffset = HFA384x_ADDR_CMD_MKOFF(curraddr);
5640 + currlen = len - (i * HFA384x_USB_RWMEM_MAXLEN);
5641 + if ( currlen > HFA384x_USB_RWMEM_MAXLEN) {
5642 + currlen = HFA384x_USB_RWMEM_MAXLEN;
5643 + }
5644 +
5645 + /* Do blocking ctlx */
5646 + result = hfa384x_dowmem_wait( hw,
5647 + currpage,
5648 + curroffset,
5649 + data + (i*HFA384x_USB_RWMEM_MAXLEN),
5650 + currlen );
5651 +
5652 + if (result) break;
5653 +
5654 + /* TODO: We really should have a readback. */
5655 + }
5656 +
5657 + DBFEXIT;
5658 + return result;
5659 +}
5660 +
5661 +
5662 +/*----------------------------------------------------------------
5663 +* hfa384x_drvr_readpda
5664 +*
5665 +* Performs the sequence to read the PDA space. Note there is no
5666 +* drvr_writepda() function. Writing a PDA is
5667 +* generally implemented by a calling component via calls to
5668 +* cmd_download and writing to the flash download buffer via the
5669 +* aux regs.
5670 +*
5671 +* Arguments:
5672 +* hw device structure
5673 +* buf buffer to store PDA in
5674 +* len buffer length
5675 +*
5676 +* Returns:
5677 +* 0 success
5678 +* >0 f/w reported error - f/w status code
5679 +* <0 driver reported error
5680 +* -ETIMEOUT timout waiting for the cmd regs to become
5681 +* available, or waiting for the control reg
5682 +* to indicate the Aux port is enabled.
5683 +* -ENODATA the buffer does NOT contain a valid PDA.
5684 +* Either the card PDA is bad, or the auxdata
5685 +* reads are giving us garbage.
5686 +
5687 +*
5688 +* Side effects:
5689 +*
5690 +* Call context:
5691 +* process or non-card interrupt.
5692 +----------------------------------------------------------------*/
5693 +int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len)
5694 +{
5695 + int result = 0;
5696 + u16 *pda = buf;
5697 + int pdaok = 0;
5698 + int morepdrs = 1;
5699 + int currpdr = 0; /* word offset of the current pdr */
5700 + size_t i;
5701 + u16 pdrlen; /* pdr length in bytes, host order */
5702 + u16 pdrcode; /* pdr code, host order */
5703 + u16 currpage;
5704 + u16 curroffset;
5705 + struct pdaloc {
5706 + u32 cardaddr;
5707 + u16 auxctl;
5708 + } pdaloc[] =
5709 + {
5710 + { HFA3842_PDA_BASE, 0},
5711 + { HFA3841_PDA_BASE, 0},
5712 + { HFA3841_PDA_BOGUS_BASE, 0}
5713 + };
5714 +
5715 + DBFENTER;
5716 +
5717 + /* Read the pda from each known address. */
5718 + for ( i = 0; i < ARRAY_SIZE(pdaloc); i++) {
5719 + /* Make address */
5720 + currpage = HFA384x_ADDR_CMD_MKPAGE(pdaloc[i].cardaddr);
5721 + curroffset = HFA384x_ADDR_CMD_MKOFF(pdaloc[i].cardaddr);
5722 +
5723 + result = hfa384x_dormem_wait(hw,
5724 + currpage,
5725 + curroffset,
5726 + buf,
5727 + len); /* units of bytes */
5728 +
5729 + if (result) {
5730 + WLAN_LOG_WARNING(
5731 + "Read from index %zd failed, continuing\n",
5732 + i );
5733 + continue;
5734 + }
5735 +
5736 + /* Test for garbage */
5737 + pdaok = 1; /* initially assume good */
5738 + morepdrs = 1;
5739 + while ( pdaok && morepdrs ) {
5740 + pdrlen = hfa384x2host_16(pda[currpdr]) * 2;
5741 + pdrcode = hfa384x2host_16(pda[currpdr+1]);
5742 + /* Test the record length */
5743 + if ( pdrlen > HFA384x_PDR_LEN_MAX || pdrlen == 0) {
5744 + WLAN_LOG_ERROR("pdrlen invalid=%d\n",
5745 + pdrlen);
5746 + pdaok = 0;
5747 + break;
5748 + }
5749 + /* Test the code */
5750 + if ( !hfa384x_isgood_pdrcode(pdrcode) ) {
5751 + WLAN_LOG_ERROR("pdrcode invalid=%d\n",
5752 + pdrcode);
5753 + pdaok = 0;
5754 + break;
5755 + }
5756 + /* Test for completion */
5757 + if ( pdrcode == HFA384x_PDR_END_OF_PDA) {
5758 + morepdrs = 0;
5759 + }
5760 +
5761 + /* Move to the next pdr (if necessary) */
5762 + if ( morepdrs ) {
5763 + /* note the access to pda[], need words here */
5764 + currpdr += hfa384x2host_16(pda[currpdr]) + 1;
5765 + }
5766 + }
5767 + if ( pdaok ) {
5768 + WLAN_LOG_INFO(
5769 + "PDA Read from 0x%08x in %s space.\n",
5770 + pdaloc[i].cardaddr,
5771 + pdaloc[i].auxctl == 0 ? "EXTDS" :
5772 + pdaloc[i].auxctl == 1 ? "NV" :
5773 + pdaloc[i].auxctl == 2 ? "PHY" :
5774 + pdaloc[i].auxctl == 3 ? "ICSRAM" :
5775 + "<bogus auxctl>");
5776 + break;
5777 + }
5778 + }
5779 + result = pdaok ? 0 : -ENODATA;
5780 +
5781 + if ( result ) {
5782 + WLAN_LOG_DEBUG(3,"Failure: pda is not okay\n");
5783 + }
5784 +
5785 + DBFEXIT;
5786 + return result;
5787 +}
5788 +
5789 +
5790 +/*----------------------------------------------------------------
5791 +* hfa384x_drvr_setconfig
5792 +*
5793 +* Performs the sequence necessary to write a config/info item.
5794 +*
5795 +* Arguments:
5796 +* hw device structure
5797 +* rid config/info record id (in host order)
5798 +* buf host side record buffer
5799 +* len buffer length (in bytes)
5800 +*
5801 +* Returns:
5802 +* 0 success
5803 +* >0 f/w reported error - f/w status code
5804 +* <0 driver reported error
5805 +*
5806 +* Side effects:
5807 +*
5808 +* Call context:
5809 +* process
5810 +----------------------------------------------------------------*/
5811 +int hfa384x_drvr_setconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len)
5812 +{
5813 + return hfa384x_dowrid_wait(hw, rid, buf, len);
5814 +}
5815 +
5816 +/*----------------------------------------------------------------
5817 +* hfa384x_drvr_start
5818 +*
5819 +* Issues the MAC initialize command, sets up some data structures,
5820 +* and enables the interrupts. After this function completes, the
5821 +* low-level stuff should be ready for any/all commands.
5822 +*
5823 +* Arguments:
5824 +* hw device structure
5825 +* Returns:
5826 +* 0 success
5827 +* >0 f/w reported error - f/w status code
5828 +* <0 driver reported error
5829 +*
5830 +* Side effects:
5831 +*
5832 +* Call context:
5833 +* process
5834 +----------------------------------------------------------------*/
5835 +
5836 +int hfa384x_drvr_start(hfa384x_t *hw)
5837 +{
5838 + int result, result1, result2;
5839 + u16 status;
5840 + DBFENTER;
5841 +
5842 + might_sleep();
5843 +
5844 + /* Clear endpoint stalls - but only do this if the endpoint
5845 + * is showing a stall status. Some prism2 cards seem to behave
5846 + * badly if a clear_halt is called when the endpoint is already
5847 + * ok
5848 + */
5849 + result = usb_get_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_in, &status);
5850 + if (result < 0) {
5851 + WLAN_LOG_ERROR(
5852 + "Cannot get bulk in endpoint status.\n");
5853 + goto done;
5854 + }
5855 + if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_in)) {
5856 + WLAN_LOG_ERROR(
5857 + "Failed to reset bulk in endpoint.\n");
5858 + }
5859 +
5860 + result = usb_get_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_out, &status);
5861 + if (result < 0) {
5862 + WLAN_LOG_ERROR(
5863 + "Cannot get bulk out endpoint status.\n");
5864 + goto done;
5865 + }
5866 + if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_out)) {
5867 + WLAN_LOG_ERROR(
5868 + "Failed to reset bulk out endpoint.\n");
5869 + }
5870 +
5871 + /* Synchronous unlink, in case we're trying to restart the driver */
5872 + usb_kill_urb(&hw->rx_urb);
5873 +
5874 + /* Post the IN urb */
5875 + result = submit_rx_urb(hw, GFP_KERNEL);
5876 + if (result != 0) {
5877 + WLAN_LOG_ERROR(
5878 + "Fatal, failed to submit RX URB, result=%d\n",
5879 + result);
5880 + goto done;
5881 + }
5882 +
5883 + /* Call initialize twice, with a 1 second sleep in between.
5884 + * This is a nasty work-around since many prism2 cards seem to
5885 + * need time to settle after an init from cold. The second
5886 + * call to initialize in theory is not necessary - but we call
5887 + * it anyway as a double insurance policy:
5888 + * 1) If the first init should fail, the second may well succeed
5889 + * and the card can still be used
5890 + * 2) It helps ensures all is well with the card after the first
5891 + * init and settle time.
5892 + */
5893 + result1 = hfa384x_cmd_initialize(hw);
5894 + msleep(1000);
5895 + result = result2 = hfa384x_cmd_initialize(hw);
5896 + if (result1 != 0) {
5897 + if (result2 != 0) {
5898 + WLAN_LOG_ERROR(
5899 + "cmd_initialize() failed on two attempts, results %d and %d\n",
5900 + result1, result2);
5901 + usb_kill_urb(&hw->rx_urb);
5902 + goto done;
5903 + } else {
5904 + WLAN_LOG_DEBUG(0, "First cmd_initialize() failed (result %d),\n",
5905 + result1);
5906 + WLAN_LOG_DEBUG(0, "but second attempt succeeded. All should be ok\n");
5907 + }
5908 + } else if (result2 != 0) {
5909 + WLAN_LOG_WARNING(
5910 + "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n",
5911 + result2);
5912 + WLAN_LOG_WARNING("Most likely the card will be functional\n");
5913 + goto done;
5914 + }
5915 +
5916 + hw->state = HFA384x_STATE_RUNNING;
5917 +
5918 +done:
5919 + DBFEXIT;
5920 + return result;
5921 +}
5922 +
5923 +
5924 +/*----------------------------------------------------------------
5925 +* hfa384x_drvr_stop
5926 +*
5927 +* Shuts down the MAC to the point where it is safe to unload the
5928 +* driver. Any subsystem that may be holding a data or function
5929 +* ptr into the driver must be cleared/deinitialized.
5930 +*
5931 +* Arguments:
5932 +* hw device structure
5933 +* Returns:
5934 +* 0 success
5935 +* >0 f/w reported error - f/w status code
5936 +* <0 driver reported error
5937 +*
5938 +* Side effects:
5939 +*
5940 +* Call context:
5941 +* process
5942 +----------------------------------------------------------------*/
5943 +int
5944 +hfa384x_drvr_stop(hfa384x_t *hw)
5945 +{
5946 + int result = 0;
5947 + int i;
5948 + DBFENTER;
5949 +
5950 + might_sleep();
5951 +
5952 + /* There's no need for spinlocks here. The USB "disconnect"
5953 + * function sets this "removed" flag and then calls us.
5954 + */
5955 + if ( !hw->wlandev->hwremoved ) {
5956 + /* Call initialize to leave the MAC in its 'reset' state */
5957 + hfa384x_cmd_initialize(hw);
5958 +
5959 + /* Cancel the rxurb */
5960 + usb_kill_urb(&hw->rx_urb);
5961 + }
5962 +
5963 + hw->link_status = HFA384x_LINK_NOTCONNECTED;
5964 + hw->state = HFA384x_STATE_INIT;
5965 +
5966 + del_timer_sync(&hw->commsqual_timer);
5967 +
5968 + /* Clear all the port status */
5969 + for ( i = 0; i < HFA384x_NUMPORTS_MAX; i++) {
5970 + hw->port_enabled[i] = 0;
5971 + }
5972 +
5973 + DBFEXIT;
5974 + return result;
5975 +}
5976 +
5977 +/*----------------------------------------------------------------
5978 +* hfa384x_drvr_txframe
5979 +*
5980 +* Takes a frame from prism2sta and queues it for transmission.
5981 +*
5982 +* Arguments:
5983 +* hw device structure
5984 +* skb packet buffer struct. Contains an 802.11
5985 +* data frame.
5986 +* p80211_hdr points to the 802.11 header for the packet.
5987 +* Returns:
5988 +* 0 Success and more buffs available
5989 +* 1 Success but no more buffs
5990 +* 2 Allocation failure
5991 +* 4 Buffer full or queue busy
5992 +*
5993 +* Side effects:
5994 +*
5995 +* Call context:
5996 +* interrupt
5997 +----------------------------------------------------------------*/
5998 +int hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep)
5999 +
6000 +{
6001 + int usbpktlen = sizeof(hfa384x_tx_frame_t);
6002 + int result;
6003 + int ret;
6004 + char *ptr;
6005 +
6006 + DBFENTER;
6007 +
6008 + if (hw->tx_urb.status == -EINPROGRESS) {
6009 + WLAN_LOG_WARNING("TX URB already in use\n");
6010 + result = 3;
6011 + goto exit;
6012 + }
6013 +
6014 + /* Build Tx frame structure */
6015 + /* Set up the control field */
6016 + memset(&hw->txbuff.txfrm.desc, 0, sizeof(hw->txbuff.txfrm.desc));
6017 +
6018 + /* Setup the usb type field */
6019 + hw->txbuff.type = host2hfa384x_16(HFA384x_USB_TXFRM);
6020 +
6021 + /* Set up the sw_support field to identify this frame */
6022 + hw->txbuff.txfrm.desc.sw_support = 0x0123;
6023 +
6024 +/* Tx complete and Tx exception disable per dleach. Might be causing
6025 + * buf depletion
6026 + */
6027 +//#define DOEXC SLP -- doboth breaks horribly under load, doexc less so.
6028 +#if defined(DOBOTH)
6029 + hw->txbuff.txfrm.desc.tx_control =
6030 + HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
6031 + HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(1);
6032 +#elif defined(DOEXC)
6033 + hw->txbuff.txfrm.desc.tx_control =
6034 + HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
6035 + HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(0);
6036 +#else
6037 + hw->txbuff.txfrm.desc.tx_control =
6038 + HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
6039 + HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0);
6040 +#endif
6041 + hw->txbuff.txfrm.desc.tx_control =
6042 + host2hfa384x_16(hw->txbuff.txfrm.desc.tx_control);
6043 +
6044 + /* copy the header over to the txdesc */
6045 + memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, sizeof(p80211_hdr_t));
6046 +
6047 + /* if we're using host WEP, increase size by IV+ICV */
6048 + if (p80211_wep->data) {
6049 + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len+8);
6050 + // hw->txbuff.txfrm.desc.tx_control |= HFA384x_TX_NOENCRYPT_SET(1);
6051 + usbpktlen+=8;
6052 + } else {
6053 + hw->txbuff.txfrm.desc.data_len = host2hfa384x_16(skb->len);
6054 + }
6055 +
6056 + usbpktlen += skb->len;
6057 +
6058 + /* copy over the WEP IV if we are using host WEP */
6059 + ptr = hw->txbuff.txfrm.data;
6060 + if (p80211_wep->data) {
6061 + memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv));
6062 + ptr+= sizeof(p80211_wep->iv);
6063 + memcpy(ptr, p80211_wep->data, skb->len);
6064 + } else {
6065 + memcpy(ptr, skb->data, skb->len);
6066 + }
6067 + /* copy over the packet data */
6068 + ptr+= skb->len;
6069 +
6070 + /* copy over the WEP ICV if we are using host WEP */
6071 + if (p80211_wep->data) {
6072 + memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv));
6073 + }
6074 +
6075 + /* Send the USB packet */
6076 + usb_fill_bulk_urb( &(hw->tx_urb), hw->usb,
6077 + hw->endp_out,
6078 + &(hw->txbuff), ROUNDUP64(usbpktlen),
6079 + hfa384x_usbout_callback, hw->wlandev );
6080 + hw->tx_urb.transfer_flags |= USB_QUEUE_BULK;
6081 +
6082 + result = 1;
6083 + ret = submit_tx_urb(hw, &hw->tx_urb, GFP_ATOMIC);
6084 + if ( ret != 0 ) {
6085 + WLAN_LOG_ERROR(
6086 + "submit_tx_urb() failed, error=%d\n", ret);
6087 + result = 3;
6088 + }
6089 +
6090 + exit:
6091 + DBFEXIT;
6092 + return result;
6093 +}
6094 +
6095 +void hfa384x_tx_timeout(wlandevice_t *wlandev)
6096 +{
6097 + hfa384x_t *hw = wlandev->priv;
6098 + unsigned long flags;
6099 +
6100 + DBFENTER;
6101 +
6102 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
6103 +
6104 + if ( !hw->wlandev->hwremoved &&
6105 + /* Note the bitwise OR, not the logical OR. */
6106 + ( !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags) |
6107 + !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags) ) )
6108 + {
6109 + schedule_work(&hw->usb_work);
6110 + }
6111 +
6112 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
6113 +
6114 + DBFEXIT;
6115 +}
6116 +
6117 +/*----------------------------------------------------------------
6118 +* hfa384x_usbctlx_reaper_task
6119 +*
6120 +* Tasklet to delete dead CTLX objects
6121 +*
6122 +* Arguments:
6123 +* data ptr to a hfa384x_t
6124 +*
6125 +* Returns:
6126 +*
6127 +* Call context:
6128 +* Interrupt
6129 +----------------------------------------------------------------*/
6130 +static void hfa384x_usbctlx_reaper_task(unsigned long data)
6131 +{
6132 + hfa384x_t *hw = (hfa384x_t*)data;
6133 + struct list_head *entry;
6134 + struct list_head *temp;
6135 + unsigned long flags;
6136 +
6137 + DBFENTER;
6138 +
6139 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
6140 +
6141 + /* This list is guaranteed to be empty if someone
6142 + * has unplugged the adapter.
6143 + */
6144 + list_for_each_safe(entry, temp, &hw->ctlxq.reapable) {
6145 + hfa384x_usbctlx_t *ctlx;
6146 +
6147 + ctlx = list_entry(entry, hfa384x_usbctlx_t, list);
6148 + list_del(&ctlx->list);
6149 + kfree(ctlx);
6150 + }
6151 +
6152 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
6153 +
6154 + DBFEXIT;
6155 +}
6156 +
6157 +/*----------------------------------------------------------------
6158 +* hfa384x_usbctlx_completion_task
6159 +*
6160 +* Tasklet to call completion handlers for returned CTLXs
6161 +*
6162 +* Arguments:
6163 +* data ptr to hfa384x_t
6164 +*
6165 +* Returns:
6166 +* Nothing
6167 +*
6168 +* Call context:
6169 +* Interrupt
6170 +----------------------------------------------------------------*/
6171 +static void hfa384x_usbctlx_completion_task(unsigned long data)
6172 +{
6173 + hfa384x_t *hw = (hfa384x_t*)data;
6174 + struct list_head *entry;
6175 + struct list_head *temp;
6176 + unsigned long flags;
6177 +
6178 + int reap = 0;
6179 +
6180 + DBFENTER;
6181 +
6182 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
6183 +
6184 + /* This list is guaranteed to be empty if someone
6185 + * has unplugged the adapter ...
6186 + */
6187 + list_for_each_safe(entry, temp, &hw->ctlxq.completing) {
6188 + hfa384x_usbctlx_t *ctlx;
6189 +
6190 + ctlx = list_entry(entry, hfa384x_usbctlx_t, list);
6191 +
6192 + /* Call the completion function that this
6193 + * command was assigned, assuming it has one.
6194 + */
6195 + if ( ctlx->cmdcb != NULL ) {
6196 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
6197 + ctlx->cmdcb(hw, ctlx);
6198 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
6199 +
6200 + /* Make sure we don't try and complete
6201 + * this CTLX more than once!
6202 + */
6203 + ctlx->cmdcb = NULL;
6204 +
6205 + /* Did someone yank the adapter out
6206 + * while our list was (briefly) unlocked?
6207 + */
6208 + if ( hw->wlandev->hwremoved )
6209 + {
6210 + reap = 0;
6211 + break;
6212 + }
6213 + }
6214 +
6215 + /*
6216 + * "Reapable" CTLXs are ones which don't have any
6217 + * threads waiting for them to die. Hence they must
6218 + * be delivered to The Reaper!
6219 + */
6220 + if ( ctlx->reapable ) {
6221 + /* Move the CTLX off the "completing" list (hopefully)
6222 + * on to the "reapable" list where the reaper task
6223 + * can find it. And "reapable" means that this CTLX
6224 + * isn't sitting on a wait-queue somewhere.
6225 + */
6226 + list_move_tail(&ctlx->list, &hw->ctlxq.reapable);
6227 + reap = 1;
6228 + }
6229 +
6230 + complete(&ctlx->done);
6231 + }
6232 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
6233 +
6234 + if (reap)
6235 + tasklet_schedule(&hw->reaper_bh);
6236 +
6237 + DBFEXIT;
6238 +}
6239 +
6240 +/*----------------------------------------------------------------
6241 +* unlocked_usbctlx_cancel_async
6242 +*
6243 +* Mark the CTLX dead asynchronously, and ensure that the
6244 +* next command on the queue is run afterwards.
6245 +*
6246 +* Arguments:
6247 +* hw ptr to the hfa384x_t structure
6248 +* ctlx ptr to a CTLX structure
6249 +*
6250 +* Returns:
6251 +* 0 the CTLX's URB is inactive
6252 +* -EINPROGRESS the URB is currently being unlinked
6253 +*
6254 +* Call context:
6255 +* Either process or interrupt, but presumably interrupt
6256 +----------------------------------------------------------------*/
6257 +static int unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx)
6258 +{
6259 + int ret;
6260 +
6261 + DBFENTER;
6262 +
6263 + /*
6264 + * Try to delete the URB containing our request packet.
6265 + * If we succeed, then its completion handler will be
6266 + * called with a status of -ECONNRESET.
6267 + */
6268 + hw->ctlx_urb.transfer_flags |= URB_ASYNC_UNLINK;
6269 + ret = usb_unlink_urb(&hw->ctlx_urb);
6270 +
6271 + if (ret != -EINPROGRESS) {
6272 + /*
6273 + * The OUT URB had either already completed
6274 + * or was still in the pending queue, so the
6275 + * URB's completion function will not be called.
6276 + * We will have to complete the CTLX ourselves.
6277 + */
6278 + ctlx->state = CTLX_REQ_FAILED;
6279 + unlocked_usbctlx_complete(hw, ctlx);
6280 + ret = 0;
6281 + }
6282 +
6283 + DBFEXIT;
6284 +
6285 + return ret;
6286 +}
6287 +
6288 +/*----------------------------------------------------------------
6289 +* unlocked_usbctlx_complete
6290 +*
6291 +* A CTLX has completed. It may have been successful, it may not
6292 +* have been. At this point, the CTLX should be quiescent. The URBs
6293 +* aren't active and the timers should have been stopped.
6294 +*
6295 +* The CTLX is migrated to the "completing" queue, and the completing
6296 +* tasklet is scheduled.
6297 +*
6298 +* Arguments:
6299 +* hw ptr to a hfa384x_t structure
6300 +* ctlx ptr to a ctlx structure
6301 +*
6302 +* Returns:
6303 +* nothing
6304 +*
6305 +* Side effects:
6306 +*
6307 +* Call context:
6308 +* Either, assume interrupt
6309 +----------------------------------------------------------------*/
6310 +static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx)
6311 +{
6312 + DBFENTER;
6313 +
6314 + /* Timers have been stopped, and ctlx should be in
6315 + * a terminal state. Retire it from the "active"
6316 + * queue.
6317 + */
6318 + list_move_tail(&ctlx->list, &hw->ctlxq.completing);
6319 + tasklet_schedule(&hw->completion_bh);
6320 +
6321 + switch (ctlx->state) {
6322 + case CTLX_COMPLETE:
6323 + case CTLX_REQ_FAILED:
6324 + /* This are the correct terminating states. */
6325 + break;
6326 +
6327 + default:
6328 + WLAN_LOG_ERROR("CTLX[%d] not in a terminating state(%s)\n",
6329 + hfa384x2host_16(ctlx->outbuf.type),
6330 + ctlxstr(ctlx->state));
6331 + break;
6332 + } /* switch */
6333 +
6334 + DBFEXIT;
6335 +}
6336 +
6337 +/*----------------------------------------------------------------
6338 +* hfa384x_usbctlxq_run
6339 +*
6340 +* Checks to see if the head item is running. If not, starts it.
6341 +*
6342 +* Arguments:
6343 +* hw ptr to hfa384x_t
6344 +*
6345 +* Returns:
6346 +* nothing
6347 +*
6348 +* Side effects:
6349 +*
6350 +* Call context:
6351 +* any
6352 +----------------------------------------------------------------*/
6353 +static void
6354 +hfa384x_usbctlxq_run(hfa384x_t *hw)
6355 +{
6356 + unsigned long flags;
6357 + DBFENTER;
6358 +
6359 + /* acquire lock */
6360 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
6361 +
6362 + /* Only one active CTLX at any one time, because there's no
6363 + * other (reliable) way to match the response URB to the
6364 + * correct CTLX.
6365 + *
6366 + * Don't touch any of these CTLXs if the hardware
6367 + * has been removed or the USB subsystem is stalled.
6368 + */
6369 + if ( !list_empty(&hw->ctlxq.active) ||
6370 + test_bit(WORK_TX_HALT, &hw->usb_flags) ||
6371 + hw->wlandev->hwremoved )
6372 + goto unlock;
6373 +
6374 + while ( !list_empty(&hw->ctlxq.pending) ) {
6375 + hfa384x_usbctlx_t *head;
6376 + int result;
6377 +
6378 + /* This is the first pending command */
6379 + head = list_entry(hw->ctlxq.pending.next,
6380 + hfa384x_usbctlx_t,
6381 + list);
6382 +
6383 + /* We need to split this off to avoid a race condition */
6384 + list_move_tail(&head->list, &hw->ctlxq.active);
6385 +
6386 + /* Fill the out packet */
6387 + usb_fill_bulk_urb( &(hw->ctlx_urb), hw->usb,
6388 + hw->endp_out,
6389 + &(head->outbuf), ROUNDUP64(head->outbufsize),
6390 + hfa384x_ctlxout_callback, hw);
6391 + hw->ctlx_urb.transfer_flags |= USB_QUEUE_BULK;
6392 +
6393 + /* Now submit the URB and update the CTLX's state
6394 + */
6395 + if ((result = SUBMIT_URB(&hw->ctlx_urb, GFP_ATOMIC)) == 0) {
6396 + /* This CTLX is now running on the active queue */
6397 + head->state = CTLX_REQ_SUBMITTED;
6398 +
6399 + /* Start the OUT wait timer */
6400 + hw->req_timer_done = 0;
6401 + hw->reqtimer.expires = jiffies + HZ;
6402 + add_timer(&hw->reqtimer);
6403 +
6404 + /* Start the IN wait timer */
6405 + hw->resp_timer_done = 0;
6406 + hw->resptimer.expires = jiffies + 2*HZ;
6407 + add_timer(&hw->resptimer);
6408 +
6409 + break;
6410 + }
6411 +
6412 + if (result == -EPIPE) {
6413 + /* The OUT pipe needs resetting, so put
6414 + * this CTLX back in the "pending" queue
6415 + * and schedule a reset ...
6416 + */
6417 + WLAN_LOG_WARNING("%s tx pipe stalled: requesting reset\n",
6418 + hw->wlandev->netdev->name);
6419 + list_move(&head->list, &hw->ctlxq.pending);
6420 + set_bit(WORK_TX_HALT, &hw->usb_flags);
6421 + schedule_work(&hw->usb_work);
6422 + break;
6423 + }
6424 +
6425 + if (result == -ESHUTDOWN) {
6426 + WLAN_LOG_WARNING("%s urb shutdown!\n",
6427 + hw->wlandev->netdev->name);
6428 + break;
6429 + }
6430 +
6431 + WLAN_LOG_ERROR("Failed to submit CTLX[%d]: error=%d\n",
6432 + hfa384x2host_16(head->outbuf.type), result);
6433 + unlocked_usbctlx_complete(hw, head);
6434 + } /* while */
6435 +
6436 + unlock:
6437 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
6438 +
6439 + DBFEXIT;
6440 +}
6441 +
6442 +
6443 +/*----------------------------------------------------------------
6444 +* hfa384x_usbin_callback
6445 +*
6446 +* Callback for URBs on the BULKIN endpoint.
6447 +*
6448 +* Arguments:
6449 +* urb ptr to the completed urb
6450 +*
6451 +* Returns:
6452 +* nothing
6453 +*
6454 +* Side effects:
6455 +*
6456 +* Call context:
6457 +* interrupt
6458 +----------------------------------------------------------------*/
6459 +static void hfa384x_usbin_callback(struct urb *urb)
6460 +{
6461 + wlandevice_t *wlandev = urb->context;
6462 + hfa384x_t *hw;
6463 + hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) urb->transfer_buffer;
6464 + struct sk_buff *skb = NULL;
6465 + int result;
6466 + int urb_status;
6467 + u16 type;
6468 +
6469 + enum USBIN_ACTION {
6470 + HANDLE,
6471 + RESUBMIT,
6472 + ABORT
6473 + } action;
6474 +
6475 + DBFENTER;
6476 +
6477 + if ( !wlandev ||
6478 + !wlandev->netdev ||
6479 + wlandev->hwremoved )
6480 + goto exit;
6481 +
6482 + hw = wlandev->priv;
6483 + if (!hw)
6484 + goto exit;
6485 +
6486 + skb = hw->rx_urb_skb;
6487 + if (!skb || (skb->data != urb->transfer_buffer)) {
6488 + BUG();
6489 + }
6490 + hw->rx_urb_skb = NULL;
6491 +
6492 + /* Check for error conditions within the URB */
6493 + switch (urb->status) {
6494 + case 0:
6495 + action = HANDLE;
6496 +
6497 + /* Check for short packet */
6498 + if ( urb->actual_length == 0 ) {
6499 + ++(wlandev->linux_stats.rx_errors);
6500 + ++(wlandev->linux_stats.rx_length_errors);
6501 + action = RESUBMIT;
6502 + }
6503 + break;
6504 +
6505 + case -EPIPE:
6506 + WLAN_LOG_WARNING("%s rx pipe stalled: requesting reset\n",
6507 + wlandev->netdev->name);
6508 + if ( !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags) )
6509 + schedule_work(&hw->usb_work);
6510 + ++(wlandev->linux_stats.rx_errors);
6511 + action = ABORT;
6512 + break;
6513 +
6514 + case -EILSEQ:
6515 + case -ETIMEDOUT:
6516 + case -EPROTO:
6517 + if ( !test_and_set_bit(THROTTLE_RX, &hw->usb_flags) &&
6518 + !timer_pending(&hw->throttle) ) {
6519 + mod_timer(&hw->throttle, jiffies + THROTTLE_JIFFIES);
6520 + }
6521 + ++(wlandev->linux_stats.rx_errors);
6522 + action = ABORT;
6523 + break;
6524 +
6525 + case -EOVERFLOW:
6526 + ++(wlandev->linux_stats.rx_over_errors);
6527 + action = RESUBMIT;
6528 + break;
6529 +
6530 + case -ENODEV:
6531 + case -ESHUTDOWN:
6532 + WLAN_LOG_DEBUG(3,"status=%d, device removed.\n", urb->status);
6533 + action = ABORT;
6534 + break;
6535 +
6536 + case -ENOENT:
6537 + case -ECONNRESET:
6538 + WLAN_LOG_DEBUG(3,"status=%d, urb explicitly unlinked.\n", urb->status);
6539 + action = ABORT;
6540 + break;
6541 +
6542 + default:
6543 + WLAN_LOG_DEBUG(3,"urb status=%d, transfer flags=0x%x\n",
6544 + urb->status, urb->transfer_flags);
6545 + ++(wlandev->linux_stats.rx_errors);
6546 + action = RESUBMIT;
6547 + break;
6548 + }
6549 +
6550 + urb_status = urb->status;
6551 +
6552 + if (action != ABORT) {
6553 + /* Repost the RX URB */
6554 + result = submit_rx_urb(hw, GFP_ATOMIC);
6555 +
6556 + if (result != 0) {
6557 + WLAN_LOG_ERROR(
6558 + "Fatal, failed to resubmit rx_urb. error=%d\n",
6559 + result);
6560 + }
6561 + }
6562 +
6563 + /* Handle any USB-IN packet */
6564 + /* Note: the check of the sw_support field, the type field doesn't
6565 + * have bit 12 set like the docs suggest.
6566 + */
6567 + type = hfa384x2host_16(usbin->type);
6568 + if (HFA384x_USB_ISRXFRM(type)) {
6569 + if (action == HANDLE) {
6570 + if (usbin->txfrm.desc.sw_support == 0x0123) {
6571 + hfa384x_usbin_txcompl(wlandev, usbin);
6572 + } else {
6573 + skb_put(skb, sizeof(*usbin));
6574 + hfa384x_usbin_rx(wlandev, skb);
6575 + skb = NULL;
6576 + }
6577 + }
6578 + goto exit;
6579 + }
6580 + if (HFA384x_USB_ISTXFRM(type)) {
6581 + if (action == HANDLE)
6582 + hfa384x_usbin_txcompl(wlandev, usbin);
6583 + goto exit;
6584 + }
6585 + switch (type) {
6586 + case HFA384x_USB_INFOFRM:
6587 + if (action == ABORT)
6588 + goto exit;
6589 + if (action == HANDLE)
6590 + hfa384x_usbin_info(wlandev, usbin);
6591 + break;
6592 +
6593 + case HFA384x_USB_CMDRESP:
6594 + case HFA384x_USB_WRIDRESP:
6595 + case HFA384x_USB_RRIDRESP:
6596 + case HFA384x_USB_WMEMRESP:
6597 + case HFA384x_USB_RMEMRESP:
6598 + /* ALWAYS, ALWAYS, ALWAYS handle this CTLX!!!! */
6599 + hfa384x_usbin_ctlx(hw, usbin, urb_status);
6600 + break;
6601 +
6602 + case HFA384x_USB_BUFAVAIL:
6603 + WLAN_LOG_DEBUG(3,"Received BUFAVAIL packet, frmlen=%d\n",
6604 + usbin->bufavail.frmlen);
6605 + break;
6606 +
6607 + case HFA384x_USB_ERROR:
6608 + WLAN_LOG_DEBUG(3,"Received USB_ERROR packet, errortype=%d\n",
6609 + usbin->usberror.errortype);
6610 + break;
6611 +
6612 + default:
6613 + WLAN_LOG_DEBUG(3,"Unrecognized USBIN packet, type=%x, status=%d\n",
6614 + usbin->type, urb_status);
6615 + break;
6616 + } /* switch */
6617 +
6618 +exit:
6619 +
6620 + if (skb)
6621 + dev_kfree_skb(skb);
6622 +
6623 + DBFEXIT;
6624 +}
6625 +
6626 +
6627 +/*----------------------------------------------------------------
6628 +* hfa384x_usbin_ctlx
6629 +*
6630 +* We've received a URB containing a Prism2 "response" message.
6631 +* This message needs to be matched up with a CTLX on the active
6632 +* queue and our state updated accordingly.
6633 +*
6634 +* Arguments:
6635 +* hw ptr to hfa384x_t
6636 +* usbin ptr to USB IN packet
6637 +* urb_status status of this Bulk-In URB
6638 +*
6639 +* Returns:
6640 +* nothing
6641 +*
6642 +* Side effects:
6643 +*
6644 +* Call context:
6645 +* interrupt
6646 +----------------------------------------------------------------*/
6647 +static void hfa384x_usbin_ctlx(hfa384x_t *hw, hfa384x_usbin_t *usbin,
6648 + int urb_status)
6649 +{
6650 + hfa384x_usbctlx_t *ctlx;
6651 + int run_queue = 0;
6652 + unsigned long flags;
6653 +
6654 + DBFENTER;
6655 +
6656 +retry:
6657 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
6658 +
6659 + /* There can be only one CTLX on the active queue
6660 + * at any one time, and this is the CTLX that the
6661 + * timers are waiting for.
6662 + */
6663 + if ( list_empty(&hw->ctlxq.active) ) {
6664 + goto unlock;
6665 + }
6666 +
6667 + /* Remove the "response timeout". It's possible that
6668 + * we are already too late, and that the timeout is
6669 + * already running. And that's just too bad for us,
6670 + * because we could lose our CTLX from the active
6671 + * queue here ...
6672 + */
6673 + if (del_timer(&hw->resptimer) == 0) {
6674 + if (hw->resp_timer_done == 0) {
6675 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
6676 + goto retry;
6677 + }
6678 + }
6679 + else {
6680 + hw->resp_timer_done = 1;
6681 + }
6682 +
6683 + ctlx = get_active_ctlx(hw);
6684 +
6685 + if (urb_status != 0) {
6686 + /*
6687 + * Bad CTLX, so get rid of it. But we only
6688 + * remove it from the active queue if we're no
6689 + * longer expecting the OUT URB to complete.
6690 + */
6691 + if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0)
6692 + run_queue = 1;
6693 + } else {
6694 + const u16 intype = (usbin->type&~host2hfa384x_16(0x8000));
6695 +
6696 + /*
6697 + * Check that our message is what we're expecting ...
6698 + */
6699 + if (ctlx->outbuf.type != intype) {
6700 + WLAN_LOG_WARNING("Expected IN[%d], received IN[%d] - ignored.\n",
6701 + hfa384x2host_16(ctlx->outbuf.type),
6702 + hfa384x2host_16(intype));
6703 + goto unlock;
6704 + }
6705 +
6706 + /* This URB has succeeded, so grab the data ... */
6707 + memcpy(&ctlx->inbuf, usbin, sizeof(ctlx->inbuf));
6708 +
6709 + switch (ctlx->state) {
6710 + case CTLX_REQ_SUBMITTED:
6711 + /*
6712 + * We have received our response URB before
6713 + * our request has been acknowledged. Odd,
6714 + * but our OUT URB is still alive...
6715 + */
6716 + WLAN_LOG_DEBUG(0, "Causality violation: please reboot Universe, or email linux-wlan-devel@lists.linux-wlan.com\n");
6717 + ctlx->state = CTLX_RESP_COMPLETE;
6718 + break;
6719 +
6720 + case CTLX_REQ_COMPLETE:
6721 + /*
6722 + * This is the usual path: our request
6723 + * has already been acknowledged, and
6724 + * now we have received the reply too.
6725 + */
6726 + ctlx->state = CTLX_COMPLETE;
6727 + unlocked_usbctlx_complete(hw, ctlx);
6728 + run_queue = 1;
6729 + break;
6730 +
6731 + default:
6732 + /*
6733 + * Throw this CTLX away ...
6734 + */
6735 + WLAN_LOG_ERROR("Matched IN URB, CTLX[%d] in invalid state(%s)."
6736 + " Discarded.\n",
6737 + hfa384x2host_16(ctlx->outbuf.type),
6738 + ctlxstr(ctlx->state));
6739 + if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0)
6740 + run_queue = 1;
6741 + break;
6742 + } /* switch */
6743 + }
6744 +
6745 +unlock:
6746 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
6747 +
6748 + if (run_queue)
6749 + hfa384x_usbctlxq_run(hw);
6750 +
6751 + DBFEXIT;
6752 +}
6753 +
6754 +
6755 +/*----------------------------------------------------------------
6756 +* hfa384x_usbin_txcompl
6757 +*
6758 +* At this point we have the results of a previous transmit.
6759 +*
6760 +* Arguments:
6761 +* wlandev wlan device
6762 +* usbin ptr to the usb transfer buffer
6763 +*
6764 +* Returns:
6765 +* nothing
6766 +*
6767 +* Side effects:
6768 +*
6769 +* Call context:
6770 +* interrupt
6771 +----------------------------------------------------------------*/
6772 +static void hfa384x_usbin_txcompl(wlandevice_t *wlandev, hfa384x_usbin_t *usbin)
6773 +{
6774 + u16 status;
6775 + DBFENTER;
6776 +
6777 + status = hfa384x2host_16(usbin->type); /* yeah I know it says type...*/
6778 +
6779 + /* Was there an error? */
6780 + if (HFA384x_TXSTATUS_ISERROR(status)) {
6781 + prism2sta_ev_txexc(wlandev, status);
6782 + } else {
6783 + prism2sta_ev_tx(wlandev, status);
6784 + }
6785 + // prism2sta_ev_alloc(wlandev);
6786 +
6787 + DBFEXIT;
6788 +}
6789 +
6790 +
6791 +/*----------------------------------------------------------------
6792 +* hfa384x_usbin_rx
6793 +*
6794 +* At this point we have a successful received a rx frame packet.
6795 +*
6796 +* Arguments:
6797 +* wlandev wlan device
6798 +* usbin ptr to the usb transfer buffer
6799 +*
6800 +* Returns:
6801 +* nothing
6802 +*
6803 +* Side effects:
6804 +*
6805 +* Call context:
6806 +* interrupt
6807 +----------------------------------------------------------------*/
6808 +static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb)
6809 +{
6810 + hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) skb->data;
6811 + hfa384x_t *hw = wlandev->priv;
6812 + int hdrlen;
6813 + p80211_rxmeta_t *rxmeta;
6814 + u16 data_len;
6815 + u16 fc;
6816 +
6817 + DBFENTER;
6818 +
6819 + /* Byte order convert once up front. */
6820 + usbin->rxfrm.desc.status =
6821 + hfa384x2host_16(usbin->rxfrm.desc.status);
6822 + usbin->rxfrm.desc.time =
6823 + hfa384x2host_32(usbin->rxfrm.desc.time);
6824 +
6825 + /* Now handle frame based on port# */
6826 + switch( HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status) )
6827 + {
6828 + case 0:
6829 + fc = ieee2host16(usbin->rxfrm.desc.frame_control);
6830 +
6831 + /* If exclude and we receive an unencrypted, drop it */
6832 + if ( (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED) &&
6833 + !WLAN_GET_FC_ISWEP(fc)){
6834 + goto done;
6835 + }
6836 +
6837 + data_len = hfa384x2host_16(usbin->rxfrm.desc.data_len);
6838 +
6839 + /* How much header data do we have? */
6840 + hdrlen = p80211_headerlen(fc);
6841 +
6842 + /* Pull off the descriptor */
6843 + skb_pull(skb, sizeof(hfa384x_rx_frame_t));
6844 +
6845 + /* Now shunt the header block up against the data block
6846 + * with an "overlapping" copy
6847 + */
6848 + memmove(skb_push(skb, hdrlen),
6849 + &usbin->rxfrm.desc.frame_control,
6850 + hdrlen);
6851 +
6852 + skb->dev = wlandev->netdev;
6853 + skb->dev->last_rx = jiffies;
6854 +
6855 + /* And set the frame length properly */
6856 + skb_trim(skb, data_len + hdrlen);
6857 +
6858 + /* The prism2 series does not return the CRC */
6859 + memset(skb_put(skb, WLAN_CRC_LEN), 0xff, WLAN_CRC_LEN);
6860 +
6861 + skb_reset_mac_header(skb);
6862 +
6863 + /* Attach the rxmeta, set some stuff */
6864 + p80211skb_rxmeta_attach(wlandev, skb);
6865 + rxmeta = P80211SKB_RXMETA(skb);
6866 + rxmeta->mactime = usbin->rxfrm.desc.time;
6867 + rxmeta->rxrate = usbin->rxfrm.desc.rate;
6868 + rxmeta->signal = usbin->rxfrm.desc.signal - hw->dbmadjust;
6869 + rxmeta->noise = usbin->rxfrm.desc.silence - hw->dbmadjust;
6870 +
6871 + prism2sta_ev_rx(wlandev, skb);
6872 +
6873 + break;
6874 +
6875 + case 7:
6876 + if ( ! HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status) ) {
6877 + /* Copy to wlansnif skb */
6878 + hfa384x_int_rxmonitor( wlandev, &usbin->rxfrm);
6879 + dev_kfree_skb(skb);
6880 + } else {
6881 + WLAN_LOG_DEBUG(3,"Received monitor frame: FCSerr set\n");
6882 + }
6883 + break;
6884 +
6885 + default:
6886 + WLAN_LOG_WARNING("Received frame on unsupported port=%d\n",
6887 + HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status) );
6888 + goto done;
6889 + break;
6890 + }
6891 +
6892 +done:
6893 + DBFEXIT;
6894 + return;
6895 +}
6896 +
6897 +/*----------------------------------------------------------------
6898 +* hfa384x_int_rxmonitor
6899 +*
6900 +* Helper function for int_rx. Handles monitor frames.
6901 +* Note that this function allocates space for the FCS and sets it
6902 +* to 0xffffffff. The hfa384x doesn't give us the FCS value but the
6903 +* higher layers expect it. 0xffffffff is used as a flag to indicate
6904 +* the FCS is bogus.
6905 +*
6906 +* Arguments:
6907 +* wlandev wlan device structure
6908 +* rxfrm rx descriptor read from card in int_rx
6909 +*
6910 +* Returns:
6911 +* nothing
6912 +*
6913 +* Side effects:
6914 +* Allocates an skb and passes it up via the PF_PACKET interface.
6915 +* Call context:
6916 +* interrupt
6917 +----------------------------------------------------------------*/
6918 +static void hfa384x_int_rxmonitor( wlandevice_t *wlandev, hfa384x_usb_rxfrm_t *rxfrm)
6919 +{
6920 + hfa384x_rx_frame_t *rxdesc = &(rxfrm->desc);
6921 + unsigned int hdrlen = 0;
6922 + unsigned int datalen = 0;
6923 + unsigned int skblen = 0;
6924 + u8 *datap;
6925 + u16 fc;
6926 + struct sk_buff *skb;
6927 + hfa384x_t *hw = wlandev->priv;
6928 +
6929 +
6930 + DBFENTER;
6931 + /* Don't forget the status, time, and data_len fields are in host order */
6932 + /* Figure out how big the frame is */
6933 + fc = ieee2host16(rxdesc->frame_control);
6934 + hdrlen = p80211_headerlen(fc);
6935 + datalen = hfa384x2host_16(rxdesc->data_len);
6936 +
6937 + /* Allocate an ind message+framesize skb */
6938 + skblen = sizeof(p80211_caphdr_t) +
6939 + hdrlen + datalen + WLAN_CRC_LEN;
6940 +
6941 + /* sanity check the length */
6942 + if ( skblen >
6943 + (sizeof(p80211_caphdr_t) +
6944 + WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN) ) {
6945 + WLAN_LOG_DEBUG(1, "overlen frm: len=%zd\n",
6946 + skblen - sizeof(p80211_caphdr_t));
6947 + }
6948 +
6949 + if ( (skb = dev_alloc_skb(skblen)) == NULL ) {
6950 + WLAN_LOG_ERROR("alloc_skb failed trying to allocate %d bytes\n", skblen);
6951 + return;
6952 + }
6953 +
6954 + /* only prepend the prism header if in the right mode */
6955 + if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) &&
6956 + (hw->sniffhdr != 0)) {
6957 + p80211_caphdr_t *caphdr;
6958 + /* The NEW header format! */
6959 + datap = skb_put(skb, sizeof(p80211_caphdr_t));
6960 + caphdr = (p80211_caphdr_t*) datap;
6961 +
6962 + caphdr->version = htonl(P80211CAPTURE_VERSION);
6963 + caphdr->length = htonl(sizeof(p80211_caphdr_t));
6964 + caphdr->mactime = __cpu_to_be64(rxdesc->time) * 1000;
6965 + caphdr->hosttime = __cpu_to_be64(jiffies);
6966 + caphdr->phytype = htonl(4); /* dss_dot11_b */
6967 + caphdr->channel = htonl(hw->sniff_channel);
6968 + caphdr->datarate = htonl(rxdesc->rate);
6969 + caphdr->antenna = htonl(0); /* unknown */
6970 + caphdr->priority = htonl(0); /* unknown */
6971 + caphdr->ssi_type = htonl(3); /* rssi_raw */
6972 + caphdr->ssi_signal = htonl(rxdesc->signal);
6973 + caphdr->ssi_noise = htonl(rxdesc->silence);
6974 + caphdr->preamble = htonl(0); /* unknown */
6975 + caphdr->encoding = htonl(1); /* cck */
6976 + }
6977 +
6978 + /* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */
6979 + datap = skb_put(skb, hdrlen);
6980 + memcpy( datap, &(rxdesc->frame_control), hdrlen);
6981 +
6982 + /* If any, copy the data from the card to the skb */
6983 + if ( datalen > 0 )
6984 + {
6985 + datap = skb_put(skb, datalen);
6986 + memcpy(datap, rxfrm->data, datalen);
6987 +
6988 + /* check for unencrypted stuff if WEP bit set. */
6989 + if (*(datap - hdrlen + 1) & 0x40) // wep set
6990 + if ((*(datap) == 0xaa) && (*(datap+1) == 0xaa))
6991 + *(datap - hdrlen + 1) &= 0xbf; // clear wep; it's the 802.2 header!
6992 + }
6993 +
6994 + if (hw->sniff_fcs) {
6995 + /* Set the FCS */
6996 + datap = skb_put(skb, WLAN_CRC_LEN);
6997 + memset( datap, 0xff, WLAN_CRC_LEN);
6998 + }
6999 +
7000 + /* pass it back up */
7001 + prism2sta_ev_rx(wlandev, skb);
7002 +
7003 + DBFEXIT;
7004 + return;
7005 +}
7006 +
7007 +
7008 +
7009 +/*----------------------------------------------------------------
7010 +* hfa384x_usbin_info
7011 +*
7012 +* At this point we have a successful received a Prism2 info frame.
7013 +*
7014 +* Arguments:
7015 +* wlandev wlan device
7016 +* usbin ptr to the usb transfer buffer
7017 +*
7018 +* Returns:
7019 +* nothing
7020 +*
7021 +* Side effects:
7022 +*
7023 +* Call context:
7024 +* interrupt
7025 +----------------------------------------------------------------*/
7026 +static void hfa384x_usbin_info(wlandevice_t *wlandev, hfa384x_usbin_t *usbin)
7027 +{
7028 + DBFENTER;
7029 +
7030 + usbin->infofrm.info.framelen = hfa384x2host_16(usbin->infofrm.info.framelen);
7031 + prism2sta_ev_info(wlandev, &usbin->infofrm.info);
7032 +
7033 + DBFEXIT;
7034 +}
7035 +
7036 +
7037 +
7038 +/*----------------------------------------------------------------
7039 +* hfa384x_usbout_callback
7040 +*
7041 +* Callback for URBs on the BULKOUT endpoint.
7042 +*
7043 +* Arguments:
7044 +* urb ptr to the completed urb
7045 +*
7046 +* Returns:
7047 +* nothing
7048 +*
7049 +* Side effects:
7050 +*
7051 +* Call context:
7052 +* interrupt
7053 +----------------------------------------------------------------*/
7054 +static void hfa384x_usbout_callback(struct urb *urb)
7055 +{
7056 + wlandevice_t *wlandev = urb->context;
7057 + hfa384x_usbout_t *usbout = urb->transfer_buffer;
7058 + DBFENTER;
7059 +
7060 +#ifdef DEBUG_USB
7061 + dbprint_urb(urb);
7062 +#endif
7063 +
7064 + if ( wlandev &&
7065 + wlandev->netdev ) {
7066 +
7067 + switch(urb->status) {
7068 + case 0:
7069 + hfa384x_usbout_tx(wlandev, usbout);
7070 + break;
7071 +
7072 + case -EPIPE:
7073 + {
7074 + hfa384x_t *hw = wlandev->priv;
7075 + WLAN_LOG_WARNING("%s tx pipe stalled: requesting reset\n",
7076 + wlandev->netdev->name);
7077 + if ( !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags) )
7078 + schedule_work(&hw->usb_work);
7079 + ++(wlandev->linux_stats.tx_errors);
7080 + break;
7081 + }
7082 +
7083 + case -EPROTO:
7084 + case -ETIMEDOUT:
7085 + case -EILSEQ:
7086 + {
7087 + hfa384x_t *hw = wlandev->priv;
7088 +
7089 + if ( !test_and_set_bit(THROTTLE_TX, &hw->usb_flags)
7090 + && !timer_pending(&hw->throttle) ) {
7091 + mod_timer(&hw->throttle,
7092 + jiffies + THROTTLE_JIFFIES);
7093 + }
7094 + ++(wlandev->linux_stats.tx_errors);
7095 + netif_stop_queue(wlandev->netdev);
7096 + break;
7097 + }
7098 +
7099 + case -ENOENT:
7100 + case -ESHUTDOWN:
7101 + /* Ignorable errors */
7102 + break;
7103 +
7104 + default:
7105 + WLAN_LOG_INFO("unknown urb->status=%d\n", urb->status);
7106 + ++(wlandev->linux_stats.tx_errors);
7107 + break;
7108 + } /* switch */
7109 + }
7110 +
7111 + DBFEXIT;
7112 +}
7113 +
7114 +
7115 +/*----------------------------------------------------------------
7116 +* hfa384x_ctlxout_callback
7117 +*
7118 +* Callback for control data on the BULKOUT endpoint.
7119 +*
7120 +* Arguments:
7121 +* urb ptr to the completed urb
7122 +*
7123 +* Returns:
7124 +* nothing
7125 +*
7126 +* Side effects:
7127 +*
7128 +* Call context:
7129 +* interrupt
7130 +----------------------------------------------------------------*/
7131 +static void hfa384x_ctlxout_callback(struct urb *urb)
7132 +{
7133 + hfa384x_t *hw = urb->context;
7134 + int delete_resptimer = 0;
7135 + int timer_ok = 1;
7136 + int run_queue = 0;
7137 + hfa384x_usbctlx_t *ctlx;
7138 + unsigned long flags;
7139 +
7140 + DBFENTER;
7141 +
7142 + WLAN_LOG_DEBUG(3,"urb->status=%d\n", urb->status);
7143 +#ifdef DEBUG_USB
7144 + dbprint_urb(urb);
7145 +#endif
7146 + if ( (urb->status == -ESHUTDOWN) ||
7147 + (urb->status == -ENODEV) ||
7148 + (hw == NULL) )
7149 + goto done;
7150 +
7151 +retry:
7152 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
7153 +
7154 + /*
7155 + * Only one CTLX at a time on the "active" list, and
7156 + * none at all if we are unplugged. However, we can
7157 + * rely on the disconnect function to clean everything
7158 + * up if someone unplugged the adapter.
7159 + */
7160 + if ( list_empty(&hw->ctlxq.active) ) {
7161 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7162 + goto done;
7163 + }
7164 +
7165 + /*
7166 + * Having something on the "active" queue means
7167 + * that we have timers to worry about ...
7168 + */
7169 + if (del_timer(&hw->reqtimer) == 0) {
7170 + if (hw->req_timer_done == 0) {
7171 + /*
7172 + * This timer was actually running while we
7173 + * were trying to delete it. Let it terminate
7174 + * gracefully instead.
7175 + */
7176 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7177 + goto retry;
7178 + }
7179 + }
7180 + else {
7181 + hw->req_timer_done = 1;
7182 + }
7183 +
7184 + ctlx = get_active_ctlx(hw);
7185 +
7186 + if ( urb->status == 0 ) {
7187 + /* Request portion of a CTLX is successful */
7188 + switch ( ctlx->state ) {
7189 + case CTLX_REQ_SUBMITTED:
7190 + /* This OUT-ACK received before IN */
7191 + ctlx->state = CTLX_REQ_COMPLETE;
7192 + break;
7193 +
7194 + case CTLX_RESP_COMPLETE:
7195 + /* IN already received before this OUT-ACK,
7196 + * so this command must now be complete.
7197 + */
7198 + ctlx->state = CTLX_COMPLETE;
7199 + unlocked_usbctlx_complete(hw, ctlx);
7200 + run_queue = 1;
7201 + break;
7202 +
7203 + default:
7204 + /* This is NOT a valid CTLX "success" state! */
7205 + WLAN_LOG_ERROR(
7206 + "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n",
7207 + hfa384x2host_16(ctlx->outbuf.type),
7208 + ctlxstr(ctlx->state), urb->status);
7209 + break;
7210 + } /* switch */
7211 + } else {
7212 + /* If the pipe has stalled then we need to reset it */
7213 + if ( (urb->status == -EPIPE) &&
7214 + !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags) ) {
7215 + WLAN_LOG_WARNING("%s tx pipe stalled: requesting reset\n",
7216 + hw->wlandev->netdev->name);
7217 + schedule_work(&hw->usb_work);
7218 + }
7219 +
7220 + /* If someone cancels the OUT URB then its status
7221 + * should be either -ECONNRESET or -ENOENT.
7222 + */
7223 + ctlx->state = CTLX_REQ_FAILED;
7224 + unlocked_usbctlx_complete(hw, ctlx);
7225 + delete_resptimer = 1;
7226 + run_queue = 1;
7227 + }
7228 +
7229 + delresp:
7230 + if (delete_resptimer) {
7231 + if ((timer_ok = del_timer(&hw->resptimer)) != 0) {
7232 + hw->resp_timer_done = 1;
7233 + }
7234 + }
7235 +
7236 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7237 +
7238 + if ( !timer_ok && (hw->resp_timer_done == 0) ) {
7239 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
7240 + goto delresp;
7241 + }
7242 +
7243 + if (run_queue)
7244 + hfa384x_usbctlxq_run(hw);
7245 +
7246 + done:
7247 + DBFEXIT;
7248 +}
7249 +
7250 +
7251 +/*----------------------------------------------------------------
7252 +* hfa384x_usbctlx_reqtimerfn
7253 +*
7254 +* Timer response function for CTLX request timeouts. If this
7255 +* function is called, it means that the callback for the OUT
7256 +* URB containing a Prism2.x XXX_Request was never called.
7257 +*
7258 +* Arguments:
7259 +* data a ptr to the hfa384x_t
7260 +*
7261 +* Returns:
7262 +* nothing
7263 +*
7264 +* Side effects:
7265 +*
7266 +* Call context:
7267 +* interrupt
7268 +----------------------------------------------------------------*/
7269 +static void
7270 +hfa384x_usbctlx_reqtimerfn(unsigned long data)
7271 +{
7272 + hfa384x_t *hw = (hfa384x_t*)data;
7273 + unsigned long flags;
7274 + DBFENTER;
7275 +
7276 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
7277 +
7278 + hw->req_timer_done = 1;
7279 +
7280 + /* Removing the hardware automatically empties
7281 + * the active list ...
7282 + */
7283 + if ( !list_empty(&hw->ctlxq.active) )
7284 + {
7285 + /*
7286 + * We must ensure that our URB is removed from
7287 + * the system, if it hasn't already expired.
7288 + */
7289 + hw->ctlx_urb.transfer_flags |= URB_ASYNC_UNLINK;
7290 + if (usb_unlink_urb(&hw->ctlx_urb) == -EINPROGRESS)
7291 + {
7292 + hfa384x_usbctlx_t *ctlx = get_active_ctlx(hw);
7293 +
7294 + ctlx->state = CTLX_REQ_FAILED;
7295 +
7296 + /* This URB was active, but has now been
7297 + * cancelled. It will now have a status of
7298 + * -ECONNRESET in the callback function.
7299 + *
7300 + * We are cancelling this CTLX, so we're
7301 + * not going to need to wait for a response.
7302 + * The URB's callback function will check
7303 + * that this timer is truly dead.
7304 + */
7305 + if (del_timer(&hw->resptimer) != 0)
7306 + hw->resp_timer_done = 1;
7307 + }
7308 + }
7309 +
7310 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7311 +
7312 + DBFEXIT;
7313 +}
7314 +
7315 +
7316 +/*----------------------------------------------------------------
7317 +* hfa384x_usbctlx_resptimerfn
7318 +*
7319 +* Timer response function for CTLX response timeouts. If this
7320 +* function is called, it means that the callback for the IN
7321 +* URB containing a Prism2.x XXX_Response was never called.
7322 +*
7323 +* Arguments:
7324 +* data a ptr to the hfa384x_t
7325 +*
7326 +* Returns:
7327 +* nothing
7328 +*
7329 +* Side effects:
7330 +*
7331 +* Call context:
7332 +* interrupt
7333 +----------------------------------------------------------------*/
7334 +static void
7335 +hfa384x_usbctlx_resptimerfn(unsigned long data)
7336 +{
7337 + hfa384x_t *hw = (hfa384x_t*)data;
7338 + unsigned long flags;
7339 +
7340 + DBFENTER;
7341 +
7342 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
7343 +
7344 + hw->resp_timer_done = 1;
7345 +
7346 + /* The active list will be empty if the
7347 + * adapter has been unplugged ...
7348 + */
7349 + if ( !list_empty(&hw->ctlxq.active) )
7350 + {
7351 + hfa384x_usbctlx_t *ctlx = get_active_ctlx(hw);
7352 +
7353 + if ( unlocked_usbctlx_cancel_async(hw, ctlx) == 0 )
7354 + {
7355 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7356 + hfa384x_usbctlxq_run(hw);
7357 + goto done;
7358 + }
7359 + }
7360 +
7361 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7362 +
7363 + done:
7364 + DBFEXIT;
7365 +}
7366 +
7367 +/*----------------------------------------------------------------
7368 +* hfa384x_usb_throttlefn
7369 +*
7370 +*
7371 +* Arguments:
7372 +* data ptr to hw
7373 +*
7374 +* Returns:
7375 +* Nothing
7376 +*
7377 +* Side effects:
7378 +*
7379 +* Call context:
7380 +* Interrupt
7381 +----------------------------------------------------------------*/
7382 +static void
7383 +hfa384x_usb_throttlefn(unsigned long data)
7384 +{
7385 + hfa384x_t *hw = (hfa384x_t*)data;
7386 + unsigned long flags;
7387 +
7388 + DBFENTER;
7389 +
7390 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
7391 +
7392 + /*
7393 + * We need to check BOTH the RX and the TX throttle controls,
7394 + * so we use the bitwise OR instead of the logical OR.
7395 + */
7396 + WLAN_LOG_DEBUG(3, "flags=0x%lx\n", hw->usb_flags);
7397 + if ( !hw->wlandev->hwremoved &&
7398 + (
7399 + (test_and_clear_bit(THROTTLE_RX, &hw->usb_flags) &&
7400 + !test_and_set_bit(WORK_RX_RESUME, &hw->usb_flags))
7401 + |
7402 + (test_and_clear_bit(THROTTLE_TX, &hw->usb_flags) &&
7403 + !test_and_set_bit(WORK_TX_RESUME, &hw->usb_flags))
7404 + ) )
7405 + {
7406 + schedule_work(&hw->usb_work);
7407 + }
7408 +
7409 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7410 +
7411 + DBFEXIT;
7412 +}
7413 +
7414 +
7415 +/*----------------------------------------------------------------
7416 +* hfa384x_usbctlx_submit
7417 +*
7418 +* Called from the doxxx functions to submit a CTLX to the queue
7419 +*
7420 +* Arguments:
7421 +* hw ptr to the hw struct
7422 +* ctlx ctlx structure to enqueue
7423 +*
7424 +* Returns:
7425 +* -ENODEV if the adapter is unplugged
7426 +* 0
7427 +*
7428 +* Side effects:
7429 +*
7430 +* Call context:
7431 +* process or interrupt
7432 +----------------------------------------------------------------*/
7433 +static int
7434 +hfa384x_usbctlx_submit(
7435 + hfa384x_t *hw,
7436 + hfa384x_usbctlx_t *ctlx)
7437 +{
7438 + unsigned long flags;
7439 + int ret;
7440 +
7441 + DBFENTER;
7442 +
7443 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
7444 +
7445 + if (hw->wlandev->hwremoved) {
7446 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7447 + ret = -ENODEV;
7448 + } else {
7449 + ctlx->state = CTLX_PENDING;
7450 + list_add_tail(&ctlx->list, &hw->ctlxq.pending);
7451 +
7452 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
7453 + hfa384x_usbctlxq_run(hw);
7454 + ret = 0;
7455 + }
7456 +
7457 + DBFEXIT;
7458 + return ret;
7459 +}
7460 +
7461 +
7462 +/*----------------------------------------------------------------
7463 +* hfa384x_usbout_tx
7464 +*
7465 +* At this point we have finished a send of a frame. Mark the URB
7466 +* as available and call ev_alloc to notify higher layers we're
7467 +* ready for more.
7468 +*
7469 +* Arguments:
7470 +* wlandev wlan device
7471 +* usbout ptr to the usb transfer buffer
7472 +*
7473 +* Returns:
7474 +* nothing
7475 +*
7476 +* Side effects:
7477 +*
7478 +* Call context:
7479 +* interrupt
7480 +----------------------------------------------------------------*/
7481 +static void hfa384x_usbout_tx(wlandevice_t *wlandev, hfa384x_usbout_t *usbout)
7482 +{
7483 + DBFENTER;
7484 +
7485 + prism2sta_ev_alloc(wlandev);
7486 +
7487 + DBFEXIT;
7488 +}
7489 +
7490 +/*----------------------------------------------------------------
7491 +* hfa384x_isgood_pdrcore
7492 +*
7493 +* Quick check of PDR codes.
7494 +*
7495 +* Arguments:
7496 +* pdrcode PDR code number (host order)
7497 +*
7498 +* Returns:
7499 +* zero not good.
7500 +* one is good.
7501 +*
7502 +* Side effects:
7503 +*
7504 +* Call context:
7505 +----------------------------------------------------------------*/
7506 +static int
7507 +hfa384x_isgood_pdrcode(u16 pdrcode)
7508 +{
7509 + switch(pdrcode) {
7510 + case HFA384x_PDR_END_OF_PDA:
7511 + case HFA384x_PDR_PCB_PARTNUM:
7512 + case HFA384x_PDR_PDAVER:
7513 + case HFA384x_PDR_NIC_SERIAL:
7514 + case HFA384x_PDR_MKK_MEASUREMENTS:
7515 + case HFA384x_PDR_NIC_RAMSIZE:
7516 + case HFA384x_PDR_MFISUPRANGE:
7517 + case HFA384x_PDR_CFISUPRANGE:
7518 + case HFA384x_PDR_NICID:
7519 + case HFA384x_PDR_MAC_ADDRESS:
7520 + case HFA384x_PDR_REGDOMAIN:
7521 + case HFA384x_PDR_ALLOWED_CHANNEL:
7522 + case HFA384x_PDR_DEFAULT_CHANNEL:
7523 + case HFA384x_PDR_TEMPTYPE:
7524 + case HFA384x_PDR_IFR_SETTING:
7525 + case HFA384x_PDR_RFR_SETTING:
7526 + case HFA384x_PDR_HFA3861_BASELINE:
7527 + case HFA384x_PDR_HFA3861_SHADOW:
7528 + case HFA384x_PDR_HFA3861_IFRF:
7529 + case HFA384x_PDR_HFA3861_CHCALSP:
7530 + case HFA384x_PDR_HFA3861_CHCALI:
7531 + case HFA384x_PDR_3842_NIC_CONFIG:
7532 + case HFA384x_PDR_USB_ID:
7533 + case HFA384x_PDR_PCI_ID:
7534 + case HFA384x_PDR_PCI_IFCONF:
7535 + case HFA384x_PDR_PCI_PMCONF:
7536 + case HFA384x_PDR_RFENRGY:
7537 + case HFA384x_PDR_HFA3861_MANF_TESTSP:
7538 + case HFA384x_PDR_HFA3861_MANF_TESTI:
7539 + /* code is OK */
7540 + return 1;
7541 + break;
7542 + default:
7543 + if ( pdrcode < 0x1000 ) {
7544 + /* code is OK, but we don't know exactly what it is */
7545 + WLAN_LOG_DEBUG(3,
7546 + "Encountered unknown PDR#=0x%04x, "
7547 + "assuming it's ok.\n",
7548 + pdrcode);
7549 + return 1;
7550 + } else {
7551 + /* bad code */
7552 + WLAN_LOG_DEBUG(3,
7553 + "Encountered unknown PDR#=0x%04x, "
7554 + "(>=0x1000), assuming it's bad.\n",
7555 + pdrcode);
7556 + return 0;
7557 + }
7558 + break;
7559 + }
7560 + return 0; /* avoid compiler warnings */
7561 +}
7562 +
7563 --- /dev/null
7564 +++ b/drivers/staging/wlan-ng/Kconfig
7565 @@ -0,0 +1,10 @@
7566 +config PRISM2_USB
7567 + tristate "Prism2.5/3 USB driver"
7568 + depends on WLAN_80211 && USB && WIRELESS_EXT
7569 + default n
7570 + ---help---
7571 + This is the wlan-ng prism 2.5/3 USB driver for a wide range of
7572 + old USB wireless devices.
7573 +
7574 + To compile this driver as a module, choose M here: the module
7575 + will be called prism2_usb.
7576 --- /dev/null
7577 +++ b/drivers/staging/wlan-ng/Makefile
7578 @@ -0,0 +1,8 @@
7579 +obj-$(CONFIG_PRISM2_USB) += prism2_usb.o
7580 +
7581 +prism2_usb-objs := prism2usb.o \
7582 + p80211conv.o \
7583 + p80211req.o \
7584 + p80211wep.o \
7585 + p80211wext.o \
7586 + p80211netdev.o
7587 --- /dev/null
7588 +++ b/drivers/staging/wlan-ng/p80211conv.c
7589 @@ -0,0 +1,686 @@
7590 +/* src/p80211/p80211conv.c
7591 +*
7592 +* Ether/802.11 conversions and packet buffer routines
7593 +*
7594 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
7595 +* --------------------------------------------------------------------
7596 +*
7597 +* linux-wlan
7598 +*
7599 +* The contents of this file are subject to the Mozilla Public
7600 +* License Version 1.1 (the "License"); you may not use this file
7601 +* except in compliance with the License. You may obtain a copy of
7602 +* the License at http://www.mozilla.org/MPL/
7603 +*
7604 +* Software distributed under the License is distributed on an "AS
7605 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
7606 +* implied. See the License for the specific language governing
7607 +* rights and limitations under the License.
7608 +*
7609 +* Alternatively, the contents of this file may be used under the
7610 +* terms of the GNU Public License version 2 (the "GPL"), in which
7611 +* case the provisions of the GPL are applicable instead of the
7612 +* above. If you wish to allow the use of your version of this file
7613 +* only under the terms of the GPL and not to allow others to use
7614 +* your version of this file under the MPL, indicate your decision
7615 +* by deleting the provisions above and replace them with the notice
7616 +* and other provisions required by the GPL. If you do not delete
7617 +* the provisions above, a recipient may use your version of this
7618 +* file under either the MPL or the GPL.
7619 +*
7620 +* --------------------------------------------------------------------
7621 +*
7622 +* Inquiries regarding the linux-wlan Open Source project can be
7623 +* made directly to:
7624 +*
7625 +* AbsoluteValue Systems Inc.
7626 +* info@linux-wlan.com
7627 +* http://www.linux-wlan.com
7628 +*
7629 +* --------------------------------------------------------------------
7630 +*
7631 +* Portions of the development of this software were funded by
7632 +* Intersil Corporation as part of PRISM(R) chipset product development.
7633 +*
7634 +* --------------------------------------------------------------------
7635 +*
7636 +* This file defines the functions that perform Ethernet to/from
7637 +* 802.11 frame conversions.
7638 +*
7639 +* --------------------------------------------------------------------
7640 +*/
7641 +/*================================================================*/
7642 +/* System Includes */
7643 +
7644 +
7645 +#include <linux/module.h>
7646 +#include <linux/kernel.h>
7647 +#include <linux/sched.h>
7648 +#include <linux/types.h>
7649 +#include <linux/skbuff.h>
7650 +#include <linux/slab.h>
7651 +#include <linux/wireless.h>
7652 +#include <linux/netdevice.h>
7653 +#include <linux/etherdevice.h>
7654 +#include <linux/if_ether.h>
7655 +
7656 +#include <asm/byteorder.h>
7657 +
7658 +#include "wlan_compat.h"
7659 +
7660 +/*================================================================*/
7661 +/* Project Includes */
7662 +
7663 +#include "p80211types.h"
7664 +#include "p80211hdr.h"
7665 +#include "p80211conv.h"
7666 +#include "p80211mgmt.h"
7667 +#include "p80211msg.h"
7668 +#include "p80211netdev.h"
7669 +#include "p80211ioctl.h"
7670 +#include "p80211req.h"
7671 +
7672 +
7673 +/*================================================================*/
7674 +/* Local Constants */
7675 +
7676 +/*================================================================*/
7677 +/* Local Macros */
7678 +
7679 +
7680 +/*================================================================*/
7681 +/* Local Types */
7682 +
7683 +
7684 +/*================================================================*/
7685 +/* Local Static Definitions */
7686 +
7687 +static u8 oui_rfc1042[] = {0x00, 0x00, 0x00};
7688 +static u8 oui_8021h[] = {0x00, 0x00, 0xf8};
7689 +
7690 +/*================================================================*/
7691 +/* Local Function Declarations */
7692 +
7693 +
7694 +/*================================================================*/
7695 +/* Function Definitions */
7696 +
7697 +/*----------------------------------------------------------------
7698 +* p80211pb_ether_to_80211
7699 +*
7700 +* Uses the contents of the ether frame and the etherconv setting
7701 +* to build the elements of the 802.11 frame.
7702 +*
7703 +* We don't actually set
7704 +* up the frame header here. That's the MAC's job. We're only handling
7705 +* conversion of DIXII or 802.3+LLC frames to something that works
7706 +* with 802.11.
7707 +*
7708 +* Note -- 802.11 header is NOT part of the skb. Likewise, the 802.11
7709 +* FCS is also not present and will need to be added elsewhere.
7710 +*
7711 +* Arguments:
7712 +* ethconv Conversion type to perform
7713 +* skb skbuff containing the ether frame
7714 +* p80211_hdr 802.11 header
7715 +*
7716 +* Returns:
7717 +* 0 on success, non-zero otherwise
7718 +*
7719 +* Call context:
7720 +* May be called in interrupt or non-interrupt context
7721 +----------------------------------------------------------------*/
7722 +int skb_ether_to_p80211( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep)
7723 +{
7724 +
7725 + u16 fc;
7726 + u16 proto;
7727 + wlan_ethhdr_t e_hdr;
7728 + wlan_llc_t *e_llc;
7729 + wlan_snap_t *e_snap;
7730 + int foo;
7731 +
7732 + DBFENTER;
7733 + memcpy(&e_hdr, skb->data, sizeof(e_hdr));
7734 +
7735 + if (skb->len <= 0) {
7736 + WLAN_LOG_DEBUG(1, "zero-length skb!\n");
7737 + return 1;
7738 + }
7739 +
7740 + if ( ethconv == WLAN_ETHCONV_ENCAP ) { /* simplest case */
7741 + WLAN_LOG_DEBUG(3, "ENCAP len: %d\n", skb->len);
7742 + /* here, we don't care what kind of ether frm. Just stick it */
7743 + /* in the 80211 payload */
7744 + /* which is to say, leave the skb alone. */
7745 + } else {
7746 + /* step 1: classify ether frame, DIX or 802.3? */
7747 + proto = ntohs(e_hdr.type);
7748 + if ( proto <= 1500 ) {
7749 + WLAN_LOG_DEBUG(3, "802.3 len: %d\n", skb->len);
7750 + /* codes <= 1500 reserved for 802.3 lengths */
7751 + /* it's 802.3, pass ether payload unchanged, */
7752 +
7753 + /* trim off ethernet header */
7754 + skb_pull(skb, WLAN_ETHHDR_LEN);
7755 +
7756 + /* leave off any PAD octets. */
7757 + skb_trim(skb, proto);
7758 + } else {
7759 + WLAN_LOG_DEBUG(3, "DIXII len: %d\n", skb->len);
7760 + /* it's DIXII, time for some conversion */
7761 +
7762 + /* trim off ethernet header */
7763 + skb_pull(skb, WLAN_ETHHDR_LEN);
7764 +
7765 + /* tack on SNAP */
7766 + e_snap = (wlan_snap_t *) skb_push(skb, sizeof(wlan_snap_t));
7767 + e_snap->type = htons(proto);
7768 + if ( ethconv == WLAN_ETHCONV_8021h && p80211_stt_findproto(proto) ) {
7769 + memcpy( e_snap->oui, oui_8021h, WLAN_IEEE_OUI_LEN);
7770 + } else {
7771 + memcpy( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN);
7772 + }
7773 +
7774 + /* tack on llc */
7775 + e_llc = (wlan_llc_t *) skb_push(skb, sizeof(wlan_llc_t));
7776 + e_llc->dsap = 0xAA; /* SNAP, see IEEE 802 */
7777 + e_llc->ssap = 0xAA;
7778 + e_llc->ctl = 0x03;
7779 +
7780 + }
7781 + }
7782 +
7783 + /* Set up the 802.11 header */
7784 + /* It's a data frame */
7785 + fc = host2ieee16( WLAN_SET_FC_FTYPE(WLAN_FTYPE_DATA) |
7786 + WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DATAONLY));
7787 +
7788 + switch ( wlandev->macmode ) {
7789 + case WLAN_MACMODE_IBSS_STA:
7790 + memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, WLAN_ADDR_LEN);
7791 + memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, WLAN_ADDR_LEN);
7792 + memcpy(p80211_hdr->a3.a3, wlandev->bssid, WLAN_ADDR_LEN);
7793 + break;
7794 + case WLAN_MACMODE_ESS_STA:
7795 + fc |= host2ieee16(WLAN_SET_FC_TODS(1));
7796 + memcpy(p80211_hdr->a3.a1, wlandev->bssid, WLAN_ADDR_LEN);
7797 + memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, WLAN_ADDR_LEN);
7798 + memcpy(p80211_hdr->a3.a3, &e_hdr.daddr, WLAN_ADDR_LEN);
7799 + break;
7800 + case WLAN_MACMODE_ESS_AP:
7801 + fc |= host2ieee16(WLAN_SET_FC_FROMDS(1));
7802 + memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, WLAN_ADDR_LEN);
7803 + memcpy(p80211_hdr->a3.a2, wlandev->bssid, WLAN_ADDR_LEN);
7804 + memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, WLAN_ADDR_LEN);
7805 + break;
7806 + default:
7807 + WLAN_LOG_ERROR("Error: Converting eth to wlan in unknown mode.\n");
7808 + return 1;
7809 + break;
7810 + }
7811 +
7812 + p80211_wep->data = NULL;
7813 +
7814 + if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && (wlandev->hostwep & HOSTWEP_ENCRYPT)) {
7815 + // XXXX need to pick keynum other than default?
7816 +
7817 +#if 1
7818 + p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
7819 +#else
7820 + p80211_wep->data = skb->data;
7821 +#endif
7822 +
7823 + if ((foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
7824 + skb->len,
7825 + (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK),
7826 + p80211_wep->iv, p80211_wep->icv))) {
7827 + WLAN_LOG_WARNING("Host en-WEP failed, dropping frame (%d).\n", foo);
7828 + return 2;
7829 + }
7830 + fc |= host2ieee16(WLAN_SET_FC_ISWEP(1));
7831 + }
7832 +
7833 +
7834 + // skb->nh.raw = skb->data;
7835 +
7836 + p80211_hdr->a3.fc = fc;
7837 + p80211_hdr->a3.dur = 0;
7838 + p80211_hdr->a3.seq = 0;
7839 +
7840 + DBFEXIT;
7841 + return 0;
7842 +}
7843 +
7844 +/* jkriegl: from orinoco, modified */
7845 +static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
7846 + p80211_rxmeta_t *rxmeta)
7847 +{
7848 + int i;
7849 +
7850 + /* Gather wireless spy statistics: for each packet, compare the
7851 + * source address with out list, and if match, get the stats... */
7852 +
7853 + for (i = 0; i < wlandev->spy_number; i++) {
7854 +
7855 + if (!memcmp(wlandev->spy_address[i], mac, ETH_ALEN)) {
7856 + memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
7857 + wlandev->spy_stat[i].level = rxmeta->signal;
7858 + wlandev->spy_stat[i].noise = rxmeta->noise;
7859 + wlandev->spy_stat[i].qual = (rxmeta->signal > rxmeta->noise) ? \
7860 + (rxmeta->signal - rxmeta->noise) : 0;
7861 + wlandev->spy_stat[i].updated = 0x7;
7862 + }
7863 + }
7864 +}
7865 +
7866 +/*----------------------------------------------------------------
7867 +* p80211pb_80211_to_ether
7868 +*
7869 +* Uses the contents of a received 802.11 frame and the etherconv
7870 +* setting to build an ether frame.
7871 +*
7872 +* This function extracts the src and dest address from the 802.11
7873 +* frame to use in the construction of the eth frame.
7874 +*
7875 +* Arguments:
7876 +* ethconv Conversion type to perform
7877 +* skb Packet buffer containing the 802.11 frame
7878 +*
7879 +* Returns:
7880 +* 0 on success, non-zero otherwise
7881 +*
7882 +* Call context:
7883 +* May be called in interrupt or non-interrupt context
7884 +----------------------------------------------------------------*/
7885 +int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb)
7886 +{
7887 + netdevice_t *netdev = wlandev->netdev;
7888 + u16 fc;
7889 + unsigned int payload_length;
7890 + unsigned int payload_offset;
7891 + u8 daddr[WLAN_ETHADDR_LEN];
7892 + u8 saddr[WLAN_ETHADDR_LEN];
7893 + p80211_hdr_t *w_hdr;
7894 + wlan_ethhdr_t *e_hdr;
7895 + wlan_llc_t *e_llc;
7896 + wlan_snap_t *e_snap;
7897 +
7898 + int foo;
7899 +
7900 + DBFENTER;
7901 +
7902 + payload_length = skb->len - WLAN_HDR_A3_LEN - WLAN_CRC_LEN;
7903 + payload_offset = WLAN_HDR_A3_LEN;
7904 +
7905 + w_hdr = (p80211_hdr_t *) skb->data;
7906 +
7907 + /* setup some vars for convenience */
7908 + fc = ieee2host16(w_hdr->a3.fc);
7909 + if ( (WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 0) ) {
7910 + memcpy(daddr, w_hdr->a3.a1, WLAN_ETHADDR_LEN);
7911 + memcpy(saddr, w_hdr->a3.a2, WLAN_ETHADDR_LEN);
7912 + } else if( (WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 1) ) {
7913 + memcpy(daddr, w_hdr->a3.a1, WLAN_ETHADDR_LEN);
7914 + memcpy(saddr, w_hdr->a3.a3, WLAN_ETHADDR_LEN);
7915 + } else if( (WLAN_GET_FC_TODS(fc) == 1) && (WLAN_GET_FC_FROMDS(fc) == 0) ) {
7916 + memcpy(daddr, w_hdr->a3.a3, WLAN_ETHADDR_LEN);
7917 + memcpy(saddr, w_hdr->a3.a2, WLAN_ETHADDR_LEN);
7918 + } else {
7919 + payload_offset = WLAN_HDR_A4_LEN;
7920 + if (payload_length < WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN) {
7921 + WLAN_LOG_ERROR("A4 frame too short!\n");
7922 + return 1;
7923 + }
7924 + payload_length -= (WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN);
7925 + memcpy(daddr, w_hdr->a4.a3, WLAN_ETHADDR_LEN);
7926 + memcpy(saddr, w_hdr->a4.a4, WLAN_ETHADDR_LEN);
7927 + }
7928 +
7929 + /* perform de-wep if necessary.. */
7930 + if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && WLAN_GET_FC_ISWEP(fc) && (wlandev->hostwep & HOSTWEP_DECRYPT)) {
7931 + if (payload_length <= 8) {
7932 + WLAN_LOG_ERROR("WEP frame too short (%u).\n",
7933 + skb->len);
7934 + return 1;
7935 + }
7936 + if ((foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
7937 + payload_length - 8, -1,
7938 + skb->data + payload_offset,
7939 + skb->data + payload_offset + payload_length - 4))) {
7940 + /* de-wep failed, drop skb. */
7941 + WLAN_LOG_DEBUG(1, "Host de-WEP failed, dropping frame (%d).\n", foo);
7942 + wlandev->rx.decrypt_err++;
7943 + return 2;
7944 + }
7945 +
7946 + /* subtract the IV+ICV length off the payload */
7947 + payload_length -= 8;
7948 + /* chop off the IV */
7949 + skb_pull(skb, 4);
7950 + /* chop off the ICV. */
7951 + skb_trim(skb, skb->len - 4);
7952 +
7953 + wlandev->rx.decrypt++;
7954 + }
7955 +
7956 + e_hdr = (wlan_ethhdr_t *) (skb->data + payload_offset);
7957 +
7958 + e_llc = (wlan_llc_t *) (skb->data + payload_offset);
7959 + e_snap = (wlan_snap_t *) (skb->data + payload_offset + sizeof(wlan_llc_t));
7960 +
7961 + /* Test for the various encodings */
7962 + if ( (payload_length >= sizeof(wlan_ethhdr_t)) &&
7963 + ( e_llc->dsap != 0xaa || e_llc->ssap != 0xaa ) &&
7964 + ((memcmp(daddr, e_hdr->daddr, WLAN_ETHADDR_LEN) == 0) ||
7965 + (memcmp(saddr, e_hdr->saddr, WLAN_ETHADDR_LEN) == 0))) {
7966 + WLAN_LOG_DEBUG(3, "802.3 ENCAP len: %d\n", payload_length);
7967 + /* 802.3 Encapsulated */
7968 + /* Test for an overlength frame */
7969 + if ( payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) {
7970 + /* A bogus length ethfrm has been encap'd. */
7971 + /* Is someone trying an oflow attack? */
7972 + WLAN_LOG_ERROR("ENCAP frame too large (%d > %d)\n",
7973 + payload_length, netdev->mtu + WLAN_ETHHDR_LEN);
7974 + return 1;
7975 + }
7976 +
7977 + /* Chop off the 802.11 header. it's already sane. */
7978 + skb_pull(skb, payload_offset);
7979 + /* chop off the 802.11 CRC */
7980 + skb_trim(skb, skb->len - WLAN_CRC_LEN);
7981 +
7982 + } else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t)) &&
7983 + (e_llc->dsap == 0xaa) &&
7984 + (e_llc->ssap == 0xaa) &&
7985 + (e_llc->ctl == 0x03) &&
7986 + (((memcmp( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN)==0) &&
7987 + (ethconv == WLAN_ETHCONV_8021h) &&
7988 + (p80211_stt_findproto(ieee2host16(e_snap->type)))) ||
7989 + (memcmp( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN)!=0)))
7990 + {
7991 + WLAN_LOG_DEBUG(3, "SNAP+RFC1042 len: %d\n", payload_length);
7992 + /* it's a SNAP + RFC1042 frame && protocol is in STT */
7993 + /* build 802.3 + RFC1042 */
7994 +
7995 + /* Test for an overlength frame */
7996 + if ( payload_length > netdev->mtu ) {
7997 + /* A bogus length ethfrm has been sent. */
7998 + /* Is someone trying an oflow attack? */
7999 + WLAN_LOG_ERROR("SNAP frame too large (%d > %d)\n",
8000 + payload_length, netdev->mtu);
8001 + return 1;
8002 + }
8003 +
8004 + /* chop 802.11 header from skb. */
8005 + skb_pull(skb, payload_offset);
8006 +
8007 + /* create 802.3 header at beginning of skb. */
8008 + e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN);
8009 + memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN);
8010 + memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN);
8011 + e_hdr->type = htons(payload_length);
8012 +
8013 + /* chop off the 802.11 CRC */
8014 + skb_trim(skb, skb->len - WLAN_CRC_LEN);
8015 +
8016 + } else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t)) &&
8017 + (e_llc->dsap == 0xaa) &&
8018 + (e_llc->ssap == 0xaa) &&
8019 + (e_llc->ctl == 0x03) ) {
8020 + WLAN_LOG_DEBUG(3, "802.1h/RFC1042 len: %d\n", payload_length);
8021 + /* it's an 802.1h frame || (an RFC1042 && protocol is not in STT) */
8022 + /* build a DIXII + RFC894 */
8023 +
8024 + /* Test for an overlength frame */
8025 + if ((payload_length - sizeof(wlan_llc_t) - sizeof(wlan_snap_t))
8026 + > netdev->mtu) {
8027 + /* A bogus length ethfrm has been sent. */
8028 + /* Is someone trying an oflow attack? */
8029 + WLAN_LOG_ERROR("DIXII frame too large (%ld > %d)\n",
8030 + (long int) (payload_length - sizeof(wlan_llc_t) -
8031 + sizeof(wlan_snap_t)),
8032 + netdev->mtu);
8033 + return 1;
8034 + }
8035 +
8036 + /* chop 802.11 header from skb. */
8037 + skb_pull(skb, payload_offset);
8038 +
8039 + /* chop llc header from skb. */
8040 + skb_pull(skb, sizeof(wlan_llc_t));
8041 +
8042 + /* chop snap header from skb. */
8043 + skb_pull(skb, sizeof(wlan_snap_t));
8044 +
8045 + /* create 802.3 header at beginning of skb. */
8046 + e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN);
8047 + e_hdr->type = e_snap->type;
8048 + memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN);
8049 + memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN);
8050 +
8051 + /* chop off the 802.11 CRC */
8052 + skb_trim(skb, skb->len - WLAN_CRC_LEN);
8053 + } else {
8054 + WLAN_LOG_DEBUG(3, "NON-ENCAP len: %d\n", payload_length);
8055 + /* any NON-ENCAP */
8056 + /* it's a generic 80211+LLC or IPX 'Raw 802.3' */
8057 + /* build an 802.3 frame */
8058 + /* allocate space and setup hostbuf */
8059 +
8060 + /* Test for an overlength frame */
8061 + if ( payload_length > netdev->mtu ) {
8062 + /* A bogus length ethfrm has been sent. */
8063 + /* Is someone trying an oflow attack? */
8064 + WLAN_LOG_ERROR("OTHER frame too large (%d > %d)\n",
8065 + payload_length,
8066 + netdev->mtu);
8067 + return 1;
8068 + }
8069 +
8070 + /* Chop off the 802.11 header. */
8071 + skb_pull(skb, payload_offset);
8072 +
8073 + /* create 802.3 header at beginning of skb. */
8074 + e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN);
8075 + memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN);
8076 + memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN);
8077 + e_hdr->type = htons(payload_length);
8078 +
8079 + /* chop off the 802.11 CRC */
8080 + skb_trim(skb, skb->len - WLAN_CRC_LEN);
8081 +
8082 + }
8083 +
8084 + /*
8085 + * Note that eth_type_trans() expects an skb w/ skb->data pointing
8086 + * at the MAC header, it then sets the following skb members:
8087 + * skb->mac_header,
8088 + * skb->data, and
8089 + * skb->pkt_type.
8090 + * It then _returns_ the value that _we're_ supposed to stuff in
8091 + * skb->protocol. This is nuts.
8092 + */
8093 + skb->protocol = eth_type_trans(skb, netdev);
8094 +
8095 + /* jkriegl: process signal and noise as set in hfa384x_int_rx() */
8096 + /* jkriegl: only process signal/noise if requested by iwspy */
8097 + if (wlandev->spy_number)
8098 + orinoco_spy_gather(wlandev, eth_hdr(skb)->h_source, P80211SKB_RXMETA(skb));
8099 +
8100 + /* Free the metadata */
8101 + p80211skb_rxmeta_detach(skb);
8102 +
8103 + DBFEXIT;
8104 + return 0;
8105 +}
8106 +
8107 +/*----------------------------------------------------------------
8108 +* p80211_stt_findproto
8109 +*
8110 +* Searches the 802.1h Selective Translation Table for a given
8111 +* protocol.
8112 +*
8113 +* Arguments:
8114 +* proto protocl number (in host order) to search for.
8115 +*
8116 +* Returns:
8117 +* 1 - if the table is empty or a match is found.
8118 +* 0 - if the table is non-empty and a match is not found.
8119 +*
8120 +* Call context:
8121 +* May be called in interrupt or non-interrupt context
8122 +----------------------------------------------------------------*/
8123 +int p80211_stt_findproto(u16 proto)
8124 +{
8125 + /* Always return found for now. This is the behavior used by the */
8126 + /* Zoom Win95 driver when 802.1h mode is selected */
8127 + /* TODO: If necessary, add an actual search we'll probably
8128 + need this to match the CMAC's way of doing things.
8129 + Need to do some testing to confirm.
8130 + */
8131 +
8132 + if (proto == 0x80f3) /* APPLETALK */
8133 + return 1;
8134 +
8135 + return 0;
8136 +}
8137 +
8138 +/*----------------------------------------------------------------
8139 +* p80211skb_rxmeta_detach
8140 +*
8141 +* Disconnects the frmmeta and rxmeta from an skb.
8142 +*
8143 +* Arguments:
8144 +* wlandev The wlandev this skb belongs to.
8145 +* skb The skb we're attaching to.
8146 +*
8147 +* Returns:
8148 +* 0 on success, non-zero otherwise
8149 +*
8150 +* Call context:
8151 +* May be called in interrupt or non-interrupt context
8152 +----------------------------------------------------------------*/
8153 +void
8154 +p80211skb_rxmeta_detach(struct sk_buff *skb)
8155 +{
8156 + p80211_rxmeta_t *rxmeta;
8157 + p80211_frmmeta_t *frmmeta;
8158 +
8159 + DBFENTER;
8160 + /* Sanity checks */
8161 + if ( skb==NULL ) { /* bad skb */
8162 + WLAN_LOG_DEBUG(1, "Called w/ null skb.\n");
8163 + goto exit;
8164 + }
8165 + frmmeta = P80211SKB_FRMMETA(skb);
8166 + if ( frmmeta == NULL ) { /* no magic */
8167 + WLAN_LOG_DEBUG(1, "Called w/ bad frmmeta magic.\n");
8168 + goto exit;
8169 + }
8170 + rxmeta = frmmeta->rx;
8171 + if ( rxmeta == NULL ) { /* bad meta ptr */
8172 + WLAN_LOG_DEBUG(1, "Called w/ bad rxmeta ptr.\n");
8173 + goto exit;
8174 + }
8175 +
8176 + /* Free rxmeta */
8177 + kfree(rxmeta);
8178 +
8179 + /* Clear skb->cb */
8180 + memset(skb->cb, 0, sizeof(skb->cb));
8181 +exit:
8182 + DBFEXIT;
8183 + return;
8184 +}
8185 +
8186 +/*----------------------------------------------------------------
8187 +* p80211skb_rxmeta_attach
8188 +*
8189 +* Allocates a p80211rxmeta structure, initializes it, and attaches
8190 +* it to an skb.
8191 +*
8192 +* Arguments:
8193 +* wlandev The wlandev this skb belongs to.
8194 +* skb The skb we're attaching to.
8195 +*
8196 +* Returns:
8197 +* 0 on success, non-zero otherwise
8198 +*
8199 +* Call context:
8200 +* May be called in interrupt or non-interrupt context
8201 +----------------------------------------------------------------*/
8202 +int
8203 +p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
8204 +{
8205 + int result = 0;
8206 + p80211_rxmeta_t *rxmeta;
8207 + p80211_frmmeta_t *frmmeta;
8208 +
8209 + DBFENTER;
8210 +
8211 + /* If these already have metadata, we error out! */
8212 + if (P80211SKB_RXMETA(skb) != NULL) {
8213 + WLAN_LOG_ERROR("%s: RXmeta already attached!\n",
8214 + wlandev->name);
8215 + result = 0;
8216 + goto exit;
8217 + }
8218 +
8219 + /* Allocate the rxmeta */
8220 + rxmeta = kmalloc(sizeof(p80211_rxmeta_t), GFP_ATOMIC);
8221 +
8222 + if ( rxmeta == NULL ) {
8223 + WLAN_LOG_ERROR("%s: Failed to allocate rxmeta.\n",
8224 + wlandev->name);
8225 + result = 1;
8226 + goto exit;
8227 + }
8228 +
8229 + /* Initialize the rxmeta */
8230 + memset(rxmeta, 0, sizeof(p80211_rxmeta_t));
8231 + rxmeta->wlandev = wlandev;
8232 + rxmeta->hosttime = jiffies;
8233 +
8234 + /* Overlay a frmmeta_t onto skb->cb */
8235 + memset(skb->cb, 0, sizeof(p80211_frmmeta_t));
8236 + frmmeta = (p80211_frmmeta_t*)(skb->cb);
8237 + frmmeta->magic = P80211_FRMMETA_MAGIC;
8238 + frmmeta->rx = rxmeta;
8239 +exit:
8240 + DBFEXIT;
8241 + return result;
8242 +}
8243 +
8244 +/*----------------------------------------------------------------
8245 +* p80211skb_free
8246 +*
8247 +* Frees an entire p80211skb by checking and freeing the meta struct
8248 +* and then freeing the skb.
8249 +*
8250 +* Arguments:
8251 +* wlandev The wlandev this skb belongs to.
8252 +* skb The skb we're attaching to.
8253 +*
8254 +* Returns:
8255 +* 0 on success, non-zero otherwise
8256 +*
8257 +* Call context:
8258 +* May be called in interrupt or non-interrupt context
8259 +----------------------------------------------------------------*/
8260 +void
8261 +p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb)
8262 +{
8263 + p80211_frmmeta_t *meta;
8264 + DBFENTER;
8265 + meta = P80211SKB_FRMMETA(skb);
8266 + if ( meta && meta->rx) {
8267 + p80211skb_rxmeta_detach(skb);
8268 + } else {
8269 + WLAN_LOG_ERROR("Freeing an skb (%p) w/ no frmmeta.\n", skb);
8270 + }
8271 +
8272 + dev_kfree_skb(skb);
8273 + DBFEXIT;
8274 + return;
8275 +}
8276 --- /dev/null
8277 +++ b/drivers/staging/wlan-ng/p80211conv.h
8278 @@ -0,0 +1,186 @@
8279 +/* p80211conv.h
8280 +*
8281 +* Ether/802.11 conversions and packet buffer routines
8282 +*
8283 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
8284 +* --------------------------------------------------------------------
8285 +*
8286 +* linux-wlan
8287 +*
8288 +* The contents of this file are subject to the Mozilla Public
8289 +* License Version 1.1 (the "License"); you may not use this file
8290 +* except in compliance with the License. You may obtain a copy of
8291 +* the License at http://www.mozilla.org/MPL/
8292 +*
8293 +* Software distributed under the License is distributed on an "AS
8294 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8295 +* implied. See the License for the specific language governing
8296 +* rights and limitations under the License.
8297 +*
8298 +* Alternatively, the contents of this file may be used under the
8299 +* terms of the GNU Public License version 2 (the "GPL"), in which
8300 +* case the provisions of the GPL are applicable instead of the
8301 +* above. If you wish to allow the use of your version of this file
8302 +* only under the terms of the GPL and not to allow others to use
8303 +* your version of this file under the MPL, indicate your decision
8304 +* by deleting the provisions above and replace them with the notice
8305 +* and other provisions required by the GPL. If you do not delete
8306 +* the provisions above, a recipient may use your version of this
8307 +* file under either the MPL or the GPL.
8308 +*
8309 +* --------------------------------------------------------------------
8310 +*
8311 +* Inquiries regarding the linux-wlan Open Source project can be
8312 +* made directly to:
8313 +*
8314 +* AbsoluteValue Systems Inc.
8315 +* info@linux-wlan.com
8316 +* http://www.linux-wlan.com
8317 +*
8318 +* --------------------------------------------------------------------
8319 +*
8320 +* Portions of the development of this software were funded by
8321 +* Intersil Corporation as part of PRISM(R) chipset product development.
8322 +*
8323 +* --------------------------------------------------------------------
8324 +*
8325 +* This file declares the functions, types and macros that perform
8326 +* Ethernet to/from 802.11 frame conversions.
8327 +*
8328 +* --------------------------------------------------------------------
8329 +*/
8330 +
8331 +#ifndef _LINUX_P80211CONV_H
8332 +#define _LINUX_P80211CONV_H
8333 +
8334 +/*================================================================*/
8335 +/* Constants */
8336 +
8337 +#define WLAN_ETHADDR_LEN 6
8338 +#define WLAN_IEEE_OUI_LEN 3
8339 +
8340 +#define WLAN_ETHCONV_ENCAP 1
8341 +#define WLAN_ETHCONV_RFC1042 2
8342 +#define WLAN_ETHCONV_8021h 3
8343 +
8344 +#define WLAN_MIN_ETHFRM_LEN 60
8345 +#define WLAN_MAX_ETHFRM_LEN 1514
8346 +#define WLAN_ETHHDR_LEN 14
8347 +
8348 +#define P80211CAPTURE_VERSION 0x80211001
8349 +
8350 +/*================================================================*/
8351 +/* Macros */
8352 +
8353 +#define P80211_FRMMETA_MAGIC 0x802110
8354 +
8355 +#define P80211SKB_FRMMETA(s) \
8356 + (((((p80211_frmmeta_t*)((s)->cb))->magic)==P80211_FRMMETA_MAGIC) ? \
8357 + ((p80211_frmmeta_t*)((s)->cb)) : \
8358 + (NULL))
8359 +
8360 +#define P80211SKB_RXMETA(s) \
8361 + (P80211SKB_FRMMETA((s)) ? P80211SKB_FRMMETA((s))->rx : ((p80211_rxmeta_t*)(NULL)))
8362 +
8363 +typedef struct p80211_rxmeta
8364 +{
8365 + struct wlandevice *wlandev;
8366 +
8367 + u64 mactime; /* Hi-rez MAC-supplied time value */
8368 + u64 hosttime; /* Best-rez host supplied time value */
8369 +
8370 + unsigned int rxrate; /* Receive data rate in 100kbps */
8371 + unsigned int priority; /* 0-15, 0=contention, 6=CF */
8372 + int signal; /* An SSI, see p80211netdev.h */
8373 + int noise; /* An SSI, see p80211netdev.h */
8374 + unsigned int channel; /* Receive channel (mostly for snifs) */
8375 + unsigned int preamble; /* P80211ENUM_preambletype_* */
8376 + unsigned int encoding; /* P80211ENUM_encoding_* */
8377 +
8378 +} p80211_rxmeta_t;
8379 +
8380 +typedef struct p80211_frmmeta
8381 +{
8382 + unsigned int magic;
8383 + p80211_rxmeta_t *rx;
8384 +} p80211_frmmeta_t;
8385 +
8386 +void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb);
8387 +int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb);
8388 +void p80211skb_rxmeta_detach(struct sk_buff *skb);
8389 +
8390 +/*================================================================*/
8391 +/* Types */
8392 +
8393 +/*
8394 + * Frame capture header. (See doc/capturefrm.txt)
8395 + */
8396 +typedef struct p80211_caphdr
8397 +{
8398 + u32 version;
8399 + u32 length;
8400 + u64 mactime;
8401 + u64 hosttime;
8402 + u32 phytype;
8403 + u32 channel;
8404 + u32 datarate;
8405 + u32 antenna;
8406 + u32 priority;
8407 + u32 ssi_type;
8408 + s32 ssi_signal;
8409 + s32 ssi_noise;
8410 + u32 preamble;
8411 + u32 encoding;
8412 +} p80211_caphdr_t;
8413 +
8414 +/* buffer free method pointer type */
8415 +typedef void (* freebuf_method_t)(void *buf, int size);
8416 +
8417 +typedef struct p80211_metawep {
8418 + void *data;
8419 + u8 iv[4];
8420 + u8 icv[4];
8421 +} p80211_metawep_t;
8422 +
8423 +/* local ether header type */
8424 +typedef struct wlan_ethhdr
8425 +{
8426 + u8 daddr[WLAN_ETHADDR_LEN];
8427 + u8 saddr[WLAN_ETHADDR_LEN];
8428 + u16 type;
8429 +} __WLAN_ATTRIB_PACK__ wlan_ethhdr_t;
8430 +
8431 +/* local llc header type */
8432 +typedef struct wlan_llc
8433 +{
8434 + u8 dsap;
8435 + u8 ssap;
8436 + u8 ctl;
8437 +} __WLAN_ATTRIB_PACK__ wlan_llc_t;
8438 +
8439 +/* local snap header type */
8440 +typedef struct wlan_snap
8441 +{
8442 + u8 oui[WLAN_IEEE_OUI_LEN];
8443 + u16 type;
8444 +} __WLAN_ATTRIB_PACK__ wlan_snap_t;
8445 +
8446 +/* Circular include trick */
8447 +struct wlandevice;
8448 +
8449 +/*================================================================*/
8450 +/* Externs */
8451 +
8452 +/*================================================================*/
8453 +/*Function Declarations */
8454 +
8455 +int skb_p80211_to_ether( struct wlandevice *wlandev, u32 ethconv,
8456 + struct sk_buff *skb);
8457 +int skb_ether_to_p80211( struct wlandevice *wlandev, u32 ethconv,
8458 + struct sk_buff *skb, p80211_hdr_t *p80211_hdr,
8459 + p80211_metawep_t *p80211_wep );
8460 +
8461 +int p80211_stt_findproto(u16 proto);
8462 +int p80211_stt_addproto(u16 proto);
8463 +
8464 +#endif
8465 --- /dev/null
8466 +++ b/drivers/staging/wlan-ng/p80211hdr.h
8467 @@ -0,0 +1,299 @@
8468 +/* p80211hdr.h
8469 +*
8470 +* Macros, types, and functions for handling 802.11 MAC headers
8471 +*
8472 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
8473 +* --------------------------------------------------------------------
8474 +*
8475 +* linux-wlan
8476 +*
8477 +* The contents of this file are subject to the Mozilla Public
8478 +* License Version 1.1 (the "License"); you may not use this file
8479 +* except in compliance with the License. You may obtain a copy of
8480 +* the License at http://www.mozilla.org/MPL/
8481 +*
8482 +* Software distributed under the License is distributed on an "AS
8483 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8484 +* implied. See the License for the specific language governing
8485 +* rights and limitations under the License.
8486 +*
8487 +* Alternatively, the contents of this file may be used under the
8488 +* terms of the GNU Public License version 2 (the "GPL"), in which
8489 +* case the provisions of the GPL are applicable instead of the
8490 +* above. If you wish to allow the use of your version of this file
8491 +* only under the terms of the GPL and not to allow others to use
8492 +* your version of this file under the MPL, indicate your decision
8493 +* by deleting the provisions above and replace them with the notice
8494 +* and other provisions required by the GPL. If you do not delete
8495 +* the provisions above, a recipient may use your version of this
8496 +* file under either the MPL or the GPL.
8497 +*
8498 +* --------------------------------------------------------------------
8499 +*
8500 +* Inquiries regarding the linux-wlan Open Source project can be
8501 +* made directly to:
8502 +*
8503 +* AbsoluteValue Systems Inc.
8504 +* info@linux-wlan.com
8505 +* http://www.linux-wlan.com
8506 +*
8507 +* --------------------------------------------------------------------
8508 +*
8509 +* Portions of the development of this software were funded by
8510 +* Intersil Corporation as part of PRISM(R) chipset product development.
8511 +*
8512 +* --------------------------------------------------------------------
8513 +*
8514 +* This file declares the constants and types used in the interface
8515 +* between a wlan driver and the user mode utilities.
8516 +*
8517 +* Note:
8518 +* - Constant values are always in HOST byte order. To assign
8519 +* values to multi-byte fields they _must_ be converted to
8520 +* ieee byte order. To retrieve multi-byte values from incoming
8521 +* frames, they must be converted to host order.
8522 +*
8523 +* All functions declared here are implemented in p80211.c
8524 +* --------------------------------------------------------------------
8525 +*/
8526 +
8527 +#ifndef _P80211HDR_H
8528 +#define _P80211HDR_H
8529 +
8530 +/*================================================================*/
8531 +/* System Includes */
8532 +
8533 +/*================================================================*/
8534 +/* Project Includes */
8535 +
8536 +#ifndef _WLAN_COMPAT_H
8537 +#include "wlan_compat.h"
8538 +#endif
8539 +
8540 +
8541 +/*================================================================*/
8542 +/* Constants */
8543 +
8544 +/*--- Sizes -----------------------------------------------*/
8545 +#define WLAN_ADDR_LEN 6
8546 +#define WLAN_CRC_LEN 4
8547 +#define WLAN_BSSID_LEN 6
8548 +#define WLAN_BSS_TS_LEN 8
8549 +#define WLAN_HDR_A3_LEN 24
8550 +#define WLAN_HDR_A4_LEN 30
8551 +#define WLAN_SSID_MAXLEN 32
8552 +#define WLAN_DATA_MAXLEN 2312
8553 +#define WLAN_A3FR_MAXLEN (WLAN_HDR_A3_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
8554 +#define WLAN_A4FR_MAXLEN (WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
8555 +#define WLAN_BEACON_FR_MAXLEN (WLAN_HDR_A3_LEN + 334)
8556 +#define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_A3_LEN + 0)
8557 +#define WLAN_DISASSOC_FR_MAXLEN (WLAN_HDR_A3_LEN + 2)
8558 +#define WLAN_ASSOCREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 48)
8559 +#define WLAN_ASSOCRESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 16)
8560 +#define WLAN_REASSOCREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 54)
8561 +#define WLAN_REASSOCRESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 16)
8562 +#define WLAN_PROBEREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 44)
8563 +#define WLAN_PROBERESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 78)
8564 +#define WLAN_AUTHEN_FR_MAXLEN (WLAN_HDR_A3_LEN + 261)
8565 +#define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_A3_LEN + 2)
8566 +#define WLAN_WEP_NKEYS 4
8567 +#define WLAN_WEP_MAXKEYLEN 13
8568 +#define WLAN_CHALLENGE_IE_LEN 130
8569 +#define WLAN_CHALLENGE_LEN 128
8570 +#define WLAN_WEP_IV_LEN 4
8571 +#define WLAN_WEP_ICV_LEN 4
8572 +
8573 +/*--- Frame Control Field -------------------------------------*/
8574 +/* Frame Types */
8575 +#define WLAN_FTYPE_MGMT 0x00
8576 +#define WLAN_FTYPE_CTL 0x01
8577 +#define WLAN_FTYPE_DATA 0x02
8578 +
8579 +/* Frame subtypes */
8580 +/* Management */
8581 +#define WLAN_FSTYPE_ASSOCREQ 0x00
8582 +#define WLAN_FSTYPE_ASSOCRESP 0x01
8583 +#define WLAN_FSTYPE_REASSOCREQ 0x02
8584 +#define WLAN_FSTYPE_REASSOCRESP 0x03
8585 +#define WLAN_FSTYPE_PROBEREQ 0x04
8586 +#define WLAN_FSTYPE_PROBERESP 0x05
8587 +#define WLAN_FSTYPE_BEACON 0x08
8588 +#define WLAN_FSTYPE_ATIM 0x09
8589 +#define WLAN_FSTYPE_DISASSOC 0x0a
8590 +#define WLAN_FSTYPE_AUTHEN 0x0b
8591 +#define WLAN_FSTYPE_DEAUTHEN 0x0c
8592 +
8593 +/* Control */
8594 +#define WLAN_FSTYPE_BLOCKACKREQ 0x8
8595 +#define WLAN_FSTYPE_BLOCKACK 0x9
8596 +#define WLAN_FSTYPE_PSPOLL 0x0a
8597 +#define WLAN_FSTYPE_RTS 0x0b
8598 +#define WLAN_FSTYPE_CTS 0x0c
8599 +#define WLAN_FSTYPE_ACK 0x0d
8600 +#define WLAN_FSTYPE_CFEND 0x0e
8601 +#define WLAN_FSTYPE_CFENDCFACK 0x0f
8602 +
8603 +/* Data */
8604 +#define WLAN_FSTYPE_DATAONLY 0x00
8605 +#define WLAN_FSTYPE_DATA_CFACK 0x01
8606 +#define WLAN_FSTYPE_DATA_CFPOLL 0x02
8607 +#define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03
8608 +#define WLAN_FSTYPE_NULL 0x04
8609 +#define WLAN_FSTYPE_CFACK 0x05
8610 +#define WLAN_FSTYPE_CFPOLL 0x06
8611 +#define WLAN_FSTYPE_CFACK_CFPOLL 0x07
8612 +
8613 +
8614 +/*================================================================*/
8615 +/* Macros */
8616 +
8617 +/*--- FC Macros ----------------------------------------------*/
8618 +/* Macros to get/set the bitfields of the Frame Control Field */
8619 +/* GET_FC_??? - takes the host byte-order value of an FC */
8620 +/* and retrieves the value of one of the */
8621 +/* bitfields and moves that value so its lsb is */
8622 +/* in bit 0. */
8623 +/* SET_FC_??? - takes a host order value for one of the FC */
8624 +/* bitfields and moves it to the proper bit */
8625 +/* location for ORing into a host order FC. */
8626 +/* To send the FC produced from SET_FC_???, */
8627 +/* one must put the bytes in IEEE order. */
8628 +/* e.g. */
8629 +/* printf("the frame subtype is %x", */
8630 +/* GET_FC_FTYPE( ieee2host( rx.fc ))) */
8631 +/* */
8632 +/* tx.fc = host2ieee( SET_FC_FTYPE(WLAN_FTYP_CTL) | */
8633 +/* SET_FC_FSTYPE(WLAN_FSTYPE_RTS) ); */
8634 +/*------------------------------------------------------------*/
8635 +
8636 +#define WLAN_GET_FC_PVER(n) (((u16)(n)) & (BIT0 | BIT1))
8637 +#define WLAN_GET_FC_FTYPE(n) ((((u16)(n)) & (BIT2 | BIT3)) >> 2)
8638 +#define WLAN_GET_FC_FSTYPE(n) ((((u16)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
8639 +#define WLAN_GET_FC_TODS(n) ((((u16)(n)) & (BIT8)) >> 8)
8640 +#define WLAN_GET_FC_FROMDS(n) ((((u16)(n)) & (BIT9)) >> 9)
8641 +#define WLAN_GET_FC_MOREFRAG(n) ((((u16)(n)) & (BIT10)) >> 10)
8642 +#define WLAN_GET_FC_RETRY(n) ((((u16)(n)) & (BIT11)) >> 11)
8643 +#define WLAN_GET_FC_PWRMGT(n) ((((u16)(n)) & (BIT12)) >> 12)
8644 +#define WLAN_GET_FC_MOREDATA(n) ((((u16)(n)) & (BIT13)) >> 13)
8645 +#define WLAN_GET_FC_ISWEP(n) ((((u16)(n)) & (BIT14)) >> 14)
8646 +#define WLAN_GET_FC_ORDER(n) ((((u16)(n)) & (BIT15)) >> 15)
8647 +
8648 +#define WLAN_SET_FC_PVER(n) ((u16)(n))
8649 +#define WLAN_SET_FC_FTYPE(n) (((u16)(n)) << 2)
8650 +#define WLAN_SET_FC_FSTYPE(n) (((u16)(n)) << 4)
8651 +#define WLAN_SET_FC_TODS(n) (((u16)(n)) << 8)
8652 +#define WLAN_SET_FC_FROMDS(n) (((u16)(n)) << 9)
8653 +#define WLAN_SET_FC_MOREFRAG(n) (((u16)(n)) << 10)
8654 +#define WLAN_SET_FC_RETRY(n) (((u16)(n)) << 11)
8655 +#define WLAN_SET_FC_PWRMGT(n) (((u16)(n)) << 12)
8656 +#define WLAN_SET_FC_MOREDATA(n) (((u16)(n)) << 13)
8657 +#define WLAN_SET_FC_ISWEP(n) (((u16)(n)) << 14)
8658 +#define WLAN_SET_FC_ORDER(n) (((u16)(n)) << 15)
8659 +
8660 +/*--- Duration Macros ----------------------------------------*/
8661 +/* Macros to get/set the bitfields of the Duration Field */
8662 +/* - the duration value is only valid when bit15 is zero */
8663 +/* - the firmware handles these values, so I'm not going */
8664 +/* these macros right now. */
8665 +/*------------------------------------------------------------*/
8666 +
8667 +/*--- Sequence Control Macros -------------------------------*/
8668 +/* Macros to get/set the bitfields of the Sequence Control */
8669 +/* Field. */
8670 +/*------------------------------------------------------------*/
8671 +#define WLAN_GET_SEQ_FRGNUM(n) (((u16)(n)) & (BIT0|BIT1|BIT2|BIT3))
8672 +#define WLAN_GET_SEQ_SEQNUM(n) ((((u16)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
8673 +
8674 +/*--- Data ptr macro -----------------------------------------*/
8675 +/* Creates a u8* to the data portion of a frame */
8676 +/* Assumes you're passing in a ptr to the beginning of the hdr*/
8677 +/*------------------------------------------------------------*/
8678 +#define WLAN_HDR_A3_DATAP(p) (((u8*)(p)) + WLAN_HDR_A3_LEN)
8679 +#define WLAN_HDR_A4_DATAP(p) (((u8*)(p)) + WLAN_HDR_A4_LEN)
8680 +
8681 +#define DOT11_RATE5_ISBASIC_GET(r) (((u8)(r)) & BIT7)
8682 +
8683 +/*================================================================*/
8684 +/* Types */
8685 +
8686 +/* BSS Timestamp */
8687 +typedef u8 wlan_bss_ts_t[WLAN_BSS_TS_LEN];
8688 +
8689 +/* Generic 802.11 Header types */
8690 +
8691 +typedef struct p80211_hdr_a3
8692 +{
8693 + u16 fc;
8694 + u16 dur;
8695 + u8 a1[WLAN_ADDR_LEN];
8696 + u8 a2[WLAN_ADDR_LEN];
8697 + u8 a3[WLAN_ADDR_LEN];
8698 + u16 seq;
8699 +} __WLAN_ATTRIB_PACK__ p80211_hdr_a3_t;
8700 +
8701 +typedef struct p80211_hdr_a4
8702 +{
8703 + u16 fc;
8704 + u16 dur;
8705 + u8 a1[WLAN_ADDR_LEN];
8706 + u8 a2[WLAN_ADDR_LEN];
8707 + u8 a3[WLAN_ADDR_LEN];
8708 + u16 seq;
8709 + u8 a4[WLAN_ADDR_LEN];
8710 +} __WLAN_ATTRIB_PACK__ p80211_hdr_a4_t;
8711 +
8712 +typedef union p80211_hdr
8713 +{
8714 + p80211_hdr_a3_t a3;
8715 + p80211_hdr_a4_t a4;
8716 +} __WLAN_ATTRIB_PACK__ p80211_hdr_t;
8717 +
8718 +
8719 +/*================================================================*/
8720 +/* Extern Declarations */
8721 +
8722 +
8723 +/*================================================================*/
8724 +/* Function Declarations */
8725 +
8726 +/* Frame and header lenght macros */
8727 +
8728 +#define WLAN_CTL_FRAMELEN(fstype) (\
8729 + (fstype) == WLAN_FSTYPE_BLOCKACKREQ ? 24 : \
8730 + (fstype) == WLAN_FSTYPE_BLOCKACK ? 152 : \
8731 + (fstype) == WLAN_FSTYPE_PSPOLL ? 20 : \
8732 + (fstype) == WLAN_FSTYPE_RTS ? 20 : \
8733 + (fstype) == WLAN_FSTYPE_CTS ? 14 : \
8734 + (fstype) == WLAN_FSTYPE_ACK ? 14 : \
8735 + (fstype) == WLAN_FSTYPE_CFEND ? 20 : \
8736 + (fstype) == WLAN_FSTYPE_CFENDCFACK ? 20 : 4)
8737 +
8738 +#define WLAN_FCS_LEN 4
8739 +
8740 +/* ftcl in HOST order */
8741 +inline static u16 p80211_headerlen(u16 fctl)
8742 +{
8743 + u16 hdrlen = 0;
8744 +
8745 + switch ( WLAN_GET_FC_FTYPE(fctl) ) {
8746 + case WLAN_FTYPE_MGMT:
8747 + hdrlen = WLAN_HDR_A3_LEN;
8748 + break;
8749 + case WLAN_FTYPE_DATA:
8750 + hdrlen = WLAN_HDR_A3_LEN;
8751 + if ( WLAN_GET_FC_TODS(fctl) && WLAN_GET_FC_FROMDS(fctl) ) {
8752 + hdrlen += WLAN_ADDR_LEN;
8753 + }
8754 + break;
8755 + case WLAN_FTYPE_CTL:
8756 + hdrlen = WLAN_CTL_FRAMELEN(WLAN_GET_FC_FSTYPE(fctl)) -
8757 + WLAN_FCS_LEN;
8758 + break;
8759 + default:
8760 + hdrlen = WLAN_HDR_A3_LEN;
8761 + }
8762 +
8763 + return hdrlen;
8764 +}
8765 +
8766 +#endif /* _P80211HDR_H */
8767 --- /dev/null
8768 +++ b/drivers/staging/wlan-ng/p80211ioctl.h
8769 @@ -0,0 +1,123 @@
8770 +/* p80211ioctl.h
8771 +*
8772 +* Declares constants and types for the p80211 ioctls
8773 +*
8774 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
8775 +* --------------------------------------------------------------------
8776 +*
8777 +* linux-wlan
8778 +*
8779 +* The contents of this file are subject to the Mozilla Public
8780 +* License Version 1.1 (the "License"); you may not use this file
8781 +* except in compliance with the License. You may obtain a copy of
8782 +* the License at http://www.mozilla.org/MPL/
8783 +*
8784 +* Software distributed under the License is distributed on an "AS
8785 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8786 +* implied. See the License for the specific language governing
8787 +* rights and limitations under the License.
8788 +*
8789 +* Alternatively, the contents of this file may be used under the
8790 +* terms of the GNU Public License version 2 (the "GPL"), in which
8791 +* case the provisions of the GPL are applicable instead of the
8792 +* above. If you wish to allow the use of your version of this file
8793 +* only under the terms of the GPL and not to allow others to use
8794 +* your version of this file under the MPL, indicate your decision
8795 +* by deleting the provisions above and replace them with the notice
8796 +* and other provisions required by the GPL. If you do not delete
8797 +* the provisions above, a recipient may use your version of this
8798 +* file under either the MPL or the GPL.
8799 +*
8800 +* --------------------------------------------------------------------
8801 +*
8802 +* Inquiries regarding the linux-wlan Open Source project can be
8803 +* made directly to:
8804 +*
8805 +* AbsoluteValue Systems Inc.
8806 +* info@linux-wlan.com
8807 +* http://www.linux-wlan.com
8808 +*
8809 +* --------------------------------------------------------------------
8810 +*
8811 +* Portions of the development of this software were funded by
8812 +* Intersil Corporation as part of PRISM(R) chipset product development.
8813 +*
8814 +* --------------------------------------------------------------------
8815 +*
8816 +* While this file is called 'ioctl' is purpose goes a little beyond
8817 +* that. This file defines the types and contants used to implement
8818 +* the p80211 request/confirm/indicate interfaces on Linux. The
8819 +* request/confirm interface is, in fact, normally implemented as an
8820 +* ioctl. The indicate interface on the other hand, is implemented
8821 +* using the Linux 'netlink' interface.
8822 +*
8823 +* The reason I say that request/confirm is 'normally' implemented
8824 +* via ioctl is that we're reserving the right to be able to send
8825 +* request commands via the netlink interface. This will be necessary
8826 +* if we ever need to send request messages when there aren't any
8827 +* wlan network devices present (i.e. sending a message that only p80211
8828 +* cares about.
8829 +* --------------------------------------------------------------------
8830 +*/
8831 +
8832 +
8833 +#ifndef _P80211IOCTL_H
8834 +#define _P80211IOCTL_H
8835 +
8836 +/*================================================================*/
8837 +/* Constants */
8838 +
8839 +/*----------------------------------------------------------------*/
8840 +/* p80211 ioctl "request" codes. See argument 2 of ioctl(2). */
8841 +
8842 +#define P80211_IFTEST (SIOCDEVPRIVATE + 0)
8843 +#define P80211_IFREQ (SIOCDEVPRIVATE + 1)
8844 +
8845 +/*----------------------------------------------------------------*/
8846 +/* Magic number, a quick test to see we're getting the desired struct */
8847 +
8848 +#define P80211_IOCTL_MAGIC (0x4a2d464dUL)
8849 +
8850 +/*----------------------------------------------------------------*/
8851 +/* Netlink protocol numbers for the indication interface */
8852 +
8853 +#define P80211_NL_SOCK_IND NETLINK_USERSOCK
8854 +
8855 +/*----------------------------------------------------------------*/
8856 +/* Netlink multicast bits for different types of messages */
8857 +
8858 +#define P80211_NL_MCAST_GRP_MLME BIT0 /* Local station messages */
8859 +#define P80211_NL_MCAST_GRP_SNIFF BIT1 /* Sniffer messages */
8860 +#define P80211_NL_MCAST_GRP_DIST BIT2 /* Distribution system messages */
8861 +
8862 +/*================================================================*/
8863 +/* Macros */
8864 +
8865 +
8866 +/*================================================================*/
8867 +/* Types */
8868 +
8869 +/*----------------------------------------------------------------*/
8870 +/* A ptr to the following structure type is passed as the third */
8871 +/* argument to the ioctl system call when issuing a request to */
8872 +/* the p80211 module. */
8873 +
8874 +typedef struct p80211ioctl_req
8875 +{
8876 + char name[WLAN_DEVNAMELEN_MAX];
8877 + caddr_t data;
8878 + u32 magic;
8879 + u16 len;
8880 + u32 result;
8881 +} __WLAN_ATTRIB_PACK__ p80211ioctl_req_t;
8882 +
8883 +
8884 +/*================================================================*/
8885 +/* Extern Declarations */
8886 +
8887 +
8888 +/*================================================================*/
8889 +/* Function Declarations */
8890 +
8891 +
8892 +#endif /* _P80211IOCTL_H */
8893 --- /dev/null
8894 +++ b/drivers/staging/wlan-ng/p80211metadef.h
8895 @@ -0,0 +1,757 @@
8896 +/* This file is GENERATED AUTOMATICALLY. DO NOT EDIT OR MODIFY.
8897 +* --------------------------------------------------------------------
8898 +*
8899 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
8900 +* --------------------------------------------------------------------
8901 +*
8902 +* linux-wlan
8903 +*
8904 +* The contents of this file are subject to the Mozilla Public
8905 +* License Version 1.1 (the "License"); you may not use this file
8906 +* except in compliance with the License. You may obtain a copy of
8907 +* the License at http://www.mozilla.org/MPL/
8908 +*
8909 +* Software distributed under the License is distributed on an "AS
8910 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8911 +* implied. See the License for the specific language governing
8912 +* rights and limitations under the License.
8913 +*
8914 +* Alternatively, the contents of this file may be used under the
8915 +* terms of the GNU Public License version 2 (the "GPL"), in which
8916 +* case the provisions of the GPL are applicable instead of the
8917 +* above. If you wish to allow the use of your version of this file
8918 +* only under the terms of the GPL and not to allow others to use
8919 +* your version of this file under the MPL, indicate your decision
8920 +* by deleting the provisions above and replace them with the notice
8921 +* and other provisions required by the GPL. If you do not delete
8922 +* the provisions above, a recipient may use your version of this
8923 +* file under either the MPL or the GPL.
8924 +*
8925 +* --------------------------------------------------------------------
8926 +*
8927 +* Inquiries regarding the linux-wlan Open Source project can be
8928 +* made directly to:
8929 +*
8930 +* AbsoluteValue Systems Inc.
8931 +* info@linux-wlan.com
8932 +* http://www.linux-wlan.com
8933 +*
8934 +* --------------------------------------------------------------------
8935 +*
8936 +* Portions of the development of this software were funded by
8937 +* Intersil Corporation as part of PRISM(R) chipset product development.
8938 +*
8939 +* --------------------------------------------------------------------
8940 +*/
8941 +
8942 +#ifndef _P80211MKMETADEF_H
8943 +#define _P80211MKMETADEF_H
8944 +
8945 +
8946 +#define DIDmsg_cat_dot11req \
8947 + P80211DID_MKSECTION(1)
8948 +#define DIDmsg_dot11req_mibget \
8949 + (P80211DID_MKSECTION(1) | \
8950 + P80211DID_MKGROUP(1))
8951 +#define DIDmsg_dot11req_mibget_mibattribute \
8952 + (P80211DID_MKSECTION(1) | \
8953 + P80211DID_MKGROUP(1) | \
8954 + P80211DID_MKITEM(1) | 0x00000000)
8955 +#define DIDmsg_dot11req_mibget_resultcode \
8956 + (P80211DID_MKSECTION(1) | \
8957 + P80211DID_MKGROUP(1) | \
8958 + P80211DID_MKITEM(2) | 0x00000000)
8959 +#define DIDmsg_dot11req_mibset \
8960 + (P80211DID_MKSECTION(1) | \
8961 + P80211DID_MKGROUP(2))
8962 +#define DIDmsg_dot11req_mibset_mibattribute \
8963 + (P80211DID_MKSECTION(1) | \
8964 + P80211DID_MKGROUP(2) | \
8965 + P80211DID_MKITEM(1) | 0x00000000)
8966 +#define DIDmsg_dot11req_mibset_resultcode \
8967 + (P80211DID_MKSECTION(1) | \
8968 + P80211DID_MKGROUP(2) | \
8969 + P80211DID_MKITEM(2) | 0x00000000)
8970 +#define DIDmsg_dot11req_scan \
8971 + (P80211DID_MKSECTION(1) | \
8972 + P80211DID_MKGROUP(4))
8973 +#define DIDmsg_dot11req_scan_bsstype \
8974 + (P80211DID_MKSECTION(1) | \
8975 + P80211DID_MKGROUP(4) | \
8976 + P80211DID_MKITEM(1) | 0x00000000)
8977 +#define DIDmsg_dot11req_scan_bssid \
8978 + (P80211DID_MKSECTION(1) | \
8979 + P80211DID_MKGROUP(4) | \
8980 + P80211DID_MKITEM(2) | 0x00000000)
8981 +#define DIDmsg_dot11req_scan_ssid \
8982 + (P80211DID_MKSECTION(1) | \
8983 + P80211DID_MKGROUP(4) | \
8984 + P80211DID_MKITEM(3) | 0x00000000)
8985 +#define DIDmsg_dot11req_scan_scantype \
8986 + (P80211DID_MKSECTION(1) | \
8987 + P80211DID_MKGROUP(4) | \
8988 + P80211DID_MKITEM(4) | 0x00000000)
8989 +#define DIDmsg_dot11req_scan_probedelay \
8990 + (P80211DID_MKSECTION(1) | \
8991 + P80211DID_MKGROUP(4) | \
8992 + P80211DID_MKITEM(5) | 0x00000000)
8993 +#define DIDmsg_dot11req_scan_channellist \
8994 + (P80211DID_MKSECTION(1) | \
8995 + P80211DID_MKGROUP(4) | \
8996 + P80211DID_MKITEM(6) | 0x00000000)
8997 +#define DIDmsg_dot11req_scan_minchanneltime \
8998 + (P80211DID_MKSECTION(1) | \
8999 + P80211DID_MKGROUP(4) | \
9000 + P80211DID_MKITEM(7) | 0x00000000)
9001 +#define DIDmsg_dot11req_scan_maxchanneltime \
9002 + (P80211DID_MKSECTION(1) | \
9003 + P80211DID_MKGROUP(4) | \
9004 + P80211DID_MKITEM(8) | 0x00000000)
9005 +#define DIDmsg_dot11req_scan_resultcode \
9006 + (P80211DID_MKSECTION(1) | \
9007 + P80211DID_MKGROUP(4) | \
9008 + P80211DID_MKITEM(9) | 0x00000000)
9009 +#define DIDmsg_dot11req_scan_numbss \
9010 + (P80211DID_MKSECTION(1) | \
9011 + P80211DID_MKGROUP(4) | \
9012 + P80211DID_MKITEM(10) | 0x00000000)
9013 +#define DIDmsg_dot11req_scan_append \
9014 + (P80211DID_MKSECTION(1) | \
9015 + P80211DID_MKGROUP(4) | \
9016 + P80211DID_MKITEM(11) | 0x00000000)
9017 +#define DIDmsg_dot11req_scan_results \
9018 + (P80211DID_MKSECTION(1) | \
9019 + P80211DID_MKGROUP(5))
9020 +#define DIDmsg_dot11req_scan_results_bssindex \
9021 + (P80211DID_MKSECTION(1) | \
9022 + P80211DID_MKGROUP(5) | \
9023 + P80211DID_MKITEM(1) | 0x00000000)
9024 +#define DIDmsg_dot11req_scan_results_resultcode \
9025 + (P80211DID_MKSECTION(1) | \
9026 + P80211DID_MKGROUP(5) | \
9027 + P80211DID_MKITEM(2) | 0x00000000)
9028 +#define DIDmsg_dot11req_scan_results_signal \
9029 + (P80211DID_MKSECTION(1) | \
9030 + P80211DID_MKGROUP(5) | \
9031 + P80211DID_MKITEM(3) | 0x00000000)
9032 +#define DIDmsg_dot11req_scan_results_noise \
9033 + (P80211DID_MKSECTION(1) | \
9034 + P80211DID_MKGROUP(5) | \
9035 + P80211DID_MKITEM(4) | 0x00000000)
9036 +#define DIDmsg_dot11req_scan_results_bssid \
9037 + (P80211DID_MKSECTION(1) | \
9038 + P80211DID_MKGROUP(5) | \
9039 + P80211DID_MKITEM(5) | 0x00000000)
9040 +#define DIDmsg_dot11req_scan_results_ssid \
9041 + (P80211DID_MKSECTION(1) | \
9042 + P80211DID_MKGROUP(5) | \
9043 + P80211DID_MKITEM(6) | 0x00000000)
9044 +#define DIDmsg_dot11req_scan_results_bsstype \
9045 + (P80211DID_MKSECTION(1) | \
9046 + P80211DID_MKGROUP(5) | \
9047 + P80211DID_MKITEM(7) | 0x00000000)
9048 +#define DIDmsg_dot11req_scan_results_beaconperiod \
9049 + (P80211DID_MKSECTION(1) | \
9050 + P80211DID_MKGROUP(5) | \
9051 + P80211DID_MKITEM(8) | 0x00000000)
9052 +#define DIDmsg_dot11req_scan_results_dtimperiod \
9053 + (P80211DID_MKSECTION(1) | \
9054 + P80211DID_MKGROUP(5) | \
9055 + P80211DID_MKITEM(9) | 0x00000000)
9056 +#define DIDmsg_dot11req_scan_results_timestamp \
9057 + (P80211DID_MKSECTION(1) | \
9058 + P80211DID_MKGROUP(5) | \
9059 + P80211DID_MKITEM(10) | 0x00000000)
9060 +#define DIDmsg_dot11req_scan_results_localtime \
9061 + (P80211DID_MKSECTION(1) | \
9062 + P80211DID_MKGROUP(5) | \
9063 + P80211DID_MKITEM(11) | 0x00000000)
9064 +#define DIDmsg_dot11req_scan_results_fhdwelltime \
9065 + (P80211DID_MKSECTION(1) | \
9066 + P80211DID_MKGROUP(5) | \
9067 + P80211DID_MKITEM(12) | 0x00000000)
9068 +#define DIDmsg_dot11req_scan_results_fhhopset \
9069 + (P80211DID_MKSECTION(1) | \
9070 + P80211DID_MKGROUP(5) | \
9071 + P80211DID_MKITEM(13) | 0x00000000)
9072 +#define DIDmsg_dot11req_scan_results_fhhoppattern \
9073 + (P80211DID_MKSECTION(1) | \
9074 + P80211DID_MKGROUP(5) | \
9075 + P80211DID_MKITEM(14) | 0x00000000)
9076 +#define DIDmsg_dot11req_scan_results_fhhopindex \
9077 + (P80211DID_MKSECTION(1) | \
9078 + P80211DID_MKGROUP(5) | \
9079 + P80211DID_MKITEM(15) | 0x00000000)
9080 +#define DIDmsg_dot11req_scan_results_dschannel \
9081 + (P80211DID_MKSECTION(1) | \
9082 + P80211DID_MKGROUP(5) | \
9083 + P80211DID_MKITEM(16) | 0x00000000)
9084 +#define DIDmsg_dot11req_scan_results_cfpcount \
9085 + (P80211DID_MKSECTION(1) | \
9086 + P80211DID_MKGROUP(5) | \
9087 + P80211DID_MKITEM(17) | 0x00000000)
9088 +#define DIDmsg_dot11req_scan_results_cfpperiod \
9089 + (P80211DID_MKSECTION(1) | \
9090 + P80211DID_MKGROUP(5) | \
9091 + P80211DID_MKITEM(18) | 0x00000000)
9092 +#define DIDmsg_dot11req_scan_results_cfpmaxduration \
9093 + (P80211DID_MKSECTION(1) | \
9094 + P80211DID_MKGROUP(5) | \
9095 + P80211DID_MKITEM(19) | 0x00000000)
9096 +#define DIDmsg_dot11req_scan_results_cfpdurremaining \
9097 + (P80211DID_MKSECTION(1) | \
9098 + P80211DID_MKGROUP(5) | \
9099 + P80211DID_MKITEM(20) | 0x00000000)
9100 +#define DIDmsg_dot11req_scan_results_ibssatimwindow \
9101 + (P80211DID_MKSECTION(1) | \
9102 + P80211DID_MKGROUP(5) | \
9103 + P80211DID_MKITEM(21) | 0x00000000)
9104 +#define DIDmsg_dot11req_scan_results_cfpollable \
9105 + (P80211DID_MKSECTION(1) | \
9106 + P80211DID_MKGROUP(5) | \
9107 + P80211DID_MKITEM(22) | 0x00000000)
9108 +#define DIDmsg_dot11req_scan_results_cfpollreq \
9109 + (P80211DID_MKSECTION(1) | \
9110 + P80211DID_MKGROUP(5) | \
9111 + P80211DID_MKITEM(23) | 0x00000000)
9112 +#define DIDmsg_dot11req_scan_results_privacy \
9113 + (P80211DID_MKSECTION(1) | \
9114 + P80211DID_MKGROUP(5) | \
9115 + P80211DID_MKITEM(24) | 0x00000000)
9116 +#define DIDmsg_dot11req_scan_results_basicrate1 \
9117 + (P80211DID_MKSECTION(1) | \
9118 + P80211DID_MKGROUP(5) | \
9119 + P80211DID_MKITEM(25) | 0x00000000)
9120 +#define DIDmsg_dot11req_scan_results_basicrate2 \
9121 + (P80211DID_MKSECTION(1) | \
9122 + P80211DID_MKGROUP(5) | \
9123 + P80211DID_MKITEM(26) | 0x00000000)
9124 +#define DIDmsg_dot11req_scan_results_basicrate3 \
9125 + (P80211DID_MKSECTION(1) | \
9126 + P80211DID_MKGROUP(5) | \
9127 + P80211DID_MKITEM(27) | 0x00000000)
9128 +#define DIDmsg_dot11req_scan_results_basicrate4 \
9129 + (P80211DID_MKSECTION(1) | \
9130 + P80211DID_MKGROUP(5) | \
9131 + P80211DID_MKITEM(28) | 0x00000000)
9132 +#define DIDmsg_dot11req_scan_results_basicrate5 \
9133 + (P80211DID_MKSECTION(1) | \
9134 + P80211DID_MKGROUP(5) | \
9135 + P80211DID_MKITEM(29) | 0x00000000)
9136 +#define DIDmsg_dot11req_scan_results_basicrate6 \
9137 + (P80211DID_MKSECTION(1) | \
9138 + P80211DID_MKGROUP(5) | \
9139 + P80211DID_MKITEM(30) | 0x00000000)
9140 +#define DIDmsg_dot11req_scan_results_basicrate7 \
9141 + (P80211DID_MKSECTION(1) | \
9142 + P80211DID_MKGROUP(5) | \
9143 + P80211DID_MKITEM(31) | 0x00000000)
9144 +#define DIDmsg_dot11req_scan_results_basicrate8 \
9145 + (P80211DID_MKSECTION(1) | \
9146 + P80211DID_MKGROUP(5) | \
9147 + P80211DID_MKITEM(32) | 0x00000000)
9148 +#define DIDmsg_dot11req_scan_results_supprate1 \
9149 + (P80211DID_MKSECTION(1) | \
9150 + P80211DID_MKGROUP(5) | \
9151 + P80211DID_MKITEM(33) | 0x00000000)
9152 +#define DIDmsg_dot11req_scan_results_supprate2 \
9153 + (P80211DID_MKSECTION(1) | \
9154 + P80211DID_MKGROUP(5) | \
9155 + P80211DID_MKITEM(34) | 0x00000000)
9156 +#define DIDmsg_dot11req_scan_results_supprate3 \
9157 + (P80211DID_MKSECTION(1) | \
9158 + P80211DID_MKGROUP(5) | \
9159 + P80211DID_MKITEM(35) | 0x00000000)
9160 +#define DIDmsg_dot11req_scan_results_supprate4 \
9161 + (P80211DID_MKSECTION(1) | \
9162 + P80211DID_MKGROUP(5) | \
9163 + P80211DID_MKITEM(36) | 0x00000000)
9164 +#define DIDmsg_dot11req_scan_results_supprate5 \
9165 + (P80211DID_MKSECTION(1) | \
9166 + P80211DID_MKGROUP(5) | \
9167 + P80211DID_MKITEM(37) | 0x00000000)
9168 +#define DIDmsg_dot11req_scan_results_supprate6 \
9169 + (P80211DID_MKSECTION(1) | \
9170 + P80211DID_MKGROUP(5) | \
9171 + P80211DID_MKITEM(38) | 0x00000000)
9172 +#define DIDmsg_dot11req_scan_results_supprate7 \
9173 + (P80211DID_MKSECTION(1) | \
9174 + P80211DID_MKGROUP(5) | \
9175 + P80211DID_MKITEM(39) | 0x00000000)
9176 +#define DIDmsg_dot11req_scan_results_supprate8 \
9177 + (P80211DID_MKSECTION(1) | \
9178 + P80211DID_MKGROUP(5) | \
9179 + P80211DID_MKITEM(40) | 0x00000000)
9180 +#define DIDmsg_dot11req_start \
9181 + (P80211DID_MKSECTION(1) | \
9182 + P80211DID_MKGROUP(13))
9183 +#define DIDmsg_dot11req_start_ssid \
9184 + (P80211DID_MKSECTION(1) | \
9185 + P80211DID_MKGROUP(13) | \
9186 + P80211DID_MKITEM(1) | 0x00000000)
9187 +#define DIDmsg_dot11req_start_bsstype \
9188 + (P80211DID_MKSECTION(1) | \
9189 + P80211DID_MKGROUP(13) | \
9190 + P80211DID_MKITEM(2) | 0x00000000)
9191 +#define DIDmsg_dot11req_start_beaconperiod \
9192 + (P80211DID_MKSECTION(1) | \
9193 + P80211DID_MKGROUP(13) | \
9194 + P80211DID_MKITEM(3) | 0x00000000)
9195 +#define DIDmsg_dot11req_start_dtimperiod \
9196 + (P80211DID_MKSECTION(1) | \
9197 + P80211DID_MKGROUP(13) | \
9198 + P80211DID_MKITEM(4) | 0x00000000)
9199 +#define DIDmsg_dot11req_start_cfpperiod \
9200 + (P80211DID_MKSECTION(1) | \
9201 + P80211DID_MKGROUP(13) | \
9202 + P80211DID_MKITEM(5) | 0x00000000)
9203 +#define DIDmsg_dot11req_start_cfpmaxduration \
9204 + (P80211DID_MKSECTION(1) | \
9205 + P80211DID_MKGROUP(13) | \
9206 + P80211DID_MKITEM(6) | 0x00000000)
9207 +#define DIDmsg_dot11req_start_fhdwelltime \
9208 + (P80211DID_MKSECTION(1) | \
9209 + P80211DID_MKGROUP(13) | \
9210 + P80211DID_MKITEM(7) | 0x00000000)
9211 +#define DIDmsg_dot11req_start_fhhopset \
9212 + (P80211DID_MKSECTION(1) | \
9213 + P80211DID_MKGROUP(13) | \
9214 + P80211DID_MKITEM(8) | 0x00000000)
9215 +#define DIDmsg_dot11req_start_fhhoppattern \
9216 + (P80211DID_MKSECTION(1) | \
9217 + P80211DID_MKGROUP(13) | \
9218 + P80211DID_MKITEM(9) | 0x00000000)
9219 +#define DIDmsg_dot11req_start_dschannel \
9220 + (P80211DID_MKSECTION(1) | \
9221 + P80211DID_MKGROUP(13) | \
9222 + P80211DID_MKITEM(10) | 0x00000000)
9223 +#define DIDmsg_dot11req_start_ibssatimwindow \
9224 + (P80211DID_MKSECTION(1) | \
9225 + P80211DID_MKGROUP(13) | \
9226 + P80211DID_MKITEM(11) | 0x00000000)
9227 +#define DIDmsg_dot11req_start_probedelay \
9228 + (P80211DID_MKSECTION(1) | \
9229 + P80211DID_MKGROUP(13) | \
9230 + P80211DID_MKITEM(12) | 0x00000000)
9231 +#define DIDmsg_dot11req_start_cfpollable \
9232 + (P80211DID_MKSECTION(1) | \
9233 + P80211DID_MKGROUP(13) | \
9234 + P80211DID_MKITEM(13) | 0x00000000)
9235 +#define DIDmsg_dot11req_start_cfpollreq \
9236 + (P80211DID_MKSECTION(1) | \
9237 + P80211DID_MKGROUP(13) | \
9238 + P80211DID_MKITEM(14) | 0x00000000)
9239 +#define DIDmsg_dot11req_start_basicrate1 \
9240 + (P80211DID_MKSECTION(1) | \
9241 + P80211DID_MKGROUP(13) | \
9242 + P80211DID_MKITEM(15) | 0x00000000)
9243 +#define DIDmsg_dot11req_start_basicrate2 \
9244 + (P80211DID_MKSECTION(1) | \
9245 + P80211DID_MKGROUP(13) | \
9246 + P80211DID_MKITEM(16) | 0x00000000)
9247 +#define DIDmsg_dot11req_start_basicrate3 \
9248 + (P80211DID_MKSECTION(1) | \
9249 + P80211DID_MKGROUP(13) | \
9250 + P80211DID_MKITEM(17) | 0x00000000)
9251 +#define DIDmsg_dot11req_start_basicrate4 \
9252 + (P80211DID_MKSECTION(1) | \
9253 + P80211DID_MKGROUP(13) | \
9254 + P80211DID_MKITEM(18) | 0x00000000)
9255 +#define DIDmsg_dot11req_start_basicrate5 \
9256 + (P80211DID_MKSECTION(1) | \
9257 + P80211DID_MKGROUP(13) | \
9258 + P80211DID_MKITEM(19) | 0x00000000)
9259 +#define DIDmsg_dot11req_start_basicrate6 \
9260 + (P80211DID_MKSECTION(1) | \
9261 + P80211DID_MKGROUP(13) | \
9262 + P80211DID_MKITEM(20) | 0x00000000)
9263 +#define DIDmsg_dot11req_start_basicrate7 \
9264 + (P80211DID_MKSECTION(1) | \
9265 + P80211DID_MKGROUP(13) | \
9266 + P80211DID_MKITEM(21) | 0x00000000)
9267 +#define DIDmsg_dot11req_start_basicrate8 \
9268 + (P80211DID_MKSECTION(1) | \
9269 + P80211DID_MKGROUP(13) | \
9270 + P80211DID_MKITEM(22) | 0x00000000)
9271 +#define DIDmsg_dot11req_start_operationalrate1 \
9272 + (P80211DID_MKSECTION(1) | \
9273 + P80211DID_MKGROUP(13) | \
9274 + P80211DID_MKITEM(23) | 0x00000000)
9275 +#define DIDmsg_dot11req_start_operationalrate2 \
9276 + (P80211DID_MKSECTION(1) | \
9277 + P80211DID_MKGROUP(13) | \
9278 + P80211DID_MKITEM(24) | 0x00000000)
9279 +#define DIDmsg_dot11req_start_operationalrate3 \
9280 + (P80211DID_MKSECTION(1) | \
9281 + P80211DID_MKGROUP(13) | \
9282 + P80211DID_MKITEM(25) | 0x00000000)
9283 +#define DIDmsg_dot11req_start_operationalrate4 \
9284 + (P80211DID_MKSECTION(1) | \
9285 + P80211DID_MKGROUP(13) | \
9286 + P80211DID_MKITEM(26) | 0x00000000)
9287 +#define DIDmsg_dot11req_start_operationalrate5 \
9288 + (P80211DID_MKSECTION(1) | \
9289 + P80211DID_MKGROUP(13) | \
9290 + P80211DID_MKITEM(27) | 0x00000000)
9291 +#define DIDmsg_dot11req_start_operationalrate6 \
9292 + (P80211DID_MKSECTION(1) | \
9293 + P80211DID_MKGROUP(13) | \
9294 + P80211DID_MKITEM(28) | 0x00000000)
9295 +#define DIDmsg_dot11req_start_operationalrate7 \
9296 + (P80211DID_MKSECTION(1) | \
9297 + P80211DID_MKGROUP(13) | \
9298 + P80211DID_MKITEM(29) | 0x00000000)
9299 +#define DIDmsg_dot11req_start_operationalrate8 \
9300 + (P80211DID_MKSECTION(1) | \
9301 + P80211DID_MKGROUP(13) | \
9302 + P80211DID_MKITEM(30) | 0x00000000)
9303 +#define DIDmsg_dot11req_start_resultcode \
9304 + (P80211DID_MKSECTION(1) | \
9305 + P80211DID_MKGROUP(13) | \
9306 + P80211DID_MKITEM(31) | 0x00000000)
9307 +#define DIDmsg_cat_dot11ind \
9308 + P80211DID_MKSECTION(2)
9309 +#define DIDmsg_dot11ind_authenticate \
9310 + (P80211DID_MKSECTION(2) | \
9311 + P80211DID_MKGROUP(1))
9312 +#define DIDmsg_dot11ind_authenticate_peerstaaddress \
9313 + (P80211DID_MKSECTION(2) | \
9314 + P80211DID_MKGROUP(1) | \
9315 + P80211DID_MKITEM(1) | 0x00000000)
9316 +#define DIDmsg_dot11ind_authenticate_authenticationtype \
9317 + (P80211DID_MKSECTION(2) | \
9318 + P80211DID_MKGROUP(1) | \
9319 + P80211DID_MKITEM(2) | 0x00000000)
9320 +#define DIDmsg_dot11ind_deauthenticate \
9321 + (P80211DID_MKSECTION(2) | \
9322 + P80211DID_MKGROUP(2))
9323 +#define DIDmsg_dot11ind_deauthenticate_peerstaaddress \
9324 + (P80211DID_MKSECTION(2) | \
9325 + P80211DID_MKGROUP(2) | \
9326 + P80211DID_MKITEM(1) | 0x00000000)
9327 +#define DIDmsg_dot11ind_deauthenticate_reasoncode \
9328 + (P80211DID_MKSECTION(2) | \
9329 + P80211DID_MKGROUP(2) | \
9330 + P80211DID_MKITEM(2) | 0x00000000)
9331 +#define DIDmsg_dot11ind_associate \
9332 + (P80211DID_MKSECTION(2) | \
9333 + P80211DID_MKGROUP(3))
9334 +#define DIDmsg_dot11ind_associate_peerstaaddress \
9335 + (P80211DID_MKSECTION(2) | \
9336 + P80211DID_MKGROUP(3) | \
9337 + P80211DID_MKITEM(1) | 0x00000000)
9338 +#define DIDmsg_dot11ind_associate_aid \
9339 + (P80211DID_MKSECTION(2) | \
9340 + P80211DID_MKGROUP(3) | \
9341 + P80211DID_MKITEM(2) | 0x00000000)
9342 +#define DIDmsg_dot11ind_reassociate \
9343 + (P80211DID_MKSECTION(2) | \
9344 + P80211DID_MKGROUP(4))
9345 +#define DIDmsg_dot11ind_reassociate_peerstaaddress \
9346 + (P80211DID_MKSECTION(2) | \
9347 + P80211DID_MKGROUP(4) | \
9348 + P80211DID_MKITEM(1) | 0x00000000)
9349 +#define DIDmsg_dot11ind_reassociate_aid \
9350 + (P80211DID_MKSECTION(2) | \
9351 + P80211DID_MKGROUP(4) | \
9352 + P80211DID_MKITEM(2) | 0x00000000)
9353 +#define DIDmsg_dot11ind_reassociate_oldapaddress \
9354 + (P80211DID_MKSECTION(2) | \
9355 + P80211DID_MKGROUP(4) | \
9356 + P80211DID_MKITEM(3) | 0x00000000)
9357 +#define DIDmsg_dot11ind_disassociate \
9358 + (P80211DID_MKSECTION(2) | \
9359 + P80211DID_MKGROUP(5))
9360 +#define DIDmsg_dot11ind_disassociate_peerstaaddress \
9361 + (P80211DID_MKSECTION(2) | \
9362 + P80211DID_MKGROUP(5) | \
9363 + P80211DID_MKITEM(1) | 0x00000000)
9364 +#define DIDmsg_dot11ind_disassociate_reasoncode \
9365 + (P80211DID_MKSECTION(2) | \
9366 + P80211DID_MKGROUP(5) | \
9367 + P80211DID_MKITEM(2) | 0x00000000)
9368 +#define DIDmsg_cat_lnxreq \
9369 + P80211DID_MKSECTION(3)
9370 +#define DIDmsg_lnxreq_ifstate \
9371 + (P80211DID_MKSECTION(3) | \
9372 + P80211DID_MKGROUP(1))
9373 +#define DIDmsg_lnxreq_ifstate_ifstate \
9374 + (P80211DID_MKSECTION(3) | \
9375 + P80211DID_MKGROUP(1) | \
9376 + P80211DID_MKITEM(1) | 0x00000000)
9377 +#define DIDmsg_lnxreq_ifstate_resultcode \
9378 + (P80211DID_MKSECTION(3) | \
9379 + P80211DID_MKGROUP(1) | \
9380 + P80211DID_MKITEM(2) | 0x00000000)
9381 +#define DIDmsg_lnxreq_wlansniff \
9382 + (P80211DID_MKSECTION(3) | \
9383 + P80211DID_MKGROUP(2))
9384 +#define DIDmsg_lnxreq_wlansniff_enable \
9385 + (P80211DID_MKSECTION(3) | \
9386 + P80211DID_MKGROUP(2) | \
9387 + P80211DID_MKITEM(1) | 0x00000000)
9388 +#define DIDmsg_lnxreq_wlansniff_channel \
9389 + (P80211DID_MKSECTION(3) | \
9390 + P80211DID_MKGROUP(2) | \
9391 + P80211DID_MKITEM(2) | 0x00000000)
9392 +#define DIDmsg_lnxreq_wlansniff_prismheader \
9393 + (P80211DID_MKSECTION(3) | \
9394 + P80211DID_MKGROUP(2) | \
9395 + P80211DID_MKITEM(3) | 0x00000000)
9396 +#define DIDmsg_lnxreq_wlansniff_wlanheader \
9397 + (P80211DID_MKSECTION(3) | \
9398 + P80211DID_MKGROUP(2) | \
9399 + P80211DID_MKITEM(4) | 0x00000000)
9400 +#define DIDmsg_lnxreq_wlansniff_keepwepflags \
9401 + (P80211DID_MKSECTION(3) | \
9402 + P80211DID_MKGROUP(2) | \
9403 + P80211DID_MKITEM(5) | 0x00000000)
9404 +#define DIDmsg_lnxreq_wlansniff_stripfcs \
9405 + (P80211DID_MKSECTION(3) | \
9406 + P80211DID_MKGROUP(2) | \
9407 + P80211DID_MKITEM(6) | 0x00000000)
9408 +#define DIDmsg_lnxreq_wlansniff_packet_trunc \
9409 + (P80211DID_MKSECTION(3) | \
9410 + P80211DID_MKGROUP(2) | \
9411 + P80211DID_MKITEM(7) | 0x00000000)
9412 +#define DIDmsg_lnxreq_wlansniff_resultcode \
9413 + (P80211DID_MKSECTION(3) | \
9414 + P80211DID_MKGROUP(2) | \
9415 + P80211DID_MKITEM(8) | 0x00000000)
9416 +#define DIDmsg_lnxreq_hostwep \
9417 + (P80211DID_MKSECTION(3) | \
9418 + P80211DID_MKGROUP(3))
9419 +#define DIDmsg_lnxreq_hostwep_resultcode \
9420 + (P80211DID_MKSECTION(3) | \
9421 + P80211DID_MKGROUP(3) | \
9422 + P80211DID_MKITEM(1) | 0x00000000)
9423 +#define DIDmsg_lnxreq_hostwep_decrypt \
9424 + (P80211DID_MKSECTION(3) | \
9425 + P80211DID_MKGROUP(3) | \
9426 + P80211DID_MKITEM(2) | 0x00000000)
9427 +#define DIDmsg_lnxreq_hostwep_encrypt \
9428 + (P80211DID_MKSECTION(3) | \
9429 + P80211DID_MKGROUP(3) | \
9430 + P80211DID_MKITEM(3) | 0x00000000)
9431 +#define DIDmsg_lnxreq_commsquality \
9432 + (P80211DID_MKSECTION(3) | \
9433 + P80211DID_MKGROUP(4))
9434 +#define DIDmsg_lnxreq_commsquality_resultcode \
9435 + (P80211DID_MKSECTION(3) | \
9436 + P80211DID_MKGROUP(4) | \
9437 + P80211DID_MKITEM(1) | 0x00000000)
9438 +#define DIDmsg_lnxreq_commsquality_dbm \
9439 + (P80211DID_MKSECTION(3) | \
9440 + P80211DID_MKGROUP(4) | \
9441 + P80211DID_MKITEM(2) | 0x00000000)
9442 +#define DIDmsg_lnxreq_commsquality_link \
9443 + (P80211DID_MKSECTION(3) | \
9444 + P80211DID_MKGROUP(4) | \
9445 + P80211DID_MKITEM(3) | 0x00000000)
9446 +#define DIDmsg_lnxreq_commsquality_level \
9447 + (P80211DID_MKSECTION(3) | \
9448 + P80211DID_MKGROUP(4) | \
9449 + P80211DID_MKITEM(4) | 0x00000000)
9450 +#define DIDmsg_lnxreq_commsquality_noise \
9451 + (P80211DID_MKSECTION(3) | \
9452 + P80211DID_MKGROUP(4) | \
9453 + P80211DID_MKITEM(5) | 0x00000000)
9454 +#define DIDmsg_lnxreq_autojoin \
9455 + (P80211DID_MKSECTION(3) | \
9456 + P80211DID_MKGROUP(5))
9457 +#define DIDmsg_lnxreq_autojoin_ssid \
9458 + (P80211DID_MKSECTION(3) | \
9459 + P80211DID_MKGROUP(5) | \
9460 + P80211DID_MKITEM(1) | 0x00000000)
9461 +#define DIDmsg_lnxreq_autojoin_authtype \
9462 + (P80211DID_MKSECTION(3) | \
9463 + P80211DID_MKGROUP(5) | \
9464 + P80211DID_MKITEM(2) | 0x00000000)
9465 +#define DIDmsg_lnxreq_autojoin_resultcode \
9466 + (P80211DID_MKSECTION(3) | \
9467 + P80211DID_MKGROUP(5) | \
9468 + P80211DID_MKITEM(3) | 0x00000000)
9469 +#define DIDmsg_cat_p2req \
9470 + P80211DID_MKSECTION(5)
9471 +#define DIDmsg_p2req_readpda \
9472 + (P80211DID_MKSECTION(5) | \
9473 + P80211DID_MKGROUP(2))
9474 +#define DIDmsg_p2req_readpda_pda \
9475 + (P80211DID_MKSECTION(5) | \
9476 + P80211DID_MKGROUP(2) | \
9477 + P80211DID_MKITEM(1) | 0x00000000)
9478 +#define DIDmsg_p2req_readpda_resultcode \
9479 + (P80211DID_MKSECTION(5) | \
9480 + P80211DID_MKGROUP(2) | \
9481 + P80211DID_MKITEM(2) | 0x00000000)
9482 +#define DIDmsg_p2req_ramdl_state \
9483 + (P80211DID_MKSECTION(5) | \
9484 + P80211DID_MKGROUP(11))
9485 +#define DIDmsg_p2req_ramdl_state_enable \
9486 + (P80211DID_MKSECTION(5) | \
9487 + P80211DID_MKGROUP(11) | \
9488 + P80211DID_MKITEM(1) | 0x00000000)
9489 +#define DIDmsg_p2req_ramdl_state_exeaddr \
9490 + (P80211DID_MKSECTION(5) | \
9491 + P80211DID_MKGROUP(11) | \
9492 + P80211DID_MKITEM(2) | 0x00000000)
9493 +#define DIDmsg_p2req_ramdl_state_resultcode \
9494 + (P80211DID_MKSECTION(5) | \
9495 + P80211DID_MKGROUP(11) | \
9496 + P80211DID_MKITEM(3) | 0x00000000)
9497 +#define DIDmsg_p2req_ramdl_write \
9498 + (P80211DID_MKSECTION(5) | \
9499 + P80211DID_MKGROUP(12))
9500 +#define DIDmsg_p2req_ramdl_write_addr \
9501 + (P80211DID_MKSECTION(5) | \
9502 + P80211DID_MKGROUP(12) | \
9503 + P80211DID_MKITEM(1) | 0x00000000)
9504 +#define DIDmsg_p2req_ramdl_write_len \
9505 + (P80211DID_MKSECTION(5) | \
9506 + P80211DID_MKGROUP(12) | \
9507 + P80211DID_MKITEM(2) | 0x00000000)
9508 +#define DIDmsg_p2req_ramdl_write_data \
9509 + (P80211DID_MKSECTION(5) | \
9510 + P80211DID_MKGROUP(12) | \
9511 + P80211DID_MKITEM(3) | 0x00000000)
9512 +#define DIDmsg_p2req_ramdl_write_resultcode \
9513 + (P80211DID_MKSECTION(5) | \
9514 + P80211DID_MKGROUP(12) | \
9515 + P80211DID_MKITEM(4) | 0x00000000)
9516 +#define DIDmsg_p2req_flashdl_state \
9517 + (P80211DID_MKSECTION(5) | \
9518 + P80211DID_MKGROUP(13))
9519 +#define DIDmsg_p2req_flashdl_state_enable \
9520 + (P80211DID_MKSECTION(5) | \
9521 + P80211DID_MKGROUP(13) | \
9522 + P80211DID_MKITEM(1) | 0x00000000)
9523 +#define DIDmsg_p2req_flashdl_state_resultcode \
9524 + (P80211DID_MKSECTION(5) | \
9525 + P80211DID_MKGROUP(13) | \
9526 + P80211DID_MKITEM(2) | 0x00000000)
9527 +#define DIDmsg_p2req_flashdl_write \
9528 + (P80211DID_MKSECTION(5) | \
9529 + P80211DID_MKGROUP(14))
9530 +#define DIDmsg_p2req_flashdl_write_addr \
9531 + (P80211DID_MKSECTION(5) | \
9532 + P80211DID_MKGROUP(14) | \
9533 + P80211DID_MKITEM(1) | 0x00000000)
9534 +#define DIDmsg_p2req_flashdl_write_len \
9535 + (P80211DID_MKSECTION(5) | \
9536 + P80211DID_MKGROUP(14) | \
9537 + P80211DID_MKITEM(2) | 0x00000000)
9538 +#define DIDmsg_p2req_flashdl_write_data \
9539 + (P80211DID_MKSECTION(5) | \
9540 + P80211DID_MKGROUP(14) | \
9541 + P80211DID_MKITEM(3) | 0x00000000)
9542 +#define DIDmsg_p2req_flashdl_write_resultcode \
9543 + (P80211DID_MKSECTION(5) | \
9544 + P80211DID_MKGROUP(14) | \
9545 + P80211DID_MKITEM(4) | 0x00000000)
9546 +#define DIDmib_cat_dot11smt \
9547 + P80211DID_MKSECTION(1)
9548 +#define DIDmib_dot11smt_dot11WEPDefaultKeysTable \
9549 + (P80211DID_MKSECTION(1) | \
9550 + P80211DID_MKGROUP(4))
9551 +#define DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0 \
9552 + (P80211DID_MKSECTION(1) | \
9553 + P80211DID_MKGROUP(4) | \
9554 + P80211DID_MKITEM(1) | 0x0c000000)
9555 +#define DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1 \
9556 + (P80211DID_MKSECTION(1) | \
9557 + P80211DID_MKGROUP(4) | \
9558 + P80211DID_MKITEM(2) | 0x0c000000)
9559 +#define DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2 \
9560 + (P80211DID_MKSECTION(1) | \
9561 + P80211DID_MKGROUP(4) | \
9562 + P80211DID_MKITEM(3) | 0x0c000000)
9563 +#define DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3 \
9564 + (P80211DID_MKSECTION(1) | \
9565 + P80211DID_MKGROUP(4) | \
9566 + P80211DID_MKITEM(4) | 0x0c000000)
9567 +#define DIDmib_dot11smt_dot11PrivacyTable \
9568 + (P80211DID_MKSECTION(1) | \
9569 + P80211DID_MKGROUP(6))
9570 +#define DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked \
9571 + (P80211DID_MKSECTION(1) | \
9572 + P80211DID_MKGROUP(6) | \
9573 + P80211DID_MKITEM(1) | 0x18000000)
9574 +#define DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID \
9575 + (P80211DID_MKSECTION(1) | \
9576 + P80211DID_MKGROUP(6) | \
9577 + P80211DID_MKITEM(2) | 0x18000000)
9578 +#define DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted \
9579 + (P80211DID_MKSECTION(1) | \
9580 + P80211DID_MKGROUP(6) | \
9581 + P80211DID_MKITEM(4) | 0x18000000)
9582 +#define DIDmib_cat_dot11mac \
9583 + P80211DID_MKSECTION(2)
9584 +#define DIDmib_dot11mac_dot11OperationTable \
9585 + (P80211DID_MKSECTION(2) | \
9586 + P80211DID_MKGROUP(1))
9587 +#define DIDmib_dot11mac_dot11OperationTable_dot11MACAddress \
9588 + (P80211DID_MKSECTION(2) | \
9589 + P80211DID_MKGROUP(1) | \
9590 + P80211DID_MKITEM(1) | 0x18000000)
9591 +#define DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold \
9592 + (P80211DID_MKSECTION(2) | \
9593 + P80211DID_MKGROUP(1) | \
9594 + P80211DID_MKITEM(2) | 0x18000000)
9595 +#define DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit \
9596 + (P80211DID_MKSECTION(2) | \
9597 + P80211DID_MKGROUP(1) | \
9598 + P80211DID_MKITEM(3) | 0x10000000)
9599 +#define DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit \
9600 + (P80211DID_MKSECTION(2) | \
9601 + P80211DID_MKGROUP(1) | \
9602 + P80211DID_MKITEM(4) | 0x10000000)
9603 +#define DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold \
9604 + (P80211DID_MKSECTION(2) | \
9605 + P80211DID_MKGROUP(1) | \
9606 + P80211DID_MKITEM(5) | 0x18000000)
9607 +#define DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime \
9608 + (P80211DID_MKSECTION(2) | \
9609 + P80211DID_MKGROUP(1) | \
9610 + P80211DID_MKITEM(6) | 0x10000000)
9611 +#define DIDmib_cat_dot11phy \
9612 + P80211DID_MKSECTION(3)
9613 +#define DIDmib_dot11phy_dot11PhyOperationTable \
9614 + (P80211DID_MKSECTION(3) | \
9615 + P80211DID_MKGROUP(1))
9616 +#define DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel \
9617 + (P80211DID_MKSECTION(3) | \
9618 + P80211DID_MKGROUP(3) | \
9619 + P80211DID_MKITEM(10) | 0x18000000)
9620 +#define DIDmib_dot11phy_dot11PhyDSSSTable \
9621 + (P80211DID_MKSECTION(3) | \
9622 + P80211DID_MKGROUP(5))
9623 +#define DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel \
9624 + (P80211DID_MKSECTION(3) | \
9625 + P80211DID_MKGROUP(5) | \
9626 + P80211DID_MKITEM(1) | 0x10000000)
9627 +#define DIDmib_cat_lnx \
9628 + P80211DID_MKSECTION(4)
9629 +#define DIDmib_lnx_lnxConfigTable \
9630 + (P80211DID_MKSECTION(4) | \
9631 + P80211DID_MKGROUP(1))
9632 +#define DIDmib_lnx_lnxConfigTable_lnxRSNAIE \
9633 + (P80211DID_MKSECTION(4) | \
9634 + P80211DID_MKGROUP(1) | \
9635 + P80211DID_MKITEM(1) | 0x18000000)
9636 +#define DIDmib_cat_p2 \
9637 + P80211DID_MKSECTION(5)
9638 +#define DIDmib_p2_p2Static \
9639 + (P80211DID_MKSECTION(5) | \
9640 + P80211DID_MKGROUP(2))
9641 +#define DIDmib_p2_p2Static_p2CnfPortType \
9642 + (P80211DID_MKSECTION(5) | \
9643 + P80211DID_MKGROUP(2) | \
9644 + P80211DID_MKITEM(1) | 0x18000000)
9645 +#define DIDmib_p2_p2MAC \
9646 + (P80211DID_MKSECTION(5) | \
9647 + P80211DID_MKGROUP(6))
9648 +#define DIDmib_p2_p2MAC_p2CurrentTxRate \
9649 + (P80211DID_MKSECTION(5) | \
9650 + P80211DID_MKGROUP(6) | \
9651 + P80211DID_MKITEM(12) | 0x10000000)
9652 +#endif
9653 --- /dev/null
9654 +++ b/drivers/staging/wlan-ng/p80211meta.h
9655 @@ -0,0 +1,169 @@
9656 +/* p80211meta.h
9657 +*
9658 +* Macros, constants, types, and funcs for p80211 metadata
9659 +*
9660 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
9661 +* --------------------------------------------------------------------
9662 +*
9663 +* linux-wlan
9664 +*
9665 +* The contents of this file are subject to the Mozilla Public
9666 +* License Version 1.1 (the "License"); you may not use this file
9667 +* except in compliance with the License. You may obtain a copy of
9668 +* the License at http://www.mozilla.org/MPL/
9669 +*
9670 +* Software distributed under the License is distributed on an "AS
9671 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9672 +* implied. See the License for the specific language governing
9673 +* rights and limitations under the License.
9674 +*
9675 +* Alternatively, the contents of this file may be used under the
9676 +* terms of the GNU Public License version 2 (the "GPL"), in which
9677 +* case the provisions of the GPL are applicable instead of the
9678 +* above. If you wish to allow the use of your version of this file
9679 +* only under the terms of the GPL and not to allow others to use
9680 +* your version of this file under the MPL, indicate your decision
9681 +* by deleting the provisions above and replace them with the notice
9682 +* and other provisions required by the GPL. If you do not delete
9683 +* the provisions above, a recipient may use your version of this
9684 +* file under either the MPL or the GPL.
9685 +*
9686 +* --------------------------------------------------------------------
9687 +*
9688 +* Inquiries regarding the linux-wlan Open Source project can be
9689 +* made directly to:
9690 +*
9691 +* AbsoluteValue Systems Inc.
9692 +* info@linux-wlan.com
9693 +* http://www.linux-wlan.com
9694 +*
9695 +* --------------------------------------------------------------------
9696 +*
9697 +* Portions of the development of this software were funded by
9698 +* Intersil Corporation as part of PRISM(R) chipset product development.
9699 +*
9700 +* --------------------------------------------------------------------
9701 +*
9702 +* This file declares some of the constants and types used in various
9703 +* parts of the linux-wlan system.
9704 +*
9705 +* Notes:
9706 +* - Constant values are always in HOST byte order.
9707 +*
9708 +* All functions and statics declared here are implemented in p80211types.c
9709 +* --------------------------------------------------------------------
9710 +*/
9711 +
9712 +#ifndef _P80211META_H
9713 +#define _P80211META_H
9714 +
9715 +/*================================================================*/
9716 +/* System Includes */
9717 +
9718 +/*================================================================*/
9719 +/* Project Includes */
9720 +
9721 +#ifndef _WLAN_COMPAT_H
9722 +#include "wlan_compat.h"
9723 +#endif
9724 +
9725 +/*================================================================*/
9726 +/* Constants */
9727 +
9728 +/*----------------------------------------------------------------*/
9729 +/* */
9730 +
9731 +/*================================================================*/
9732 +/* Macros */
9733 +
9734 +/*----------------------------------------------------------------*/
9735 +/* The following macros are used to ensure consistent naming */
9736 +/* conventions for all the different metadata lists. */
9737 +
9738 +#define MKREQMETANAME(name) p80211meta_ ## req ## _ ## name
9739 +#define MKINDMETANAME(name) p80211meta_ ## ind ## _ ## name
9740 +#define MKMIBMETANAME(name) p80211meta_ ## mib ## _ ## name
9741 +#define MKGRPMETANAME(name) p80211meta_ ## grp ## _ ## name
9742 +
9743 +#define MKREQMETASIZE(name) p80211meta_ ## req ## _ ## name ## _ ## size
9744 +#define MKINDMETASIZE(name) p80211meta_ ## ind ## _ ## name ## _ ## size
9745 +#define MKMIBMETASIZE(name) p80211meta_ ## mib ## _ ## name ## _ ## size
9746 +#define MKGRPMETASIZE(name) p80211meta_ ## grp ## _ ## name ## _ ## size
9747 +
9748 +#define GETMETASIZE(aptr) (**((u32**)(aptr)))
9749 +
9750 +/*----------------------------------------------------------------*/
9751 +/* The following ifdef depends on the following defines: */
9752 +/* P80211_NOINCLUDESTRINGS - if defined, all metadata name fields */
9753 +/* are empty strings */
9754 +
9755 +#ifdef P80211_NOINCLUDESTRINGS
9756 + #define MKITEMNAME(s) ("")
9757 +#else
9758 + #define MKITEMNAME(s) (s)
9759 +#endif
9760 +
9761 +/*================================================================*/
9762 +/* Types */
9763 +
9764 +/*----------------------------------------------------------------*/
9765 +/* The following structure types are used for the metadata */
9766 +/* representation of category list metadata, group list metadata, */
9767 +/* and data item metadata for both Mib and Messages. */
9768 +
9769 +typedef struct p80211meta
9770 +{
9771 + char *name; /* data item name */
9772 + u32 did; /* partial did */
9773 + u32 flags; /* set of various flag bits */
9774 + u32 min; /* min value of a BOUNDEDint */
9775 + u32 max; /* max value of a BOUNDEDint */
9776 +
9777 + u32 maxlen; /* maxlen of a OCTETSTR or DISPLAYSTR */
9778 + u32 minlen; /* minlen of a OCTETSTR or DISPLAYSTR */
9779 + p80211enum_t *enumptr; /* ptr to the enum type for ENUMint */
9780 + p80211_totext_t totextptr; /* ptr to totext conversion function */
9781 + p80211_fromtext_t fromtextptr; /* ptr to totext conversion function */
9782 + p80211_valid_t validfunptr; /* ptr to totext conversion function */
9783 +} p80211meta_t;
9784 +
9785 +typedef struct grplistitem
9786 +{
9787 + char *name;
9788 + p80211meta_t *itemlist;
9789 +} grplistitem_t;
9790 +
9791 +typedef struct catlistitem
9792 +{
9793 + char *name;
9794 + grplistitem_t *grplist;
9795 +} catlistitem_t;
9796 +
9797 +/*================================================================*/
9798 +/* Extern Declarations */
9799 +
9800 +/*----------------------------------------------------------------*/
9801 +/* */
9802 +
9803 +/*================================================================*/
9804 +/* Function Declarations */
9805 +
9806 +/*----------------------------------------------------------------*/
9807 +/* */
9808 +u32 p80211_text2did(catlistitem_t *catlist, char *catname, char *grpname, char *itemname);
9809 +u32 p80211_text2catdid(catlistitem_t *list, char *name );
9810 +u32 p80211_text2grpdid(grplistitem_t *list, char *name );
9811 +u32 p80211_text2itemdid(p80211meta_t *list, char *name );
9812 +u32 p80211_isvalid_did( catlistitem_t *catlist, u32 did );
9813 +u32 p80211_isvalid_catdid( catlistitem_t *catlist, u32 did );
9814 +u32 p80211_isvalid_grpdid( catlistitem_t *catlist, u32 did );
9815 +u32 p80211_isvalid_itemdid( catlistitem_t *catlist, u32 did );
9816 +catlistitem_t *p80211_did2cat( catlistitem_t *catlist, u32 did );
9817 +grplistitem_t *p80211_did2grp( catlistitem_t *catlist, u32 did );
9818 +p80211meta_t *p80211_did2item( catlistitem_t *catlist, u32 did );
9819 +u32 p80211item_maxdatalen( struct catlistitem *metalist, u32 did );
9820 +u32 p80211_metaname2did(struct catlistitem *metalist, char *itemname);
9821 +u32 p80211item_getoffset( struct catlistitem *metalist, u32 did );
9822 +int p80211item_gettype(p80211meta_t *meta);
9823 +
9824 +#endif /* _P80211META_H */
9825 --- /dev/null
9826 +++ b/drivers/staging/wlan-ng/p80211metamib.h
9827 @@ -0,0 +1,105 @@
9828 +/* p80211metamib.h
9829 +*
9830 +* Macros, const, types, and funcs for p80211 mib metadata
9831 +*
9832 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
9833 +* --------------------------------------------------------------------
9834 +*
9835 +* linux-wlan
9836 +*
9837 +* The contents of this file are subject to the Mozilla Public
9838 +* License Version 1.1 (the "License"); you may not use this file
9839 +* except in compliance with the License. You may obtain a copy of
9840 +* the License at http://www.mozilla.org/MPL/
9841 +*
9842 +* Software distributed under the License is distributed on an "AS
9843 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9844 +* implied. See the License for the specific language governing
9845 +* rights and limitations under the License.
9846 +*
9847 +* Alternatively, the contents of this file may be used under the
9848 +* terms of the GNU Public License version 2 (the "GPL"), in which
9849 +* case the provisions of the GPL are applicable instead of the
9850 +* above. If you wish to allow the use of your version of this file
9851 +* only under the terms of the GPL and not to allow others to use
9852 +* your version of this file under the MPL, indicate your decision
9853 +* by deleting the provisions above and replace them with the notice
9854 +* and other provisions required by the GPL. If you do not delete
9855 +* the provisions above, a recipient may use your version of this
9856 +* file under either the MPL or the GPL.
9857 +*
9858 +* --------------------------------------------------------------------
9859 +*
9860 +* Inquiries regarding the linux-wlan Open Source project can be
9861 +* made directly to:
9862 +*
9863 +* AbsoluteValue Systems Inc.
9864 +* info@linux-wlan.com
9865 +* http://www.linux-wlan.com
9866 +*
9867 +* --------------------------------------------------------------------
9868 +*
9869 +* Portions of the development of this software were funded by
9870 +* Intersil Corporation as part of PRISM(R) chipset product development.
9871 +*
9872 +* --------------------------------------------------------------------
9873 +*
9874 +* This file declares some of the constants and types used in various
9875 +* parts of the linux-wlan system.
9876 +*
9877 +* Notes:
9878 +* - Constant values are always in HOST byte order.
9879 +*
9880 +* All functions and statics declared here are implemented in p80211types.c
9881 +* --------------------------------------------------------------------
9882 +*/
9883 +
9884 +#ifndef _P80211METAMIB_H
9885 +#define _P80211METAMIB_H
9886 +
9887 +/*================================================================*/
9888 +/* System Includes */
9889 +
9890 +/*================================================================*/
9891 +/* Project Includes */
9892 +
9893 +#ifndef _WLAN_COMPAT_H
9894 +#include "wlan_compat.h"
9895 +#endif
9896 +
9897 +/*================================================================*/
9898 +/* Constants */
9899 +
9900 +/*----------------------------------------------------------------*/
9901 +/* */
9902 +
9903 +/*================================================================*/
9904 +/* Macros */
9905 +
9906 +/*----------------------------------------------------------------*/
9907 +/* */
9908 +
9909 +/*================================================================*/
9910 +/* Types */
9911 +
9912 +/*----------------------------------------------------------------*/
9913 +/* */
9914 +
9915 +/*================================================================*/
9916 +/* Extern Declarations */
9917 +
9918 +/*----------------------------------------------------------------*/
9919 +/* The following is the external declaration for the mib */
9920 +/* category metadata list */
9921 +
9922 +extern catlistitem_t mib_catlist[];
9923 +extern u32 mib_catlist_size;
9924 +
9925 +
9926 +/*================================================================*/
9927 +/* Function Declarations */
9928 +
9929 +/*----------------------------------------------------------------*/
9930 +/* */
9931 +
9932 +#endif /* _P80211METAMIB_H */
9933 --- /dev/null
9934 +++ b/drivers/staging/wlan-ng/p80211metamsg.h
9935 @@ -0,0 +1,105 @@
9936 +/* p80211metamsg.h
9937 +*
9938 +* Macros, const, types, and funcs for p80211 msg metadata
9939 +*
9940 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
9941 +* --------------------------------------------------------------------
9942 +*
9943 +* linux-wlan
9944 +*
9945 +* The contents of this file are subject to the Mozilla Public
9946 +* License Version 1.1 (the "License"); you may not use this file
9947 +* except in compliance with the License. You may obtain a copy of
9948 +* the License at http://www.mozilla.org/MPL/
9949 +*
9950 +* Software distributed under the License is distributed on an "AS
9951 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9952 +* implied. See the License for the specific language governing
9953 +* rights and limitations under the License.
9954 +*
9955 +* Alternatively, the contents of this file may be used under the
9956 +* terms of the GNU Public License version 2 (the "GPL"), in which
9957 +* case the provisions of the GPL are applicable instead of the
9958 +* above. If you wish to allow the use of your version of this file
9959 +* only under the terms of the GPL and not to allow others to use
9960 +* your version of this file under the MPL, indicate your decision
9961 +* by deleting the provisions above and replace them with the notice
9962 +* and other provisions required by the GPL. If you do not delete
9963 +* the provisions above, a recipient may use your version of this
9964 +* file under either the MPL or the GPL.
9965 +*
9966 +* --------------------------------------------------------------------
9967 +*
9968 +* Inquiries regarding the linux-wlan Open Source project can be
9969 +* made directly to:
9970 +*
9971 +* AbsoluteValue Systems Inc.
9972 +* info@linux-wlan.com
9973 +* http://www.linux-wlan.com
9974 +*
9975 +* --------------------------------------------------------------------
9976 +*
9977 +* Portions of the development of this software were funded by
9978 +* Intersil Corporation as part of PRISM(R) chipset product development.
9979 +*
9980 +* --------------------------------------------------------------------
9981 +*
9982 +* This file declares some of the constants and types used in various
9983 +* parts of the linux-wlan system.
9984 +*
9985 +* Notes:
9986 +* - Constant values are always in HOST byte order.
9987 +*
9988 +* All functions and statics declared here are implemented in p80211types.c
9989 +* --------------------------------------------------------------------
9990 +*/
9991 +
9992 +#ifndef _P80211METAMSG_H
9993 +#define _P80211METAMSG_H
9994 +
9995 +/*================================================================*/
9996 +/* System Includes */
9997 +
9998 +/*================================================================*/
9999 +/* Project Includes */
10000 +
10001 +#ifndef _WLAN_COMPAT_H
10002 +#include "wlan_compat.h"
10003 +#endif
10004 +
10005 +/*================================================================*/
10006 +/* Constants */
10007 +
10008 +/*----------------------------------------------------------------*/
10009 +/* */
10010 +
10011 +/*================================================================*/
10012 +/* Macros */
10013 +
10014 +/*----------------------------------------------------------------*/
10015 +/* */
10016 +
10017 +/*================================================================*/
10018 +/* Types */
10019 +
10020 +/*----------------------------------------------------------------*/
10021 +/* */
10022 +
10023 +/*================================================================*/
10024 +/* Extern Declarations */
10025 +
10026 +/*----------------------------------------------------------------*/
10027 +/* The following is the external declaration for the message */
10028 +/* category metadata list */
10029 +
10030 +extern catlistitem_t msg_catlist[];
10031 +extern u32 msg_catlist_size;
10032 +
10033 +
10034 +/*================================================================*/
10035 +/* Function Declarations */
10036 +
10037 +/*----------------------------------------------------------------*/
10038 +/* */
10039 +
10040 +#endif /* _P80211METAMSG_H */
10041 --- /dev/null
10042 +++ b/drivers/staging/wlan-ng/p80211metastruct.h
10043 @@ -0,0 +1,285 @@
10044 +/* This file is GENERATED AUTOMATICALLY. DO NOT EDIT OR MODIFY.
10045 +* --------------------------------------------------------------------
10046 +*
10047 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
10048 +* --------------------------------------------------------------------
10049 +*
10050 +* linux-wlan
10051 +*
10052 +* The contents of this file are subject to the Mozilla Public
10053 +* License Version 1.1 (the "License"); you may not use this file
10054 +* except in compliance with the License. You may obtain a copy of
10055 +* the License at http://www.mozilla.org/MPL/
10056 +*
10057 +* Software distributed under the License is distributed on an "AS
10058 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10059 +* implied. See the License for the specific language governing
10060 +* rights and limitations under the License.
10061 +*
10062 +* Alternatively, the contents of this file may be used under the
10063 +* terms of the GNU Public License version 2 (the "GPL"), in which
10064 +* case the provisions of the GPL are applicable instead of the
10065 +* above. If you wish to allow the use of your version of this file
10066 +* only under the terms of the GPL and not to allow others to use
10067 +* your version of this file under the MPL, indicate your decision
10068 +* by deleting the provisions above and replace them with the notice
10069 +* and other provisions required by the GPL. If you do not delete
10070 +* the provisions above, a recipient may use your version of this
10071 +* file under either the MPL or the GPL.
10072 +*
10073 +* --------------------------------------------------------------------
10074 +*
10075 +* Inquiries regarding the linux-wlan Open Source project can be
10076 +* made directly to:
10077 +*
10078 +* AbsoluteValue Systems Inc.
10079 +* info@linux-wlan.com
10080 +* http://www.linux-wlan.com
10081 +*
10082 +* --------------------------------------------------------------------
10083 +*
10084 +* Portions of the development of this software were funded by
10085 +* Intersil Corporation as part of PRISM(R) chipset product development.
10086 +*
10087 +* --------------------------------------------------------------------
10088 +*/
10089 +
10090 +#ifndef _P80211MKMETASTRUCT_H
10091 +#define _P80211MKMETASTRUCT_H
10092 +
10093 +
10094 +typedef struct p80211msg_dot11req_mibget
10095 +{
10096 + u32 msgcode ;
10097 + u32 msglen ;
10098 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10099 + p80211item_unk392_t mibattribute ;
10100 + p80211item_uint32_t resultcode ;
10101 +} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_mibget_t;
10102 +
10103 +typedef struct p80211msg_dot11req_mibset
10104 +{
10105 + u32 msgcode ;
10106 + u32 msglen ;
10107 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10108 + p80211item_unk392_t mibattribute ;
10109 + p80211item_uint32_t resultcode ;
10110 +} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_mibset_t;
10111 +
10112 +typedef struct p80211msg_dot11req_scan
10113 +{
10114 + u32 msgcode ;
10115 + u32 msglen ;
10116 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10117 + p80211item_uint32_t bsstype ;
10118 + p80211item_pstr6_t bssid ;
10119 + u8 pad_0C[1] ;
10120 + p80211item_pstr32_t ssid ;
10121 + u8 pad_1D[3] ;
10122 + p80211item_uint32_t scantype ;
10123 + p80211item_uint32_t probedelay ;
10124 + p80211item_pstr14_t channellist ;
10125 + u8 pad_2C[1] ;
10126 + p80211item_uint32_t minchanneltime ;
10127 + p80211item_uint32_t maxchanneltime ;
10128 + p80211item_uint32_t resultcode ;
10129 + p80211item_uint32_t numbss ;
10130 + p80211item_uint32_t append ;
10131 +} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_scan_t;
10132 +
10133 +typedef struct p80211msg_dot11req_scan_results
10134 +{
10135 + u32 msgcode ;
10136 + u32 msglen ;
10137 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10138 + p80211item_uint32_t bssindex ;
10139 + p80211item_uint32_t resultcode ;
10140 + p80211item_uint32_t signal ;
10141 + p80211item_uint32_t noise ;
10142 + p80211item_pstr6_t bssid ;
10143 + u8 pad_3C[1] ;
10144 + p80211item_pstr32_t ssid ;
10145 + u8 pad_4D[3] ;
10146 + p80211item_uint32_t bsstype ;
10147 + p80211item_uint32_t beaconperiod ;
10148 + p80211item_uint32_t dtimperiod ;
10149 + p80211item_uint32_t timestamp ;
10150 + p80211item_uint32_t localtime ;
10151 + p80211item_uint32_t fhdwelltime ;
10152 + p80211item_uint32_t fhhopset ;
10153 + p80211item_uint32_t fhhoppattern ;
10154 + p80211item_uint32_t fhhopindex ;
10155 + p80211item_uint32_t dschannel ;
10156 + p80211item_uint32_t cfpcount ;
10157 + p80211item_uint32_t cfpperiod ;
10158 + p80211item_uint32_t cfpmaxduration ;
10159 + p80211item_uint32_t cfpdurremaining ;
10160 + p80211item_uint32_t ibssatimwindow ;
10161 + p80211item_uint32_t cfpollable ;
10162 + p80211item_uint32_t cfpollreq ;
10163 + p80211item_uint32_t privacy ;
10164 + p80211item_uint32_t basicrate1 ;
10165 + p80211item_uint32_t basicrate2 ;
10166 + p80211item_uint32_t basicrate3 ;
10167 + p80211item_uint32_t basicrate4 ;
10168 + p80211item_uint32_t basicrate5 ;
10169 + p80211item_uint32_t basicrate6 ;
10170 + p80211item_uint32_t basicrate7 ;
10171 + p80211item_uint32_t basicrate8 ;
10172 + p80211item_uint32_t supprate1 ;
10173 + p80211item_uint32_t supprate2 ;
10174 + p80211item_uint32_t supprate3 ;
10175 + p80211item_uint32_t supprate4 ;
10176 + p80211item_uint32_t supprate5 ;
10177 + p80211item_uint32_t supprate6 ;
10178 + p80211item_uint32_t supprate7 ;
10179 + p80211item_uint32_t supprate8 ;
10180 +} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_scan_results_t;
10181 +
10182 +typedef struct p80211msg_dot11req_start
10183 +{
10184 + u32 msgcode ;
10185 + u32 msglen ;
10186 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10187 + p80211item_pstr32_t ssid ;
10188 + u8 pad_12D[3] ;
10189 + p80211item_uint32_t bsstype ;
10190 + p80211item_uint32_t beaconperiod ;
10191 + p80211item_uint32_t dtimperiod ;
10192 + p80211item_uint32_t cfpperiod ;
10193 + p80211item_uint32_t cfpmaxduration ;
10194 + p80211item_uint32_t fhdwelltime ;
10195 + p80211item_uint32_t fhhopset ;
10196 + p80211item_uint32_t fhhoppattern ;
10197 + p80211item_uint32_t dschannel ;
10198 + p80211item_uint32_t ibssatimwindow ;
10199 + p80211item_uint32_t probedelay ;
10200 + p80211item_uint32_t cfpollable ;
10201 + p80211item_uint32_t cfpollreq ;
10202 + p80211item_uint32_t basicrate1 ;
10203 + p80211item_uint32_t basicrate2 ;
10204 + p80211item_uint32_t basicrate3 ;
10205 + p80211item_uint32_t basicrate4 ;
10206 + p80211item_uint32_t basicrate5 ;
10207 + p80211item_uint32_t basicrate6 ;
10208 + p80211item_uint32_t basicrate7 ;
10209 + p80211item_uint32_t basicrate8 ;
10210 + p80211item_uint32_t operationalrate1 ;
10211 + p80211item_uint32_t operationalrate2 ;
10212 + p80211item_uint32_t operationalrate3 ;
10213 + p80211item_uint32_t operationalrate4 ;
10214 + p80211item_uint32_t operationalrate5 ;
10215 + p80211item_uint32_t operationalrate6 ;
10216 + p80211item_uint32_t operationalrate7 ;
10217 + p80211item_uint32_t operationalrate8 ;
10218 + p80211item_uint32_t resultcode ;
10219 +} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_start_t;
10220 +
10221 +typedef struct p80211msg_lnxreq_ifstate
10222 +{
10223 + u32 msgcode ;
10224 + u32 msglen ;
10225 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10226 + p80211item_uint32_t ifstate ;
10227 + p80211item_uint32_t resultcode ;
10228 +} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_ifstate_t;
10229 +
10230 +typedef struct p80211msg_lnxreq_wlansniff
10231 +{
10232 + u32 msgcode ;
10233 + u32 msglen ;
10234 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10235 + p80211item_uint32_t enable ;
10236 + p80211item_uint32_t channel ;
10237 + p80211item_uint32_t prismheader ;
10238 + p80211item_uint32_t wlanheader ;
10239 + p80211item_uint32_t keepwepflags ;
10240 + p80211item_uint32_t stripfcs ;
10241 + p80211item_uint32_t packet_trunc ;
10242 + p80211item_uint32_t resultcode ;
10243 +} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_wlansniff_t;
10244 +
10245 +typedef struct p80211msg_lnxreq_hostwep
10246 +{
10247 + u32 msgcode ;
10248 + u32 msglen ;
10249 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10250 + p80211item_uint32_t resultcode ;
10251 + p80211item_uint32_t decrypt ;
10252 + p80211item_uint32_t encrypt ;
10253 +} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_hostwep_t;
10254 +
10255 +typedef struct p80211msg_lnxreq_commsquality
10256 +{
10257 + u32 msgcode ;
10258 + u32 msglen ;
10259 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10260 + p80211item_uint32_t resultcode ;
10261 + p80211item_uint32_t dbm ;
10262 + p80211item_uint32_t link ;
10263 + p80211item_uint32_t level ;
10264 + p80211item_uint32_t noise ;
10265 +} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_commsquality_t;
10266 +
10267 +typedef struct p80211msg_lnxreq_autojoin
10268 +{
10269 + u32 msgcode ;
10270 + u32 msglen ;
10271 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10272 + p80211item_pstr32_t ssid ;
10273 + u8 pad_19D[3] ;
10274 + p80211item_uint32_t authtype ;
10275 + p80211item_uint32_t resultcode ;
10276 +} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_autojoin_t;
10277 +
10278 +typedef struct p80211msg_p2req_readpda
10279 +{
10280 + u32 msgcode ;
10281 + u32 msglen ;
10282 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10283 + p80211item_unk1024_t pda ;
10284 + p80211item_uint32_t resultcode ;
10285 +} __WLAN_ATTRIB_PACK__ p80211msg_p2req_readpda_t;
10286 +
10287 +typedef struct p80211msg_p2req_ramdl_state
10288 +{
10289 + u32 msgcode ;
10290 + u32 msglen ;
10291 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10292 + p80211item_uint32_t enable ;
10293 + p80211item_uint32_t exeaddr ;
10294 + p80211item_uint32_t resultcode ;
10295 +} __WLAN_ATTRIB_PACK__ p80211msg_p2req_ramdl_state_t;
10296 +
10297 +typedef struct p80211msg_p2req_ramdl_write
10298 +{
10299 + u32 msgcode ;
10300 + u32 msglen ;
10301 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10302 + p80211item_uint32_t addr ;
10303 + p80211item_uint32_t len ;
10304 + p80211item_unk4096_t data ;
10305 + p80211item_uint32_t resultcode ;
10306 +} __WLAN_ATTRIB_PACK__ p80211msg_p2req_ramdl_write_t;
10307 +
10308 +typedef struct p80211msg_p2req_flashdl_state
10309 +{
10310 + u32 msgcode ;
10311 + u32 msglen ;
10312 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10313 + p80211item_uint32_t enable ;
10314 + p80211item_uint32_t resultcode ;
10315 +} __WLAN_ATTRIB_PACK__ p80211msg_p2req_flashdl_state_t;
10316 +
10317 +typedef struct p80211msg_p2req_flashdl_write
10318 +{
10319 + u32 msgcode ;
10320 + u32 msglen ;
10321 + u8 devname[WLAN_DEVNAMELEN_MAX] ;
10322 + p80211item_uint32_t addr ;
10323 + p80211item_uint32_t len ;
10324 + p80211item_unk4096_t data ;
10325 + p80211item_uint32_t resultcode ;
10326 +} __WLAN_ATTRIB_PACK__ p80211msg_p2req_flashdl_write_t;
10327 +
10328 +#endif
10329 --- /dev/null
10330 +++ b/drivers/staging/wlan-ng/p80211mgmt.h
10331 @@ -0,0 +1,575 @@
10332 +/* p80211mgmt.h
10333 +*
10334 +* Macros, types, and functions to handle 802.11 mgmt frames
10335 +*
10336 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
10337 +* --------------------------------------------------------------------
10338 +*
10339 +* linux-wlan
10340 +*
10341 +* The contents of this file are subject to the Mozilla Public
10342 +* License Version 1.1 (the "License"); you may not use this file
10343 +* except in compliance with the License. You may obtain a copy of
10344 +* the License at http://www.mozilla.org/MPL/
10345 +*
10346 +* Software distributed under the License is distributed on an "AS
10347 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10348 +* implied. See the License for the specific language governing
10349 +* rights and limitations under the License.
10350 +*
10351 +* Alternatively, the contents of this file may be used under the
10352 +* terms of the GNU Public License version 2 (the "GPL"), in which
10353 +* case the provisions of the GPL are applicable instead of the
10354 +* above. If you wish to allow the use of your version of this file
10355 +* only under the terms of the GPL and not to allow others to use
10356 +* your version of this file under the MPL, indicate your decision
10357 +* by deleting the provisions above and replace them with the notice
10358 +* and other provisions required by the GPL. If you do not delete
10359 +* the provisions above, a recipient may use your version of this
10360 +* file under either the MPL or the GPL.
10361 +*
10362 +* --------------------------------------------------------------------
10363 +*
10364 +* Inquiries regarding the linux-wlan Open Source project can be
10365 +* made directly to:
10366 +*
10367 +* AbsoluteValue Systems Inc.
10368 +* info@linux-wlan.com
10369 +* http://www.linux-wlan.com
10370 +*
10371 +* --------------------------------------------------------------------
10372 +*
10373 +* Portions of the development of this software were funded by
10374 +* Intersil Corporation as part of PRISM(R) chipset product development.
10375 +*
10376 +* --------------------------------------------------------------------
10377 +*
10378 +* This file declares the constants and types used in the interface
10379 +* between a wlan driver and the user mode utilities.
10380 +*
10381 +* Notes:
10382 +* - Constant values are always in HOST byte order. To assign
10383 +* values to multi-byte fields they _must_ be converted to
10384 +* ieee byte order. To retrieve multi-byte values from incoming
10385 +* frames, they must be converted to host order.
10386 +*
10387 +* - The len member of the frame structure does NOT!!! include
10388 +* the MAC CRC. Therefore, the len field on rx'd frames should
10389 +* have 4 subtracted from it.
10390 +*
10391 +* All functions declared here are implemented in p80211.c
10392 +*
10393 +* The types, macros, and functions defined here are primarily
10394 +* used for encoding and decoding management frames. They are
10395 +* designed to follow these patterns of use:
10396 +*
10397 +* DECODE:
10398 +* 1) a frame of length len is received into buffer b
10399 +* 2) using the hdr structure and macros, we determine the type
10400 +* 3) an appropriate mgmt frame structure, mf, is allocated and zeroed
10401 +* 4) mf.hdr = b
10402 +* mf.buf = b
10403 +* mf.len = len
10404 +* 5) call mgmt_decode( mf )
10405 +* 6) the frame field pointers in mf are now set. Note that any
10406 +* multi-byte frame field values accessed using the frame field
10407 +* pointers are in ieee byte order and will have to be converted
10408 +* to host order.
10409 +*
10410 +* ENCODE:
10411 +* 1) Library client allocates buffer space for maximum length
10412 +* frame of the desired type
10413 +* 2) Library client allocates a mgmt frame structure, called mf,
10414 +* of the desired type
10415 +* 3) Set the following:
10416 +* mf.type = <desired type>
10417 +* mf.buf = <allocated buffer address>
10418 +* 4) call mgmt_encode( mf )
10419 +* 5) all of the fixed field pointers and fixed length information element
10420 +* pointers in mf are now set to their respective locations in the
10421 +* allocated space (fortunately, all variable length information elements
10422 +* fall at the end of their respective frames).
10423 +* 5a) The length field is set to include the last of the fixed and fixed
10424 +* length fields. It may have to be updated for optional or variable
10425 +* length information elements.
10426 +* 6) Optional and variable length information elements are special cases
10427 +* and must be handled individually by the client code.
10428 +* --------------------------------------------------------------------
10429 +*/
10430 +
10431 +#ifndef _P80211MGMT_H
10432 +#define _P80211MGMT_H
10433 +
10434 +/*================================================================*/
10435 +/* System Includes */
10436 +
10437 +/*================================================================*/
10438 +/* Project Includes */
10439 +
10440 +#ifndef _WLAN_COMPAT_H
10441 +#include "wlan_compat.h"
10442 +#endif
10443 +
10444 +#ifndef _P80211HDR_H
10445 +#include "p80211hdr.h"
10446 +#endif
10447 +
10448 +
10449 +/*================================================================*/
10450 +/* Constants */
10451 +
10452 +/*-- Information Element IDs --------------------*/
10453 +#define WLAN_EID_SSID 0
10454 +#define WLAN_EID_SUPP_RATES 1
10455 +#define WLAN_EID_FH_PARMS 2
10456 +#define WLAN_EID_DS_PARMS 3
10457 +#define WLAN_EID_CF_PARMS 4
10458 +#define WLAN_EID_TIM 5
10459 +#define WLAN_EID_IBSS_PARMS 6
10460 +/*-- values 7-15 reserved --*/
10461 +#define WLAN_EID_CHALLENGE 16
10462 +/*-- values 17-31 reserved for challenge text extension --*/
10463 +/*-- values 32-255 reserved --*/
10464 +
10465 +/*-- Reason Codes -------------------------------*/
10466 +#define WLAN_MGMT_REASON_RSVD 0
10467 +#define WLAN_MGMT_REASON_UNSPEC 1
10468 +#define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2
10469 +#define WLAN_MGMT_REASON_DEAUTH_LEAVING 3
10470 +#define WLAN_MGMT_REASON_DISASSOC_INACTIVE 4
10471 +#define WLAN_MGMT_REASON_DISASSOC_AP_BUSY 5
10472 +#define WLAN_MGMT_REASON_CLASS2_NONAUTH 6
10473 +#define WLAN_MGMT_REASON_CLASS3_NONASSOC 7
10474 +#define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT 8
10475 +#define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH 9
10476 +
10477 +/*-- Status Codes -------------------------------*/
10478 +#define WLAN_MGMT_STATUS_SUCCESS 0
10479 +#define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1
10480 +#define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10
10481 +#define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC 11
10482 +#define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC 12
10483 +#define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG 13
10484 +#define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ 14
10485 +#define WLAN_MGMT_STATUS_CHALLENGE_FAIL 15
10486 +#define WLAN_MGMT_STATUS_AUTH_TIMEOUT 16
10487 +#define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY 17
10488 +#define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES 18
10489 + /* p80211b additions */
10490 +#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOSHORT 19
10491 +#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOPBCC 20
10492 +#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOAGILITY 21
10493 +
10494 +
10495 +
10496 +/*-- Auth Algorithm Field ---------------------------*/
10497 +#define WLAN_AUTH_ALG_OPENSYSTEM 0
10498 +#define WLAN_AUTH_ALG_SHAREDKEY 1
10499 +
10500 +/*-- Management Frame Field Offsets -------------*/
10501 +/* Note: Not all fields are listed because of variable lengths, */
10502 +/* see the code in p80211.c to see how we search for fields */
10503 +/* Note: These offsets are from the start of the frame data */
10504 +
10505 +#define WLAN_BEACON_OFF_TS 0
10506 +#define WLAN_BEACON_OFF_BCN_int 8
10507 +#define WLAN_BEACON_OFF_CAPINFO 10
10508 +#define WLAN_BEACON_OFF_SSID 12
10509 +
10510 +#define WLAN_DISASSOC_OFF_REASON 0
10511 +
10512 +#define WLAN_ASSOCREQ_OFF_CAP_INFO 0
10513 +#define WLAN_ASSOCREQ_OFF_LISTEN_int 2
10514 +#define WLAN_ASSOCREQ_OFF_SSID 4
10515 +
10516 +#define WLAN_ASSOCRESP_OFF_CAP_INFO 0
10517 +#define WLAN_ASSOCRESP_OFF_STATUS 2
10518 +#define WLAN_ASSOCRESP_OFF_AID 4
10519 +#define WLAN_ASSOCRESP_OFF_SUPP_RATES 6
10520 +
10521 +#define WLAN_REASSOCREQ_OFF_CAP_INFO 0
10522 +#define WLAN_REASSOCREQ_OFF_LISTEN_int 2
10523 +#define WLAN_REASSOCREQ_OFF_CURR_AP 4
10524 +#define WLAN_REASSOCREQ_OFF_SSID 10
10525 +
10526 +#define WLAN_REASSOCRESP_OFF_CAP_INFO 0
10527 +#define WLAN_REASSOCRESP_OFF_STATUS 2
10528 +#define WLAN_REASSOCRESP_OFF_AID 4
10529 +#define WLAN_REASSOCRESP_OFF_SUPP_RATES 6
10530 +
10531 +#define WLAN_PROBEREQ_OFF_SSID 0
10532 +
10533 +#define WLAN_PROBERESP_OFF_TS 0
10534 +#define WLAN_PROBERESP_OFF_BCN_int 8
10535 +#define WLAN_PROBERESP_OFF_CAP_INFO 10
10536 +#define WLAN_PROBERESP_OFF_SSID 12
10537 +
10538 +#define WLAN_AUTHEN_OFF_AUTH_ALG 0
10539 +#define WLAN_AUTHEN_OFF_AUTH_SEQ 2
10540 +#define WLAN_AUTHEN_OFF_STATUS 4
10541 +#define WLAN_AUTHEN_OFF_CHALLENGE 6
10542 +
10543 +#define WLAN_DEAUTHEN_OFF_REASON 0
10544 +
10545 +
10546 +/*================================================================*/
10547 +/* Macros */
10548 +
10549 +/*-- Capability Field ---------------------------*/
10550 +#define WLAN_GET_MGMT_CAP_INFO_ESS(n) ((n) & BIT0)
10551 +#define WLAN_GET_MGMT_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1)
10552 +#define WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2)
10553 +#define WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(n) (((n) & BIT3) >> 3)
10554 +#define WLAN_GET_MGMT_CAP_INFO_PRIVACY(n) (((n) & BIT4) >> 4)
10555 + /* p80211b additions */
10556 +#define WLAN_GET_MGMT_CAP_INFO_SHORT(n) (((n) & BIT5) >> 5)
10557 +#define WLAN_GET_MGMT_CAP_INFO_PBCC(n) (((n) & BIT6) >> 6)
10558 +#define WLAN_GET_MGMT_CAP_INFO_AGILITY(n) (((n) & BIT7) >> 7)
10559 +
10560 +#define WLAN_SET_MGMT_CAP_INFO_ESS(n) (n)
10561 +#define WLAN_SET_MGMT_CAP_INFO_IBSS(n) ((n) << 1)
10562 +#define WLAN_SET_MGMT_CAP_INFO_CFPOLLABLE(n) ((n) << 2)
10563 +#define WLAN_SET_MGMT_CAP_INFO_CFPOLLREQ(n) ((n) << 3)
10564 +#define WLAN_SET_MGMT_CAP_INFO_PRIVACY(n) ((n) << 4)
10565 + /* p80211b additions */
10566 +#define WLAN_SET_MGMT_CAP_INFO_SHORT(n) ((n) << 5)
10567 +#define WLAN_SET_MGMT_CAP_INFO_PBCC(n) ((n) << 6)
10568 +#define WLAN_SET_MGMT_CAP_INFO_AGILITY(n) ((n) << 7)
10569 +
10570 +
10571 +/*================================================================*/
10572 +/* Types */
10573 +
10574 +/*-- Information Element Types --------------------*/
10575 +/* prototype structure, all IEs start with these members */
10576 +
10577 +typedef struct wlan_ie
10578 +{
10579 + u8 eid;
10580 + u8 len;
10581 +} __WLAN_ATTRIB_PACK__ wlan_ie_t;
10582 +
10583 +/*-- Service Set Identity (SSID) -----------------*/
10584 +typedef struct wlan_ie_ssid
10585 +{
10586 + u8 eid;
10587 + u8 len;
10588 + u8 ssid[1]; /* may be zero, ptrs may overlap */
10589 +} __WLAN_ATTRIB_PACK__ wlan_ie_ssid_t;
10590 +
10591 +/*-- Supported Rates -----------------------------*/
10592 +typedef struct wlan_ie_supp_rates
10593 +{
10594 + u8 eid;
10595 + u8 len;
10596 + u8 rates[1]; /* had better be at LEAST one! */
10597 +} __WLAN_ATTRIB_PACK__ wlan_ie_supp_rates_t;
10598 +
10599 +/*-- FH Parameter Set ----------------------------*/
10600 +typedef struct wlan_ie_fh_parms
10601 +{
10602 + u8 eid;
10603 + u8 len;
10604 + u16 dwell;
10605 + u8 hopset;
10606 + u8 hoppattern;
10607 + u8 hopindex;
10608 +} __WLAN_ATTRIB_PACK__ wlan_ie_fh_parms_t;
10609 +
10610 +/*-- DS Parameter Set ----------------------------*/
10611 +typedef struct wlan_ie_ds_parms
10612 +{
10613 + u8 eid;
10614 + u8 len;
10615 + u8 curr_ch;
10616 +} __WLAN_ATTRIB_PACK__ wlan_ie_ds_parms_t;
10617 +
10618 +/*-- CF Parameter Set ----------------------------*/
10619 +
10620 +typedef struct wlan_ie_cf_parms
10621 +{
10622 + u8 eid;
10623 + u8 len;
10624 + u8 cfp_cnt;
10625 + u8 cfp_period;
10626 + u16 cfp_maxdur;
10627 + u16 cfp_durremaining;
10628 +} __WLAN_ATTRIB_PACK__ wlan_ie_cf_parms_t;
10629 +
10630 +/*-- TIM ------------------------------------------*/
10631 +typedef struct wlan_ie_tim
10632 +{
10633 + u8 eid;
10634 + u8 len;
10635 + u8 dtim_cnt;
10636 + u8 dtim_period;
10637 + u8 bitmap_ctl;
10638 + u8 virt_bm[1];
10639 +} __WLAN_ATTRIB_PACK__ wlan_ie_tim_t;
10640 +
10641 +/*-- IBSS Parameter Set ---------------------------*/
10642 +typedef struct wlan_ie_ibss_parms
10643 +{
10644 + u8 eid;
10645 + u8 len;
10646 + u16 atim_win;
10647 +} __WLAN_ATTRIB_PACK__ wlan_ie_ibss_parms_t;
10648 +
10649 +/*-- Challenge Text ------------------------------*/
10650 +typedef struct wlan_ie_challenge
10651 +{
10652 + u8 eid;
10653 + u8 len;
10654 + u8 challenge[1];
10655 +} __WLAN_ATTRIB_PACK__ wlan_ie_challenge_t;
10656 +
10657 +/*-------------------------------------------------*/
10658 +/* Frame Types */
10659 +
10660 +/* prototype structure, all mgmt frame types will start with these members */
10661 +typedef struct wlan_fr_mgmt
10662 +{
10663 + u16 type;
10664 + u16 len; /* DOES NOT include CRC !!!!*/
10665 + u8 *buf;
10666 + p80211_hdr_t *hdr;
10667 + /* used for target specific data, skb in Linux */
10668 + void *priv;
10669 + /*-- fixed fields -----------*/
10670 + /*-- info elements ----------*/
10671 +} wlan_fr_mgmt_t;
10672 +
10673 +/*-- Beacon ---------------------------------------*/
10674 +typedef struct wlan_fr_beacon
10675 +{
10676 + u16 type;
10677 + u16 len;
10678 + u8 *buf;
10679 + p80211_hdr_t *hdr;
10680 + /* used for target specific data, skb in Linux */
10681 + void *priv;
10682 + /*-- fixed fields -----------*/
10683 + u64 *ts;
10684 + u16 *bcn_int;
10685 + u16 *cap_info;
10686 + /*-- info elements ----------*/
10687 + wlan_ie_ssid_t *ssid;
10688 + wlan_ie_supp_rates_t *supp_rates;
10689 + wlan_ie_fh_parms_t *fh_parms;
10690 + wlan_ie_ds_parms_t *ds_parms;
10691 + wlan_ie_cf_parms_t *cf_parms;
10692 + wlan_ie_ibss_parms_t *ibss_parms;
10693 + wlan_ie_tim_t *tim;
10694 +
10695 +} wlan_fr_beacon_t;
10696 +
10697 +
10698 +/*-- IBSS ATIM ------------------------------------*/
10699 +typedef struct wlan_fr_ibssatim
10700 +{
10701 + u16 type;
10702 + u16 len;
10703 + u8* buf;
10704 + p80211_hdr_t *hdr;
10705 + /* used for target specific data, skb in Linux */
10706 + void *priv;
10707 +
10708 + /*-- fixed fields -----------*/
10709 + /*-- info elements ----------*/
10710 +
10711 + /* this frame type has a null body */
10712 +
10713 +} wlan_fr_ibssatim_t;
10714 +
10715 +/*-- Disassociation -------------------------------*/
10716 +typedef struct wlan_fr_disassoc
10717 +{
10718 + u16 type;
10719 + u16 len;
10720 + u8 *buf;
10721 + p80211_hdr_t *hdr;
10722 + /* used for target specific data, skb in Linux */
10723 + void *priv;
10724 + /*-- fixed fields -----------*/
10725 + u16 *reason;
10726 +
10727 + /*-- info elements ----------*/
10728 +
10729 +} wlan_fr_disassoc_t;
10730 +
10731 +/*-- Association Request --------------------------*/
10732 +typedef struct wlan_fr_assocreq
10733 +{
10734 + u16 type;
10735 + u16 len;
10736 + u8* buf;
10737 + p80211_hdr_t *hdr;
10738 + /* used for target specific data, skb in Linux */
10739 + void *priv;
10740 + /*-- fixed fields -----------*/
10741 + u16 *cap_info;
10742 + u16 *listen_int;
10743 + /*-- info elements ----------*/
10744 + wlan_ie_ssid_t *ssid;
10745 + wlan_ie_supp_rates_t *supp_rates;
10746 +
10747 +} wlan_fr_assocreq_t;
10748 +
10749 +/*-- Association Response -------------------------*/
10750 +typedef struct wlan_fr_assocresp
10751 +{
10752 + u16 type;
10753 + u16 len;
10754 + u8 *buf;
10755 + p80211_hdr_t *hdr;
10756 + /* used for target specific data, skb in Linux */
10757 + void *priv;
10758 + /*-- fixed fields -----------*/
10759 + u16 *cap_info;
10760 + u16 *status;
10761 + u16 *aid;
10762 + /*-- info elements ----------*/
10763 + wlan_ie_supp_rates_t *supp_rates;
10764 +
10765 +} wlan_fr_assocresp_t;
10766 +
10767 +/*-- Reassociation Request ------------------------*/
10768 +typedef struct wlan_fr_reassocreq
10769 +{
10770 + u16 type;
10771 + u16 len;
10772 + u8 *buf;
10773 + p80211_hdr_t *hdr;
10774 + /* used for target specific data, skb in Linux */
10775 + void *priv;
10776 + /*-- fixed fields -----------*/
10777 + u16 *cap_info;
10778 + u16 *listen_int;
10779 + u8 *curr_ap;
10780 + /*-- info elements ----------*/
10781 + wlan_ie_ssid_t *ssid;
10782 + wlan_ie_supp_rates_t *supp_rates;
10783 +
10784 +} wlan_fr_reassocreq_t;
10785 +
10786 +/*-- Reassociation Response -----------------------*/
10787 +typedef struct wlan_fr_reassocresp
10788 +{
10789 + u16 type;
10790 + u16 len;
10791 + u8 *buf;
10792 + p80211_hdr_t *hdr;
10793 + /* used for target specific data, skb in Linux */
10794 + void *priv;
10795 + /*-- fixed fields -----------*/
10796 + u16 *cap_info;
10797 + u16 *status;
10798 + u16 *aid;
10799 + /*-- info elements ----------*/
10800 + wlan_ie_supp_rates_t *supp_rates;
10801 +
10802 +} wlan_fr_reassocresp_t;
10803 +
10804 +/*-- Probe Request --------------------------------*/
10805 +typedef struct wlan_fr_probereq
10806 +{
10807 + u16 type;
10808 + u16 len;
10809 + u8 *buf;
10810 + p80211_hdr_t *hdr;
10811 + /* used for target specific data, skb in Linux */
10812 + void *priv;
10813 + /*-- fixed fields -----------*/
10814 + /*-- info elements ----------*/
10815 + wlan_ie_ssid_t *ssid;
10816 + wlan_ie_supp_rates_t *supp_rates;
10817 +
10818 +} wlan_fr_probereq_t;
10819 +
10820 +/*-- Probe Response -------------------------------*/
10821 +typedef struct wlan_fr_proberesp
10822 +{
10823 + u16 type;
10824 + u16 len;
10825 + u8 *buf;
10826 + p80211_hdr_t *hdr;
10827 + /* used for target specific data, skb in Linux */
10828 + void *priv;
10829 + /*-- fixed fields -----------*/
10830 + u64 *ts;
10831 + u16 *bcn_int;
10832 + u16 *cap_info;
10833 + /*-- info elements ----------*/
10834 + wlan_ie_ssid_t *ssid;
10835 + wlan_ie_supp_rates_t *supp_rates;
10836 + wlan_ie_fh_parms_t *fh_parms;
10837 + wlan_ie_ds_parms_t *ds_parms;
10838 + wlan_ie_cf_parms_t *cf_parms;
10839 + wlan_ie_ibss_parms_t *ibss_parms;
10840 +} wlan_fr_proberesp_t;
10841 +
10842 +/*-- Authentication -------------------------------*/
10843 +typedef struct wlan_fr_authen
10844 +{
10845 + u16 type;
10846 + u16 len;
10847 + u8 *buf;
10848 + p80211_hdr_t *hdr;
10849 + /* used for target specific data, skb in Linux */
10850 + void *priv;
10851 + /*-- fixed fields -----------*/
10852 + u16 *auth_alg;
10853 + u16 *auth_seq;
10854 + u16 *status;
10855 + /*-- info elements ----------*/
10856 + wlan_ie_challenge_t *challenge;
10857 +
10858 +} wlan_fr_authen_t;
10859 +
10860 +/*-- Deauthenication -----------------------------*/
10861 +typedef struct wlan_fr_deauthen
10862 +{
10863 + u16 type;
10864 + u16 len;
10865 + u8 *buf;
10866 + p80211_hdr_t *hdr;
10867 + /* used for target specific data, skb in Linux */
10868 + void *priv;
10869 + /*-- fixed fields -----------*/
10870 + u16 *reason;
10871 +
10872 + /*-- info elements ----------*/
10873 +
10874 +} wlan_fr_deauthen_t;
10875 +
10876 +
10877 +/*================================================================*/
10878 +/* Extern Declarations */
10879 +
10880 +
10881 +/*================================================================*/
10882 +/* Function Declarations */
10883 +
10884 +void wlan_mgmt_encode_beacon( wlan_fr_beacon_t *f );
10885 +void wlan_mgmt_decode_beacon( wlan_fr_beacon_t *f );
10886 +void wlan_mgmt_encode_disassoc( wlan_fr_disassoc_t *f );
10887 +void wlan_mgmt_decode_disassoc( wlan_fr_disassoc_t *f );
10888 +void wlan_mgmt_encode_assocreq( wlan_fr_assocreq_t *f );
10889 +void wlan_mgmt_decode_assocreq( wlan_fr_assocreq_t *f );
10890 +void wlan_mgmt_encode_assocresp( wlan_fr_assocresp_t *f );
10891 +void wlan_mgmt_decode_assocresp( wlan_fr_assocresp_t *f );
10892 +void wlan_mgmt_encode_reassocreq( wlan_fr_reassocreq_t *f );
10893 +void wlan_mgmt_decode_reassocreq( wlan_fr_reassocreq_t *f );
10894 +void wlan_mgmt_encode_reassocresp( wlan_fr_reassocresp_t *f );
10895 +void wlan_mgmt_decode_reassocresp( wlan_fr_reassocresp_t *f );
10896 +void wlan_mgmt_encode_probereq( wlan_fr_probereq_t *f );
10897 +void wlan_mgmt_decode_probereq( wlan_fr_probereq_t *f );
10898 +void wlan_mgmt_encode_proberesp( wlan_fr_proberesp_t *f );
10899 +void wlan_mgmt_decode_proberesp( wlan_fr_proberesp_t *f );
10900 +void wlan_mgmt_encode_authen( wlan_fr_authen_t *f );
10901 +void wlan_mgmt_decode_authen( wlan_fr_authen_t *f );
10902 +void wlan_mgmt_encode_deauthen( wlan_fr_deauthen_t *f );
10903 +void wlan_mgmt_decode_deauthen( wlan_fr_deauthen_t *f );
10904 +
10905 +
10906 +#endif /* _P80211MGMT_H */
10907 --- /dev/null
10908 +++ b/drivers/staging/wlan-ng/p80211msg.h
10909 @@ -0,0 +1,102 @@
10910 +/* p80211msg.h
10911 +*
10912 +* Macros, constants, types, and funcs for req and ind messages
10913 +*
10914 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
10915 +* --------------------------------------------------------------------
10916 +*
10917 +* linux-wlan
10918 +*
10919 +* The contents of this file are subject to the Mozilla Public
10920 +* License Version 1.1 (the "License"); you may not use this file
10921 +* except in compliance with the License. You may obtain a copy of
10922 +* the License at http://www.mozilla.org/MPL/
10923 +*
10924 +* Software distributed under the License is distributed on an "AS
10925 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10926 +* implied. See the License for the specific language governing
10927 +* rights and limitations under the License.
10928 +*
10929 +* Alternatively, the contents of this file may be used under the
10930 +* terms of the GNU Public License version 2 (the "GPL"), in which
10931 +* case the provisions of the GPL are applicable instead of the
10932 +* above. If you wish to allow the use of your version of this file
10933 +* only under the terms of the GPL and not to allow others to use
10934 +* your version of this file under the MPL, indicate your decision
10935 +* by deleting the provisions above and replace them with the notice
10936 +* and other provisions required by the GPL. If you do not delete
10937 +* the provisions above, a recipient may use your version of this
10938 +* file under either the MPL or the GPL.
10939 +*
10940 +* --------------------------------------------------------------------
10941 +*
10942 +* Inquiries regarding the linux-wlan Open Source project can be
10943 +* made directly to:
10944 +*
10945 +* AbsoluteValue Systems Inc.
10946 +* info@linux-wlan.com
10947 +* http://www.linux-wlan.com
10948 +*
10949 +* --------------------------------------------------------------------
10950 +*
10951 +* Portions of the development of this software were funded by
10952 +* Intersil Corporation as part of PRISM(R) chipset product development.
10953 +*
10954 +* --------------------------------------------------------------------
10955 +*/
10956 +
10957 +#ifndef _P80211MSG_H
10958 +#define _P80211MSG_H
10959 +
10960 +/*================================================================*/
10961 +/* System Includes */
10962 +
10963 +/*================================================================*/
10964 +/* Project Includes */
10965 +
10966 +#ifndef _WLAN_COMPAT_H
10967 +#include "wlan_compat.h"
10968 +#endif
10969 +
10970 +/*================================================================*/
10971 +/* Constants */
10972 +
10973 +#define MSG_BUFF_LEN 4000
10974 +#define WLAN_DEVNAMELEN_MAX 16
10975 +
10976 +/*================================================================*/
10977 +/* Macros */
10978 +
10979 +/*================================================================*/
10980 +/* Types */
10981 +
10982 +/*--------------------------------------------------------------------*/
10983 +/*----- Message Structure Types --------------------------------------*/
10984 +
10985 +/*--------------------------------------------------------------------*/
10986 +/* Prototype msg type */
10987 +
10988 +typedef struct p80211msg
10989 +{
10990 + u32 msgcode;
10991 + u32 msglen;
10992 + u8 devname[WLAN_DEVNAMELEN_MAX];
10993 +} __WLAN_ATTRIB_PACK__ p80211msg_t;
10994 +
10995 +typedef struct p80211msgd
10996 +{
10997 + u32 msgcode;
10998 + u32 msglen;
10999 + u8 devname[WLAN_DEVNAMELEN_MAX];
11000 + u8 args[0];
11001 +} __WLAN_ATTRIB_PACK__ p80211msgd_t;
11002 +
11003 +/*================================================================*/
11004 +/* Extern Declarations */
11005 +
11006 +
11007 +/*================================================================*/
11008 +/* Function Declarations */
11009 +
11010 +#endif /* _P80211MSG_H */
11011 +
11012 --- /dev/null
11013 +++ b/drivers/staging/wlan-ng/p80211netdev.c
11014 @@ -0,0 +1,1209 @@
11015 +/* src/p80211/p80211knetdev.c
11016 +*
11017 +* Linux Kernel net device interface
11018 +*
11019 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
11020 +* --------------------------------------------------------------------
11021 +*
11022 +* linux-wlan
11023 +*
11024 +* The contents of this file are subject to the Mozilla Public
11025 +* License Version 1.1 (the "License"); you may not use this file
11026 +* except in compliance with the License. You may obtain a copy of
11027 +* the License at http://www.mozilla.org/MPL/
11028 +*
11029 +* Software distributed under the License is distributed on an "AS
11030 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11031 +* implied. See the License for the specific language governing
11032 +* rights and limitations under the License.
11033 +*
11034 +* Alternatively, the contents of this file may be used under the
11035 +* terms of the GNU Public License version 2 (the "GPL"), in which
11036 +* case the provisions of the GPL are applicable instead of the
11037 +* above. If you wish to allow the use of your version of this file
11038 +* only under the terms of the GPL and not to allow others to use
11039 +* your version of this file under the MPL, indicate your decision
11040 +* by deleting the provisions above and replace them with the notice
11041 +* and other provisions required by the GPL. If you do not delete
11042 +* the provisions above, a recipient may use your version of this
11043 +* file under either the MPL or the GPL.
11044 +*
11045 +* --------------------------------------------------------------------
11046 +*
11047 +* Inquiries regarding the linux-wlan Open Source project can be
11048 +* made directly to:
11049 +*
11050 +* AbsoluteValue Systems Inc.
11051 +* info@linux-wlan.com
11052 +* http://www.linux-wlan.com
11053 +*
11054 +* --------------------------------------------------------------------
11055 +*
11056 +* Portions of the development of this software were funded by
11057 +* Intersil Corporation as part of PRISM(R) chipset product development.
11058 +*
11059 +* --------------------------------------------------------------------
11060 +*
11061 +* The functions required for a Linux network device are defined here.
11062 +*
11063 +* --------------------------------------------------------------------
11064 +*/
11065 +
11066 +
11067 +/*================================================================*/
11068 +/* System Includes */
11069 +
11070 +
11071 +#include <linux/version.h>
11072 +
11073 +#include <linux/module.h>
11074 +#include <linux/kernel.h>
11075 +#include <linux/sched.h>
11076 +#include <linux/types.h>
11077 +#include <linux/skbuff.h>
11078 +#include <linux/slab.h>
11079 +#include <linux/proc_fs.h>
11080 +#include <linux/interrupt.h>
11081 +#include <linux/netdevice.h>
11082 +#include <linux/kmod.h>
11083 +#include <linux/if_arp.h>
11084 +#include <linux/wireless.h>
11085 +#include <linux/sockios.h>
11086 +#include <linux/etherdevice.h>
11087 +
11088 +#include <asm/bitops.h>
11089 +#include <asm/uaccess.h>
11090 +#include <asm/byteorder.h>
11091 +
11092 +#ifdef SIOCETHTOOL
11093 +#include <linux/ethtool.h>
11094 +#endif
11095 +
11096 +#include <net/iw_handler.h>
11097 +#include <net/net_namespace.h>
11098 +
11099 +/*================================================================*/
11100 +/* Project Includes */
11101 +
11102 +#include "wlan_compat.h"
11103 +#include "p80211types.h"
11104 +#include "p80211hdr.h"
11105 +#include "p80211conv.h"
11106 +#include "p80211mgmt.h"
11107 +#include "p80211msg.h"
11108 +#include "p80211netdev.h"
11109 +#include "p80211ioctl.h"
11110 +#include "p80211req.h"
11111 +#include "p80211metastruct.h"
11112 +#include "p80211metadef.h"
11113 +
11114 +/*================================================================*/
11115 +/* Local Constants */
11116 +
11117 +/*================================================================*/
11118 +/* Local Macros */
11119 +
11120 +
11121 +/*================================================================*/
11122 +/* Local Types */
11123 +
11124 +/*================================================================*/
11125 +/* Local Function Declarations */
11126 +
11127 +/* Support functions */
11128 +static void p80211netdev_rx_bh(unsigned long arg);
11129 +
11130 +/* netdevice method functions */
11131 +static int p80211knetdev_init( netdevice_t *netdev);
11132 +static struct net_device_stats* p80211knetdev_get_stats(netdevice_t *netdev);
11133 +static int p80211knetdev_open( netdevice_t *netdev);
11134 +static int p80211knetdev_stop( netdevice_t *netdev );
11135 +static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netdev);
11136 +static void p80211knetdev_set_multicast_list(netdevice_t *dev);
11137 +static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd);
11138 +static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr);
11139 +static void p80211knetdev_tx_timeout(netdevice_t *netdev);
11140 +static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc);
11141 +
11142 +int wlan_watchdog = 5000;
11143 +module_param(wlan_watchdog, int, 0644);
11144 +MODULE_PARM_DESC(wlan_watchdog, "transmit timeout in milliseconds");
11145 +
11146 +int wlan_wext_write = 1;
11147 +module_param(wlan_wext_write, int, 0644);
11148 +MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions");
11149 +
11150 +#ifdef WLAN_INCLUDE_DEBUG
11151 +int wlan_debug=0;
11152 +module_param(wlan_debug, int, 0644);
11153 +MODULE_PARM_DESC(wlan_debug, "p80211 debug level");
11154 +#endif
11155 +
11156 +/*================================================================*/
11157 +/* Function Definitions */
11158 +
11159 +/*----------------------------------------------------------------
11160 +* p80211knetdev_init
11161 +*
11162 +* Init method for a Linux netdevice. Called in response to
11163 +* register_netdev.
11164 +*
11165 +* Arguments:
11166 +* none
11167 +*
11168 +* Returns:
11169 +* nothing
11170 +----------------------------------------------------------------*/
11171 +static int p80211knetdev_init( netdevice_t *netdev)
11172 +{
11173 + DBFENTER;
11174 + /* Called in response to register_netdev */
11175 + /* This is usually the probe function, but the probe has */
11176 + /* already been done by the MSD and the create_kdev */
11177 + /* function. All we do here is return success */
11178 + DBFEXIT;
11179 + return 0;
11180 +}
11181 +
11182 +
11183 +/*----------------------------------------------------------------
11184 +* p80211knetdev_get_stats
11185 +*
11186 +* Statistics retrieval for linux netdevices. Here we're reporting
11187 +* the Linux i/f level statistics. Hence, for the primary numbers,
11188 +* we don't want to report the numbers from the MIB. Eventually,
11189 +* it might be useful to collect some of the error counters though.
11190 +*
11191 +* Arguments:
11192 +* netdev Linux netdevice
11193 +*
11194 +* Returns:
11195 +* the address of the statistics structure
11196 +----------------------------------------------------------------*/
11197 +static struct net_device_stats*
11198 +p80211knetdev_get_stats(netdevice_t *netdev)
11199 +{
11200 + wlandevice_t *wlandev = (wlandevice_t*)netdev->priv;
11201 + DBFENTER;
11202 +
11203 + /* TODO: review the MIB stats for items that correspond to
11204 + linux stats */
11205 +
11206 + DBFEXIT;
11207 + return &(wlandev->linux_stats);
11208 +}
11209 +
11210 +
11211 +/*----------------------------------------------------------------
11212 +* p80211knetdev_open
11213 +*
11214 +* Linux netdevice open method. Following a successful call here,
11215 +* the device is supposed to be ready for tx and rx. In our
11216 +* situation that may not be entirely true due to the state of the
11217 +* MAC below.
11218 +*
11219 +* Arguments:
11220 +* netdev Linux network device structure
11221 +*
11222 +* Returns:
11223 +* zero on success, non-zero otherwise
11224 +----------------------------------------------------------------*/
11225 +static int p80211knetdev_open( netdevice_t *netdev )
11226 +{
11227 + int result = 0; /* success */
11228 + wlandevice_t *wlandev = (wlandevice_t*)(netdev->priv);
11229 +
11230 + DBFENTER;
11231 +
11232 + /* Check to make sure the MSD is running */
11233 + if ( wlandev->msdstate != WLAN_MSD_RUNNING ) {
11234 + return -ENODEV;
11235 + }
11236 +
11237 + /* Tell the MSD to open */
11238 + if ( wlandev->open != NULL) {
11239 + result = wlandev->open(wlandev);
11240 + if ( result == 0 ) {
11241 + netif_start_queue(wlandev->netdev);
11242 + wlandev->state = WLAN_DEVICE_OPEN;
11243 + }
11244 + } else {
11245 + result = -EAGAIN;
11246 + }
11247 +
11248 + DBFEXIT;
11249 + return result;
11250 +}
11251 +
11252 +
11253 +/*----------------------------------------------------------------
11254 +* p80211knetdev_stop
11255 +*
11256 +* Linux netdevice stop (close) method. Following this call,
11257 +* no frames should go up or down through this interface.
11258 +*
11259 +* Arguments:
11260 +* netdev Linux network device structure
11261 +*
11262 +* Returns:
11263 +* zero on success, non-zero otherwise
11264 +----------------------------------------------------------------*/
11265 +static int p80211knetdev_stop( netdevice_t *netdev )
11266 +{
11267 + int result = 0;
11268 + wlandevice_t *wlandev = (wlandevice_t*)(netdev->priv);
11269 +
11270 + DBFENTER;
11271 +
11272 + if ( wlandev->close != NULL ) {
11273 + result = wlandev->close(wlandev);
11274 + }
11275 +
11276 + netif_stop_queue(wlandev->netdev);
11277 + wlandev->state = WLAN_DEVICE_CLOSED;
11278 +
11279 + DBFEXIT;
11280 + return result;
11281 +}
11282 +
11283 +/*----------------------------------------------------------------
11284 +* p80211netdev_rx
11285 +*
11286 +* Frame receive function called by the mac specific driver.
11287 +*
11288 +* Arguments:
11289 +* wlandev WLAN network device structure
11290 +* skb skbuff containing a full 802.11 frame.
11291 +* Returns:
11292 +* nothing
11293 +* Side effects:
11294 +*
11295 +----------------------------------------------------------------*/
11296 +void
11297 +p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb )
11298 +{
11299 + DBFENTER;
11300 +
11301 + /* Enqueue for post-irq processing */
11302 + skb_queue_tail(&wlandev->nsd_rxq, skb);
11303 +
11304 + tasklet_schedule(&wlandev->rx_bh);
11305 +
11306 + DBFEXIT;
11307 + return;
11308 +}
11309 +
11310 +/*----------------------------------------------------------------
11311 +* p80211netdev_rx_bh
11312 +*
11313 +* Deferred processing of all received frames.
11314 +*
11315 +* Arguments:
11316 +* wlandev WLAN network device structure
11317 +* skb skbuff containing a full 802.11 frame.
11318 +* Returns:
11319 +* nothing
11320 +* Side effects:
11321 +*
11322 +----------------------------------------------------------------*/
11323 +static void p80211netdev_rx_bh(unsigned long arg)
11324 +{
11325 + wlandevice_t *wlandev = (wlandevice_t *) arg;
11326 + struct sk_buff *skb = NULL;
11327 + netdevice_t *dev = wlandev->netdev;
11328 + p80211_hdr_a3_t *hdr;
11329 + u16 fc;
11330 +
11331 + DBFENTER;
11332 +
11333 + /* Let's empty our our queue */
11334 + while ( (skb = skb_dequeue(&wlandev->nsd_rxq)) ) {
11335 + if (wlandev->state == WLAN_DEVICE_OPEN) {
11336 +
11337 + if (dev->type != ARPHRD_ETHER) {
11338 + /* RAW frame; we shouldn't convert it */
11339 + // XXX Append the Prism Header here instead.
11340 +
11341 + /* set up various data fields */
11342 + skb->dev = dev;
11343 + skb_reset_mac_header(skb);
11344 + skb->ip_summed = CHECKSUM_NONE;
11345 + skb->pkt_type = PACKET_OTHERHOST;
11346 + skb->protocol = htons(ETH_P_80211_RAW);
11347 + dev->last_rx = jiffies;
11348 +
11349 + wlandev->linux_stats.rx_packets++;
11350 + wlandev->linux_stats.rx_bytes += skb->len;
11351 + netif_rx_ni(skb);
11352 + continue;
11353 + } else {
11354 + hdr = (p80211_hdr_a3_t *)skb->data;
11355 + fc = ieee2host16(hdr->fc);
11356 + if (p80211_rx_typedrop(wlandev, fc)) {
11357 + dev_kfree_skb(skb);
11358 + continue;
11359 + }
11360 +
11361 + /* perform mcast filtering */
11362 + if (wlandev->netdev->flags & IFF_ALLMULTI) {
11363 + /* allow my local address through */
11364 + if (memcmp(hdr->a1, wlandev->netdev->dev_addr, WLAN_ADDR_LEN) != 0) {
11365 + /* but reject anything else that isn't multicast */
11366 + if (!(hdr->a1[0] & 0x01)) {
11367 + dev_kfree_skb(skb);
11368 + continue;
11369 + }
11370 + }
11371 + }
11372 +
11373 + if ( skb_p80211_to_ether(wlandev, wlandev->ethconv, skb) == 0 ) {
11374 + skb->dev->last_rx = jiffies;
11375 + wlandev->linux_stats.rx_packets++;
11376 + wlandev->linux_stats.rx_bytes += skb->len;
11377 + netif_rx_ni(skb);
11378 + continue;
11379 + }
11380 + WLAN_LOG_DEBUG(1, "p80211_to_ether failed.\n");
11381 + }
11382 + }
11383 + dev_kfree_skb(skb);
11384 + }
11385 +
11386 + DBFEXIT;
11387 +}
11388 +
11389 +
11390 +/*----------------------------------------------------------------
11391 +* p80211knetdev_hard_start_xmit
11392 +*
11393 +* Linux netdevice method for transmitting a frame.
11394 +*
11395 +* Arguments:
11396 +* skb Linux sk_buff containing the frame.
11397 +* netdev Linux netdevice.
11398 +*
11399 +* Side effects:
11400 +* If the lower layers report that buffers are full. netdev->tbusy
11401 +* will be set to prevent higher layers from sending more traffic.
11402 +*
11403 +* Note: If this function returns non-zero, higher layers retain
11404 +* ownership of the skb.
11405 +*
11406 +* Returns:
11407 +* zero on success, non-zero on failure.
11408 +----------------------------------------------------------------*/
11409 +static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netdev)
11410 +{
11411 + int result = 0;
11412 + int txresult = -1;
11413 + wlandevice_t *wlandev = (wlandevice_t*)netdev->priv;
11414 + p80211_hdr_t p80211_hdr;
11415 + p80211_metawep_t p80211_wep;
11416 +
11417 + DBFENTER;
11418 +
11419 + if (skb == NULL) {
11420 + return 0;
11421 + }
11422 +
11423 + if (wlandev->state != WLAN_DEVICE_OPEN) {
11424 + result = 1;
11425 + goto failed;
11426 + }
11427 +
11428 + memset(&p80211_hdr, 0, sizeof(p80211_hdr_t));
11429 + memset(&p80211_wep, 0, sizeof(p80211_metawep_t));
11430 +
11431 + if ( netif_queue_stopped(netdev) ) {
11432 + WLAN_LOG_DEBUG(1, "called when queue stopped.\n");
11433 + result = 1;
11434 + goto failed;
11435 + }
11436 +
11437 + netif_stop_queue(netdev);
11438 +
11439 + /* Check to see that a valid mode is set */
11440 + switch( wlandev->macmode ) {
11441 + case WLAN_MACMODE_IBSS_STA:
11442 + case WLAN_MACMODE_ESS_STA:
11443 + case WLAN_MACMODE_ESS_AP:
11444 + break;
11445 + default:
11446 + /* Mode isn't set yet, just drop the frame
11447 + * and return success .
11448 + * TODO: we need a saner way to handle this
11449 + */
11450 + if(skb->protocol != ETH_P_80211_RAW) {
11451 + netif_start_queue(wlandev->netdev);
11452 + WLAN_LOG_NOTICE(
11453 + "Tx attempt prior to association, frame dropped.\n");
11454 + wlandev->linux_stats.tx_dropped++;
11455 + result = 0;
11456 + goto failed;
11457 + }
11458 + break;
11459 + }
11460 +
11461 + /* Check for raw transmits */
11462 + if(skb->protocol == ETH_P_80211_RAW) {
11463 + if (!capable(CAP_NET_ADMIN)) {
11464 + result = 1;
11465 + goto failed;
11466 + }
11467 + /* move the header over */
11468 + memcpy(&p80211_hdr, skb->data, sizeof(p80211_hdr_t));
11469 + skb_pull(skb, sizeof(p80211_hdr_t));
11470 + } else {
11471 + if ( skb_ether_to_p80211(wlandev, wlandev->ethconv, skb, &p80211_hdr, &p80211_wep) != 0 ) {
11472 + /* convert failed */
11473 + WLAN_LOG_DEBUG(1, "ether_to_80211(%d) failed.\n",
11474 + wlandev->ethconv);
11475 + result = 1;
11476 + goto failed;
11477 + }
11478 + }
11479 + if ( wlandev->txframe == NULL ) {
11480 + result = 1;
11481 + goto failed;
11482 + }
11483 +
11484 + netdev->trans_start = jiffies;
11485 +
11486 + wlandev->linux_stats.tx_packets++;
11487 + /* count only the packet payload */
11488 + wlandev->linux_stats.tx_bytes += skb->len;
11489 +
11490 + txresult = wlandev->txframe(wlandev, skb, &p80211_hdr, &p80211_wep);
11491 +
11492 + if ( txresult == 0) {
11493 + /* success and more buf */
11494 + /* avail, re: hw_txdata */
11495 + netif_wake_queue(wlandev->netdev);
11496 + result = 0;
11497 + } else if ( txresult == 1 ) {
11498 + /* success, no more avail */
11499 + WLAN_LOG_DEBUG(3, "txframe success, no more bufs\n");
11500 + /* netdev->tbusy = 1; don't set here, irqhdlr */
11501 + /* may have already cleared it */
11502 + result = 0;
11503 + } else if ( txresult == 2 ) {
11504 + /* alloc failure, drop frame */
11505 + WLAN_LOG_DEBUG(3, "txframe returned alloc_fail\n");
11506 + result = 1;
11507 + } else {
11508 + /* buffer full or queue busy, drop frame. */
11509 + WLAN_LOG_DEBUG(3, "txframe returned full or busy\n");
11510 + result = 1;
11511 + }
11512 +
11513 + failed:
11514 + /* Free up the WEP buffer if it's not the same as the skb */
11515 + if ((p80211_wep.data) && (p80211_wep.data != skb->data))
11516 + kfree(p80211_wep.data);
11517 +
11518 + /* we always free the skb here, never in a lower level. */
11519 + if (!result)
11520 + dev_kfree_skb(skb);
11521 +
11522 + DBFEXIT;
11523 + return result;
11524 +}
11525 +
11526 +
11527 +/*----------------------------------------------------------------
11528 +* p80211knetdev_set_multicast_list
11529 +*
11530 +* Called from higher lavers whenever there's a need to set/clear
11531 +* promiscuous mode or rewrite the multicast list.
11532 +*
11533 +* Arguments:
11534 +* none
11535 +*
11536 +* Returns:
11537 +* nothing
11538 +----------------------------------------------------------------*/
11539 +static void p80211knetdev_set_multicast_list(netdevice_t *dev)
11540 +{
11541 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
11542 +
11543 + DBFENTER;
11544 +
11545 + /* TODO: real multicast support as well */
11546 +
11547 + if (wlandev->set_multicast_list)
11548 + wlandev->set_multicast_list(wlandev, dev);
11549 +
11550 + DBFEXIT;
11551 +}
11552 +
11553 +#ifdef SIOCETHTOOL
11554 +
11555 +static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr)
11556 +{
11557 + u32 ethcmd;
11558 + struct ethtool_drvinfo info;
11559 + struct ethtool_value edata;
11560 +
11561 + memset(&info, 0, sizeof(info));
11562 + memset(&edata, 0, sizeof(edata));
11563 +
11564 + if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
11565 + return -EFAULT;
11566 +
11567 + switch (ethcmd) {
11568 + case ETHTOOL_GDRVINFO:
11569 + info.cmd = ethcmd;
11570 + snprintf(info.driver, sizeof(info.driver), "p80211_%s",
11571 + wlandev->nsdname);
11572 + snprintf(info.version, sizeof(info.version), "%s",
11573 + WLAN_RELEASE);
11574 +
11575 + // info.fw_version
11576 + // info.bus_info
11577 +
11578 + if (copy_to_user(useraddr, &info, sizeof(info)))
11579 + return -EFAULT;
11580 + return 0;
11581 +#ifdef ETHTOOL_GLINK
11582 + case ETHTOOL_GLINK:
11583 + edata.cmd = ethcmd;
11584 +
11585 + if (wlandev->linkstatus &&
11586 + (wlandev->macmode != WLAN_MACMODE_NONE)) {
11587 + edata.data = 1;
11588 + } else {
11589 + edata.data = 0;
11590 + }
11591 +
11592 + if (copy_to_user(useraddr, &edata, sizeof(edata)))
11593 + return -EFAULT;
11594 + return 0;
11595 + }
11596 +#endif
11597 +
11598 + return -EOPNOTSUPP;
11599 +}
11600 +
11601 +#endif
11602 +
11603 +/*----------------------------------------------------------------
11604 +* p80211knetdev_do_ioctl
11605 +*
11606 +* Handle an ioctl call on one of our devices. Everything Linux
11607 +* ioctl specific is done here. Then we pass the contents of the
11608 +* ifr->data to the request message handler.
11609 +*
11610 +* Arguments:
11611 +* dev Linux kernel netdevice
11612 +* ifr Our private ioctl request structure, typed for the
11613 +* generic struct ifreq so we can use ptr to func
11614 +* w/o cast.
11615 +*
11616 +* Returns:
11617 +* zero on success, a negative errno on failure. Possible values:
11618 +* -ENETDOWN Device isn't up.
11619 +* -EBUSY cmd already in progress
11620 +* -ETIME p80211 cmd timed out (MSD may have its own timers)
11621 +* -EFAULT memory fault copying msg from user buffer
11622 +* -ENOMEM unable to allocate kernel msg buffer
11623 +* -ENOSYS bad magic, it the cmd really for us?
11624 +* -EintR sleeping on cmd, awakened by signal, cmd cancelled.
11625 +*
11626 +* Call Context:
11627 +* Process thread (ioctl caller). TODO: SMP support may require
11628 +* locks.
11629 +----------------------------------------------------------------*/
11630 +static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)
11631 +{
11632 + int result = 0;
11633 + p80211ioctl_req_t *req = (p80211ioctl_req_t*)ifr;
11634 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
11635 + u8 *msgbuf;
11636 + DBFENTER;
11637 +
11638 + WLAN_LOG_DEBUG(2, "rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len);
11639 +
11640 +#ifdef SIOCETHTOOL
11641 + if (cmd == SIOCETHTOOL) {
11642 + result = p80211netdev_ethtool(wlandev, (void __user *) ifr->ifr_data);
11643 + goto bail;
11644 + }
11645 +#endif
11646 +
11647 + /* Test the magic, assume ifr is good if it's there */
11648 + if ( req->magic != P80211_IOCTL_MAGIC ) {
11649 + result = -ENOSYS;
11650 + goto bail;
11651 + }
11652 +
11653 + if ( cmd == P80211_IFTEST ) {
11654 + result = 0;
11655 + goto bail;
11656 + } else if ( cmd != P80211_IFREQ ) {
11657 + result = -ENOSYS;
11658 + goto bail;
11659 + }
11660 +
11661 + /* Allocate a buf of size req->len */
11662 + if ((msgbuf = kmalloc( req->len, GFP_KERNEL))) {
11663 + if ( copy_from_user( msgbuf, (void __user *) req->data, req->len) ) {
11664 + result = -EFAULT;
11665 + } else {
11666 + result = p80211req_dorequest( wlandev, msgbuf);
11667 + }
11668 +
11669 + if ( result == 0 ) {
11670 + if ( copy_to_user( (void __user *) req->data, msgbuf, req->len)) {
11671 + result = -EFAULT;
11672 + }
11673 + }
11674 + kfree(msgbuf);
11675 + } else {
11676 + result = -ENOMEM;
11677 + }
11678 +bail:
11679 + DBFEXIT;
11680 +
11681 + return result; /* If allocate,copyfrom or copyto fails, return errno */
11682 +}
11683 +
11684 +/*----------------------------------------------------------------
11685 +* p80211knetdev_set_mac_address
11686 +*
11687 +* Handles the ioctl for changing the MACAddress of a netdevice
11688 +*
11689 +* references: linux/netdevice.h and drivers/net/net_init.c
11690 +*
11691 +* NOTE: [MSM] We only prevent address changes when the netdev is
11692 +* up. We don't control anything based on dot11 state. If the
11693 +* address is changed on a STA that's currently associated, you
11694 +* will probably lose the ability to send and receive data frames.
11695 +* Just be aware. Therefore, this should usually only be done
11696 +* prior to scan/join/auth/assoc.
11697 +*
11698 +* Arguments:
11699 +* dev netdevice struct
11700 +* addr the new MACAddress (a struct)
11701 +*
11702 +* Returns:
11703 +* zero on success, a negative errno on failure. Possible values:
11704 +* -EBUSY device is bussy (cmd not possible)
11705 +* -and errors returned by: p80211req_dorequest(..)
11706 +*
11707 +* by: Collin R. Mulliner <collin@mulliner.org>
11708 +----------------------------------------------------------------*/
11709 +static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
11710 +{
11711 + struct sockaddr *new_addr = addr;
11712 + p80211msg_dot11req_mibset_t dot11req;
11713 + p80211item_unk392_t *mibattr;
11714 + p80211item_pstr6_t *macaddr;
11715 + p80211item_uint32_t *resultcode;
11716 + int result = 0;
11717 +
11718 + DBFENTER;
11719 + /* If we're running, we don't allow MAC address changes */
11720 + if (netif_running(dev)) {
11721 + return -EBUSY;
11722 + }
11723 +
11724 + /* Set up some convenience pointers. */
11725 + mibattr = &dot11req.mibattribute;
11726 + macaddr = (p80211item_pstr6_t*)&mibattr->data;
11727 + resultcode = &dot11req.resultcode;
11728 +
11729 + /* Set up a dot11req_mibset */
11730 + memset(&dot11req, 0, sizeof(p80211msg_dot11req_mibset_t));
11731 + dot11req.msgcode = DIDmsg_dot11req_mibset;
11732 + dot11req.msglen = sizeof(p80211msg_dot11req_mibset_t);
11733 + memcpy(dot11req.devname,
11734 + ((wlandevice_t*)(dev->priv))->name,
11735 + WLAN_DEVNAMELEN_MAX - 1);
11736 +
11737 + /* Set up the mibattribute argument */
11738 + mibattr->did = DIDmsg_dot11req_mibset_mibattribute;
11739 + mibattr->status = P80211ENUM_msgitem_status_data_ok;
11740 + mibattr->len = sizeof(mibattr->data);
11741 +
11742 + macaddr->did = DIDmib_dot11mac_dot11OperationTable_dot11MACAddress;
11743 + macaddr->status = P80211ENUM_msgitem_status_data_ok;
11744 + macaddr->len = sizeof(macaddr->data);
11745 + macaddr->data.len = WLAN_ADDR_LEN;
11746 + memcpy(&macaddr->data.data, new_addr->sa_data, WLAN_ADDR_LEN);
11747 +
11748 + /* Set up the resultcode argument */
11749 + resultcode->did = DIDmsg_dot11req_mibset_resultcode;
11750 + resultcode->status = P80211ENUM_msgitem_status_no_value;
11751 + resultcode->len = sizeof(resultcode->data);
11752 + resultcode->data = 0;
11753 +
11754 + /* now fire the request */
11755 + result = p80211req_dorequest(dev->priv, (u8*)&dot11req);
11756 +
11757 + /* If the request wasn't successful, report an error and don't
11758 + * change the netdev address
11759 + */
11760 + if ( result != 0 || resultcode->data != P80211ENUM_resultcode_success) {
11761 + WLAN_LOG_ERROR(
11762 + "Low-level driver failed dot11req_mibset(dot11MACAddress).\n");
11763 + result = -EADDRNOTAVAIL;
11764 + } else {
11765 + /* everything's ok, change the addr in netdev */
11766 + memcpy(dev->dev_addr, new_addr->sa_data, dev->addr_len);
11767 + }
11768 +
11769 + DBFEXIT;
11770 + return result;
11771 +}
11772 +
11773 +static int wlan_change_mtu(netdevice_t *dev, int new_mtu)
11774 +{
11775 + DBFENTER;
11776 + // 2312 is max 802.11 payload, 20 is overhead, (ether + llc +snap)
11777 + // and another 8 for wep.
11778 + if ( (new_mtu < 68) || (new_mtu > (2312 - 20 - 8)))
11779 + return -EINVAL;
11780 +
11781 + dev->mtu = new_mtu;
11782 +
11783 + DBFEXIT;
11784 +
11785 + return 0;
11786 +}
11787 +
11788 +
11789 +
11790 +/*----------------------------------------------------------------
11791 +* wlan_setup
11792 +*
11793 +* Roughly matches the functionality of ether_setup. Here
11794 +* we set up any members of the wlandevice structure that are common
11795 +* to all devices. Additionally, we allocate a linux 'struct device'
11796 +* and perform the same setup as ether_setup.
11797 +*
11798 +* Note: It's important that the caller have setup the wlandev->name
11799 +* ptr prior to calling this function.
11800 +*
11801 +* Arguments:
11802 +* wlandev ptr to the wlandev structure for the
11803 +* interface.
11804 +* Returns:
11805 +* zero on success, non-zero otherwise.
11806 +* Call Context:
11807 +* Should be process thread. We'll assume it might be
11808 +* interrupt though. When we add support for statically
11809 +* compiled drivers, this function will be called in the
11810 +* context of the kernel startup code.
11811 +----------------------------------------------------------------*/
11812 +int wlan_setup(wlandevice_t *wlandev)
11813 +{
11814 + int result = 0;
11815 + netdevice_t *dev;
11816 +
11817 + DBFENTER;
11818 +
11819 + /* Set up the wlandev */
11820 + wlandev->state = WLAN_DEVICE_CLOSED;
11821 + wlandev->ethconv = WLAN_ETHCONV_8021h;
11822 + wlandev->macmode = WLAN_MACMODE_NONE;
11823 +
11824 + /* Set up the rx queue */
11825 + skb_queue_head_init(&wlandev->nsd_rxq);
11826 + tasklet_init(&wlandev->rx_bh,
11827 + p80211netdev_rx_bh,
11828 + (unsigned long)wlandev);
11829 +
11830 + /* Allocate and initialize the struct device */
11831 + dev = alloc_netdev(0,"wlan%d",ether_setup);
11832 + if ( dev == NULL ) {
11833 + WLAN_LOG_ERROR("Failed to alloc netdev.\n");
11834 + result = 1;
11835 + } else {
11836 + wlandev->netdev = dev;
11837 + dev->priv = wlandev;
11838 + dev->hard_start_xmit = p80211knetdev_hard_start_xmit;
11839 + dev->get_stats = p80211knetdev_get_stats;
11840 +#ifdef HAVE_PRIVATE_IOCTL
11841 + dev->do_ioctl = p80211knetdev_do_ioctl;
11842 +#endif
11843 +#ifdef HAVE_MULTICAST
11844 + dev->set_multicast_list = p80211knetdev_set_multicast_list;
11845 +#endif
11846 + dev->init = p80211knetdev_init;
11847 + dev->open = p80211knetdev_open;
11848 + dev->stop = p80211knetdev_stop;
11849 +
11850 +#if (WIRELESS_EXT < 21)
11851 + dev->get_wireless_stats = p80211wext_get_wireless_stats;
11852 +#endif
11853 + dev->wireless_handlers = &p80211wext_handler_def;
11854 +
11855 + netif_stop_queue(dev);
11856 +#ifdef HAVE_CHANGE_MTU
11857 + dev->change_mtu = wlan_change_mtu;
11858 +#endif
11859 +#ifdef HAVE_SET_MAC_ADDR
11860 + dev->set_mac_address = p80211knetdev_set_mac_address;
11861 +#endif
11862 +#ifdef HAVE_TX_TIMEOUT
11863 + dev->tx_timeout = &p80211knetdev_tx_timeout;
11864 + dev->watchdog_timeo = (wlan_watchdog * HZ) / 1000;
11865 +#endif
11866 + netif_carrier_off(dev);
11867 + }
11868 +
11869 + DBFEXIT;
11870 + return result;
11871 +}
11872 +
11873 +/*----------------------------------------------------------------
11874 +* wlan_unsetup
11875 +*
11876 +* This function is paired with the wlan_setup routine. It should
11877 +* be called after unregister_wlandev. Basically, all it does is
11878 +* free the 'struct device' that's associated with the wlandev.
11879 +* We do it here because the 'struct device' isn't allocated
11880 +* explicitly in the driver code, it's done in wlan_setup. To
11881 +* do the free in the driver might seem like 'magic'.
11882 +*
11883 +* Arguments:
11884 +* wlandev ptr to the wlandev structure for the
11885 +* interface.
11886 +* Returns:
11887 +* zero on success, non-zero otherwise.
11888 +* Call Context:
11889 +* Should be process thread. We'll assume it might be
11890 +* interrupt though. When we add support for statically
11891 +* compiled drivers, this function will be called in the
11892 +* context of the kernel startup code.
11893 +----------------------------------------------------------------*/
11894 +int wlan_unsetup(wlandevice_t *wlandev)
11895 +{
11896 + int result = 0;
11897 +
11898 + DBFENTER;
11899 +
11900 + tasklet_kill(&wlandev->rx_bh);
11901 +
11902 + if (wlandev->netdev == NULL ) {
11903 + WLAN_LOG_ERROR("called without wlandev->netdev set.\n");
11904 + result = 1;
11905 + } else {
11906 + free_netdev(wlandev->netdev);
11907 + wlandev->netdev = NULL;
11908 + }
11909 +
11910 + DBFEXIT;
11911 + return 0;
11912 +}
11913 +
11914 +
11915 +
11916 +/*----------------------------------------------------------------
11917 +* register_wlandev
11918 +*
11919 +* Roughly matches the functionality of register_netdev. This function
11920 +* is called after the driver has successfully probed and set up the
11921 +* resources for the device. It's now ready to become a named device
11922 +* in the Linux system.
11923 +*
11924 +* First we allocate a name for the device (if not already set), then
11925 +* we call the Linux function register_netdevice.
11926 +*
11927 +* Arguments:
11928 +* wlandev ptr to the wlandev structure for the
11929 +* interface.
11930 +* Returns:
11931 +* zero on success, non-zero otherwise.
11932 +* Call Context:
11933 +* Can be either interrupt or not.
11934 +----------------------------------------------------------------*/
11935 +int register_wlandev(wlandevice_t *wlandev)
11936 +{
11937 + int i = 0;
11938 +
11939 + DBFENTER;
11940 +
11941 + i = register_netdev(wlandev->netdev);
11942 + if (i)
11943 + return i;
11944 +
11945 + DBFEXIT;
11946 + return 0;
11947 +}
11948 +
11949 +
11950 +/*----------------------------------------------------------------
11951 +* unregister_wlandev
11952 +*
11953 +* Roughly matches the functionality of unregister_netdev. This
11954 +* function is called to remove a named device from the system.
11955 +*
11956 +* First we tell linux that the device should no longer exist.
11957 +* Then we remove it from the list of known wlan devices.
11958 +*
11959 +* Arguments:
11960 +* wlandev ptr to the wlandev structure for the
11961 +* interface.
11962 +* Returns:
11963 +* zero on success, non-zero otherwise.
11964 +* Call Context:
11965 +* Can be either interrupt or not.
11966 +----------------------------------------------------------------*/
11967 +int unregister_wlandev(wlandevice_t *wlandev)
11968 +{
11969 + struct sk_buff *skb;
11970 +
11971 + DBFENTER;
11972 +
11973 + unregister_netdev(wlandev->netdev);
11974 +
11975 + /* Now to clean out the rx queue */
11976 + while ( (skb = skb_dequeue(&wlandev->nsd_rxq)) ) {
11977 + dev_kfree_skb(skb);
11978 + }
11979 +
11980 + DBFEXIT;
11981 + return 0;
11982 +}
11983 +
11984 +
11985 +/*----------------------------------------------------------------
11986 +* p80211netdev_hwremoved
11987 +*
11988 +* Hardware removed notification. This function should be called
11989 +* immediately after an MSD has detected that the underlying hardware
11990 +* has been yanked out from under us. The primary things we need
11991 +* to do are:
11992 +* - Mark the wlandev
11993 +* - Prevent any further traffic from the knetdev i/f
11994 +* - Prevent any further requests from mgmt i/f
11995 +* - If there are any waitq'd mgmt requests or mgmt-frame exchanges,
11996 +* shut them down.
11997 +* - Call the MSD hwremoved function.
11998 +*
11999 +* The remainder of the cleanup will be handled by unregister().
12000 +* Our primary goal here is to prevent as much tickling of the MSD
12001 +* as possible since the MSD is already in a 'wounded' state.
12002 +*
12003 +* TODO: As new features are added, this function should be
12004 +* updated.
12005 +*
12006 +* Arguments:
12007 +* wlandev WLAN network device structure
12008 +* Returns:
12009 +* nothing
12010 +* Side effects:
12011 +*
12012 +* Call context:
12013 +* Usually interrupt.
12014 +----------------------------------------------------------------*/
12015 +void p80211netdev_hwremoved(wlandevice_t *wlandev)
12016 +{
12017 + DBFENTER;
12018 + wlandev->hwremoved = 1;
12019 + if ( wlandev->state == WLAN_DEVICE_OPEN) {
12020 + netif_stop_queue(wlandev->netdev);
12021 + }
12022 +
12023 + netif_device_detach(wlandev->netdev);
12024 +
12025 + DBFEXIT;
12026 +}
12027 +
12028 +
12029 +/*----------------------------------------------------------------
12030 +* p80211_rx_typedrop
12031 +*
12032 +* Classifies the frame, increments the appropriate counter, and
12033 +* returns 0|1|2 indicating whether the driver should handle, ignore, or
12034 +* drop the frame
12035 +*
12036 +* Arguments:
12037 +* wlandev wlan device structure
12038 +* fc frame control field
12039 +*
12040 +* Returns:
12041 +* zero if the frame should be handled by the driver,
12042 +* one if the frame should be ignored
12043 +* anything else means we drop it.
12044 +*
12045 +* Side effects:
12046 +*
12047 +* Call context:
12048 +* interrupt
12049 +----------------------------------------------------------------*/
12050 +static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc)
12051 +{
12052 + u16 ftype;
12053 + u16 fstype;
12054 + int drop = 0;
12055 + /* Classify frame, increment counter */
12056 + ftype = WLAN_GET_FC_FTYPE(fc);
12057 + fstype = WLAN_GET_FC_FSTYPE(fc);
12058 +#if 0
12059 + WLAN_LOG_DEBUG(4,
12060 + "rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype);
12061 +#endif
12062 + switch ( ftype ) {
12063 + case WLAN_FTYPE_MGMT:
12064 + if ((wlandev->netdev->flags & IFF_PROMISC) ||
12065 + (wlandev->netdev->flags & IFF_ALLMULTI)) {
12066 + drop = 1;
12067 + break;
12068 + }
12069 + WLAN_LOG_DEBUG(3, "rx'd mgmt:\n");
12070 + wlandev->rx.mgmt++;
12071 + switch( fstype ) {
12072 + case WLAN_FSTYPE_ASSOCREQ:
12073 + /* printk("assocreq"); */
12074 + wlandev->rx.assocreq++;
12075 + break;
12076 + case WLAN_FSTYPE_ASSOCRESP:
12077 + /* printk("assocresp"); */
12078 + wlandev->rx.assocresp++;
12079 + break;
12080 + case WLAN_FSTYPE_REASSOCREQ:
12081 + /* printk("reassocreq"); */
12082 + wlandev->rx.reassocreq++;
12083 + break;
12084 + case WLAN_FSTYPE_REASSOCRESP:
12085 + /* printk("reassocresp"); */
12086 + wlandev->rx.reassocresp++;
12087 + break;
12088 + case WLAN_FSTYPE_PROBEREQ:
12089 + /* printk("probereq"); */
12090 + wlandev->rx.probereq++;
12091 + break;
12092 + case WLAN_FSTYPE_PROBERESP:
12093 + /* printk("proberesp"); */
12094 + wlandev->rx.proberesp++;
12095 + break;
12096 + case WLAN_FSTYPE_BEACON:
12097 + /* printk("beacon"); */
12098 + wlandev->rx.beacon++;
12099 + break;
12100 + case WLAN_FSTYPE_ATIM:
12101 + /* printk("atim"); */
12102 + wlandev->rx.atim++;
12103 + break;
12104 + case WLAN_FSTYPE_DISASSOC:
12105 + /* printk("disassoc"); */
12106 + wlandev->rx.disassoc++;
12107 + break;
12108 + case WLAN_FSTYPE_AUTHEN:
12109 + /* printk("authen"); */
12110 + wlandev->rx.authen++;
12111 + break;
12112 + case WLAN_FSTYPE_DEAUTHEN:
12113 + /* printk("deauthen"); */
12114 + wlandev->rx.deauthen++;
12115 + break;
12116 + default:
12117 + /* printk("unknown"); */
12118 + wlandev->rx.mgmt_unknown++;
12119 + break;
12120 + }
12121 + /* printk("\n"); */
12122 + drop = 2;
12123 + break;
12124 +
12125 + case WLAN_FTYPE_CTL:
12126 + if ((wlandev->netdev->flags & IFF_PROMISC) ||
12127 + (wlandev->netdev->flags & IFF_ALLMULTI)) {
12128 + drop = 1;
12129 + break;
12130 + }
12131 + WLAN_LOG_DEBUG(3, "rx'd ctl:\n");
12132 + wlandev->rx.ctl++;
12133 + switch( fstype ) {
12134 + case WLAN_FSTYPE_PSPOLL:
12135 + /* printk("pspoll"); */
12136 + wlandev->rx.pspoll++;
12137 + break;
12138 + case WLAN_FSTYPE_RTS:
12139 + /* printk("rts"); */
12140 + wlandev->rx.rts++;
12141 + break;
12142 + case WLAN_FSTYPE_CTS:
12143 + /* printk("cts"); */
12144 + wlandev->rx.cts++;
12145 + break;
12146 + case WLAN_FSTYPE_ACK:
12147 + /* printk("ack"); */
12148 + wlandev->rx.ack++;
12149 + break;
12150 + case WLAN_FSTYPE_CFEND:
12151 + /* printk("cfend"); */
12152 + wlandev->rx.cfend++;
12153 + break;
12154 + case WLAN_FSTYPE_CFENDCFACK:
12155 + /* printk("cfendcfack"); */
12156 + wlandev->rx.cfendcfack++;
12157 + break;
12158 + default:
12159 + /* printk("unknown"); */
12160 + wlandev->rx.ctl_unknown++;
12161 + break;
12162 + }
12163 + /* printk("\n"); */
12164 + drop = 2;
12165 + break;
12166 +
12167 + case WLAN_FTYPE_DATA:
12168 + wlandev->rx.data++;
12169 + switch( fstype ) {
12170 + case WLAN_FSTYPE_DATAONLY:
12171 + wlandev->rx.dataonly++;
12172 + break;
12173 + case WLAN_FSTYPE_DATA_CFACK:
12174 + wlandev->rx.data_cfack++;
12175 + break;
12176 + case WLAN_FSTYPE_DATA_CFPOLL:
12177 + wlandev->rx.data_cfpoll++;
12178 + break;
12179 + case WLAN_FSTYPE_DATA_CFACK_CFPOLL:
12180 + wlandev->rx.data__cfack_cfpoll++;
12181 + break;
12182 + case WLAN_FSTYPE_NULL:
12183 + WLAN_LOG_DEBUG(3, "rx'd data:null\n");
12184 + wlandev->rx.null++;
12185 + break;
12186 + case WLAN_FSTYPE_CFACK:
12187 + WLAN_LOG_DEBUG(3, "rx'd data:cfack\n");
12188 + wlandev->rx.cfack++;
12189 + break;
12190 + case WLAN_FSTYPE_CFPOLL:
12191 + WLAN_LOG_DEBUG(3, "rx'd data:cfpoll\n");
12192 + wlandev->rx.cfpoll++;
12193 + break;
12194 + case WLAN_FSTYPE_CFACK_CFPOLL:
12195 + WLAN_LOG_DEBUG(3, "rx'd data:cfack_cfpoll\n");
12196 + wlandev->rx.cfack_cfpoll++;
12197 + break;
12198 + default:
12199 + /* printk("unknown"); */
12200 + wlandev->rx.data_unknown++;
12201 + break;
12202 + }
12203 +
12204 + break;
12205 + }
12206 + return drop;
12207 +}
12208 +
12209 +static void p80211knetdev_tx_timeout( netdevice_t *netdev)
12210 +{
12211 + wlandevice_t *wlandev = (wlandevice_t*)netdev->priv;
12212 + DBFENTER;
12213 +
12214 + if (wlandev->tx_timeout) {
12215 + wlandev->tx_timeout(wlandev);
12216 + } else {
12217 + WLAN_LOG_WARNING("Implement tx_timeout for %s\n",
12218 + wlandev->nsdname);
12219 + netif_wake_queue(wlandev->netdev);
12220 + }
12221 +
12222 + DBFEXIT;
12223 +}
12224 --- /dev/null
12225 +++ b/drivers/staging/wlan-ng/p80211netdev.h
12226 @@ -0,0 +1,254 @@
12227 +/* p80211netdev.h
12228 +*
12229 +* WLAN net device structure and functions
12230 +*
12231 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
12232 +* --------------------------------------------------------------------
12233 +*
12234 +* linux-wlan
12235 +*
12236 +* The contents of this file are subject to the Mozilla Public
12237 +* License Version 1.1 (the "License"); you may not use this file
12238 +* except in compliance with the License. You may obtain a copy of
12239 +* the License at http://www.mozilla.org/MPL/
12240 +*
12241 +* Software distributed under the License is distributed on an "AS
12242 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
12243 +* implied. See the License for the specific language governing
12244 +* rights and limitations under the License.
12245 +*
12246 +* Alternatively, the contents of this file may be used under the
12247 +* terms of the GNU Public License version 2 (the "GPL"), in which
12248 +* case the provisions of the GPL are applicable instead of the
12249 +* above. If you wish to allow the use of your version of this file
12250 +* only under the terms of the GPL and not to allow others to use
12251 +* your version of this file under the MPL, indicate your decision
12252 +* by deleting the provisions above and replace them with the notice
12253 +* and other provisions required by the GPL. If you do not delete
12254 +* the provisions above, a recipient may use your version of this
12255 +* file under either the MPL or the GPL.
12256 +*
12257 +* --------------------------------------------------------------------
12258 +*
12259 +* Inquiries regarding the linux-wlan Open Source project can be
12260 +* made directly to:
12261 +*
12262 +* AbsoluteValue Systems Inc.
12263 +* info@linux-wlan.com
12264 +* http://www.linux-wlan.com
12265 +*
12266 +* --------------------------------------------------------------------
12267 +*
12268 +* Portions of the development of this software were funded by
12269 +* Intersil Corporation as part of PRISM(R) chipset product development.
12270 +*
12271 +* --------------------------------------------------------------------
12272 +*
12273 +* This file declares the structure type that represents each wlan
12274 +* interface.
12275 +*
12276 +* --------------------------------------------------------------------
12277 +*/
12278 +
12279 +#ifndef _LINUX_P80211NETDEV_H
12280 +#define _LINUX_P80211NETDEV_H
12281 +
12282 +#include <linux/interrupt.h>
12283 +#include <linux/wireless.h>
12284 +
12285 +/*================================================================*/
12286 +/* Constants */
12287 +
12288 +#define WLAN_DEVICE_CLOSED 0
12289 +#define WLAN_DEVICE_OPEN 1
12290 +
12291 +#define WLAN_MACMODE_NONE 0
12292 +#define WLAN_MACMODE_IBSS_STA 1
12293 +#define WLAN_MACMODE_ESS_STA 2
12294 +#define WLAN_MACMODE_ESS_AP 3
12295 +
12296 +/* MSD States */
12297 +#define WLAN_MSD_START -1
12298 +#define WLAN_MSD_DRIVERLOADED 0
12299 +#define WLAN_MSD_HWPRESENT_PENDING 1
12300 +#define WLAN_MSD_HWFAIL 2
12301 +#define WLAN_MSD_HWPRESENT 3
12302 +#define WLAN_MSD_FWLOAD_PENDING 4
12303 +#define WLAN_MSD_FWLOAD 5
12304 +#define WLAN_MSD_RUNNING_PENDING 6
12305 +#define WLAN_MSD_RUNNING 7
12306 +
12307 +#ifndef ETH_P_ECONET
12308 +#define ETH_P_ECONET 0x0018 /* needed for 2.2.x kernels */
12309 +#endif
12310 +
12311 +#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
12312 +
12313 +#ifndef ARPHRD_IEEE80211
12314 +#define ARPHRD_IEEE80211 801 /* kernel 2.4.6 */
12315 +#endif
12316 +
12317 +#ifndef ARPHRD_IEEE80211_PRISM /* kernel 2.4.18 */
12318 +#define ARPHRD_IEEE80211_PRISM 802
12319 +#endif
12320 +
12321 +/*--- NSD Capabilities Flags ------------------------------*/
12322 +#define P80211_NSDCAP_HARDWAREWEP 0x01 /* hardware wep engine */
12323 +#define P80211_NSDCAP_TIEDWEP 0x02 /* can't decouple en/de */
12324 +#define P80211_NSDCAP_NOHOSTWEP 0x04 /* must use hardware wep */
12325 +#define P80211_NSDCAP_PBCC 0x08 /* hardware supports PBCC */
12326 +#define P80211_NSDCAP_SHORT_PREAMBLE 0x10 /* hardware supports */
12327 +#define P80211_NSDCAP_AGILITY 0x20 /* hardware supports */
12328 +#define P80211_NSDCAP_AP_RETRANSMIT 0x40 /* nsd handles retransmits */
12329 +#define P80211_NSDCAP_HWFRAGMENT 0x80 /* nsd handles frag/defrag */
12330 +#define P80211_NSDCAP_AUTOJOIN 0x100 /* nsd does autojoin */
12331 +#define P80211_NSDCAP_NOSCAN 0x200 /* nsd can scan */
12332 +
12333 +/*================================================================*/
12334 +/* Macros */
12335 +
12336 +/*================================================================*/
12337 +/* Types */
12338 +
12339 +/* Received frame statistics */
12340 +typedef struct p80211_frmrx_t
12341 +{
12342 + u32 mgmt;
12343 + u32 assocreq;
12344 + u32 assocresp;
12345 + u32 reassocreq;
12346 + u32 reassocresp;
12347 + u32 probereq;
12348 + u32 proberesp;
12349 + u32 beacon;
12350 + u32 atim;
12351 + u32 disassoc;
12352 + u32 authen;
12353 + u32 deauthen;
12354 + u32 mgmt_unknown;
12355 + u32 ctl;
12356 + u32 pspoll;
12357 + u32 rts;
12358 + u32 cts;
12359 + u32 ack;
12360 + u32 cfend;
12361 + u32 cfendcfack;
12362 + u32 ctl_unknown;
12363 + u32 data;
12364 + u32 dataonly;
12365 + u32 data_cfack;
12366 + u32 data_cfpoll;
12367 + u32 data__cfack_cfpoll;
12368 + u32 null;
12369 + u32 cfack;
12370 + u32 cfpoll;
12371 + u32 cfack_cfpoll;
12372 + u32 data_unknown;
12373 + u32 decrypt;
12374 + u32 decrypt_err;
12375 +} p80211_frmrx_t;
12376 +
12377 +/* called by /proc/net/wireless */
12378 +struct iw_statistics* p80211wext_get_wireless_stats(netdevice_t *dev);
12379 +/* wireless extensions' ioctls */
12380 +int p80211wext_support_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd);
12381 +extern struct iw_handler_def p80211wext_handler_def;
12382 +int p80211wext_event_associated(struct wlandevice *wlandev, int assoc);
12383 +
12384 +/* WEP stuff */
12385 +#define NUM_WEPKEYS 4
12386 +#define MAX_KEYLEN 32
12387 +
12388 +#define HOSTWEP_DEFAULTKEY_MASK (BIT1|BIT0)
12389 +#define HOSTWEP_DECRYPT BIT4
12390 +#define HOSTWEP_ENCRYPT BIT5
12391 +#define HOSTWEP_PRIVACYINVOKED BIT6
12392 +#define HOSTWEP_EXCLUDEUNENCRYPTED BIT7
12393 +
12394 +extern int wlan_watchdog;
12395 +extern int wlan_wext_write;
12396 +
12397 +/* WLAN device type */
12398 +typedef struct wlandevice
12399 +{
12400 + struct wlandevice *next; /* link for list of devices */
12401 + void *priv; /* private data for MSD */
12402 +
12403 + /* Subsystem State */
12404 + char name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev()*/
12405 + char *nsdname;
12406 +
12407 + u32 state; /* Device I/F state (open/closed) */
12408 + u32 msdstate; /* state of underlying driver */
12409 + u32 hwremoved; /* Has the hw been yanked out? */
12410 +
12411 + /* Hardware config */
12412 + unsigned int irq;
12413 + unsigned int iobase;
12414 + unsigned int membase;
12415 + u32 nsdcaps; /* NSD Capabilities flags */
12416 +
12417 + /* Config vars */
12418 + unsigned int ethconv;
12419 +
12420 + /* device methods (init by MSD, used by p80211 */
12421 + int (*open)(struct wlandevice *wlandev);
12422 + int (*close)(struct wlandevice *wlandev);
12423 + void (*reset)(struct wlandevice *wlandev );
12424 + int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
12425 + int (*mlmerequest)(struct wlandevice *wlandev, p80211msg_t *msg);
12426 + int (*set_multicast_list)(struct wlandevice *wlandev,
12427 + netdevice_t *dev);
12428 + void (*tx_timeout)(struct wlandevice *wlandev);
12429 +
12430 + /* 802.11 State */
12431 + u8 bssid[WLAN_BSSID_LEN];
12432 + p80211pstr32_t ssid;
12433 + u32 macmode;
12434 + int linkstatus;
12435 +
12436 + /* WEP State */
12437 + u8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
12438 + u8 wep_keylens[NUM_WEPKEYS];
12439 + int hostwep;
12440 +
12441 + /* Request/Confirm i/f state (used by p80211) */
12442 + unsigned long request_pending; /* flag, access atomically */
12443 +
12444 + /* netlink socket */
12445 + /* queue for indications waiting for cmd completion */
12446 + /* Linux netdevice and support */
12447 + netdevice_t *netdev; /* ptr to linux netdevice */
12448 + struct net_device_stats linux_stats;
12449 +
12450 + /* Rx bottom half */
12451 + struct tasklet_struct rx_bh;
12452 +
12453 + struct sk_buff_head nsd_rxq;
12454 +
12455 + /* 802.11 device statistics */
12456 + struct p80211_frmrx_t rx;
12457 +
12458 + struct iw_statistics wstats;
12459 +
12460 + /* jkriegl: iwspy fields */
12461 + u8 spy_number;
12462 + char spy_address[IW_MAX_SPY][ETH_ALEN];
12463 + struct iw_quality spy_stat[IW_MAX_SPY];
12464 +} wlandevice_t;
12465 +
12466 +/* WEP stuff */
12467 +int wep_change_key(wlandevice_t *wlandev, int keynum, u8* key, int keylen);
12468 +int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *iv, u8 *icv);
12469 +int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8 *iv, u8 *icv);
12470 +
12471 +void p80211netdev_startup(void);
12472 +void p80211netdev_shutdown(void);
12473 +int wlan_setup(wlandevice_t *wlandev);
12474 +int wlan_unsetup(wlandevice_t *wlandev);
12475 +int register_wlandev(wlandevice_t *wlandev);
12476 +int unregister_wlandev(wlandevice_t *wlandev);
12477 +void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
12478 +void p80211netdev_hwremoved(wlandevice_t *wlandev);
12479 +
12480 +#endif
12481 --- /dev/null
12482 +++ b/drivers/staging/wlan-ng/p80211req.c
12483 @@ -0,0 +1,300 @@
12484 +/* src/p80211/p80211req.c
12485 +*
12486 +* Request/Indication/MacMgmt interface handling functions
12487 +*
12488 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
12489 +* --------------------------------------------------------------------
12490 +*
12491 +* linux-wlan
12492 +*
12493 +* The contents of this file are subject to the Mozilla Public
12494 +* License Version 1.1 (the "License"); you may not use this file
12495 +* except in compliance with the License. You may obtain a copy of
12496 +* the License at http://www.mozilla.org/MPL/
12497 +*
12498 +* Software distributed under the License is distributed on an "AS
12499 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
12500 +* implied. See the License for the specific language governing
12501 +* rights and limitations under the License.
12502 +*
12503 +* Alternatively, the contents of this file may be used under the
12504 +* terms of the GNU Public License version 2 (the "GPL"), in which
12505 +* case the provisions of the GPL are applicable instead of the
12506 +* above. If you wish to allow the use of your version of this file
12507 +* only under the terms of the GPL and not to allow others to use
12508 +* your version of this file under the MPL, indicate your decision
12509 +* by deleting the provisions above and replace them with the notice
12510 +* and other provisions required by the GPL. If you do not delete
12511 +* the provisions above, a recipient may use your version of this
12512 +* file under either the MPL or the GPL.
12513 +*
12514 +* --------------------------------------------------------------------
12515 +*
12516 +* Inquiries regarding the linux-wlan Open Source project can be
12517 +* made directly to:
12518 +*
12519 +* AbsoluteValue Systems Inc.
12520 +* info@linux-wlan.com
12521 +* http://www.linux-wlan.com
12522 +*
12523 +* --------------------------------------------------------------------
12524 +*
12525 +* Portions of the development of this software were funded by
12526 +* Intersil Corporation as part of PRISM(R) chipset product development.
12527 +*
12528 +* --------------------------------------------------------------------
12529 +*
12530 +* This file contains the functions, types, and macros to support the
12531 +* MLME request interface that's implemented via the device ioctls.
12532 +*
12533 +* --------------------------------------------------------------------
12534 +*/
12535 +
12536 +/*================================================================*/
12537 +/* System Includes */
12538 +
12539 +
12540 +
12541 +#include <linux/module.h>
12542 +#include <linux/kernel.h>
12543 +#include <linux/sched.h>
12544 +#include <linux/types.h>
12545 +#include <linux/skbuff.h>
12546 +#include <linux/slab.h>
12547 +#include <linux/wireless.h>
12548 +#include <linux/netdevice.h>
12549 +#include <linux/etherdevice.h>
12550 +#include <net/sock.h>
12551 +#include <linux/netlink.h>
12552 +
12553 +#include "wlan_compat.h"
12554 +
12555 +/*================================================================*/
12556 +/* Project Includes */
12557 +
12558 +#include "p80211types.h"
12559 +#include "p80211hdr.h"
12560 +#include "p80211mgmt.h"
12561 +#include "p80211conv.h"
12562 +#include "p80211msg.h"
12563 +#include "p80211netdev.h"
12564 +#include "p80211ioctl.h"
12565 +#include "p80211metadef.h"
12566 +#include "p80211metastruct.h"
12567 +#include "p80211req.h"
12568 +
12569 +/*================================================================*/
12570 +/* Local Constants */
12571 +
12572 +/* Maximum amount of time we'll wait for a request to complete */
12573 +#define P80211REQ_MAXTIME 3*HZ /* 3 seconds */
12574 +
12575 +/*================================================================*/
12576 +/* Local Macros */
12577 +
12578 +/*================================================================*/
12579 +/* Local Types */
12580 +
12581 +/*================================================================*/
12582 +/* Local Static Definitions */
12583 +
12584 +/*================================================================*/
12585 +/* Local Function Declarations */
12586 +
12587 +static void p80211req_handlemsg( wlandevice_t *wlandev, p80211msg_t *msg);
12588 +static int p80211req_mibset_mibget(wlandevice_t *wlandev, p80211msg_dot11req_mibget_t *mib_msg, int isget);
12589 +
12590 +/*================================================================*/
12591 +/* Function Definitions */
12592 +
12593 +
12594 +/*----------------------------------------------------------------
12595 +* p80211req_dorequest
12596 +*
12597 +* Handles an MLME reqest/confirm message.
12598 +*
12599 +* Arguments:
12600 +* wlandev WLAN device struct
12601 +* msgbuf Buffer containing a request message
12602 +*
12603 +* Returns:
12604 +* 0 on success, an errno otherwise
12605 +*
12606 +* Call context:
12607 +* Potentially blocks the caller, so it's a good idea to
12608 +* not call this function from an interrupt context.
12609 +----------------------------------------------------------------*/
12610 +int p80211req_dorequest( wlandevice_t *wlandev, u8 *msgbuf)
12611 +{
12612 + int result = 0;
12613 + p80211msg_t *msg = (p80211msg_t*)msgbuf;
12614 +
12615 + DBFENTER;
12616 +
12617 + /* Check to make sure the MSD is running */
12618 + if (
12619 + !((wlandev->msdstate == WLAN_MSD_HWPRESENT &&
12620 + msg->msgcode == DIDmsg_lnxreq_ifstate) ||
12621 + wlandev->msdstate == WLAN_MSD_RUNNING ||
12622 + wlandev->msdstate == WLAN_MSD_FWLOAD) ) {
12623 + return -ENODEV;
12624 + }
12625 +
12626 + /* Check Permissions */
12627 + if (!capable(CAP_NET_ADMIN) &&
12628 + (msg->msgcode != DIDmsg_dot11req_mibget)) {
12629 + WLAN_LOG_ERROR("%s: only dot11req_mibget allowed for non-root.\n", wlandev->name);
12630 + return -EPERM;
12631 + }
12632 +
12633 + /* Check for busy status */
12634 + if ( test_and_set_bit(1, &(wlandev->request_pending))) {
12635 + return -EBUSY;
12636 + }
12637 +
12638 + /* Allow p80211 to look at msg and handle if desired. */
12639 + /* So far, all p80211 msgs are immediate, no waitq/timer necessary */
12640 + /* This may change. */
12641 + p80211req_handlemsg(wlandev, msg);
12642 +
12643 + /* Pass it down to wlandev via wlandev->mlmerequest */
12644 + if ( wlandev->mlmerequest != NULL )
12645 + wlandev->mlmerequest(wlandev, msg);
12646 +
12647 + clear_bit( 1, &(wlandev->request_pending));
12648 + DBFEXIT;
12649 + return result; /* if result==0, msg->status still may contain an err */
12650 +}
12651 +
12652 +/*----------------------------------------------------------------
12653 +* p80211req_handlemsg
12654 +*
12655 +* p80211 message handler. Primarily looks for messages that
12656 +* belong to p80211 and then dispatches the appropriate response.
12657 +* TODO: we don't do anything yet. Once the linuxMIB is better
12658 +* defined we'll need a get/set handler.
12659 +*
12660 +* Arguments:
12661 +* wlandev WLAN device struct
12662 +* msg message structure
12663 +*
12664 +* Returns:
12665 +* nothing (any results are set in the status field of the msg)
12666 +*
12667 +* Call context:
12668 +* Process thread
12669 +----------------------------------------------------------------*/
12670 +static void p80211req_handlemsg( wlandevice_t *wlandev, p80211msg_t *msg)
12671 +{
12672 + DBFENTER;
12673 +
12674 + switch (msg->msgcode) {
12675 +
12676 + case DIDmsg_lnxreq_hostwep: {
12677 + p80211msg_lnxreq_hostwep_t *req = (p80211msg_lnxreq_hostwep_t*) msg;
12678 + wlandev->hostwep &= ~(HOSTWEP_DECRYPT|HOSTWEP_ENCRYPT);
12679 + if (req->decrypt.data == P80211ENUM_truth_true)
12680 + wlandev->hostwep |= HOSTWEP_DECRYPT;
12681 + if (req->encrypt.data == P80211ENUM_truth_true)
12682 + wlandev->hostwep |= HOSTWEP_ENCRYPT;
12683 +
12684 + break;
12685 + }
12686 + case DIDmsg_dot11req_mibget:
12687 + case DIDmsg_dot11req_mibset: {
12688 + int isget = (msg->msgcode == DIDmsg_dot11req_mibget);
12689 + p80211msg_dot11req_mibget_t *mib_msg = (p80211msg_dot11req_mibget_t *) msg;
12690 + p80211req_mibset_mibget (wlandev, mib_msg, isget);
12691 + }
12692 + default:
12693 + // XXX do nothing!
12694 + ;
12695 + } /* switch msg->msgcode */
12696 +
12697 + DBFEXIT;
12698 +
12699 + return;
12700 +}
12701 +
12702 +static int p80211req_mibset_mibget(wlandevice_t *wlandev,
12703 + p80211msg_dot11req_mibget_t *mib_msg,
12704 + int isget)
12705 +{
12706 + p80211itemd_t *mibitem = (p80211itemd_t *) mib_msg->mibattribute.data;
12707 + p80211pstrd_t *pstr = (p80211pstrd_t*) mibitem->data;
12708 + u8 *key = mibitem->data + sizeof(p80211pstrd_t);
12709 +
12710 + DBFENTER;
12711 +
12712 + switch (mibitem->did) {
12713 + case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0: {
12714 + if (!isget)
12715 + wep_change_key(wlandev, 0, key, pstr->len);
12716 + break;
12717 + }
12718 + case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1: {
12719 + if (!isget)
12720 + wep_change_key(wlandev, 1, key, pstr->len);
12721 + break;
12722 + }
12723 + case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2: {
12724 + if (!isget)
12725 + wep_change_key(wlandev, 2, key, pstr->len);
12726 + break;
12727 + }
12728 + case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3: {
12729 + if (!isget)
12730 + wep_change_key(wlandev, 3, key, pstr->len);
12731 + break;
12732 + }
12733 + case DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID: {
12734 + u32 *data = (u32 *) mibitem->data;
12735 +
12736 + if (isget) {
12737 + *data = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
12738 + } else {
12739 + wlandev->hostwep &= ~(HOSTWEP_DEFAULTKEY_MASK);
12740 +
12741 + wlandev->hostwep |= (*data & HOSTWEP_DEFAULTKEY_MASK);
12742 + }
12743 + break;
12744 + }
12745 + case DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked: {
12746 + u32 *data = (u32 *) mibitem->data;
12747 +
12748 + if (isget) {
12749 + if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
12750 + *data = P80211ENUM_truth_true;
12751 + else
12752 + *data = P80211ENUM_truth_false;
12753 + } else {
12754 + wlandev->hostwep &= ~(HOSTWEP_PRIVACYINVOKED);
12755 + if (*data == P80211ENUM_truth_true)
12756 + wlandev->hostwep |= HOSTWEP_PRIVACYINVOKED;
12757 + }
12758 + break;
12759 + }
12760 + case DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted: {
12761 + u32 *data = (u32 *) mibitem->data;
12762 +
12763 + if (isget) {
12764 + if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED)
12765 + *data = P80211ENUM_truth_true;
12766 + else
12767 + *data = P80211ENUM_truth_false;
12768 + } else {
12769 + wlandev->hostwep &= ~(HOSTWEP_EXCLUDEUNENCRYPTED);
12770 + if (*data == P80211ENUM_truth_true)
12771 + wlandev->hostwep |= HOSTWEP_EXCLUDEUNENCRYPTED;
12772 + }
12773 + break;
12774 + }
12775 + default:
12776 + // XXXX do nothing!
12777 + ;
12778 + }
12779 +
12780 + DBFEXIT;
12781 + return 0;
12782 +}
12783 +
12784 --- /dev/null
12785 +++ b/drivers/staging/wlan-ng/p80211req.h
12786 @@ -0,0 +1,68 @@
12787 +/* p80211req.h
12788 +*
12789 +* Request handling functions
12790 +*
12791 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
12792 +* --------------------------------------------------------------------
12793 +*
12794 +* linux-wlan
12795 +*
12796 +* The contents of this file are subject to the Mozilla Public
12797 +* License Version 1.1 (the "License"); you may not use this file
12798 +* except in compliance with the License. You may obtain a copy of
12799 +* the License at http://www.mozilla.org/MPL/
12800 +*
12801 +* Software distributed under the License is distributed on an "AS
12802 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
12803 +* implied. See the License for the specific language governing
12804 +* rights and limitations under the License.
12805 +*
12806 +* Alternatively, the contents of this file may be used under the
12807 +* terms of the GNU Public License version 2 (the "GPL"), in which
12808 +* case the provisions of the GPL are applicable instead of the
12809 +* above. If you wish to allow the use of your version of this file
12810 +* only under the terms of the GPL and not to allow others to use
12811 +* your version of this file under the MPL, indicate your decision
12812 +* by deleting the provisions above and replace them with the notice
12813 +* and other provisions required by the GPL. If you do not delete
12814 +* the provisions above, a recipient may use your version of this
12815 +* file under either the MPL or the GPL.
12816 +*
12817 +* --------------------------------------------------------------------
12818 +*
12819 +* Inquiries regarding the linux-wlan Open Source project can be
12820 +* made directly to:
12821 +*
12822 +* AbsoluteValue Systems Inc.
12823 +* info@linux-wlan.com
12824 +* http://www.linux-wlan.com
12825 +*
12826 +* --------------------------------------------------------------------
12827 +*
12828 +* Portions of the development of this software were funded by
12829 +* Intersil Corporation as part of PRISM(R) chipset product development.
12830 +*
12831 +* --------------------------------------------------------------------
12832 +*/
12833 +
12834 +#ifndef _LINUX_P80211REQ_H
12835 +#define _LINUX_P80211REQ_H
12836 +
12837 +/*================================================================*/
12838 +/* Constants */
12839 +
12840 +/*================================================================*/
12841 +/* Macros */
12842 +
12843 +/*================================================================*/
12844 +/* Types */
12845 +
12846 +/*================================================================*/
12847 +/* Externs */
12848 +
12849 +/*================================================================*/
12850 +/* Function Declarations */
12851 +
12852 +int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf);
12853 +
12854 +#endif
12855 --- /dev/null
12856 +++ b/drivers/staging/wlan-ng/p80211types.h
12857 @@ -0,0 +1,675 @@
12858 +/* p80211types.h
12859 +*
12860 +* Macros, constants, types, and funcs for p80211 data types
12861 +*
12862 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
12863 +* --------------------------------------------------------------------
12864 +*
12865 +* linux-wlan
12866 +*
12867 +* The contents of this file are subject to the Mozilla Public
12868 +* License Version 1.1 (the "License"); you may not use this file
12869 +* except in compliance with the License. You may obtain a copy of
12870 +* the License at http://www.mozilla.org/MPL/
12871 +*
12872 +* Software distributed under the License is distributed on an "AS
12873 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
12874 +* implied. See the License for the specific language governing
12875 +* rights and limitations under the License.
12876 +*
12877 +* Alternatively, the contents of this file may be used under the
12878 +* terms of the GNU Public License version 2 (the "GPL"), in which
12879 +* case the provisions of the GPL are applicable instead of the
12880 +* above. If you wish to allow the use of your version of this file
12881 +* only under the terms of the GPL and not to allow others to use
12882 +* your version of this file under the MPL, indicate your decision
12883 +* by deleting the provisions above and replace them with the notice
12884 +* and other provisions required by the GPL. If you do not delete
12885 +* the provisions above, a recipient may use your version of this
12886 +* file under either the MPL or the GPL.
12887 +*
12888 +* --------------------------------------------------------------------
12889 +*
12890 +* Inquiries regarding the linux-wlan Open Source project can be
12891 +* made directly to:
12892 +*
12893 +* AbsoluteValue Systems Inc.
12894 +* info@linux-wlan.com
12895 +* http://www.linux-wlan.com
12896 +*
12897 +* --------------------------------------------------------------------
12898 +*
12899 +* Portions of the development of this software were funded by
12900 +* Intersil Corporation as part of PRISM(R) chipset product development.
12901 +*
12902 +* --------------------------------------------------------------------
12903 +*
12904 +* This file declares some of the constants and types used in various
12905 +* parts of the linux-wlan system.
12906 +*
12907 +* Notes:
12908 +* - Constant values are always in HOST byte order.
12909 +*
12910 +* All functions and statics declared here are implemented in p80211types.c
12911 +* --------------------------------------------------------------------
12912 +*/
12913 +
12914 +#ifndef _P80211TYPES_H
12915 +#define _P80211TYPES_H
12916 +
12917 +/*================================================================*/
12918 +/* System Includes */
12919 +/*================================================================*/
12920 +
12921 +/*================================================================*/
12922 +/* Project Includes */
12923 +/*================================================================*/
12924 +
12925 +#ifndef _WLAN_COMPAT_H
12926 +#include "wlan_compat.h"
12927 +#endif
12928 +
12929 +/*================================================================*/
12930 +/* Constants */
12931 +/*================================================================*/
12932 +
12933 +/*----------------------------------------------------------------*/
12934 +/* p80211 data type codes used for MIB items and message */
12935 +/* arguments. The various metadata structures provide additional */
12936 +/* information about these types. */
12937 +
12938 +#define P80211_TYPE_OCTETSTR 1 /* pascal array of bytes */
12939 +#define P80211_TYPE_DISPLAYSTR 2 /* pascal array of bytes containing ascii */
12940 +#define P80211_TYPE_int 4 /* u32 min and max limited by 32 bits */
12941 +#define P80211_TYPE_ENUMint 5 /* u32 holding a numeric
12942 + code that can be mapped
12943 + to a textual name */
12944 +#define P80211_TYPE_UNKDATA 6 /* Data item containing an
12945 + unknown data type */
12946 +#define P80211_TYPE_intARRAY 7 /* Array of 32-bit integers. */
12947 +#define P80211_TYPE_BITARRAY 8 /* Array of bits. */
12948 +#define P80211_TYPE_MACARRAY 9 /* Array of MAC addresses. */
12949 +
12950 +/*----------------------------------------------------------------*/
12951 +/* The following constants are indexes into the Mib Category List */
12952 +/* and the Message Category List */
12953 +
12954 +/* Mib Category List */
12955 +#define P80211_MIB_CAT_DOT11SMT 1
12956 +#define P80211_MIB_CAT_DOT11MAC 2
12957 +#define P80211_MIB_CAT_DOT11PHY 3
12958 +
12959 +#define P80211SEC_DOT11SMT P80211_MIB_CAT_DOT11SMT
12960 +#define P80211SEC_DOT11MAC P80211_MIB_CAT_DOT11MAC
12961 +#define P80211SEC_DOT11PHY P80211_MIB_CAT_DOT11PHY
12962 +
12963 +/* Message Category List */
12964 +#define P80211_MSG_CAT_DOT11REQ 1
12965 +#define P80211_MSG_CAT_DOT11IND 2
12966 +/* #define P80211_MSG_CAT_DOT11CFM 3 (doesn't exist at this time) */
12967 +
12968 +#define P80211SEC_DOT11REQ P80211_MSG_CAT_DOT11REQ
12969 +#define P80211SEC_DOT11IND P80211_MSG_CAT_DOT11IND
12970 +/* #define P80211SEC_DOT11CFM P80211_MSG_CAT_DOT11CFM (doesn't exist at this time */
12971 +
12972 +
12973 +
12974 +/*----------------------------------------------------------------*/
12975 +/* p80211 DID field codes that represent access type and */
12976 +/* is_table status. */
12977 +
12978 +#define P80211DID_ACCESS_READ 0x10000000
12979 +#define P80211DID_ACCESS_WRITE 0x08000000
12980 +#define P80211DID_WRITEONLY 0x00000001
12981 +#define P80211DID_READONLY 0x00000002
12982 +#define P80211DID_READWRITE 0x00000003
12983 +#define P80211DID_ISTABLE_FALSE 0
12984 +#define P80211DID_ISTABLE_TRUE 1
12985 +
12986 +/*----------------------------------------------------------------*/
12987 +/* p80211 enumeration constants. The value to text mappings for */
12988 +/* these is in p80211types.c. These defines were generated */
12989 +/* from the mappings. */
12990 +
12991 +/* error codes for lookups */
12992 +#define P80211ENUM_BAD 0xffffffffUL
12993 +#define P80211ENUM_BADSTR "P80211ENUM_BAD"
12994 +
12995 +#define P80211ENUM_truth_false 0
12996 +#define P80211ENUM_truth_true 1
12997 +#define P80211ENUM_ifstate_disable 0
12998 +#define P80211ENUM_ifstate_fwload 1
12999 +#define P80211ENUM_ifstate_enable 2
13000 +#define P80211ENUM_powermgmt_active 1
13001 +#define P80211ENUM_powermgmt_powersave 2
13002 +#define P80211ENUM_bsstype_infrastructure 1
13003 +#define P80211ENUM_bsstype_independent 2
13004 +#define P80211ENUM_bsstype_any 3
13005 +#define P80211ENUM_authalg_opensystem 1
13006 +#define P80211ENUM_authalg_sharedkey 2
13007 +#define P80211ENUM_phytype_fhss 1
13008 +#define P80211ENUM_phytype_dsss 2
13009 +#define P80211ENUM_phytype_irbaseband 3
13010 +#define P80211ENUM_temptype_commercial 1
13011 +#define P80211ENUM_temptype_industrial 2
13012 +#define P80211ENUM_regdomain_fcc 16
13013 +#define P80211ENUM_regdomain_doc 32
13014 +#define P80211ENUM_regdomain_etsi 48
13015 +#define P80211ENUM_regdomain_spain 49
13016 +#define P80211ENUM_regdomain_france 50
13017 +#define P80211ENUM_regdomain_mkk 64
13018 +#define P80211ENUM_ccamode_edonly 1
13019 +#define P80211ENUM_ccamode_csonly 2
13020 +#define P80211ENUM_ccamode_edandcs 4
13021 +#define P80211ENUM_ccamode_cswithtimer 8
13022 +#define P80211ENUM_ccamode_hrcsanded 16
13023 +#define P80211ENUM_diversity_fixedlist 1
13024 +#define P80211ENUM_diversity_notsupported 2
13025 +#define P80211ENUM_diversity_dynamic 3
13026 +#define P80211ENUM_scantype_active 1
13027 +#define P80211ENUM_scantype_passive 2
13028 +#define P80211ENUM_scantype_both 3
13029 +#define P80211ENUM_resultcode_success 1
13030 +#define P80211ENUM_resultcode_invalid_parameters 2
13031 +#define P80211ENUM_resultcode_not_supported 3
13032 +#define P80211ENUM_resultcode_timeout 4
13033 +#define P80211ENUM_resultcode_too_many_req 5
13034 +#define P80211ENUM_resultcode_refused 6
13035 +#define P80211ENUM_resultcode_bss_already 7
13036 +#define P80211ENUM_resultcode_invalid_access 8
13037 +#define P80211ENUM_resultcode_invalid_mibattribute 9
13038 +#define P80211ENUM_resultcode_cant_set_readonly_mib 10
13039 +#define P80211ENUM_resultcode_implementation_failure 11
13040 +#define P80211ENUM_resultcode_cant_get_writeonly_mib 12
13041 +#define P80211ENUM_reason_unspec_reason 1
13042 +#define P80211ENUM_reason_auth_not_valid 2
13043 +#define P80211ENUM_reason_deauth_lv_ss 3
13044 +#define P80211ENUM_reason_inactivity 4
13045 +#define P80211ENUM_reason_ap_overload 5
13046 +#define P80211ENUM_reason_class23_err 6
13047 +#define P80211ENUM_reason_class3_err 7
13048 +#define P80211ENUM_reason_disas_lv_ss 8
13049 +#define P80211ENUM_reason_asoc_not_auth 9
13050 +#define P80211ENUM_status_successful 0
13051 +#define P80211ENUM_status_unspec_failure 1
13052 +#define P80211ENUM_status_unsup_cap 10
13053 +#define P80211ENUM_status_reasoc_no_asoc 11
13054 +#define P80211ENUM_status_fail_other 12
13055 +#define P80211ENUM_status_unspt_alg 13
13056 +#define P80211ENUM_status_auth_seq_fail 14
13057 +#define P80211ENUM_status_chlng_fail 15
13058 +#define P80211ENUM_status_auth_timeout 16
13059 +#define P80211ENUM_status_ap_full 17
13060 +#define P80211ENUM_status_unsup_rate 18
13061 +#define P80211ENUM_status_unsup_shortpreamble 19
13062 +#define P80211ENUM_status_unsup_pbcc 20
13063 +#define P80211ENUM_status_unsup_agility 21
13064 +#define P80211ENUM_msgitem_status_data_ok 0
13065 +#define P80211ENUM_msgitem_status_no_value 1
13066 +#define P80211ENUM_msgitem_status_invalid_itemname 2
13067 +#define P80211ENUM_msgitem_status_invalid_itemdata 3
13068 +#define P80211ENUM_msgitem_status_missing_itemdata 4
13069 +#define P80211ENUM_msgitem_status_incomplete_itemdata 5
13070 +#define P80211ENUM_msgitem_status_invalid_msg_did 6
13071 +#define P80211ENUM_msgitem_status_invalid_mib_did 7
13072 +#define P80211ENUM_msgitem_status_missing_conv_func 8
13073 +#define P80211ENUM_msgitem_status_string_too_long 9
13074 +#define P80211ENUM_msgitem_status_data_out_of_range 10
13075 +#define P80211ENUM_msgitem_status_string_too_short 11
13076 +#define P80211ENUM_msgitem_status_missing_valid_func 12
13077 +#define P80211ENUM_msgitem_status_unknown 13
13078 +#define P80211ENUM_msgitem_status_invalid_did 14
13079 +#define P80211ENUM_msgitem_status_missing_print_func 15
13080 +
13081 +#define P80211ENUM_lnxroam_reason_unknown 0
13082 +#define P80211ENUM_lnxroam_reason_beacon 1
13083 +#define P80211ENUM_lnxroam_reason_signal 2
13084 +#define P80211ENUM_lnxroam_reason_txretry 3
13085 +#define P80211ENUM_lnxroam_reason_notjoined 4
13086 +
13087 +#define P80211ENUM_p2preamble_long 0
13088 +#define P80211ENUM_p2preamble_short 2
13089 +#define P80211ENUM_p2preamble_mixed 3
13090 +
13091 +/*----------------------------------------------------------------*/
13092 +/* p80211 max length constants for the different pascal strings. */
13093 +
13094 +#define MAXLEN_PSTR6 (6) /* pascal array of 6 bytes */
13095 +#define MAXLEN_PSTR14 (14) /* pascal array of 14 bytes */
13096 +#define MAXLEN_PSTR32 (32) /* pascal array of 32 bytes */
13097 +#define MAXLEN_PSTR255 (255) /* pascal array of 255 bytes */
13098 +#define MAXLEN_MIBATTRIBUTE (392) /* maximum mibattribute */
13099 + /* where the size of the DATA itself */
13100 + /* is a DID-LEN-DATA triple */
13101 + /* with a max size of 4+4+384 */
13102 +
13103 +#define P80211_SET_int(item, value) do { \
13104 + (item).data = (value); \
13105 + (item).status = P80211ENUM_msgitem_status_data_ok; \
13106 + } while(0)
13107 +/*----------------------------------------------------------------*/
13108 +/* string constants */
13109 +
13110 +#define NOT_SET "NOT_SET"
13111 +#define NOT_SUPPORTED "NOT_SUPPORTED"
13112 +#define UNKNOWN_DATA "UNKNOWN_DATA"
13113 +
13114 +
13115 +/*--------------------------------------------------------------------*/
13116 +/* Metadata flags */
13117 +
13118 +/* MSM: Do these belong in p80211meta.h? I'm not sure. */
13119 +
13120 +#define ISREQUIRED (0x80000000UL)
13121 +#define ISREQUEST (0x40000000UL)
13122 +#define ISCONFIRM (0x20000000UL)
13123 +
13124 +
13125 +/*================================================================*/
13126 +/* Macros */
13127 +
13128 +/*--------------------------------------------------------------------*/
13129 +/* The following macros are used to manipulate the 'flags' field in */
13130 +/* the metadata. These are only used when the metadata is for */
13131 +/* command arguments to determine if the data item is required, and */
13132 +/* whether the metadata item is for a request command, confirm */
13133 +/* command or both. */
13134 +/*--------------------------------------------------------------------*/
13135 +/* MSM: Do these belong in p80211meta.h? I'm not sure */
13136 +
13137 +#define P80211ITEM_SETFLAGS(q, r, c) ( q | r | c )
13138 +
13139 +#define P80211ITEM_ISREQUIRED(flags) (((u32)(flags & ISREQUIRED)) >> 31 )
13140 +#define P80211ITEM_ISREQUEST(flags) (((u32)(flags & ISREQUEST)) >> 30 )
13141 +#define P80211ITEM_ISCONFIRM(flags) (((u32)(flags & ISCONFIRM)) >> 29 )
13142 +
13143 +/*----------------------------------------------------------------*/
13144 +/* The following macro creates a name for an enum */
13145 +
13146 +#define MKENUMNAME(name) p80211enum_ ## name
13147 +
13148 +/*----------------------------------------------------------------
13149 +* The following constants and macros are used to construct and
13150 +* deconstruct the Data ID codes. The coding is as follows:
13151 +*
13152 +* ...rwtnnnnnnnniiiiiiggggggssssss s - Section
13153 +* g - Group
13154 +* i - Item
13155 +* n - Index
13156 +* t - Table flag
13157 +* w - Write flag
13158 +* r - Read flag
13159 +* . - Unused
13160 +*/
13161 +
13162 +#define P80211DID_INVALID 0xffffffffUL
13163 +#define P80211DID_VALID 0x00000000UL
13164 +
13165 +#define P80211DID_LSB_SECTION (0)
13166 +#define P80211DID_LSB_GROUP (6)
13167 +#define P80211DID_LSB_ITEM (12)
13168 +#define P80211DID_LSB_INDEX (18)
13169 +#define P80211DID_LSB_ISTABLE (26)
13170 +#define P80211DID_LSB_ACCESS (27)
13171 +
13172 +#define P80211DID_MASK_SECTION (0x0000003fUL)
13173 +#define P80211DID_MASK_GROUP (0x0000003fUL)
13174 +#define P80211DID_MASK_ITEM (0x0000003fUL)
13175 +#define P80211DID_MASK_INDEX (0x000000ffUL)
13176 +#define P80211DID_MASK_ISTABLE (0x00000001UL)
13177 +#define P80211DID_MASK_ACCESS (0x00000003UL)
13178 +
13179 +
13180 +#define P80211DID_MK(a,m,l) ((((u32)(a)) & (m)) << (l))
13181 +
13182 +#define P80211DID_MKSECTION(a) P80211DID_MK(a, \
13183 + P80211DID_MASK_SECTION, \
13184 + P80211DID_LSB_SECTION )
13185 +#define P80211DID_MKGROUP(a) P80211DID_MK(a, \
13186 + P80211DID_MASK_GROUP, \
13187 + P80211DID_LSB_GROUP )
13188 +#define P80211DID_MKITEM(a) P80211DID_MK(a, \
13189 + P80211DID_MASK_ITEM, \
13190 + P80211DID_LSB_ITEM )
13191 +#define P80211DID_MKINDEX(a) P80211DID_MK(a, \
13192 + P80211DID_MASK_INDEX, \
13193 + P80211DID_LSB_INDEX )
13194 +#define P80211DID_MKISTABLE(a) P80211DID_MK(a, \
13195 + P80211DID_MASK_ISTABLE, \
13196 + P80211DID_LSB_ISTABLE )
13197 +
13198 +
13199 +#define P80211DID_MKID(s,g,i,n,t,a) (P80211DID_MKSECTION(s) | \
13200 + P80211DID_MKGROUP(g) | \
13201 + P80211DID_MKITEM(i) | \
13202 + P80211DID_MKINDEX(n) | \
13203 + P80211DID_MKISTABLE(t) | \
13204 + (a) )
13205 +
13206 +
13207 +#define P80211DID_GET(a,m,l) ((((u32)(a)) >> (l)) & (m))
13208 +
13209 +#define P80211DID_SECTION(a) P80211DID_GET(a, \
13210 + P80211DID_MASK_SECTION, \
13211 + P80211DID_LSB_SECTION)
13212 +#define P80211DID_GROUP(a) P80211DID_GET(a, \
13213 + P80211DID_MASK_GROUP, \
13214 + P80211DID_LSB_GROUP)
13215 +#define P80211DID_ITEM(a) P80211DID_GET(a, \
13216 + P80211DID_MASK_ITEM, \
13217 + P80211DID_LSB_ITEM)
13218 +#define P80211DID_INDEX(a) P80211DID_GET(a, \
13219 + P80211DID_MASK_INDEX, \
13220 + P80211DID_LSB_INDEX)
13221 +#define P80211DID_ISTABLE(a) P80211DID_GET(a, \
13222 + P80211DID_MASK_ISTABLE, \
13223 + P80211DID_LSB_ISTABLE)
13224 +#define P80211DID_ACCESS(a) P80211DID_GET(a, \
13225 + P80211DID_MASK_ACCESS, \
13226 + P80211DID_LSB_ACCESS)
13227 +
13228 +/*================================================================*/
13229 +/* Types */
13230 +
13231 +/*----------------------------------------------------------------*/
13232 +/* The following structure types are used for the represenation */
13233 +/* of ENUMint type metadata. */
13234 +
13235 +typedef struct p80211enumpair
13236 +{
13237 + u32 val;
13238 + char *name;
13239 +} p80211enumpair_t;
13240 +
13241 +typedef struct p80211enum
13242 +{
13243 + int nitems;
13244 + p80211enumpair_t *list;
13245 +} p80211enum_t;
13246 +
13247 +/*----------------------------------------------------------------*/
13248 +/* The following structure types are used to store data items in */
13249 +/* messages. */
13250 +
13251 +/* Template pascal string */
13252 +typedef struct p80211pstr
13253 +{
13254 + u8 len;
13255 +} __WLAN_ATTRIB_PACK__ p80211pstr_t;
13256 +
13257 +typedef struct p80211pstrd
13258 +{
13259 + u8 len;
13260 + u8 data[0];
13261 +} __WLAN_ATTRIB_PACK__ p80211pstrd_t;
13262 +
13263 +/* Maximum pascal string */
13264 +typedef struct p80211pstr255
13265 +{
13266 + u8 len;
13267 + u8 data[MAXLEN_PSTR255];
13268 +} __WLAN_ATTRIB_PACK__ p80211pstr255_t;
13269 +
13270 +/* pascal string for macaddress and bssid */
13271 +typedef struct p80211pstr6
13272 +{
13273 + u8 len;
13274 + u8 data[MAXLEN_PSTR6];
13275 +} __WLAN_ATTRIB_PACK__ p80211pstr6_t;
13276 +
13277 +/* pascal string for channel list */
13278 +typedef struct p80211pstr14
13279 +{
13280 + u8 len;
13281 + u8 data[MAXLEN_PSTR14];
13282 +} __WLAN_ATTRIB_PACK__ p80211pstr14_t;
13283 +
13284 +/* pascal string for ssid */
13285 +typedef struct p80211pstr32
13286 +{
13287 + u8 len;
13288 + u8 data[MAXLEN_PSTR32];
13289 +} __WLAN_ATTRIB_PACK__ p80211pstr32_t;
13290 +
13291 +/* MAC address array */
13292 +typedef struct p80211macarray
13293 +{
13294 + u32 cnt;
13295 + u8 data[1][MAXLEN_PSTR6];
13296 +} __WLAN_ATTRIB_PACK__ p80211macarray_t;
13297 +
13298 +/* prototype template */
13299 +typedef struct p80211item
13300 +{
13301 + u32 did;
13302 + u16 status;
13303 + u16 len;
13304 +} __WLAN_ATTRIB_PACK__ p80211item_t;
13305 +
13306 +/* prototype template w/ data item */
13307 +typedef struct p80211itemd
13308 +{
13309 + u32 did;
13310 + u16 status;
13311 + u16 len;
13312 + u8 data[0];
13313 +} __WLAN_ATTRIB_PACK__ p80211itemd_t;
13314 +
13315 +/* message data item for int, BOUNDEDINT, ENUMINT */
13316 +typedef struct p80211item_uint32
13317 +{
13318 + u32 did;
13319 + u16 status;
13320 + u16 len;
13321 + u32 data;
13322 +} __WLAN_ATTRIB_PACK__ p80211item_uint32_t;
13323 +
13324 +/* message data item for OCTETSTR, DISPLAYSTR */
13325 +typedef struct p80211item_pstr6
13326 +{
13327 + u32 did;
13328 + u16 status;
13329 + u16 len;
13330 + p80211pstr6_t data;
13331 +} __WLAN_ATTRIB_PACK__ p80211item_pstr6_t;
13332 +
13333 +/* message data item for OCTETSTR, DISPLAYSTR */
13334 +typedef struct p80211item_pstr14
13335 +{
13336 + u32 did;
13337 + u16 status;
13338 + u16 len;
13339 + p80211pstr14_t data;
13340 +} __WLAN_ATTRIB_PACK__ p80211item_pstr14_t;
13341 +
13342 +/* message data item for OCTETSTR, DISPLAYSTR */
13343 +typedef struct p80211item_pstr32
13344 +{
13345 + u32 did;
13346 + u16 status;
13347 + u16 len;
13348 + p80211pstr32_t data;
13349 +} __WLAN_ATTRIB_PACK__ p80211item_pstr32_t;
13350 +
13351 +/* message data item for OCTETSTR, DISPLAYSTR */
13352 +typedef struct p80211item_pstr255
13353 +{
13354 + u32 did;
13355 + u16 status;
13356 + u16 len;
13357 + p80211pstr255_t data;
13358 +} __WLAN_ATTRIB_PACK__ p80211item_pstr255_t;
13359 +
13360 +/* message data item for UNK 392, namely mib items */
13361 +typedef struct p80211item_unk392
13362 +{
13363 + u32 did;
13364 + u16 status;
13365 + u16 len;
13366 + u8 data[MAXLEN_MIBATTRIBUTE];
13367 +} __WLAN_ATTRIB_PACK__ p80211item_unk392_t;
13368 +
13369 +/* message data item for UNK 1025, namely p2 pdas */
13370 +typedef struct p80211item_unk1024
13371 +{
13372 + u32 did;
13373 + u16 status;
13374 + u16 len;
13375 + u8 data[1024];
13376 +} __WLAN_ATTRIB_PACK__ p80211item_unk1024_t;
13377 +
13378 +/* message data item for UNK 4096, namely p2 download chunks */
13379 +typedef struct p80211item_unk4096
13380 +{
13381 + u32 did;
13382 + u16 status;
13383 + u16 len;
13384 + u8 data[4096];
13385 +} __WLAN_ATTRIB_PACK__ p80211item_unk4096_t;
13386 +
13387 +struct catlistitem;
13388 +
13389 +/*----------------------------------------------------------------*/
13390 +/* The following structure type is used to represent all of the */
13391 +/* metadata items. Some components may choose to use more, */
13392 +/* less or different metadata items. */
13393 +
13394 +typedef void (*p80211_totext_t)( struct catlistitem *, u32 did, u8* itembuf, char *textbuf);
13395 +typedef void (*p80211_fromtext_t)( struct catlistitem *, u32 did, u8* itembuf, char *textbuf);
13396 +typedef u32 (*p80211_valid_t)( struct catlistitem *, u32 did, u8* itembuf);
13397 +
13398 +
13399 +/*================================================================*/
13400 +/* Extern Declarations */
13401 +
13402 +/*----------------------------------------------------------------*/
13403 +/* Enumeration Lists */
13404 +/* The following are the external declarations */
13405 +/* for all enumerations */
13406 +
13407 +extern p80211enum_t MKENUMNAME(truth);
13408 +extern p80211enum_t MKENUMNAME(ifstate);
13409 +extern p80211enum_t MKENUMNAME(powermgmt);
13410 +extern p80211enum_t MKENUMNAME(bsstype);
13411 +extern p80211enum_t MKENUMNAME(authalg);
13412 +extern p80211enum_t MKENUMNAME(phytype);
13413 +extern p80211enum_t MKENUMNAME(temptype);
13414 +extern p80211enum_t MKENUMNAME(regdomain);
13415 +extern p80211enum_t MKENUMNAME(ccamode);
13416 +extern p80211enum_t MKENUMNAME(diversity);
13417 +extern p80211enum_t MKENUMNAME(scantype);
13418 +extern p80211enum_t MKENUMNAME(resultcode);
13419 +extern p80211enum_t MKENUMNAME(reason);
13420 +extern p80211enum_t MKENUMNAME(status);
13421 +extern p80211enum_t MKENUMNAME(msgcode);
13422 +extern p80211enum_t MKENUMNAME(msgitem_status);
13423 +
13424 +extern p80211enum_t MKENUMNAME(lnxroam_reason);
13425 +
13426 +extern p80211enum_t MKENUMNAME(p2preamble);
13427 +
13428 +/*================================================================*/
13429 +/* Function Declarations */
13430 +
13431 +/*----------------------------------------------------------------*/
13432 +/* The following declare some utility functions for use with the */
13433 +/* p80211enum_t type. */
13434 +
13435 +u32 p80211enum_text2int(p80211enum_t *ep, char *text);
13436 +u32 p80211enum_int2text(p80211enum_t *ep, u32 val, char *text);
13437 +void p80211_error2text(int err_code, char *err_str);
13438 +
13439 +/*----------------------------------------------------------------*/
13440 +/* The following declare some utility functions for use with the */
13441 +/* p80211item_t and p80211meta_t types. */
13442 +
13443 +/*----------------------------------------------------------------*/
13444 +/* The following declare functions that perform validation and */
13445 +/* text to binary conversions based on the metadata for interface */
13446 +/* and MIB data items. */
13447 +/*----------------------------------------------------------------*/
13448 +
13449 +/*-- DISPLAYSTR ------------------------------------------------------*/
13450 +/* pstr ==> cstr */
13451 +void p80211_totext_displaystr( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13452 +
13453 +/* cstr ==> pstr */
13454 +void p80211_fromtext_displaystr( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13455 +
13456 +/* function that checks validity of a displaystr binary value */
13457 +u32 p80211_isvalid_displaystr( struct catlistitem *metalist, u32 did, u8 *itembuf );
13458 +
13459 +/*-- OCTETSTR --------------------------------------------------------*/
13460 +/* pstr ==> "xx:xx:...." */
13461 +void p80211_totext_octetstr( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13462 +
13463 +/* "xx:xx:...." ==> pstr */
13464 +void p80211_fromtext_octetstr( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13465 +
13466 +/* function that checks validity of an octetstr binary value */
13467 +u32 p80211_isvalid_octetstr( struct catlistitem *metalist, u32 did, u8 *itembuf );
13468 +
13469 +/*-- int -------------------------------------------------------------*/
13470 +/* u32 ==> %d */
13471 +void p80211_totext_int( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13472 +
13473 +/* %d ==> u32 */
13474 +void p80211_fromtext_int( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13475 +
13476 +/* function that checks validity of an int's binary value (always successful) */
13477 +u32 p80211_isvalid_int( struct catlistitem *metalist, u32 did, u8 *itembuf );
13478 +
13479 +/*-- ENUMint ---------------------------------------------------------*/
13480 +/* u32 ==> <valuename> */
13481 +void p80211_totext_enumint( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13482 +
13483 +/* <valuename> ==> u32 */
13484 +void p80211_fromtext_enumint( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13485 +
13486 +/* function that checks validity of an enum's binary value */
13487 +u32 p80211_isvalid_enumint( struct catlistitem *metalist, u32 did, u8 *itembuf );
13488 +
13489 +/*-- intARRAY --------------------------------------------------------*/
13490 +/* u32[] => %d,%d,%d,... */
13491 +void p80211_totext_intarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13492 +
13493 +/* %d,%d,%d,... ==> u32[] */
13494 +void p80211_fromtext_intarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13495 +
13496 +/* function that checks validity of an integer array's value */
13497 +u32 p80211_isvalid_intarray( struct catlistitem *metalist, u32 did, u8 *itembuf );
13498 +
13499 +/*-- BITARRAY --------------------------------------------------------*/
13500 +/* u32 ==> %d,%d,%d,... */
13501 +void p80211_totext_bitarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13502 +
13503 +/* %d,%d,%d,... ==> u32 */
13504 +void p80211_fromtext_bitarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13505 +
13506 +/* function that checks validity of a bit array's value */
13507 +u32 p80211_isvalid_bitarray( struct catlistitem *metalist, u32 did, u8 *itembuf );
13508 +
13509 +/*-- MACARRAY --------------------------------------------------------*/
13510 +void p80211_totext_macarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13511 +
13512 +void p80211_fromtext_macarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13513 +
13514 +/* function that checks validity of a MAC address array's value */
13515 +u32 p80211_isvalid_macarray( struct catlistitem *metalist, u32 did, u8 *itembuf );
13516 +
13517 +/*-- MIBATTRIUBTE ------------------------------------------------------*/
13518 +/* <mibvalue> ==> <textual representation identified in MIB metadata> */
13519 +void p80211_totext_getmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13520 +void p80211_totext_setmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13521 +
13522 +
13523 +/* <textual representation identified in MIB metadata> ==> <mibvalue> */
13524 +void p80211_fromtext_getmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13525 +void p80211_fromtext_setmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
13526 +
13527 +/* function that checks validity of a mibitem's binary value */
13528 +u32 p80211_isvalid_getmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf );
13529 +u32 p80211_isvalid_setmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf );
13530 +
13531 +#endif /* _P80211TYPES_H */
13532 +
13533 --- /dev/null
13534 +++ b/drivers/staging/wlan-ng/p80211wep.c
13535 @@ -0,0 +1,315 @@
13536 +/* src/p80211/p80211wep.c
13537 +*
13538 +* WEP encode/decode for P80211.
13539 +*
13540 +* Copyright (C) 2002 AbsoluteValue Systems, Inc. All Rights Reserved.
13541 +* --------------------------------------------------------------------
13542 +*
13543 +* linux-wlan
13544 +*
13545 +* The contents of this file are subject to the Mozilla Public
13546 +* License Version 1.1 (the "License"); you may not use this file
13547 +* except in compliance with the License. You may obtain a copy of
13548 +* the License at http://www.mozilla.org/MPL/
13549 +*
13550 +* Software distributed under the License is distributed on an "AS
13551 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13552 +* implied. See the License for the specific language governing
13553 +* rights and limitations under the License.
13554 +*
13555 +* Alternatively, the contents of this file may be used under the
13556 +* terms of the GNU Public License version 2 (the "GPL"), in which
13557 +* case the provisions of the GPL are applicable instead of the
13558 +* above. If you wish to allow the use of your version of this file
13559 +* only under the terms of the GPL and not to allow others to use
13560 +* your version of this file under the MPL, indicate your decision
13561 +* by deleting the provisions above and replace them with the notice
13562 +* and other provisions required by the GPL. If you do not delete
13563 +* the provisions above, a recipient may use your version of this
13564 +* file under either the MPL or the GPL.
13565 +*
13566 +* --------------------------------------------------------------------
13567 +*
13568 +* Inquiries regarding the linux-wlan Open Source project can be
13569 +* made directly to:
13570 +*
13571 +* AbsoluteValue Systems Inc.
13572 +* info@linux-wlan.com
13573 +* http://www.linux-wlan.com
13574 +*
13575 +* --------------------------------------------------------------------
13576 +*
13577 +* Portions of the development of this software were funded by
13578 +* Intersil Corporation as part of PRISM(R) chipset product development.
13579 +*
13580 +* --------------------------------------------------------------------
13581 +*/
13582 +
13583 +/*================================================================*/
13584 +/* System Includes */
13585 +
13586 +
13587 +#include <linux/version.h>
13588 +
13589 +#include <linux/netdevice.h>
13590 +#include <linux/wireless.h>
13591 +#include <linux/slab.h>
13592 +#include <linux/random.h>
13593 +
13594 +#include "wlan_compat.h"
13595 +
13596 +// #define WEP_DEBUG
13597 +
13598 +/*================================================================*/
13599 +/* Project Includes */
13600 +
13601 +#include "p80211hdr.h"
13602 +#include "p80211types.h"
13603 +#include "p80211msg.h"
13604 +#include "p80211conv.h"
13605 +#include "p80211netdev.h"
13606 +
13607 +/*================================================================*/
13608 +/* Local Constants */
13609 +
13610 +#define SSWAP(a,b) {u8 tmp = s[a]; s[a] = s[b]; s[b] = tmp;}
13611 +#define WEP_KEY(x) (((x) & 0xC0) >> 6)
13612 +
13613 +/*================================================================*/
13614 +/* Local Macros */
13615 +
13616 +
13617 +/*================================================================*/
13618 +/* Local Types */
13619 +
13620 +
13621 +/*================================================================*/
13622 +/* Local Static Definitions */
13623 +
13624 +static const u32 wep_crc32_table[256] = {
13625 + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
13626 + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
13627 + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
13628 + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
13629 + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
13630 + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
13631 + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
13632 + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
13633 + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
13634 + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
13635 + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
13636 + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
13637 + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
13638 + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
13639 + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
13640 + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
13641 + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
13642 + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
13643 + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
13644 + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
13645 + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
13646 + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
13647 + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
13648 + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
13649 + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
13650 + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
13651 + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
13652 + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
13653 + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
13654 + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
13655 + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
13656 + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
13657 + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
13658 + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
13659 + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
13660 + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
13661 + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
13662 + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
13663 + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
13664 + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
13665 + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
13666 + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
13667 + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
13668 + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
13669 + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
13670 + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
13671 + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
13672 + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
13673 + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
13674 + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
13675 + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
13676 + 0x2d02ef8dL
13677 +};
13678 +
13679 +/*================================================================*/
13680 +/* Local Function Declarations */
13681 +
13682 +/*================================================================*/
13683 +/* Function Definitions */
13684 +
13685 +/* keylen in bytes! */
13686 +
13687 +int wep_change_key(wlandevice_t *wlandev, int keynum, u8* key, int keylen)
13688 +{
13689 + if (keylen < 0) return -1;
13690 + if (keylen >= MAX_KEYLEN) return -1;
13691 + if (key == NULL) return -1;
13692 + if (keynum < 0) return -1;
13693 + if (keynum >= NUM_WEPKEYS) return -1;
13694 +
13695 +
13696 +#ifdef WEP_DEBUG
13697 + printk(KERN_DEBUG "WEP key %d len %d = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", keynum, keylen, key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]);
13698 +#endif
13699 +
13700 + wlandev->wep_keylens[keynum] = keylen;
13701 + memcpy(wlandev->wep_keys[keynum], key, keylen);
13702 +
13703 + return 0;
13704 +}
13705 +
13706 +/*
13707 + 4-byte IV at start of buffer, 4-byte ICV at end of buffer.
13708 + if successful, buf start is payload begin, length -= 8;
13709 + */
13710 +int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *iv, u8 *icv)
13711 +{
13712 + u32 i, j, k, crc, keylen;
13713 + u8 s[256], key[64], c_crc[4];
13714 + u8 keyidx;
13715 +
13716 + /* Needs to be at least 8 bytes of payload */
13717 + if (len <= 0) return -1;
13718 +
13719 + /* initialize the first bytes of the key from the IV */
13720 + key[0] = iv[0];
13721 + key[1] = iv[1];
13722 + key[2] = iv[2];
13723 + keyidx = WEP_KEY(iv[3]);
13724 +
13725 + if (key_override >= 0)
13726 + keyidx = key_override;
13727 +
13728 + if (keyidx >= NUM_WEPKEYS) return -2;
13729 +
13730 + keylen = wlandev->wep_keylens[keyidx];
13731 +
13732 + if (keylen == 0) return -3;
13733 +
13734 + /* copy the rest of the key over from the designated key */
13735 + memcpy(key+3, wlandev->wep_keys[keyidx], keylen);
13736 +
13737 + keylen+=3; /* add in IV bytes */
13738 +
13739 +#ifdef WEP_DEBUG
13740 + printk(KERN_DEBUG "D %d: %02x %02x %02x (%d %d) %02x:%02x:%02x:%02x:%02x\n", len, key[0], key[1], key[2], keyidx, keylen, key[3], key[4], key[5], key[6], key[7]);
13741 +#endif
13742 +
13743 + /* set up the RC4 state */
13744 + for (i = 0; i < 256; i++)
13745 + s[i] = i;
13746 + j = 0;
13747 + for (i = 0; i < 256; i++) {
13748 + j = (j + s[i] + key[i % keylen]) & 0xff;
13749 + SSWAP(i,j);
13750 + }
13751 +
13752 + /* Apply the RC4 to the data, update the CRC32 */
13753 + crc = ~0;
13754 + i = j = 0;
13755 + for (k = 0; k < len; k++) {
13756 + i = (i+1) & 0xff;
13757 + j = (j+s[i]) & 0xff;
13758 + SSWAP(i,j);
13759 + buf[k] ^= s[(s[i] + s[j]) & 0xff];
13760 + crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8);
13761 + }
13762 + crc = ~crc;
13763 +
13764 + /* now let's check the crc */
13765 + c_crc[0] = crc;
13766 + c_crc[1] = crc >> 8;
13767 + c_crc[2] = crc >> 16;
13768 + c_crc[3] = crc >> 24;
13769 +
13770 + for (k = 0; k < 4; k++) {
13771 + i = (i + 1) & 0xff;
13772 + j = (j+s[i]) & 0xff;
13773 + SSWAP(i,j);
13774 + if ((c_crc[k] ^ s[(s[i] + s[j]) & 0xff]) != icv[k])
13775 + return -(4 | (k << 4)) ; /* ICV mismatch */
13776 + }
13777 +
13778 + return 0;
13779 +}
13780 +
13781 +/* encrypts in-place. */
13782 +int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8 *iv, u8 *icv)
13783 +{
13784 + u32 i, j, k, crc, keylen;
13785 + u8 s[256], key[64];
13786 +
13787 + /* no point in WEPping an empty frame */
13788 + if (len <= 0) return -1;
13789 +
13790 + /* we need to have a real key.. */
13791 + if (keynum >= NUM_WEPKEYS) return -2;
13792 + keylen = wlandev->wep_keylens[keynum];
13793 + if (keylen <= 0) return -3;
13794 +
13795 + /* use a random IV. And skip known weak ones. */
13796 + get_random_bytes(iv, 3);
13797 + while ((iv[1] == 0xff) && (iv[0] >= 3) && (iv[0] < keylen))
13798 + get_random_bytes(iv, 3);
13799 +
13800 + iv[3] = (keynum & 0x03) << 6;
13801 +
13802 + key[0] = iv[0];
13803 + key[1] = iv[1];
13804 + key[2] = iv[2];
13805 +
13806 + /* copy the rest of the key over from the designated key */
13807 + memcpy(key+3, wlandev->wep_keys[keynum], keylen);
13808 +
13809 + keylen+=3; /* add in IV bytes */
13810 +
13811 +#ifdef WEP_DEBUG
13812 + printk(KERN_DEBUG "E %d (%d/%d %d) %02x %02x %02x %02x:%02x:%02x:%02x:%02x\n", len, iv[3], keynum, keylen, key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]);
13813 +#endif
13814 +
13815 + /* set up the RC4 state */
13816 + for (i = 0; i < 256; i++)
13817 + s[i] = i;
13818 + j = 0;
13819 + for (i = 0; i < 256; i++) {
13820 + j = (j + s[i] + key[i % keylen]) & 0xff;
13821 + SSWAP(i,j);
13822 + }
13823 +
13824 + /* Update CRC32 then apply RC4 to the data */
13825 + crc = ~0;
13826 + i = j = 0;
13827 + for (k = 0; k < len; k++) {
13828 + crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8);
13829 + i = (i+1) & 0xff;
13830 + j = (j+s[i]) & 0xff;
13831 + SSWAP(i,j);
13832 + dst[k] = buf[k] ^ s[(s[i] + s[j]) & 0xff];
13833 + }
13834 + crc = ~crc;
13835 +
13836 + /* now let's encrypt the crc */
13837 + icv[0] = crc;
13838 + icv[1] = crc >> 8;
13839 + icv[2] = crc >> 16;
13840 + icv[3] = crc >> 24;
13841 +
13842 + for (k = 0; k < 4; k++) {
13843 + i = (i + 1) & 0xff;
13844 + j = (j+s[i]) & 0xff;
13845 + SSWAP(i,j);
13846 + icv[k] ^= s[(s[i] + s[j]) & 0xff];
13847 + }
13848 +
13849 + return 0;
13850 +}
13851 --- /dev/null
13852 +++ b/drivers/staging/wlan-ng/p80211wext.c
13853 @@ -0,0 +1,1826 @@
13854 +/* src/p80211/p80211wext.c
13855 +*
13856 +* Glue code to make linux-wlan-ng a happy wireless extension camper.
13857 +*
13858 +* original author: Reyk Floeter <reyk@synack.de>
13859 +* Completely re-written by Solomon Peachy <solomon@linux-wlan.com>
13860 +*
13861 +* Copyright (C) 2002 AbsoluteValue Systems, Inc. All Rights Reserved.
13862 +* --------------------------------------------------------------------
13863 +*
13864 +* linux-wlan
13865 +*
13866 +* The contents of this file are subject to the Mozilla Public
13867 +* License Version 1.1 (the "License"); you may not use this file
13868 +* except in compliance with the License. You may obtain a copy of
13869 +* the License at http://www.mozilla.org/MPL/
13870 +*
13871 +* Software distributed under the License is distributed on an "AS
13872 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13873 +* implied. See the License for the specific language governing
13874 +* rights and limitations under the License.
13875 +*
13876 +* Alternatively, the contents of this file may be used under the
13877 +* terms of the GNU Public License version 2 (the "GPL"), in which
13878 +* case the provisions of the GPL are applicable instead of the
13879 +* above. If you wish to allow the use of your version of this file
13880 +* only under the terms of the GPL and not to allow others to use
13881 +* your version of this file under the MPL, indicate your decision
13882 +* by deleting the provisions above and replace them with the notice
13883 +* and other provisions required by the GPL. If you do not delete
13884 +* the provisions above, a recipient may use your version of this
13885 +* file under either the MPL or the GPL.
13886 +*
13887 +* --------------------------------------------------------------------
13888 +*/
13889 +
13890 +/*================================================================*/
13891 +/* System Includes */
13892 +
13893 +
13894 +
13895 +#include <linux/kernel.h>
13896 +#include <linux/sched.h>
13897 +#include <linux/types.h>
13898 +#include <linux/slab.h>
13899 +#include <linux/netdevice.h>
13900 +#include <linux/etherdevice.h>
13901 +#include <linux/wireless.h>
13902 +#include <net/iw_handler.h>
13903 +#include <linux/if_arp.h>
13904 +#include <asm/bitops.h>
13905 +#include <asm/uaccess.h>
13906 +#include <asm/byteorder.h>
13907 +
13908 +/*================================================================*/
13909 +/* Project Includes */
13910 +
13911 +#include "wlan_compat.h"
13912 +
13913 +#include "p80211types.h"
13914 +#include "p80211hdr.h"
13915 +#include "p80211conv.h"
13916 +#include "p80211mgmt.h"
13917 +#include "p80211msg.h"
13918 +#include "p80211metastruct.h"
13919 +#include "p80211metadef.h"
13920 +#include "p80211netdev.h"
13921 +#include "p80211ioctl.h"
13922 +#include "p80211req.h"
13923 +
13924 +static int p80211wext_giwrate(netdevice_t *dev,
13925 + struct iw_request_info *info,
13926 + struct iw_param *rrq, char *extra);
13927 +static int p80211wext_giwessid(netdevice_t *dev,
13928 + struct iw_request_info *info,
13929 + struct iw_point *data, char *essid);
13930 +
13931 +static u8 p80211_mhz_to_channel(u16 mhz)
13932 +{
13933 + if (mhz >= 5000) {
13934 + return ((mhz - 5000) / 5);
13935 + }
13936 +
13937 + if (mhz == 2482)
13938 + return 14;
13939 +
13940 + if (mhz >= 2407) {
13941 + return ((mhz - 2407) / 5);
13942 + }
13943 +
13944 + return 0;
13945 +}
13946 +
13947 +static u16 p80211_channel_to_mhz(u8 ch, int dot11a)
13948 +{
13949 +
13950 + if (ch == 0)
13951 + return 0;
13952 + if (ch > 200)
13953 + return 0;
13954 +
13955 + /* 5G */
13956 +
13957 + if (dot11a) {
13958 + return (5000 + (5 * ch));
13959 + }
13960 +
13961 + /* 2.4G */
13962 +
13963 + if (ch == 14)
13964 + return 2484;
13965 +
13966 + if ((ch < 14) && (ch > 0)) {
13967 + return (2407 + (5 * ch));
13968 + }
13969 +
13970 + return 0;
13971 +}
13972 +
13973 +/* taken from orinoco.c ;-) */
13974 +static const long p80211wext_channel_freq[] = {
13975 + 2412, 2417, 2422, 2427, 2432, 2437, 2442,
13976 + 2447, 2452, 2457, 2462, 2467, 2472, 2484
13977 +};
13978 +#define NUM_CHANNELS ARRAY_SIZE(p80211wext_channel_freq)
13979 +
13980 +/* steal a spare bit to store the shared/opensystems state. should default to open if not set */
13981 +#define HOSTWEP_SHAREDKEY BIT3
13982 +
13983 +
13984 +/** function declarations =============== */
13985 +
13986 +static int qual_as_percent(int snr ) {
13987 + if ( snr <= 0 )
13988 + return 0;
13989 + if ( snr <= 40 )
13990 + return snr*5/2;
13991 + return 100;
13992 +}
13993 +
13994 +
13995 +
13996 +
13997 +static int p80211wext_dorequest(wlandevice_t *wlandev, u32 did, u32 data)
13998 +{
13999 + p80211msg_dot11req_mibset_t msg;
14000 + p80211item_uint32_t mibitem;
14001 + int result;
14002 +
14003 + DBFENTER;
14004 +
14005 + msg.msgcode = DIDmsg_dot11req_mibset;
14006 + mibitem.did = did;
14007 + mibitem.data = data;
14008 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14009 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14010 +
14011 + DBFEXIT;
14012 + return result;
14013 +}
14014 +
14015 +static int p80211wext_autojoin(wlandevice_t *wlandev)
14016 +{
14017 + p80211msg_lnxreq_autojoin_t msg;
14018 + struct iw_point data;
14019 + char ssid[IW_ESSID_MAX_SIZE];
14020 +
14021 + int result;
14022 + int err = 0;
14023 +
14024 + DBFENTER;
14025 +
14026 + /* Get ESSID */
14027 + result = p80211wext_giwessid(wlandev->netdev, NULL, &data, ssid);
14028 +
14029 + if (result) {
14030 + err = -EFAULT;
14031 + goto exit;
14032 + }
14033 +
14034 + if ( wlandev->hostwep & HOSTWEP_SHAREDKEY )
14035 + msg.authtype.data = P80211ENUM_authalg_sharedkey;
14036 + else
14037 + msg.authtype.data = P80211ENUM_authalg_opensystem;
14038 +
14039 + msg.msgcode = DIDmsg_lnxreq_autojoin;
14040 +
14041 + /* Trim the last '\0' to fit the SSID format */
14042 +
14043 + if (data.length && ssid[data.length-1] == '\0') {
14044 + data.length = data.length - 1;
14045 + }
14046 +
14047 + memcpy(msg.ssid.data.data, ssid, data.length);
14048 + msg.ssid.data.len = data.length;
14049 +
14050 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14051 +
14052 + if (result) {
14053 + err = -EFAULT;
14054 + goto exit;
14055 + }
14056 +
14057 +exit:
14058 +
14059 + DBFEXIT;
14060 + return err;
14061 +
14062 +}
14063 +
14064 +/* called by /proc/net/wireless */
14065 +struct iw_statistics* p80211wext_get_wireless_stats (netdevice_t *dev)
14066 +{
14067 + p80211msg_lnxreq_commsquality_t quality;
14068 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14069 + struct iw_statistics* wstats = &wlandev->wstats;
14070 + int retval;
14071 +
14072 + DBFENTER;
14073 + /* Check */
14074 + if ( (wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING) )
14075 + return NULL;
14076 +
14077 + /* XXX Only valid in station mode */
14078 + wstats->status = 0;
14079 +
14080 + /* build request message */
14081 + quality.msgcode = DIDmsg_lnxreq_commsquality;
14082 + quality.dbm.data = P80211ENUM_truth_true;
14083 + quality.dbm.status = P80211ENUM_msgitem_status_data_ok;
14084 +
14085 + /* send message to nsd */
14086 + if ( wlandev->mlmerequest == NULL )
14087 + return NULL;
14088 +
14089 + retval = wlandev->mlmerequest(wlandev, (p80211msg_t*) &quality);
14090 +
14091 + wstats->qual.qual = qual_as_percent(quality.link.data); /* overall link quality */
14092 + wstats->qual.level = quality.level.data; /* instant signal level */
14093 + wstats->qual.noise = quality.noise.data; /* instant noise level */
14094 +
14095 + wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
14096 + wstats->discard.code = wlandev->rx.decrypt_err;
14097 + wstats->discard.nwid = 0;
14098 + wstats->discard.misc = 0;
14099 +
14100 + wstats->discard.fragment = 0; // incomplete fragments
14101 + wstats->discard.retries = 0; // tx retries.
14102 + wstats->miss.beacon = 0;
14103 +
14104 + DBFEXIT;
14105 +
14106 + return wstats;
14107 +}
14108 +
14109 +static int p80211wext_giwname(netdevice_t *dev,
14110 + struct iw_request_info *info,
14111 + char *name, char *extra)
14112 +{
14113 + struct iw_param rate;
14114 + int result;
14115 + int err = 0;
14116 +
14117 + DBFENTER;
14118 +
14119 + result = p80211wext_giwrate(dev, NULL, &rate, NULL);
14120 +
14121 + if (result) {
14122 + err = -EFAULT;
14123 + goto exit;
14124 + }
14125 +
14126 + switch (rate.value) {
14127 + case 1000000:
14128 + case 2000000:
14129 + strcpy(name, "IEEE 802.11-DS");
14130 + break;
14131 + case 5500000:
14132 + case 11000000:
14133 + strcpy(name, "IEEE 802.11-b");
14134 + break;
14135 + }
14136 +exit:
14137 + DBFEXIT;
14138 + return err;
14139 +}
14140 +
14141 +static int p80211wext_giwfreq(netdevice_t *dev,
14142 + struct iw_request_info *info,
14143 + struct iw_freq *freq, char *extra)
14144 +{
14145 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14146 + p80211item_uint32_t mibitem;
14147 + p80211msg_dot11req_mibset_t msg;
14148 + int result;
14149 + int err = 0;
14150 +
14151 + DBFENTER;
14152 +
14153 + msg.msgcode = DIDmsg_dot11req_mibget;
14154 + mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel;
14155 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14156 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14157 +
14158 + if (result) {
14159 + err = -EFAULT;
14160 + goto exit;
14161 + }
14162 +
14163 + memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
14164 +
14165 + if (mibitem.data > NUM_CHANNELS) {
14166 + err = -EFAULT;
14167 + goto exit;
14168 + }
14169 +
14170 + /* convert into frequency instead of a channel */
14171 + freq->e = 1;
14172 + freq->m = p80211_channel_to_mhz(mibitem.data, 0) * 100000;
14173 +
14174 + exit:
14175 + DBFEXIT;
14176 + return err;
14177 +}
14178 +
14179 +static int p80211wext_siwfreq(netdevice_t *dev,
14180 + struct iw_request_info *info,
14181 + struct iw_freq *freq, char *extra)
14182 +{
14183 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14184 + p80211item_uint32_t mibitem;
14185 + p80211msg_dot11req_mibset_t msg;
14186 + int result;
14187 + int err = 0;
14188 +
14189 + DBFENTER;
14190 +
14191 + if (!wlan_wext_write) {
14192 + err = (-EOPNOTSUPP);
14193 + goto exit;
14194 + }
14195 +
14196 + msg.msgcode = DIDmsg_dot11req_mibset;
14197 + mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel;
14198 + mibitem.status = P80211ENUM_msgitem_status_data_ok;
14199 +
14200 + if ( (freq->e == 0) && (freq->m <= 1000) )
14201 + mibitem.data = freq->m;
14202 + else
14203 + mibitem.data = p80211_mhz_to_channel(freq->m);
14204 +
14205 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14206 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14207 +
14208 + if (result) {
14209 + err = -EFAULT;
14210 + goto exit;
14211 + }
14212 +
14213 + exit:
14214 + DBFEXIT;
14215 + return err;
14216 +}
14217 +
14218 +static int p80211wext_giwmode(netdevice_t *dev,
14219 + struct iw_request_info *info,
14220 + __u32 *mode, char *extra)
14221 +{
14222 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14223 +
14224 + DBFENTER;
14225 +
14226 + switch (wlandev->macmode) {
14227 + case WLAN_MACMODE_IBSS_STA:
14228 + *mode = IW_MODE_ADHOC;
14229 + break;
14230 + case WLAN_MACMODE_ESS_STA:
14231 + *mode = IW_MODE_INFRA;
14232 + break;
14233 + case WLAN_MACMODE_ESS_AP:
14234 + *mode = IW_MODE_MASTER;
14235 + break;
14236 + default:
14237 + /* Not set yet. */
14238 + *mode = IW_MODE_AUTO;
14239 + }
14240 +
14241 + DBFEXIT;
14242 + return 0;
14243 +}
14244 +
14245 +static int p80211wext_siwmode(netdevice_t *dev,
14246 + struct iw_request_info *info,
14247 + __u32 *mode, char *extra)
14248 +{
14249 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14250 + p80211item_uint32_t mibitem;
14251 + p80211msg_dot11req_mibset_t msg;
14252 + int result;
14253 + int err = 0;
14254 +
14255 + DBFENTER;
14256 +
14257 + if (!wlan_wext_write) {
14258 + err = (-EOPNOTSUPP);
14259 + goto exit;
14260 + }
14261 +
14262 + if (*mode != IW_MODE_ADHOC && *mode != IW_MODE_INFRA &&
14263 + *mode != IW_MODE_MASTER) {
14264 + err = (-EOPNOTSUPP);
14265 + goto exit;
14266 + }
14267 +
14268 + /* Operation mode is the same with current mode */
14269 + if (*mode == wlandev->macmode)
14270 + goto exit;
14271 +
14272 + switch (*mode) {
14273 + case IW_MODE_ADHOC:
14274 + wlandev->macmode = WLAN_MACMODE_IBSS_STA;
14275 + break;
14276 + case IW_MODE_INFRA:
14277 + wlandev->macmode = WLAN_MACMODE_ESS_STA;
14278 + break;
14279 + case IW_MODE_MASTER:
14280 + wlandev->macmode = WLAN_MACMODE_ESS_AP;
14281 + break;
14282 + default:
14283 + /* Not set yet. */
14284 + WLAN_LOG_INFO("Operation mode: %d not support\n", *mode);
14285 + return -EOPNOTSUPP;
14286 + }
14287 +
14288 + /* Set Operation mode to the PORT TYPE RID */
14289 + msg.msgcode = DIDmsg_dot11req_mibset;
14290 + mibitem.did = DIDmib_p2_p2Static_p2CnfPortType;
14291 + mibitem.data = (*mode == IW_MODE_ADHOC) ? 0 : 1;
14292 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14293 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14294 +
14295 + if (result)
14296 + err = -EFAULT;
14297 +
14298 + exit:
14299 + DBFEXIT;
14300 +
14301 + return err;
14302 +}
14303 +
14304 +
14305 +static int p80211wext_giwrange(netdevice_t *dev,
14306 + struct iw_request_info *info,
14307 + struct iw_point *data, char *extra)
14308 +{
14309 + struct iw_range *range = (struct iw_range *) extra;
14310 + int i, val;
14311 +
14312 + DBFENTER;
14313 +
14314 + // for backward compatability set size & zero everything we don't understand
14315 + data->length = sizeof(*range);
14316 + memset(range,0,sizeof(*range));
14317 +
14318 + range->txpower_capa = IW_TXPOW_DBM;
14319 + // XXX what about min/max_pmp, min/max_pmt, etc.
14320 +
14321 + range->we_version_compiled = WIRELESS_EXT;
14322 + range->we_version_source = 13;
14323 +
14324 + range->retry_capa = IW_RETRY_LIMIT;
14325 + range->retry_flags = IW_RETRY_LIMIT;
14326 + range->min_retry = 0;
14327 + range->max_retry = 255;
14328 +
14329 + range->event_capa[0] = (IW_EVENT_CAPA_K_0 | //mode/freq/ssid
14330 + IW_EVENT_CAPA_MASK(SIOCGIWAP) |
14331 + IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
14332 + range->event_capa[1] = IW_EVENT_CAPA_K_1; //encode
14333 + range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVQUAL) |
14334 + IW_EVENT_CAPA_MASK(IWEVCUSTOM) );
14335 +
14336 + range->num_channels = NUM_CHANNELS;
14337 +
14338 + /* XXX need to filter against the regulatory domain &| active set */
14339 + val = 0;
14340 + for (i = 0; i < NUM_CHANNELS ; i++) {
14341 + range->freq[val].i = i + 1;
14342 + range->freq[val].m = p80211wext_channel_freq[i] * 100000;
14343 + range->freq[val].e = 1;
14344 + val++;
14345 + }
14346 +
14347 + range->num_frequency = val;
14348 +
14349 + /* Max of /proc/net/wireless */
14350 + range->max_qual.qual = 100;
14351 + range->max_qual.level = 0;
14352 + range->max_qual.noise = 0;
14353 + range->sensitivity = 3;
14354 + // XXX these need to be nsd-specific!
14355 +
14356 + range->min_rts = 0;
14357 + range->max_rts = 2347;
14358 + range->min_frag = 256;
14359 + range->max_frag = 2346;
14360 +
14361 + range->max_encoding_tokens = NUM_WEPKEYS;
14362 + range->num_encoding_sizes = 2;
14363 + range->encoding_size[0] = 5;
14364 + range->encoding_size[1] = 13;
14365 +
14366 + // XXX what about num_bitrates/throughput?
14367 + range->num_bitrates = 0;
14368 +
14369 + /* estimated max throughput */
14370 + // XXX need to cap it if we're running at ~2Mbps..
14371 + range->throughput = 5500000;
14372 +
14373 + DBFEXIT;
14374 + return 0;
14375 +}
14376 +
14377 +static int p80211wext_giwap(netdevice_t *dev,
14378 + struct iw_request_info *info,
14379 + struct sockaddr *ap_addr, char *extra)
14380 +{
14381 +
14382 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14383 +
14384 + DBFENTER;
14385 +
14386 + memcpy(ap_addr->sa_data, wlandev->bssid, WLAN_BSSID_LEN);
14387 + ap_addr->sa_family = ARPHRD_ETHER;
14388 +
14389 + DBFEXIT;
14390 + return 0;
14391 +}
14392 +
14393 +static int p80211wext_giwencode(netdevice_t *dev,
14394 + struct iw_request_info *info,
14395 + struct iw_point *erq, char *key)
14396 +{
14397 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14398 + int err = 0;
14399 + int i;
14400 +
14401 + DBFENTER;
14402 +
14403 + i = (erq->flags & IW_ENCODE_INDEX) - 1;
14404 + erq->flags = 0;
14405 +
14406 + if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
14407 + erq->flags |= IW_ENCODE_ENABLED;
14408 + else
14409 + erq->flags |= IW_ENCODE_DISABLED;
14410 +
14411 + if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED)
14412 + erq->flags |= IW_ENCODE_RESTRICTED;
14413 + else
14414 + erq->flags |= IW_ENCODE_OPEN;
14415 +
14416 + i = (erq->flags & IW_ENCODE_INDEX) - 1;
14417 +
14418 + if (i == -1)
14419 + i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
14420 +
14421 + if ((i < 0) || (i >= NUM_WEPKEYS)) {
14422 + err = -EINVAL;
14423 + goto exit;
14424 + }
14425 +
14426 + erq->flags |= i + 1;
14427 +
14428 + /* copy the key from the driver cache as the keys are read-only MIBs */
14429 + erq->length = wlandev->wep_keylens[i];
14430 + memcpy(key, wlandev->wep_keys[i], erq->length);
14431 +
14432 + exit:
14433 + DBFEXIT;
14434 + return err;
14435 +}
14436 +
14437 +static int p80211wext_siwencode(netdevice_t *dev,
14438 + struct iw_request_info *info,
14439 + struct iw_point *erq, char *key)
14440 +{
14441 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14442 + p80211msg_dot11req_mibset_t msg;
14443 + p80211item_pstr32_t pstr;
14444 +
14445 + int err = 0;
14446 + int result = 0;
14447 + int i;
14448 +
14449 + DBFENTER;
14450 + if (!wlan_wext_write) {
14451 + err = (-EOPNOTSUPP);
14452 + goto exit;
14453 + }
14454 +
14455 + /* Check the Key index first. */
14456 + if((i = (erq->flags & IW_ENCODE_INDEX))) {
14457 +
14458 + if ((i < 1) || (i > NUM_WEPKEYS)) {
14459 + err = -EINVAL;
14460 + goto exit;
14461 + }
14462 + else
14463 + i--;
14464 +
14465 + /* Set current key number only if no keys are given */
14466 + if (erq->flags & IW_ENCODE_NOKEY) {
14467 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, i);
14468 +
14469 + if (result) {
14470 + err = -EFAULT;
14471 + goto exit;
14472 + }
14473 + }
14474 +
14475 + } else {
14476 + // Use defaultkey if no Key Index
14477 + i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
14478 + }
14479 +
14480 + /* Check if there is no key information in the iwconfig request */
14481 + if((erq->flags & IW_ENCODE_NOKEY) == 0 ) {
14482 +
14483 + /*------------------------------------------------------------
14484 + * If there is WEP Key for setting, check the Key Information
14485 + * and then set it to the firmware.
14486 + -------------------------------------------------------------*/
14487 +
14488 + if (erq->length > 0) {
14489 +
14490 + /* copy the key from the driver cache as the keys are read-only MIBs */
14491 + wlandev->wep_keylens[i] = erq->length;
14492 + memcpy(wlandev->wep_keys[i], key, erq->length);
14493 +
14494 + /* Prepare data struture for p80211req_dorequest. */
14495 + memcpy(pstr.data.data, key, erq->length);
14496 + pstr.data.len = erq->length;
14497 +
14498 + switch(i)
14499 + {
14500 + case 0:
14501 + pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
14502 + break;
14503 +
14504 + case 1:
14505 + pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
14506 + break;
14507 +
14508 + case 2:
14509 + pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
14510 + break;
14511 +
14512 + case 3:
14513 + pstr.did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
14514 + break;
14515 +
14516 + default:
14517 + err = -EINVAL;
14518 + goto exit;
14519 + }
14520 +
14521 + msg.msgcode = DIDmsg_dot11req_mibset;
14522 + memcpy(&msg.mibattribute.data, &pstr, sizeof(pstr));
14523 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14524 +
14525 + if (result) {
14526 + err = -EFAULT;
14527 + goto exit;
14528 + }
14529 + }
14530 +
14531 + }
14532 +
14533 + /* Check the PrivacyInvoked flag */
14534 + if (erq->flags & IW_ENCODE_DISABLED) {
14535 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false);
14536 + } else {
14537 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true);
14538 + }
14539 +
14540 + if (result) {
14541 + err = -EFAULT;
14542 + goto exit;
14543 + }
14544 +
14545 + /* The security mode may be open or restricted, and its meaning
14546 + depends on the card used. With most cards, in open mode no
14547 + authentication is used and the card may also accept non-
14548 + encrypted sessions, whereas in restricted mode only encrypted
14549 + sessions are accepted and the card will use authentication if
14550 + available.
14551 + */
14552 + if (erq->flags & IW_ENCODE_RESTRICTED) {
14553 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true);
14554 + }
14555 + else if (erq->flags & IW_ENCODE_OPEN) {
14556 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false);
14557 + }
14558 +
14559 + if (result) {
14560 + err = -EFAULT;
14561 + goto exit;
14562 + }
14563 +
14564 + exit:
14565 +
14566 + DBFEXIT;
14567 + return err;
14568 +}
14569 +
14570 +static int p80211wext_giwessid(netdevice_t *dev,
14571 + struct iw_request_info *info,
14572 + struct iw_point *data, char *essid)
14573 +{
14574 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14575 +
14576 + DBFENTER;
14577 +
14578 + if (wlandev->ssid.len) {
14579 + data->length = wlandev->ssid.len;
14580 + data->flags = 1;
14581 + memcpy(essid, wlandev->ssid.data, data->length);
14582 + essid[data->length] = 0;
14583 +#if (WIRELESS_EXT < 21)
14584 + data->length++;
14585 +#endif
14586 + } else {
14587 + memset(essid, 0, sizeof(wlandev->ssid.data));
14588 + data->length = 0;
14589 + data->flags = 0;
14590 + }
14591 +
14592 + DBFEXIT;
14593 + return 0;
14594 +}
14595 +
14596 +static int p80211wext_siwessid(netdevice_t *dev,
14597 + struct iw_request_info *info,
14598 + struct iw_point *data, char *essid)
14599 +{
14600 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14601 + p80211msg_lnxreq_autojoin_t msg;
14602 +
14603 + int result;
14604 + int err = 0;
14605 + int length = data->length;
14606 +
14607 + DBFENTER;
14608 +
14609 + if (!wlan_wext_write) {
14610 + err = (-EOPNOTSUPP);
14611 + goto exit;
14612 + }
14613 +
14614 +
14615 + if ( wlandev->hostwep & HOSTWEP_SHAREDKEY )
14616 + msg.authtype.data = P80211ENUM_authalg_sharedkey;
14617 + else
14618 + msg.authtype.data = P80211ENUM_authalg_opensystem;
14619 +
14620 + msg.msgcode = DIDmsg_lnxreq_autojoin;
14621 +
14622 +#if (WIRELESS_EXT < 21)
14623 + if (length) length--;
14624 +#endif
14625 +
14626 + /* Trim the last '\0' to fit the SSID format */
14627 +
14628 + if (length && essid[length-1] == '\0') {
14629 + length--;
14630 + }
14631 +
14632 + memcpy(msg.ssid.data.data, essid, length);
14633 + msg.ssid.data.len = length;
14634 +
14635 + WLAN_LOG_DEBUG(1,"autojoin_ssid for %s \n",essid);
14636 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14637 + WLAN_LOG_DEBUG(1,"autojoin_ssid %d\n",result);
14638 +
14639 + if (result) {
14640 + err = -EFAULT;
14641 + goto exit;
14642 + }
14643 +
14644 + exit:
14645 + DBFEXIT;
14646 + return err;
14647 +}
14648 +
14649 +
14650 +static int p80211wext_siwcommit(netdevice_t *dev,
14651 + struct iw_request_info *info,
14652 + struct iw_point *data, char *essid)
14653 +{
14654 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14655 + int err = 0;
14656 +
14657 + DBFENTER;
14658 +
14659 + if (!wlan_wext_write) {
14660 + err = (-EOPNOTSUPP);
14661 + goto exit;
14662 + }
14663 +
14664 + /* Auto Join */
14665 + err = p80211wext_autojoin(wlandev);
14666 +
14667 + exit:
14668 + DBFEXIT;
14669 + return err;
14670 +}
14671 +
14672 +
14673 +static int p80211wext_giwrate(netdevice_t *dev,
14674 + struct iw_request_info *info,
14675 + struct iw_param *rrq, char *extra)
14676 +{
14677 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14678 + p80211item_uint32_t mibitem;
14679 + p80211msg_dot11req_mibset_t msg;
14680 + int result;
14681 + int err = 0;
14682 +
14683 + DBFENTER;
14684 +
14685 + msg.msgcode = DIDmsg_dot11req_mibget;
14686 + mibitem.did = DIDmib_p2_p2MAC_p2CurrentTxRate;
14687 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14688 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14689 +
14690 + if (result) {
14691 + err = -EFAULT;
14692 + goto exit;
14693 + }
14694 +
14695 + memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
14696 +
14697 + rrq->fixed = 0; /* can it change? */
14698 + rrq->disabled = 0;
14699 + rrq->value = 0;
14700 +
14701 +#define HFA384x_RATEBIT_1 ((u16)1)
14702 +#define HFA384x_RATEBIT_2 ((u16)2)
14703 +#define HFA384x_RATEBIT_5dot5 ((u16)4)
14704 +#define HFA384x_RATEBIT_11 ((u16)8)
14705 +
14706 + switch (mibitem.data) {
14707 + case HFA384x_RATEBIT_1:
14708 + rrq->value = 1000000;
14709 + break;
14710 + case HFA384x_RATEBIT_2:
14711 + rrq->value = 2000000;
14712 + break;
14713 + case HFA384x_RATEBIT_5dot5:
14714 + rrq->value = 5500000;
14715 + break;
14716 + case HFA384x_RATEBIT_11:
14717 + rrq->value = 11000000;
14718 + break;
14719 + default:
14720 + err = -EINVAL;
14721 + }
14722 + exit:
14723 + DBFEXIT;
14724 + return err;
14725 +}
14726 +
14727 +static int p80211wext_giwrts(netdevice_t *dev,
14728 + struct iw_request_info *info,
14729 + struct iw_param *rts, char *extra)
14730 +{
14731 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14732 + p80211item_uint32_t mibitem;
14733 + p80211msg_dot11req_mibset_t msg;
14734 + int result;
14735 + int err = 0;
14736 +
14737 + DBFENTER;
14738 +
14739 + msg.msgcode = DIDmsg_dot11req_mibget;
14740 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold;
14741 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14742 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14743 +
14744 + if (result) {
14745 + err = -EFAULT;
14746 + goto exit;
14747 + }
14748 +
14749 + memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
14750 +
14751 + rts->value = mibitem.data;
14752 + rts->disabled = (rts->value == 2347);
14753 + rts->fixed = 1;
14754 +
14755 + exit:
14756 + DBFEXIT;
14757 + return err;
14758 +}
14759 +
14760 +
14761 +static int p80211wext_siwrts(netdevice_t *dev,
14762 + struct iw_request_info *info,
14763 + struct iw_param *rts, char *extra)
14764 +{
14765 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14766 + p80211item_uint32_t mibitem;
14767 + p80211msg_dot11req_mibset_t msg;
14768 + int result;
14769 + int err = 0;
14770 +
14771 + DBFENTER;
14772 +
14773 + if (!wlan_wext_write) {
14774 + err = (-EOPNOTSUPP);
14775 + goto exit;
14776 + }
14777 +
14778 + msg.msgcode = DIDmsg_dot11req_mibget;
14779 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold;
14780 + if (rts->disabled)
14781 + mibitem.data = 2347;
14782 + else
14783 + mibitem.data = rts->value;
14784 +
14785 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14786 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14787 +
14788 + if (result) {
14789 + err = -EFAULT;
14790 + goto exit;
14791 + }
14792 +
14793 + exit:
14794 + DBFEXIT;
14795 + return err;
14796 +}
14797 +
14798 +static int p80211wext_giwfrag(netdevice_t *dev,
14799 + struct iw_request_info *info,
14800 + struct iw_param *frag, char *extra)
14801 +{
14802 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14803 + p80211item_uint32_t mibitem;
14804 + p80211msg_dot11req_mibset_t msg;
14805 + int result;
14806 + int err = 0;
14807 +
14808 + DBFENTER;
14809 +
14810 + msg.msgcode = DIDmsg_dot11req_mibget;
14811 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold;
14812 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14813 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14814 +
14815 + if (result) {
14816 + err = -EFAULT;
14817 + goto exit;
14818 + }
14819 +
14820 + memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
14821 +
14822 + frag->value = mibitem.data;
14823 + frag->disabled = (frag->value == 2346);
14824 + frag->fixed = 1;
14825 +
14826 + exit:
14827 + DBFEXIT;
14828 + return err;
14829 +}
14830 +
14831 +static int p80211wext_siwfrag(netdevice_t *dev,
14832 + struct iw_request_info *info,
14833 + struct iw_param *frag, char *extra)
14834 +{
14835 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14836 + p80211item_uint32_t mibitem;
14837 + p80211msg_dot11req_mibset_t msg;
14838 + int result;
14839 + int err = 0;
14840 +
14841 + DBFENTER;
14842 +
14843 + if (!wlan_wext_write) {
14844 + err = (-EOPNOTSUPP);
14845 + goto exit;
14846 + }
14847 +
14848 + msg.msgcode = DIDmsg_dot11req_mibset;
14849 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold;
14850 +
14851 + if (frag->disabled)
14852 + mibitem.data = 2346;
14853 + else
14854 + mibitem.data = frag->value;
14855 +
14856 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14857 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14858 +
14859 + if (result) {
14860 + err = -EFAULT;
14861 + goto exit;
14862 + }
14863 +
14864 + exit:
14865 + DBFEXIT;
14866 + return err;
14867 +}
14868 +
14869 +#ifndef IW_RETRY_LONG
14870 +#define IW_RETRY_LONG IW_RETRY_MAX
14871 +#endif
14872 +
14873 +#ifndef IW_RETRY_SHORT
14874 +#define IW_RETRY_SHORT IW_RETRY_MIN
14875 +#endif
14876 +
14877 +static int p80211wext_giwretry(netdevice_t *dev,
14878 + struct iw_request_info *info,
14879 + struct iw_param *rrq, char *extra)
14880 +{
14881 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14882 + p80211item_uint32_t mibitem;
14883 + p80211msg_dot11req_mibset_t msg;
14884 + int result;
14885 + int err = 0;
14886 + u16 shortretry, longretry, lifetime;
14887 +
14888 + DBFENTER;
14889 +
14890 + msg.msgcode = DIDmsg_dot11req_mibget;
14891 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit;
14892 +
14893 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14894 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14895 +
14896 + if (result) {
14897 + err = -EFAULT;
14898 + goto exit;
14899 + }
14900 +
14901 + memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
14902 +
14903 + shortretry = mibitem.data;
14904 +
14905 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit;
14906 +
14907 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14908 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14909 +
14910 + if (result) {
14911 + err = -EFAULT;
14912 + goto exit;
14913 + }
14914 +
14915 + memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
14916 +
14917 + longretry = mibitem.data;
14918 +
14919 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime;
14920 +
14921 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14922 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14923 +
14924 + if (result) {
14925 + err = -EFAULT;
14926 + goto exit;
14927 + }
14928 +
14929 + memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
14930 +
14931 + lifetime = mibitem.data;
14932 +
14933 + rrq->disabled = 0;
14934 +
14935 + if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
14936 + rrq->flags = IW_RETRY_LIFETIME;
14937 + rrq->value = lifetime * 1024;
14938 + } else {
14939 + if (rrq->flags & IW_RETRY_LONG) {
14940 + rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
14941 + rrq->value = longretry;
14942 + } else {
14943 + rrq->flags = IW_RETRY_LIMIT;
14944 + rrq->value = shortretry;
14945 + if (shortretry != longretry)
14946 + rrq->flags |= IW_RETRY_SHORT;
14947 + }
14948 + }
14949 +
14950 + exit:
14951 + DBFEXIT;
14952 + return err;
14953 +
14954 +}
14955 +
14956 +static int p80211wext_siwretry(netdevice_t *dev,
14957 + struct iw_request_info *info,
14958 + struct iw_param *rrq, char *extra)
14959 +{
14960 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
14961 + p80211item_uint32_t mibitem;
14962 + p80211msg_dot11req_mibset_t msg;
14963 + int result;
14964 + int err = 0;
14965 +
14966 + DBFENTER;
14967 +
14968 + if (!wlan_wext_write) {
14969 + err = (-EOPNOTSUPP);
14970 + goto exit;
14971 + }
14972 +
14973 + if (rrq->disabled) {
14974 + err = -EINVAL;
14975 + goto exit;
14976 + }
14977 +
14978 + msg.msgcode = DIDmsg_dot11req_mibset;
14979 +
14980 + if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
14981 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime;
14982 + mibitem.data = rrq->value /= 1024;
14983 +
14984 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14985 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14986 +
14987 + if (result) {
14988 + err = -EFAULT;
14989 + goto exit;
14990 + }
14991 + } else {
14992 + if (rrq->flags & IW_RETRY_LONG) {
14993 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit;
14994 + mibitem.data = rrq->value;
14995 +
14996 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
14997 + result = p80211req_dorequest(wlandev, (u8*)&msg);
14998 +
14999 + if (result) {
15000 + err = -EFAULT;
15001 + goto exit;
15002 + }
15003 + }
15004 +
15005 + if (rrq->flags & IW_RETRY_SHORT) {
15006 + mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit;
15007 + mibitem.data = rrq->value;
15008 +
15009 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
15010 + result = p80211req_dorequest(wlandev, (u8*)&msg);
15011 +
15012 + if (result) {
15013 + err = -EFAULT;
15014 + goto exit;
15015 + }
15016 + }
15017 + }
15018 +
15019 + exit:
15020 + DBFEXIT;
15021 + return err;
15022 +
15023 +}
15024 +
15025 +static int p80211wext_siwtxpow(netdevice_t *dev,
15026 + struct iw_request_info *info,
15027 + struct iw_param *rrq, char *extra)
15028 +{
15029 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15030 + p80211item_uint32_t mibitem;
15031 + p80211msg_dot11req_mibset_t msg;
15032 + int result;
15033 + int err = 0;
15034 +
15035 + DBFENTER;
15036 +
15037 + if (!wlan_wext_write) {
15038 + err = (-EOPNOTSUPP);
15039 + goto exit;
15040 + }
15041 +
15042 + msg.msgcode = DIDmsg_dot11req_mibset;
15043 + mibitem.did = DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
15044 + if (rrq->fixed == 0)
15045 + mibitem.data = 30;
15046 + else
15047 + mibitem.data = rrq->value;
15048 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
15049 + result = p80211req_dorequest(wlandev, (u8*)&msg);
15050 +
15051 + if (result) {
15052 + err = -EFAULT;
15053 + goto exit;
15054 + }
15055 +
15056 + exit:
15057 + DBFEXIT;
15058 + return err;
15059 +}
15060 +
15061 +static int p80211wext_giwtxpow(netdevice_t *dev,
15062 + struct iw_request_info *info,
15063 + struct iw_param *rrq, char *extra)
15064 +{
15065 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15066 + p80211item_uint32_t mibitem;
15067 + p80211msg_dot11req_mibset_t msg;
15068 + int result;
15069 + int err = 0;
15070 +
15071 + DBFENTER;
15072 +
15073 + msg.msgcode = DIDmsg_dot11req_mibget;
15074 + mibitem.did = DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
15075 +
15076 + memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem));
15077 + result = p80211req_dorequest(wlandev, (u8*)&msg);
15078 +
15079 + if (result) {
15080 + err = -EFAULT;
15081 + goto exit;
15082 + }
15083 +
15084 + memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem));
15085 +
15086 + // XXX handle OFF by setting disabled = 1;
15087 +
15088 + rrq->flags = 0; // IW_TXPOW_DBM;
15089 + rrq->disabled = 0;
15090 + rrq->fixed = 0;
15091 + rrq->value = mibitem.data;
15092 +
15093 + exit:
15094 + DBFEXIT;
15095 + return err;
15096 +}
15097 +
15098 +static int p80211wext_siwspy(netdevice_t *dev,
15099 + struct iw_request_info *info,
15100 + struct iw_point *srq, char *extra)
15101 +{
15102 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15103 + struct sockaddr address[IW_MAX_SPY];
15104 + int number = srq->length;
15105 + int i;
15106 +
15107 + DBFENTER;
15108 +
15109 + /* Copy the data from the input buffer */
15110 + memcpy(address, extra, sizeof(struct sockaddr)*number);
15111 +
15112 + wlandev->spy_number = 0;
15113 +
15114 + if (number > 0) {
15115 +
15116 + /* extract the addresses */
15117 + for (i = 0; i < number; i++) {
15118 +
15119 + memcpy(wlandev->spy_address[i], address[i].sa_data, ETH_ALEN);
15120 + }
15121 +
15122 + /* reset stats */
15123 + memset(wlandev->spy_stat, 0, sizeof(struct iw_quality) * IW_MAX_SPY);
15124 +
15125 + /* set number of addresses */
15126 + wlandev->spy_number = number;
15127 + }
15128 +
15129 + DBFEXIT;
15130 + return 0;
15131 +}
15132 +
15133 +/* jkriegl: from orinoco, modified */
15134 +static int p80211wext_giwspy(netdevice_t *dev,
15135 + struct iw_request_info *info,
15136 + struct iw_point *srq, char *extra)
15137 +{
15138 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15139 +
15140 + struct sockaddr address[IW_MAX_SPY];
15141 + struct iw_quality spy_stat[IW_MAX_SPY];
15142 + int number;
15143 + int i;
15144 +
15145 + DBFENTER;
15146 +
15147 + number = wlandev->spy_number;
15148 +
15149 + if (number > 0) {
15150 +
15151 + /* populate address and spy struct's */
15152 + for (i = 0; i < number; i++) {
15153 + memcpy(address[i].sa_data, wlandev->spy_address[i], ETH_ALEN);
15154 + address[i].sa_family = AF_UNIX;
15155 + memcpy(&spy_stat[i], &wlandev->spy_stat[i], sizeof(struct iw_quality));
15156 + }
15157 +
15158 + /* reset update flag */
15159 + for (i=0; i < number; i++)
15160 + wlandev->spy_stat[i].updated = 0;
15161 + }
15162 +
15163 + /* push stuff to user space */
15164 + srq->length = number;
15165 + memcpy(extra, address, sizeof(struct sockaddr)*number);
15166 + memcpy(extra+sizeof(struct sockaddr)*number, spy_stat, sizeof(struct iw_quality)*number);
15167 +
15168 + DBFEXIT;
15169 + return 0;
15170 +}
15171 +
15172 +static int prism2_result2err (int prism2_result)
15173 +{
15174 + int err = 0;
15175 +
15176 + switch (prism2_result) {
15177 + case P80211ENUM_resultcode_invalid_parameters:
15178 + err = -EINVAL;
15179 + break;
15180 + case P80211ENUM_resultcode_implementation_failure:
15181 + err = -EIO;
15182 + break;
15183 + case P80211ENUM_resultcode_not_supported:
15184 + err = -EOPNOTSUPP;
15185 + break;
15186 + default:
15187 + err = 0;
15188 + break;
15189 + }
15190 +
15191 + return err;
15192 +}
15193 +
15194 +static int p80211wext_siwscan(netdevice_t *dev,
15195 + struct iw_request_info *info,
15196 + struct iw_point *srq, char *extra)
15197 +{
15198 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15199 + p80211msg_dot11req_scan_t msg;
15200 + int result;
15201 + int err = 0;
15202 + int i = 0;
15203 +
15204 + DBFENTER;
15205 +
15206 + if (wlandev->macmode == WLAN_MACMODE_ESS_AP) {
15207 + WLAN_LOG_ERROR("Can't scan in AP mode\n");
15208 + err = (-EOPNOTSUPP);
15209 + goto exit;
15210 + }
15211 +
15212 + memset(&msg, 0x00, sizeof(p80211msg_dot11req_scan_t));
15213 + msg.msgcode = DIDmsg_dot11req_scan;
15214 + msg.bsstype.data = P80211ENUM_bsstype_any;
15215 +
15216 + memset(&(msg.bssid.data), 0xFF, sizeof (p80211item_pstr6_t));
15217 + msg.bssid.data.len = 6;
15218 +
15219 + msg.scantype.data = P80211ENUM_scantype_active;
15220 + msg.probedelay.data = 0;
15221 +
15222 + for (i = 1; i <= 14; i++)
15223 + msg.channellist.data.data[i-1] = i;
15224 + msg.channellist.data.len = 14;
15225 +
15226 + msg.maxchanneltime.data = 250;
15227 + msg.minchanneltime.data = 200;
15228 +
15229 + result = p80211req_dorequest(wlandev, (u8*)&msg);
15230 + if (result)
15231 + err = prism2_result2err (msg.resultcode.data);
15232 +
15233 + exit:
15234 + DBFEXIT;
15235 + return err;
15236 +}
15237 +
15238 +
15239 +/* Helper to translate scan into Wireless Extensions scan results.
15240 + * Inspired by the prism54 code, which was in turn inspired by the
15241 + * airo driver code.
15242 + */
15243 +static char *
15244 +wext_translate_bss(struct iw_request_info *info, char *current_ev,
15245 + char *end_buf, p80211msg_dot11req_scan_results_t *bss)
15246 +{
15247 + struct iw_event iwe; /* Temporary buffer */
15248 +
15249 + /* The first entry must be the MAC address */
15250 + memcpy(iwe.u.ap_addr.sa_data, bss->bssid.data.data, WLAN_BSSID_LEN);
15251 + iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
15252 + iwe.cmd = SIOCGIWAP;
15253 + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
15254 +
15255 + /* The following entries will be displayed in the same order we give them */
15256 +
15257 + /* The ESSID. */
15258 + if (bss->ssid.data.len > 0) {
15259 + char essid[IW_ESSID_MAX_SIZE + 1];
15260 + int size;
15261 +
15262 + size = wlan_min(IW_ESSID_MAX_SIZE, bss->ssid.data.len);
15263 + memset(&essid, 0, sizeof (essid));
15264 + memcpy(&essid, bss->ssid.data.data, size);
15265 + WLAN_LOG_DEBUG(1, " essid size = %d\n", size);
15266 + iwe.u.data.length = size;
15267 + iwe.u.data.flags = 1;
15268 + iwe.cmd = SIOCGIWESSID;
15269 + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &essid[0]);
15270 + WLAN_LOG_DEBUG(1, " essid size OK.\n");
15271 + }
15272 +
15273 + switch (bss->bsstype.data) {
15274 + case P80211ENUM_bsstype_infrastructure:
15275 + iwe.u.mode = IW_MODE_MASTER;
15276 + break;
15277 +
15278 + case P80211ENUM_bsstype_independent:
15279 + iwe.u.mode = IW_MODE_ADHOC;
15280 + break;
15281 +
15282 + default:
15283 + iwe.u.mode = 0;
15284 + break;
15285 + }
15286 + iwe.cmd = SIOCGIWMODE;
15287 + if (iwe.u.mode)
15288 + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
15289 +
15290 + /* Encryption capability */
15291 + if (bss->privacy.data == P80211ENUM_truth_true)
15292 + iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
15293 + else
15294 + iwe.u.data.flags = IW_ENCODE_DISABLED;
15295 + iwe.u.data.length = 0;
15296 + iwe.cmd = SIOCGIWENCODE;
15297 + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, NULL);
15298 +
15299 + /* Add frequency. (short) bss->channel is the frequency in MHz */
15300 + iwe.u.freq.m = bss->dschannel.data;
15301 + iwe.u.freq.e = 0;
15302 + iwe.cmd = SIOCGIWFREQ;
15303 + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
15304 +
15305 + /* Add quality statistics */
15306 + iwe.u.qual.level = bss->signal.data;
15307 + iwe.u.qual.noise = bss->noise.data;
15308 + /* do a simple SNR for quality */
15309 + iwe.u.qual.qual = qual_as_percent(bss->signal.data - bss->noise.data);
15310 + iwe.cmd = IWEVQUAL;
15311 + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
15312 +
15313 + return current_ev;
15314 +}
15315 +
15316 +
15317 +static int p80211wext_giwscan(netdevice_t *dev,
15318 + struct iw_request_info *info,
15319 + struct iw_point *srq, char *extra)
15320 +{
15321 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15322 + p80211msg_dot11req_scan_results_t msg;
15323 + int result = 0;
15324 + int err = 0;
15325 + int i = 0;
15326 + int scan_good = 0;
15327 + char *current_ev = extra;
15328 +
15329 + DBFENTER;
15330 +
15331 + /* Since wireless tools doesn't really have a way of passing how
15332 + * many scan results results there were back here, keep grabbing them
15333 + * until we fail.
15334 + */
15335 + do {
15336 + memset(&msg, 0, sizeof(msg));
15337 + msg.msgcode = DIDmsg_dot11req_scan_results;
15338 + msg.bssindex.data = i;
15339 +
15340 + result = p80211req_dorequest(wlandev, (u8*)&msg);
15341 + if ((result != 0) ||
15342 + (msg.resultcode.data != P80211ENUM_resultcode_success)) {
15343 + break;
15344 + }
15345 +
15346 + current_ev = wext_translate_bss(info, current_ev, extra + IW_SCAN_MAX_DATA, &msg);
15347 + scan_good = 1;
15348 + i++;
15349 + } while (i < IW_MAX_AP);
15350 +
15351 + srq->length = (current_ev - extra);
15352 + srq->flags = 0; /* todo */
15353 +
15354 + if (result && !scan_good)
15355 + err = prism2_result2err (msg.resultcode.data);
15356 +
15357 + DBFEXIT;
15358 + return err;
15359 +}
15360 +
15361 +/*****************************************************/
15362 +//extra wireless extensions stuff to support NetworkManager (I hope)
15363 +
15364 +/* SIOCSIWENCODEEXT */
15365 +static int p80211wext_set_encodeext(struct net_device *dev,
15366 + struct iw_request_info *info,
15367 + union iwreq_data *wrqu, char *extra)
15368 +{
15369 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15370 + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
15371 + p80211msg_dot11req_mibset_t msg;
15372 + p80211item_pstr32_t *pstr;
15373 +
15374 + int result = 0;
15375 + struct iw_point *encoding = &wrqu->encoding;
15376 + int idx = encoding->flags & IW_ENCODE_INDEX;
15377 +
15378 + WLAN_LOG_DEBUG(1,"set_encode_ext flags[%d] alg[%d] keylen[%d]\n",ext->ext_flags,(int)ext->alg,(int)ext->key_len);
15379 +
15380 +
15381 + if ( ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY ) {
15382 + // set default key ? I'm not sure if this the the correct thing to do here
15383 +
15384 + if ( idx ) {
15385 + if (idx < 1 || idx > NUM_WEPKEYS) {
15386 + return -EINVAL;
15387 + } else
15388 + idx--;
15389 + }
15390 + WLAN_LOG_DEBUG(1,"setting default key (%d)\n",idx);
15391 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, idx);
15392 + if ( result )
15393 + return -EFAULT;
15394 + }
15395 +
15396 +
15397 + if ( ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY ) {
15398 + if (!(ext->alg & IW_ENCODE_ALG_WEP)) {
15399 + WLAN_LOG_DEBUG(1,"asked to set a non wep key :(");
15400 + return -EINVAL;
15401 + }
15402 + if (idx) {
15403 + if (idx <1 || idx > NUM_WEPKEYS)
15404 + return -EINVAL;
15405 + else
15406 + idx--;
15407 + }
15408 + WLAN_LOG_DEBUG(1,"Set WEP key (%d)\n",idx);
15409 + wlandev->wep_keylens[idx] = ext->key_len;
15410 + memcpy(wlandev->wep_keys[idx], ext->key, ext->key_len);
15411 +
15412 + memset( &msg,0,sizeof(msg));
15413 + pstr = (p80211item_pstr32_t*)&msg.mibattribute.data;
15414 + memcpy(pstr->data.data, ext->key,ext->key_len);
15415 + pstr->data.len = ext->key_len;
15416 + switch (idx) {
15417 + case 0:
15418 + pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
15419 + break;
15420 + case 1:
15421 + pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
15422 + break;
15423 + case 2:
15424 + pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
15425 + break;
15426 + case 3:
15427 + pstr->did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
15428 + break;
15429 + default:
15430 + break;
15431 + }
15432 + msg.msgcode = DIDmsg_dot11req_mibset;
15433 + result = p80211req_dorequest(wlandev,(u8*)&msg);
15434 + WLAN_LOG_DEBUG(1,"result (%d)\n",result);
15435 + }
15436 + return result;
15437 +}
15438 +
15439 +/* SIOCGIWENCODEEXT */
15440 +static int p80211wext_get_encodeext(struct net_device *dev,
15441 + struct iw_request_info *info,
15442 + union iwreq_data *wrqu, char *extra)
15443 +
15444 +{
15445 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15446 + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
15447 +
15448 + struct iw_point *encoding = &wrqu->encoding;
15449 + int result = 0;
15450 + int max_len;
15451 + int idx;
15452 +
15453 + DBFENTER;
15454 +
15455 + WLAN_LOG_DEBUG(1,"get_encode_ext flags[%d] alg[%d] keylen[%d]\n",ext->ext_flags,(int)ext->alg,(int)ext->key_len);
15456 +
15457 +
15458 + max_len = encoding->length - sizeof(*ext);
15459 + if ( max_len <= 0) {
15460 + WLAN_LOG_DEBUG(1,"get_encodeext max_len [%d] invalid\n",max_len);
15461 + result = -EINVAL;
15462 + goto exit;
15463 + }
15464 + idx = encoding->flags & IW_ENCODE_INDEX;
15465 +
15466 + WLAN_LOG_DEBUG(1,"get_encode_ext index [%d]\n",idx);
15467 +
15468 + if (idx) {
15469 + if (idx < 1 || idx > NUM_WEPKEYS ) {
15470 + WLAN_LOG_DEBUG(1,"get_encode_ext invalid key index [%d]\n",idx);
15471 + result = -EINVAL;
15472 + goto exit;
15473 + }
15474 + idx--;
15475 + } else {
15476 + /* default key ? not sure what to do */
15477 + /* will just use key[0] for now ! FIX ME */
15478 + }
15479 +
15480 + encoding->flags = idx + 1;
15481 + memset(ext,0,sizeof(*ext));
15482 +
15483 + ext->alg = IW_ENCODE_ALG_WEP;
15484 + ext->key_len = wlandev->wep_keylens[idx];
15485 + memcpy( ext->key, wlandev->wep_keys[idx] , ext->key_len );
15486 +
15487 + encoding->flags |= IW_ENCODE_ENABLED;
15488 +exit:
15489 + DBFEXIT;
15490 +
15491 + return result;
15492 +}
15493 +
15494 +
15495 +/* SIOCSIWAUTH */
15496 +static int p80211_wext_set_iwauth (struct net_device *dev,
15497 + struct iw_request_info *info,
15498 + union iwreq_data *wrqu, char *extra)
15499 +{
15500 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15501 + struct iw_param *param = &wrqu->param;
15502 + int result =0;
15503 +
15504 + WLAN_LOG_DEBUG(1,"set_iwauth flags[%d]\n",(int)param->flags & IW_AUTH_INDEX );
15505 +
15506 + switch (param->flags & IW_AUTH_INDEX) {
15507 + case IW_AUTH_DROP_UNENCRYPTED:
15508 + WLAN_LOG_DEBUG(1,"drop_unencrypted %d\n",param->value);
15509 + if (param->value)
15510 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true);
15511 + else
15512 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false);
15513 + break;
15514 +
15515 + case IW_AUTH_PRIVACY_INVOKED:
15516 + WLAN_LOG_DEBUG(1,"privacy invoked %d\n",param->value);
15517 + if ( param->value)
15518 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true);
15519 + else
15520 + result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false);
15521 +
15522 + break;
15523 +
15524 + case IW_AUTH_80211_AUTH_ALG:
15525 + if ( param->value & IW_AUTH_ALG_OPEN_SYSTEM ) {
15526 + WLAN_LOG_DEBUG(1,"set open_system\n");
15527 + wlandev->hostwep &= ~HOSTWEP_SHAREDKEY;
15528 + } else if ( param->value & IW_AUTH_ALG_SHARED_KEY) {
15529 + WLAN_LOG_DEBUG(1,"set shared key\n");
15530 + wlandev->hostwep |= HOSTWEP_SHAREDKEY;
15531 + } else {
15532 + /* don't know what to do know :( */
15533 + WLAN_LOG_DEBUG(1,"unknown AUTH_ALG (%d)\n",param->value);
15534 + result = -EINVAL;
15535 + }
15536 + break;
15537 +
15538 + default:
15539 + break;
15540 + }
15541 +
15542 +
15543 +
15544 + return result;
15545 +}
15546 +
15547 +/* SIOCSIWAUTH */
15548 +static int p80211_wext_get_iwauth (struct net_device *dev,
15549 + struct iw_request_info *info,
15550 + union iwreq_data *wrqu, char *extra)
15551 +{
15552 + wlandevice_t *wlandev = (wlandevice_t*)dev->priv;
15553 + struct iw_param *param = &wrqu->param;
15554 + int result =0;
15555 +
15556 + WLAN_LOG_DEBUG(1,"get_iwauth flags[%d]\n",(int)param->flags & IW_AUTH_INDEX );
15557 +
15558 + switch (param->flags & IW_AUTH_INDEX) {
15559 + case IW_AUTH_DROP_UNENCRYPTED:
15560 + param->value = wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED?1:0;
15561 + break;
15562 +
15563 + case IW_AUTH_PRIVACY_INVOKED:
15564 + param->value = wlandev->hostwep & HOSTWEP_PRIVACYINVOKED?1:0;
15565 + break;
15566 +
15567 + case IW_AUTH_80211_AUTH_ALG:
15568 + param->value = wlandev->hostwep & HOSTWEP_SHAREDKEY?IW_AUTH_ALG_SHARED_KEY:IW_AUTH_ALG_OPEN_SYSTEM;
15569 + break;
15570 +
15571 +
15572 + default:
15573 + break;
15574 + }
15575 +
15576 +
15577 +
15578 + return result;
15579 +}
15580 +
15581 +static iw_handler p80211wext_handlers[] = {
15582 + (iw_handler) p80211wext_siwcommit, /* SIOCSIWCOMMIT */
15583 + (iw_handler) p80211wext_giwname, /* SIOCGIWNAME */
15584 + (iw_handler) NULL, /* SIOCSIWNWID */
15585 + (iw_handler) NULL, /* SIOCGIWNWID */
15586 + (iw_handler) p80211wext_siwfreq, /* SIOCSIWFREQ */
15587 + (iw_handler) p80211wext_giwfreq, /* SIOCGIWFREQ */
15588 + (iw_handler) p80211wext_siwmode, /* SIOCSIWMODE */
15589 + (iw_handler) p80211wext_giwmode, /* SIOCGIWMODE */
15590 + (iw_handler) NULL, /* SIOCSIWSENS */
15591 + (iw_handler) NULL, /* SIOCGIWSENS */
15592 + (iw_handler) NULL, /* not used */ /* SIOCSIWRANGE */
15593 + (iw_handler) p80211wext_giwrange, /* SIOCGIWRANGE */
15594 + (iw_handler) NULL, /* not used */ /* SIOCSIWPRIV */
15595 + (iw_handler) NULL, /* kernel code */ /* SIOCGIWPRIV */
15596 + (iw_handler) NULL, /* not used */ /* SIOCSIWSTATS */
15597 + (iw_handler) NULL, /* kernel code */ /* SIOCGIWSTATS */
15598 + (iw_handler) p80211wext_siwspy, /* SIOCSIWSPY */
15599 + (iw_handler) p80211wext_giwspy, /* SIOCGIWSPY */
15600 + (iw_handler) NULL, /* -- hole -- */
15601 + (iw_handler) NULL, /* -- hole -- */
15602 + (iw_handler) NULL, /* SIOCSIWAP */
15603 + (iw_handler) p80211wext_giwap, /* SIOCGIWAP */
15604 + (iw_handler) NULL, /* -- hole -- */
15605 + (iw_handler) NULL, /* SIOCGIWAPLIST */
15606 + (iw_handler) p80211wext_siwscan, /* SIOCSIWSCAN */
15607 + (iw_handler) p80211wext_giwscan, /* SIOCGIWSCAN */
15608 + (iw_handler) p80211wext_siwessid, /* SIOCSIWESSID */
15609 + (iw_handler) p80211wext_giwessid, /* SIOCGIWESSID */
15610 + (iw_handler) NULL, /* SIOCSIWNICKN */
15611 + (iw_handler) p80211wext_giwessid, /* SIOCGIWNICKN */
15612 + (iw_handler) NULL, /* -- hole -- */
15613 + (iw_handler) NULL, /* -- hole -- */
15614 + (iw_handler) NULL, /* SIOCSIWRATE */
15615 + (iw_handler) p80211wext_giwrate, /* SIOCGIWRATE */
15616 + (iw_handler) p80211wext_siwrts, /* SIOCSIWRTS */
15617 + (iw_handler) p80211wext_giwrts, /* SIOCGIWRTS */
15618 + (iw_handler) p80211wext_siwfrag, /* SIOCSIWFRAG */
15619 + (iw_handler) p80211wext_giwfrag, /* SIOCGIWFRAG */
15620 + (iw_handler) p80211wext_siwtxpow, /* SIOCSIWTXPOW */
15621 + (iw_handler) p80211wext_giwtxpow, /* SIOCGIWTXPOW */
15622 + (iw_handler) p80211wext_siwretry, /* SIOCSIWRETRY */
15623 + (iw_handler) p80211wext_giwretry, /* SIOCGIWRETRY */
15624 + (iw_handler) p80211wext_siwencode, /* SIOCSIWENCODE */
15625 + (iw_handler) p80211wext_giwencode, /* SIOCGIWENCODE */
15626 + (iw_handler) NULL, /* SIOCSIWPOWER */
15627 + (iw_handler) NULL, /* SIOCGIWPOWER */
15628 +/* WPA operations */
15629 + (iw_handler) NULL, /* -- hole -- */
15630 + (iw_handler) NULL, /* -- hole -- */
15631 + (iw_handler) NULL, /* SIOCSIWGENIE set generic IE */
15632 + (iw_handler) NULL, /* SIOCGIWGENIE get generic IE */
15633 + (iw_handler) p80211_wext_set_iwauth, /* SIOCSIWAUTH set authentication mode params */
15634 + (iw_handler) p80211_wext_get_iwauth, /* SIOCGIWAUTH get authentication mode params */
15635 +
15636 + (iw_handler) p80211wext_set_encodeext, /* SIOCSIWENCODEEXT set encoding token & mode */
15637 + (iw_handler) p80211wext_get_encodeext, /* SIOCGIWENCODEEXT get encoding token & mode */
15638 + (iw_handler) NULL, /* SIOCSIWPMKSA PMKSA cache operation */
15639 +};
15640 +
15641 +struct iw_handler_def p80211wext_handler_def = {
15642 + .num_standard = ARRAY_SIZE(p80211wext_handlers),
15643 + .num_private = 0,
15644 + .num_private_args = 0,
15645 + .standard = p80211wext_handlers,
15646 + .private = NULL,
15647 + .private_args = NULL,
15648 + .get_wireless_stats = p80211wext_get_wireless_stats
15649 +};
15650 +
15651 +int p80211wext_event_associated(wlandevice_t *wlandev, int assoc)
15652 +{
15653 + union iwreq_data data;
15654 +
15655 + DBFENTER;
15656 +
15657 + /* Send the association state first */
15658 + data.ap_addr.sa_family = ARPHRD_ETHER;
15659 + if (assoc) {
15660 + memcpy(data.ap_addr.sa_data, wlandev->bssid, WLAN_ADDR_LEN);
15661 + } else {
15662 + memset(data.ap_addr.sa_data, 0, WLAN_ADDR_LEN);
15663 + }
15664 +
15665 + if (wlan_wext_write)
15666 + wireless_send_event(wlandev->netdev, SIOCGIWAP, &data, NULL);
15667 +
15668 + if (!assoc) goto done;
15669 +
15670 + // XXX send association data, like IEs, etc etc.
15671 +
15672 + done:
15673 + DBFEXIT;
15674 + return 0;
15675 +}
15676 +
15677 +
15678 +
15679 +
15680 --- /dev/null
15681 +++ b/drivers/staging/wlan-ng/prism2mgmt.c
15682 @@ -0,0 +1,1363 @@
15683 +/* src/prism2/driver/prism2mgmt.c
15684 +*
15685 +* Management request handler functions.
15686 +*
15687 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
15688 +* --------------------------------------------------------------------
15689 +*
15690 +* linux-wlan
15691 +*
15692 +* The contents of this file are subject to the Mozilla Public
15693 +* License Version 1.1 (the "License"); you may not use this file
15694 +* except in compliance with the License. You may obtain a copy of
15695 +* the License at http://www.mozilla.org/MPL/
15696 +*
15697 +* Software distributed under the License is distributed on an "AS
15698 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15699 +* implied. See the License for the specific language governing
15700 +* rights and limitations under the License.
15701 +*
15702 +* Alternatively, the contents of this file may be used under the
15703 +* terms of the GNU Public License version 2 (the "GPL"), in which
15704 +* case the provisions of the GPL are applicable instead of the
15705 +* above. If you wish to allow the use of your version of this file
15706 +* only under the terms of the GPL and not to allow others to use
15707 +* your version of this file under the MPL, indicate your decision
15708 +* by deleting the provisions above and replace them with the notice
15709 +* and other provisions required by the GPL. If you do not delete
15710 +* the provisions above, a recipient may use your version of this
15711 +* file under either the MPL or the GPL.
15712 +*
15713 +* --------------------------------------------------------------------
15714 +*
15715 +* Inquiries regarding the linux-wlan Open Source project can be
15716 +* made directly to:
15717 +*
15718 +* AbsoluteValue Systems Inc.
15719 +* info@linux-wlan.com
15720 +* http://www.linux-wlan.com
15721 +*
15722 +* --------------------------------------------------------------------
15723 +*
15724 +* Portions of the development of this software were funded by
15725 +* Intersil Corporation as part of PRISM(R) chipset product development.
15726 +*
15727 +* --------------------------------------------------------------------
15728 +*
15729 +* The functions in this file handle management requests sent from
15730 +* user mode.
15731 +*
15732 +* Most of these functions have two separate blocks of code that are
15733 +* conditional on whether this is a station or an AP. This is used
15734 +* to separate out the STA and AP responses to these management primitives.
15735 +* It's a choice (good, bad, indifferent?) to have the code in the same
15736 +* place so it's clear that the same primitive is implemented in both
15737 +* cases but has different behavior.
15738 +*
15739 +* --------------------------------------------------------------------
15740 +*/
15741 +
15742 +/*================================================================*/
15743 +/* System Includes */
15744 +#define WLAN_DBVAR prism2_debug
15745 +
15746 +
15747 +#include <linux/if_arp.h>
15748 +#include <linux/module.h>
15749 +#include <linux/kernel.h>
15750 +#include <linux/wait.h>
15751 +#include <linux/sched.h>
15752 +#include <linux/types.h>
15753 +#include <linux/slab.h>
15754 +#include <linux/wireless.h>
15755 +#include <linux/netdevice.h>
15756 +#include <linux/delay.h>
15757 +#include <asm/io.h>
15758 +#include <asm/byteorder.h>
15759 +#include <linux/random.h>
15760 +#include <linux/usb.h>
15761 +
15762 +#include "wlan_compat.h"
15763 +
15764 +/*================================================================*/
15765 +/* Project Includes */
15766 +
15767 +#include "p80211types.h"
15768 +#include "p80211hdr.h"
15769 +#include "p80211mgmt.h"
15770 +#include "p80211conv.h"
15771 +#include "p80211msg.h"
15772 +#include "p80211netdev.h"
15773 +#include "p80211metadef.h"
15774 +#include "p80211metastruct.h"
15775 +#include "hfa384x.h"
15776 +#include "prism2mgmt.h"
15777 +
15778 +/* Converts 802.11 format rate specifications to prism2 */
15779 +#define p80211rate_to_p2bit(n) ((((n)&~BIT7) == 2) ? BIT0 : \
15780 + (((n)&~BIT7) == 4) ? BIT1 : \
15781 + (((n)&~BIT7) == 11) ? BIT2 : \
15782 + (((n)&~BIT7) == 22) ? BIT3 : 0)
15783 +
15784 +/*----------------------------------------------------------------
15785 +* prism2mgmt_scan
15786 +*
15787 +* Initiate a scan for BSSs.
15788 +*
15789 +* This function corresponds to MLME-scan.request and part of
15790 +* MLME-scan.confirm. As far as I can tell in the standard, there
15791 +* are no restrictions on when a scan.request may be issued. We have
15792 +* to handle in whatever state the driver/MAC happen to be.
15793 +*
15794 +* Arguments:
15795 +* wlandev wlan device structure
15796 +* msgp ptr to msg buffer
15797 +*
15798 +* Returns:
15799 +* 0 success and done
15800 +* <0 success, but we're waiting for something to finish.
15801 +* >0 an error occurred while handling the message.
15802 +* Side effects:
15803 +*
15804 +* Call context:
15805 +* process thread (usually)
15806 +* interrupt
15807 +----------------------------------------------------------------*/
15808 +int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
15809 +{
15810 + int result = 0;
15811 + hfa384x_t *hw = wlandev->priv;
15812 + p80211msg_dot11req_scan_t *msg = msgp;
15813 + u16 roamingmode, word;
15814 + int i, timeout;
15815 + int istmpenable = 0;
15816 +
15817 + hfa384x_HostScanRequest_data_t scanreq;
15818 +
15819 + DBFENTER;
15820 +
15821 + /* gatekeeper check */
15822 + if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
15823 + hw->ident_sta_fw.minor,
15824 + hw->ident_sta_fw.variant) <
15825 + HFA384x_FIRMWARE_VERSION(1,3,2)) {
15826 + WLAN_LOG_ERROR("HostScan not supported with current firmware (<1.3.2).\n");
15827 + result = 1;
15828 + msg->resultcode.data = P80211ENUM_resultcode_not_supported;
15829 + goto exit;
15830 + }
15831 +
15832 + memset(&scanreq, 0, sizeof(scanreq));
15833 +
15834 + /* save current roaming mode */
15835 + result = hfa384x_drvr_getconfig16(hw,
15836 + HFA384x_RID_CNFROAMINGMODE, &roamingmode);
15837 + if ( result ) {
15838 + WLAN_LOG_ERROR("getconfig(ROAMMODE) failed. result=%d\n",
15839 + result);
15840 + msg->resultcode.data =
15841 + P80211ENUM_resultcode_implementation_failure;
15842 + goto exit;
15843 + }
15844 +
15845 + /* drop into mode 3 for the scan */
15846 + result = hfa384x_drvr_setconfig16(hw,
15847 + HFA384x_RID_CNFROAMINGMODE,
15848 + HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
15849 + if ( result ) {
15850 + WLAN_LOG_ERROR("setconfig(ROAMINGMODE) failed. result=%d\n",
15851 + result);
15852 + msg->resultcode.data =
15853 + P80211ENUM_resultcode_implementation_failure;
15854 + goto exit;
15855 + }
15856 +
15857 + /* active or passive? */
15858 + if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
15859 + hw->ident_sta_fw.minor,
15860 + hw->ident_sta_fw.variant) >
15861 + HFA384x_FIRMWARE_VERSION(1,5,0)) {
15862 + if (msg->scantype.data != P80211ENUM_scantype_active) {
15863 + word = host2hfa384x_16(msg->maxchanneltime.data);
15864 + } else {
15865 + word = 0;
15866 + }
15867 + result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL, word);
15868 + if ( result ) {
15869 + WLAN_LOG_WARNING("Passive scan not supported with "
15870 + "current firmware. (<1.5.1)\n");
15871 + }
15872 + }
15873 +
15874 + /* set up the txrate to be 2MBPS. Should be fastest basicrate... */
15875 + word = HFA384x_RATEBIT_2;
15876 + scanreq.txRate = host2hfa384x_16(word);
15877 +
15878 + /* set up the channel list */
15879 + word = 0;
15880 + for (i = 0; i < msg->channellist.data.len; i++) {
15881 + u8 channel = msg->channellist.data.data[i];
15882 + if (channel > 14) continue;
15883 + /* channel 1 is BIT0 ... channel 14 is BIT13 */
15884 + word |= (1 << (channel-1));
15885 + }
15886 + scanreq.channelList = host2hfa384x_16(word);
15887 +
15888 + /* set up the ssid, if present. */
15889 + scanreq.ssid.len = host2hfa384x_16(msg->ssid.data.len);
15890 + memcpy(scanreq.ssid.data, msg->ssid.data.data, msg->ssid.data.len);
15891 +
15892 + /* Enable the MAC port if it's not already enabled */
15893 + result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word);
15894 + if ( result ) {
15895 + WLAN_LOG_ERROR("getconfig(PORTSTATUS) failed. "
15896 + "result=%d\n", result);
15897 + msg->resultcode.data =
15898 + P80211ENUM_resultcode_implementation_failure;
15899 + goto exit;
15900 + }
15901 + if (word == HFA384x_PORTSTATUS_DISABLED) {
15902 + u16 wordbuf[17];
15903 +
15904 + result = hfa384x_drvr_setconfig16(hw,
15905 + HFA384x_RID_CNFROAMINGMODE,
15906 + HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
15907 + if ( result ) {
15908 + WLAN_LOG_ERROR("setconfig(ROAMINGMODE) failed. result=%d\n", result);
15909 + msg->resultcode.data =
15910 + P80211ENUM_resultcode_implementation_failure;
15911 + goto exit;
15912 + }
15913 + /* Construct a bogus SSID and assign it to OwnSSID and
15914 + * DesiredSSID
15915 + */
15916 + wordbuf[0] = host2hfa384x_16(WLAN_SSID_MAXLEN);
15917 + get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN);
15918 + result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
15919 + wordbuf, HFA384x_RID_CNFOWNSSID_LEN);
15920 + if ( result ) {
15921 + WLAN_LOG_ERROR("Failed to set OwnSSID.\n");
15922 + msg->resultcode.data =
15923 + P80211ENUM_resultcode_implementation_failure;
15924 + goto exit;
15925 + }
15926 + result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID,
15927 + wordbuf, HFA384x_RID_CNFDESIREDSSID_LEN);
15928 + if ( result ) {
15929 + WLAN_LOG_ERROR("Failed to set DesiredSSID.\n");
15930 + msg->resultcode.data =
15931 + P80211ENUM_resultcode_implementation_failure;
15932 + goto exit;
15933 + }
15934 + /* bsstype */
15935 + result = hfa384x_drvr_setconfig16(hw,
15936 + HFA384x_RID_CNFPORTTYPE,
15937 + HFA384x_PORTTYPE_IBSS);
15938 + if ( result ) {
15939 + WLAN_LOG_ERROR("Failed to set CNFPORTTYPE.\n");
15940 + msg->resultcode.data =
15941 + P80211ENUM_resultcode_implementation_failure;
15942 + goto exit;
15943 + }
15944 + /* ibss options */
15945 + result = hfa384x_drvr_setconfig16(hw,
15946 + HFA384x_RID_CREATEIBSS,
15947 + HFA384x_CREATEIBSS_JOINCREATEIBSS);
15948 + if ( result ) {
15949 + WLAN_LOG_ERROR("Failed to set CREATEIBSS.\n");
15950 + msg->resultcode.data =
15951 + P80211ENUM_resultcode_implementation_failure;
15952 + goto exit;
15953 + }
15954 + result = hfa384x_drvr_enable(hw, 0);
15955 + if ( result ) {
15956 + WLAN_LOG_ERROR("drvr_enable(0) failed. "
15957 + "result=%d\n", result);
15958 + msg->resultcode.data =
15959 + P80211ENUM_resultcode_implementation_failure;
15960 + goto exit;
15961 + }
15962 + istmpenable = 1;
15963 + }
15964 +
15965 + /* Figure out our timeout first Kus, then HZ */
15966 + timeout = msg->channellist.data.len * msg->maxchanneltime.data;
15967 + timeout = (timeout * HZ)/1000;
15968 +
15969 + /* Issue the scan request */
15970 + hw->scanflag = 0;
15971 +
15972 + WLAN_HEX_DUMP(5,"hscanreq", &scanreq, sizeof(scanreq));
15973 +
15974 + result = hfa384x_drvr_setconfig( hw,
15975 + HFA384x_RID_HOSTSCAN, &scanreq,
15976 + sizeof(hfa384x_HostScanRequest_data_t));
15977 + if ( result ) {
15978 + WLAN_LOG_ERROR("setconfig(SCANREQUEST) failed. result=%d\n",
15979 + result);
15980 + msg->resultcode.data =
15981 + P80211ENUM_resultcode_implementation_failure;
15982 + goto exit;
15983 + }
15984 +
15985 + /* sleep until info frame arrives */
15986 + wait_event_interruptible_timeout(hw->cmdq, hw->scanflag, timeout);
15987 +
15988 + msg->numbss.status = P80211ENUM_msgitem_status_data_ok;
15989 + if (hw->scanflag == -1)
15990 + hw->scanflag = 0;
15991 +
15992 + msg->numbss.data = hw->scanflag;
15993 +
15994 + hw->scanflag = 0;
15995 +
15996 + /* Disable port if we temporarily enabled it. */
15997 + if (istmpenable) {
15998 + result = hfa384x_drvr_disable(hw, 0);
15999 + if ( result ) {
16000 + WLAN_LOG_ERROR("drvr_disable(0) failed. "
16001 + "result=%d\n", result);
16002 + msg->resultcode.data =
16003 + P80211ENUM_resultcode_implementation_failure;
16004 + goto exit;
16005 + }
16006 + }
16007 +
16008 + /* restore original roaming mode */
16009 + result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE,
16010 + roamingmode);
16011 + if ( result ) {
16012 + WLAN_LOG_ERROR("setconfig(ROAMMODE) failed. result=%d\n",
16013 + result);
16014 + msg->resultcode.data =
16015 + P80211ENUM_resultcode_implementation_failure;
16016 + goto exit;
16017 + }
16018 +
16019 + result = 0;
16020 + msg->resultcode.data = P80211ENUM_resultcode_success;
16021 +
16022 + exit:
16023 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16024 +
16025 + DBFEXIT;
16026 + return result;
16027 +}
16028 +
16029 +
16030 +/*----------------------------------------------------------------
16031 +* prism2mgmt_scan_results
16032 +*
16033 +* Retrieve the BSS description for one of the BSSs identified in
16034 +* a scan.
16035 +*
16036 +* Arguments:
16037 +* wlandev wlan device structure
16038 +* msgp ptr to msg buffer
16039 +*
16040 +* Returns:
16041 +* 0 success and done
16042 +* <0 success, but we're waiting for something to finish.
16043 +* >0 an error occurred while handling the message.
16044 +* Side effects:
16045 +*
16046 +* Call context:
16047 +* process thread (usually)
16048 +* interrupt
16049 +----------------------------------------------------------------*/
16050 +int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
16051 +{
16052 + int result = 0;
16053 + p80211msg_dot11req_scan_results_t *req;
16054 + hfa384x_t *hw = wlandev->priv;
16055 + hfa384x_HScanResultSub_t *item = NULL;
16056 +
16057 + int count;
16058 +
16059 + DBFENTER;
16060 +
16061 + req = (p80211msg_dot11req_scan_results_t *) msgp;
16062 +
16063 + req->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16064 +
16065 + if (! hw->scanresults) {
16066 + WLAN_LOG_ERROR("dot11req_scan_results can only be used after a successful dot11req_scan.\n");
16067 + result = 2;
16068 + req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
16069 + goto exit;
16070 + }
16071 +
16072 + count = (hw->scanresults->framelen - 3) / 32;
16073 + if (count > 32) count = 32;
16074 +
16075 + if (req->bssindex.data >= count) {
16076 + WLAN_LOG_DEBUG(0, "requested index (%d) out of range (%d)\n",
16077 + req->bssindex.data, count);
16078 + result = 2;
16079 + req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
16080 + goto exit;
16081 + }
16082 +
16083 + item = &(hw->scanresults->info.hscanresult.result[req->bssindex.data]);
16084 + /* signal and noise */
16085 + req->signal.status = P80211ENUM_msgitem_status_data_ok;
16086 + req->noise.status = P80211ENUM_msgitem_status_data_ok;
16087 + req->signal.data = hfa384x2host_16(item->sl);
16088 + req->noise.data = hfa384x2host_16(item->anl);
16089 +
16090 + /* BSSID */
16091 + req->bssid.status = P80211ENUM_msgitem_status_data_ok;
16092 + req->bssid.data.len = WLAN_BSSID_LEN;
16093 + memcpy(req->bssid.data.data, item->bssid, WLAN_BSSID_LEN);
16094 +
16095 + /* SSID */
16096 + req->ssid.status = P80211ENUM_msgitem_status_data_ok;
16097 + req->ssid.data.len = hfa384x2host_16(item->ssid.len);
16098 + memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len);
16099 +
16100 + /* supported rates */
16101 + for (count = 0; count < 10 ; count++)
16102 + if (item->supprates[count] == 0)
16103 + break;
16104 +
16105 +#define REQBASICRATE(N) \
16106 + if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \
16107 + req->basicrate ## N .data = item->supprates[(N)-1]; \
16108 + req->basicrate ## N .status = P80211ENUM_msgitem_status_data_ok; \
16109 + }
16110 +
16111 + REQBASICRATE(1);
16112 + REQBASICRATE(2);
16113 + REQBASICRATE(3);
16114 + REQBASICRATE(4);
16115 + REQBASICRATE(5);
16116 + REQBASICRATE(6);
16117 + REQBASICRATE(7);
16118 + REQBASICRATE(8);
16119 +
16120 +#define REQSUPPRATE(N) \
16121 + if (count >= N) { \
16122 + req->supprate ## N .data = item->supprates[(N)-1]; \
16123 + req->supprate ## N .status = P80211ENUM_msgitem_status_data_ok; \
16124 + }
16125 +
16126 + REQSUPPRATE(1);
16127 + REQSUPPRATE(2);
16128 + REQSUPPRATE(3);
16129 + REQSUPPRATE(4);
16130 + REQSUPPRATE(5);
16131 + REQSUPPRATE(6);
16132 + REQSUPPRATE(7);
16133 + REQSUPPRATE(8);
16134 +
16135 + /* beacon period */
16136 + req->beaconperiod.status = P80211ENUM_msgitem_status_data_ok;
16137 + req->beaconperiod.data = hfa384x2host_16(item->bcnint);
16138 +
16139 + /* timestamps */
16140 + req->timestamp.status = P80211ENUM_msgitem_status_data_ok;
16141 + req->timestamp.data = jiffies;
16142 + req->localtime.status = P80211ENUM_msgitem_status_data_ok;
16143 + req->localtime.data = jiffies;
16144 +
16145 + /* atim window */
16146 + req->ibssatimwindow.status = P80211ENUM_msgitem_status_data_ok;
16147 + req->ibssatimwindow.data = hfa384x2host_16(item->atim);
16148 +
16149 + /* Channel */
16150 + req->dschannel.status = P80211ENUM_msgitem_status_data_ok;
16151 + req->dschannel.data = hfa384x2host_16(item->chid);
16152 +
16153 + /* capinfo bits */
16154 + count = hfa384x2host_16(item->capinfo);
16155 +
16156 + /* privacy flag */
16157 + req->privacy.status = P80211ENUM_msgitem_status_data_ok;
16158 + req->privacy.data = WLAN_GET_MGMT_CAP_INFO_PRIVACY(count);
16159 +
16160 + /* cfpollable */
16161 + req->cfpollable.status = P80211ENUM_msgitem_status_data_ok;
16162 + req->cfpollable.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(count);
16163 +
16164 + /* cfpollreq */
16165 + req->cfpollreq.status = P80211ENUM_msgitem_status_data_ok;
16166 + req->cfpollreq.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count);
16167 +
16168 + /* bsstype */
16169 + req->bsstype.status = P80211ENUM_msgitem_status_data_ok;
16170 + req->bsstype.data = (WLAN_GET_MGMT_CAP_INFO_ESS(count)) ?
16171 + P80211ENUM_bsstype_infrastructure :
16172 + P80211ENUM_bsstype_independent;
16173 +
16174 + // item->proberesp_rate
16175 +/*
16176 + req->fhdwelltime
16177 + req->fhhopset
16178 + req->fhhoppattern
16179 + req->fhhopindex
16180 + req->cfpdurremaining
16181 +*/
16182 +
16183 + result = 0;
16184 + req->resultcode.data = P80211ENUM_resultcode_success;
16185 +
16186 + exit:
16187 + DBFEXIT;
16188 + return result;
16189 +}
16190 +
16191 +/*----------------------------------------------------------------
16192 +* prism2mgmt_start
16193 +*
16194 +* Start a BSS. Any station can do this for IBSS, only AP for ESS.
16195 +*
16196 +* Arguments:
16197 +* wlandev wlan device structure
16198 +* msgp ptr to msg buffer
16199 +*
16200 +* Returns:
16201 +* 0 success and done
16202 +* <0 success, but we're waiting for something to finish.
16203 +* >0 an error occurred while handling the message.
16204 +* Side effects:
16205 +*
16206 +* Call context:
16207 +* process thread (usually)
16208 +* interrupt
16209 +----------------------------------------------------------------*/
16210 +int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
16211 +{
16212 + int result = 0;
16213 + hfa384x_t *hw = wlandev->priv;
16214 + p80211msg_dot11req_start_t *msg = msgp;
16215 +
16216 + p80211pstrd_t *pstr;
16217 + u8 bytebuf[80];
16218 + hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
16219 + u16 word;
16220 + DBFENTER;
16221 +
16222 + wlandev->macmode = WLAN_MACMODE_NONE;
16223 +
16224 + /* Set the SSID */
16225 + memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data));
16226 +
16227 + /*** ADHOC IBSS ***/
16228 + /* see if current f/w is less than 8c3 */
16229 + if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
16230 + hw->ident_sta_fw.minor,
16231 + hw->ident_sta_fw.variant) <
16232 + HFA384x_FIRMWARE_VERSION(0,8,3)) {
16233 + /* Ad-Hoc not quite supported on Prism2 */
16234 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16235 + msg->resultcode.data = P80211ENUM_resultcode_not_supported;
16236 + goto done;
16237 + }
16238 +
16239 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16240 +
16241 + /*** STATION ***/
16242 + /* Set the REQUIRED config items */
16243 + /* SSID */
16244 + pstr = (p80211pstrd_t*)&(msg->ssid.data);
16245 + prism2mgmt_pstr2bytestr(p2bytestr, pstr);
16246 + result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
16247 + bytebuf, HFA384x_RID_CNFOWNSSID_LEN);
16248 + if ( result ) {
16249 + WLAN_LOG_ERROR("Failed to set CnfOwnSSID\n");
16250 + goto failed;
16251 + }
16252 + result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID,
16253 + bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
16254 + if ( result ) {
16255 + WLAN_LOG_ERROR("Failed to set CnfDesiredSSID\n");
16256 + goto failed;
16257 + }
16258 +
16259 + /* bsstype - we use the default in the ap firmware */
16260 + /* IBSS port */
16261 + hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 0);
16262 +
16263 + /* beacon period */
16264 + word = msg->beaconperiod.data;
16265 + result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNint, word);
16266 + if ( result ) {
16267 + WLAN_LOG_ERROR("Failed to set beacon period=%d.\n", word);
16268 + goto failed;
16269 + }
16270 +
16271 + /* dschannel */
16272 + word = msg->dschannel.data;
16273 + result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word);
16274 + if ( result ) {
16275 + WLAN_LOG_ERROR("Failed to set channel=%d.\n", word);
16276 + goto failed;
16277 + }
16278 + /* Basic rates */
16279 + word = p80211rate_to_p2bit(msg->basicrate1.data);
16280 + if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) {
16281 + word |= p80211rate_to_p2bit(msg->basicrate2.data);
16282 + }
16283 + if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) {
16284 + word |= p80211rate_to_p2bit(msg->basicrate3.data);
16285 + }
16286 + if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) {
16287 + word |= p80211rate_to_p2bit(msg->basicrate4.data);
16288 + }
16289 + if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) {
16290 + word |= p80211rate_to_p2bit(msg->basicrate5.data);
16291 + }
16292 + if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) {
16293 + word |= p80211rate_to_p2bit(msg->basicrate6.data);
16294 + }
16295 + if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) {
16296 + word |= p80211rate_to_p2bit(msg->basicrate7.data);
16297 + }
16298 + if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) {
16299 + word |= p80211rate_to_p2bit(msg->basicrate8.data);
16300 + }
16301 + result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word);
16302 + if ( result ) {
16303 + WLAN_LOG_ERROR("Failed to set basicrates=%d.\n", word);
16304 + goto failed;
16305 + }
16306 +
16307 + /* Operational rates (supprates and txratecontrol) */
16308 + word = p80211rate_to_p2bit(msg->operationalrate1.data);
16309 + if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) {
16310 + word |= p80211rate_to_p2bit(msg->operationalrate2.data);
16311 + }
16312 + if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) {
16313 + word |= p80211rate_to_p2bit(msg->operationalrate3.data);
16314 + }
16315 + if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) {
16316 + word |= p80211rate_to_p2bit(msg->operationalrate4.data);
16317 + }
16318 + if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) {
16319 + word |= p80211rate_to_p2bit(msg->operationalrate5.data);
16320 + }
16321 + if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) {
16322 + word |= p80211rate_to_p2bit(msg->operationalrate6.data);
16323 + }
16324 + if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) {
16325 + word |= p80211rate_to_p2bit(msg->operationalrate7.data);
16326 + }
16327 + if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) {
16328 + word |= p80211rate_to_p2bit(msg->operationalrate8.data);
16329 + }
16330 + result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word);
16331 + if ( result ) {
16332 + WLAN_LOG_ERROR("Failed to set supprates=%d.\n", word);
16333 + goto failed;
16334 + }
16335 +
16336 + result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word);
16337 + if ( result ) {
16338 + WLAN_LOG_ERROR("Failed to set txrates=%d.\n", word);
16339 + goto failed;
16340 + }
16341 +
16342 + /* Set the macmode so the frame setup code knows what to do */
16343 + if ( msg->bsstype.data == P80211ENUM_bsstype_independent ) {
16344 + wlandev->macmode = WLAN_MACMODE_IBSS_STA;
16345 + /* lets extend the data length a bit */
16346 + hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304);
16347 + }
16348 +
16349 + /* Enable the Port */
16350 + result = hfa384x_drvr_enable(hw, 0);
16351 + if ( result ) {
16352 + WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
16353 + goto failed;
16354 + }
16355 +
16356 + msg->resultcode.data = P80211ENUM_resultcode_success;
16357 +
16358 + goto done;
16359 +failed:
16360 + WLAN_LOG_DEBUG(1, "Failed to set a config option, result=%d\n", result);
16361 + msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
16362 +
16363 +done:
16364 + result = 0;
16365 +
16366 + DBFEXIT;
16367 + return result;
16368 +}
16369 +
16370 +/*----------------------------------------------------------------
16371 +* prism2mgmt_readpda
16372 +*
16373 +* Collect the PDA data and put it in the message.
16374 +*
16375 +* Arguments:
16376 +* wlandev wlan device structure
16377 +* msgp ptr to msg buffer
16378 +*
16379 +* Returns:
16380 +* 0 success and done
16381 +* <0 success, but we're waiting for something to finish.
16382 +* >0 an error occurred while handling the message.
16383 +* Side effects:
16384 +*
16385 +* Call context:
16386 +* process thread (usually)
16387 +----------------------------------------------------------------*/
16388 +int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp)
16389 +{
16390 + hfa384x_t *hw = wlandev->priv;
16391 + p80211msg_p2req_readpda_t *msg = msgp;
16392 + int result;
16393 + DBFENTER;
16394 +
16395 + /* We only support collecting the PDA when in the FWLOAD
16396 + * state.
16397 + */
16398 + if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
16399 + WLAN_LOG_ERROR(
16400 + "PDA may only be read "
16401 + "in the fwload state.\n");
16402 + msg->resultcode.data =
16403 + P80211ENUM_resultcode_implementation_failure;
16404 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16405 + } else {
16406 + /* Call drvr_readpda(), it handles the auxport enable
16407 + * and validating the returned PDA.
16408 + */
16409 + result = hfa384x_drvr_readpda(
16410 + hw,
16411 + msg->pda.data,
16412 + HFA384x_PDA_LEN_MAX);
16413 + if (result) {
16414 + WLAN_LOG_ERROR(
16415 + "hfa384x_drvr_readpda() failed, "
16416 + "result=%d\n",
16417 + result);
16418 +
16419 + msg->resultcode.data =
16420 + P80211ENUM_resultcode_implementation_failure;
16421 + msg->resultcode.status =
16422 + P80211ENUM_msgitem_status_data_ok;
16423 + DBFEXIT;
16424 + return 0;
16425 + }
16426 + msg->pda.status = P80211ENUM_msgitem_status_data_ok;
16427 + msg->resultcode.data = P80211ENUM_resultcode_success;
16428 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16429 + }
16430 +
16431 + DBFEXIT;
16432 + return 0;
16433 +}
16434 +
16435 +/*----------------------------------------------------------------
16436 +* prism2mgmt_ramdl_state
16437 +*
16438 +* Establishes the beginning/end of a card RAM download session.
16439 +*
16440 +* It is expected that the ramdl_write() function will be called
16441 +* one or more times between the 'enable' and 'disable' calls to
16442 +* this function.
16443 +*
16444 +* Note: This function should not be called when a mac comm port
16445 +* is active.
16446 +*
16447 +* Arguments:
16448 +* wlandev wlan device structure
16449 +* msgp ptr to msg buffer
16450 +*
16451 +* Returns:
16452 +* 0 success and done
16453 +* <0 success, but we're waiting for something to finish.
16454 +* >0 an error occurred while handling the message.
16455 +* Side effects:
16456 +*
16457 +* Call context:
16458 +* process thread (usually)
16459 +----------------------------------------------------------------*/
16460 +int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
16461 +{
16462 + hfa384x_t *hw = wlandev->priv;
16463 + p80211msg_p2req_ramdl_state_t *msg = msgp;
16464 + DBFENTER;
16465 +
16466 + if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
16467 + WLAN_LOG_ERROR(
16468 + "ramdl_state(): may only be called "
16469 + "in the fwload state.\n");
16470 + msg->resultcode.data =
16471 + P80211ENUM_resultcode_implementation_failure;
16472 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16473 + DBFEXIT;
16474 + return 0;
16475 + }
16476 +
16477 + /*
16478 + ** Note: Interrupts are locked out if this is an AP and are NOT
16479 + ** locked out if this is a station.
16480 + */
16481 +
16482 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16483 + if ( msg->enable.data == P80211ENUM_truth_true ) {
16484 + if ( hfa384x_drvr_ramdl_enable(hw, msg->exeaddr.data) ) {
16485 + msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
16486 + } else {
16487 + msg->resultcode.data = P80211ENUM_resultcode_success;
16488 + }
16489 + } else {
16490 + hfa384x_drvr_ramdl_disable(hw);
16491 + msg->resultcode.data = P80211ENUM_resultcode_success;
16492 + }
16493 +
16494 + DBFEXIT;
16495 + return 0;
16496 +}
16497 +
16498 +
16499 +/*----------------------------------------------------------------
16500 +* prism2mgmt_ramdl_write
16501 +*
16502 +* Writes a buffer to the card RAM using the download state. This
16503 +* is for writing code to card RAM. To just read or write raw data
16504 +* use the aux functions.
16505 +*
16506 +* Arguments:
16507 +* wlandev wlan device structure
16508 +* msgp ptr to msg buffer
16509 +*
16510 +* Returns:
16511 +* 0 success and done
16512 +* <0 success, but we're waiting for something to finish.
16513 +* >0 an error occurred while handling the message.
16514 +* Side effects:
16515 +*
16516 +* Call context:
16517 +* process thread (usually)
16518 +----------------------------------------------------------------*/
16519 +int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp)
16520 +{
16521 + hfa384x_t *hw = wlandev->priv;
16522 + p80211msg_p2req_ramdl_write_t *msg = msgp;
16523 + u32 addr;
16524 + u32 len;
16525 + u8 *buf;
16526 + DBFENTER;
16527 +
16528 + if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
16529 + WLAN_LOG_ERROR(
16530 + "ramdl_write(): may only be called "
16531 + "in the fwload state.\n");
16532 + msg->resultcode.data =
16533 + P80211ENUM_resultcode_implementation_failure;
16534 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16535 + DBFEXIT;
16536 + return 0;
16537 + }
16538 +
16539 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16540 + /* first validate the length */
16541 + if ( msg->len.data > sizeof(msg->data.data) ) {
16542 + msg->resultcode.status = P80211ENUM_resultcode_invalid_parameters;
16543 + return 0;
16544 + }
16545 + /* call the hfa384x function to do the write */
16546 + addr = msg->addr.data;
16547 + len = msg->len.data;
16548 + buf = msg->data.data;
16549 + if ( hfa384x_drvr_ramdl_write(hw, addr, buf, len) ) {
16550 + msg->resultcode.data = P80211ENUM_resultcode_refused;
16551 +
16552 + }
16553 + msg->resultcode.data = P80211ENUM_resultcode_success;
16554 +
16555 + DBFEXIT;
16556 + return 0;
16557 +}
16558 +
16559 +
16560 +/*----------------------------------------------------------------
16561 +* prism2mgmt_flashdl_state
16562 +*
16563 +* Establishes the beginning/end of a card Flash download session.
16564 +*
16565 +* It is expected that the flashdl_write() function will be called
16566 +* one or more times between the 'enable' and 'disable' calls to
16567 +* this function.
16568 +*
16569 +* Note: This function should not be called when a mac comm port
16570 +* is active.
16571 +*
16572 +* Arguments:
16573 +* wlandev wlan device structure
16574 +* msgp ptr to msg buffer
16575 +*
16576 +* Returns:
16577 +* 0 success and done
16578 +* <0 success, but we're waiting for something to finish.
16579 +* >0 an error occurred while handling the message.
16580 +* Side effects:
16581 +*
16582 +* Call context:
16583 +* process thread (usually)
16584 +----------------------------------------------------------------*/
16585 +int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
16586 +{
16587 + int result = 0;
16588 + hfa384x_t *hw = wlandev->priv;
16589 + p80211msg_p2req_flashdl_state_t *msg = msgp;
16590 + DBFENTER;
16591 +
16592 + if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
16593 + WLAN_LOG_ERROR(
16594 + "flashdl_state(): may only be called "
16595 + "in the fwload state.\n");
16596 + msg->resultcode.data =
16597 + P80211ENUM_resultcode_implementation_failure;
16598 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16599 + DBFEXIT;
16600 + return 0;
16601 + }
16602 +
16603 + /*
16604 + ** Note: Interrupts are locked out if this is an AP and are NOT
16605 + ** locked out if this is a station.
16606 + */
16607 +
16608 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16609 + if ( msg->enable.data == P80211ENUM_truth_true ) {
16610 + if ( hfa384x_drvr_flashdl_enable(hw) ) {
16611 + msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
16612 + } else {
16613 + msg->resultcode.data = P80211ENUM_resultcode_success;
16614 + }
16615 + } else {
16616 + hfa384x_drvr_flashdl_disable(hw);
16617 + msg->resultcode.data = P80211ENUM_resultcode_success;
16618 + /* NOTE: At this point, the MAC is in the post-reset
16619 + * state and the driver is in the fwload state.
16620 + * We need to get the MAC back into the fwload
16621 + * state. To do this, we set the nsdstate to HWPRESENT
16622 + * and then call the ifstate function to redo everything
16623 + * that got us into the fwload state.
16624 + */
16625 + wlandev->msdstate = WLAN_MSD_HWPRESENT;
16626 + result = prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload);
16627 + if (result != P80211ENUM_resultcode_success) {
16628 + WLAN_LOG_ERROR("prism2sta_ifstate(fwload) failed,"
16629 + "P80211ENUM_resultcode=%d\n", result);
16630 + msg->resultcode.data =
16631 + P80211ENUM_resultcode_implementation_failure;
16632 + result = -1;
16633 + }
16634 + }
16635 +
16636 + DBFEXIT;
16637 + return 0;
16638 +}
16639 +
16640 +
16641 +/*----------------------------------------------------------------
16642 +* prism2mgmt_flashdl_write
16643 +*
16644 +*
16645 +*
16646 +* Arguments:
16647 +* wlandev wlan device structure
16648 +* msgp ptr to msg buffer
16649 +*
16650 +* Returns:
16651 +* 0 success and done
16652 +* <0 success, but we're waiting for something to finish.
16653 +* >0 an error occurred while handling the message.
16654 +* Side effects:
16655 +*
16656 +* Call context:
16657 +* process thread (usually)
16658 +----------------------------------------------------------------*/
16659 +int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp)
16660 +{
16661 + hfa384x_t *hw = wlandev->priv;
16662 + p80211msg_p2req_flashdl_write_t *msg = msgp;
16663 + u32 addr;
16664 + u32 len;
16665 + u8 *buf;
16666 + DBFENTER;
16667 +
16668 + if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
16669 + WLAN_LOG_ERROR(
16670 + "flashdl_write(): may only be called "
16671 + "in the fwload state.\n");
16672 + msg->resultcode.data =
16673 + P80211ENUM_resultcode_implementation_failure;
16674 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16675 + DBFEXIT;
16676 + return 0;
16677 + }
16678 +
16679 + /*
16680 + ** Note: Interrupts are locked out if this is an AP and are NOT
16681 + ** locked out if this is a station.
16682 + */
16683 +
16684 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16685 + /* first validate the length */
16686 + if ( msg->len.data > sizeof(msg->data.data) ) {
16687 + msg->resultcode.status =
16688 + P80211ENUM_resultcode_invalid_parameters;
16689 + return 0;
16690 + }
16691 + /* call the hfa384x function to do the write */
16692 + addr = msg->addr.data;
16693 + len = msg->len.data;
16694 + buf = msg->data.data;
16695 + if ( hfa384x_drvr_flashdl_write(hw, addr, buf, len) ) {
16696 + msg->resultcode.data = P80211ENUM_resultcode_refused;
16697 +
16698 + }
16699 + msg->resultcode.data = P80211ENUM_resultcode_success;
16700 +
16701 + DBFEXIT;
16702 + return 0;
16703 +}
16704 +
16705 +/*----------------------------------------------------------------
16706 +* prism2mgmt_autojoin
16707 +*
16708 +* Associate with an ESS.
16709 +*
16710 +* Arguments:
16711 +* wlandev wlan device structure
16712 +* msgp ptr to msg buffer
16713 +*
16714 +* Returns:
16715 +* 0 success and done
16716 +* <0 success, but we're waiting for something to finish.
16717 +* >0 an error occurred while handling the message.
16718 +* Side effects:
16719 +*
16720 +* Call context:
16721 +* process thread (usually)
16722 +* interrupt
16723 +----------------------------------------------------------------*/
16724 +int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
16725 +{
16726 + hfa384x_t *hw = wlandev->priv;
16727 + int result = 0;
16728 + u16 reg;
16729 + u16 port_type;
16730 + p80211msg_lnxreq_autojoin_t *msg = msgp;
16731 + p80211pstrd_t *pstr;
16732 + u8 bytebuf[256];
16733 + hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
16734 + DBFENTER;
16735 +
16736 + wlandev->macmode = WLAN_MACMODE_NONE;
16737 +
16738 + /* Set the SSID */
16739 + memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data));
16740 +
16741 + /* Disable the Port */
16742 + hfa384x_drvr_disable(hw, 0);
16743 +
16744 + /*** STATION ***/
16745 + /* Set the TxRates */
16746 + hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, 0x000f);
16747 +
16748 + /* Set the auth type */
16749 + if ( msg->authtype.data == P80211ENUM_authalg_sharedkey ) {
16750 + reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY;
16751 + } else {
16752 + reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM;
16753 + }
16754 + hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg);
16755 +
16756 + /* Set the ssid */
16757 + memset(bytebuf, 0, 256);
16758 + pstr = (p80211pstrd_t*)&(msg->ssid.data);
16759 + prism2mgmt_pstr2bytestr(p2bytestr, pstr);
16760 + result = hfa384x_drvr_setconfig(
16761 + hw, HFA384x_RID_CNFDESIREDSSID,
16762 + bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
16763 +#if 0
16764 + /* we can use the new-fangled auto-unknown mode if the firmware
16765 + is 1.3.3 or newer */
16766 + if (HFA384x_FIRMARE_VERSION(hw->ident_sta_fw.major,
16767 + hw->ident_sta_fw.minor,
16768 + hw->ident_sta_fw.variant) >=
16769 + HFA384x_FIRMWARE_VERSION(1,3,3)) {
16770 + /* Set up the IBSS options */
16771 + reg = HFA384x_CREATEIBSS_JOINESS_JOINCREATEIBSS;
16772 + hfa384x_drvr_setconfig16(hw, HFA384x_RID_CREATEIBSS, reg);
16773 +
16774 + /* Set the PortType */
16775 + port_type = HFA384x_PORTTYPE_IBSS;
16776 + } else {
16777 + port_type = HFA384x_PORTTYPE_BSS;
16778 + }
16779 +#else
16780 + port_type = HFA384x_PORTTYPE_BSS;
16781 +#endif
16782 + /* Set the PortType */
16783 + hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, port_type);
16784 +
16785 + /* Enable the Port */
16786 + hfa384x_drvr_enable(hw, 0);
16787 +
16788 + /* Set the resultcode */
16789 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16790 + msg->resultcode.data = P80211ENUM_resultcode_success;
16791 +
16792 + DBFEXIT;
16793 + return result;
16794 +}
16795 +
16796 +
16797 +/*----------------------------------------------------------------
16798 +* prism2mgmt_wlansniff
16799 +*
16800 +* Start or stop sniffing.
16801 +*
16802 +* Arguments:
16803 +* wlandev wlan device structure
16804 +* msgp ptr to msg buffer
16805 +*
16806 +* Returns:
16807 +* 0 success and done
16808 +* <0 success, but we're waiting for something to finish.
16809 +* >0 an error occurred while handling the message.
16810 +* Side effects:
16811 +*
16812 +* Call context:
16813 +* process thread (usually)
16814 +* interrupt
16815 +----------------------------------------------------------------*/
16816 +int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
16817 +{
16818 + int result = 0;
16819 + p80211msg_lnxreq_wlansniff_t *msg = msgp;
16820 +
16821 + hfa384x_t *hw = wlandev->priv;
16822 + u16 word;
16823 +
16824 + DBFENTER;
16825 +
16826 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
16827 + switch (msg->enable.data)
16828 + {
16829 + case P80211ENUM_truth_false:
16830 + /* Confirm that we're in monitor mode */
16831 + if ( wlandev->netdev->type == ARPHRD_ETHER ) {
16832 + msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
16833 + result = 0;
16834 + goto exit;
16835 + }
16836 + /* Disable monitor mode */
16837 + result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
16838 + if ( result ) {
16839 + WLAN_LOG_DEBUG(1,
16840 + "failed to disable monitor mode, result=%d\n",
16841 + result);
16842 + goto failed;
16843 + }
16844 + /* Disable port 0 */
16845 + result = hfa384x_drvr_disable(hw, 0);
16846 + if ( result ) {
16847 + WLAN_LOG_DEBUG(1,
16848 + "failed to disable port 0 after sniffing, result=%d\n",
16849 + result);
16850 + goto failed;
16851 + }
16852 + /* Clear the driver state */
16853 + wlandev->netdev->type = ARPHRD_ETHER;
16854 +
16855 + /* Restore the wepflags */
16856 + result = hfa384x_drvr_setconfig16(hw,
16857 + HFA384x_RID_CNFWEPFLAGS,
16858 + hw->presniff_wepflags);
16859 + if ( result ) {
16860 + WLAN_LOG_DEBUG(1,
16861 + "failed to restore wepflags=0x%04x, result=%d\n",
16862 + hw->presniff_wepflags,
16863 + result);
16864 + goto failed;
16865 + }
16866 +
16867 + /* Set the port to its prior type and enable (if necessary) */
16868 + if (hw->presniff_port_type != 0 ) {
16869 + word = hw->presniff_port_type;
16870 + result = hfa384x_drvr_setconfig16(hw,
16871 + HFA384x_RID_CNFPORTTYPE, word);
16872 + if ( result ) {
16873 + WLAN_LOG_DEBUG(1,
16874 + "failed to restore porttype, result=%d\n",
16875 + result);
16876 + goto failed;
16877 + }
16878 +
16879 + /* Enable the port */
16880 + result = hfa384x_drvr_enable(hw, 0);
16881 + if ( result ) {
16882 + WLAN_LOG_DEBUG(1, "failed to enable port to presniff setting, result=%d\n", result);
16883 + goto failed;
16884 + }
16885 + } else {
16886 + result = hfa384x_drvr_disable(hw, 0);
16887 +
16888 + }
16889 +
16890 + WLAN_LOG_INFO("monitor mode disabled\n");
16891 + msg->resultcode.data = P80211ENUM_resultcode_success;
16892 + result = 0;
16893 + goto exit;
16894 + break;
16895 + case P80211ENUM_truth_true:
16896 + /* Disable the port (if enabled), only check Port 0 */
16897 + if ( hw->port_enabled[0]) {
16898 + if (wlandev->netdev->type == ARPHRD_ETHER) {
16899 + /* Save macport 0 state */
16900 + result = hfa384x_drvr_getconfig16(hw,
16901 + HFA384x_RID_CNFPORTTYPE,
16902 + &(hw->presniff_port_type));
16903 + if ( result ) {
16904 + WLAN_LOG_DEBUG(1,"failed to read porttype, result=%d\n", result);
16905 + goto failed;
16906 + }
16907 + /* Save the wepflags state */
16908 + result = hfa384x_drvr_getconfig16(hw,
16909 + HFA384x_RID_CNFWEPFLAGS,
16910 + &(hw->presniff_wepflags));
16911 + if ( result ) {
16912 + WLAN_LOG_DEBUG(1,"failed to read wepflags, result=%d\n", result);
16913 + goto failed;
16914 + }
16915 + hfa384x_drvr_stop(hw);
16916 + result = hfa384x_drvr_start(hw);
16917 + if ( result ) {
16918 + WLAN_LOG_DEBUG(1,
16919 + "failed to restart the card for sniffing, result=%d\n",
16920 + result);
16921 + goto failed;
16922 + }
16923 + } else {
16924 + /* Disable the port */
16925 + result = hfa384x_drvr_disable(hw, 0);
16926 + if ( result ) {
16927 + WLAN_LOG_DEBUG(1,
16928 + "failed to enable port for sniffing, result=%d\n",
16929 + result);
16930 + goto failed;
16931 + }
16932 + }
16933 + } else {
16934 + hw->presniff_port_type = 0;
16935 + }
16936 +
16937 + /* Set the channel we wish to sniff */
16938 + word = msg->channel.data;
16939 + result = hfa384x_drvr_setconfig16(hw,
16940 + HFA384x_RID_CNFOWNCHANNEL, word);
16941 + hw->sniff_channel=word;
16942 +
16943 + if ( result ) {
16944 + WLAN_LOG_DEBUG(1,
16945 + "failed to set channel %d, result=%d\n",
16946 + word,
16947 + result);
16948 + goto failed;
16949 + }
16950 +
16951 + /* Now if we're already sniffing, we can skip the rest */
16952 + if (wlandev->netdev->type != ARPHRD_ETHER) {
16953 + /* Set the port type to pIbss */
16954 + word = HFA384x_PORTTYPE_PSUEDOIBSS;
16955 + result = hfa384x_drvr_setconfig16(hw,
16956 + HFA384x_RID_CNFPORTTYPE, word);
16957 + if ( result ) {
16958 + WLAN_LOG_DEBUG(1,
16959 + "failed to set porttype %d, result=%d\n",
16960 + word,
16961 + result);
16962 + goto failed;
16963 + }
16964 + if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) {
16965 + /* Set the wepflags for no decryption */
16966 + word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT |
16967 + HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
16968 + result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word);
16969 + }
16970 +
16971 + if ( result ) {
16972 + WLAN_LOG_DEBUG(1,
16973 + "failed to set wepflags=0x%04x, result=%d\n",
16974 + word,
16975 + result);
16976 + goto failed;
16977 + }
16978 + }
16979 +
16980 + /* Do we want to strip the FCS in monitor mode? */
16981 + if ((msg->stripfcs.status == P80211ENUM_msgitem_status_data_ok) && (msg->stripfcs.data == P80211ENUM_truth_true)) {
16982 + hw->sniff_fcs = 0;
16983 + } else {
16984 + hw->sniff_fcs = 1;
16985 + }
16986 +
16987 + /* Do we want to truncate the packets? */
16988 + if (msg->packet_trunc.status == P80211ENUM_msgitem_status_data_ok) {
16989 + hw->sniff_truncate = msg->packet_trunc.data;
16990 + } else {
16991 + hw->sniff_truncate = 0;
16992 + }
16993 +
16994 + /* Enable the port */
16995 + result = hfa384x_drvr_enable(hw, 0);
16996 + if ( result ) {
16997 + WLAN_LOG_DEBUG(1,
16998 + "failed to enable port for sniffing, result=%d\n",
16999 + result);
17000 + goto failed;
17001 + }
17002 + /* Enable monitor mode */
17003 + result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
17004 + if ( result ) {
17005 + WLAN_LOG_DEBUG(1,
17006 + "failed to enable monitor mode, result=%d\n",
17007 + result);
17008 + goto failed;
17009 + }
17010 +
17011 + if (wlandev->netdev->type == ARPHRD_ETHER) {
17012 + WLAN_LOG_INFO("monitor mode enabled\n");
17013 + }
17014 +
17015 + /* Set the driver state */
17016 + /* Do we want the prism2 header? */
17017 + if ((msg->prismheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->prismheader.data == P80211ENUM_truth_true)) {
17018 + hw->sniffhdr = 0;
17019 + wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
17020 + } else if ((msg->wlanheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->wlanheader.data == P80211ENUM_truth_true)) {
17021 + hw->sniffhdr = 1;
17022 + wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
17023 + } else {
17024 + wlandev->netdev->type = ARPHRD_IEEE80211;
17025 + }
17026 +
17027 + msg->resultcode.data = P80211ENUM_resultcode_success;
17028 + result = 0;
17029 + goto exit;
17030 + break;
17031 + default:
17032 + msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
17033 + result = 0;
17034 + goto exit;
17035 + break;
17036 + }
17037 +
17038 +failed:
17039 + msg->resultcode.data = P80211ENUM_resultcode_refused;
17040 + result = 0;
17041 +exit:
17042 +
17043 + DBFEXIT;
17044 + return result;
17045 +}
17046 --- /dev/null
17047 +++ b/drivers/staging/wlan-ng/prism2mgmt.h
17048 @@ -0,0 +1,155 @@
17049 +/* prism2mgmt.h
17050 +*
17051 +* Declares the mgmt command handler functions
17052 +*
17053 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
17054 +* --------------------------------------------------------------------
17055 +*
17056 +* linux-wlan
17057 +*
17058 +* The contents of this file are subject to the Mozilla Public
17059 +* License Version 1.1 (the "License"); you may not use this file
17060 +* except in compliance with the License. You may obtain a copy of
17061 +* the License at http://www.mozilla.org/MPL/
17062 +*
17063 +* Software distributed under the License is distributed on an "AS
17064 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17065 +* implied. See the License for the specific language governing
17066 +* rights and limitations under the License.
17067 +*
17068 +* Alternatively, the contents of this file may be used under the
17069 +* terms of the GNU Public License version 2 (the "GPL"), in which
17070 +* case the provisions of the GPL are applicable instead of the
17071 +* above. If you wish to allow the use of your version of this file
17072 +* only under the terms of the GPL and not to allow others to use
17073 +* your version of this file under the MPL, indicate your decision
17074 +* by deleting the provisions above and replace them with the notice
17075 +* and other provisions required by the GPL. If you do not delete
17076 +* the provisions above, a recipient may use your version of this
17077 +* file under either the MPL or the GPL.
17078 +*
17079 +* --------------------------------------------------------------------
17080 +*
17081 +* Inquiries regarding the linux-wlan Open Source project can be
17082 +* made directly to:
17083 +*
17084 +* AbsoluteValue Systems Inc.
17085 +* info@linux-wlan.com
17086 +* http://www.linux-wlan.com
17087 +*
17088 +* --------------------------------------------------------------------
17089 +*
17090 +* Portions of the development of this software were funded by
17091 +* Intersil Corporation as part of PRISM(R) chipset product development.
17092 +*
17093 +* --------------------------------------------------------------------
17094 +*
17095 +* This file contains the constants and data structures for interaction
17096 +* with the hfa384x Wireless LAN (WLAN) Media Access Contoller (MAC).
17097 +* The hfa384x is a portion of the Harris PRISM(tm) WLAN chipset.
17098 +*
17099 +* [Implementation and usage notes]
17100 +*
17101 +* [References]
17102 +* CW10 Programmer's Manual v1.5
17103 +* IEEE 802.11 D10.0
17104 +*
17105 +* --------------------------------------------------------------------
17106 +*/
17107 +
17108 +#ifndef _PRISM2MGMT_H
17109 +#define _PRISM2MGMT_H
17110 +
17111 +
17112 +/*=============================================================*/
17113 +/*------ Constants --------------------------------------------*/
17114 +
17115 +/*=============================================================*/
17116 +/*------ Macros -----------------------------------------------*/
17117 +
17118 +/*=============================================================*/
17119 +/*------ Types and their related constants --------------------*/
17120 +
17121 +/*=============================================================*/
17122 +/*------ Static variable externs ------------------------------*/
17123 +
17124 +extern int prism2_debug;
17125 +extern int prism2_reset_holdtime;
17126 +extern int prism2_reset_settletime;
17127 +/*=============================================================*/
17128 +/*--- Function Declarations -----------------------------------*/
17129 +/*=============================================================*/
17130 +
17131 +u32
17132 +prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate);
17133 +
17134 +void
17135 +prism2sta_ev_dtim(wlandevice_t *wlandev);
17136 +void
17137 +prism2sta_ev_infdrop(wlandevice_t *wlandev);
17138 +void
17139 +prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
17140 +void
17141 +prism2sta_ev_txexc(wlandevice_t *wlandev, u16 status);
17142 +void
17143 +prism2sta_ev_tx(wlandevice_t *wlandev, u16 status);
17144 +void
17145 +prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
17146 +void
17147 +prism2sta_ev_alloc(wlandevice_t *wlandev);
17148 +
17149 +int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp);
17150 +int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp);
17151 +int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp);
17152 +int prism2mgmt_start(wlandevice_t *wlandev, void *msgp);
17153 +int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp);
17154 +int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp);
17155 +int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp);
17156 +int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp);
17157 +int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp);
17158 +int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp);
17159 +int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp);
17160 +
17161 +/*---------------------------------------------------------------
17162 +* conversion functions going between wlan message data types and
17163 +* Prism2 data types
17164 +---------------------------------------------------------------*/
17165 +/* byte area conversion functions*/
17166 +void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr);
17167 +void prism2mgmt_bytearea2pstr(u8 *bytearea, p80211pstrd_t *pstr, int len);
17168 +
17169 +/* byte string conversion functions*/
17170 +void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr);
17171 +void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr);
17172 +
17173 +/* integer conversion functions */
17174 +void prism2mgmt_prism2int2p80211int(u16 *prism2int, u32 *wlanint);
17175 +void prism2mgmt_p80211int2prism2int(u16 *prism2int, u32 *wlanint);
17176 +
17177 +/* enumerated integer conversion functions */
17178 +void prism2mgmt_prism2enum2p80211enum(u16 *prism2enum, u32 *wlanenum, u16 rid);
17179 +void prism2mgmt_p80211enum2prism2enum(u16 *prism2enum, u32 *wlanenum, u16 rid);
17180 +
17181 +/* functions to convert a bit area to/from an Operational Rate Set */
17182 +void prism2mgmt_get_oprateset(u16 *rate, p80211pstrd_t *pstr);
17183 +void prism2mgmt_set_oprateset(u16 *rate, p80211pstrd_t *pstr);
17184 +
17185 +/* functions to convert Group Addresses */
17186 +void prism2mgmt_get_grpaddr(u32 did,
17187 + p80211pstrd_t *pstr, hfa384x_t *priv );
17188 +int prism2mgmt_set_grpaddr(u32 did,
17189 + u8 *prism2buf, p80211pstrd_t *pstr, hfa384x_t *priv );
17190 +int prism2mgmt_get_grpaddr_index( u32 did );
17191 +
17192 +void prism2sta_processing_defer(struct work_struct *data);
17193 +
17194 +void prism2sta_commsqual_defer(struct work_struct *data);
17195 +void prism2sta_commsqual_timer(unsigned long data);
17196 +
17197 +/*=============================================================*/
17198 +/*--- Inline Function Definitions (if supported) --------------*/
17199 +/*=============================================================*/
17200 +
17201 +
17202 +
17203 +#endif
17204 --- /dev/null
17205 +++ b/drivers/staging/wlan-ng/prism2mib.c
17206 @@ -0,0 +1,1135 @@
17207 +/* src/prism2/driver/prism2mib.c
17208 +*
17209 +* Management request for mibset/mibget
17210 +*
17211 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
17212 +* --------------------------------------------------------------------
17213 +*
17214 +* linux-wlan
17215 +*
17216 +* The contents of this file are subject to the Mozilla Public
17217 +* License Version 1.1 (the "License"); you may not use this file
17218 +* except in compliance with the License. You may obtain a copy of
17219 +* the License at http://www.mozilla.org/MPL/
17220 +*
17221 +* Software distributed under the License is distributed on an "AS
17222 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17223 +* implied. See the License for the specific language governing
17224 +* rights and limitations under the License.
17225 +*
17226 +* Alternatively, the contents of this file may be used under the
17227 +* terms of the GNU Public License version 2 (the "GPL"), in which
17228 +* case the provisions of the GPL are applicable instead of the
17229 +* above. If you wish to allow the use of your version of this file
17230 +* only under the terms of the GPL and not to allow others to use
17231 +* your version of this file under the MPL, indicate your decision
17232 +* by deleting the provisions above and replace them with the notice
17233 +* and other provisions required by the GPL. If you do not delete
17234 +* the provisions above, a recipient may use your version of this
17235 +* file under either the MPL or the GPL.
17236 +*
17237 +* --------------------------------------------------------------------
17238 +*
17239 +* Inquiries regarding the linux-wlan Open Source project can be
17240 +* made directly to:
17241 +*
17242 +* AbsoluteValue Systems Inc.
17243 +* info@linux-wlan.com
17244 +* http://www.linux-wlan.com
17245 +*
17246 +* --------------------------------------------------------------------
17247 +*
17248 +* Portions of the development of this software were funded by
17249 +* Intersil Corporation as part of PRISM(R) chipset product development.
17250 +*
17251 +* --------------------------------------------------------------------
17252 +*
17253 +* The functions in this file handle the mibset/mibget management
17254 +* functions.
17255 +*
17256 +* --------------------------------------------------------------------
17257 +*/
17258 +
17259 +/*================================================================*/
17260 +/* System Includes */
17261 +#define WLAN_DBVAR prism2_debug
17262 +
17263 +#include <linux/version.h>
17264 +
17265 +#include <linux/module.h>
17266 +#include <linux/kernel.h>
17267 +#include <linux/sched.h>
17268 +#include <linux/types.h>
17269 +#include <linux/slab.h>
17270 +#include <linux/wireless.h>
17271 +#include <linux/netdevice.h>
17272 +#include <asm/io.h>
17273 +#include <linux/delay.h>
17274 +#include <asm/byteorder.h>
17275 +#include <linux/usb.h>
17276 +
17277 +/*================================================================*/
17278 +/* Project Includes */
17279 +
17280 +#include "p80211types.h"
17281 +#include "p80211hdr.h"
17282 +#include "p80211mgmt.h"
17283 +#include "p80211conv.h"
17284 +#include "p80211msg.h"
17285 +#include "p80211netdev.h"
17286 +#include "p80211metadef.h"
17287 +#include "p80211metastruct.h"
17288 +#include "hfa384x.h"
17289 +#include "prism2mgmt.h"
17290 +
17291 +/*================================================================*/
17292 +/* Local Constants */
17293 +
17294 +#define MIB_TMP_MAXLEN 200 /* Max length of RID record (in bytes). */
17295 +
17296 +/*================================================================*/
17297 +/* Local Types */
17298 +
17299 +#define F_STA 0x1 /* MIB is supported on stations. */
17300 +#define F_READ 0x2 /* MIB may be read. */
17301 +#define F_WRITE 0x4 /* MIB may be written. */
17302 +
17303 +typedef struct mibrec
17304 +{
17305 + u32 did;
17306 + u16 flag;
17307 + u16 parm1;
17308 + u16 parm2;
17309 + u16 parm3;
17310 + int (*func)(struct mibrec *mib,
17311 + int isget,
17312 + wlandevice_t *wlandev,
17313 + hfa384x_t *hw,
17314 + p80211msg_dot11req_mibset_t *msg,
17315 + void *data);
17316 +} mibrec_t;
17317 +
17318 +/*================================================================*/
17319 +/* Local Function Declarations */
17320 +
17321 +static int prism2mib_bytearea2pstr(
17322 +mibrec_t *mib,
17323 +int isget,
17324 +wlandevice_t *wlandev,
17325 +hfa384x_t *hw,
17326 +p80211msg_dot11req_mibset_t *msg,
17327 +void *data);
17328 +
17329 +static int prism2mib_uint32(
17330 +mibrec_t *mib,
17331 +int isget,
17332 +wlandevice_t *wlandev,
17333 +hfa384x_t *hw,
17334 +p80211msg_dot11req_mibset_t *msg,
17335 +void *data);
17336 +
17337 +static int prism2mib_flag(
17338 +mibrec_t *mib,
17339 +int isget,
17340 +wlandevice_t *wlandev,
17341 +hfa384x_t *hw,
17342 +p80211msg_dot11req_mibset_t *msg,
17343 +void *data);
17344 +
17345 +static int prism2mib_wepdefaultkey(
17346 +mibrec_t *mib,
17347 +int isget,
17348 +wlandevice_t *wlandev,
17349 +hfa384x_t *hw,
17350 +p80211msg_dot11req_mibset_t *msg,
17351 +void *data);
17352 +
17353 +static int prism2mib_privacyinvoked(
17354 +mibrec_t *mib,
17355 +int isget,
17356 +wlandevice_t *wlandev,
17357 +hfa384x_t *hw,
17358 +p80211msg_dot11req_mibset_t *msg,
17359 +void *data);
17360 +
17361 +static int prism2mib_excludeunencrypted(
17362 +mibrec_t *mib,
17363 +int isget,
17364 +wlandevice_t *wlandev,
17365 +hfa384x_t *hw,
17366 +p80211msg_dot11req_mibset_t *msg,
17367 +void *data);
17368 +
17369 +static int prism2mib_fragmentationthreshold(
17370 +mibrec_t *mib,
17371 +int isget,
17372 +wlandevice_t *wlandev,
17373 +hfa384x_t *hw,
17374 +p80211msg_dot11req_mibset_t *msg,
17375 +void *data);
17376 +
17377 +static int prism2mib_priv(
17378 +mibrec_t *mib,
17379 +int isget,
17380 +wlandevice_t *wlandev,
17381 +hfa384x_t *hw,
17382 +p80211msg_dot11req_mibset_t *msg,
17383 +void *data);
17384 +
17385 +/*================================================================*/
17386 +/* Local Static Definitions */
17387 +
17388 +static mibrec_t mibtab[] = {
17389 +
17390 + /* dot11smt MIB's */
17391 + { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0,
17392 + F_STA | F_WRITE,
17393 + HFA384x_RID_CNFWEPDEFAULTKEY0, 0, 0,
17394 + prism2mib_wepdefaultkey },
17395 + { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1,
17396 + F_STA | F_WRITE,
17397 + HFA384x_RID_CNFWEPDEFAULTKEY1, 0, 0,
17398 + prism2mib_wepdefaultkey },
17399 + { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2,
17400 + F_STA | F_WRITE,
17401 + HFA384x_RID_CNFWEPDEFAULTKEY2, 0, 0,
17402 + prism2mib_wepdefaultkey },
17403 + { DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3,
17404 + F_STA | F_WRITE,
17405 + HFA384x_RID_CNFWEPDEFAULTKEY3, 0, 0,
17406 + prism2mib_wepdefaultkey },
17407 + { DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
17408 + F_STA | F_READ | F_WRITE,
17409 + HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_PRIVINVOKED, 0,
17410 + prism2mib_privacyinvoked },
17411 + { DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
17412 + F_STA | F_READ | F_WRITE,
17413 + HFA384x_RID_CNFWEPDEFAULTKEYID, 0, 0,
17414 + prism2mib_uint32 },
17415 + { DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
17416 + F_STA | F_READ | F_WRITE,
17417 + HFA384x_RID_CNFWEPFLAGS, HFA384x_WEPFLAGS_EXCLUDE, 0,
17418 + prism2mib_excludeunencrypted },
17419 +
17420 + /* dot11mac MIB's */
17421 +
17422 + { DIDmib_dot11mac_dot11OperationTable_dot11MACAddress,
17423 + F_STA | F_READ | F_WRITE,
17424 + HFA384x_RID_CNFOWNMACADDR, HFA384x_RID_CNFOWNMACADDR_LEN, 0,
17425 + prism2mib_bytearea2pstr },
17426 + { DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
17427 + F_STA | F_READ | F_WRITE,
17428 + HFA384x_RID_RTSTHRESH, 0, 0,
17429 + prism2mib_uint32 },
17430 + { DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit,
17431 + F_STA | F_READ,
17432 + HFA384x_RID_SHORTRETRYLIMIT, 0, 0,
17433 + prism2mib_uint32 },
17434 + { DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit,
17435 + F_STA | F_READ,
17436 + HFA384x_RID_LONGRETRYLIMIT, 0, 0,
17437 + prism2mib_uint32 },
17438 + { DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
17439 + F_STA | F_READ | F_WRITE,
17440 + HFA384x_RID_FRAGTHRESH, 0, 0,
17441 + prism2mib_fragmentationthreshold },
17442 + { DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime,
17443 + F_STA | F_READ,
17444 + HFA384x_RID_MAXTXLIFETIME, 0, 0,
17445 + prism2mib_uint32 },
17446 +
17447 + /* dot11phy MIB's */
17448 +
17449 + { DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
17450 + F_STA | F_READ,
17451 + HFA384x_RID_CURRENTCHANNEL, 0, 0,
17452 + prism2mib_uint32 },
17453 + { DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
17454 + F_STA | F_READ | F_WRITE,
17455 + HFA384x_RID_TXPOWERMAX, 0, 0,
17456 + prism2mib_uint32 },
17457 +
17458 + /* p2Static MIB's */
17459 +
17460 + { DIDmib_p2_p2Static_p2CnfPortType,
17461 + F_STA | F_READ | F_WRITE,
17462 + HFA384x_RID_CNFPORTTYPE, 0, 0,
17463 + prism2mib_uint32 },
17464 +
17465 + /* p2MAC MIB's */
17466 +
17467 + { DIDmib_p2_p2MAC_p2CurrentTxRate,
17468 + F_STA | F_READ,
17469 + HFA384x_RID_CURRENTTXRATE, 0, 0,
17470 + prism2mib_uint32 },
17471 +
17472 + /* And finally, lnx mibs */
17473 + { DIDmib_lnx_lnxConfigTable_lnxRSNAIE,
17474 + F_STA | F_READ | F_WRITE,
17475 + HFA384x_RID_CNFWPADATA, 0, 0,
17476 + prism2mib_priv },
17477 + { 0, 0, 0, 0, 0, NULL}};
17478 +
17479 +/*================================================================*/
17480 +/* Function Definitions */
17481 +
17482 +/*----------------------------------------------------------------
17483 +* prism2mgmt_mibset_mibget
17484 +*
17485 +* Set the value of a mib item.
17486 +*
17487 +* Arguments:
17488 +* wlandev wlan device structure
17489 +* msgp ptr to msg buffer
17490 +*
17491 +* Returns:
17492 +* 0 success and done
17493 +* <0 success, but we're waiting for something to finish.
17494 +* >0 an error occurred while handling the message.
17495 +* Side effects:
17496 +*
17497 +* Call context:
17498 +* process thread (usually)
17499 +* interrupt
17500 +----------------------------------------------------------------*/
17501 +
17502 +int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp)
17503 +{
17504 + hfa384x_t *hw = wlandev->priv;
17505 + int result, isget;
17506 + mibrec_t *mib;
17507 +
17508 + u16 which;
17509 +
17510 + p80211msg_dot11req_mibset_t *msg = msgp;
17511 + p80211itemd_t *mibitem;
17512 +
17513 + DBFENTER;
17514 +
17515 + msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
17516 + msg->resultcode.data = P80211ENUM_resultcode_success;
17517 +
17518 + /*
17519 + ** Determine if this is an Access Point or a station.
17520 + */
17521 +
17522 + which = F_STA;
17523 +
17524 + /*
17525 + ** Find the MIB in the MIB table. Note that a MIB may be in the
17526 + ** table twice...once for an AP and once for a station. Make sure
17527 + ** to get the correct one. Note that DID=0 marks the end of the
17528 + ** MIB table.
17529 + */
17530 +
17531 + mibitem = (p80211itemd_t *) msg->mibattribute.data;
17532 +
17533 + for (mib = mibtab; mib->did != 0; mib++)
17534 + if (mib->did == mibitem->did && (mib->flag & which))
17535 + break;
17536 +
17537 + if (mib->did == 0) {
17538 + msg->resultcode.data = P80211ENUM_resultcode_not_supported;
17539 + goto done;
17540 + }
17541 +
17542 + /*
17543 + ** Determine if this is a "mibget" or a "mibset". If this is a
17544 + ** "mibget", then make sure that the MIB may be read. Otherwise,
17545 + ** this is a "mibset" so make make sure that the MIB may be written.
17546 + */
17547 +
17548 + isget = (msg->msgcode == DIDmsg_dot11req_mibget);
17549 +
17550 + if (isget) {
17551 + if (!(mib->flag & F_READ)) {
17552 + msg->resultcode.data =
17553 + P80211ENUM_resultcode_cant_get_writeonly_mib;
17554 + goto done;
17555 + }
17556 + } else {
17557 + if (!(mib->flag & F_WRITE)) {
17558 + msg->resultcode.data =
17559 + P80211ENUM_resultcode_cant_set_readonly_mib;
17560 + goto done;
17561 + }
17562 + }
17563 +
17564 + /*
17565 + ** Execute the MIB function. If things worked okay, then make
17566 + ** sure that the MIB function also worked okay. If so, and this
17567 + ** is a "mibget", then the status value must be set for both the
17568 + ** "mibattribute" parameter and the mib item within the data
17569 + ** portion of the "mibattribute".
17570 + */
17571 +
17572 + result = mib->func(mib, isget, wlandev, hw, msg,
17573 + (void *) mibitem->data);
17574 +
17575 + if (msg->resultcode.data == P80211ENUM_resultcode_success) {
17576 + if (result != 0) {
17577 + WLAN_LOG_DEBUG(1, "get/set failure, result=%d\n",
17578 + result);
17579 + msg->resultcode.data =
17580 + P80211ENUM_resultcode_implementation_failure;
17581 + } else {
17582 + if (isget) {
17583 + msg->mibattribute.status =
17584 + P80211ENUM_msgitem_status_data_ok;
17585 + mibitem->status =
17586 + P80211ENUM_msgitem_status_data_ok;
17587 + }
17588 + }
17589 + }
17590 +
17591 +done:
17592 + DBFEXIT;
17593 +
17594 + return(0);
17595 +}
17596 +
17597 +/*----------------------------------------------------------------
17598 +* prism2mib_bytearea2pstr
17599 +*
17600 +* Get/set pstr data to/from a byte area.
17601 +*
17602 +* MIB record parameters:
17603 +* parm1 Prism2 RID value.
17604 +* parm2 Number of bytes of RID data.
17605 +* parm3 Not used.
17606 +*
17607 +* Arguments:
17608 +* mib MIB record.
17609 +* isget MIBGET/MIBSET flag.
17610 +* wlandev wlan device structure.
17611 +* priv "priv" structure.
17612 +* hw "hw" structure.
17613 +* msg Message structure.
17614 +* data Data buffer.
17615 +*
17616 +* Returns:
17617 +* 0 - Success.
17618 +* ~0 - Error.
17619 +*
17620 +----------------------------------------------------------------*/
17621 +
17622 +static int prism2mib_bytearea2pstr(
17623 +mibrec_t *mib,
17624 +int isget,
17625 +wlandevice_t *wlandev,
17626 +hfa384x_t *hw,
17627 +p80211msg_dot11req_mibset_t *msg,
17628 +void *data)
17629 +{
17630 + int result;
17631 + p80211pstrd_t *pstr = (p80211pstrd_t*) data;
17632 + u8 bytebuf[MIB_TMP_MAXLEN];
17633 +
17634 + DBFENTER;
17635 +
17636 + if (isget) {
17637 + result = hfa384x_drvr_getconfig(hw, mib->parm1, bytebuf, mib->parm2);
17638 + prism2mgmt_bytearea2pstr(bytebuf, pstr, mib->parm2);
17639 + } else {
17640 + memset(bytebuf, 0, mib->parm2);
17641 + prism2mgmt_pstr2bytearea(bytebuf, pstr);
17642 + result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, mib->parm2);
17643 + }
17644 +
17645 + DBFEXIT;
17646 + return(result);
17647 +}
17648 +
17649 +/*----------------------------------------------------------------
17650 +* prism2mib_uint32
17651 +*
17652 +* Get/set uint32 data.
17653 +*
17654 +* MIB record parameters:
17655 +* parm1 Prism2 RID value.
17656 +* parm2 Not used.
17657 +* parm3 Not used.
17658 +*
17659 +* Arguments:
17660 +* mib MIB record.
17661 +* isget MIBGET/MIBSET flag.
17662 +* wlandev wlan device structure.
17663 +* priv "priv" structure.
17664 +* hw "hw" structure.
17665 +* msg Message structure.
17666 +* data Data buffer.
17667 +*
17668 +* Returns:
17669 +* 0 - Success.
17670 +* ~0 - Error.
17671 +*
17672 +----------------------------------------------------------------*/
17673 +
17674 +static int prism2mib_uint32(
17675 +mibrec_t *mib,
17676 +int isget,
17677 +wlandevice_t *wlandev,
17678 +hfa384x_t *hw,
17679 +p80211msg_dot11req_mibset_t *msg,
17680 +void *data)
17681 +{
17682 + int result;
17683 + u32 *uint32 = (u32*) data;
17684 + u8 bytebuf[MIB_TMP_MAXLEN];
17685 + u16 *wordbuf = (u16*) bytebuf;
17686 +
17687 + DBFENTER;
17688 +
17689 + if (isget) {
17690 + result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
17691 + *uint32 = *wordbuf;
17692 + /* [MSM] Removed, getconfig16 returns the value in host order.
17693 + * prism2mgmt_prism2int2p80211int(wordbuf, uint32);
17694 + */
17695 + } else {
17696 + /* [MSM] Removed, setconfig16 expects host order.
17697 + * prism2mgmt_p80211int2prism2int(wordbuf, uint32);
17698 + */
17699 + *wordbuf = *uint32;
17700 + result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
17701 + }
17702 +
17703 + DBFEXIT;
17704 + return(result);
17705 +}
17706 +
17707 +/*----------------------------------------------------------------
17708 +* prism2mib_flag
17709 +*
17710 +* Get/set a flag.
17711 +*
17712 +* MIB record parameters:
17713 +* parm1 Prism2 RID value.
17714 +* parm2 Bit to get/set.
17715 +* parm3 Not used.
17716 +*
17717 +* Arguments:
17718 +* mib MIB record.
17719 +* isget MIBGET/MIBSET flag.
17720 +* wlandev wlan device structure.
17721 +* priv "priv" structure.
17722 +* hw "hw" structure.
17723 +* msg Message structure.
17724 +* data Data buffer.
17725 +*
17726 +* Returns:
17727 +* 0 - Success.
17728 +* ~0 - Error.
17729 +*
17730 +----------------------------------------------------------------*/
17731 +
17732 +static int prism2mib_flag(
17733 +mibrec_t *mib,
17734 +int isget,
17735 +wlandevice_t *wlandev,
17736 +hfa384x_t *hw,
17737 +p80211msg_dot11req_mibset_t *msg,
17738 +void *data)
17739 +{
17740 + int result;
17741 + u32 *uint32 = (u32*) data;
17742 + u8 bytebuf[MIB_TMP_MAXLEN];
17743 + u16 *wordbuf = (u16*) bytebuf;
17744 + u32 flags;
17745 +
17746 + DBFENTER;
17747 +
17748 + result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf);
17749 + if (result == 0) {
17750 + /* [MSM] Removed, getconfig16 returns the value in host order.
17751 + * prism2mgmt_prism2int2p80211int(wordbuf, &flags);
17752 + */
17753 + flags = *wordbuf;
17754 + if (isget) {
17755 + *uint32 = (flags & mib->parm2) ?
17756 + P80211ENUM_truth_true : P80211ENUM_truth_false;
17757 + } else {
17758 + if ((*uint32) == P80211ENUM_truth_true)
17759 + flags |= mib->parm2;
17760 + else
17761 + flags &= ~mib->parm2;
17762 + /* [MSM] Removed, setconfig16 expects host order.
17763 + * prism2mgmt_p80211int2prism2int(wordbuf, &flags);
17764 + */
17765 + *wordbuf = flags;
17766 + result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf);
17767 + }
17768 + }
17769 +
17770 + DBFEXIT;
17771 + return(result);
17772 +}
17773 +
17774 +/*----------------------------------------------------------------
17775 +* prism2mib_wepdefaultkey
17776 +*
17777 +* Get/set WEP default keys.
17778 +*
17779 +* MIB record parameters:
17780 +* parm1 Prism2 RID value.
17781 +* parm2 Number of bytes of RID data.
17782 +* parm3 Not used.
17783 +*
17784 +* Arguments:
17785 +* mib MIB record.
17786 +* isget MIBGET/MIBSET flag.
17787 +* wlandev wlan device structure.
17788 +* priv "priv" structure.
17789 +* hw "hw" structure.
17790 +* msg Message structure.
17791 +* data Data buffer.
17792 +*
17793 +* Returns:
17794 +* 0 - Success.
17795 +* ~0 - Error.
17796 +*
17797 +----------------------------------------------------------------*/
17798 +
17799 +static int prism2mib_wepdefaultkey(
17800 +mibrec_t *mib,
17801 +int isget,
17802 +wlandevice_t *wlandev,
17803 +hfa384x_t *hw,
17804 +p80211msg_dot11req_mibset_t *msg,
17805 +void *data)
17806 +{
17807 + int result;
17808 + p80211pstrd_t *pstr = (p80211pstrd_t*) data;
17809 + u8 bytebuf[MIB_TMP_MAXLEN];
17810 + u16 len;
17811 +
17812 + DBFENTER;
17813 +
17814 + if (isget) {
17815 + result = 0; /* Should never happen. */
17816 + } else {
17817 + len = (pstr->len > 5) ? HFA384x_RID_CNFWEP128DEFAULTKEY_LEN :
17818 + HFA384x_RID_CNFWEPDEFAULTKEY_LEN;
17819 + memset(bytebuf, 0, len);
17820 + prism2mgmt_pstr2bytearea(bytebuf, pstr);
17821 + result = hfa384x_drvr_setconfig(hw, mib->parm1, bytebuf, len);
17822 + }
17823 +
17824 + DBFEXIT;
17825 + return(result);
17826 +}
17827 +
17828 +/*----------------------------------------------------------------
17829 +* prism2mib_privacyinvoked
17830 +*
17831 +* Get/set the dot11PrivacyInvoked value.
17832 +*
17833 +* MIB record parameters:
17834 +* parm1 Prism2 RID value.
17835 +* parm2 Bit value for PrivacyInvoked flag.
17836 +* parm3 Not used.
17837 +*
17838 +* Arguments:
17839 +* mib MIB record.
17840 +* isget MIBGET/MIBSET flag.
17841 +* wlandev wlan device structure.
17842 +* priv "priv" structure.
17843 +* hw "hw" structure.
17844 +* msg Message structure.
17845 +* data Data buffer.
17846 +*
17847 +* Returns:
17848 +* 0 - Success.
17849 +* ~0 - Error.
17850 +*
17851 +----------------------------------------------------------------*/
17852 +
17853 +static int prism2mib_privacyinvoked(
17854 +mibrec_t *mib,
17855 +int isget,
17856 +wlandevice_t *wlandev,
17857 +hfa384x_t *hw,
17858 +p80211msg_dot11req_mibset_t *msg,
17859 +void *data)
17860 +{
17861 + int result;
17862 +
17863 + DBFENTER;
17864 +
17865 + if (wlandev->hostwep & HOSTWEP_DECRYPT) {
17866 + if (wlandev->hostwep & HOSTWEP_DECRYPT)
17867 + mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
17868 + if (wlandev->hostwep & HOSTWEP_ENCRYPT)
17869 + mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_TXCRYPT;
17870 + }
17871 +
17872 + result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
17873 +
17874 + DBFEXIT;
17875 + return(result);
17876 +}
17877 +
17878 +/*----------------------------------------------------------------
17879 +* prism2mib_excludeunencrypted
17880 +*
17881 +* Get/set the dot11ExcludeUnencrypted value.
17882 +*
17883 +* MIB record parameters:
17884 +* parm1 Prism2 RID value.
17885 +* parm2 Bit value for ExcludeUnencrypted flag.
17886 +* parm3 Not used.
17887 +*
17888 +* Arguments:
17889 +* mib MIB record.
17890 +* isget MIBGET/MIBSET flag.
17891 +* wlandev wlan device structure.
17892 +* priv "priv" structure.
17893 +* hw "hw" structure.
17894 +* msg Message structure.
17895 +* data Data buffer.
17896 +*
17897 +* Returns:
17898 +* 0 - Success.
17899 +* ~0 - Error.
17900 +*
17901 +----------------------------------------------------------------*/
17902 +
17903 +static int prism2mib_excludeunencrypted(
17904 +mibrec_t *mib,
17905 +int isget,
17906 +wlandevice_t *wlandev,
17907 +hfa384x_t *hw,
17908 +p80211msg_dot11req_mibset_t *msg,
17909 +void *data)
17910 +{
17911 + int result;
17912 +
17913 + DBFENTER;
17914 +
17915 + result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
17916 +
17917 + DBFEXIT;
17918 + return(result);
17919 +}
17920 +
17921 +/*----------------------------------------------------------------
17922 +* prism2mib_fragmentationthreshold
17923 +*
17924 +* Get/set the fragmentation threshold.
17925 +*
17926 +* MIB record parameters:
17927 +* parm1 Prism2 RID value.
17928 +* parm2 Not used.
17929 +* parm3 Not used.
17930 +*
17931 +* Arguments:
17932 +* mib MIB record.
17933 +* isget MIBGET/MIBSET flag.
17934 +* wlandev wlan device structure.
17935 +* priv "priv" structure.
17936 +* hw "hw" structure.
17937 +* msg Message structure.
17938 +* data Data buffer.
17939 +*
17940 +* Returns:
17941 +* 0 - Success.
17942 +* ~0 - Error.
17943 +*
17944 +----------------------------------------------------------------*/
17945 +
17946 +static int prism2mib_fragmentationthreshold(
17947 +mibrec_t *mib,
17948 +int isget,
17949 +wlandevice_t *wlandev,
17950 +hfa384x_t *hw,
17951 +p80211msg_dot11req_mibset_t *msg,
17952 +void *data)
17953 +{
17954 + int result;
17955 + u32 *uint32 = (u32*) data;
17956 +
17957 + DBFENTER;
17958 +
17959 + if (!isget)
17960 + if ((*uint32) % 2) {
17961 + WLAN_LOG_WARNING("Attempt to set odd number "
17962 + "FragmentationThreshold\n");
17963 + msg->resultcode.data = P80211ENUM_resultcode_not_supported;
17964 + return(0);
17965 + }
17966 +
17967 + result = prism2mib_uint32(mib, isget, wlandev, hw, msg, data);
17968 +
17969 + DBFEXIT;
17970 + return(result);
17971 +}
17972 +
17973 +/*----------------------------------------------------------------
17974 +* prism2mib_priv
17975 +*
17976 +* Get/set values in the "priv" data structure.
17977 +*
17978 +* MIB record parameters:
17979 +* parm1 Not used.
17980 +* parm2 Not used.
17981 +* parm3 Not used.
17982 +*
17983 +* Arguments:
17984 +* mib MIB record.
17985 +* isget MIBGET/MIBSET flag.
17986 +* wlandev wlan device structure.
17987 +* priv "priv" structure.
17988 +* hw "hw" structure.
17989 +* msg Message structure.
17990 +* data Data buffer.
17991 +*
17992 +* Returns:
17993 +* 0 - Success.
17994 +* ~0 - Error.
17995 +*
17996 +----------------------------------------------------------------*/
17997 +
17998 +static int prism2mib_priv(
17999 +mibrec_t *mib,
18000 +int isget,
18001 +wlandevice_t *wlandev,
18002 +hfa384x_t *hw,
18003 +p80211msg_dot11req_mibset_t *msg,
18004 +void *data)
18005 +{
18006 + p80211pstrd_t *pstr = (p80211pstrd_t*) data;
18007 +
18008 + int result;
18009 +
18010 + DBFENTER;
18011 +
18012 + switch (mib->did) {
18013 + case DIDmib_lnx_lnxConfigTable_lnxRSNAIE: {
18014 + hfa384x_WPAData_t wpa;
18015 + if (isget) {
18016 + hfa384x_drvr_getconfig( hw, HFA384x_RID_CNFWPADATA,
18017 + (u8 *) &wpa, sizeof(wpa));
18018 + pstr->len = hfa384x2host_16(wpa.datalen);
18019 + memcpy(pstr->data, wpa.data, pstr->len);
18020 + } else {
18021 + wpa.datalen = host2hfa384x_16(pstr->len);
18022 + memcpy(wpa.data, pstr->data, pstr->len);
18023 +
18024 + result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFWPADATA,
18025 + (u8 *) &wpa, sizeof(wpa));
18026 + }
18027 + break;
18028 + }
18029 + default:
18030 + WLAN_LOG_ERROR("Unhandled DID 0x%08x\n", mib->did);
18031 + }
18032 +
18033 + DBFEXIT;
18034 + return(0);
18035 +}
18036 +
18037 +/*----------------------------------------------------------------
18038 +* prism2mgmt_pstr2bytestr
18039 +*
18040 +* Convert the pstr data in the WLAN message structure into an hfa384x
18041 +* byte string format.
18042 +*
18043 +* Arguments:
18044 +* bytestr hfa384x byte string data type
18045 +* pstr wlan message data
18046 +*
18047 +* Returns:
18048 +* Nothing
18049 +*
18050 +----------------------------------------------------------------*/
18051 +
18052 +void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
18053 +{
18054 + DBFENTER;
18055 +
18056 + bytestr->len = host2hfa384x_16((u16)(pstr->len));
18057 + memcpy(bytestr->data, pstr->data, pstr->len);
18058 + DBFEXIT;
18059 +}
18060 +
18061 +
18062 +/*----------------------------------------------------------------
18063 +* prism2mgmt_pstr2bytearea
18064 +*
18065 +* Convert the pstr data in the WLAN message structure into an hfa384x
18066 +* byte area format.
18067 +*
18068 +* Arguments:
18069 +* bytearea hfa384x byte area data type
18070 +* pstr wlan message data
18071 +*
18072 +* Returns:
18073 +* Nothing
18074 +*
18075 +----------------------------------------------------------------*/
18076 +
18077 +void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr)
18078 +{
18079 + DBFENTER;
18080 +
18081 + memcpy(bytearea, pstr->data, pstr->len);
18082 + DBFEXIT;
18083 +}
18084 +
18085 +
18086 +/*----------------------------------------------------------------
18087 +* prism2mgmt_bytestr2pstr
18088 +*
18089 +* Convert the data in an hfa384x byte string format into a
18090 +* pstr in the WLAN message.
18091 +*
18092 +* Arguments:
18093 +* bytestr hfa384x byte string data type
18094 +* msg wlan message
18095 +*
18096 +* Returns:
18097 +* Nothing
18098 +*
18099 +----------------------------------------------------------------*/
18100 +
18101 +void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr)
18102 +{
18103 + DBFENTER;
18104 +
18105 + pstr->len = (u8)(hfa384x2host_16((u16)(bytestr->len)));
18106 + memcpy(pstr->data, bytestr->data, pstr->len);
18107 + DBFEXIT;
18108 +}
18109 +
18110 +
18111 +/*----------------------------------------------------------------
18112 +* prism2mgmt_bytearea2pstr
18113 +*
18114 +* Convert the data in an hfa384x byte area format into a pstr
18115 +* in the WLAN message.
18116 +*
18117 +* Arguments:
18118 +* bytearea hfa384x byte area data type
18119 +* msg wlan message
18120 +*
18121 +* Returns:
18122 +* Nothing
18123 +*
18124 +----------------------------------------------------------------*/
18125 +
18126 +void prism2mgmt_bytearea2pstr(u8 *bytearea, p80211pstrd_t *pstr, int len)
18127 +{
18128 + DBFENTER;
18129 +
18130 + pstr->len = (u8)len;
18131 + memcpy(pstr->data, bytearea, len);
18132 + DBFEXIT;
18133 +}
18134 +
18135 +
18136 +/*----------------------------------------------------------------
18137 +* prism2mgmt_prism2int2p80211int
18138 +*
18139 +* Convert an hfa384x integer into a wlan integer
18140 +*
18141 +* Arguments:
18142 +* prism2enum pointer to hfa384x integer
18143 +* wlanenum pointer to p80211 integer
18144 +*
18145 +* Returns:
18146 +* Nothing
18147 +*
18148 +----------------------------------------------------------------*/
18149 +
18150 +void prism2mgmt_prism2int2p80211int(u16 *prism2int, u32 *wlanint)
18151 +{
18152 + DBFENTER;
18153 +
18154 + *wlanint = (u32)hfa384x2host_16(*prism2int);
18155 + DBFEXIT;
18156 +}
18157 +
18158 +
18159 +/*----------------------------------------------------------------
18160 +* prism2mgmt_p80211int2prism2int
18161 +*
18162 +* Convert a wlan integer into an hfa384x integer
18163 +*
18164 +* Arguments:
18165 +* prism2enum pointer to hfa384x integer
18166 +* wlanenum pointer to p80211 integer
18167 +*
18168 +* Returns:
18169 +* Nothing
18170 +*
18171 +----------------------------------------------------------------*/
18172 +
18173 +void prism2mgmt_p80211int2prism2int(u16 *prism2int, u32 *wlanint)
18174 +{
18175 + DBFENTER;
18176 +
18177 + *prism2int = host2hfa384x_16((u16)(*wlanint));
18178 + DBFEXIT;
18179 +}
18180 +
18181 +
18182 +/*----------------------------------------------------------------
18183 +* prism2mgmt_prism2enum2p80211enum
18184 +*
18185 +* Convert the hfa384x enumerated int into a p80211 enumerated int
18186 +*
18187 +* Arguments:
18188 +* prism2enum pointer to hfa384x integer
18189 +* wlanenum pointer to p80211 integer
18190 +* rid hfa384x record id
18191 +*
18192 +* Returns:
18193 +* Nothing
18194 +*
18195 +----------------------------------------------------------------*/
18196 +void prism2mgmt_prism2enum2p80211enum(u16 *prism2enum, u32 *wlanenum, u16 rid)
18197 +{
18198 + DBFENTER;
18199 +
18200 + /* At the moment, the need for this functionality hasn't
18201 + presented itself. All the wlan enumerated values are
18202 + a 1-to-1 match against the Prism2 enumerated values*/
18203 + DBFEXIT;
18204 + return;
18205 +}
18206 +
18207 +
18208 +/*----------------------------------------------------------------
18209 +* prism2mgmt_p80211enum2prism2enum
18210 +*
18211 +* Convert the p80211 enumerated int into an hfa384x enumerated int
18212 +*
18213 +* Arguments:
18214 +* prism2enum pointer to hfa384x integer
18215 +* wlanenum pointer to p80211 integer
18216 +* rid hfa384x record id
18217 +*
18218 +* Returns:
18219 +* Nothing
18220 +*
18221 +----------------------------------------------------------------*/
18222 +void prism2mgmt_p80211enum2prism2enum(u16 *prism2enum, u32 *wlanenum, u16 rid)
18223 +{
18224 + DBFENTER;
18225 +
18226 + /* At the moment, the need for this functionality hasn't
18227 + presented itself. All the wlan enumerated values are
18228 + a 1-to-1 match against the Prism2 enumerated values*/
18229 + DBFEXIT;
18230 + return;
18231 +}
18232 +
18233 +
18234 +
18235 +/*----------------------------------------------------------------
18236 +* prism2mgmt_get_oprateset
18237 +*
18238 +* Convert the hfa384x bit area into a wlan octet string.
18239 +*
18240 +* Arguments:
18241 +* rate Prism2 bit area
18242 +* pstr wlan octet string
18243 +*
18244 +* Returns:
18245 +* Nothing
18246 +*
18247 +----------------------------------------------------------------*/
18248 +void prism2mgmt_get_oprateset(u16 *rate, p80211pstrd_t *pstr)
18249 +{
18250 + u8 len;
18251 + u8 *datarate;
18252 +
18253 + DBFENTER;
18254 +
18255 + len = 0;
18256 + datarate = pstr->data;
18257 +
18258 + /* 1 Mbps */
18259 + if ( BIT0 & (*rate) ) {
18260 + len += (u8)1;
18261 + *datarate = (u8)2;
18262 + datarate++;
18263 + }
18264 +
18265 + /* 2 Mbps */
18266 + if ( BIT1 & (*rate) ) {
18267 + len += (u8)1;
18268 + *datarate = (u8)4;
18269 + datarate++;
18270 + }
18271 +
18272 + /* 5.5 Mbps */
18273 + if ( BIT2 & (*rate) ) {
18274 + len += (u8)1;
18275 + *datarate = (u8)11;
18276 + datarate++;
18277 + }
18278 +
18279 + /* 11 Mbps */
18280 + if ( BIT3 & (*rate) ) {
18281 + len += (u8)1;
18282 + *datarate = (u8)22;
18283 + datarate++;
18284 + }
18285 +
18286 + pstr->len = len;
18287 +
18288 + DBFEXIT;
18289 + return;
18290 +}
18291 +
18292 +
18293 +
18294 +/*----------------------------------------------------------------
18295 +* prism2mgmt_set_oprateset
18296 +*
18297 +* Convert the wlan octet string into an hfa384x bit area.
18298 +*
18299 +* Arguments:
18300 +* rate Prism2 bit area
18301 +* pstr wlan octet string
18302 +*
18303 +* Returns:
18304 +* Nothing
18305 +*
18306 +----------------------------------------------------------------*/
18307 +void prism2mgmt_set_oprateset(u16 *rate, p80211pstrd_t *pstr)
18308 +{
18309 + u8 *datarate;
18310 + int i;
18311 +
18312 + DBFENTER;
18313 +
18314 + *rate = 0;
18315 +
18316 + datarate = pstr->data;
18317 +
18318 + for ( i=0; i < pstr->len; i++, datarate++ ) {
18319 + switch (*datarate) {
18320 + case 2: /* 1 Mbps */
18321 + *rate |= BIT0;
18322 + break;
18323 + case 4: /* 2 Mbps */
18324 + *rate |= BIT1;
18325 + break;
18326 + case 11: /* 5.5 Mbps */
18327 + *rate |= BIT2;
18328 + break;
18329 + case 22: /* 11 Mbps */
18330 + *rate |= BIT3;
18331 + break;
18332 + default:
18333 + WLAN_LOG_DEBUG(1, "Unrecoginzed Rate of %d\n",
18334 + *datarate);
18335 + break;
18336 + }
18337 + }
18338 +
18339 + DBFEXIT;
18340 + return;
18341 +}
18342 --- /dev/null
18343 +++ b/drivers/staging/wlan-ng/prism2sta.c
18344 @@ -0,0 +1,2212 @@
18345 +/* src/prism2/driver/prism2sta.c
18346 +*
18347 +* Implements the station functionality for prism2
18348 +*
18349 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
18350 +* --------------------------------------------------------------------
18351 +*
18352 +* linux-wlan
18353 +*
18354 +* The contents of this file are subject to the Mozilla Public
18355 +* License Version 1.1 (the "License"); you may not use this file
18356 +* except in compliance with the License. You may obtain a copy of
18357 +* the License at http://www.mozilla.org/MPL/
18358 +*
18359 +* Software distributed under the License is distributed on an "AS
18360 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
18361 +* implied. See the License for the specific language governing
18362 +* rights and limitations under the License.
18363 +*
18364 +* Alternatively, the contents of this file may be used under the
18365 +* terms of the GNU Public License version 2 (the "GPL"), in which
18366 +* case the provisions of the GPL are applicable instead of the
18367 +* above. If you wish to allow the use of your version of this file
18368 +* only under the terms of the GPL and not to allow others to use
18369 +* your version of this file under the MPL, indicate your decision
18370 +* by deleting the provisions above and replace them with the notice
18371 +* and other provisions required by the GPL. If you do not delete
18372 +* the provisions above, a recipient may use your version of this
18373 +* file under either the MPL or the GPL.
18374 +*
18375 +* --------------------------------------------------------------------
18376 +*
18377 +* Inquiries regarding the linux-wlan Open Source project can be
18378 +* made directly to:
18379 +*
18380 +* AbsoluteValue Systems Inc.
18381 +* info@linux-wlan.com
18382 +* http://www.linux-wlan.com
18383 +*
18384 +* --------------------------------------------------------------------
18385 +*
18386 +* Portions of the development of this software were funded by
18387 +* Intersil Corporation as part of PRISM(R) chipset product development.
18388 +*
18389 +* --------------------------------------------------------------------
18390 +*
18391 +* This file implements the module and linux pcmcia routines for the
18392 +* prism2 driver.
18393 +*
18394 +* --------------------------------------------------------------------
18395 +*/
18396 +
18397 +/*================================================================*/
18398 +/* System Includes */
18399 +#define WLAN_DBVAR prism2_debug
18400 +
18401 +#include <linux/version.h>
18402 +#include <linux/module.h>
18403 +#include <linux/moduleparam.h>
18404 +#include <linux/kernel.h>
18405 +#include <linux/sched.h>
18406 +#include <linux/types.h>
18407 +#include <linux/init.h>
18408 +#include <linux/slab.h>
18409 +#include <linux/wireless.h>
18410 +#include <linux/netdevice.h>
18411 +#include <linux/workqueue.h>
18412 +
18413 +#include <asm/io.h>
18414 +#include <linux/delay.h>
18415 +#include <asm/byteorder.h>
18416 +#include <linux/if_arp.h>
18417 +
18418 +#include "wlan_compat.h"
18419 +
18420 +/*================================================================*/
18421 +/* Project Includes */
18422 +
18423 +#include "p80211types.h"
18424 +#include "p80211hdr.h"
18425 +#include "p80211mgmt.h"
18426 +#include "p80211conv.h"
18427 +#include "p80211msg.h"
18428 +#include "p80211netdev.h"
18429 +#include "p80211req.h"
18430 +#include "p80211metadef.h"
18431 +#include "p80211metastruct.h"
18432 +#include "hfa384x.h"
18433 +#include "prism2mgmt.h"
18434 +
18435 +/*================================================================*/
18436 +/* Local Constants */
18437 +
18438 +/*================================================================*/
18439 +/* Local Macros */
18440 +
18441 +/*================================================================*/
18442 +/* Local Types */
18443 +
18444 +/*================================================================*/
18445 +/* Local Static Definitions */
18446 +
18447 +static char *dev_info = "prism2_usb";
18448 +
18449 +static wlandevice_t *create_wlan(void);
18450 +
18451 +/*----------------------------------------------------------------*/
18452 +/* --Module Parameters */
18453 +
18454 +int prism2_reset_holdtime=30; /* Reset hold time in ms */
18455 +int prism2_reset_settletime=100; /* Reset settle time in ms */
18456 +
18457 +static int prism2_doreset=0; /* Do a reset at init? */
18458 +
18459 +#ifdef WLAN_INCLUDE_DEBUG
18460 +int prism2_debug=0;
18461 +module_param( prism2_debug, int, 0644);
18462 +MODULE_PARM_DESC(prism2_debug, "prism2 debugging");
18463 +#endif
18464 +
18465 +module_param( prism2_doreset, int, 0644);
18466 +MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
18467 +
18468 +module_param( prism2_reset_holdtime, int, 0644);
18469 +MODULE_PARM_DESC( prism2_reset_holdtime, "reset hold time in ms");
18470 +module_param( prism2_reset_settletime, int, 0644);
18471 +MODULE_PARM_DESC( prism2_reset_settletime, "reset settle time in ms");
18472 +
18473 +MODULE_LICENSE("Dual MPL/GPL");
18474 +
18475 +/*================================================================*/
18476 +/* Local Function Declarations */
18477 +
18478 +static int prism2sta_open(wlandevice_t *wlandev);
18479 +static int prism2sta_close(wlandevice_t *wlandev);
18480 +static void prism2sta_reset(wlandevice_t *wlandev );
18481 +static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
18482 +static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg);
18483 +static int prism2sta_getcardinfo(wlandevice_t *wlandev);
18484 +static int prism2sta_globalsetup(wlandevice_t *wlandev);
18485 +static int prism2sta_setmulticast(wlandevice_t *wlandev,
18486 + netdevice_t *dev);
18487 +
18488 +static void prism2sta_inf_handover(
18489 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18490 +static void prism2sta_inf_tallies(
18491 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18492 +static void prism2sta_inf_hostscanresults(
18493 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18494 +static void prism2sta_inf_scanresults(
18495 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18496 +static void prism2sta_inf_chinforesults(
18497 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18498 +static void prism2sta_inf_linkstatus(
18499 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18500 +static void prism2sta_inf_assocstatus(
18501 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18502 +static void prism2sta_inf_authreq(
18503 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18504 +static void prism2sta_inf_authreq_defer(
18505 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18506 +static void prism2sta_inf_psusercnt(
18507 + wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
18508 +
18509 +/*================================================================*/
18510 +/* Function Definitions */
18511 +
18512 +/*----------------------------------------------------------------
18513 +* dmpmem
18514 +*
18515 +* Debug utility function to dump memory to the kernel debug log.
18516 +*
18517 +* Arguments:
18518 +* buf ptr data we want dumped
18519 +* len length of data
18520 +*
18521 +* Returns:
18522 +* nothing
18523 +* Side effects:
18524 +*
18525 +* Call context:
18526 +* process thread
18527 +* interrupt
18528 +----------------------------------------------------------------*/
18529 +inline void dmpmem(void *buf, int n)
18530 +{
18531 + int c;
18532 + for ( c= 0; c < n; c++) {
18533 + if ( (c % 16) == 0 ) printk(KERN_DEBUG"dmp[%d]: ", c);
18534 + printk("%02x ", ((u8*)buf)[c]);
18535 + if ( (c % 16) == 15 ) printk("\n");
18536 + }
18537 + if ( (c % 16) != 0 ) printk("\n");
18538 +}
18539 +
18540 +
18541 +/*----------------------------------------------------------------
18542 +* prism2sta_open
18543 +*
18544 +* WLAN device open method. Called from p80211netdev when kernel
18545 +* device open (start) method is called in response to the
18546 +* SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
18547 +* from clear to set.
18548 +*
18549 +* Arguments:
18550 +* wlandev wlan device structure
18551 +*
18552 +* Returns:
18553 +* 0 success
18554 +* >0 f/w reported error
18555 +* <0 driver reported error
18556 +*
18557 +* Side effects:
18558 +*
18559 +* Call context:
18560 +* process thread
18561 +----------------------------------------------------------------*/
18562 +static int prism2sta_open(wlandevice_t *wlandev)
18563 +{
18564 + DBFENTER;
18565 +
18566 + /* We don't currently have to do anything else.
18567 + * The setup of the MAC should be subsequently completed via
18568 + * the mlme commands.
18569 + * Higher layers know we're ready from dev->start==1 and
18570 + * dev->tbusy==0. Our rx path knows to pass up received/
18571 + * frames because of dev->flags&IFF_UP is true.
18572 + */
18573 +
18574 + DBFEXIT;
18575 + return 0;
18576 +}
18577 +
18578 +
18579 +/*----------------------------------------------------------------
18580 +* prism2sta_close
18581 +*
18582 +* WLAN device close method. Called from p80211netdev when kernel
18583 +* device close method is called in response to the
18584 +* SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP
18585 +* from set to clear.
18586 +*
18587 +* Arguments:
18588 +* wlandev wlan device structure
18589 +*
18590 +* Returns:
18591 +* 0 success
18592 +* >0 f/w reported error
18593 +* <0 driver reported error
18594 +*
18595 +* Side effects:
18596 +*
18597 +* Call context:
18598 +* process thread
18599 +----------------------------------------------------------------*/
18600 +static int prism2sta_close(wlandevice_t *wlandev)
18601 +{
18602 + DBFENTER;
18603 +
18604 + /* We don't currently have to do anything else.
18605 + * Higher layers know we're not ready from dev->start==0 and
18606 + * dev->tbusy==1. Our rx path knows to not pass up received
18607 + * frames because of dev->flags&IFF_UP is false.
18608 + */
18609 +
18610 + DBFEXIT;
18611 + return 0;
18612 +}
18613 +
18614 +
18615 +/*----------------------------------------------------------------
18616 +* prism2sta_reset
18617 +*
18618 +* Not currently implented.
18619 +*
18620 +* Arguments:
18621 +* wlandev wlan device structure
18622 +* none
18623 +*
18624 +* Returns:
18625 +* nothing
18626 +*
18627 +* Side effects:
18628 +*
18629 +* Call context:
18630 +* process thread
18631 +----------------------------------------------------------------*/
18632 +static void prism2sta_reset(wlandevice_t *wlandev )
18633 +{
18634 + DBFENTER;
18635 + DBFEXIT;
18636 + return;
18637 +}
18638 +
18639 +
18640 +/*----------------------------------------------------------------
18641 +* prism2sta_txframe
18642 +*
18643 +* Takes a frame from p80211 and queues it for transmission.
18644 +*
18645 +* Arguments:
18646 +* wlandev wlan device structure
18647 +* pb packet buffer struct. Contains an 802.11
18648 +* data frame.
18649 +* p80211_hdr points to the 802.11 header for the packet.
18650 +* Returns:
18651 +* 0 Success and more buffs available
18652 +* 1 Success but no more buffs
18653 +* 2 Allocation failure
18654 +* 4 Buffer full or queue busy
18655 +*
18656 +* Side effects:
18657 +*
18658 +* Call context:
18659 +* process thread
18660 +----------------------------------------------------------------*/
18661 +static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
18662 + p80211_hdr_t *p80211_hdr,
18663 + p80211_metawep_t *p80211_wep)
18664 +{
18665 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
18666 + int result;
18667 + DBFENTER;
18668 +
18669 + /* If necessary, set the 802.11 WEP bit */
18670 + if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) {
18671 + p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1));
18672 + }
18673 +
18674 + result = hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
18675 +
18676 + DBFEXIT;
18677 + return result;
18678 +}
18679 +
18680 +
18681 +/*----------------------------------------------------------------
18682 +* prism2sta_mlmerequest
18683 +*
18684 +* wlan command message handler. All we do here is pass the message
18685 +* over to the prism2sta_mgmt_handler.
18686 +*
18687 +* Arguments:
18688 +* wlandev wlan device structure
18689 +* msg wlan command message
18690 +* Returns:
18691 +* 0 success
18692 +* <0 successful acceptance of message, but we're
18693 +* waiting for an async process to finish before
18694 +* we're done with the msg. When the asynch
18695 +* process is done, we'll call the p80211
18696 +* function p80211req_confirm() .
18697 +* >0 An error occurred while we were handling
18698 +* the message.
18699 +*
18700 +* Side effects:
18701 +*
18702 +* Call context:
18703 +* process thread
18704 +----------------------------------------------------------------*/
18705 +static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg)
18706 +{
18707 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
18708 +
18709 + int result = 0;
18710 + DBFENTER;
18711 +
18712 + switch( msg->msgcode )
18713 + {
18714 + case DIDmsg_dot11req_mibget :
18715 + WLAN_LOG_DEBUG(2,"Received mibget request\n");
18716 + result = prism2mgmt_mibset_mibget(wlandev, msg);
18717 + break;
18718 + case DIDmsg_dot11req_mibset :
18719 + WLAN_LOG_DEBUG(2,"Received mibset request\n");
18720 + result = prism2mgmt_mibset_mibget(wlandev, msg);
18721 + break;
18722 + case DIDmsg_dot11req_scan :
18723 + WLAN_LOG_DEBUG(2,"Received scan request\n");
18724 + result = prism2mgmt_scan(wlandev, msg);
18725 + break;
18726 + case DIDmsg_dot11req_scan_results :
18727 + WLAN_LOG_DEBUG(2,"Received scan_results request\n");
18728 + result = prism2mgmt_scan_results(wlandev, msg);
18729 + break;
18730 + case DIDmsg_dot11req_start :
18731 + WLAN_LOG_DEBUG(2,"Received mlme start request\n");
18732 + result = prism2mgmt_start(wlandev, msg);
18733 + break;
18734 + /*
18735 + * Prism2 specific messages
18736 + */
18737 + case DIDmsg_p2req_readpda :
18738 + WLAN_LOG_DEBUG(2,"Received mlme readpda request\n");
18739 + result = prism2mgmt_readpda(wlandev, msg);
18740 + break;
18741 + case DIDmsg_p2req_ramdl_state :
18742 + WLAN_LOG_DEBUG(2,"Received mlme ramdl_state request\n");
18743 + result = prism2mgmt_ramdl_state(wlandev, msg);
18744 + break;
18745 + case DIDmsg_p2req_ramdl_write :
18746 + WLAN_LOG_DEBUG(2,"Received mlme ramdl_write request\n");
18747 + result = prism2mgmt_ramdl_write(wlandev, msg);
18748 + break;
18749 + case DIDmsg_p2req_flashdl_state :
18750 + WLAN_LOG_DEBUG(2,"Received mlme flashdl_state request\n");
18751 + result = prism2mgmt_flashdl_state(wlandev, msg);
18752 + break;
18753 + case DIDmsg_p2req_flashdl_write :
18754 + WLAN_LOG_DEBUG(2,"Received mlme flashdl_write request\n");
18755 + result = prism2mgmt_flashdl_write(wlandev, msg);
18756 + break;
18757 + /*
18758 + * Linux specific messages
18759 + */
18760 + case DIDmsg_lnxreq_hostwep :
18761 + break; // ignore me.
18762 + case DIDmsg_lnxreq_ifstate :
18763 + {
18764 + p80211msg_lnxreq_ifstate_t *ifstatemsg;
18765 + WLAN_LOG_DEBUG(2,"Received mlme ifstate request\n");
18766 + ifstatemsg = (p80211msg_lnxreq_ifstate_t*)msg;
18767 + result = prism2sta_ifstate(wlandev, ifstatemsg->ifstate.data);
18768 + ifstatemsg->resultcode.status =
18769 + P80211ENUM_msgitem_status_data_ok;
18770 + ifstatemsg->resultcode.data = result;
18771 + result = 0;
18772 + }
18773 + break;
18774 + case DIDmsg_lnxreq_wlansniff :
18775 + WLAN_LOG_DEBUG(2,"Received mlme wlansniff request\n");
18776 + result = prism2mgmt_wlansniff(wlandev, msg);
18777 + break;
18778 + case DIDmsg_lnxreq_autojoin :
18779 + WLAN_LOG_DEBUG(2,"Received mlme autojoin request\n");
18780 + result = prism2mgmt_autojoin(wlandev, msg);
18781 + break;
18782 + case DIDmsg_lnxreq_commsquality: {
18783 + p80211msg_lnxreq_commsquality_t *qualmsg;
18784 +
18785 + WLAN_LOG_DEBUG(2,"Received commsquality request\n");
18786 +
18787 + qualmsg = (p80211msg_lnxreq_commsquality_t*) msg;
18788 +
18789 + qualmsg->link.status = P80211ENUM_msgitem_status_data_ok;
18790 + qualmsg->level.status = P80211ENUM_msgitem_status_data_ok;
18791 + qualmsg->noise.status = P80211ENUM_msgitem_status_data_ok;
18792 +
18793 +
18794 + qualmsg->link.data = hfa384x2host_16(hw->qual.CQ_currBSS);
18795 + qualmsg->level.data = hfa384x2host_16(hw->qual.ASL_currBSS);
18796 + qualmsg->noise.data = hfa384x2host_16(hw->qual.ANL_currFC);
18797 +
18798 + break;
18799 + }
18800 + default:
18801 + WLAN_LOG_WARNING("Unknown mgmt request message 0x%08x", msg->msgcode);
18802 + break;
18803 + }
18804 +
18805 + DBFEXIT;
18806 + return result;
18807 +}
18808 +
18809 +
18810 +/*----------------------------------------------------------------
18811 +* prism2sta_ifstate
18812 +*
18813 +* Interface state. This is the primary WLAN interface enable/disable
18814 +* handler. Following the driver/load/deviceprobe sequence, this
18815 +* function must be called with a state of "enable" before any other
18816 +* commands will be accepted.
18817 +*
18818 +* Arguments:
18819 +* wlandev wlan device structure
18820 +* msgp ptr to msg buffer
18821 +*
18822 +* Returns:
18823 +* A p80211 message resultcode value.
18824 +*
18825 +* Side effects:
18826 +*
18827 +* Call context:
18828 +* process thread (usually)
18829 +* interrupt
18830 +----------------------------------------------------------------*/
18831 +u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate)
18832 +{
18833 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
18834 + u32 result;
18835 + DBFENTER;
18836 +
18837 + result = P80211ENUM_resultcode_implementation_failure;
18838 +
18839 + WLAN_LOG_DEBUG(2, "Current MSD state(%d), requesting(%d)\n",
18840 + wlandev->msdstate, ifstate);
18841 + switch (ifstate)
18842 + {
18843 + case P80211ENUM_ifstate_fwload:
18844 + switch (wlandev->msdstate) {
18845 + case WLAN_MSD_HWPRESENT:
18846 + wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING;
18847 + /*
18848 + * Initialize the device+driver sufficiently
18849 + * for firmware loading.
18850 + */
18851 + if ((result=hfa384x_drvr_start(hw))) {
18852 + WLAN_LOG_ERROR(
18853 + "hfa384x_drvr_start() failed,"
18854 + "result=%d\n", (int)result);
18855 + result =
18856 + P80211ENUM_resultcode_implementation_failure;
18857 + wlandev->msdstate = WLAN_MSD_HWPRESENT;
18858 + break;
18859 + }
18860 + wlandev->msdstate = WLAN_MSD_FWLOAD;
18861 + result = P80211ENUM_resultcode_success;
18862 + break;
18863 + case WLAN_MSD_FWLOAD:
18864 + hfa384x_cmd_initialize(hw);
18865 + result = P80211ENUM_resultcode_success;
18866 + break;
18867 + case WLAN_MSD_RUNNING:
18868 + WLAN_LOG_WARNING(
18869 + "Cannot enter fwload state from enable state,"
18870 + "you must disable first.\n");
18871 + result = P80211ENUM_resultcode_invalid_parameters;
18872 + break;
18873 + case WLAN_MSD_HWFAIL:
18874 + default:
18875 + /* probe() had a problem or the msdstate contains
18876 + * an unrecognized value, there's nothing we can do.
18877 + */
18878 + result = P80211ENUM_resultcode_implementation_failure;
18879 + break;
18880 + }
18881 + break;
18882 + case P80211ENUM_ifstate_enable:
18883 + switch (wlandev->msdstate) {
18884 + case WLAN_MSD_HWPRESENT:
18885 + case WLAN_MSD_FWLOAD:
18886 + wlandev->msdstate = WLAN_MSD_RUNNING_PENDING;
18887 + /* Initialize the device+driver for full
18888 + * operation. Note that this might me an FWLOAD to
18889 + * to RUNNING transition so we must not do a chip
18890 + * or board level reset. Note that on failure,
18891 + * the MSD state is set to HWPRESENT because we
18892 + * can't make any assumptions about the state
18893 + * of the hardware or a previous firmware load.
18894 + */
18895 + if ((result=hfa384x_drvr_start(hw))) {
18896 + WLAN_LOG_ERROR(
18897 + "hfa384x_drvr_start() failed,"
18898 + "result=%d\n", (int)result);
18899 + result =
18900 + P80211ENUM_resultcode_implementation_failure;
18901 + wlandev->msdstate = WLAN_MSD_HWPRESENT;
18902 + break;
18903 + }
18904 +
18905 + if ((result=prism2sta_getcardinfo(wlandev))) {
18906 + WLAN_LOG_ERROR(
18907 + "prism2sta_getcardinfo() failed,"
18908 + "result=%d\n", (int)result);
18909 + result =
18910 + P80211ENUM_resultcode_implementation_failure;
18911 + hfa384x_drvr_stop(hw);
18912 + wlandev->msdstate = WLAN_MSD_HWPRESENT;
18913 + break;
18914 + }
18915 + if ((result=prism2sta_globalsetup(wlandev))) {
18916 + WLAN_LOG_ERROR(
18917 + "prism2sta_globalsetup() failed,"
18918 + "result=%d\n", (int)result);
18919 + result =
18920 + P80211ENUM_resultcode_implementation_failure;
18921 + hfa384x_drvr_stop(hw);
18922 + wlandev->msdstate = WLAN_MSD_HWPRESENT;
18923 + break;
18924 + }
18925 + wlandev->msdstate = WLAN_MSD_RUNNING;
18926 + hw->join_ap = 0;
18927 + hw->join_retries = 60;
18928 + result = P80211ENUM_resultcode_success;
18929 + break;
18930 + case WLAN_MSD_RUNNING:
18931 + /* Do nothing, we're already in this state.*/
18932 + result = P80211ENUM_resultcode_success;
18933 + break;
18934 + case WLAN_MSD_HWFAIL:
18935 + default:
18936 + /* probe() had a problem or the msdstate contains
18937 + * an unrecognized value, there's nothing we can do.
18938 + */
18939 + result = P80211ENUM_resultcode_implementation_failure;
18940 + break;
18941 + }
18942 + break;
18943 + case P80211ENUM_ifstate_disable:
18944 + switch (wlandev->msdstate) {
18945 + case WLAN_MSD_HWPRESENT:
18946 + /* Do nothing, we're already in this state.*/
18947 + result = P80211ENUM_resultcode_success;
18948 + break;
18949 + case WLAN_MSD_FWLOAD:
18950 + case WLAN_MSD_RUNNING:
18951 + wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
18952 + /*
18953 + * TODO: Shut down the MAC completely. Here a chip
18954 + * or board level reset is probably called for.
18955 + * After a "disable" _all_ results are lost, even
18956 + * those from a fwload.
18957 + */
18958 + if (!wlandev->hwremoved)
18959 + netif_carrier_off(wlandev->netdev);
18960 +
18961 + hfa384x_drvr_stop(hw);
18962 +
18963 + wlandev->macmode = WLAN_MACMODE_NONE;
18964 + wlandev->msdstate = WLAN_MSD_HWPRESENT;
18965 + result = P80211ENUM_resultcode_success;
18966 + break;
18967 + case WLAN_MSD_HWFAIL:
18968 + default:
18969 + /* probe() had a problem or the msdstate contains
18970 + * an unrecognized value, there's nothing we can do.
18971 + */
18972 + result = P80211ENUM_resultcode_implementation_failure;
18973 + break;
18974 + }
18975 + break;
18976 + default:
18977 + result = P80211ENUM_resultcode_invalid_parameters;
18978 + break;
18979 + }
18980 +
18981 + DBFEXIT;
18982 + return result;
18983 +}
18984 +
18985 +
18986 +/*----------------------------------------------------------------
18987 +* prism2sta_getcardinfo
18988 +*
18989 +* Collect the NICID, firmware version and any other identifiers
18990 +* we'd like to have in host-side data structures.
18991 +*
18992 +* Arguments:
18993 +* wlandev wlan device structure
18994 +*
18995 +* Returns:
18996 +* 0 success
18997 +* >0 f/w reported error
18998 +* <0 driver reported error
18999 +*
19000 +* Side effects:
19001 +*
19002 +* Call context:
19003 +* Either.
19004 +----------------------------------------------------------------*/
19005 +static int prism2sta_getcardinfo(wlandevice_t *wlandev)
19006 +{
19007 + int result = 0;
19008 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19009 + u16 temp;
19010 + u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
19011 + char pstr[(HFA384x_RID_NICSERIALNUMBER_LEN * 4) + 1];
19012 +
19013 + DBFENTER;
19014 +
19015 + /* Collect version and compatibility info */
19016 + /* Some are critical, some are not */
19017 + /* NIC identity */
19018 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY,
19019 + &hw->ident_nic, sizeof(hfa384x_compident_t));
19020 + if ( result ) {
19021 + WLAN_LOG_ERROR("Failed to retrieve NICIDENTITY\n");
19022 + goto failed;
19023 + }
19024 +
19025 + /* get all the nic id fields in host byte order */
19026 + hw->ident_nic.id = hfa384x2host_16(hw->ident_nic.id);
19027 + hw->ident_nic.variant = hfa384x2host_16(hw->ident_nic.variant);
19028 + hw->ident_nic.major = hfa384x2host_16(hw->ident_nic.major);
19029 + hw->ident_nic.minor = hfa384x2host_16(hw->ident_nic.minor);
19030 +
19031 + WLAN_LOG_INFO( "ident: nic h/w: id=0x%02x %d.%d.%d\n",
19032 + hw->ident_nic.id, hw->ident_nic.major,
19033 + hw->ident_nic.minor, hw->ident_nic.variant);
19034 +
19035 + /* Primary f/w identity */
19036 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,
19037 + &hw->ident_pri_fw, sizeof(hfa384x_compident_t));
19038 + if ( result ) {
19039 + WLAN_LOG_ERROR("Failed to retrieve PRIIDENTITY\n");
19040 + goto failed;
19041 + }
19042 +
19043 + /* get all the private fw id fields in host byte order */
19044 + hw->ident_pri_fw.id = hfa384x2host_16(hw->ident_pri_fw.id);
19045 + hw->ident_pri_fw.variant = hfa384x2host_16(hw->ident_pri_fw.variant);
19046 + hw->ident_pri_fw.major = hfa384x2host_16(hw->ident_pri_fw.major);
19047 + hw->ident_pri_fw.minor = hfa384x2host_16(hw->ident_pri_fw.minor);
19048 +
19049 + WLAN_LOG_INFO( "ident: pri f/w: id=0x%02x %d.%d.%d\n",
19050 + hw->ident_pri_fw.id, hw->ident_pri_fw.major,
19051 + hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
19052 +
19053 + /* Station (Secondary?) f/w identity */
19054 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,
19055 + &hw->ident_sta_fw, sizeof(hfa384x_compident_t));
19056 + if ( result ) {
19057 + WLAN_LOG_ERROR("Failed to retrieve STAIDENTITY\n");
19058 + goto failed;
19059 + }
19060 +
19061 + if (hw->ident_nic.id < 0x8000) {
19062 + WLAN_LOG_ERROR("FATAL: Card is not an Intersil Prism2/2.5/3\n");
19063 + result = -1;
19064 + goto failed;
19065 + }
19066 +
19067 + /* get all the station fw id fields in host byte order */
19068 + hw->ident_sta_fw.id = hfa384x2host_16(hw->ident_sta_fw.id);
19069 + hw->ident_sta_fw.variant = hfa384x2host_16(hw->ident_sta_fw.variant);
19070 + hw->ident_sta_fw.major = hfa384x2host_16(hw->ident_sta_fw.major);
19071 + hw->ident_sta_fw.minor = hfa384x2host_16(hw->ident_sta_fw.minor);
19072 +
19073 + /* strip out the 'special' variant bits */
19074 + hw->mm_mods = hw->ident_sta_fw.variant & (BIT14 | BIT15);
19075 + hw->ident_sta_fw.variant &= ~((u16)(BIT14 | BIT15));
19076 +
19077 + if ( hw->ident_sta_fw.id == 0x1f ) {
19078 + WLAN_LOG_INFO(
19079 + "ident: sta f/w: id=0x%02x %d.%d.%d\n",
19080 + hw->ident_sta_fw.id, hw->ident_sta_fw.major,
19081 + hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
19082 + } else {
19083 + WLAN_LOG_INFO(
19084 + "ident: ap f/w: id=0x%02x %d.%d.%d\n",
19085 + hw->ident_sta_fw.id, hw->ident_sta_fw.major,
19086 + hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
19087 + WLAN_LOG_ERROR("Unsupported Tertiary AP firmeare loaded!\n");
19088 + goto failed;
19089 + }
19090 +
19091 + /* Compatibility range, Modem supplier */
19092 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,
19093 + &hw->cap_sup_mfi, sizeof(hfa384x_caplevel_t));
19094 + if ( result ) {
19095 + WLAN_LOG_ERROR("Failed to retrieve MFISUPRANGE\n");
19096 + goto failed;
19097 + }
19098 +
19099 + /* get all the Compatibility range, modem interface supplier
19100 + fields in byte order */
19101 + hw->cap_sup_mfi.role = hfa384x2host_16(hw->cap_sup_mfi.role);
19102 + hw->cap_sup_mfi.id = hfa384x2host_16(hw->cap_sup_mfi.id);
19103 + hw->cap_sup_mfi.variant = hfa384x2host_16(hw->cap_sup_mfi.variant);
19104 + hw->cap_sup_mfi.bottom = hfa384x2host_16(hw->cap_sup_mfi.bottom);
19105 + hw->cap_sup_mfi.top = hfa384x2host_16(hw->cap_sup_mfi.top);
19106 +
19107 + WLAN_LOG_INFO(
19108 + "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
19109 + hw->cap_sup_mfi.role, hw->cap_sup_mfi.id,
19110 + hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom,
19111 + hw->cap_sup_mfi.top);
19112 +
19113 + /* Compatibility range, Controller supplier */
19114 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,
19115 + &hw->cap_sup_cfi, sizeof(hfa384x_caplevel_t));
19116 + if ( result ) {
19117 + WLAN_LOG_ERROR("Failed to retrieve CFISUPRANGE\n");
19118 + goto failed;
19119 + }
19120 +
19121 + /* get all the Compatibility range, controller interface supplier
19122 + fields in byte order */
19123 + hw->cap_sup_cfi.role = hfa384x2host_16(hw->cap_sup_cfi.role);
19124 + hw->cap_sup_cfi.id = hfa384x2host_16(hw->cap_sup_cfi.id);
19125 + hw->cap_sup_cfi.variant = hfa384x2host_16(hw->cap_sup_cfi.variant);
19126 + hw->cap_sup_cfi.bottom = hfa384x2host_16(hw->cap_sup_cfi.bottom);
19127 + hw->cap_sup_cfi.top = hfa384x2host_16(hw->cap_sup_cfi.top);
19128 +
19129 + WLAN_LOG_INFO(
19130 + "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
19131 + hw->cap_sup_cfi.role, hw->cap_sup_cfi.id,
19132 + hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom,
19133 + hw->cap_sup_cfi.top);
19134 +
19135 + /* Compatibility range, Primary f/w supplier */
19136 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE,
19137 + &hw->cap_sup_pri, sizeof(hfa384x_caplevel_t));
19138 + if ( result ) {
19139 + WLAN_LOG_ERROR("Failed to retrieve PRISUPRANGE\n");
19140 + goto failed;
19141 + }
19142 +
19143 + /* get all the Compatibility range, primary firmware supplier
19144 + fields in byte order */
19145 + hw->cap_sup_pri.role = hfa384x2host_16(hw->cap_sup_pri.role);
19146 + hw->cap_sup_pri.id = hfa384x2host_16(hw->cap_sup_pri.id);
19147 + hw->cap_sup_pri.variant = hfa384x2host_16(hw->cap_sup_pri.variant);
19148 + hw->cap_sup_pri.bottom = hfa384x2host_16(hw->cap_sup_pri.bottom);
19149 + hw->cap_sup_pri.top = hfa384x2host_16(hw->cap_sup_pri.top);
19150 +
19151 + WLAN_LOG_INFO(
19152 + "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
19153 + hw->cap_sup_pri.role, hw->cap_sup_pri.id,
19154 + hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom,
19155 + hw->cap_sup_pri.top);
19156 +
19157 + /* Compatibility range, Station f/w supplier */
19158 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE,
19159 + &hw->cap_sup_sta, sizeof(hfa384x_caplevel_t));
19160 + if ( result ) {
19161 + WLAN_LOG_ERROR("Failed to retrieve STASUPRANGE\n");
19162 + goto failed;
19163 + }
19164 +
19165 + /* get all the Compatibility range, station firmware supplier
19166 + fields in byte order */
19167 + hw->cap_sup_sta.role = hfa384x2host_16(hw->cap_sup_sta.role);
19168 + hw->cap_sup_sta.id = hfa384x2host_16(hw->cap_sup_sta.id);
19169 + hw->cap_sup_sta.variant = hfa384x2host_16(hw->cap_sup_sta.variant);
19170 + hw->cap_sup_sta.bottom = hfa384x2host_16(hw->cap_sup_sta.bottom);
19171 + hw->cap_sup_sta.top = hfa384x2host_16(hw->cap_sup_sta.top);
19172 +
19173 + if ( hw->cap_sup_sta.id == 0x04 ) {
19174 + WLAN_LOG_INFO(
19175 + "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
19176 + hw->cap_sup_sta.role, hw->cap_sup_sta.id,
19177 + hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
19178 + hw->cap_sup_sta.top);
19179 + } else {
19180 + WLAN_LOG_INFO(
19181 + "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
19182 + hw->cap_sup_sta.role, hw->cap_sup_sta.id,
19183 + hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
19184 + hw->cap_sup_sta.top);
19185 + }
19186 +
19187 + /* Compatibility range, primary f/w actor, CFI supplier */
19188 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES,
19189 + &hw->cap_act_pri_cfi, sizeof(hfa384x_caplevel_t));
19190 + if ( result ) {
19191 + WLAN_LOG_ERROR("Failed to retrieve PRI_CFIACTRANGES\n");
19192 + goto failed;
19193 + }
19194 +
19195 + /* get all the Compatibility range, primary f/w actor, CFI supplier
19196 + fields in byte order */
19197 + hw->cap_act_pri_cfi.role = hfa384x2host_16(hw->cap_act_pri_cfi.role);
19198 + hw->cap_act_pri_cfi.id = hfa384x2host_16(hw->cap_act_pri_cfi.id);
19199 + hw->cap_act_pri_cfi.variant = hfa384x2host_16(hw->cap_act_pri_cfi.variant);
19200 + hw->cap_act_pri_cfi.bottom = hfa384x2host_16(hw->cap_act_pri_cfi.bottom);
19201 + hw->cap_act_pri_cfi.top = hfa384x2host_16(hw->cap_act_pri_cfi.top);
19202 +
19203 + WLAN_LOG_INFO(
19204 + "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
19205 + hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id,
19206 + hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom,
19207 + hw->cap_act_pri_cfi.top);
19208 +
19209 + /* Compatibility range, sta f/w actor, CFI supplier */
19210 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES,
19211 + &hw->cap_act_sta_cfi, sizeof(hfa384x_caplevel_t));
19212 + if ( result ) {
19213 + WLAN_LOG_ERROR("Failed to retrieve STA_CFIACTRANGES\n");
19214 + goto failed;
19215 + }
19216 +
19217 + /* get all the Compatibility range, station f/w actor, CFI supplier
19218 + fields in byte order */
19219 + hw->cap_act_sta_cfi.role = hfa384x2host_16(hw->cap_act_sta_cfi.role);
19220 + hw->cap_act_sta_cfi.id = hfa384x2host_16(hw->cap_act_sta_cfi.id);
19221 + hw->cap_act_sta_cfi.variant = hfa384x2host_16(hw->cap_act_sta_cfi.variant);
19222 + hw->cap_act_sta_cfi.bottom = hfa384x2host_16(hw->cap_act_sta_cfi.bottom);
19223 + hw->cap_act_sta_cfi.top = hfa384x2host_16(hw->cap_act_sta_cfi.top);
19224 +
19225 + WLAN_LOG_INFO(
19226 + "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
19227 + hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id,
19228 + hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom,
19229 + hw->cap_act_sta_cfi.top);
19230 +
19231 + /* Compatibility range, sta f/w actor, MFI supplier */
19232 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES,
19233 + &hw->cap_act_sta_mfi, sizeof(hfa384x_caplevel_t));
19234 + if ( result ) {
19235 + WLAN_LOG_ERROR("Failed to retrieve STA_MFIACTRANGES\n");
19236 + goto failed;
19237 + }
19238 +
19239 + /* get all the Compatibility range, station f/w actor, MFI supplier
19240 + fields in byte order */
19241 + hw->cap_act_sta_mfi.role = hfa384x2host_16(hw->cap_act_sta_mfi.role);
19242 + hw->cap_act_sta_mfi.id = hfa384x2host_16(hw->cap_act_sta_mfi.id);
19243 + hw->cap_act_sta_mfi.variant = hfa384x2host_16(hw->cap_act_sta_mfi.variant);
19244 + hw->cap_act_sta_mfi.bottom = hfa384x2host_16(hw->cap_act_sta_mfi.bottom);
19245 + hw->cap_act_sta_mfi.top = hfa384x2host_16(hw->cap_act_sta_mfi.top);
19246 +
19247 + WLAN_LOG_INFO(
19248 + "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
19249 + hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id,
19250 + hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom,
19251 + hw->cap_act_sta_mfi.top);
19252 +
19253 + /* Serial Number */
19254 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
19255 + snum, HFA384x_RID_NICSERIALNUMBER_LEN);
19256 + if ( !result ) {
19257 + wlan_mkprintstr(snum, HFA384x_RID_NICSERIALNUMBER_LEN,
19258 + pstr, sizeof(pstr));
19259 + WLAN_LOG_INFO("Prism2 card SN: %s\n", pstr);
19260 + } else {
19261 + WLAN_LOG_ERROR("Failed to retrieve Prism2 Card SN\n");
19262 + goto failed;
19263 + }
19264 +
19265 + /* Collect the MAC address */
19266 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
19267 + wlandev->netdev->dev_addr, WLAN_ADDR_LEN);
19268 + if ( result != 0 ) {
19269 + WLAN_LOG_ERROR("Failed to retrieve mac address\n");
19270 + goto failed;
19271 + }
19272 +
19273 + /* short preamble is always implemented */
19274 + wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE;
19275 +
19276 + /* find out if hardware wep is implemented */
19277 + hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp);
19278 + if (temp)
19279 + wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP;
19280 +
19281 + /* get the dBm Scaling constant */
19282 + hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp);
19283 + hw->dbmadjust = temp;
19284 +
19285 + /* Only enable scan by default on newer firmware */
19286 + if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
19287 + hw->ident_sta_fw.minor,
19288 + hw->ident_sta_fw.variant) <
19289 + HFA384x_FIRMWARE_VERSION(1,5,5)) {
19290 + wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN;
19291 + }
19292 +
19293 + /* TODO: Set any internally managed config items */
19294 +
19295 + goto done;
19296 +failed:
19297 + WLAN_LOG_ERROR("Failed, result=%d\n", result);
19298 +done:
19299 + DBFEXIT;
19300 + return result;
19301 +}
19302 +
19303 +
19304 +/*----------------------------------------------------------------
19305 +* prism2sta_globalsetup
19306 +*
19307 +* Set any global RIDs that we want to set at device activation.
19308 +*
19309 +* Arguments:
19310 +* wlandev wlan device structure
19311 +*
19312 +* Returns:
19313 +* 0 success
19314 +* >0 f/w reported error
19315 +* <0 driver reported error
19316 +*
19317 +* Side effects:
19318 +*
19319 +* Call context:
19320 +* process thread
19321 +----------------------------------------------------------------*/
19322 +static int prism2sta_globalsetup(wlandevice_t *wlandev)
19323 +{
19324 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19325 +
19326 + /* Set the maximum frame size */
19327 + return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN,
19328 + WLAN_DATA_MAXLEN);
19329 +}
19330 +
19331 +static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev)
19332 +{
19333 + int result = 0;
19334 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19335 +
19336 + u16 promisc;
19337 +
19338 + DBFENTER;
19339 +
19340 + /* If we're not ready, what's the point? */
19341 + if ( hw->state != HFA384x_STATE_RUNNING )
19342 + goto exit;
19343 +
19344 + if ( (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0 )
19345 + promisc = P80211ENUM_truth_true;
19346 + else
19347 + promisc = P80211ENUM_truth_false;
19348 +
19349 + result = hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE, promisc);
19350 +
19351 + /* XXX TODO: configure the multicast list */
19352 + // CLEAR_HW_MULTICAST_LIST
19353 + // struct dev_mc_list element = dev->mc_list;
19354 + // while (element != null) {
19355 + // HW_ADD_MULTICAST_ADDR(element->dmi_addr, dmi_addrlen)
19356 + // element = element->next;
19357 + // }
19358 +
19359 + exit:
19360 + DBFEXIT;
19361 + return result;
19362 +}
19363 +
19364 +/*----------------------------------------------------------------
19365 +* prism2sta_inf_handover
19366 +*
19367 +* Handles the receipt of a Handover info frame. Should only be present
19368 +* in APs only.
19369 +*
19370 +* Arguments:
19371 +* wlandev wlan device structure
19372 +* inf ptr to info frame (contents in hfa384x order)
19373 +*
19374 +* Returns:
19375 +* nothing
19376 +*
19377 +* Side effects:
19378 +*
19379 +* Call context:
19380 +* interrupt
19381 +----------------------------------------------------------------*/
19382 +static void prism2sta_inf_handover(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
19383 +{
19384 + DBFENTER;
19385 + WLAN_LOG_DEBUG(2,"received infoframe:HANDOVER (unhandled)\n");
19386 + DBFEXIT;
19387 + return;
19388 +}
19389 +
19390 +
19391 +/*----------------------------------------------------------------
19392 +* prism2sta_inf_tallies
19393 +*
19394 +* Handles the receipt of a CommTallies info frame.
19395 +*
19396 +* Arguments:
19397 +* wlandev wlan device structure
19398 +* inf ptr to info frame (contents in hfa384x order)
19399 +*
19400 +* Returns:
19401 +* nothing
19402 +*
19403 +* Side effects:
19404 +*
19405 +* Call context:
19406 +* interrupt
19407 +----------------------------------------------------------------*/
19408 +static void prism2sta_inf_tallies(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
19409 +{
19410 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19411 + u16 *src16;
19412 + u32 *dst;
19413 + u32 *src32;
19414 + int i;
19415 + int cnt;
19416 +
19417 + DBFENTER;
19418 +
19419 + /*
19420 + ** Determine if these are 16-bit or 32-bit tallies, based on the
19421 + ** record length of the info record.
19422 + */
19423 +
19424 + cnt = sizeof(hfa384x_CommTallies32_t) / sizeof(u32);
19425 + if (inf->framelen > 22) {
19426 + dst = (u32 *) &hw->tallies;
19427 + src32 = (u32 *) &inf->info.commtallies32;
19428 + for (i = 0; i < cnt; i++, dst++, src32++)
19429 + *dst += hfa384x2host_32(*src32);
19430 + } else {
19431 + dst = (u32 *) &hw->tallies;
19432 + src16 = (u16 *) &inf->info.commtallies16;
19433 + for (i = 0; i < cnt; i++, dst++, src16++)
19434 + *dst += hfa384x2host_16(*src16);
19435 + }
19436 +
19437 + DBFEXIT;
19438 +
19439 + return;
19440 +}
19441 +
19442 +/*----------------------------------------------------------------
19443 +* prism2sta_inf_scanresults
19444 +*
19445 +* Handles the receipt of a Scan Results info frame.
19446 +*
19447 +* Arguments:
19448 +* wlandev wlan device structure
19449 +* inf ptr to info frame (contents in hfa384x order)
19450 +*
19451 +* Returns:
19452 +* nothing
19453 +*
19454 +* Side effects:
19455 +*
19456 +* Call context:
19457 +* interrupt
19458 +----------------------------------------------------------------*/
19459 +static void prism2sta_inf_scanresults(wlandevice_t *wlandev,
19460 + hfa384x_InfFrame_t *inf)
19461 +{
19462 +
19463 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19464 + int nbss;
19465 + hfa384x_ScanResult_t *sr = &(inf->info.scanresult);
19466 + int i;
19467 + hfa384x_JoinRequest_data_t joinreq;
19468 + int result;
19469 + DBFENTER;
19470 +
19471 + /* Get the number of results, first in bytes, then in results */
19472 + nbss = (inf->framelen * sizeof(u16)) -
19473 + sizeof(inf->infotype) -
19474 + sizeof(inf->info.scanresult.scanreason);
19475 + nbss /= sizeof(hfa384x_ScanResultSub_t);
19476 +
19477 + /* Print em */
19478 + WLAN_LOG_DEBUG(1,"rx scanresults, reason=%d, nbss=%d:\n",
19479 + inf->info.scanresult.scanreason, nbss);
19480 + for ( i = 0; i < nbss; i++) {
19481 + WLAN_LOG_DEBUG(1, "chid=%d anl=%d sl=%d bcnint=%d\n",
19482 + sr->result[i].chid,
19483 + sr->result[i].anl,
19484 + sr->result[i].sl,
19485 + sr->result[i].bcnint);
19486 + WLAN_LOG_DEBUG(1, " capinfo=0x%04x proberesp_rate=%d\n",
19487 + sr->result[i].capinfo,
19488 + sr->result[i].proberesp_rate);
19489 + }
19490 + /* issue a join request */
19491 + joinreq.channel = sr->result[0].chid;
19492 + memcpy( joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN);
19493 + result = hfa384x_drvr_setconfig( hw,
19494 + HFA384x_RID_JOINREQUEST,
19495 + &joinreq, HFA384x_RID_JOINREQUEST_LEN);
19496 + if (result) {
19497 + WLAN_LOG_ERROR("setconfig(joinreq) failed, result=%d\n", result);
19498 + }
19499 +
19500 + DBFEXIT;
19501 + return;
19502 +}
19503 +
19504 +/*----------------------------------------------------------------
19505 +* prism2sta_inf_hostscanresults
19506 +*
19507 +* Handles the receipt of a Scan Results info frame.
19508 +*
19509 +* Arguments:
19510 +* wlandev wlan device structure
19511 +* inf ptr to info frame (contents in hfa384x order)
19512 +*
19513 +* Returns:
19514 +* nothing
19515 +*
19516 +* Side effects:
19517 +*
19518 +* Call context:
19519 +* interrupt
19520 +----------------------------------------------------------------*/
19521 +static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
19522 + hfa384x_InfFrame_t *inf)
19523 +{
19524 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19525 + int nbss;
19526 + DBFENTER;
19527 +
19528 + nbss = (inf->framelen - 3) / 32;
19529 + WLAN_LOG_DEBUG(1, "Received %d hostscan results\n", nbss);
19530 +
19531 + if (nbss > 32)
19532 + nbss = 32;
19533 +
19534 + if (hw->scanresults)
19535 + kfree(hw->scanresults);
19536 +
19537 + hw->scanresults = kmalloc(sizeof(hfa384x_InfFrame_t), GFP_ATOMIC);
19538 + memcpy(hw->scanresults, inf, sizeof(hfa384x_InfFrame_t));
19539 +
19540 + if (nbss == 0)
19541 + nbss = -1;
19542 +
19543 + /* Notify/wake the sleeping caller. */
19544 + hw->scanflag = nbss;
19545 + wake_up_interruptible(&hw->cmdq);
19546 +
19547 + DBFEXIT;
19548 +};
19549 +
19550 +/*----------------------------------------------------------------
19551 +* prism2sta_inf_chinforesults
19552 +*
19553 +* Handles the receipt of a Channel Info Results info frame.
19554 +*
19555 +* Arguments:
19556 +* wlandev wlan device structure
19557 +* inf ptr to info frame (contents in hfa384x order)
19558 +*
19559 +* Returns:
19560 +* nothing
19561 +*
19562 +* Side effects:
19563 +*
19564 +* Call context:
19565 +* interrupt
19566 +----------------------------------------------------------------*/
19567 +static void prism2sta_inf_chinforesults(wlandevice_t *wlandev,
19568 + hfa384x_InfFrame_t *inf)
19569 +{
19570 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19571 + unsigned int i, n;
19572 +
19573 + DBFENTER;
19574 + hw->channel_info.results.scanchannels =
19575 + hfa384x2host_16(inf->info.chinforesult.scanchannels);
19576 +#if 0
19577 + memcpy(&inf->info.chinforesult, &hw->channel_info.results, sizeof(hfa384x_ChInfoResult_t));
19578 +#endif
19579 +
19580 + for (i=0, n=0; i<HFA384x_CHINFORESULT_MAX; i++) {
19581 + if (hw->channel_info.results.scanchannels & (1<<i)) {
19582 + int channel=hfa384x2host_16(inf->info.chinforesult.result[n].chid)-1;
19583 + hfa384x_ChInfoResultSub_t *chinforesult=&hw->channel_info.results.result[channel];
19584 + chinforesult->chid = channel;
19585 + chinforesult->anl = hfa384x2host_16(inf->info.chinforesult.result[n].anl);
19586 + chinforesult->pnl = hfa384x2host_16(inf->info.chinforesult.result[n].pnl);
19587 + chinforesult->active = hfa384x2host_16(inf->info.chinforesult.result[n].active);
19588 + WLAN_LOG_DEBUG(2, "chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
19589 + channel+1,
19590 + chinforesult->active &
19591 + HFA384x_CHINFORESULT_BSSACTIVE ? "signal" : "noise",
19592 + chinforesult->anl, chinforesult->pnl,
19593 + chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE ? 1 : 0
19594 + );
19595 + n++;
19596 + }
19597 + }
19598 + atomic_set(&hw->channel_info.done, 2);
19599 +
19600 + hw->channel_info.count = n;
19601 + DBFEXIT;
19602 + return;
19603 +}
19604 +
19605 +void prism2sta_processing_defer(struct work_struct *data)
19606 +{
19607 + hfa384x_t *hw = container_of(data, struct hfa384x, link_bh);
19608 + wlandevice_t *wlandev = hw->wlandev;
19609 + hfa384x_bytestr32_t ssid;
19610 + int result;
19611 +
19612 + DBFENTER;
19613 + /* First let's process the auth frames */
19614 + {
19615 + struct sk_buff *skb;
19616 + hfa384x_InfFrame_t *inf;
19617 +
19618 + while ( (skb = skb_dequeue(&hw->authq)) ) {
19619 + inf = (hfa384x_InfFrame_t *) skb->data;
19620 + prism2sta_inf_authreq_defer(wlandev, inf);
19621 + }
19622 +
19623 + }
19624 +
19625 + /* Now let's handle the linkstatus stuff */
19626 + if (hw->link_status == hw->link_status_new)
19627 + goto failed;
19628 +
19629 + hw->link_status = hw->link_status_new;
19630 +
19631 + switch(hw->link_status) {
19632 + case HFA384x_LINK_NOTCONNECTED:
19633 + /* I'm currently assuming that this is the initial link
19634 + * state. It should only be possible immediately
19635 + * following an Enable command.
19636 + * Response:
19637 + * Block Transmits, Ignore receives of data frames
19638 + */
19639 + netif_carrier_off(wlandev->netdev);
19640 +
19641 + WLAN_LOG_INFO("linkstatus=NOTCONNECTED (unhandled)\n");
19642 + break;
19643 +
19644 + case HFA384x_LINK_CONNECTED:
19645 + /* This one indicates a successful scan/join/auth/assoc.
19646 + * When we have the full MLME complement, this event will
19647 + * signify successful completion of both mlme_authenticate
19648 + * and mlme_associate. State management will get a little
19649 + * ugly here.
19650 + * Response:
19651 + * Indicate authentication and/or association
19652 + * Enable Transmits, Receives and pass up data frames
19653 + */
19654 +
19655 + netif_carrier_on(wlandev->netdev);
19656 +
19657 + /* If we are joining a specific AP, set our state and reset retries */
19658 + if(hw->join_ap == 1)
19659 + hw->join_ap = 2;
19660 + hw->join_retries = 60;
19661 +
19662 + /* Don't call this in monitor mode */
19663 + if ( wlandev->netdev->type == ARPHRD_ETHER ) {
19664 + u16 portstatus;
19665 +
19666 + WLAN_LOG_INFO("linkstatus=CONNECTED\n");
19667 +
19668 + /* For non-usb devices, we can use the sync versions */
19669 + /* Collect the BSSID, and set state to allow tx */
19670 +
19671 + result = hfa384x_drvr_getconfig(hw,
19672 + HFA384x_RID_CURRENTBSSID,
19673 + wlandev->bssid, WLAN_BSSID_LEN);
19674 + if ( result ) {
19675 + WLAN_LOG_DEBUG(1,
19676 + "getconfig(0x%02x) failed, result = %d\n",
19677 + HFA384x_RID_CURRENTBSSID, result);
19678 + goto failed;
19679 + }
19680 +
19681 + result = hfa384x_drvr_getconfig(hw,
19682 + HFA384x_RID_CURRENTSSID,
19683 + &ssid, sizeof(ssid));
19684 + if ( result ) {
19685 + WLAN_LOG_DEBUG(1,
19686 + "getconfig(0x%02x) failed, result = %d\n",
19687 + HFA384x_RID_CURRENTSSID, result);
19688 + goto failed;
19689 + }
19690 + prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *)&ssid,
19691 + (p80211pstrd_t *) &wlandev->ssid);
19692 +
19693 + /* Collect the port status */
19694 + result = hfa384x_drvr_getconfig16(hw,
19695 + HFA384x_RID_PORTSTATUS, &portstatus);
19696 + if ( result ) {
19697 + WLAN_LOG_DEBUG(1,
19698 + "getconfig(0x%02x) failed, result = %d\n",
19699 + HFA384x_RID_PORTSTATUS, result);
19700 + goto failed;
19701 + }
19702 + wlandev->macmode =
19703 + (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
19704 + WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
19705 +
19706 + /* Get the ball rolling on the comms quality stuff */
19707 + prism2sta_commsqual_defer(&hw->commsqual_bh);
19708 + }
19709 + break;
19710 +
19711 + case HFA384x_LINK_DISCONNECTED:
19712 + /* This one indicates that our association is gone. We've
19713 + * lost connection with the AP and/or been disassociated.
19714 + * This indicates that the MAC has completely cleared it's
19715 + * associated state. We * should send a deauth indication
19716 + * (implying disassoc) up * to the MLME.
19717 + * Response:
19718 + * Indicate Deauthentication
19719 + * Block Transmits, Ignore receives of data frames
19720 + */
19721 + if(hw->join_ap == 2)
19722 + {
19723 + hfa384x_JoinRequest_data_t joinreq;
19724 + joinreq = hw->joinreq;
19725 + /* Send the join request */
19726 + hfa384x_drvr_setconfig( hw,
19727 + HFA384x_RID_JOINREQUEST,
19728 + &joinreq, HFA384x_RID_JOINREQUEST_LEN);
19729 + WLAN_LOG_INFO("linkstatus=DISCONNECTED (re-submitting join)\n");
19730 + } else {
19731 + if (wlandev->netdev->type == ARPHRD_ETHER)
19732 + WLAN_LOG_INFO("linkstatus=DISCONNECTED (unhandled)\n");
19733 + }
19734 + wlandev->macmode = WLAN_MACMODE_NONE;
19735 +
19736 + netif_carrier_off(wlandev->netdev);
19737 +
19738 + break;
19739 +
19740 + case HFA384x_LINK_AP_CHANGE:
19741 + /* This one indicates that the MAC has decided to and
19742 + * successfully completed a change to another AP. We
19743 + * should probably implement a reassociation indication
19744 + * in response to this one. I'm thinking that the the
19745 + * p80211 layer needs to be notified in case of
19746 + * buffering/queueing issues. User mode also needs to be
19747 + * notified so that any BSS dependent elements can be
19748 + * updated.
19749 + * associated state. We * should send a deauth indication
19750 + * (implying disassoc) up * to the MLME.
19751 + * Response:
19752 + * Indicate Reassociation
19753 + * Enable Transmits, Receives and pass up data frames
19754 + */
19755 + WLAN_LOG_INFO("linkstatus=AP_CHANGE\n");
19756 +
19757 + result = hfa384x_drvr_getconfig(hw,
19758 + HFA384x_RID_CURRENTBSSID,
19759 + wlandev->bssid, WLAN_BSSID_LEN);
19760 + if ( result ) {
19761 + WLAN_LOG_DEBUG(1,
19762 + "getconfig(0x%02x) failed, result = %d\n",
19763 + HFA384x_RID_CURRENTBSSID, result);
19764 + goto failed;
19765 + }
19766 +
19767 + result = hfa384x_drvr_getconfig(hw,
19768 + HFA384x_RID_CURRENTSSID,
19769 + &ssid, sizeof(ssid));
19770 + if ( result ) {
19771 + WLAN_LOG_DEBUG(1,
19772 + "getconfig(0x%02x) failed, result = %d\n",
19773 + HFA384x_RID_CURRENTSSID, result);
19774 + goto failed;
19775 + }
19776 + prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *)&ssid,
19777 + (p80211pstrd_t *) &wlandev->ssid);
19778 +
19779 +
19780 + hw->link_status = HFA384x_LINK_CONNECTED;
19781 + netif_carrier_on(wlandev->netdev);
19782 +
19783 + break;
19784 +
19785 + case HFA384x_LINK_AP_OUTOFRANGE:
19786 + /* This one indicates that the MAC has decided that the
19787 + * AP is out of range, but hasn't found a better candidate
19788 + * so the MAC maintains its "associated" state in case
19789 + * we get back in range. We should block transmits and
19790 + * receives in this state. Do we need an indication here?
19791 + * Probably not since a polling user-mode element would
19792 + * get this status from from p2PortStatus(FD40). What about
19793 + * p80211?
19794 + * Response:
19795 + * Block Transmits, Ignore receives of data frames
19796 + */
19797 + WLAN_LOG_INFO("linkstatus=AP_OUTOFRANGE (unhandled)\n");
19798 +
19799 + netif_carrier_off(wlandev->netdev);
19800 +
19801 + break;
19802 +
19803 + case HFA384x_LINK_AP_INRANGE:
19804 + /* This one indicates that the MAC has decided that the
19805 + * AP is back in range. We continue working with our
19806 + * existing association.
19807 + * Response:
19808 + * Enable Transmits, Receives and pass up data frames
19809 + */
19810 + WLAN_LOG_INFO("linkstatus=AP_INRANGE\n");
19811 +
19812 + hw->link_status = HFA384x_LINK_CONNECTED;
19813 + netif_carrier_on(wlandev->netdev);
19814 +
19815 + break;
19816 +
19817 + case HFA384x_LINK_ASSOCFAIL:
19818 + /* This one is actually a peer to CONNECTED. We've
19819 + * requested a join for a given SSID and optionally BSSID.
19820 + * We can use this one to indicate authentication and
19821 + * association failures. The trick is going to be
19822 + * 1) identifying the failure, and 2) state management.
19823 + * Response:
19824 + * Disable Transmits, Ignore receives of data frames
19825 + */
19826 + if(hw->join_ap && --hw->join_retries > 0)
19827 + {
19828 + hfa384x_JoinRequest_data_t joinreq;
19829 + joinreq = hw->joinreq;
19830 + /* Send the join request */
19831 + hfa384x_drvr_setconfig( hw,
19832 + HFA384x_RID_JOINREQUEST,
19833 + &joinreq, HFA384x_RID_JOINREQUEST_LEN);
19834 + WLAN_LOG_INFO("linkstatus=ASSOCFAIL (re-submitting join)\n");
19835 + } else {
19836 + WLAN_LOG_INFO("linkstatus=ASSOCFAIL (unhandled)\n");
19837 + }
19838 +
19839 + netif_carrier_off(wlandev->netdev);
19840 +
19841 + break;
19842 +
19843 + default:
19844 + /* This is bad, IO port problems? */
19845 + WLAN_LOG_WARNING(
19846 + "unknown linkstatus=0x%02x\n", hw->link_status);
19847 + goto failed;
19848 + break;
19849 + }
19850 +
19851 + wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
19852 +#ifdef WIRELESS_EXT
19853 + p80211wext_event_associated(wlandev, wlandev->linkstatus);
19854 +#endif
19855 +
19856 + failed:
19857 + DBFEXIT;
19858 +}
19859 +
19860 +/*----------------------------------------------------------------
19861 +* prism2sta_inf_linkstatus
19862 +*
19863 +* Handles the receipt of a Link Status info frame.
19864 +*
19865 +* Arguments:
19866 +* wlandev wlan device structure
19867 +* inf ptr to info frame (contents in hfa384x order)
19868 +*
19869 +* Returns:
19870 +* nothing
19871 +*
19872 +* Side effects:
19873 +*
19874 +* Call context:
19875 +* interrupt
19876 +----------------------------------------------------------------*/
19877 +static void prism2sta_inf_linkstatus(wlandevice_t *wlandev,
19878 + hfa384x_InfFrame_t *inf)
19879 +{
19880 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19881 +
19882 + DBFENTER;
19883 +
19884 + hw->link_status_new = hfa384x2host_16(inf->info.linkstatus.linkstatus);
19885 +
19886 + schedule_work(&hw->link_bh);
19887 +
19888 + DBFEXIT;
19889 + return;
19890 +}
19891 +
19892 +/*----------------------------------------------------------------
19893 +* prism2sta_inf_assocstatus
19894 +*
19895 +* Handles the receipt of an Association Status info frame. Should
19896 +* be present in APs only.
19897 +*
19898 +* Arguments:
19899 +* wlandev wlan device structure
19900 +* inf ptr to info frame (contents in hfa384x order)
19901 +*
19902 +* Returns:
19903 +* nothing
19904 +*
19905 +* Side effects:
19906 +*
19907 +* Call context:
19908 +* interrupt
19909 +----------------------------------------------------------------*/
19910 +static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
19911 + hfa384x_InfFrame_t *inf)
19912 +{
19913 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19914 + hfa384x_AssocStatus_t rec;
19915 + int i;
19916 +
19917 + DBFENTER;
19918 +
19919 + memcpy(&rec, &inf->info.assocstatus, sizeof(rec));
19920 + rec.assocstatus = hfa384x2host_16(rec.assocstatus);
19921 + rec.reason = hfa384x2host_16(rec.reason);
19922 +
19923 + /*
19924 + ** Find the address in the list of authenticated stations. If it wasn't
19925 + ** found, then this address has not been previously authenticated and
19926 + ** something weird has happened if this is anything other than an
19927 + ** "authentication failed" message. If the address was found, then
19928 + ** set the "associated" flag for that station, based on whether the
19929 + ** station is associating or losing its association. Something weird
19930 + ** has also happened if we find the address in the list of authenticated
19931 + ** stations but we are getting an "authentication failed" message.
19932 + */
19933 +
19934 + for (i = 0; i < hw->authlist.cnt; i++)
19935 + if (memcmp(rec.sta_addr, hw->authlist.addr[i], WLAN_ADDR_LEN) == 0)
19936 + break;
19937 +
19938 + if (i >= hw->authlist.cnt) {
19939 + if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
19940 + WLAN_LOG_WARNING("assocstatus info frame received for non-authenticated station.\n");
19941 + } else {
19942 + hw->authlist.assoc[i] =
19943 + (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
19944 + rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);
19945 +
19946 + if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
19947 + WLAN_LOG_WARNING("authfail assocstatus info frame received for authenticated station.\n");
19948 + }
19949 +
19950 + DBFEXIT;
19951 +
19952 + return;
19953 +}
19954 +
19955 +/*----------------------------------------------------------------
19956 +* prism2sta_inf_authreq
19957 +*
19958 +* Handles the receipt of an Authentication Request info frame. Should
19959 +* be present in APs only.
19960 +*
19961 +* Arguments:
19962 +* wlandev wlan device structure
19963 +* inf ptr to info frame (contents in hfa384x order)
19964 +*
19965 +* Returns:
19966 +* nothing
19967 +*
19968 +* Side effects:
19969 +*
19970 +* Call context:
19971 +* interrupt
19972 +*
19973 +----------------------------------------------------------------*/
19974 +static void prism2sta_inf_authreq(wlandevice_t *wlandev,
19975 + hfa384x_InfFrame_t *inf)
19976 +{
19977 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19978 + struct sk_buff *skb;
19979 +
19980 + DBFENTER;
19981 +
19982 + skb = dev_alloc_skb(sizeof(*inf));
19983 + if (skb) {
19984 + skb_put(skb, sizeof(*inf));
19985 + memcpy(skb->data, inf, sizeof(*inf));
19986 + skb_queue_tail(&hw->authq, skb);
19987 + schedule_work(&hw->link_bh);
19988 + }
19989 +
19990 + DBFEXIT;
19991 +}
19992 +
19993 +static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
19994 + hfa384x_InfFrame_t *inf)
19995 +{
19996 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
19997 + hfa384x_authenticateStation_data_t rec;
19998 +
19999 + int i, added, result, cnt;
20000 + u8 *addr;
20001 +
20002 + DBFENTER;
20003 +
20004 + /*
20005 + ** Build the AuthenticateStation record. Initialize it for denying
20006 + ** authentication.
20007 + */
20008 +
20009 + memcpy(rec.address, inf->info.authreq.sta_addr, WLAN_ADDR_LEN);
20010 + rec.status = P80211ENUM_status_unspec_failure;
20011 +
20012 + /*
20013 + ** Authenticate based on the access mode.
20014 + */
20015 +
20016 + switch (hw->accessmode) {
20017 + case WLAN_ACCESS_NONE:
20018 +
20019 + /*
20020 + ** Deny all new authentications. However, if a station
20021 + ** is ALREADY authenticated, then accept it.
20022 + */
20023 +
20024 + for (i = 0; i < hw->authlist.cnt; i++)
20025 + if (memcmp(rec.address, hw->authlist.addr[i],
20026 + WLAN_ADDR_LEN) == 0) {
20027 + rec.status = P80211ENUM_status_successful;
20028 + break;
20029 + }
20030 +
20031 + break;
20032 +
20033 + case WLAN_ACCESS_ALL:
20034 +
20035 + /*
20036 + ** Allow all authentications.
20037 + */
20038 +
20039 + rec.status = P80211ENUM_status_successful;
20040 + break;
20041 +
20042 + case WLAN_ACCESS_ALLOW:
20043 +
20044 + /*
20045 + ** Only allow the authentication if the MAC address
20046 + ** is in the list of allowed addresses.
20047 + **
20048 + ** Since this is the interrupt handler, we may be here
20049 + ** while the access list is in the middle of being
20050 + ** updated. Choose the list which is currently okay.
20051 + ** See "prism2mib_priv_accessallow()" for details.
20052 + */
20053 +
20054 + if (hw->allow.modify == 0) {
20055 + cnt = hw->allow.cnt;
20056 + addr = hw->allow.addr[0];
20057 + } else {
20058 + cnt = hw->allow.cnt1;
20059 + addr = hw->allow.addr1[0];
20060 + }
20061 +
20062 + for (i = 0; i < cnt; i++, addr += WLAN_ADDR_LEN)
20063 + if (memcmp(rec.address, addr, WLAN_ADDR_LEN) == 0) {
20064 + rec.status = P80211ENUM_status_successful;
20065 + break;
20066 + }
20067 +
20068 + break;
20069 +
20070 + case WLAN_ACCESS_DENY:
20071 +
20072 + /*
20073 + ** Allow the authentication UNLESS the MAC address is
20074 + ** in the list of denied addresses.
20075 + **
20076 + ** Since this is the interrupt handler, we may be here
20077 + ** while the access list is in the middle of being
20078 + ** updated. Choose the list which is currently okay.
20079 + ** See "prism2mib_priv_accessdeny()" for details.
20080 + */
20081 +
20082 + if (hw->deny.modify == 0) {
20083 + cnt = hw->deny.cnt;
20084 + addr = hw->deny.addr[0];
20085 + } else {
20086 + cnt = hw->deny.cnt1;
20087 + addr = hw->deny.addr1[0];
20088 + }
20089 +
20090 + rec.status = P80211ENUM_status_successful;
20091 +
20092 + for (i = 0; i < cnt; i++, addr += WLAN_ADDR_LEN)
20093 + if (memcmp(rec.address, addr, WLAN_ADDR_LEN) == 0) {
20094 + rec.status = P80211ENUM_status_unspec_failure;
20095 + break;
20096 + }
20097 +
20098 + break;
20099 + }
20100 +
20101 + /*
20102 + ** If the authentication is okay, then add the MAC address to the list
20103 + ** of authenticated stations. Don't add the address if it is already in
20104 + ** the list. (802.11b does not seem to disallow a station from issuing
20105 + ** an authentication request when the station is already authenticated.
20106 + ** Does this sort of thing ever happen? We might as well do the check
20107 + ** just in case.)
20108 + */
20109 +
20110 + added = 0;
20111 +
20112 + if (rec.status == P80211ENUM_status_successful) {
20113 + for (i = 0; i < hw->authlist.cnt; i++)
20114 + if (memcmp(rec.address, hw->authlist.addr[i], WLAN_ADDR_LEN) == 0)
20115 + break;
20116 +
20117 + if (i >= hw->authlist.cnt) {
20118 + if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
20119 + rec.status = P80211ENUM_status_ap_full;
20120 + } else {
20121 + memcpy(hw->authlist.addr[hw->authlist.cnt],
20122 + rec.address, WLAN_ADDR_LEN);
20123 + hw->authlist.cnt++;
20124 + added = 1;
20125 + }
20126 + }
20127 + }
20128 +
20129 + /*
20130 + ** Send back the results of the authentication. If this doesn't work,
20131 + ** then make sure to remove the address from the authenticated list if
20132 + ** it was added.
20133 + */
20134 +
20135 + rec.status = host2hfa384x_16(rec.status);
20136 + rec.algorithm = inf->info.authreq.algorithm;
20137 +
20138 + result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
20139 + &rec, sizeof(rec));
20140 + if (result) {
20141 + if (added) hw->authlist.cnt--;
20142 + WLAN_LOG_ERROR("setconfig(authenticatestation) failed, result=%d\n", result);
20143 + }
20144 +
20145 + DBFEXIT;
20146 +
20147 + return;
20148 +}
20149 +
20150 +
20151 +/*----------------------------------------------------------------
20152 +* prism2sta_inf_psusercnt
20153 +*
20154 +* Handles the receipt of a PowerSaveUserCount info frame. Should
20155 +* be present in APs only.
20156 +*
20157 +* Arguments:
20158 +* wlandev wlan device structure
20159 +* inf ptr to info frame (contents in hfa384x order)
20160 +*
20161 +* Returns:
20162 +* nothing
20163 +*
20164 +* Side effects:
20165 +*
20166 +* Call context:
20167 +* interrupt
20168 +----------------------------------------------------------------*/
20169 +static void prism2sta_inf_psusercnt(wlandevice_t *wlandev,
20170 + hfa384x_InfFrame_t *inf)
20171 +{
20172 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
20173 +
20174 + DBFENTER;
20175 +
20176 + hw->psusercount = hfa384x2host_16(inf->info.psusercnt.usercnt);
20177 +
20178 + DBFEXIT;
20179 +
20180 + return;
20181 +}
20182 +
20183 +/*----------------------------------------------------------------
20184 +* prism2sta_ev_dtim
20185 +*
20186 +* Handles the DTIM early warning event.
20187 +*
20188 +* Arguments:
20189 +* wlandev wlan device structure
20190 +*
20191 +* Returns:
20192 +* nothing
20193 +*
20194 +* Side effects:
20195 +*
20196 +* Call context:
20197 +* interrupt
20198 +----------------------------------------------------------------*/
20199 +void prism2sta_ev_dtim(wlandevice_t *wlandev)
20200 +{
20201 +#if 0
20202 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
20203 +#endif
20204 + DBFENTER;
20205 + WLAN_LOG_DEBUG(3, "DTIM event, currently unhandled.\n");
20206 + DBFEXIT;
20207 + return;
20208 +}
20209 +
20210 +
20211 +/*----------------------------------------------------------------
20212 +* prism2sta_ev_infdrop
20213 +*
20214 +* Handles the InfDrop event.
20215 +*
20216 +* Arguments:
20217 +* wlandev wlan device structure
20218 +*
20219 +* Returns:
20220 +* nothing
20221 +*
20222 +* Side effects:
20223 +*
20224 +* Call context:
20225 +* interrupt
20226 +----------------------------------------------------------------*/
20227 +void prism2sta_ev_infdrop(wlandevice_t *wlandev)
20228 +{
20229 +#if 0
20230 + hfa384x_t *hw = (hfa384x_t *)wlandev->priv;
20231 +#endif
20232 + DBFENTER;
20233 + WLAN_LOG_DEBUG(3, "Info frame dropped due to card mem low.\n");
20234 + DBFEXIT;
20235 + return;
20236 +}
20237 +
20238 +
20239 +/*----------------------------------------------------------------
20240 +* prism2sta_ev_info
20241 +*
20242 +* Handles the Info event.
20243 +*
20244 +* Arguments:
20245 +* wlandev wlan device structure
20246 +* inf ptr to a generic info frame
20247 +*
20248 +* Returns:
20249 +* nothing
20250 +*
20251 +* Side effects:
20252 +*
20253 +* Call context:
20254 +* interrupt
20255 +----------------------------------------------------------------*/
20256 +void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf)
20257 +{
20258 + DBFENTER;
20259 + inf->infotype = hfa384x2host_16(inf->infotype);
20260 + /* Dispatch */
20261 + switch ( inf->infotype ) {
20262 + case HFA384x_IT_HANDOVERADDR:
20263 + prism2sta_inf_handover(wlandev, inf);
20264 + break;
20265 + case HFA384x_IT_COMMTALLIES:
20266 + prism2sta_inf_tallies(wlandev, inf);
20267 + break;
20268 + case HFA384x_IT_HOSTSCANRESULTS:
20269 + prism2sta_inf_hostscanresults(wlandev, inf);
20270 + break;
20271 + case HFA384x_IT_SCANRESULTS:
20272 + prism2sta_inf_scanresults(wlandev, inf);
20273 + break;
20274 + case HFA384x_IT_CHINFORESULTS:
20275 + prism2sta_inf_chinforesults(wlandev, inf);
20276 + break;
20277 + case HFA384x_IT_LINKSTATUS:
20278 + prism2sta_inf_linkstatus(wlandev, inf);
20279 + break;
20280 + case HFA384x_IT_ASSOCSTATUS:
20281 + prism2sta_inf_assocstatus(wlandev, inf);
20282 + break;
20283 + case HFA384x_IT_AUTHREQ:
20284 + prism2sta_inf_authreq(wlandev, inf);
20285 + break;
20286 + case HFA384x_IT_PSUSERCNT:
20287 + prism2sta_inf_psusercnt(wlandev, inf);
20288 + break;
20289 + case HFA384x_IT_KEYIDCHANGED:
20290 + WLAN_LOG_WARNING("Unhandled IT_KEYIDCHANGED\n");
20291 + break;
20292 + case HFA384x_IT_ASSOCREQ:
20293 + WLAN_LOG_WARNING("Unhandled IT_ASSOCREQ\n");
20294 + break;
20295 + case HFA384x_IT_MICFAILURE:
20296 + WLAN_LOG_WARNING("Unhandled IT_MICFAILURE\n");
20297 + break;
20298 + default:
20299 + WLAN_LOG_WARNING(
20300 + "Unknown info type=0x%02x\n", inf->infotype);
20301 + break;
20302 + }
20303 + DBFEXIT;
20304 + return;
20305 +}
20306 +
20307 +
20308 +/*----------------------------------------------------------------
20309 +* prism2sta_ev_txexc
20310 +*
20311 +* Handles the TxExc event. A Transmit Exception event indicates
20312 +* that the MAC's TX process was unsuccessful - so the packet did
20313 +* not get transmitted.
20314 +*
20315 +* Arguments:
20316 +* wlandev wlan device structure
20317 +* status tx frame status word
20318 +*
20319 +* Returns:
20320 +* nothing
20321 +*
20322 +* Side effects:
20323 +*
20324 +* Call context:
20325 +* interrupt
20326 +----------------------------------------------------------------*/
20327 +void prism2sta_ev_txexc(wlandevice_t *wlandev, u16 status)
20328 +{
20329 + DBFENTER;
20330 +
20331 + WLAN_LOG_DEBUG(3, "TxExc status=0x%x.\n", status);
20332 +
20333 + DBFEXIT;
20334 + return;
20335 +}
20336 +
20337 +
20338 +/*----------------------------------------------------------------
20339 +* prism2sta_ev_tx
20340 +*
20341 +* Handles the Tx event.
20342 +*
20343 +* Arguments:
20344 +* wlandev wlan device structure
20345 +* status tx frame status word
20346 +* Returns:
20347 +* nothing
20348 +*
20349 +* Side effects:
20350 +*
20351 +* Call context:
20352 +* interrupt
20353 +----------------------------------------------------------------*/
20354 +void prism2sta_ev_tx(wlandevice_t *wlandev, u16 status)
20355 +{
20356 + DBFENTER;
20357 + WLAN_LOG_DEBUG(4, "Tx Complete, status=0x%04x\n", status);
20358 + /* update linux network stats */
20359 + wlandev->linux_stats.tx_packets++;
20360 + DBFEXIT;
20361 + return;
20362 +}
20363 +
20364 +
20365 +/*----------------------------------------------------------------
20366 +* prism2sta_ev_rx
20367 +*
20368 +* Handles the Rx event.
20369 +*
20370 +* Arguments:
20371 +* wlandev wlan device structure
20372 +*
20373 +* Returns:
20374 +* nothing
20375 +*
20376 +* Side effects:
20377 +*
20378 +* Call context:
20379 +* interrupt
20380 +----------------------------------------------------------------*/
20381 +void prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
20382 +{
20383 + DBFENTER;
20384 +
20385 + p80211netdev_rx(wlandev, skb);
20386 +
20387 + DBFEXIT;
20388 + return;
20389 +}
20390 +
20391 +/*----------------------------------------------------------------
20392 +* prism2sta_ev_alloc
20393 +*
20394 +* Handles the Alloc event.
20395 +*
20396 +* Arguments:
20397 +* wlandev wlan device structure
20398 +*
20399 +* Returns:
20400 +* nothing
20401 +*
20402 +* Side effects:
20403 +*
20404 +* Call context:
20405 +* interrupt
20406 +----------------------------------------------------------------*/
20407 +void prism2sta_ev_alloc(wlandevice_t *wlandev)
20408 +{
20409 + DBFENTER;
20410 +
20411 + netif_wake_queue(wlandev->netdev);
20412 +
20413 + DBFEXIT;
20414 + return;
20415 +}
20416 +
20417 +/*----------------------------------------------------------------
20418 +* create_wlan
20419 +*
20420 +* Called at module init time. This creates the wlandevice_t structure
20421 +* and initializes it with relevant bits.
20422 +*
20423 +* Arguments:
20424 +* none
20425 +*
20426 +* Returns:
20427 +* the created wlandevice_t structure.
20428 +*
20429 +* Side effects:
20430 +* also allocates the priv/hw structures.
20431 +*
20432 +* Call context:
20433 +* process thread
20434 +*
20435 +----------------------------------------------------------------*/
20436 +static wlandevice_t *create_wlan(void)
20437 +{
20438 + wlandevice_t *wlandev = NULL;
20439 + hfa384x_t *hw = NULL;
20440 +
20441 + /* Alloc our structures */
20442 + wlandev = kmalloc(sizeof(wlandevice_t), GFP_KERNEL);
20443 + hw = kmalloc(sizeof(hfa384x_t), GFP_KERNEL);
20444 +
20445 + if (!wlandev || !hw) {
20446 + WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info);
20447 + if (wlandev) kfree(wlandev);
20448 + if (hw) kfree(hw);
20449 + return NULL;
20450 + }
20451 +
20452 + /* Clear all the structs */
20453 + memset(wlandev, 0, sizeof(wlandevice_t));
20454 + memset(hw, 0, sizeof(hfa384x_t));
20455 +
20456 + /* Initialize the network device object. */
20457 + wlandev->nsdname = dev_info;
20458 + wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
20459 + wlandev->priv = hw;
20460 + wlandev->open = prism2sta_open;
20461 + wlandev->close = prism2sta_close;
20462 + wlandev->reset = prism2sta_reset;
20463 + wlandev->txframe = prism2sta_txframe;
20464 + wlandev->mlmerequest = prism2sta_mlmerequest;
20465 + wlandev->set_multicast_list = prism2sta_setmulticast;
20466 + wlandev->tx_timeout = hfa384x_tx_timeout;
20467 +
20468 + wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT |
20469 + P80211_NSDCAP_AUTOJOIN;
20470 +
20471 + /* Initialize the device private data stucture. */
20472 + hw->dot11_desired_bss_type = 1;
20473 +
20474 + return wlandev;
20475 +}
20476 +
20477 +void prism2sta_commsqual_defer(struct work_struct *data)
20478 +{
20479 + hfa384x_t *hw = container_of(data, struct hfa384x, commsqual_bh);
20480 + wlandevice_t *wlandev = hw->wlandev;
20481 + hfa384x_bytestr32_t ssid;
20482 + int result = 0;
20483 +
20484 + DBFENTER;
20485 +
20486 + if (hw->wlandev->hwremoved)
20487 + goto done;
20488 +
20489 + /* we don't care if we're in AP mode */
20490 + if ((wlandev->macmode == WLAN_MACMODE_NONE) ||
20491 + (wlandev->macmode == WLAN_MACMODE_ESS_AP)) {
20492 + goto done;
20493 + }
20494 +
20495 + /* It only makes sense to poll these in non-IBSS */
20496 + if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
20497 + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DBMCOMMSQUALITY,
20498 + &hw->qual,
20499 + HFA384x_RID_DBMCOMMSQUALITY_LEN);
20500 +
20501 + if (result) {
20502 + WLAN_LOG_ERROR("error fetching commsqual\n");
20503 + goto done;
20504 + }
20505 +
20506 + // qual.CQ_currBSS; // link
20507 + // ASL_currBSS; // level
20508 + // qual.ANL_currFC; // noise
20509 +
20510 + WLAN_LOG_DEBUG(3, "commsqual %d %d %d\n",
20511 + hfa384x2host_16(hw->qual.CQ_currBSS),
20512 + hfa384x2host_16(hw->qual.ASL_currBSS),
20513 + hfa384x2host_16(hw->qual.ANL_currFC));
20514 + }
20515 +
20516 + /* Lastly, we need to make sure the BSSID didn't change on us */
20517 + result = hfa384x_drvr_getconfig(hw,
20518 + HFA384x_RID_CURRENTBSSID,
20519 + wlandev->bssid, WLAN_BSSID_LEN);
20520 + if ( result ) {
20521 + WLAN_LOG_DEBUG(1,
20522 + "getconfig(0x%02x) failed, result = %d\n",
20523 + HFA384x_RID_CURRENTBSSID, result);
20524 + goto done;
20525 + }
20526 +
20527 + result = hfa384x_drvr_getconfig(hw,
20528 + HFA384x_RID_CURRENTSSID,
20529 + &ssid, sizeof(ssid));
20530 + if ( result ) {
20531 + WLAN_LOG_DEBUG(1,
20532 + "getconfig(0x%02x) failed, result = %d\n",
20533 + HFA384x_RID_CURRENTSSID, result);
20534 + goto done;
20535 + }
20536 + prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *)&ssid,
20537 + (p80211pstrd_t *) &wlandev->ssid);
20538 +
20539 +
20540 + /* Reschedule timer */
20541 + mod_timer(&hw->commsqual_timer, jiffies + HZ);
20542 +
20543 + done:
20544 + DBFEXIT;
20545 +}
20546 +
20547 +void prism2sta_commsqual_timer(unsigned long data)
20548 +{
20549 + hfa384x_t *hw = (hfa384x_t *) data;
20550 +
20551 + DBFENTER;
20552 +
20553 + schedule_work(&hw->commsqual_bh);
20554 +
20555 + DBFEXIT;
20556 +}
20557 --- /dev/null
20558 +++ b/drivers/staging/wlan-ng/prism2usb.c
20559 @@ -0,0 +1,302 @@
20560 +#include "hfa384x_usb.c"
20561 +#include "prism2mgmt.c"
20562 +#include "prism2mib.c"
20563 +#include "prism2sta.c"
20564 +
20565 +#define PRISM_USB_DEVICE(vid, pid, name) \
20566 + USB_DEVICE(vid, pid), \
20567 + .driver_info = (unsigned long) name
20568 +
20569 +static struct usb_device_id usb_prism_tbl[] = {
20570 + {PRISM_USB_DEVICE(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS")},
20571 + {PRISM_USB_DEVICE(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11")},
20572 + {PRISM_USB_DEVICE(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter")},
20573 + {PRISM_USB_DEVICE(0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")},
20574 + {PRISM_USB_DEVICE(0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")},
20575 + {PRISM_USB_DEVICE(0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter")},
20576 + {PRISM_USB_DEVICE(0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter")},
20577 + {PRISM_USB_DEVICE(0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter")},
20578 + {PRISM_USB_DEVICE(0x067c, 0x1022, "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter")},
20579 + {PRISM_USB_DEVICE(0x049f, 0x0033, "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter")},
20580 + {PRISM_USB_DEVICE(0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter")},
20581 + {PRISM_USB_DEVICE(0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")},
20582 + {PRISM_USB_DEVICE(0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter")},
20583 + {PRISM_USB_DEVICE(0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")},
20584 + {PRISM_USB_DEVICE(0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter")},
20585 + {PRISM_USB_DEVICE(0x0967, 0x0204, "Acer Warplink USB Adapter")},
20586 + {PRISM_USB_DEVICE(0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated")},
20587 + {PRISM_USB_DEVICE(0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter")},
20588 + {PRISM_USB_DEVICE(0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter")},
20589 + {PRISM_USB_DEVICE(0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter")},
20590 + {PRISM_USB_DEVICE(0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter")},
20591 + {PRISM_USB_DEVICE(0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter")},
20592 + {PRISM_USB_DEVICE(0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter")},
20593 + {PRISM_USB_DEVICE(0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter")},
20594 + {PRISM_USB_DEVICE(0x0846, 0x4110, "NetGear MA111")},
20595 + {PRISM_USB_DEVICE(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter")},
20596 +// {PRISM_USB_DEVICE(0x0ace, 0x1201, "ZyDAS ZD1201 Wireless USB Adapter")},
20597 + {PRISM_USB_DEVICE(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter")},
20598 + {PRISM_USB_DEVICE(0x2001, 0x3700, "DWL-122 Wireless USB Adapter")},
20599 + {PRISM_USB_DEVICE(0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter")},
20600 + {PRISM_USB_DEVICE(0x50c2, 0x4013, "Averatec USB WLAN Adapter")},
20601 + {PRISM_USB_DEVICE(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter")},
20602 + {PRISM_USB_DEVICE(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter")},
20603 + {PRISM_USB_DEVICE(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter")},
20604 + {PRISM_USB_DEVICE(0x2821, 0x3300, "Hawking HighDB USB Adapter")},
20605 + {PRISM_USB_DEVICE(0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter")},
20606 + {PRISM_USB_DEVICE(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter")},
20607 + {PRISM_USB_DEVICE(0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter")},
20608 + {PRISM_USB_DEVICE(0x0bb2, 0x0302, "Ambit Microsystems Corp.")},
20609 + {PRISM_USB_DEVICE(0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter")},
20610 + {PRISM_USB_DEVICE(0x0543, 0x0f01, "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)")},
20611 + { /* terminator */ }
20612 +};
20613 +
20614 +MODULE_DEVICE_TABLE(usb, usb_prism_tbl);
20615 +
20616 +/*----------------------------------------------------------------
20617 +* prism2sta_probe_usb
20618 +*
20619 +* Probe routine called by the USB subsystem.
20620 +*
20621 +* Arguments:
20622 +* dev ptr to the usb_device struct
20623 +* ifnum interface number being offered
20624 +*
20625 +* Returns:
20626 +* NULL - we're not claiming the device+interface
20627 +* non-NULL - we are claiming the device+interface and
20628 +* this is a ptr to the data we want back
20629 +* when disconnect is called.
20630 +*
20631 +* Side effects:
20632 +*
20633 +* Call context:
20634 +* I'm not sure, assume it's interrupt.
20635 +*
20636 +----------------------------------------------------------------*/
20637 +static int prism2sta_probe_usb(
20638 + struct usb_interface *interface,
20639 + const struct usb_device_id *id)
20640 +{
20641 + struct usb_device *dev;
20642 +
20643 + wlandevice_t *wlandev = NULL;
20644 + hfa384x_t *hw = NULL;
20645 + int result = 0;
20646 +
20647 + DBFENTER;
20648 +
20649 + dev = interface_to_usbdev(interface);
20650 +
20651 + if ((wlandev = create_wlan()) == NULL) {
20652 + WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info);
20653 + result = -EIO;
20654 + goto failed;
20655 + }
20656 + hw = wlandev->priv;
20657 +
20658 + if ( wlan_setup(wlandev) != 0 ) {
20659 + WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info);
20660 + result = -EIO;
20661 + goto failed;
20662 + }
20663 +
20664 + /* Initialize the hw data */
20665 + hfa384x_create(hw, dev);
20666 + hw->wlandev = wlandev;
20667 +
20668 + /* Register the wlandev, this gets us a name and registers the
20669 + * linux netdevice.
20670 + */
20671 + SET_NETDEV_DEV(wlandev->netdev, &(interface->dev));
20672 +
20673 + /* Do a chip-level reset on the MAC */
20674 + if (prism2_doreset) {
20675 + result = hfa384x_corereset(hw,
20676 + prism2_reset_holdtime,
20677 + prism2_reset_settletime, 0);
20678 + if (result != 0) {
20679 + unregister_wlandev(wlandev);
20680 + hfa384x_destroy(hw);
20681 + result = -EIO;
20682 + WLAN_LOG_ERROR(
20683 + "%s: hfa384x_corereset() failed.\n",
20684 + dev_info);
20685 + goto failed;
20686 + }
20687 + }
20688 +
20689 + usb_get_dev(dev);
20690 +
20691 + wlandev->msdstate = WLAN_MSD_HWPRESENT;
20692 +
20693 + if ( register_wlandev(wlandev) != 0 ) {
20694 + WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
20695 + result = -EIO;
20696 + goto failed;
20697 + }
20698 +
20699 +/* enable the card */
20700 + prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable);
20701 +
20702 + goto done;
20703 +
20704 + failed:
20705 + if (wlandev) kfree(wlandev);
20706 + if (hw) kfree(hw);
20707 + wlandev = NULL;
20708 +
20709 + done:
20710 + DBFEXIT;
20711 +
20712 + usb_set_intfdata(interface, wlandev);
20713 + return result;
20714 +}
20715 +
20716 +
20717 +/*----------------------------------------------------------------
20718 +* prism2sta_disconnect_usb
20719 +*
20720 +* Called when a device previously claimed by probe is removed
20721 +* from the USB.
20722 +*
20723 +* Arguments:
20724 +* dev ptr to the usb_device struct
20725 +* ptr ptr returned by probe() when the device
20726 +* was claimed.
20727 +*
20728 +* Returns:
20729 +* Nothing
20730 +*
20731 +* Side effects:
20732 +*
20733 +* Call context:
20734 +* process
20735 +----------------------------------------------------------------*/
20736 +static void
20737 +prism2sta_disconnect_usb(struct usb_interface *interface)
20738 +{
20739 + wlandevice_t *wlandev;
20740 +
20741 + DBFENTER;
20742 +
20743 + wlandev = (wlandevice_t *) usb_get_intfdata(interface);
20744 +
20745 + if ( wlandev != NULL ) {
20746 + LIST_HEAD(cleanlist);
20747 + struct list_head *entry;
20748 + struct list_head *temp;
20749 + unsigned long flags;
20750 +
20751 + hfa384x_t *hw = wlandev->priv;
20752 +
20753 + if (!hw)
20754 + goto exit;
20755 +
20756 + spin_lock_irqsave(&hw->ctlxq.lock, flags);
20757 +
20758 + p80211netdev_hwremoved(wlandev);
20759 + list_splice_init(&hw->ctlxq.reapable, &cleanlist);
20760 + list_splice_init(&hw->ctlxq.completing, &cleanlist);
20761 + list_splice_init(&hw->ctlxq.pending, &cleanlist);
20762 + list_splice_init(&hw->ctlxq.active, &cleanlist);
20763 +
20764 + spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
20765 +
20766 + /* There's no hardware to shutdown, but the driver
20767 + * might have some tasks or tasklets that must be
20768 + * stopped before we can tear everything down.
20769 + */
20770 + prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable);
20771 +
20772 + del_singleshot_timer_sync(&hw->throttle);
20773 + del_singleshot_timer_sync(&hw->reqtimer);
20774 + del_singleshot_timer_sync(&hw->resptimer);
20775 +
20776 + /* Unlink all the URBs. This "removes the wheels"
20777 + * from the entire CTLX handling mechanism.
20778 + */
20779 + usb_kill_urb(&hw->rx_urb);
20780 + usb_kill_urb(&hw->tx_urb);
20781 + usb_kill_urb(&hw->ctlx_urb);
20782 +
20783 + tasklet_kill(&hw->completion_bh);
20784 + tasklet_kill(&hw->reaper_bh);
20785 +
20786 + flush_scheduled_work();
20787 +
20788 + /* Now we complete any outstanding commands
20789 + * and tell everyone who is waiting for their
20790 + * responses that we have shut down.
20791 + */
20792 + list_for_each(entry, &cleanlist) {
20793 + hfa384x_usbctlx_t *ctlx;
20794 +
20795 + ctlx = list_entry(entry, hfa384x_usbctlx_t, list);
20796 + complete(&ctlx->done);
20797 + }
20798 +
20799 + /* Give any outstanding synchronous commands
20800 + * a chance to complete. All they need to do
20801 + * is "wake up", so that's easy.
20802 + * (I'd like a better way to do this, really.)
20803 + */
20804 + msleep(100);
20805 +
20806 + /* Now delete the CTLXs, because no-one else can now. */
20807 + list_for_each_safe(entry, temp, &cleanlist) {
20808 + hfa384x_usbctlx_t *ctlx;
20809 +
20810 + ctlx = list_entry(entry, hfa384x_usbctlx_t, list);
20811 + kfree(ctlx);
20812 + }
20813 +
20814 + /* Unhook the wlandev */
20815 + unregister_wlandev(wlandev);
20816 + wlan_unsetup(wlandev);
20817 +
20818 + usb_put_dev(hw->usb);
20819 +
20820 + hfa384x_destroy(hw);
20821 + kfree(hw);
20822 +
20823 + kfree(wlandev);
20824 + }
20825 +
20826 + exit:
20827 +
20828 + usb_set_intfdata(interface, NULL);
20829 + DBFEXIT;
20830 +}
20831 +
20832 +
20833 +static struct usb_driver prism2_usb_driver = {
20834 + .name = "prism2_usb",
20835 + .probe = prism2sta_probe_usb,
20836 + .disconnect = prism2sta_disconnect_usb,
20837 + .id_table = usb_prism_tbl,
20838 + /* fops, minor? */
20839 +};
20840 +
20841 +static int __init prism2usb_init(void)
20842 +{
20843 + DBFENTER;
20844 +
20845 + /* This call will result in calls to prism2sta_probe_usb. */
20846 + return usb_register(&prism2_usb_driver);
20847 +
20848 + DBFEXIT;
20849 +};
20850 +
20851 +static void __exit prism2usb_cleanup(void)
20852 +{
20853 + DBFENTER;
20854 +
20855 + usb_deregister(&prism2_usb_driver);
20856 +
20857 + DBFEXIT;
20858 +};
20859 +
20860 +module_init(prism2usb_init);
20861 +module_exit(prism2usb_cleanup);
20862 --- /dev/null
20863 +++ b/drivers/staging/wlan-ng/README
20864 @@ -0,0 +1,7 @@
20865 +TODO:
20866 + - checkpatch.pl cleanups
20867 + - sparse warnings
20868 + - Lindent cleanups
20869 + - move to use the in-kernel wireless stack
20870 +
20871 +Please send all patches to Greg Kroah-Hartman <greg@kroah.com>
20872 --- /dev/null
20873 +++ b/drivers/staging/wlan-ng/version.h
20874 @@ -0,0 +1,56 @@
20875 +/* src/include/wlan/version.h
20876 +*
20877 +*
20878 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
20879 +* --------------------------------------------------------------------
20880 +*
20881 +* linux-wlan
20882 +*
20883 +* The contents of this file are subject to the Mozilla Public
20884 +* License Version 1.1 (the "License"); you may not use this file
20885 +* except in compliance with the License. You may obtain a copy of
20886 +* the License at http://www.mozilla.org/MPL/
20887 +*
20888 +* Software distributed under the License is distributed on an "AS
20889 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
20890 +* implied. See the License for the specific language governing
20891 +* rights and limitations under the License.
20892 +*
20893 +* Alternatively, the contents of this file may be used under the
20894 +* terms of the GNU Public License version 2 (the "GPL"), in which
20895 +* case the provisions of the GPL are applicable instead of the
20896 +* above. If you wish to allow the use of your version of this file
20897 +* only under the terms of the GPL and not to allow others to use
20898 +* your version of this file under the MPL, indicate your decision
20899 +* by deleting the provisions above and replace them with the notice
20900 +* and other provisions required by the GPL. If you do not delete
20901 +* the provisions above, a recipient may use your version of this
20902 +* file under either the MPL or the GPL.
20903 +*
20904 +* --------------------------------------------------------------------
20905 +*
20906 +* Inquiries regarding the linux-wlan Open Source project can be
20907 +* made directly to:
20908 +*
20909 +* AbsoluteValue Systems Inc.
20910 +* info@linux-wlan.com
20911 +* http://www.linux-wlan.com
20912 +*
20913 +* --------------------------------------------------------------------
20914 +*
20915 +* Portions of the development of this software were funded by
20916 +* Intersil Corporation as part of PRISM(R) chipset product development.
20917 +*
20918 +* --------------------------------------------------------------------
20919 +*/
20920 +#ifndef _WLAN_VERSION_H
20921 +#define _WLAN_VERSION_H
20922 +#ifndef KERNEL_VERSION
20923 +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
20924 +#endif
20925 +
20926 +#define WLAN_RELEASE "0.2.8"
20927 +#define WLAN_RELEASE_CODE 0x000208
20928 +#define WLAN_BUILD_DATE "Thu Oct 2 11:04:42 PDT 2008"
20929 +
20930 +#endif
20931 --- /dev/null
20932 +++ b/drivers/staging/wlan-ng/wlan_compat.h
20933 @@ -0,0 +1,193 @@
20934 +/* wlan_compat.h
20935 +*
20936 +* Types and macros to aid in portability
20937 +*
20938 +* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
20939 +* --------------------------------------------------------------------
20940 +*
20941 +* linux-wlan
20942 +*
20943 +* The contents of this file are subject to the Mozilla Public
20944 +* License Version 1.1 (the "License"); you may not use this file
20945 +* except in compliance with the License. You may obtain a copy of
20946 +* the License at http://www.mozilla.org/MPL/
20947 +*
20948 +* Software distributed under the License is distributed on an "AS
20949 +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
20950 +* implied. See the License for the specific language governing
20951 +* rights and limitations under the License.
20952 +*
20953 +* Alternatively, the contents of this file may be used under the
20954 +* terms of the GNU Public License version 2 (the "GPL"), in which
20955 +* case the provisions of the GPL are applicable instead of the
20956 +* above. If you wish to allow the use of your version of this file
20957 +* only under the terms of the GPL and not to allow others to use
20958 +* your version of this file under the MPL, indicate your decision
20959 +* by deleting the provisions above and replace them with the notice
20960 +* and other provisions required by the GPL. If you do not delete
20961 +* the provisions above, a recipient may use your version of this
20962 +* file under either the MPL or the GPL.
20963 +*
20964 +* --------------------------------------------------------------------
20965 +*
20966 +* Inquiries regarding the linux-wlan Open Source project can be
20967 +* made directly to:
20968 +*
20969 +* AbsoluteValue Systems Inc.
20970 +* info@linux-wlan.com
20971 +* http://www.linux-wlan.com
20972 +*
20973 +* --------------------------------------------------------------------
20974 +*
20975 +* Portions of the development of this software were funded by
20976 +* Intersil Corporation as part of PRISM(R) chipset product development.
20977 +*
20978 +* --------------------------------------------------------------------
20979 +*/
20980 +
20981 +#ifndef _WLAN_COMPAT_H
20982 +#define _WLAN_COMPAT_H
20983 +
20984 +/*=============================================================*/
20985 +/*------ Bit settings -----------------------------------------*/
20986 +/*=============================================================*/
20987 +
20988 +#define BIT0 0x00000001
20989 +#define BIT1 0x00000002
20990 +#define BIT2 0x00000004
20991 +#define BIT3 0x00000008
20992 +#define BIT4 0x00000010
20993 +#define BIT5 0x00000020
20994 +#define BIT6 0x00000040
20995 +#define BIT7 0x00000080
20996 +#define BIT8 0x00000100
20997 +#define BIT9 0x00000200
20998 +#define BIT10 0x00000400
20999 +#define BIT11 0x00000800
21000 +#define BIT12 0x00001000
21001 +#define BIT13 0x00002000
21002 +#define BIT14 0x00004000
21003 +#define BIT15 0x00008000
21004 +#define BIT16 0x00010000
21005 +#define BIT17 0x00020000
21006 +#define BIT18 0x00040000
21007 +#define BIT19 0x00080000
21008 +#define BIT20 0x00100000
21009 +#define BIT21 0x00200000
21010 +#define BIT22 0x00400000
21011 +#define BIT23 0x00800000
21012 +#define BIT24 0x01000000
21013 +#define BIT25 0x02000000
21014 +#define BIT26 0x04000000
21015 +#define BIT27 0x08000000
21016 +#define BIT28 0x10000000
21017 +#define BIT29 0x20000000
21018 +#define BIT30 0x40000000
21019 +#define BIT31 0x80000000
21020 +
21021 +/*=============================================================*/
21022 +/*------ Compiler Portability Macros --------------------------*/
21023 +/*=============================================================*/
21024 +#define __WLAN_ATTRIB_PACK__ __attribute__ ((packed))
21025 +
21026 +/*=============================================================*/
21027 +/*------ OS Portability Macros --------------------------------*/
21028 +/*=============================================================*/
21029 +
21030 +#ifndef WLAN_DBVAR
21031 +#define WLAN_DBVAR wlan_debug
21032 +#endif
21033 +
21034 +#define WLAN_RELEASE "0.3.0-lkml"
21035 +
21036 +#include <linux/hardirq.h>
21037 +
21038 +#define WLAN_LOG_ERROR(x,args...) printk(KERN_ERR "%s: " x , __func__ , ##args);
21039 +
21040 +#define WLAN_LOG_WARNING(x,args...) printk(KERN_WARNING "%s: " x , __func__ , ##args);
21041 +
21042 +#define WLAN_LOG_NOTICE(x,args...) printk(KERN_NOTICE "%s: " x , __func__ , ##args);
21043 +
21044 +#define WLAN_LOG_INFO(args... ) printk(KERN_INFO args)
21045 +
21046 +#if defined(WLAN_INCLUDE_DEBUG)
21047 + #define WLAN_HEX_DUMP( l, x, p, n) if( WLAN_DBVAR >= (l) ){ \
21048 + int __i__; \
21049 + printk(KERN_DEBUG x ":"); \
21050 + for( __i__=0; __i__ < (n); __i__++) \
21051 + printk( " %02x", ((u8*)(p))[__i__]); \
21052 + printk("\n"); }
21053 + #define DBFENTER { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"---->\n"); } }
21054 + #define DBFEXIT { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"<----\n"); } }
21055 +
21056 + #define WLAN_LOG_DEBUG(l,x,args...) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s(%lu): " x , __func__, (preempt_count() & PREEMPT_MASK), ##args );
21057 +#else
21058 + #define WLAN_HEX_DUMP( l, s, p, n)
21059 + #define DBFENTER
21060 + #define DBFEXIT
21061 +
21062 + #define WLAN_LOG_DEBUG(l, s, args...)
21063 +#endif
21064 +
21065 +#undef netdevice_t
21066 +typedef struct net_device netdevice_t;
21067 +
21068 +#define URB_ASYNC_UNLINK 0
21069 +#define USB_QUEUE_BULK 0
21070 +
21071 +/*=============================================================*/
21072 +/*------ Hardware Portability Macros --------------------------*/
21073 +/*=============================================================*/
21074 +
21075 +#define ieee2host16(n) __le16_to_cpu(n)
21076 +#define ieee2host32(n) __le32_to_cpu(n)
21077 +#define host2ieee16(n) __cpu_to_le16(n)
21078 +#define host2ieee32(n) __cpu_to_le32(n)
21079 +
21080 +/*=============================================================*/
21081 +/*--- General Macros ------------------------------------------*/
21082 +/*=============================================================*/
21083 +
21084 +#define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
21085 +#define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
21086 +
21087 +#define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
21088 +
21089 +#define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
21090 +
21091 +/* Create a string of printable chars from something that might not be */
21092 +/* It's recommended that the str be 4*len + 1 bytes long */
21093 +#define wlan_mkprintstr(buf, buflen, str, strlen) \
21094 +{ \
21095 + int i = 0; \
21096 + int j = 0; \
21097 + memset(str, 0, (strlen)); \
21098 + for (i = 0; i < (buflen); i++) { \
21099 + if ( wlan_isprint((buf)[i]) ) { \
21100 + (str)[j] = (buf)[i]; \
21101 + j++; \
21102 + } else { \
21103 + (str)[j] = '\\'; \
21104 + (str)[j+1] = 'x'; \
21105 + (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
21106 + (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
21107 + j += 4; \
21108 + } \
21109 + } \
21110 +}
21111 +
21112 +/*=============================================================*/
21113 +/*--- Variables -----------------------------------------------*/
21114 +/*=============================================================*/
21115 +
21116 +#ifdef WLAN_INCLUDE_DEBUG
21117 +extern int wlan_debug;
21118 +#endif
21119 +
21120 +extern int wlan_ethconv; /* What's the default ethconv? */
21121 +
21122 +/*=============================================================*/
21123 +/*--- Functions -----------------------------------------------*/
21124 +/*=============================================================*/
21125 +#endif /* _WLAN_COMPAT_H */
21126 +