Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
0002 /*
0003  *
0004  * Defines the constants and data structures for the hfa384x
0005  *
0006  * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
0007  * --------------------------------------------------------------------
0008  *
0009  * linux-wlan
0010  *
0011  *   The contents of this file are subject to the Mozilla Public
0012  *   License Version 1.1 (the "License"); you may not use this file
0013  *   except in compliance with the License. You may obtain a copy of
0014  *   the License at http://www.mozilla.org/MPL/
0015  *
0016  *   Software distributed under the License is distributed on an "AS
0017  *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
0018  *    implied. See the License for the specific language governing
0019  *   rights and limitations under the License.
0020  *
0021  *   Alternatively, the contents of this file may be used under the
0022  *   terms of the GNU Public License version 2 (the "GPL"), in which
0023  *   case the provisions of the GPL are applicable instead of the
0024  *   above.  If you wish to allow the use of your version of this file
0025  *   only under the terms of the GPL and not to allow others to use
0026  *   your version of this file under the MPL, indicate your decision
0027  *   by deleting the provisions above and replace them with the notice
0028  *   and other provisions required by the GPL.  If you do not delete
0029  *   the provisions above, a recipient may use your version of this
0030  *   file under either the MPL or the GPL.
0031  *
0032  * --------------------------------------------------------------------
0033  *
0034  * Inquiries regarding the linux-wlan Open Source project can be
0035  * made directly to:
0036  *
0037  * AbsoluteValue Systems Inc.
0038  * info@linux-wlan.com
0039  * http://www.linux-wlan.com
0040  *
0041  * --------------------------------------------------------------------
0042  *
0043  * Portions of the development of this software were funded by
0044  * Intersil Corporation as part of PRISM(R) chipset product development.
0045  *
0046  * --------------------------------------------------------------------
0047  *
0048  *   [Implementation and usage notes]
0049  *
0050  *   [References]
0051  *  CW10 Programmer's Manual v1.5
0052  *  IEEE 802.11 D10.0
0053  *
0054  * --------------------------------------------------------------------
0055  */
0056 
0057 #ifndef _HFA384x_H
0058 #define _HFA384x_H
0059 
0060 #define HFA384x_FIRMWARE_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
0061 
0062 #include <linux/if_ether.h>
0063 #include <linux/usb.h>
0064 
0065 /*--- Mins & Maxs -----------------------------------*/
0066 #define HFA384x_PORTID_MAX      ((u16)7)
0067 #define HFA384x_NUMPORTS_MAX        ((u16)(HFA384x_PORTID_MAX + 1))
0068 #define HFA384x_PDR_LEN_MAX     ((u16)512) /* in bytes, from EK */
0069 #define HFA384x_PDA_RECS_MAX        ((u16)200) /* a guess */
0070 #define HFA384x_PDA_LEN_MAX     ((u16)1024) /* in bytes, from EK*/
0071 #define HFA384x_SCANRESULT_MAX      ((u16)31)
0072 #define HFA384x_HSCANRESULT_MAX     ((u16)31)
0073 #define HFA384x_CHINFORESULT_MAX    ((u16)16)
0074 #define HFA384x_RID_GUESSING_MAXLEN 2048    /* I'm not really sure */
0075 #define HFA384x_RIDDATA_MAXLEN      HFA384x_RID_GUESSING_MAXLEN
0076 #define HFA384x_USB_RWMEM_MAXLEN    2048
0077 
0078 /*--- Support Constants -----------------------------*/
0079 #define     HFA384x_PORTTYPE_IBSS           ((u16)0)
0080 #define     HFA384x_PORTTYPE_BSS            ((u16)1)
0081 #define     HFA384x_PORTTYPE_PSUEDOIBSS     ((u16)3)
0082 #define     HFA384x_WEPFLAGS_PRIVINVOKED        ((u16)BIT(0))
0083 #define     HFA384x_WEPFLAGS_EXCLUDE        ((u16)BIT(1))
0084 #define     HFA384x_WEPFLAGS_DISABLE_TXCRYPT    ((u16)BIT(4))
0085 #define     HFA384x_WEPFLAGS_DISABLE_RXCRYPT    ((u16)BIT(7))
0086 #define     HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM  ((u16)3)
0087 #define     HFA384x_PORTSTATUS_DISABLED     ((u16)1)
0088 #define     HFA384x_RATEBIT_1           ((u16)1)
0089 #define     HFA384x_RATEBIT_2           ((u16)2)
0090 #define     HFA384x_RATEBIT_5dot5           ((u16)4)
0091 #define     HFA384x_RATEBIT_11          ((u16)8)
0092 
0093 /*--- MAC Internal memory constants and macros ------*/
0094 /* masks and macros used to manipulate MAC internal memory addresses. */
0095 /* MAC internal memory addresses are 23 bit quantities.  The MAC uses
0096  * a paged address space where the upper 16 bits are the page number
0097  * and the lower 7 bits are the offset.  There are various Host API
0098  * elements that require two 16-bit quantities to specify a MAC
0099  * internal memory address.  Unfortunately, some of the API's use a
0100  * page/offset format where the offset value is JUST the lower seven
0101  * bits and the page is  the remaining 16 bits.  Some of the API's
0102  * assume that the 23 bit address has been split at the 16th bit.  We
0103  * refer to these two formats as AUX format and CMD format.  The
0104  * macros below help handle some of this.
0105  */
0106 
0107 /* Mask bits for discarding unwanted pieces in a flat address */
0108 #define     HFA384x_ADDR_FLAT_AUX_PAGE_MASK (0x007fff80)
0109 #define     HFA384x_ADDR_FLAT_AUX_OFF_MASK  (0x0000007f)
0110 #define     HFA384x_ADDR_FLAT_CMD_PAGE_MASK (0xffff0000)
0111 #define     HFA384x_ADDR_FLAT_CMD_OFF_MASK  (0x0000ffff)
0112 
0113 /* Mask bits for discarding unwanted pieces in AUX format
0114  * 16-bit address parts
0115  */
0116 #define     HFA384x_ADDR_AUX_PAGE_MASK  (0xffff)
0117 #define     HFA384x_ADDR_AUX_OFF_MASK   (0x007f)
0118 
0119 /* Make a 32-bit flat address from AUX format 16-bit page and offset */
0120 #define     HFA384x_ADDR_AUX_MKFLAT(p, o)   \
0121         ((((u32)(((u16)(p)) & HFA384x_ADDR_AUX_PAGE_MASK)) << 7) | \
0122         ((u32)(((u16)(o)) & HFA384x_ADDR_AUX_OFF_MASK)))
0123 
0124 /* Make CMD format offset and page from a 32-bit flat address */
0125 #define     HFA384x_ADDR_CMD_MKPAGE(f) \
0126         ((u16)((((u32)(f)) & HFA384x_ADDR_FLAT_CMD_PAGE_MASK) >> 16))
0127 #define     HFA384x_ADDR_CMD_MKOFF(f) \
0128         ((u16)(((u32)(f)) & HFA384x_ADDR_FLAT_CMD_OFF_MASK))
0129 
0130 /*--- Controller Memory addresses -------------------*/
0131 #define     HFA3842_PDA_BASE    (0x007f0000UL)
0132 #define     HFA3841_PDA_BASE    (0x003f0000UL)
0133 #define     HFA3841_PDA_BOGUS_BASE  (0x00390000UL)
0134 
0135 /*--- Driver Download states  -----------------------*/
0136 #define     HFA384x_DLSTATE_DISABLED        0
0137 #define     HFA384x_DLSTATE_RAMENABLED      1
0138 #define     HFA384x_DLSTATE_FLASHENABLED        2
0139 
0140 /*--- Register Field Masks --------------------------*/
0141 #define     HFA384x_CMD_AINFO       ((u16)GENMASK(14, 8))
0142 #define     HFA384x_CMD_MACPORT     ((u16)GENMASK(10, 8))
0143 #define     HFA384x_CMD_PROGMODE        ((u16)GENMASK(9, 8))
0144 #define     HFA384x_CMD_CMDCODE     ((u16)GENMASK(5, 0))
0145 #define     HFA384x_STATUS_RESULT       ((u16)GENMASK(14, 8))
0146 
0147 /*--- Command Code Constants --------------------------*/
0148 /*--- Controller Commands --------------------------*/
0149 #define     HFA384x_CMDCODE_INIT        ((u16)0x00)
0150 #define     HFA384x_CMDCODE_ENABLE      ((u16)0x01)
0151 #define     HFA384x_CMDCODE_DISABLE     ((u16)0x02)
0152 
0153 /*--- Regulate Commands --------------------------*/
0154 #define     HFA384x_CMDCODE_INQ     ((u16)0x11)
0155 
0156 /*--- Configure Commands --------------------------*/
0157 #define     HFA384x_CMDCODE_DOWNLD      ((u16)0x22)
0158 
0159 /*--- Debugging Commands -----------------------------*/
0160 #define     HFA384x_CMDCODE_MONITOR     ((u16)(0x38))
0161 #define     HFA384x_MONITOR_ENABLE      ((u16)(0x0b))
0162 #define     HFA384x_MONITOR_DISABLE     ((u16)(0x0f))
0163 
0164 /*--- Result Codes --------------------------*/
0165 #define     HFA384x_CMD_ERR         ((u16)(0x7F))
0166 
0167 /*--- Programming Modes --------------------------
0168  *  MODE 0: Disable programming
0169  *  MODE 1: Enable volatile memory programming
0170  *  MODE 2: Enable non-volatile memory programming
0171  *  MODE 3: Program non-volatile memory section
0172  *-------------------------------------------------
0173  */
0174 #define     HFA384x_PROGMODE_DISABLE    ((u16)0x00)
0175 #define     HFA384x_PROGMODE_RAM        ((u16)0x01)
0176 #define     HFA384x_PROGMODE_NV     ((u16)0x02)
0177 #define     HFA384x_PROGMODE_NVWRITE    ((u16)0x03)
0178 
0179 /*--- Record ID Constants --------------------------*/
0180 /*--------------------------------------------------------------------
0181  * Configuration RIDs: Network Parameters, Static Configuration Entities
0182  *--------------------------------------------------------------------
0183  */
0184 #define     HFA384x_RID_CNFPORTTYPE     ((u16)0xFC00)
0185 #define     HFA384x_RID_CNFOWNMACADDR   ((u16)0xFC01)
0186 #define     HFA384x_RID_CNFDESIREDSSID  ((u16)0xFC02)
0187 #define     HFA384x_RID_CNFOWNCHANNEL   ((u16)0xFC03)
0188 #define     HFA384x_RID_CNFOWNSSID      ((u16)0xFC04)
0189 #define     HFA384x_RID_CNFMAXDATALEN   ((u16)0xFC07)
0190 
0191 /*--------------------------------------------------------------------
0192  * Configuration RID lengths: Network Params, Static Config Entities
0193  * This is the length of JUST the DATA part of the RID (does not
0194  * include the len or code fields)
0195  *--------------------------------------------------------------------
0196  */
0197 #define     HFA384x_RID_CNFOWNMACADDR_LEN   ((u16)6)
0198 #define     HFA384x_RID_CNFDESIREDSSID_LEN  ((u16)34)
0199 #define     HFA384x_RID_CNFOWNSSID_LEN  ((u16)34)
0200 
0201 /*--------------------------------------------------------------------
0202  * Configuration RIDs: Network Parameters, Dynamic Configuration Entities
0203  *--------------------------------------------------------------------
0204  */
0205 #define     HFA384x_RID_CREATEIBSS      ((u16)0xFC81)
0206 #define     HFA384x_RID_FRAGTHRESH      ((u16)0xFC82)
0207 #define     HFA384x_RID_RTSTHRESH       ((u16)0xFC83)
0208 #define     HFA384x_RID_TXRATECNTL      ((u16)0xFC84)
0209 #define     HFA384x_RID_PROMISCMODE     ((u16)0xFC85)
0210 
0211 /*----------------------------------------------------------------------
0212  * Information RIDs: NIC Information
0213  *----------------------------------------------------------------------
0214  */
0215 #define     HFA384x_RID_MAXLOADTIME     ((u16)0xFD00)
0216 #define     HFA384x_RID_DOWNLOADBUFFER  ((u16)0xFD01)
0217 #define     HFA384x_RID_PRIIDENTITY     ((u16)0xFD02)
0218 #define     HFA384x_RID_PRISUPRANGE     ((u16)0xFD03)
0219 #define     HFA384x_RID_PRI_CFIACTRANGES    ((u16)0xFD04)
0220 #define     HFA384x_RID_NICSERIALNUMBER ((u16)0xFD0A)
0221 #define     HFA384x_RID_NICIDENTITY     ((u16)0xFD0B)
0222 #define     HFA384x_RID_MFISUPRANGE     ((u16)0xFD0C)
0223 #define     HFA384x_RID_CFISUPRANGE     ((u16)0xFD0D)
0224 #define     HFA384x_RID_STAIDENTITY     ((u16)0xFD20)
0225 #define     HFA384x_RID_STASUPRANGE     ((u16)0xFD21)
0226 #define     HFA384x_RID_STA_MFIACTRANGES    ((u16)0xFD22)
0227 #define     HFA384x_RID_STA_CFIACTRANGES    ((u16)0xFD23)
0228 
0229 /*----------------------------------------------------------------------
0230  * Information RID Lengths: NIC Information
0231  * This is the length of JUST the DATA part of the RID (does not
0232  * include the len or code fields)
0233  *---------------------------------------------------------------------
0234  */
0235 #define     HFA384x_RID_NICSERIALNUMBER_LEN     ((u16)12)
0236 
0237 /*--------------------------------------------------------------------
0238  * Information RIDs:  MAC Information
0239  *--------------------------------------------------------------------
0240  */
0241 #define     HFA384x_RID_PORTSTATUS      ((u16)0xFD40)
0242 #define     HFA384x_RID_CURRENTSSID     ((u16)0xFD41)
0243 #define     HFA384x_RID_CURRENTBSSID    ((u16)0xFD42)
0244 #define     HFA384x_RID_CURRENTTXRATE   ((u16)0xFD44)
0245 #define     HFA384x_RID_SHORTRETRYLIMIT ((u16)0xFD48)
0246 #define     HFA384x_RID_LONGRETRYLIMIT  ((u16)0xFD49)
0247 #define     HFA384x_RID_MAXTXLIFETIME   ((u16)0xFD4A)
0248 #define     HFA384x_RID_PRIVACYOPTIMP   ((u16)0xFD4F)
0249 #define     HFA384x_RID_DBMCOMMSQUALITY ((u16)0xFD51)
0250 
0251 /*--------------------------------------------------------------------
0252  * Information RID Lengths:  MAC Information
0253  * This is the length of JUST the DATA part of the RID (does not
0254  * include the len or code fields)
0255  *--------------------------------------------------------------------
0256  */
0257 #define     HFA384x_RID_DBMCOMMSQUALITY_LEN  \
0258     ((u16)sizeof(struct hfa384x_dbmcommsquality))
0259 #define     HFA384x_RID_JOINREQUEST_LEN \
0260     ((u16)sizeof(struct hfa384x_join_request_data))
0261 
0262 /*--------------------------------------------------------------------
0263  * Information RIDs:  Modem Information
0264  *--------------------------------------------------------------------
0265  */
0266 #define     HFA384x_RID_CURRENTCHANNEL  ((u16)0xFDC1)
0267 
0268 /*--------------------------------------------------------------------
0269  * API ENHANCEMENTS (NOT ALREADY IMPLEMENTED)
0270  *--------------------------------------------------------------------
0271  */
0272 #define     HFA384x_RID_CNFWEPDEFAULTKEYID  ((u16)0xFC23)
0273 #define     HFA384x_RID_CNFWEPDEFAULTKEY0   ((u16)0xFC24)
0274 #define     HFA384x_RID_CNFWEPDEFAULTKEY1   ((u16)0xFC25)
0275 #define     HFA384x_RID_CNFWEPDEFAULTKEY2   ((u16)0xFC26)
0276 #define     HFA384x_RID_CNFWEPDEFAULTKEY3   ((u16)0xFC27)
0277 #define     HFA384x_RID_CNFWEPFLAGS     ((u16)0xFC28)
0278 #define     HFA384x_RID_CNFAUTHENTICATION   ((u16)0xFC2A)
0279 #define     HFA384x_RID_CNFROAMINGMODE  ((u16)0xFC2D)
0280 #define     HFA384x_RID_CNFAPBCNINT     ((u16)0xFC33)
0281 #define     HFA384x_RID_CNFDBMADJUST    ((u16)0xFC46)
0282 #define     HFA384x_RID_CNFWPADATA      ((u16)0xFC48)
0283 #define     HFA384x_RID_CNFBASICRATES   ((u16)0xFCB3)
0284 #define     HFA384x_RID_CNFSUPPRATES    ((u16)0xFCB4)
0285 #define     HFA384x_RID_CNFPASSIVESCANCTRL  ((u16)0xFCBA)
0286 #define     HFA384x_RID_TXPOWERMAX      ((u16)0xFCBE)
0287 #define     HFA384x_RID_JOINREQUEST     ((u16)0xFCE2)
0288 #define     HFA384x_RID_AUTHENTICATESTA ((u16)0xFCE3)
0289 #define     HFA384x_RID_HOSTSCAN        ((u16)0xFCE5)
0290 
0291 #define     HFA384x_RID_CNFWEPDEFAULTKEY_LEN    ((u16)6)
0292 #define     HFA384x_RID_CNFWEP128DEFAULTKEY_LEN ((u16)14)
0293 
0294 /*--------------------------------------------------------------------
0295  * PD Record codes
0296  *--------------------------------------------------------------------
0297  */
0298 #define HFA384x_PDR_PCB_PARTNUM     ((u16)0x0001)
0299 #define HFA384x_PDR_PDAVER      ((u16)0x0002)
0300 #define HFA384x_PDR_NIC_SERIAL      ((u16)0x0003)
0301 #define HFA384x_PDR_MKK_MEASUREMENTS    ((u16)0x0004)
0302 #define HFA384x_PDR_NIC_RAMSIZE     ((u16)0x0005)
0303 #define HFA384x_PDR_MFISUPRANGE     ((u16)0x0006)
0304 #define HFA384x_PDR_CFISUPRANGE     ((u16)0x0007)
0305 #define HFA384x_PDR_NICID       ((u16)0x0008)
0306 #define HFA384x_PDR_MAC_ADDRESS     ((u16)0x0101)
0307 #define HFA384x_PDR_REGDOMAIN       ((u16)0x0103)
0308 #define HFA384x_PDR_ALLOWED_CHANNEL ((u16)0x0104)
0309 #define HFA384x_PDR_DEFAULT_CHANNEL ((u16)0x0105)
0310 #define HFA384x_PDR_TEMPTYPE        ((u16)0x0107)
0311 #define HFA384x_PDR_IFR_SETTING     ((u16)0x0200)
0312 #define HFA384x_PDR_RFR_SETTING     ((u16)0x0201)
0313 #define HFA384x_PDR_HFA3861_BASELINE    ((u16)0x0202)
0314 #define HFA384x_PDR_HFA3861_SHADOW  ((u16)0x0203)
0315 #define HFA384x_PDR_HFA3861_IFRF    ((u16)0x0204)
0316 #define HFA384x_PDR_HFA3861_CHCALSP ((u16)0x0300)
0317 #define HFA384x_PDR_HFA3861_CHCALI  ((u16)0x0301)
0318 #define HFA384x_PDR_MAX_TX_POWER    ((u16)0x0302)
0319 #define HFA384x_PDR_MASTER_CHAN_LIST    ((u16)0x0303)
0320 #define HFA384x_PDR_3842_NIC_CONFIG ((u16)0x0400)
0321 #define HFA384x_PDR_USB_ID      ((u16)0x0401)
0322 #define HFA384x_PDR_PCI_ID      ((u16)0x0402)
0323 #define HFA384x_PDR_PCI_IFCONF      ((u16)0x0403)
0324 #define HFA384x_PDR_PCI_PMCONF      ((u16)0x0404)
0325 #define HFA384x_PDR_RFENRGY     ((u16)0x0406)
0326 #define HFA384x_PDR_USB_POWER_TYPE      ((u16)0x0407)
0327 #define HFA384x_PDR_USB_MAX_POWER   ((u16)0x0409)
0328 #define HFA384x_PDR_USB_MANUFACTURER    ((u16)0x0410)
0329 #define HFA384x_PDR_USB_PRODUCT     ((u16)0x0411)
0330 #define HFA384x_PDR_ANT_DIVERSITY   ((u16)0x0412)
0331 #define HFA384x_PDR_HFO_DELAY       ((u16)0x0413)
0332 #define HFA384x_PDR_SCALE_THRESH    ((u16)0x0414)
0333 
0334 #define HFA384x_PDR_HFA3861_MANF_TESTSP ((u16)0x0900)
0335 #define HFA384x_PDR_HFA3861_MANF_TESTI  ((u16)0x0901)
0336 #define HFA384x_PDR_END_OF_PDA      ((u16)0x0000)
0337 
0338 /*--- Register Test/Get/Set Field macros ------------------------*/
0339 
0340 #define     HFA384x_CMD_AINFO_SET(value)    ((u16)((u16)(value) << 8))
0341 #define     HFA384x_CMD_MACPORT_SET(value)  \
0342             ((u16)HFA384x_CMD_AINFO_SET(value))
0343 #define     HFA384x_CMD_PROGMODE_SET(value) \
0344             ((u16)HFA384x_CMD_AINFO_SET((u16)value))
0345 #define     HFA384x_CMD_CMDCODE_SET(value)      ((u16)(value))
0346 
0347 #define     HFA384x_STATUS_RESULT_SET(value)    (((u16)(value)) << 8)
0348 
0349 /* Host Maintained State Info */
0350 #define HFA384x_STATE_PREINIT   0
0351 #define HFA384x_STATE_INIT  1
0352 #define HFA384x_STATE_RUNNING   2
0353 
0354 /*-------------------------------------------------------------*/
0355 /* Commonly used basic types */
0356 struct hfa384x_bytestr {
0357     __le16 len;
0358     u8 data[];
0359 } __packed;
0360 
0361 struct hfa384x_bytestr32 {
0362     __le16 len;
0363     u8 data[32];
0364 } __packed;
0365 
0366 /*--------------------------------------------------------------------
0367  * Configuration Record Structures:
0368  *  Network Parameters, Static Configuration Entities
0369  *--------------------------------------------------------------------
0370  */
0371 
0372 /*-- Hardware/Firmware Component Information ----------*/
0373 struct hfa384x_compident {
0374     u16 id;
0375     u16 variant;
0376     u16 major;
0377     u16 minor;
0378 } __packed;
0379 
0380 struct hfa384x_caplevel {
0381     u16 role;
0382     u16 id;
0383     u16 variant;
0384     u16 bottom;
0385     u16 top;
0386 } __packed;
0387 
0388 /*-- Configuration Record: cnfAuthentication --*/
0389 #define HFA384x_CNFAUTHENTICATION_OPENSYSTEM    0x0001
0390 #define HFA384x_CNFAUTHENTICATION_SHAREDKEY 0x0002
0391 #define HFA384x_CNFAUTHENTICATION_LEAP      0x0004
0392 
0393 /*--------------------------------------------------------------------
0394  * Configuration Record Structures:
0395  *  Network Parameters, Dynamic Configuration Entities
0396  *--------------------------------------------------------------------
0397  */
0398 
0399 #define HFA384x_CREATEIBSS_JOINCREATEIBSS          0
0400 
0401 /*-- Configuration Record: HostScanRequest (data portion only) --*/
0402 struct hfa384x_host_scan_request_data {
0403     __le16 channel_list;
0404     __le16 tx_rate;
0405     struct hfa384x_bytestr32 ssid;
0406 } __packed;
0407 
0408 /*-- Configuration Record: JoinRequest (data portion only) --*/
0409 struct hfa384x_join_request_data {
0410     u8 bssid[WLAN_BSSID_LEN];
0411     u16 channel;
0412 } __packed;
0413 
0414 /*-- Configuration Record: authenticateStation (data portion only) --*/
0415 struct hfa384x_authenticate_station_data {
0416     u8 address[ETH_ALEN];
0417     __le16 status;
0418     __le16 algorithm;
0419 } __packed;
0420 
0421 /*-- Configuration Record: WPAData       (data portion only) --*/
0422 struct hfa384x_wpa_data {
0423     __le16 datalen;
0424     u8 data[];      /* max 80 */
0425 } __packed;
0426 
0427 /*--------------------------------------------------------------------
0428  * Information Record Structures: NIC Information
0429  *--------------------------------------------------------------------
0430  */
0431 
0432 /*-- Information Record: DownLoadBuffer --*/
0433 /* NOTE: The page and offset are in AUX format */
0434 struct hfa384x_downloadbuffer {
0435     u16 page;
0436     u16 offset;
0437     u16 len;
0438 } __packed;
0439 
0440 /*--------------------------------------------------------------------
0441  * Information Record Structures: NIC Information
0442  *--------------------------------------------------------------------
0443  */
0444 
0445 #define HFA384x_PSTATUS_CONN_IBSS   ((u16)3)
0446 
0447 /*-- Information Record: commsquality --*/
0448 struct hfa384x_commsquality {
0449     __le16 cq_curr_bss;
0450     __le16 asl_curr_bss;
0451     __le16 anl_curr_fc;
0452 } __packed;
0453 
0454 /*-- Information Record: dmbcommsquality --*/
0455 struct hfa384x_dbmcommsquality {
0456     u16 cq_dbm_curr_bss;
0457     u16 asl_dbm_curr_bss;
0458     u16 anl_dbm_curr_fc;
0459 } __packed;
0460 
0461 /*--------------------------------------------------------------------
0462  * FRAME STRUCTURES: Communication Frames
0463  *--------------------------------------------------------------------
0464  * Communication Frames: Transmit Frames
0465  *--------------------------------------------------------------------
0466  */
0467 /*-- Communication Frame: Transmit Frame Structure --*/
0468 struct hfa384x_tx_frame {
0469     u16 status;
0470     u16 reserved1;
0471     u16 reserved2;
0472     u32 sw_support;
0473     u8 tx_retrycount;
0474     u8 tx_rate;
0475     u16 tx_control;
0476 
0477     /*-- 802.11 Header Information --*/
0478     struct p80211_hdr hdr;
0479     __le16 data_len;        /* little endian format */
0480 
0481     /*-- 802.3 Header Information --*/
0482 
0483     u8 dest_addr[6];
0484     u8 src_addr[6];
0485     u16 data_length;    /* big endian format */
0486 } __packed;
0487 /*--------------------------------------------------------------------
0488  * Communication Frames: Field Masks for Transmit Frames
0489  *--------------------------------------------------------------------
0490  */
0491 /*-- Status Field --*/
0492 #define     HFA384x_TXSTATUS_ACKERR         ((u16)BIT(5))
0493 #define     HFA384x_TXSTATUS_FORMERR        ((u16)BIT(3))
0494 #define     HFA384x_TXSTATUS_DISCON         ((u16)BIT(2))
0495 #define     HFA384x_TXSTATUS_AGEDERR        ((u16)BIT(1))
0496 #define     HFA384x_TXSTATUS_RETRYERR       ((u16)BIT(0))
0497 /*-- Transmit Control Field --*/
0498 #define     HFA384x_TX_MACPORT          ((u16)GENMASK(10, 8))
0499 #define     HFA384x_TX_STRUCTYPE            ((u16)GENMASK(4, 3))
0500 #define     HFA384x_TX_TXEX             ((u16)BIT(2))
0501 #define     HFA384x_TX_TXOK             ((u16)BIT(1))
0502 /*--------------------------------------------------------------------
0503  * Communication Frames: Test/Get/Set Field Values for Transmit Frames
0504  *--------------------------------------------------------------------
0505  */
0506 /*-- Status Field --*/
0507 #define HFA384x_TXSTATUS_ISERROR(v) \
0508     (((u16)(v)) & \
0509     (HFA384x_TXSTATUS_ACKERR | HFA384x_TXSTATUS_FORMERR | \
0510     HFA384x_TXSTATUS_DISCON | HFA384x_TXSTATUS_AGEDERR | \
0511     HFA384x_TXSTATUS_RETRYERR))
0512 
0513 #define HFA384x_TX_SET(v, m, s)     ((((u16)(v)) << ((u16)(s))) & ((u16)(m)))
0514 
0515 #define HFA384x_TX_MACPORT_SET(v)   HFA384x_TX_SET(v, HFA384x_TX_MACPORT, 8)
0516 #define HFA384x_TX_STRUCTYPE_SET(v) HFA384x_TX_SET(v, \
0517                         HFA384x_TX_STRUCTYPE, 3)
0518 #define HFA384x_TX_TXEX_SET(v)      HFA384x_TX_SET(v, HFA384x_TX_TXEX, 2)
0519 #define HFA384x_TX_TXOK_SET(v)      HFA384x_TX_SET(v, HFA384x_TX_TXOK, 1)
0520 /*--------------------------------------------------------------------
0521  * Communication Frames: Receive Frames
0522  *--------------------------------------------------------------------
0523  */
0524 /*-- Communication Frame: Receive Frame Structure --*/
0525 struct hfa384x_rx_frame {
0526     /*-- MAC rx descriptor (hfa384x byte order) --*/
0527     u16 status;
0528     u32 time;
0529     u8 silence;
0530     u8 signal;
0531     u8 rate;
0532     u8 rx_flow;
0533     u16 reserved1;
0534     u16 reserved2;
0535 
0536     /*-- 802.11 Header Information (802.11 byte order) --*/
0537     struct p80211_hdr hdr;
0538     __le16 data_len;        /* hfa384x (little endian) format */
0539 
0540     /*-- 802.3 Header Information --*/
0541     u8 dest_addr[6];
0542     u8 src_addr[6];
0543     u16 data_length;    /* IEEE? (big endian) format */
0544 } __packed;
0545 /*--------------------------------------------------------------------
0546  * Communication Frames: Field Masks for Receive Frames
0547  *--------------------------------------------------------------------
0548  */
0549 
0550 /*-- Status Fields --*/
0551 #define     HFA384x_RXSTATUS_MACPORT        ((u16)GENMASK(10, 8))
0552 #define     HFA384x_RXSTATUS_FCSERR         ((u16)BIT(0))
0553 /*--------------------------------------------------------------------
0554  * Communication Frames: Test/Get/Set Field Values for Receive Frames
0555  *--------------------------------------------------------------------
0556  */
0557 #define     HFA384x_RXSTATUS_MACPORT_GET(value) ((u16)((((u16)(value)) \
0558                         & HFA384x_RXSTATUS_MACPORT) >> 8))
0559 #define     HFA384x_RXSTATUS_ISFCSERR(value)    ((u16)(((u16)(value)) \
0560                           & HFA384x_RXSTATUS_FCSERR))
0561 /*--------------------------------------------------------------------
0562  * FRAME STRUCTURES: Information Types and Information Frame Structures
0563  *--------------------------------------------------------------------
0564  * Information Types
0565  *--------------------------------------------------------------------
0566  */
0567 #define     HFA384x_IT_HANDOVERADDR         ((u16)0xF000UL)
0568 #define     HFA384x_IT_COMMTALLIES          ((u16)0xF100UL)
0569 #define     HFA384x_IT_SCANRESULTS          ((u16)0xF101UL)
0570 #define     HFA384x_IT_CHINFORESULTS        ((u16)0xF102UL)
0571 #define     HFA384x_IT_HOSTSCANRESULTS      ((u16)0xF103UL)
0572 #define     HFA384x_IT_LINKSTATUS           ((u16)0xF200UL)
0573 #define     HFA384x_IT_ASSOCSTATUS          ((u16)0xF201UL)
0574 #define     HFA384x_IT_AUTHREQ          ((u16)0xF202UL)
0575 #define     HFA384x_IT_PSUSERCNT            ((u16)0xF203UL)
0576 #define     HFA384x_IT_KEYIDCHANGED         ((u16)0xF204UL)
0577 #define     HFA384x_IT_ASSOCREQ         ((u16)0xF205UL)
0578 #define     HFA384x_IT_MICFAILURE           ((u16)0xF206UL)
0579 
0580 /*--------------------------------------------------------------------
0581  * Information Frames Structures
0582  *--------------------------------------------------------------------
0583  * Information Frames: Notification Frame Structures
0584  *--------------------------------------------------------------------
0585  */
0586 
0587 /*--  Inquiry Frame, Diagnose: Communication Tallies --*/
0588 struct hfa384x_comm_tallies_16 {
0589     __le16 txunicastframes;
0590     __le16 txmulticastframes;
0591     __le16 txfragments;
0592     __le16 txunicastoctets;
0593     __le16 txmulticastoctets;
0594     __le16 txdeferredtrans;
0595     __le16 txsingleretryframes;
0596     __le16 txmultipleretryframes;
0597     __le16 txretrylimitexceeded;
0598     __le16 txdiscards;
0599     __le16 rxunicastframes;
0600     __le16 rxmulticastframes;
0601     __le16 rxfragments;
0602     __le16 rxunicastoctets;
0603     __le16 rxmulticastoctets;
0604     __le16 rxfcserrors;
0605     __le16 rxdiscardsnobuffer;
0606     __le16 txdiscardswrongsa;
0607     __le16 rxdiscardswepundecr;
0608     __le16 rxmsginmsgfrag;
0609     __le16 rxmsginbadmsgfrag;
0610 } __packed;
0611 
0612 struct hfa384x_comm_tallies_32 {
0613     __le32 txunicastframes;
0614     __le32 txmulticastframes;
0615     __le32 txfragments;
0616     __le32 txunicastoctets;
0617     __le32 txmulticastoctets;
0618     __le32 txdeferredtrans;
0619     __le32 txsingleretryframes;
0620     __le32 txmultipleretryframes;
0621     __le32 txretrylimitexceeded;
0622     __le32 txdiscards;
0623     __le32 rxunicastframes;
0624     __le32 rxmulticastframes;
0625     __le32 rxfragments;
0626     __le32 rxunicastoctets;
0627     __le32 rxmulticastoctets;
0628     __le32 rxfcserrors;
0629     __le32 rxdiscardsnobuffer;
0630     __le32 txdiscardswrongsa;
0631     __le32 rxdiscardswepundecr;
0632     __le32 rxmsginmsgfrag;
0633     __le32 rxmsginbadmsgfrag;
0634 } __packed;
0635 
0636 /*--  Inquiry Frame, Diagnose: Scan Results & Subfields--*/
0637 struct hfa384x_scan_result_sub {
0638     u16 chid;
0639     u16 anl;
0640     u16 sl;
0641     u8 bssid[WLAN_BSSID_LEN];
0642     u16 bcnint;
0643     u16 capinfo;
0644     struct hfa384x_bytestr32 ssid;
0645     u8 supprates[10];   /* 802.11 info element */
0646     u16 proberesp_rate;
0647 } __packed;
0648 
0649 struct hfa384x_scan_result {
0650     u16 rsvd;
0651     u16 scanreason;
0652     struct hfa384x_scan_result_sub result[HFA384x_SCANRESULT_MAX];
0653 } __packed;
0654 
0655 /*--  Inquiry Frame, Diagnose: ChInfo Results & Subfields--*/
0656 struct hfa384x_ch_info_result_sub {
0657     u16 chid;
0658     u16 anl;
0659     u16 pnl;
0660     u16 active;
0661 } __packed;
0662 
0663 #define HFA384x_CHINFORESULT_BSSACTIVE  BIT(0)
0664 #define HFA384x_CHINFORESULT_PCFACTIVE  BIT(1)
0665 
0666 struct hfa384x_ch_info_result {
0667     u16 scanchannels;
0668     struct hfa384x_ch_info_result_sub result[HFA384x_CHINFORESULT_MAX];
0669 } __packed;
0670 
0671 /*--  Inquiry Frame, Diagnose: Host Scan Results & Subfields--*/
0672 struct hfa384x_hscan_result_sub {
0673     __le16 chid;
0674     __le16 anl;
0675     __le16 sl;
0676     u8 bssid[WLAN_BSSID_LEN];
0677     __le16 bcnint;
0678     __le16 capinfo;
0679     struct hfa384x_bytestr32 ssid;
0680     u8 supprates[10];   /* 802.11 info element */
0681     u16 proberesp_rate;
0682     __le16 atim;
0683 } __packed;
0684 
0685 struct hfa384x_hscan_result {
0686     u16 nresult;
0687     u16 rsvd;
0688     struct hfa384x_hscan_result_sub result[HFA384x_HSCANRESULT_MAX];
0689 } __packed;
0690 
0691 /*--  Unsolicited Frame, MAC Mgmt: LinkStatus --*/
0692 
0693 #define HFA384x_LINK_NOTCONNECTED   ((u16)0)
0694 #define HFA384x_LINK_CONNECTED      ((u16)1)
0695 #define HFA384x_LINK_DISCONNECTED   ((u16)2)
0696 #define HFA384x_LINK_AP_CHANGE      ((u16)3)
0697 #define HFA384x_LINK_AP_OUTOFRANGE  ((u16)4)
0698 #define HFA384x_LINK_AP_INRANGE     ((u16)5)
0699 #define HFA384x_LINK_ASSOCFAIL      ((u16)6)
0700 
0701 struct hfa384x_link_status {
0702     __le16 linkstatus;
0703 } __packed;
0704 
0705 /*--  Unsolicited Frame, MAC Mgmt: AssociationStatus (--*/
0706 
0707 #define HFA384x_ASSOCSTATUS_STAASSOC    ((u16)1)
0708 #define HFA384x_ASSOCSTATUS_REASSOC ((u16)2)
0709 #define HFA384x_ASSOCSTATUS_AUTHFAIL    ((u16)5)
0710 
0711 struct hfa384x_assoc_status {
0712     u16 assocstatus;
0713     u8 sta_addr[ETH_ALEN];
0714     /* old_ap_addr is only valid if assocstatus == 2 */
0715     u8 old_ap_addr[ETH_ALEN];
0716     u16 reason;
0717     u16 reserved;
0718 } __packed;
0719 
0720 /*--  Unsolicited Frame, MAC Mgmt: AuthRequest (AP Only) --*/
0721 
0722 struct hfa384x_auth_request {
0723     u8 sta_addr[ETH_ALEN];
0724     __le16 algorithm;
0725 } __packed;
0726 
0727 /*--  Unsolicited Frame, MAC Mgmt: PSUserCount (AP Only) --*/
0728 
0729 struct hfa384x_ps_user_count {
0730     __le16 usercnt;
0731 } __packed;
0732 
0733 struct hfa384x_key_id_changed {
0734     u8 sta_addr[ETH_ALEN];
0735     u16 keyid;
0736 } __packed;
0737 
0738 /*--  Collection of all Inf frames ---------------*/
0739 union hfa384x_infodata {
0740     struct hfa384x_comm_tallies_16 commtallies16;
0741     struct hfa384x_comm_tallies_32 commtallies32;
0742     struct hfa384x_scan_result scanresult;
0743     struct hfa384x_ch_info_result chinforesult;
0744     struct hfa384x_hscan_result hscanresult;
0745     struct hfa384x_link_status linkstatus;
0746     struct hfa384x_assoc_status assocstatus;
0747     struct hfa384x_auth_request authreq;
0748     struct hfa384x_ps_user_count psusercnt;
0749     struct hfa384x_key_id_changed keyidchanged;
0750 } __packed;
0751 
0752 struct hfa384x_inf_frame {
0753     u16 framelen;
0754     u16 infotype;
0755     union hfa384x_infodata info;
0756 } __packed;
0757 
0758 /*--------------------------------------------------------------------
0759  * USB Packet structures and constants.
0760  *--------------------------------------------------------------------
0761  */
0762 
0763 /* Should be sent to the bulkout endpoint */
0764 #define HFA384x_USB_TXFRM   0
0765 #define HFA384x_USB_CMDREQ  1
0766 #define HFA384x_USB_WRIDREQ 2
0767 #define HFA384x_USB_RRIDREQ 3
0768 #define HFA384x_USB_WMEMREQ 4
0769 #define HFA384x_USB_RMEMREQ 5
0770 
0771 /* Received from the bulkin endpoint */
0772 #define HFA384x_USB_ISTXFRM(a)  (((a) & 0x9000) == 0x1000)
0773 #define HFA384x_USB_ISRXFRM(a)  (!((a) & 0x9000))
0774 #define HFA384x_USB_INFOFRM 0x8000
0775 #define HFA384x_USB_CMDRESP 0x8001
0776 #define HFA384x_USB_WRIDRESP    0x8002
0777 #define HFA384x_USB_RRIDRESP    0x8003
0778 #define HFA384x_USB_WMEMRESP    0x8004
0779 #define HFA384x_USB_RMEMRESP    0x8005
0780 #define HFA384x_USB_BUFAVAIL    0x8006
0781 #define HFA384x_USB_ERROR   0x8007
0782 
0783 /*------------------------------------*/
0784 /* Request (bulk OUT) packet contents */
0785 
0786 struct hfa384x_usb_txfrm {
0787     struct hfa384x_tx_frame desc;
0788     u8 data[WLAN_DATA_MAXLEN];
0789 } __packed;
0790 
0791 struct hfa384x_usb_cmdreq {
0792     __le16 type;
0793     __le16 cmd;
0794     __le16 parm0;
0795     __le16 parm1;
0796     __le16 parm2;
0797     u8 pad[54];
0798 } __packed;
0799 
0800 struct hfa384x_usb_wridreq {
0801     __le16 type;
0802     __le16 frmlen;
0803     __le16 rid;
0804     u8 data[HFA384x_RIDDATA_MAXLEN];
0805 } __packed;
0806 
0807 struct hfa384x_usb_rridreq {
0808     __le16 type;
0809     __le16 frmlen;
0810     __le16 rid;
0811     u8 pad[58];
0812 } __packed;
0813 
0814 struct hfa384x_usb_wmemreq {
0815     __le16 type;
0816     __le16 frmlen;
0817     __le16 offset;
0818     __le16 page;
0819     u8 data[HFA384x_USB_RWMEM_MAXLEN];
0820 } __packed;
0821 
0822 struct hfa384x_usb_rmemreq {
0823     __le16 type;
0824     __le16 frmlen;
0825     __le16 offset;
0826     __le16 page;
0827     u8 pad[56];
0828 } __packed;
0829 
0830 /*------------------------------------*/
0831 /* Response (bulk IN) packet contents */
0832 
0833 struct hfa384x_usb_rxfrm {
0834     struct hfa384x_rx_frame desc;
0835     u8 data[WLAN_DATA_MAXLEN];
0836 } __packed;
0837 
0838 struct hfa384x_usb_infofrm {
0839     u16 type;
0840     struct hfa384x_inf_frame info;
0841 } __packed;
0842 
0843 struct hfa384x_usb_statusresp {
0844     u16 type;
0845     __le16 status;
0846     __le16 resp0;
0847     __le16 resp1;
0848     __le16 resp2;
0849 } __packed;
0850 
0851 struct hfa384x_usb_rridresp {
0852     u16 type;
0853     __le16 frmlen;
0854     __le16 rid;
0855     u8 data[HFA384x_RIDDATA_MAXLEN];
0856 } __packed;
0857 
0858 struct hfa384x_usb_rmemresp {
0859     u16 type;
0860     u16 frmlen;
0861     u8 data[HFA384x_USB_RWMEM_MAXLEN];
0862 } __packed;
0863 
0864 struct hfa384x_usb_bufavail {
0865     u16 type;
0866     u16 frmlen;
0867 } __packed;
0868 
0869 struct hfa384x_usb_error {
0870     u16 type;
0871     u16 errortype;
0872 } __packed;
0873 
0874 /*----------------------------------------------------------*/
0875 /* Unions for packaging all the known packet types together */
0876 
0877 union hfa384x_usbout {
0878     __le16 type;
0879     struct hfa384x_usb_txfrm txfrm;
0880     struct hfa384x_usb_cmdreq cmdreq;
0881     struct hfa384x_usb_wridreq wridreq;
0882     struct hfa384x_usb_rridreq rridreq;
0883     struct hfa384x_usb_wmemreq wmemreq;
0884     struct hfa384x_usb_rmemreq rmemreq;
0885 } __packed;
0886 
0887 union hfa384x_usbin {
0888     __le16 type;
0889     struct hfa384x_usb_rxfrm rxfrm;
0890     struct hfa384x_usb_txfrm txfrm;
0891     struct hfa384x_usb_infofrm infofrm;
0892     struct hfa384x_usb_statusresp cmdresp;
0893     struct hfa384x_usb_statusresp wridresp;
0894     struct hfa384x_usb_rridresp rridresp;
0895     struct hfa384x_usb_statusresp wmemresp;
0896     struct hfa384x_usb_rmemresp rmemresp;
0897     struct hfa384x_usb_bufavail bufavail;
0898     struct hfa384x_usb_error usberror;
0899     u8 boguspad[3000];
0900 } __packed;
0901 
0902 /*--------------------------------------------------------------------
0903  * PD record structures.
0904  *--------------------------------------------------------------------
0905  */
0906 
0907 struct hfa384x_pdr_pcb_partnum {
0908     u8 num[8];
0909 } __packed;
0910 
0911 struct hfa384x_pdr_pcb_tracenum {
0912     u8 num[8];
0913 } __packed;
0914 
0915 struct hfa384x_pdr_nic_serial {
0916     u8 num[12];
0917 } __packed;
0918 
0919 struct hfa384x_pdr_mkk_measurements {
0920     double carrier_freq;
0921     double occupied_band;
0922     double power_density;
0923     double tx_spur_f1;
0924     double tx_spur_f2;
0925     double tx_spur_f3;
0926     double tx_spur_f4;
0927     double tx_spur_l1;
0928     double tx_spur_l2;
0929     double tx_spur_l3;
0930     double tx_spur_l4;
0931     double rx_spur_f1;
0932     double rx_spur_f2;
0933     double rx_spur_l1;
0934     double rx_spur_l2;
0935 } __packed;
0936 
0937 struct hfa384x_pdr_nic_ramsize {
0938     u8 size[12];        /* units of KB */
0939 } __packed;
0940 
0941 struct hfa384x_pdr_mfisuprange {
0942     u16 id;
0943     u16 variant;
0944     u16 bottom;
0945     u16 top;
0946 } __packed;
0947 
0948 struct hfa384x_pdr_cfisuprange {
0949     u16 id;
0950     u16 variant;
0951     u16 bottom;
0952     u16 top;
0953 } __packed;
0954 
0955 struct hfa384x_pdr_nicid {
0956     u16 id;
0957     u16 variant;
0958     u16 major;
0959     u16 minor;
0960 } __packed;
0961 
0962 struct hfa384x_pdr_refdac_measurements {
0963     u16 value[0];
0964 } __packed;
0965 
0966 struct hfa384x_pdr_vgdac_measurements {
0967     u16 value[0];
0968 } __packed;
0969 
0970 struct hfa384x_pdr_level_comp_measurements {
0971     u16 value[0];
0972 } __packed;
0973 
0974 struct hfa384x_pdr_mac_address {
0975     u8 addr[6];
0976 } __packed;
0977 
0978 struct hfa384x_pdr_mkk_callname {
0979     u8 callname[8];
0980 } __packed;
0981 
0982 struct hfa384x_pdr_regdomain {
0983     u16 numdomains;
0984     u16 domain[5];
0985 } __packed;
0986 
0987 struct hfa384x_pdr_allowed_channel {
0988     u16 ch_bitmap;
0989 } __packed;
0990 
0991 struct hfa384x_pdr_default_channel {
0992     u16 channel;
0993 } __packed;
0994 
0995 struct hfa384x_pdr_privacy_option {
0996     u16 available;
0997 } __packed;
0998 
0999 struct hfa384x_pdr_temptype {
1000     u16 type;
1001 } __packed;
1002 
1003 struct hfa384x_pdr_refdac_setup {
1004     u16 ch_value[14];
1005 } __packed;
1006 
1007 struct hfa384x_pdr_vgdac_setup {
1008     u16 ch_value[14];
1009 } __packed;
1010 
1011 struct hfa384x_pdr_level_comp_setup {
1012     u16 ch_value[14];
1013 } __packed;
1014 
1015 struct hfa384x_pdr_trimdac_setup {
1016     u16 trimidac;
1017     u16 trimqdac;
1018 } __packed;
1019 
1020 struct hfa384x_pdr_ifr_setting {
1021     u16 value[3];
1022 } __packed;
1023 
1024 struct hfa384x_pdr_rfr_setting {
1025     u16 value[3];
1026 } __packed;
1027 
1028 struct hfa384x_pdr_hfa3861_baseline {
1029     u16 value[50];
1030 } __packed;
1031 
1032 struct hfa384x_pdr_hfa3861_shadow {
1033     u32 value[32];
1034 } __packed;
1035 
1036 struct hfa384x_pdr_hfa3861_ifrf {
1037     u32 value[20];
1038 } __packed;
1039 
1040 struct hfa384x_pdr_hfa3861_chcalsp {
1041     u16 value[14];
1042 } __packed;
1043 
1044 struct hfa384x_pdr_hfa3861_chcali {
1045     u16 value[17];
1046 } __packed;
1047 
1048 struct hfa384x_pdr_hfa3861_nic_config {
1049     u16 config_bitmap;
1050 } __packed;
1051 
1052 struct hfa384x_pdr_hfo_delay {
1053     u8 hfo_delay;
1054 } __packed;
1055 
1056 struct hfa384x_pdr_hfa3861_manf_testsp {
1057     u16 value[30];
1058 } __packed;
1059 
1060 struct hfa384x_pdr_hfa3861_manf_testi {
1061     u16 value[30];
1062 } __packed;
1063 
1064 struct hfa384x_pdr_end_of_pda {
1065     u16 crc;
1066 } __packed;
1067 
1068 struct hfa384x_pdrec {
1069     __le16 len;     /* in words */
1070     __le16 code;
1071     union pdr {
1072         struct hfa384x_pdr_pcb_partnum pcb_partnum;
1073         struct hfa384x_pdr_pcb_tracenum pcb_tracenum;
1074         struct hfa384x_pdr_nic_serial nic_serial;
1075         struct hfa384x_pdr_mkk_measurements mkk_measurements;
1076         struct hfa384x_pdr_nic_ramsize nic_ramsize;
1077         struct hfa384x_pdr_mfisuprange mfisuprange;
1078         struct hfa384x_pdr_cfisuprange cfisuprange;
1079         struct hfa384x_pdr_nicid nicid;
1080         struct hfa384x_pdr_refdac_measurements refdac_measurements;
1081         struct hfa384x_pdr_vgdac_measurements vgdac_measurements;
1082         struct hfa384x_pdr_level_comp_measurements level_compc_measurements;
1083         struct hfa384x_pdr_mac_address mac_address;
1084         struct hfa384x_pdr_mkk_callname mkk_callname;
1085         struct hfa384x_pdr_regdomain regdomain;
1086         struct hfa384x_pdr_allowed_channel allowed_channel;
1087         struct hfa384x_pdr_default_channel default_channel;
1088         struct hfa384x_pdr_privacy_option privacy_option;
1089         struct hfa384x_pdr_temptype temptype;
1090         struct hfa384x_pdr_refdac_setup refdac_setup;
1091         struct hfa384x_pdr_vgdac_setup vgdac_setup;
1092         struct hfa384x_pdr_level_comp_setup level_comp_setup;
1093         struct hfa384x_pdr_trimdac_setup trimdac_setup;
1094         struct hfa384x_pdr_ifr_setting ifr_setting;
1095         struct hfa384x_pdr_rfr_setting rfr_setting;
1096         struct hfa384x_pdr_hfa3861_baseline hfa3861_baseline;
1097         struct hfa384x_pdr_hfa3861_shadow hfa3861_shadow;
1098         struct hfa384x_pdr_hfa3861_ifrf hfa3861_ifrf;
1099         struct hfa384x_pdr_hfa3861_chcalsp hfa3861_chcalsp;
1100         struct hfa384x_pdr_hfa3861_chcali hfa3861_chcali;
1101         struct hfa384x_pdr_hfa3861_nic_config nic_config;
1102         struct hfa384x_pdr_hfo_delay hfo_delay;
1103         struct hfa384x_pdr_hfa3861_manf_testsp hfa3861_manf_testsp;
1104         struct hfa384x_pdr_hfa3861_manf_testi hfa3861_manf_testi;
1105         struct hfa384x_pdr_end_of_pda end_of_pda;
1106 
1107     } data;
1108 } __packed;
1109 
1110 #ifdef __KERNEL__
1111 /*--------------------------------------------------------------------
1112  * ---  MAC state structure, argument to all functions --
1113  * ---  Also, a collection of support types --
1114  *--------------------------------------------------------------------
1115  */
1116 struct hfa384x_cmdresult {
1117     u16 status;
1118     u16 resp0;
1119     u16 resp1;
1120     u16 resp2;
1121 };
1122 
1123 /* USB Control Exchange (CTLX):
1124  *  A queue of the structure below is maintained for all of the
1125  *  Request/Response type USB packets supported by Prism2.
1126  */
1127 /* The following hfa384x_* structures are arguments to
1128  * the usercb() for the different CTLX types.
1129  */
1130 struct hfa384x_rridresult {
1131     u16 rid;
1132     const void *riddata;
1133     unsigned int riddata_len;
1134 };
1135 
1136 enum ctlx_state {
1137     CTLX_START = 0,     /* Start state, not queued */
1138 
1139     CTLX_COMPLETE,      /* CTLX successfully completed */
1140     CTLX_REQ_FAILED,    /* OUT URB completed w/ error */
1141 
1142     CTLX_PENDING,       /* Queued, data valid */
1143     CTLX_REQ_SUBMITTED, /* OUT URB submitted */
1144     CTLX_REQ_COMPLETE,  /* OUT URB complete */
1145     CTLX_RESP_COMPLETE  /* IN URB received */
1146 };
1147 
1148 struct hfa384x_usbctlx;
1149 struct hfa384x;
1150 
1151 typedef void (*ctlx_cmdcb_t) (struct hfa384x *, const struct hfa384x_usbctlx *);
1152 
1153 typedef void (*ctlx_usercb_t) (struct hfa384x *hw,
1154                    void *ctlxresult, void *usercb_data);
1155 
1156 struct hfa384x_usbctlx {
1157     struct list_head list;
1158 
1159     size_t outbufsize;
1160     union hfa384x_usbout outbuf;    /* pkt buf for OUT */
1161     union hfa384x_usbin inbuf;  /* pkt buf for IN(a copy) */
1162 
1163     enum ctlx_state state;  /* Tracks running state */
1164 
1165     struct completion done;
1166     int reapable;       /* Food for the reaper task */
1167 
1168     ctlx_cmdcb_t cmdcb; /* Async command callback */
1169     ctlx_usercb_t usercb;   /* Async user callback, */
1170     void *usercb_data;  /*  at CTLX completion  */
1171 };
1172 
1173 struct hfa384x_usbctlxq {
1174     spinlock_t lock;
1175     struct list_head pending;
1176     struct list_head active;
1177     struct list_head completing;
1178     struct list_head reapable;
1179 };
1180 
1181 struct hfa384x_metacmd {
1182     u16 cmd;
1183 
1184     u16 parm0;
1185     u16 parm1;
1186     u16 parm2;
1187 
1188     struct hfa384x_cmdresult result;
1189 };
1190 
1191 #define MAX_GRP_ADDR        32
1192 #define WLAN_COMMENT_MAX    80  /* Max. length of user comment string. */
1193 
1194 #define WLAN_AUTH_MAX           60  /* Max. # of authenticated stations. */
1195 #define WLAN_ACCESS_MAX     60  /* Max. # of stations in an access list. */
1196 #define WLAN_ACCESS_NONE    0   /* No stations may be authenticated. */
1197 #define WLAN_ACCESS_ALL     1   /* All stations may be authenticated. */
1198 #define WLAN_ACCESS_ALLOW   2   /* Authenticate only "allowed" stations. */
1199 #define WLAN_ACCESS_DENY    3   /* Do not authenticate "denied" stations. */
1200 
1201 /* XXX These are going away ASAP */
1202 struct prism2sta_authlist {
1203     unsigned int cnt;
1204     u8 addr[WLAN_AUTH_MAX][ETH_ALEN];
1205     u8 assoc[WLAN_AUTH_MAX];
1206 };
1207 
1208 struct prism2sta_accesslist {
1209     unsigned int modify;
1210     unsigned int cnt;
1211     u8 addr[WLAN_ACCESS_MAX][ETH_ALEN];
1212     unsigned int cnt1;
1213     u8 addr1[WLAN_ACCESS_MAX][ETH_ALEN];
1214 };
1215 
1216 struct hfa384x {
1217     /* USB support data */
1218     struct usb_device *usb;
1219     struct urb rx_urb;
1220     struct sk_buff *rx_urb_skb;
1221     struct urb tx_urb;
1222     struct urb ctlx_urb;
1223     union hfa384x_usbout txbuff;
1224     struct hfa384x_usbctlxq ctlxq;
1225     struct timer_list reqtimer;
1226     struct timer_list resptimer;
1227 
1228     struct timer_list throttle;
1229 
1230     struct work_struct reaper_bh;
1231     struct work_struct completion_bh;
1232 
1233     struct work_struct usb_work;
1234 
1235     unsigned long usb_flags;
1236 #define THROTTLE_RX 0
1237 #define THROTTLE_TX 1
1238 #define WORK_RX_HALT    2
1239 #define WORK_TX_HALT    3
1240 #define WORK_RX_RESUME  4
1241 #define WORK_TX_RESUME  5
1242 
1243     unsigned short req_timer_done:1;
1244     unsigned short resp_timer_done:1;
1245 
1246     int endp_in;
1247     int endp_out;
1248 
1249     int sniff_fcs;
1250     int sniff_channel;
1251     int sniff_truncate;
1252     int sniffhdr;
1253 
1254     wait_queue_head_t cmdq; /* wait queue itself */
1255 
1256     /* Controller state */
1257     u32 state;
1258     u32 isap;
1259     u8 port_enabled[HFA384x_NUMPORTS_MAX];
1260 
1261     /* Download support */
1262     unsigned int dlstate;
1263     struct hfa384x_downloadbuffer bufinfo;
1264     u16 dltimeout;
1265 
1266     int scanflag;       /* to signal scan complete */
1267     int join_ap;        /* are we joined to a specific ap */
1268     int join_retries;   /* number of join retries till we fail */
1269     struct hfa384x_join_request_data joinreq;/* join request saved data */
1270 
1271     struct wlandevice *wlandev;
1272     /* Timer to allow for the deferred processing of linkstatus messages */
1273     struct work_struct link_bh;
1274 
1275     struct work_struct commsqual_bh;
1276     struct hfa384x_commsquality qual;
1277     struct timer_list commsqual_timer;
1278 
1279     u16 link_status;
1280     u16 link_status_new;
1281     struct sk_buff_head authq;
1282 
1283     u32 txrate;
1284 
1285     /* And here we have stuff that used to be in priv */
1286 
1287     /* State variables */
1288     unsigned int presniff_port_type;
1289     u16 presniff_wepflags;
1290     u32 dot11_desired_bss_type;
1291 
1292     int dbmadjust;
1293 
1294     /* Group Addresses - right now, there are up to a total
1295      * of MAX_GRP_ADDR group addresses
1296      */
1297     u8 dot11_grp_addr[MAX_GRP_ADDR][ETH_ALEN];
1298     unsigned int dot11_grpcnt;
1299 
1300     /* Component Identities */
1301     struct hfa384x_compident ident_nic;
1302     struct hfa384x_compident ident_pri_fw;
1303     struct hfa384x_compident ident_sta_fw;
1304     struct hfa384x_compident ident_ap_fw;
1305     u16 mm_mods;
1306 
1307     /* Supplier compatibility ranges */
1308     struct hfa384x_caplevel cap_sup_mfi;
1309     struct hfa384x_caplevel cap_sup_cfi;
1310     struct hfa384x_caplevel cap_sup_pri;
1311     struct hfa384x_caplevel cap_sup_sta;
1312     struct hfa384x_caplevel cap_sup_ap;
1313 
1314     /* Actor compatibility ranges */
1315     struct hfa384x_caplevel cap_act_pri_cfi; /*
1316                           * pri f/w to controller
1317                           * interface
1318                           */
1319 
1320     struct hfa384x_caplevel cap_act_sta_cfi; /*
1321                           * sta f/w to controller
1322                           * interface
1323                           */
1324 
1325     struct hfa384x_caplevel cap_act_sta_mfi; /*
1326                           * sta f/w to modem interface
1327                           */
1328 
1329     struct hfa384x_caplevel cap_act_ap_cfi; /*
1330                          * ap f/w to controller
1331                          * interface
1332                          */
1333 
1334     struct hfa384x_caplevel cap_act_ap_mfi; /* ap f/w to modem interface */
1335 
1336     u32 psusercount;    /* Power save user count. */
1337     struct hfa384x_comm_tallies_32 tallies; /* Communication tallies. */
1338     u8 comment[WLAN_COMMENT_MAX + 1];   /* User comment */
1339 
1340     /* Channel Info request results (AP only) */
1341     struct {
1342         atomic_t done;
1343         u8 count;
1344         struct hfa384x_ch_info_result results;
1345     } channel_info;
1346 
1347     struct hfa384x_inf_frame *scanresults;
1348 
1349     struct prism2sta_authlist authlist; /*
1350                          * Authenticated station list.
1351                          */
1352     unsigned int accessmode;        /* Access mode. */
1353     struct prism2sta_accesslist allow;  /* Allowed station list. */
1354     struct prism2sta_accesslist deny;   /* Denied station list. */
1355 
1356 };
1357 
1358 void hfa384x_create(struct hfa384x *hw, struct usb_device *usb);
1359 void hfa384x_destroy(struct hfa384x *hw);
1360 
1361 int hfa384x_corereset(struct hfa384x *hw, int holdtime, int settletime,
1362               int genesis);
1363 int hfa384x_drvr_disable(struct hfa384x *hw, u16 macport);
1364 int hfa384x_drvr_enable(struct hfa384x *hw, u16 macport);
1365 int hfa384x_drvr_flashdl_enable(struct hfa384x *hw);
1366 int hfa384x_drvr_flashdl_disable(struct hfa384x *hw);
1367 int hfa384x_drvr_flashdl_write(struct hfa384x *hw, u32 daddr, void *buf,
1368                    u32 len);
1369 int hfa384x_drvr_getconfig(struct hfa384x *hw, u16 rid, void *buf, u16 len);
1370 int hfa384x_drvr_ramdl_enable(struct hfa384x *hw, u32 exeaddr);
1371 int hfa384x_drvr_ramdl_disable(struct hfa384x *hw);
1372 int hfa384x_drvr_ramdl_write(struct hfa384x *hw, u32 daddr, void *buf, u32 len);
1373 int hfa384x_drvr_readpda(struct hfa384x *hw, void *buf, unsigned int len);
1374 int hfa384x_drvr_setconfig(struct hfa384x *hw, u16 rid, void *buf, u16 len);
1375 
1376 static inline int
1377 hfa384x_drvr_getconfig16(struct hfa384x *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         le16_to_cpus(val);
1384     return result;
1385 }
1386 
1387 static inline int hfa384x_drvr_setconfig16(struct hfa384x *hw, u16 rid, u16 val)
1388 {
1389     __le16 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(struct hfa384x *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(struct hfa384x *hw, u16 rid, u16 val)
1402 {
1403     __le16 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(struct hfa384x *hw);
1410 int hfa384x_drvr_stop(struct hfa384x *hw);
1411 int
1412 hfa384x_drvr_txframe(struct hfa384x *hw, struct sk_buff *skb,
1413              struct p80211_hdr *p80211_hdr,
1414              struct p80211_metawep *p80211_wep);
1415 void hfa384x_tx_timeout(struct wlandevice *wlandev);
1416 
1417 int hfa384x_cmd_initialize(struct hfa384x *hw);
1418 int hfa384x_cmd_enable(struct hfa384x *hw, u16 macport);
1419 int hfa384x_cmd_disable(struct hfa384x *hw, u16 macport);
1420 int hfa384x_cmd_allocate(struct hfa384x *hw, u16 len);
1421 int hfa384x_cmd_monitor(struct hfa384x *hw, u16 enable);
1422 int
1423 hfa384x_cmd_download(struct hfa384x *hw,
1424              u16 mode, u16 lowaddr, u16 highaddr, u16 codelen);
1425 
1426 #endif /*__KERNEL__ */
1427 
1428 #endif /*_HFA384x_H */