1 /* hfa384x.h
2 *
3 * Defines the constants and data structures for the hfa384x
4 *
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
6 * --------------------------------------------------------------------
7 *
8 * linux-wlan
9 *
10 *   The contents of this file are subject to the Mozilla Public
11 *   License Version 1.1 (the "License"); you may not use this file
12 *   except in compliance with the License. You may obtain a copy of
13 *   the License at http://www.mozilla.org/MPL/
14 *
15 *   Software distributed under the License is distributed on an "AS
16 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 *   implied. See the License for the specific language governing
18 *   rights and limitations under the License.
19 *
20 *   Alternatively, the contents of this file may be used under the
21 *   terms of the GNU Public License version 2 (the "GPL"), in which
22 *   case the provisions of the GPL are applicable instead of the
23 *   above.  If you wish to allow the use of your version of this file
24 *   only under the terms of the GPL and not to allow others to use
25 *   your version of this file under the MPL, indicate your decision
26 *   by deleting the provisions above and replace them with the notice
27 *   and other provisions required by the GPL.  If you do not delete
28 *   the provisions above, a recipient may use your version of this
29 *   file under either the MPL or the GPL.
30 *
31 * --------------------------------------------------------------------
32 *
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
35 *
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
39 *
40 * --------------------------------------------------------------------
41 *
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
44 *
45 * --------------------------------------------------------------------
46 *
47 *   [Implementation and usage notes]
48 *
49 *   [References]
50 *	CW10 Programmer's Manual v1.5
51 *	IEEE 802.11 D10.0
52 *
53 * --------------------------------------------------------------------
54 */
55 
56 #ifndef _HFA384x_H
57 #define _HFA384x_H
58 
59 #define HFA384x_FIRMWARE_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
60 
61 #include <linux/if_ether.h>
62 #include <linux/usb.h>
63 
64 /*--- Mins & Maxs -----------------------------------*/
65 #define	HFA384x_PORTID_MAX		((u16)7)
66 #define	HFA384x_NUMPORTS_MAX		((u16)(HFA384x_PORTID_MAX + 1))
67 #define	HFA384x_PDR_LEN_MAX		((u16)512) /* in bytes, from EK */
68 #define	HFA384x_PDA_RECS_MAX		((u16)200) /* a guess */
69 #define	HFA384x_PDA_LEN_MAX		((u16)1024) /* in bytes, from EK*/
70 #define	HFA384x_SCANRESULT_MAX		((u16)31)
71 #define	HFA384x_HSCANRESULT_MAX		((u16)31)
72 #define	HFA384x_CHINFORESULT_MAX	((u16)16)
73 #define	HFA384x_RID_GUESSING_MAXLEN	2048	/* I'm not really sure */
74 #define	HFA384x_RIDDATA_MAXLEN		HFA384x_RID_GUESSING_MAXLEN
75 #define	HFA384x_USB_RWMEM_MAXLEN	2048
76 
77 /*--- Support Constants -----------------------------*/
78 #define		HFA384x_PORTTYPE_IBSS			((u16)0)
79 #define		HFA384x_PORTTYPE_BSS			((u16)1)
80 #define		HFA384x_PORTTYPE_PSUEDOIBSS		((u16)3)
81 #define		HFA384x_WEPFLAGS_PRIVINVOKED		((u16)BIT(0))
82 #define		HFA384x_WEPFLAGS_EXCLUDE		((u16)BIT(1))
83 #define		HFA384x_WEPFLAGS_DISABLE_TXCRYPT	((u16)BIT(4))
84 #define		HFA384x_WEPFLAGS_DISABLE_RXCRYPT	((u16)BIT(7))
85 #define		HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM	((u16)3)
86 #define		HFA384x_PORTSTATUS_DISABLED		((u16)1)
87 #define		HFA384x_RATEBIT_1			((u16)1)
88 #define		HFA384x_RATEBIT_2			((u16)2)
89 #define		HFA384x_RATEBIT_5dot5			((u16)4)
90 #define		HFA384x_RATEBIT_11			((u16)8)
91 
92 /*--- MAC Internal memory constants and macros ------*/
93 /* masks and macros used to manipulate MAC internal memory addresses. */
94 /* MAC internal memory addresses are 23 bit quantities.  The MAC uses
95  * a paged address space where the upper 16 bits are the page number
96  * and the lower 7 bits are the offset.  There are various Host API
97  * elements that require two 16-bit quantities to specify a MAC
98  * internal memory address.  Unfortunately, some of the API's use a
99  * page/offset format where the offset value is JUST the lower seven
100  * bits and the page is  the remaining 16 bits.  Some of the API's
101  * assume that the 23 bit address has been split at the 16th bit.  We
102  * refer to these two formats as AUX format and CMD format.  The
103  * macros below help handle some of this.
104  */
105 
106 /* Mask bits for discarding unwanted pieces in a flat address */
107 #define		HFA384x_ADDR_FLAT_AUX_PAGE_MASK	(0x007fff80)
108 #define		HFA384x_ADDR_FLAT_AUX_OFF_MASK	(0x0000007f)
109 #define		HFA384x_ADDR_FLAT_CMD_PAGE_MASK	(0xffff0000)
110 #define		HFA384x_ADDR_FLAT_CMD_OFF_MASK	(0x0000ffff)
111 
112 /* Mask bits for discarding unwanted pieces in AUX format
113  * 16-bit address parts
114  */
115 #define		HFA384x_ADDR_AUX_PAGE_MASK	(0xffff)
116 #define		HFA384x_ADDR_AUX_OFF_MASK	(0x007f)
117 
118 /* Make a 32-bit flat address from AUX format 16-bit page and offset */
119 #define		HFA384x_ADDR_AUX_MKFLAT(p, o)	\
120 		((((u32)(((u16)(p)) & HFA384x_ADDR_AUX_PAGE_MASK)) << 7) | \
121 		((u32)(((u16)(o)) & HFA384x_ADDR_AUX_OFF_MASK)))
122 
123 /* Make CMD format offset and page from a 32-bit flat address */
124 #define		HFA384x_ADDR_CMD_MKPAGE(f) \
125 		((u16)((((u32)(f)) & HFA384x_ADDR_FLAT_CMD_PAGE_MASK) >> 16))
126 #define		HFA384x_ADDR_CMD_MKOFF(f) \
127 		((u16)(((u32)(f)) & HFA384x_ADDR_FLAT_CMD_OFF_MASK))
128 
129 /*--- Controller Memory addresses -------------------*/
130 #define		HFA3842_PDA_BASE	(0x007f0000UL)
131 #define		HFA3841_PDA_BASE	(0x003f0000UL)
132 #define		HFA3841_PDA_BOGUS_BASE	(0x00390000UL)
133 
134 /*--- Driver Download states  -----------------------*/
135 #define		HFA384x_DLSTATE_DISABLED		0
136 #define		HFA384x_DLSTATE_RAMENABLED		1
137 #define		HFA384x_DLSTATE_FLASHENABLED		2
138 
139 /*--- Register Field Masks --------------------------*/
140 #define		HFA384x_CMD_AINFO		((u16)(BIT(14) | BIT(13) \
141 							| BIT(12) | BIT(11) \
142 							| BIT(10) | BIT(9) \
143 							| BIT(8)))
144 #define		HFA384x_CMD_MACPORT		((u16)(BIT(10) | BIT(9) | \
145 							BIT(8)))
146 #define		HFA384x_CMD_PROGMODE		((u16)(BIT(9) | BIT(8)))
147 #define		HFA384x_CMD_CMDCODE		((u16)(BIT(5) | BIT(4) | \
148 							BIT(3) | BIT(2) | \
149 							BIT(1) | BIT(0)))
150 
151 #define		HFA384x_STATUS_RESULT		((u16)(BIT(14) | BIT(13) \
152 							| BIT(12) | BIT(11) \
153 							| BIT(10) | BIT(9) \
154 							| BIT(8)))
155 
156 /*--- Command Code Constants --------------------------*/
157 /*--- Controller Commands --------------------------*/
158 #define		HFA384x_CMDCODE_INIT		((u16)0x00)
159 #define		HFA384x_CMDCODE_ENABLE		((u16)0x01)
160 #define		HFA384x_CMDCODE_DISABLE		((u16)0x02)
161 
162 /*--- Regulate Commands --------------------------*/
163 #define		HFA384x_CMDCODE_INQ		((u16)0x11)
164 
165 /*--- Configure Commands --------------------------*/
166 #define		HFA384x_CMDCODE_DOWNLD		((u16)0x22)
167 
168 /*--- Debugging Commands -----------------------------*/
169 #define		HFA384x_CMDCODE_MONITOR		((u16)(0x38))
170 #define		HFA384x_MONITOR_ENABLE		((u16)(0x0b))
171 #define		HFA384x_MONITOR_DISABLE		((u16)(0x0f))
172 
173 /*--- Result Codes --------------------------*/
174 #define		HFA384x_CMD_ERR			((u16)(0x7F))
175 
176 /*--- Programming Modes --------------------------
177 	MODE 0: Disable programming
178 	MODE 1: Enable volatile memory programming
179 	MODE 2: Enable non-volatile memory programming
180 	MODE 3: Program non-volatile memory section
181 --------------------------------------------------*/
182 #define		HFA384x_PROGMODE_DISABLE	((u16)0x00)
183 #define		HFA384x_PROGMODE_RAM		((u16)0x01)
184 #define		HFA384x_PROGMODE_NV		((u16)0x02)
185 #define		HFA384x_PROGMODE_NVWRITE	((u16)0x03)
186 
187 /*--- Record ID Constants --------------------------*/
188 /*--------------------------------------------------------------------
189 Configuration RIDs: Network Parameters, Static Configuration Entities
190 --------------------------------------------------------------------*/
191 #define		HFA384x_RID_CNFPORTTYPE		((u16)0xFC00)
192 #define		HFA384x_RID_CNFOWNMACADDR	((u16)0xFC01)
193 #define		HFA384x_RID_CNFDESIREDSSID	((u16)0xFC02)
194 #define		HFA384x_RID_CNFOWNCHANNEL	((u16)0xFC03)
195 #define		HFA384x_RID_CNFOWNSSID		((u16)0xFC04)
196 #define		HFA384x_RID_CNFMAXDATALEN	((u16)0xFC07)
197 
198 /*--------------------------------------------------------------------
199 Configuration RID lengths: Network Params, Static Config Entities
200   This is the length of JUST the DATA part of the RID (does not
201   include the len or code fields)
202 --------------------------------------------------------------------*/
203 #define		HFA384x_RID_CNFOWNMACADDR_LEN	((u16)6)
204 #define		HFA384x_RID_CNFDESIREDSSID_LEN	((u16)34)
205 #define		HFA384x_RID_CNFOWNSSID_LEN	((u16)34)
206 
207 /*--------------------------------------------------------------------
208 Configuration RIDs: Network Parameters, Dynamic Configuration Entities
209 --------------------------------------------------------------------*/
210 #define		HFA384x_RID_CREATEIBSS		((u16)0xFC81)
211 #define		HFA384x_RID_FRAGTHRESH		((u16)0xFC82)
212 #define		HFA384x_RID_RTSTHRESH		((u16)0xFC83)
213 #define		HFA384x_RID_TXRATECNTL		((u16)0xFC84)
214 #define		HFA384x_RID_PROMISCMODE		((u16)0xFC85)
215 
216 /*----------------------------------------------------------------------
217 Information RIDs: NIC Information
218 --------------------------------------------------------------------*/
219 #define		HFA384x_RID_MAXLOADTIME		((u16)0xFD00)
220 #define		HFA384x_RID_DOWNLOADBUFFER	((u16)0xFD01)
221 #define		HFA384x_RID_PRIIDENTITY		((u16)0xFD02)
222 #define		HFA384x_RID_PRISUPRANGE		((u16)0xFD03)
223 #define		HFA384x_RID_PRI_CFIACTRANGES	((u16)0xFD04)
224 #define		HFA384x_RID_NICSERIALNUMBER	((u16)0xFD0A)
225 #define		HFA384x_RID_NICIDENTITY		((u16)0xFD0B)
226 #define		HFA384x_RID_MFISUPRANGE		((u16)0xFD0C)
227 #define		HFA384x_RID_CFISUPRANGE		((u16)0xFD0D)
228 #define		HFA384x_RID_STAIDENTITY		((u16)0xFD20)
229 #define		HFA384x_RID_STASUPRANGE		((u16)0xFD21)
230 #define		HFA384x_RID_STA_MFIACTRANGES	((u16)0xFD22)
231 #define		HFA384x_RID_STA_CFIACTRANGES	((u16)0xFD23)
232 
233 /*----------------------------------------------------------------------
234 Information RID Lengths: NIC Information
235   This is the length of JUST the DATA part of the RID (does not
236   include the len or code fields)
237 --------------------------------------------------------------------*/
238 #define		HFA384x_RID_NICSERIALNUMBER_LEN		((u16)12)
239 
240 /*--------------------------------------------------------------------
241 Information RIDs:  MAC Information
242 --------------------------------------------------------------------*/
243 #define		HFA384x_RID_PORTSTATUS		((u16)0xFD40)
244 #define		HFA384x_RID_CURRENTSSID		((u16)0xFD41)
245 #define		HFA384x_RID_CURRENTBSSID	((u16)0xFD42)
246 #define		HFA384x_RID_CURRENTTXRATE	((u16)0xFD44)
247 #define		HFA384x_RID_SHORTRETRYLIMIT	((u16)0xFD48)
248 #define		HFA384x_RID_LONGRETRYLIMIT	((u16)0xFD49)
249 #define		HFA384x_RID_MAXTXLIFETIME	((u16)0xFD4A)
250 #define		HFA384x_RID_PRIVACYOPTIMP	((u16)0xFD4F)
251 #define		HFA384x_RID_DBMCOMMSQUALITY	((u16)0xFD51)
252 
253 /*--------------------------------------------------------------------
254 Information RID Lengths:  MAC Information
255   This is the length of JUST the DATA part of the RID (does not
256   include the len or code fields)
257 --------------------------------------------------------------------*/
258 #define		HFA384x_RID_DBMCOMMSQUALITY_LEN	 \
259 	((u16) sizeof(hfa384x_dbmcommsquality_t))
260 #define		HFA384x_RID_JOINREQUEST_LEN \
261 	((u16)sizeof(hfa384x_JoinRequest_data_t))
262 
263 /*--------------------------------------------------------------------
264 Information RIDs:  Modem Information
265 --------------------------------------------------------------------*/
266 #define		HFA384x_RID_CURRENTCHANNEL	((u16)0xFDC1)
267 
268 /*--------------------------------------------------------------------
269 API ENHANCEMENTS (NOT ALREADY IMPLEMENTED)
270 --------------------------------------------------------------------*/
271 #define		HFA384x_RID_CNFWEPDEFAULTKEYID	((u16)0xFC23)
272 #define		HFA384x_RID_CNFWEPDEFAULTKEY0	((u16)0xFC24)
273 #define		HFA384x_RID_CNFWEPDEFAULTKEY1	((u16)0xFC25)
274 #define		HFA384x_RID_CNFWEPDEFAULTKEY2	((u16)0xFC26)
275 #define		HFA384x_RID_CNFWEPDEFAULTKEY3	((u16)0xFC27)
276 #define		HFA384x_RID_CNFWEPFLAGS		((u16)0xFC28)
277 #define		HFA384x_RID_CNFAUTHENTICATION	((u16)0xFC2A)
278 #define		HFA384x_RID_CNFROAMINGMODE	((u16)0xFC2D)
279 #define		HFA384x_RID_CNFAPBCNint		((u16)0xFC33)
280 #define		HFA384x_RID_CNFDBMADJUST	((u16)0xFC46)
281 #define		HFA384x_RID_CNFWPADATA		((u16)0xFC48)
282 #define		HFA384x_RID_CNFBASICRATES	((u16)0xFCB3)
283 #define		HFA384x_RID_CNFSUPPRATES	((u16)0xFCB4)
284 #define		HFA384x_RID_CNFPASSIVESCANCTRL	((u16)0xFCBA)
285 #define		HFA384x_RID_TXPOWERMAX		((u16)0xFCBE)
286 #define		HFA384x_RID_JOINREQUEST		((u16)0xFCE2)
287 #define		HFA384x_RID_AUTHENTICATESTA	((u16)0xFCE3)
288 #define		HFA384x_RID_HOSTSCAN		((u16)0xFCE5)
289 
290 #define		HFA384x_RID_CNFWEPDEFAULTKEY_LEN	((u16)6)
291 #define		HFA384x_RID_CNFWEP128DEFAULTKEY_LEN	((u16)14)
292 
293 /*--------------------------------------------------------------------
294 PD Record codes
295 --------------------------------------------------------------------*/
296 #define HFA384x_PDR_PCB_PARTNUM		((u16)0x0001)
297 #define HFA384x_PDR_PDAVER		((u16)0x0002)
298 #define HFA384x_PDR_NIC_SERIAL		((u16)0x0003)
299 #define HFA384x_PDR_MKK_MEASUREMENTS	((u16)0x0004)
300 #define HFA384x_PDR_NIC_RAMSIZE		((u16)0x0005)
301 #define HFA384x_PDR_MFISUPRANGE		((u16)0x0006)
302 #define HFA384x_PDR_CFISUPRANGE		((u16)0x0007)
303 #define HFA384x_PDR_NICID		((u16)0x0008)
304 #define HFA384x_PDR_MAC_ADDRESS		((u16)0x0101)
305 #define HFA384x_PDR_REGDOMAIN		((u16)0x0103)
306 #define HFA384x_PDR_ALLOWED_CHANNEL	((u16)0x0104)
307 #define HFA384x_PDR_DEFAULT_CHANNEL	((u16)0x0105)
308 #define HFA384x_PDR_TEMPTYPE		((u16)0x0107)
309 #define HFA384x_PDR_IFR_SETTING		((u16)0x0200)
310 #define HFA384x_PDR_RFR_SETTING		((u16)0x0201)
311 #define HFA384x_PDR_HFA3861_BASELINE	((u16)0x0202)
312 #define HFA384x_PDR_HFA3861_SHADOW	((u16)0x0203)
313 #define HFA384x_PDR_HFA3861_IFRF	((u16)0x0204)
314 #define HFA384x_PDR_HFA3861_CHCALSP	((u16)0x0300)
315 #define HFA384x_PDR_HFA3861_CHCALI	((u16)0x0301)
316 #define HFA384x_PDR_MAX_TX_POWER	((u16)0x0302)
317 #define HFA384x_PDR_MASTER_CHAN_LIST	((u16)0x0303)
318 #define HFA384x_PDR_3842_NIC_CONFIG	((u16)0x0400)
319 #define HFA384x_PDR_USB_ID		((u16)0x0401)
320 #define HFA384x_PDR_PCI_ID		((u16)0x0402)
321 #define HFA384x_PDR_PCI_IFCONF		((u16)0x0403)
322 #define HFA384x_PDR_PCI_PMCONF		((u16)0x0404)
323 #define HFA384x_PDR_RFENRGY		((u16)0x0406)
324 #define HFA384x_PDR_USB_POWER_TYPE      ((u16)0x0407)
325 #define HFA384x_PDR_USB_MAX_POWER	((u16)0x0409)
326 #define HFA384x_PDR_USB_MANUFACTURER	((u16)0x0410)
327 #define HFA384x_PDR_USB_PRODUCT		((u16)0x0411)
328 #define HFA384x_PDR_ANT_DIVERSITY	((u16)0x0412)
329 #define HFA384x_PDR_HFO_DELAY		((u16)0x0413)
330 #define HFA384x_PDR_SCALE_THRESH	((u16)0x0414)
331 
332 #define HFA384x_PDR_HFA3861_MANF_TESTSP	((u16)0x0900)
333 #define HFA384x_PDR_HFA3861_MANF_TESTI	((u16)0x0901)
334 #define HFA384x_PDR_END_OF_PDA		((u16)0x0000)
335 
336 /*--- Register Test/Get/Set Field macros ------------------------*/
337 
338 #define		HFA384x_CMD_AINFO_SET(value)	((u16)((u16)(value) << 8))
339 #define		HFA384x_CMD_MACPORT_SET(value)	\
340 			((u16)HFA384x_CMD_AINFO_SET(value))
341 #define		HFA384x_CMD_PROGMODE_SET(value)	\
342 			((u16)HFA384x_CMD_AINFO_SET((u16)value))
343 #define		HFA384x_CMD_CMDCODE_SET(value)		((u16)(value))
344 
345 #define		HFA384x_STATUS_RESULT_SET(value)	(((u16)(value)) << 8)
346 
347 /* Host Maintained State Info */
348 #define HFA384x_STATE_PREINIT	0
349 #define HFA384x_STATE_INIT	1
350 #define HFA384x_STATE_RUNNING	2
351 
352 /*-------------------------------------------------------------*/
353 /* Commonly used basic types */
354 struct hfa384x_bytestr {
355 	u16 len;
356 	u8 data[0];
357 } __packed;
358 
359 typedef struct hfa384x_bytestr32 {
360 	u16 len;
361 	u8 data[32];
362 } __packed hfa384x_bytestr32_t;
363 
364 /*--------------------------------------------------------------------
365 Configuration Record Structures:
366 	Network Parameters, Static Configuration Entities
367 --------------------------------------------------------------------*/
368 
369 /*-- Hardware/Firmware Component Information ----------*/
370 typedef struct hfa384x_compident {
371 	u16 id;
372 	u16 variant;
373 	u16 major;
374 	u16 minor;
375 } __packed hfa384x_compident_t;
376 
377 typedef struct hfa384x_caplevel {
378 	u16 role;
379 	u16 id;
380 	u16 variant;
381 	u16 bottom;
382 	u16 top;
383 } __packed hfa384x_caplevel_t;
384 
385 /*-- Configuration Record: cnfAuthentication --*/
386 #define HFA384x_CNFAUTHENTICATION_OPENSYSTEM	0x0001
387 #define HFA384x_CNFAUTHENTICATION_SHAREDKEY	0x0002
388 #define HFA384x_CNFAUTHENTICATION_LEAP		0x0004
389 
390 /*--------------------------------------------------------------------
391 Configuration Record Structures:
392 	Network Parameters, Dynamic Configuration Entities
393 --------------------------------------------------------------------*/
394 
395 #define HFA384x_CREATEIBSS_JOINCREATEIBSS          0
396 
397 /*-- Configuration Record: HostScanRequest (data portion only) --*/
398 typedef struct hfa384x_HostScanRequest_data {
399 	u16 channelList;
400 	u16 txRate;
401 	hfa384x_bytestr32_t ssid;
402 } __packed hfa384x_HostScanRequest_data_t;
403 
404 /*-- Configuration Record: JoinRequest (data portion only) --*/
405 typedef struct hfa384x_JoinRequest_data {
406 	u8 bssid[WLAN_BSSID_LEN];
407 	u16 channel;
408 } __packed hfa384x_JoinRequest_data_t;
409 
410 /*-- Configuration Record: authenticateStation (data portion only) --*/
411 typedef struct hfa384x_authenticateStation_data {
412 	u8 address[ETH_ALEN];
413 	u16 status;
414 	u16 algorithm;
415 } __packed hfa384x_authenticateStation_data_t;
416 
417 /*-- Configuration Record: WPAData       (data portion only) --*/
418 typedef struct hfa384x_WPAData {
419 	u16 datalen;
420 	u8 data[0];		/* max 80 */
421 } __packed hfa384x_WPAData_t;
422 
423 /*--------------------------------------------------------------------
424 Information Record Structures: NIC Information
425 --------------------------------------------------------------------*/
426 
427 /*-- Information Record: DownLoadBuffer --*/
428 /* NOTE: The page and offset are in AUX format */
429 typedef struct hfa384x_downloadbuffer {
430 	u16 page;
431 	u16 offset;
432 	u16 len;
433 } __packed hfa384x_downloadbuffer_t;
434 
435 /*--------------------------------------------------------------------
436 Information Record Structures: NIC Information
437 --------------------------------------------------------------------*/
438 
439 #define HFA384x_PSTATUS_CONN_IBSS	((u16)3)
440 
441 /*-- Information Record: commsquality --*/
442 typedef struct hfa384x_commsquality {
443 	u16 CQ_currBSS;
444 	u16 ASL_currBSS;
445 	u16 ANL_currFC;
446 } __packed hfa384x_commsquality_t;
447 
448 /*-- Information Record: dmbcommsquality --*/
449 typedef struct hfa384x_dbmcommsquality {
450 	u16 CQdbm_currBSS;
451 	u16 ASLdbm_currBSS;
452 	u16 ANLdbm_currFC;
453 } __packed hfa384x_dbmcommsquality_t;
454 
455 /*--------------------------------------------------------------------
456 FRAME STRUCTURES: Communication Frames
457 ----------------------------------------------------------------------
458 Communication Frames: Transmit Frames
459 --------------------------------------------------------------------*/
460 /*-- Communication Frame: Transmit Frame Structure --*/
461 typedef struct hfa384x_tx_frame {
462 	u16 status;
463 	u16 reserved1;
464 	u16 reserved2;
465 	u32 sw_support;
466 	u8 tx_retrycount;
467 	u8 tx_rate;
468 	u16 tx_control;
469 
470 	/*-- 802.11 Header Information --*/
471 
472 	u16 frame_control;
473 	u16 duration_id;
474 	u8 address1[6];
475 	u8 address2[6];
476 	u8 address3[6];
477 	u16 sequence_control;
478 	u8 address4[6];
479 	u16 data_len;		/* little endian format */
480 
481 	/*-- 802.3 Header Information --*/
482 
483 	u8 dest_addr[6];
484 	u8 src_addr[6];
485 	u16 data_length;	/* big endian format */
486 } __packed hfa384x_tx_frame_t;
487 /*--------------------------------------------------------------------
488 Communication Frames: Field Masks for Transmit Frames
489 --------------------------------------------------------------------*/
490 /*-- Status Field --*/
491 #define		HFA384x_TXSTATUS_ACKERR			((u16)BIT(5))
492 #define		HFA384x_TXSTATUS_FORMERR		((u16)BIT(3))
493 #define		HFA384x_TXSTATUS_DISCON			((u16)BIT(2))
494 #define		HFA384x_TXSTATUS_AGEDERR		((u16)BIT(1))
495 #define		HFA384x_TXSTATUS_RETRYERR		((u16)BIT(0))
496 /*-- Transmit Control Field --*/
497 #define		HFA384x_TX_MACPORT			((u16)(BIT(10) | \
498 							  BIT(9) | BIT(8)))
499 #define		HFA384x_TX_STRUCTYPE			((u16)(BIT(4) | BIT(3)))
500 #define		HFA384x_TX_TXEX				((u16)BIT(2))
501 #define		HFA384x_TX_TXOK				((u16)BIT(1))
502 /*--------------------------------------------------------------------
503 Communication Frames: Test/Get/Set Field Values for Transmit Frames
504 --------------------------------------------------------------------*/
505 /*-- Status Field --*/
506 #define HFA384x_TXSTATUS_ISERROR(v)	\
507 	(((u16)(v)) & \
508 	(HFA384x_TXSTATUS_ACKERR | HFA384x_TXSTATUS_FORMERR | \
509 	HFA384x_TXSTATUS_DISCON | HFA384x_TXSTATUS_AGEDERR | \
510 	HFA384x_TXSTATUS_RETRYERR))
511 
512 #define	HFA384x_TX_SET(v, m, s)		((((u16)(v)) << ((u16)(s))) & ((u16)(m)))
513 
514 #define	HFA384x_TX_MACPORT_SET(v)	HFA384x_TX_SET(v, HFA384x_TX_MACPORT, 8)
515 #define	HFA384x_TX_STRUCTYPE_SET(v)	HFA384x_TX_SET(v, \
516 						HFA384x_TX_STRUCTYPE, 3)
517 #define	HFA384x_TX_TXEX_SET(v)		HFA384x_TX_SET(v, HFA384x_TX_TXEX, 2)
518 #define	HFA384x_TX_TXOK_SET(v)		HFA384x_TX_SET(v, HFA384x_TX_TXOK, 1)
519 /*--------------------------------------------------------------------
520 Communication Frames: Receive Frames
521 --------------------------------------------------------------------*/
522 /*-- Communication Frame: Receive Frame Structure --*/
523 typedef struct hfa384x_rx_frame {
524 	/*-- MAC rx descriptor (hfa384x byte order) --*/
525 	u16 status;
526 	u32 time;
527 	u8 silence;
528 	u8 signal;
529 	u8 rate;
530 	u8 rx_flow;
531 	u16 reserved1;
532 	u16 reserved2;
533 
534 	/*-- 802.11 Header Information (802.11 byte order) --*/
535 	__le16 frame_control;
536 	u16 duration_id;
537 	u8 address1[6];
538 	u8 address2[6];
539 	u8 address3[6];
540 	u16 sequence_control;
541 	u8 address4[6];
542 	__le16 data_len;		/* hfa384x (little endian) format */
543 
544 	/*-- 802.3 Header Information --*/
545 	u8 dest_addr[6];
546 	u8 src_addr[6];
547 	u16 data_length;	/* IEEE? (big endian) format */
548 } __packed hfa384x_rx_frame_t;
549 /*--------------------------------------------------------------------
550 Communication Frames: Field Masks for Receive Frames
551 --------------------------------------------------------------------*/
552 
553 /*-- Status Fields --*/
554 #define		HFA384x_RXSTATUS_MACPORT		((u16)(BIT(10) | \
555 								BIT(9) | \
556 								BIT(8)))
557 #define		HFA384x_RXSTATUS_FCSERR			((u16)BIT(0))
558 /*--------------------------------------------------------------------
559 Communication Frames: Test/Get/Set Field Values for Receive Frames
560 --------------------------------------------------------------------*/
561 #define		HFA384x_RXSTATUS_MACPORT_GET(value)	((u16)((((u16)(value)) \
562 					    & HFA384x_RXSTATUS_MACPORT) >> 8))
563 #define		HFA384x_RXSTATUS_ISFCSERR(value)	((u16)(((u16)(value)) \
564 						  & HFA384x_RXSTATUS_FCSERR))
565 /*--------------------------------------------------------------------
566  FRAME STRUCTURES: Information Types and Information Frame Structures
567 ----------------------------------------------------------------------
568 Information Types
569 --------------------------------------------------------------------*/
570 #define		HFA384x_IT_HANDOVERADDR			((u16)0xF000UL)
571 #define		HFA384x_IT_COMMTALLIES			((u16)0xF100UL)
572 #define		HFA384x_IT_SCANRESULTS			((u16)0xF101UL)
573 #define		HFA384x_IT_CHINFORESULTS		((u16)0xF102UL)
574 #define		HFA384x_IT_HOSTSCANRESULTS		((u16)0xF103UL)
575 #define		HFA384x_IT_LINKSTATUS			((u16)0xF200UL)
576 #define		HFA384x_IT_ASSOCSTATUS			((u16)0xF201UL)
577 #define		HFA384x_IT_AUTHREQ			((u16)0xF202UL)
578 #define		HFA384x_IT_PSUSERCNT			((u16)0xF203UL)
579 #define		HFA384x_IT_KEYIDCHANGED			((u16)0xF204UL)
580 #define		HFA384x_IT_ASSOCREQ			((u16)0xF205UL)
581 #define		HFA384x_IT_MICFAILURE			((u16)0xF206UL)
582 
583 /*--------------------------------------------------------------------
584 Information Frames Structures
585 ----------------------------------------------------------------------
586 Information Frames: Notification Frame Structures
587 --------------------------------------------------------------------*/
588 
589 /*--  Inquiry Frame, Diagnose: Communication Tallies --*/
590 typedef struct hfa384x_CommTallies16 {
591 	u16 txunicastframes;
592 	u16 txmulticastframes;
593 	u16 txfragments;
594 	u16 txunicastoctets;
595 	u16 txmulticastoctets;
596 	u16 txdeferredtrans;
597 	u16 txsingleretryframes;
598 	u16 txmultipleretryframes;
599 	u16 txretrylimitexceeded;
600 	u16 txdiscards;
601 	u16 rxunicastframes;
602 	u16 rxmulticastframes;
603 	u16 rxfragments;
604 	u16 rxunicastoctets;
605 	u16 rxmulticastoctets;
606 	u16 rxfcserrors;
607 	u16 rxdiscardsnobuffer;
608 	u16 txdiscardswrongsa;
609 	u16 rxdiscardswepundecr;
610 	u16 rxmsginmsgfrag;
611 	u16 rxmsginbadmsgfrag;
612 } __packed hfa384x_CommTallies16_t;
613 
614 typedef struct hfa384x_CommTallies32 {
615 	u32 txunicastframes;
616 	u32 txmulticastframes;
617 	u32 txfragments;
618 	u32 txunicastoctets;
619 	u32 txmulticastoctets;
620 	u32 txdeferredtrans;
621 	u32 txsingleretryframes;
622 	u32 txmultipleretryframes;
623 	u32 txretrylimitexceeded;
624 	u32 txdiscards;
625 	u32 rxunicastframes;
626 	u32 rxmulticastframes;
627 	u32 rxfragments;
628 	u32 rxunicastoctets;
629 	u32 rxmulticastoctets;
630 	u32 rxfcserrors;
631 	u32 rxdiscardsnobuffer;
632 	u32 txdiscardswrongsa;
633 	u32 rxdiscardswepundecr;
634 	u32 rxmsginmsgfrag;
635 	u32 rxmsginbadmsgfrag;
636 } __packed hfa384x_CommTallies32_t;
637 
638 /*--  Inquiry Frame, Diagnose: Scan Results & Subfields--*/
639 typedef struct hfa384x_ScanResultSub {
640 	u16 chid;
641 	u16 anl;
642 	u16 sl;
643 	u8 bssid[WLAN_BSSID_LEN];
644 	u16 bcnint;
645 	u16 capinfo;
646 	hfa384x_bytestr32_t ssid;
647 	u8 supprates[10];	/* 802.11 info element */
648 	u16 proberesp_rate;
649 } __packed hfa384x_ScanResultSub_t;
650 
651 typedef struct hfa384x_ScanResult {
652 	u16 rsvd;
653 	u16 scanreason;
654 	hfa384x_ScanResultSub_t result[HFA384x_SCANRESULT_MAX];
655 } __packed hfa384x_ScanResult_t;
656 
657 /*--  Inquiry Frame, Diagnose: ChInfo Results & Subfields--*/
658 typedef struct hfa384x_ChInfoResultSub {
659 	u16 chid;
660 	u16 anl;
661 	u16 pnl;
662 	u16 active;
663 } __packed hfa384x_ChInfoResultSub_t;
664 
665 #define HFA384x_CHINFORESULT_BSSACTIVE	BIT(0)
666 #define HFA384x_CHINFORESULT_PCFACTIVE	BIT(1)
667 
668 typedef struct hfa384x_ChInfoResult {
669 	u16 scanchannels;
670 	hfa384x_ChInfoResultSub_t result[HFA384x_CHINFORESULT_MAX];
671 } __packed hfa384x_ChInfoResult_t;
672 
673 /*--  Inquiry Frame, Diagnose: Host Scan Results & Subfields--*/
674 typedef struct hfa384x_HScanResultSub {
675 	u16 chid;
676 	u16 anl;
677 	u16 sl;
678 	u8 bssid[WLAN_BSSID_LEN];
679 	u16 bcnint;
680 	u16 capinfo;
681 	hfa384x_bytestr32_t ssid;
682 	u8 supprates[10];	/* 802.11 info element */
683 	u16 proberesp_rate;
684 	u16 atim;
685 } __packed hfa384x_HScanResultSub_t;
686 
687 typedef struct hfa384x_HScanResult {
688 	u16 nresult;
689 	u16 rsvd;
690 	hfa384x_HScanResultSub_t result[HFA384x_HSCANRESULT_MAX];
691 } __packed hfa384x_HScanResult_t;
692 
693 /*--  Unsolicited Frame, MAC Mgmt: LinkStatus --*/
694 
695 #define HFA384x_LINK_NOTCONNECTED	((u16)0)
696 #define HFA384x_LINK_CONNECTED		((u16)1)
697 #define HFA384x_LINK_DISCONNECTED	((u16)2)
698 #define HFA384x_LINK_AP_CHANGE		((u16)3)
699 #define HFA384x_LINK_AP_OUTOFRANGE	((u16)4)
700 #define HFA384x_LINK_AP_INRANGE		((u16)5)
701 #define HFA384x_LINK_ASSOCFAIL		((u16)6)
702 
703 typedef struct hfa384x_LinkStatus {
704 	u16 linkstatus;
705 } __packed hfa384x_LinkStatus_t;
706 
707 /*--  Unsolicited Frame, MAC Mgmt: AssociationStatus (--*/
708 
709 #define HFA384x_ASSOCSTATUS_STAASSOC	((u16)1)
710 #define HFA384x_ASSOCSTATUS_REASSOC	((u16)2)
711 #define HFA384x_ASSOCSTATUS_AUTHFAIL	((u16)5)
712 
713 typedef struct hfa384x_AssocStatus {
714 	u16 assocstatus;
715 	u8 sta_addr[ETH_ALEN];
716 	/* old_ap_addr is only valid if assocstatus == 2 */
717 	u8 old_ap_addr[ETH_ALEN];
718 	u16 reason;
719 	u16 reserved;
720 } __packed hfa384x_AssocStatus_t;
721 
722 /*--  Unsolicited Frame, MAC Mgmt: AuthRequest (AP Only) --*/
723 
724 typedef struct hfa384x_AuthRequest {
725 	u8 sta_addr[ETH_ALEN];
726 	u16 algorithm;
727 } __packed hfa384x_AuthReq_t;
728 
729 /*--  Unsolicited Frame, MAC Mgmt: PSUserCount (AP Only) --*/
730 
731 typedef struct hfa384x_PSUserCount {
732 	u16 usercnt;
733 } __packed hfa384x_PSUserCount_t;
734 
735 typedef struct hfa384x_KeyIDChanged {
736 	u8 sta_addr[ETH_ALEN];
737 	u16 keyid;
738 } __packed hfa384x_KeyIDChanged_t;
739 
740 /*--  Collection of all Inf frames ---------------*/
741 typedef union hfa384x_infodata {
742 	hfa384x_CommTallies16_t commtallies16;
743 	hfa384x_CommTallies32_t commtallies32;
744 	hfa384x_ScanResult_t scanresult;
745 	hfa384x_ChInfoResult_t chinforesult;
746 	hfa384x_HScanResult_t hscanresult;
747 	hfa384x_LinkStatus_t linkstatus;
748 	hfa384x_AssocStatus_t assocstatus;
749 	hfa384x_AuthReq_t authreq;
750 	hfa384x_PSUserCount_t psusercnt;
751 	hfa384x_KeyIDChanged_t keyidchanged;
752 } __packed hfa384x_infodata_t;
753 
754 typedef struct hfa384x_InfFrame {
755 	u16 framelen;
756 	u16 infotype;
757 	hfa384x_infodata_t info;
758 } __packed hfa384x_InfFrame_t;
759 
760 /*--------------------------------------------------------------------
761 USB Packet structures and constants.
762 --------------------------------------------------------------------*/
763 
764 /* Should be sent to the bulkout endpoint */
765 #define HFA384x_USB_TXFRM	0
766 #define HFA384x_USB_CMDREQ	1
767 #define HFA384x_USB_WRIDREQ	2
768 #define HFA384x_USB_RRIDREQ	3
769 #define HFA384x_USB_WMEMREQ	4
770 #define HFA384x_USB_RMEMREQ	5
771 
772 /* Received from the bulkin endpoint */
773 #define HFA384x_USB_ISTXFRM(a)	(((a) & 0x9000) == 0x1000)
774 #define HFA384x_USB_ISRXFRM(a)	(!((a) & 0x9000))
775 #define HFA384x_USB_INFOFRM	0x8000
776 #define HFA384x_USB_CMDRESP	0x8001
777 #define HFA384x_USB_WRIDRESP	0x8002
778 #define HFA384x_USB_RRIDRESP	0x8003
779 #define HFA384x_USB_WMEMRESP	0x8004
780 #define HFA384x_USB_RMEMRESP	0x8005
781 #define HFA384x_USB_BUFAVAIL	0x8006
782 #define HFA384x_USB_ERROR	0x8007
783 
784 /*------------------------------------*/
785 /* Request (bulk OUT) packet contents */
786 
787 typedef struct hfa384x_usb_txfrm {
788 	hfa384x_tx_frame_t desc;
789 	u8 data[WLAN_DATA_MAXLEN];
790 } __packed hfa384x_usb_txfrm_t;
791 
792 typedef struct hfa384x_usb_cmdreq {
793 	u16 type;
794 	u16 cmd;
795 	u16 parm0;
796 	u16 parm1;
797 	u16 parm2;
798 	u8 pad[54];
799 } __packed hfa384x_usb_cmdreq_t;
800 
801 typedef struct hfa384x_usb_wridreq {
802 	u16 type;
803 	u16 frmlen;
804 	u16 rid;
805 	u8 data[HFA384x_RIDDATA_MAXLEN];
806 } __packed hfa384x_usb_wridreq_t;
807 
808 typedef struct hfa384x_usb_rridreq {
809 	u16 type;
810 	u16 frmlen;
811 	u16 rid;
812 	u8 pad[58];
813 } __packed hfa384x_usb_rridreq_t;
814 
815 typedef struct hfa384x_usb_wmemreq {
816 	u16 type;
817 	u16 frmlen;
818 	u16 offset;
819 	u16 page;
820 	u8 data[HFA384x_USB_RWMEM_MAXLEN];
821 } __packed hfa384x_usb_wmemreq_t;
822 
823 typedef struct hfa384x_usb_rmemreq {
824 	u16 type;
825 	u16 frmlen;
826 	u16 offset;
827 	u16 page;
828 	u8 pad[56];
829 } __packed hfa384x_usb_rmemreq_t;
830 
831 /*------------------------------------*/
832 /* Response (bulk IN) packet contents */
833 
834 typedef struct hfa384x_usb_rxfrm {
835 	hfa384x_rx_frame_t desc;
836 	u8 data[WLAN_DATA_MAXLEN];
837 } __packed hfa384x_usb_rxfrm_t;
838 
839 typedef struct hfa384x_usb_infofrm {
840 	u16 type;
841 	hfa384x_InfFrame_t info;
842 } __packed hfa384x_usb_infofrm_t;
843 
844 typedef struct hfa384x_usb_statusresp {
845 	u16 type;
846 	u16 status;
847 	u16 resp0;
848 	u16 resp1;
849 	u16 resp2;
850 } __packed hfa384x_usb_cmdresp_t;
851 
852 typedef hfa384x_usb_cmdresp_t hfa384x_usb_wridresp_t;
853 
854 typedef struct hfa384x_usb_rridresp {
855 	u16 type;
856 	u16 frmlen;
857 	u16 rid;
858 	u8 data[HFA384x_RIDDATA_MAXLEN];
859 } __packed hfa384x_usb_rridresp_t;
860 
861 typedef hfa384x_usb_cmdresp_t hfa384x_usb_wmemresp_t;
862 
863 typedef struct hfa384x_usb_rmemresp {
864 	u16 type;
865 	u16 frmlen;
866 	u8 data[HFA384x_USB_RWMEM_MAXLEN];
867 } __packed hfa384x_usb_rmemresp_t;
868 
869 typedef struct hfa384x_usb_bufavail {
870 	u16 type;
871 	u16 frmlen;
872 } __packed hfa384x_usb_bufavail_t;
873 
874 typedef struct hfa384x_usb_error {
875 	u16 type;
876 	u16 errortype;
877 } __packed hfa384x_usb_error_t;
878 
879 /*----------------------------------------------------------*/
880 /* Unions for packaging all the known packet types together */
881 
882 typedef union hfa384x_usbout {
883 	__le16 type;
884 	hfa384x_usb_txfrm_t txfrm;
885 	hfa384x_usb_cmdreq_t cmdreq;
886 	hfa384x_usb_wridreq_t wridreq;
887 	hfa384x_usb_rridreq_t rridreq;
888 	hfa384x_usb_wmemreq_t wmemreq;
889 	hfa384x_usb_rmemreq_t rmemreq;
890 } __packed hfa384x_usbout_t;
891 
892 typedef union hfa384x_usbin {
893 	__le16 type;
894 	hfa384x_usb_rxfrm_t rxfrm;
895 	hfa384x_usb_txfrm_t txfrm;
896 	hfa384x_usb_infofrm_t infofrm;
897 	hfa384x_usb_cmdresp_t cmdresp;
898 	hfa384x_usb_wridresp_t wridresp;
899 	hfa384x_usb_rridresp_t rridresp;
900 	hfa384x_usb_wmemresp_t wmemresp;
901 	hfa384x_usb_rmemresp_t rmemresp;
902 	hfa384x_usb_bufavail_t bufavail;
903 	hfa384x_usb_error_t usberror;
904 	u8 boguspad[3000];
905 } __packed hfa384x_usbin_t;
906 
907 /*--------------------------------------------------------------------
908 PD record structures.
909 --------------------------------------------------------------------*/
910 
911 typedef struct hfa384x_pdr_pcb_partnum {
912 	u8 num[8];
913 } __packed hfa384x_pdr_pcb_partnum_t;
914 
915 typedef struct hfa384x_pdr_pcb_tracenum {
916 	u8 num[8];
917 } __packed hfa384x_pdr_pcb_tracenum_t;
918 
919 typedef struct hfa384x_pdr_nic_serial {
920 	u8 num[12];
921 } __packed hfa384x_pdr_nic_serial_t;
922 
923 typedef struct hfa384x_pdr_mkk_measurements {
924 	double carrier_freq;
925 	double occupied_band;
926 	double power_density;
927 	double tx_spur_f1;
928 	double tx_spur_f2;
929 	double tx_spur_f3;
930 	double tx_spur_f4;
931 	double tx_spur_l1;
932 	double tx_spur_l2;
933 	double tx_spur_l3;
934 	double tx_spur_l4;
935 	double rx_spur_f1;
936 	double rx_spur_f2;
937 	double rx_spur_l1;
938 	double rx_spur_l2;
939 } __packed hfa384x_pdr_mkk_measurements_t;
940 
941 typedef struct hfa384x_pdr_nic_ramsize {
942 	u8 size[12];		/* units of KB */
943 } __packed hfa384x_pdr_nic_ramsize_t;
944 
945 typedef struct hfa384x_pdr_mfisuprange {
946 	u16 id;
947 	u16 variant;
948 	u16 bottom;
949 	u16 top;
950 } __packed hfa384x_pdr_mfisuprange_t;
951 
952 typedef struct hfa384x_pdr_cfisuprange {
953 	u16 id;
954 	u16 variant;
955 	u16 bottom;
956 	u16 top;
957 } __packed hfa384x_pdr_cfisuprange_t;
958 
959 typedef struct hfa384x_pdr_nicid {
960 	u16 id;
961 	u16 variant;
962 	u16 major;
963 	u16 minor;
964 } __packed hfa384x_pdr_nicid_t;
965 
966 typedef struct hfa384x_pdr_refdac_measurements {
967 	u16 value[0];
968 } __packed hfa384x_pdr_refdac_measurements_t;
969 
970 typedef struct hfa384x_pdr_vgdac_measurements {
971 	u16 value[0];
972 } __packed hfa384x_pdr_vgdac_measurements_t;
973 
974 typedef struct hfa384x_pdr_level_comp_measurements {
975 	u16 value[0];
976 } __packed hfa384x_pdr_level_compc_measurements_t;
977 
978 typedef struct hfa384x_pdr_mac_address {
979 	u8 addr[6];
980 } __packed hfa384x_pdr_mac_address_t;
981 
982 typedef struct hfa384x_pdr_mkk_callname {
983 	u8 callname[8];
984 } __packed hfa384x_pdr_mkk_callname_t;
985 
986 typedef struct hfa384x_pdr_regdomain {
987 	u16 numdomains;
988 	u16 domain[5];
989 } __packed hfa384x_pdr_regdomain_t;
990 
991 typedef struct hfa384x_pdr_allowed_channel {
992 	u16 ch_bitmap;
993 } __packed hfa384x_pdr_allowed_channel_t;
994 
995 typedef struct hfa384x_pdr_default_channel {
996 	u16 channel;
997 } __packed hfa384x_pdr_default_channel_t;
998 
999 typedef struct hfa384x_pdr_privacy_option {
1000 	u16 available;
1001 } __packed hfa384x_pdr_privacy_option_t;
1002 
1003 typedef struct hfa384x_pdr_temptype {
1004 	u16 type;
1005 } __packed hfa384x_pdr_temptype_t;
1006 
1007 typedef struct hfa384x_pdr_refdac_setup {
1008 	u16 ch_value[14];
1009 } __packed hfa384x_pdr_refdac_setup_t;
1010 
1011 typedef struct hfa384x_pdr_vgdac_setup {
1012 	u16 ch_value[14];
1013 } __packed hfa384x_pdr_vgdac_setup_t;
1014 
1015 typedef struct hfa384x_pdr_level_comp_setup {
1016 	u16 ch_value[14];
1017 } __packed hfa384x_pdr_level_comp_setup_t;
1018 
1019 typedef struct hfa384x_pdr_trimdac_setup {
1020 	u16 trimidac;
1021 	u16 trimqdac;
1022 } __packed hfa384x_pdr_trimdac_setup_t;
1023 
1024 typedef struct hfa384x_pdr_ifr_setting {
1025 	u16 value[3];
1026 } __packed hfa384x_pdr_ifr_setting_t;
1027 
1028 typedef struct hfa384x_pdr_rfr_setting {
1029 	u16 value[3];
1030 } __packed hfa384x_pdr_rfr_setting_t;
1031 
1032 typedef struct hfa384x_pdr_hfa3861_baseline {
1033 	u16 value[50];
1034 } __packed hfa384x_pdr_hfa3861_baseline_t;
1035 
1036 typedef struct hfa384x_pdr_hfa3861_shadow {
1037 	u32 value[32];
1038 } __packed hfa384x_pdr_hfa3861_shadow_t;
1039 
1040 typedef struct hfa384x_pdr_hfa3861_ifrf {
1041 	u32 value[20];
1042 } __packed hfa384x_pdr_hfa3861_ifrf_t;
1043 
1044 typedef struct hfa384x_pdr_hfa3861_chcalsp {
1045 	u16 value[14];
1046 } __packed hfa384x_pdr_hfa3861_chcalsp_t;
1047 
1048 typedef struct hfa384x_pdr_hfa3861_chcali {
1049 	u16 value[17];
1050 } __packed hfa384x_pdr_hfa3861_chcali_t;
1051 
1052 typedef struct hfa384x_pdr_hfa3861_nic_config {
1053 	u16 config_bitmap;
1054 } __packed hfa384x_pdr_nic_config_t;
1055 
1056 typedef struct hfa384x_pdr_hfo_delay {
1057 	u8 hfo_delay;
1058 } __packed hfa384x_hfo_delay_t;
1059 
1060 typedef struct hfa384x_pdr_hfa3861_manf_testsp {
1061 	u16 value[30];
1062 } __packed hfa384x_pdr_hfa3861_manf_testsp_t;
1063 
1064 typedef struct hfa384x_pdr_hfa3861_manf_testi {
1065 	u16 value[30];
1066 } __packed hfa384x_pdr_hfa3861_manf_testi_t;
1067 
1068 typedef struct hfa384x_end_of_pda {
1069 	u16 crc;
1070 } __packed hfa384x_pdr_end_of_pda_t;
1071 
1072 typedef struct hfa384x_pdrec {
1073 	u16 len;		/* in words */
1074 	u16 code;
1075 	union pdr {
1076 		hfa384x_pdr_pcb_partnum_t pcb_partnum;
1077 		hfa384x_pdr_pcb_tracenum_t pcb_tracenum;
1078 		hfa384x_pdr_nic_serial_t nic_serial;
1079 		hfa384x_pdr_mkk_measurements_t mkk_measurements;
1080 		hfa384x_pdr_nic_ramsize_t nic_ramsize;
1081 		hfa384x_pdr_mfisuprange_t mfisuprange;
1082 		hfa384x_pdr_cfisuprange_t cfisuprange;
1083 		hfa384x_pdr_nicid_t nicid;
1084 		hfa384x_pdr_refdac_measurements_t refdac_measurements;
1085 		hfa384x_pdr_vgdac_measurements_t vgdac_measurements;
1086 		hfa384x_pdr_level_compc_measurements_t level_compc_measurements;
1087 		hfa384x_pdr_mac_address_t mac_address;
1088 		hfa384x_pdr_mkk_callname_t mkk_callname;
1089 		hfa384x_pdr_regdomain_t regdomain;
1090 		hfa384x_pdr_allowed_channel_t allowed_channel;
1091 		hfa384x_pdr_default_channel_t default_channel;
1092 		hfa384x_pdr_privacy_option_t privacy_option;
1093 		hfa384x_pdr_temptype_t temptype;
1094 		hfa384x_pdr_refdac_setup_t refdac_setup;
1095 		hfa384x_pdr_vgdac_setup_t vgdac_setup;
1096 		hfa384x_pdr_level_comp_setup_t level_comp_setup;
1097 		hfa384x_pdr_trimdac_setup_t trimdac_setup;
1098 		hfa384x_pdr_ifr_setting_t ifr_setting;
1099 		hfa384x_pdr_rfr_setting_t rfr_setting;
1100 		hfa384x_pdr_hfa3861_baseline_t hfa3861_baseline;
1101 		hfa384x_pdr_hfa3861_shadow_t hfa3861_shadow;
1102 		hfa384x_pdr_hfa3861_ifrf_t hfa3861_ifrf;
1103 		hfa384x_pdr_hfa3861_chcalsp_t hfa3861_chcalsp;
1104 		hfa384x_pdr_hfa3861_chcali_t hfa3861_chcali;
1105 		hfa384x_pdr_nic_config_t nic_config;
1106 		hfa384x_hfo_delay_t hfo_delay;
1107 		hfa384x_pdr_hfa3861_manf_testsp_t hfa3861_manf_testsp;
1108 		hfa384x_pdr_hfa3861_manf_testi_t hfa3861_manf_testi;
1109 		hfa384x_pdr_end_of_pda_t end_of_pda;
1110 
1111 	} data;
1112 } __packed hfa384x_pdrec_t;
1113 
1114 #ifdef __KERNEL__
1115 /*--------------------------------------------------------------------
1116 ---  MAC state structure, argument to all functions --
1117 ---  Also, a collection of support types --
1118 --------------------------------------------------------------------*/
1119 typedef struct hfa384x_statusresult {
1120 	u16 status;
1121 	u16 resp0;
1122 	u16 resp1;
1123 	u16 resp2;
1124 } hfa384x_cmdresult_t;
1125 
1126 /* USB Control Exchange (CTLX):
1127  *  A queue of the structure below is maintained for all of the
1128  *  Request/Response type USB packets supported by Prism2.
1129  */
1130 /* The following hfa384x_* structures are arguments to
1131  * the usercb() for the different CTLX types.
1132  */
1133 typedef struct hfa384x_rridresult {
1134 	u16 rid;
1135 	const void *riddata;
1136 	unsigned int riddata_len;
1137 } hfa384x_rridresult_t;
1138 
1139 enum ctlx_state {
1140 	CTLX_START = 0,		/* Start state, not queued */
1141 
1142 	CTLX_COMPLETE,		/* CTLX successfully completed */
1143 	CTLX_REQ_FAILED,	/* OUT URB completed w/ error */
1144 
1145 	CTLX_PENDING,		/* Queued, data valid */
1146 	CTLX_REQ_SUBMITTED,	/* OUT URB submitted */
1147 	CTLX_REQ_COMPLETE,	/* OUT URB complete */
1148 	CTLX_RESP_COMPLETE	/* IN URB received */
1149 };
1150 typedef enum ctlx_state CTLX_STATE;
1151 
1152 struct hfa384x_usbctlx;
1153 struct hfa384x;
1154 
1155 typedef void (*ctlx_cmdcb_t) (struct hfa384x *, const struct hfa384x_usbctlx *);
1156 
1157 typedef void (*ctlx_usercb_t) (struct hfa384x *hw,
1158 			       void *ctlxresult, void *usercb_data);
1159 
1160 typedef struct hfa384x_usbctlx {
1161 	struct list_head list;
1162 
1163 	size_t outbufsize;
1164 	hfa384x_usbout_t outbuf;	/* pkt buf for OUT */
1165 	hfa384x_usbin_t inbuf;	/* pkt buf for IN(a copy) */
1166 
1167 	CTLX_STATE state;	/* Tracks running state */
1168 
1169 	struct completion done;
1170 	volatile int reapable;	/* Food for the reaper task */
1171 
1172 	ctlx_cmdcb_t cmdcb;	/* Async command callback */
1173 	ctlx_usercb_t usercb;	/* Async user callback, */
1174 	void *usercb_data;	/*  at CTLX completion  */
1175 
1176 	int variant;		/* Identifies cmd variant */
1177 } hfa384x_usbctlx_t;
1178 
1179 typedef struct hfa384x_usbctlxq {
1180 	spinlock_t lock;
1181 	struct list_head pending;
1182 	struct list_head active;
1183 	struct list_head completing;
1184 	struct list_head reapable;
1185 } hfa384x_usbctlxq_t;
1186 
1187 typedef struct hfa484x_metacmd {
1188 	u16 cmd;
1189 
1190 	u16 parm0;
1191 	u16 parm1;
1192 	u16 parm2;
1193 
1194 	hfa384x_cmdresult_t result;
1195 } hfa384x_metacmd_t;
1196 
1197 #define	MAX_GRP_ADDR		32
1198 #define WLAN_COMMENT_MAX	80  /* Max. length of user comment string. */
1199 
1200 #define WLAN_AUTH_MAX           60  /* Max. # of authenticated stations. */
1201 #define WLAN_ACCESS_MAX		60  /* Max. # of stations in an access list. */
1202 #define WLAN_ACCESS_NONE	0   /* No stations may be authenticated. */
1203 #define WLAN_ACCESS_ALL		1   /* All stations may be authenticated. */
1204 #define WLAN_ACCESS_ALLOW	2   /* Authenticate only "allowed" stations. */
1205 #define WLAN_ACCESS_DENY	3   /* Do not authenticate "denied" stations. */
1206 
1207 /* XXX These are going away ASAP */
1208 struct prism2sta_authlist {
1209 	unsigned int cnt;
1210 	u8 addr[WLAN_AUTH_MAX][ETH_ALEN];
1211 	u8 assoc[WLAN_AUTH_MAX];
1212 };
1213 
1214 struct prism2sta_accesslist {
1215 	unsigned int modify;
1216 	unsigned int cnt;
1217 	u8 addr[WLAN_ACCESS_MAX][ETH_ALEN];
1218 	unsigned int cnt1;
1219 	u8 addr1[WLAN_ACCESS_MAX][ETH_ALEN];
1220 };
1221 
1222 typedef struct hfa384x {
1223 	/* USB support data */
1224 	struct usb_device *usb;
1225 	struct urb rx_urb;
1226 	struct sk_buff *rx_urb_skb;
1227 	struct urb tx_urb;
1228 	struct urb ctlx_urb;
1229 	hfa384x_usbout_t txbuff;
1230 	hfa384x_usbctlxq_t ctlxq;
1231 	struct timer_list reqtimer;
1232 	struct timer_list resptimer;
1233 
1234 	struct timer_list throttle;
1235 
1236 	struct tasklet_struct reaper_bh;
1237 	struct tasklet_struct completion_bh;
1238 
1239 	struct work_struct usb_work;
1240 
1241 	unsigned long usb_flags;
1242 #define THROTTLE_RX	0
1243 #define THROTTLE_TX	1
1244 #define WORK_RX_HALT	2
1245 #define WORK_TX_HALT	3
1246 #define WORK_RX_RESUME	4
1247 #define WORK_TX_RESUME	5
1248 
1249 	unsigned short req_timer_done:1;
1250 	unsigned short resp_timer_done:1;
1251 
1252 	int endp_in;
1253 	int endp_out;
1254 
1255 	int sniff_fcs;
1256 	int sniff_channel;
1257 	int sniff_truncate;
1258 	int sniffhdr;
1259 
1260 	wait_queue_head_t cmdq;	/* wait queue itself */
1261 
1262 	/* Controller state */
1263 	u32 state;
1264 	u32 isap;
1265 	u8 port_enabled[HFA384x_NUMPORTS_MAX];
1266 
1267 	/* Download support */
1268 	unsigned int dlstate;
1269 	hfa384x_downloadbuffer_t bufinfo;
1270 	u16 dltimeout;
1271 
1272 	int scanflag;		/* to signal scan complete */
1273 	int join_ap;		/* are we joined to a specific ap */
1274 	int join_retries;	/* number of join retries till we fail */
1275 	hfa384x_JoinRequest_data_t joinreq;	/* join request saved data */
1276 
1277 	struct wlandevice *wlandev;
1278 	/* Timer to allow for the deferred processing of linkstatus messages */
1279 	struct work_struct link_bh;
1280 
1281 	struct work_struct commsqual_bh;
1282 	hfa384x_commsquality_t qual;
1283 	struct timer_list commsqual_timer;
1284 
1285 	u16 link_status;
1286 	u16 link_status_new;
1287 	struct sk_buff_head authq;
1288 
1289 	u32 txrate;
1290 
1291 	/* And here we have stuff that used to be in priv */
1292 
1293 	/* State variables */
1294 	unsigned int presniff_port_type;
1295 	u16 presniff_wepflags;
1296 	u32 dot11_desired_bss_type;
1297 
1298 	int dbmadjust;
1299 
1300 	/* Group Addresses - right now, there are up to a total
1301 	 * of MAX_GRP_ADDR group addresses
1302 	 */
1303 	u8 dot11_grp_addr[MAX_GRP_ADDR][ETH_ALEN];
1304 	unsigned int dot11_grpcnt;
1305 
1306 	/* Component Identities */
1307 	hfa384x_compident_t ident_nic;
1308 	hfa384x_compident_t ident_pri_fw;
1309 	hfa384x_compident_t ident_sta_fw;
1310 	hfa384x_compident_t ident_ap_fw;
1311 	u16 mm_mods;
1312 
1313 	/* Supplier compatibility ranges */
1314 	hfa384x_caplevel_t cap_sup_mfi;
1315 	hfa384x_caplevel_t cap_sup_cfi;
1316 	hfa384x_caplevel_t cap_sup_pri;
1317 	hfa384x_caplevel_t cap_sup_sta;
1318 	hfa384x_caplevel_t cap_sup_ap;
1319 
1320 	/* Actor compatibility ranges */
1321 	hfa384x_caplevel_t cap_act_pri_cfi;	/*
1322 						 * pri f/w to controller
1323 						 * interface
1324 						 */
1325 
1326 	hfa384x_caplevel_t cap_act_sta_cfi;	/*
1327 						 * sta f/w to controller
1328 						 * interface
1329 						 */
1330 
1331 	hfa384x_caplevel_t cap_act_sta_mfi;	/* sta f/w to modem interface */
1332 
1333 	hfa384x_caplevel_t cap_act_ap_cfi;	/*
1334 						 * ap f/w to controller
1335 						 * interface
1336 						 */
1337 
1338 	hfa384x_caplevel_t cap_act_ap_mfi;	/* ap f/w to modem interface */
1339 
1340 	u32 psusercount;	/* Power save user count. */
1341 	hfa384x_CommTallies32_t tallies;	/* Communication tallies. */
1342 	u8 comment[WLAN_COMMENT_MAX + 1];	/* User comment */
1343 
1344 	/* Channel Info request results (AP only) */
1345 	struct {
1346 		atomic_t done;
1347 		u8 count;
1348 		hfa384x_ChInfoResult_t results;
1349 	} channel_info;
1350 
1351 	hfa384x_InfFrame_t *scanresults;
1352 
1353 	struct prism2sta_authlist authlist;	/* Authenticated station list. */
1354 	unsigned int accessmode;		/* Access mode. */
1355 	struct prism2sta_accesslist allow;	/* Allowed station list. */
1356 	struct prism2sta_accesslist deny;	/* Denied station list. */
1357 
1358 } hfa384x_t;
1359 
1360 void hfa384x_create(hfa384x_t *hw, struct usb_device *usb);
1361 void hfa384x_destroy(hfa384x_t *hw);
1362 
1363 int
1364 hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis);
1365 int hfa384x_drvr_disable(hfa384x_t *hw, u16 macport);
1366 int hfa384x_drvr_enable(hfa384x_t *hw, u16 macport);
1367 int hfa384x_drvr_flashdl_enable(hfa384x_t *hw);
1368 int hfa384x_drvr_flashdl_disable(hfa384x_t *hw);
1369 int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len);
1370 int hfa384x_drvr_getconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len);
1371 int hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr);
1372 int hfa384x_drvr_ramdl_disable(hfa384x_t *hw);
1373 int hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len);
1374 int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len);
1375 int hfa384x_drvr_setconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len);
1376 
1377 static inline int hfa384x_drvr_getconfig16(hfa384x_t *hw, u16 rid, void *val)
1378 {
1379 	int result = 0;
1380 
1381 	result = hfa384x_drvr_getconfig(hw, rid, val, sizeof(u16));
1382 	if (result == 0)
1383 		*((u16 *) val) = le16_to_cpu(*((u16 *) val));
1384 	return result;
1385 }
1386 
1387 static inline int hfa384x_drvr_setconfig16(hfa384x_t *hw, u16 rid, u16 val)
1388 {
1389 	u16 value = cpu_to_le16(val);
1390 
1391 	return hfa384x_drvr_setconfig(hw, rid, &value, sizeof(value));
1392 }
1393 
1394 int
1395 hfa384x_drvr_setconfig_async(hfa384x_t *hw,
1396 			     u16 rid,
1397 			     void *buf,
1398 			     u16 len, ctlx_usercb_t usercb, void *usercb_data);
1399 
1400 static inline int
1401 hfa384x_drvr_setconfig16_async(hfa384x_t *hw, u16 rid, u16 val)
1402 {
1403 	u16 value = cpu_to_le16(val);
1404 
1405 	return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value),
1406 					    NULL, NULL);
1407 }
1408 
1409 int hfa384x_drvr_start(hfa384x_t *hw);
1410 int hfa384x_drvr_stop(hfa384x_t *hw);
1411 int
1412 hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb,
1413 		     union p80211_hdr *p80211_hdr,
1414 		     struct p80211_metawep *p80211_wep);
1415 void hfa384x_tx_timeout(struct wlandevice *wlandev);
1416 
1417 int hfa384x_cmd_initialize(hfa384x_t *hw);
1418 int hfa384x_cmd_enable(hfa384x_t *hw, u16 macport);
1419 int hfa384x_cmd_disable(hfa384x_t *hw, u16 macport);
1420 int hfa384x_cmd_allocate(hfa384x_t *hw, u16 len);
1421 int hfa384x_cmd_monitor(hfa384x_t *hw, u16 enable);
1422 int
1423 hfa384x_cmd_download(hfa384x_t *hw,
1424 		     u16 mode, u16 lowaddr, u16 highaddr, u16 codelen);
1425 
1426 #endif /*__KERNEL__ */
1427 
1428 #endif /*_HFA384x_H */
1429