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