mwifiex: add WOWLAN support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / mwifiex / fw.h
1 /*
2  * Marvell Wireless LAN device driver: Firmware specific macros & structures
3  *
4  * Copyright (C) 2011, Marvell International Ltd.
5  *
6  * This software file (the "File") is distributed by Marvell International
7  * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8  * (the "License").  You may use, redistribute and/or modify this File in
9  * accordance with the terms and conditions of the License, a copy of which
10  * is available by writing to the Free Software Foundation, Inc.,
11  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12  * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13  *
14  * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16  * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
17  * this warranty disclaimer.
18  */
19
20 #ifndef _MWIFIEX_FW_H_
21 #define _MWIFIEX_FW_H_
22
23 #include <linux/if_ether.h>
24
25
26 #define INTF_HEADER_LEN     4
27
28 struct rfc_1042_hdr {
29         u8 llc_dsap;
30         u8 llc_ssap;
31         u8 llc_ctrl;
32         u8 snap_oui[3];
33         u16 snap_type;
34 };
35
36 struct rx_packet_hdr {
37         struct ethhdr eth803_hdr;
38         struct rfc_1042_hdr rfc1042_hdr;
39 };
40
41 struct tx_packet_hdr {
42         struct ethhdr eth803_hdr;
43         struct rfc_1042_hdr rfc1042_hdr;
44 };
45
46 #define B_SUPPORTED_RATES               5
47 #define G_SUPPORTED_RATES               9
48 #define BG_SUPPORTED_RATES              13
49 #define A_SUPPORTED_RATES               9
50 #define HOSTCMD_SUPPORTED_RATES         14
51 #define N_SUPPORTED_RATES               3
52 #define ALL_802_11_BANDS           (BAND_A | BAND_B | BAND_G | BAND_GN | \
53                                     BAND_AN | BAND_GAC | BAND_AAC)
54
55 #define FW_MULTI_BANDS_SUPPORT  (BIT(8) | BIT(9) | BIT(10) | BIT(11) | \
56                                  BIT(12) | BIT(13))
57 #define IS_SUPPORT_MULTI_BANDS(adapter)        \
58         (adapter->fw_cap_info & FW_MULTI_BANDS_SUPPORT)
59
60 /* shift bit 12 and bit 13 in fw_cap_info from the firmware to bit 13 and 14
61  * for 11ac so that bit 11 is for GN, bit 12 for AN, bit 13 for GAC, and bit
62  * bit 14 for AAC, in order to be compatible with the band capability
63  * defined in the driver after right shift of 8 bits.
64  */
65 #define GET_FW_DEFAULT_BANDS(adapter)  \
66             (((((adapter->fw_cap_info & 0x3000) << 1) | \
67                (adapter->fw_cap_info & ~0xF000)) >> 8) & \
68              ALL_802_11_BANDS)
69
70 #define HostCmd_WEP_KEY_INDEX_MASK              0x3fff
71
72 #define KEY_INFO_ENABLED        0x01
73 enum KEY_TYPE_ID {
74         KEY_TYPE_ID_WEP = 0,
75         KEY_TYPE_ID_TKIP,
76         KEY_TYPE_ID_AES,
77         KEY_TYPE_ID_WAPI,
78         KEY_TYPE_ID_AES_CMAC,
79 };
80 #define KEY_MCAST       BIT(0)
81 #define KEY_UNICAST     BIT(1)
82 #define KEY_ENABLED     BIT(2)
83 #define KEY_IGTK        BIT(10)
84
85 #define WAPI_KEY_LEN                    50
86
87 #define MAX_POLL_TRIES                  100
88
89 #define MAX_MULTI_INTERFACE_POLL_TRIES  1000
90
91 #define MAX_FIRMWARE_POLL_TRIES                 100
92
93 #define FIRMWARE_READY_SDIO                             0xfedc
94 #define FIRMWARE_READY_PCIE                             0xfedcba00
95
96 enum mwifiex_usb_ep {
97         MWIFIEX_USB_EP_CMD_EVENT = 1,
98         MWIFIEX_USB_EP_DATA = 2,
99 };
100
101 enum MWIFIEX_802_11_PRIVACY_FILTER {
102         MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL,
103         MWIFIEX_802_11_PRIV_FILTER_8021X_WEP
104 };
105
106 #define CAL_SNR(RSSI, NF)               ((s16)((s16)(RSSI)-(s16)(NF)))
107 #define CAL_RSSI(SNR, NF)               ((s16)((s16)(SNR)+(s16)(NF)))
108
109 #define UAP_BSS_PARAMS_I                        0
110 #define UAP_CUSTOM_IE_I                         1
111 #define MWIFIEX_AUTO_IDX_MASK                   0xffff
112 #define MWIFIEX_DELETE_MASK                     0x0000
113 #define MGMT_MASK_ASSOC_REQ                     0x01
114 #define MGMT_MASK_REASSOC_REQ                   0x04
115 #define MGMT_MASK_ASSOC_RESP                    0x02
116 #define MGMT_MASK_REASSOC_RESP                  0x08
117 #define MGMT_MASK_PROBE_REQ                     0x10
118 #define MGMT_MASK_PROBE_RESP                    0x20
119 #define MGMT_MASK_BEACON                        0x100
120
121 #define TLV_TYPE_UAP_SSID                       0x0000
122 #define TLV_TYPE_UAP_RATES                      0x0001
123
124 #define PROPRIETARY_TLV_BASE_ID                 0x0100
125 #define TLV_TYPE_KEY_MATERIAL       (PROPRIETARY_TLV_BASE_ID + 0)
126 #define TLV_TYPE_CHANLIST           (PROPRIETARY_TLV_BASE_ID + 1)
127 #define TLV_TYPE_NUMPROBES          (PROPRIETARY_TLV_BASE_ID + 2)
128 #define TLV_TYPE_RSSI_LOW           (PROPRIETARY_TLV_BASE_ID + 4)
129 #define TLV_TYPE_PASSTHROUGH        (PROPRIETARY_TLV_BASE_ID + 10)
130 #define TLV_TYPE_WMMQSTATUS         (PROPRIETARY_TLV_BASE_ID + 16)
131 #define TLV_TYPE_WILDCARDSSID       (PROPRIETARY_TLV_BASE_ID + 18)
132 #define TLV_TYPE_TSFTIMESTAMP       (PROPRIETARY_TLV_BASE_ID + 19)
133 #define TLV_TYPE_RSSI_HIGH          (PROPRIETARY_TLV_BASE_ID + 22)
134 #define TLV_TYPE_AUTH_TYPE          (PROPRIETARY_TLV_BASE_ID + 31)
135 #define TLV_TYPE_STA_MAC_ADDR       (PROPRIETARY_TLV_BASE_ID + 32)
136 #define TLV_TYPE_CHANNELBANDLIST    (PROPRIETARY_TLV_BASE_ID + 42)
137 #define TLV_TYPE_UAP_BEACON_PERIOD  (PROPRIETARY_TLV_BASE_ID + 44)
138 #define TLV_TYPE_UAP_DTIM_PERIOD    (PROPRIETARY_TLV_BASE_ID + 45)
139 #define TLV_TYPE_UAP_BCAST_SSID     (PROPRIETARY_TLV_BASE_ID + 48)
140 #define TLV_TYPE_UAP_RTS_THRESHOLD  (PROPRIETARY_TLV_BASE_ID + 51)
141 #define TLV_TYPE_UAP_AO_TIMER       (PROPRIETARY_TLV_BASE_ID + 57)
142 #define TLV_TYPE_UAP_WEP_KEY        (PROPRIETARY_TLV_BASE_ID + 59)
143 #define TLV_TYPE_UAP_WPA_PASSPHRASE (PROPRIETARY_TLV_BASE_ID + 60)
144 #define TLV_TYPE_UAP_ENCRY_PROTOCOL (PROPRIETARY_TLV_BASE_ID + 64)
145 #define TLV_TYPE_UAP_AKMP           (PROPRIETARY_TLV_BASE_ID + 65)
146 #define TLV_TYPE_UAP_FRAG_THRESHOLD (PROPRIETARY_TLV_BASE_ID + 70)
147 #define TLV_TYPE_RATE_DROP_CONTROL  (PROPRIETARY_TLV_BASE_ID + 82)
148 #define TLV_TYPE_RATE_SCOPE         (PROPRIETARY_TLV_BASE_ID + 83)
149 #define TLV_TYPE_POWER_GROUP        (PROPRIETARY_TLV_BASE_ID + 84)
150 #define TLV_TYPE_UAP_RETRY_LIMIT    (PROPRIETARY_TLV_BASE_ID + 93)
151 #define TLV_TYPE_WAPI_IE            (PROPRIETARY_TLV_BASE_ID + 94)
152 #define TLV_TYPE_UAP_MGMT_FRAME     (PROPRIETARY_TLV_BASE_ID + 104)
153 #define TLV_TYPE_MGMT_IE            (PROPRIETARY_TLV_BASE_ID + 105)
154 #define TLV_TYPE_AUTO_DS_PARAM      (PROPRIETARY_TLV_BASE_ID + 113)
155 #define TLV_TYPE_PS_PARAM           (PROPRIETARY_TLV_BASE_ID + 114)
156 #define TLV_TYPE_UAP_PS_AO_TIMER    (PROPRIETARY_TLV_BASE_ID + 123)
157 #define TLV_TYPE_PWK_CIPHER         (PROPRIETARY_TLV_BASE_ID + 145)
158 #define TLV_TYPE_GWK_CIPHER         (PROPRIETARY_TLV_BASE_ID + 146)
159
160 #define MWIFIEX_TX_DATA_BUF_SIZE_2K        2048
161
162 #define SSN_MASK         0xfff0
163
164 #define BA_RESULT_SUCCESS        0x0
165 #define BA_RESULT_TIMEOUT        0x2
166
167 #define IS_BASTREAM_SETUP(ptr)  (ptr->ba_status)
168
169 #define BA_STREAM_NOT_ALLOWED   0xff
170
171 #define IS_11N_ENABLED(priv) ((priv->adapter->config_bands & BAND_GN || \
172                         priv->adapter->config_bands & BAND_AN) && \
173                         priv->curr_bss_params.bss_descriptor.bcn_ht_cap)
174 #define INITIATOR_BIT(DelBAParamSet) (((DelBAParamSet) &\
175                         BIT(DELBA_INITIATOR_POS)) >> DELBA_INITIATOR_POS)
176
177 #define MWIFIEX_TX_DATA_BUF_SIZE_4K        4096
178 #define MWIFIEX_TX_DATA_BUF_SIZE_8K        8192
179
180 #define ISSUPP_11NENABLED(FwCapInfo) (FwCapInfo & BIT(11))
181
182 #define MWIFIEX_DEF_HT_CAP      (IEEE80211_HT_CAP_DSSSCCK40 | \
183                                  (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT) | \
184                                  IEEE80211_HT_CAP_SM_PS)
185
186 #define MWIFIEX_DEF_AMPDU       IEEE80211_HT_AMPDU_PARM_FACTOR
187
188 /* dev_cap bitmap
189  * BIT
190  * 0-16         reserved
191  * 17           IEEE80211_HT_CAP_SUP_WIDTH_20_40
192  * 18-22        reserved
193  * 23           IEEE80211_HT_CAP_SGI_20
194  * 24           IEEE80211_HT_CAP_SGI_40
195  * 25           IEEE80211_HT_CAP_TX_STBC
196  * 26           IEEE80211_HT_CAP_RX_STBC
197  * 27-28        reserved
198  * 29           IEEE80211_HT_CAP_GRN_FLD
199  * 30-31        reserved
200  */
201 #define ISSUPP_CHANWIDTH40(Dot11nDevCap) (Dot11nDevCap & BIT(17))
202 #define ISSUPP_SHORTGI20(Dot11nDevCap) (Dot11nDevCap & BIT(23))
203 #define ISSUPP_SHORTGI40(Dot11nDevCap) (Dot11nDevCap & BIT(24))
204 #define ISSUPP_TXSTBC(Dot11nDevCap) (Dot11nDevCap & BIT(25))
205 #define ISSUPP_RXSTBC(Dot11nDevCap) (Dot11nDevCap & BIT(26))
206 #define ISSUPP_GREENFIELD(Dot11nDevCap) (Dot11nDevCap & BIT(29))
207 #define ISENABLED_40MHZ_INTOLERANT(Dot11nDevCap) (Dot11nDevCap & BIT(8))
208 #define ISSUPP_RXLDPC(Dot11nDevCap) (Dot11nDevCap & BIT(22))
209
210 /* httxcfg bitmap
211  * 0            reserved
212  * 1            20/40 Mhz enable(1)/disable(0)
213  * 2-3          reserved
214  * 4            green field enable(1)/disable(0)
215  * 5            short GI in 20 Mhz enable(1)/disable(0)
216  * 6            short GI in 40 Mhz enable(1)/disable(0)
217  * 7-15         reserved
218  */
219 #define MWIFIEX_FW_DEF_HTTXCFG (BIT(1) | BIT(4) | BIT(5) | BIT(6))
220
221 #define GET_RXMCSSUPP(DevMCSSupported) (DevMCSSupported & 0x0f)
222 #define SETHT_MCS32(x) (x[4] |= 1)
223 #define HT_STREAM_2X2   0x22
224
225 #define SET_SECONDARYCHAN(RadioType, SECCHAN) (RadioType |= (SECCHAN << 4))
226
227 #define LLC_SNAP_LEN    8
228
229 /* HW_SPEC fw_cap_info */
230
231 #define ISSUPP_11ACENABLED(fw_cap_info) (fw_cap_info & (BIT(13)|BIT(14)))
232
233 #define GET_VHTCAP_MAXMPDULEN(vht_cap_info) (vht_cap_info & 0x3)
234 #define GET_VHTCAP_CHWDSET(vht_cap_info)    ((vht_cap_info >> 2) & 0x3)
235 #define GET_VHTNSSMCS(mcs_mapset, nss) ((mcs_mapset >> (2 * (nss - 1))) & 0x3)
236 #define SET_VHTNSSMCS(mcs_mapset, nss, value) (mcs_mapset |= (value & 0x3) << \
237                                               (2 * (nss - 1)))
238 #define NO_NSS_SUPPORT          0x3
239
240 /* HW_SPEC: HTC-VHT supported */
241 #define ISSUPP_11ACVHTHTCVHT(Dot11acDevCap) (Dot11acDevCap & BIT(22))
242 /* HW_SPEC: VHT TXOP PS support */
243 #define ISSUPP_11ACVHTTXOPPS(Dot11acDevCap) (Dot11acDevCap & BIT(21))
244 /* HW_SPEC: MU RX beamformee support */
245 #define ISSUPP_11ACMURXBEAMFORMEE(Dot11acDevCap) (Dot11acDevCap & BIT(20))
246 /* HW_SPEC: MU TX beamformee support */
247 #define ISSUPP_11ACMUTXBEAMFORMEE(Dot11acDevCap) (Dot11acDevCap & BIT(19))
248 /* HW_SPEC: SU Beamformee support */
249 #define ISSUPP_11ACSUBEAMFORMEE(Dot11acDevCap) (Dot11acDevCap & BIT(10))
250 /* HW_SPEC: SU Beamformer support */
251 #define ISSUPP_11ACSUBEAMFORMER(Dot11acDevCap) (Dot11acDevCap & BIT(9))
252 /* HW_SPEC: Rx STBC support */
253 #define ISSUPP_11ACRXSTBC(Dot11acDevCap) (Dot11acDevCap & BIT(8))
254 /* HW_SPEC: Tx STBC support */
255 #define ISSUPP_11ACTXSTBC(Dot11acDevCap) (Dot11acDevCap & BIT(7))
256 /* HW_SPEC: Short GI support for 160MHz BW */
257 #define ISSUPP_11ACSGI160(Dot11acDevCap) (Dot11acDevCap & BIT(6))
258 /* HW_SPEC: Short GI support for 80MHz BW */
259 #define ISSUPP_11ACSGI80(Dot11acDevCap) (Dot11acDevCap & BIT(5))
260 /* HW_SPEC: LDPC coding support */
261 #define ISSUPP_11ACLDPC(Dot11acDevCap) (Dot11acDevCap & BIT(4))
262 /* HW_SPEC: Channel BW 20/40/80/160/80+80 MHz support */
263 #define ISSUPP_11ACBW8080(Dot11acDevCap) (Dot11acDevCap & BIT(3))
264 /* HW_SPEC: Channel BW 20/40/80/160 MHz support */
265 #define ISSUPP_11ACBW160(Dot11acDevCap) (Dot11acDevCap & BIT(2))
266
267 #define GET_DEVTXMCSMAP(dev_mcs_map)      (dev_mcs_map >> 16)
268 #define GET_DEVRXMCSMAP(dev_mcs_map)      (dev_mcs_map & 0xFFFF)
269
270 #define MOD_CLASS_HR_DSSS       0x03
271 #define MOD_CLASS_OFDM          0x07
272 #define MOD_CLASS_HT            0x08
273 #define HT_BW_20    0
274 #define HT_BW_40    1
275
276 #define HostCmd_CMD_GET_HW_SPEC                       0x0003
277 #define HostCmd_CMD_802_11_SCAN                       0x0006
278 #define HostCmd_CMD_802_11_GET_LOG                    0x000b
279 #define HostCmd_CMD_MAC_MULTICAST_ADR                 0x0010
280 #define HostCmd_CMD_802_11_EEPROM_ACCESS              0x0059
281 #define HostCmd_CMD_802_11_ASSOCIATE                  0x0012
282 #define HostCmd_CMD_802_11_SNMP_MIB                   0x0016
283 #define HostCmd_CMD_MAC_REG_ACCESS                    0x0019
284 #define HostCmd_CMD_BBP_REG_ACCESS                    0x001a
285 #define HostCmd_CMD_RF_REG_ACCESS                     0x001b
286 #define HostCmd_CMD_PMIC_REG_ACCESS                   0x00ad
287 #define HostCmd_CMD_RF_TX_PWR                         0x001e
288 #define HostCmd_CMD_RF_ANTENNA                        0x0020
289 #define HostCmd_CMD_802_11_DEAUTHENTICATE             0x0024
290 #define HostCmd_CMD_MAC_CONTROL                       0x0028
291 #define HostCmd_CMD_802_11_AD_HOC_START               0x002b
292 #define HostCmd_CMD_802_11_AD_HOC_JOIN                0x002c
293 #define HostCmd_CMD_802_11_AD_HOC_STOP                0x0040
294 #define HostCmd_CMD_802_11_MAC_ADDRESS                0x004D
295 #define HostCmd_CMD_802_11D_DOMAIN_INFO               0x005b
296 #define HostCmd_CMD_802_11_KEY_MATERIAL               0x005e
297 #define HostCmd_CMD_802_11_BG_SCAN_QUERY              0x006c
298 #define HostCmd_CMD_WMM_GET_STATUS                    0x0071
299 #define HostCmd_CMD_802_11_SUBSCRIBE_EVENT            0x0075
300 #define HostCmd_CMD_802_11_TX_RATE_QUERY              0x007f
301 #define HostCmd_CMD_802_11_IBSS_COALESCING_STATUS     0x0083
302 #define HostCmd_CMD_VERSION_EXT                       0x0097
303 #define HostCmd_CMD_MEF_CFG                           0x009a
304 #define HostCmd_CMD_RSSI_INFO                         0x00a4
305 #define HostCmd_CMD_FUNC_INIT                         0x00a9
306 #define HostCmd_CMD_FUNC_SHUTDOWN                     0x00aa
307 #define HostCmd_CMD_UAP_SYS_CONFIG                    0x00b0
308 #define HostCmd_CMD_UAP_BSS_START                     0x00b1
309 #define HostCmd_CMD_UAP_BSS_STOP                      0x00b2
310 #define HostCmd_CMD_11N_CFG                           0x00cd
311 #define HostCmd_CMD_11N_ADDBA_REQ                     0x00ce
312 #define HostCmd_CMD_11N_ADDBA_RSP                     0x00cf
313 #define HostCmd_CMD_11N_DELBA                         0x00d0
314 #define HostCmd_CMD_RECONFIGURE_TX_BUFF               0x00d9
315 #define HostCmd_CMD_AMSDU_AGGR_CTRL                   0x00df
316 #define HostCmd_CMD_TXPWR_CFG                         0x00d1
317 #define HostCmd_CMD_TX_RATE_CFG                       0x00d6
318 #define HostCmd_CMD_802_11_PS_MODE_ENH                0x00e4
319 #define HostCmd_CMD_802_11_HS_CFG_ENH                 0x00e5
320 #define HostCmd_CMD_P2P_MODE_CFG                      0x00eb
321 #define HostCmd_CMD_CAU_REG_ACCESS                    0x00ed
322 #define HostCmd_CMD_SET_BSS_MODE                      0x00f7
323 #define HostCmd_CMD_PCIE_DESC_DETAILS                 0x00fa
324 #define HostCmd_CMD_MGMT_FRAME_REG                    0x010c
325 #define HostCmd_CMD_REMAIN_ON_CHAN                    0x010d
326
327 #define PROTOCOL_NO_SECURITY        0x01
328 #define PROTOCOL_STATIC_WEP         0x02
329 #define PROTOCOL_WPA                0x08
330 #define PROTOCOL_WPA2               0x20
331 #define PROTOCOL_WPA2_MIXED         0x28
332 #define PROTOCOL_EAP                0x40
333 #define KEY_MGMT_NONE               0x04
334 #define KEY_MGMT_PSK                0x02
335 #define KEY_MGMT_EAP                0x01
336 #define CIPHER_TKIP                 0x04
337 #define CIPHER_AES_CCMP             0x08
338 #define VALID_CIPHER_BITMAP         0x0c
339
340 enum ENH_PS_MODES {
341         EN_PS = 1,
342         DIS_PS = 2,
343         EN_AUTO_DS = 3,
344         DIS_AUTO_DS = 4,
345         SLEEP_CONFIRM = 5,
346         GET_PS = 0,
347         EN_AUTO_PS = 0xff,
348         DIS_AUTO_PS = 0xfe,
349 };
350
351 enum P2P_MODES {
352         P2P_MODE_DISABLE = 0,
353         P2P_MODE_DEVICE = 1,
354         P2P_MODE_GO = 2,
355         P2P_MODE_CLIENT = 3,
356 };
357
358 #define HostCmd_RET_BIT                       0x8000
359 #define HostCmd_ACT_GEN_GET                   0x0000
360 #define HostCmd_ACT_GEN_SET                   0x0001
361 #define HostCmd_ACT_GEN_REMOVE                0x0004
362 #define HostCmd_ACT_BITWISE_SET               0x0002
363 #define HostCmd_ACT_BITWISE_CLR               0x0003
364 #define HostCmd_RESULT_OK                     0x0000
365
366 #define HostCmd_ACT_MAC_RX_ON                 0x0001
367 #define HostCmd_ACT_MAC_TX_ON                 0x0002
368 #define HostCmd_ACT_MAC_WEP_ENABLE            0x0008
369 #define HostCmd_ACT_MAC_ETHERNETII_ENABLE     0x0010
370 #define HostCmd_ACT_MAC_PROMISCUOUS_ENABLE    0x0080
371 #define HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE  0x0100
372 #define HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON     0x2000
373
374 #define HostCmd_BSS_MODE_IBSS               0x0002
375 #define HostCmd_BSS_MODE_ANY                0x0003
376
377 #define HostCmd_SCAN_RADIO_TYPE_BG          0
378 #define HostCmd_SCAN_RADIO_TYPE_A           1
379
380 #define HS_CFG_CANCEL                   0xffffffff
381 #define HS_CFG_COND_DEF                 0x00000000
382 #define HS_CFG_GPIO_DEF                 0xff
383 #define HS_CFG_GAP_DEF                  0
384 #define HS_CFG_COND_BROADCAST_DATA      0x00000001
385 #define HS_CFG_COND_UNICAST_DATA        0x00000002
386 #define HS_CFG_COND_MAC_EVENT           0x00000004
387 #define HS_CFG_COND_MULTICAST_DATA      0x00000008
388
389 #define MWIFIEX_TIMEOUT_FOR_AP_RESP             0xfffc
390 #define MWIFIEX_STATUS_CODE_AUTH_TIMEOUT        2
391
392 #define CMD_F_HOSTCMD           (1 << 0)
393 #define CMD_F_CANCELED          (1 << 1)
394
395 #define HostCmd_CMD_ID_MASK             0x0fff
396
397 #define HostCmd_SEQ_NUM_MASK            0x00ff
398
399 #define HostCmd_BSS_NUM_MASK            0x0f00
400
401 #define HostCmd_BSS_TYPE_MASK           0xf000
402
403 #define HostCmd_ACT_SET_RX              0x0001
404 #define HostCmd_ACT_SET_TX              0x0002
405 #define HostCmd_ACT_SET_BOTH            0x0003
406
407 #define RF_ANTENNA_AUTO                 0xFFFF
408
409 #define HostCmd_SET_SEQ_NO_BSS_INFO(seq, num, type) {   \
410         (((seq) & 0x00ff) |                             \
411          (((num) & 0x000f) << 8)) |                     \
412         (((type) & 0x000f) << 12);                  }
413
414 #define HostCmd_GET_SEQ_NO(seq)       \
415         ((seq) & HostCmd_SEQ_NUM_MASK)
416
417 #define HostCmd_GET_BSS_NO(seq)         \
418         (((seq) & HostCmd_BSS_NUM_MASK) >> 8)
419
420 #define HostCmd_GET_BSS_TYPE(seq)       \
421         (((seq) & HostCmd_BSS_TYPE_MASK) >> 12)
422
423 #define EVENT_DUMMY_HOST_WAKEUP_SIGNAL  0x00000001
424 #define EVENT_LINK_LOST                 0x00000003
425 #define EVENT_LINK_SENSED               0x00000004
426 #define EVENT_MIB_CHANGED               0x00000006
427 #define EVENT_INIT_DONE                 0x00000007
428 #define EVENT_DEAUTHENTICATED           0x00000008
429 #define EVENT_DISASSOCIATED             0x00000009
430 #define EVENT_PS_AWAKE                  0x0000000a
431 #define EVENT_PS_SLEEP                  0x0000000b
432 #define EVENT_MIC_ERR_MULTICAST         0x0000000d
433 #define EVENT_MIC_ERR_UNICAST           0x0000000e
434 #define EVENT_DEEP_SLEEP_AWAKE          0x00000010
435 #define EVENT_ADHOC_BCN_LOST            0x00000011
436
437 #define EVENT_WMM_STATUS_CHANGE         0x00000017
438 #define EVENT_BG_SCAN_REPORT            0x00000018
439 #define EVENT_RSSI_LOW                  0x00000019
440 #define EVENT_SNR_LOW                   0x0000001a
441 #define EVENT_MAX_FAIL                  0x0000001b
442 #define EVENT_RSSI_HIGH                 0x0000001c
443 #define EVENT_SNR_HIGH                  0x0000001d
444 #define EVENT_IBSS_COALESCED            0x0000001e
445 #define EVENT_DATA_RSSI_LOW             0x00000024
446 #define EVENT_DATA_SNR_LOW              0x00000025
447 #define EVENT_DATA_RSSI_HIGH            0x00000026
448 #define EVENT_DATA_SNR_HIGH             0x00000027
449 #define EVENT_LINK_QUALITY              0x00000028
450 #define EVENT_PORT_RELEASE              0x0000002b
451 #define EVENT_UAP_STA_DEAUTH            0x0000002c
452 #define EVENT_UAP_STA_ASSOC             0x0000002d
453 #define EVENT_UAP_BSS_START             0x0000002e
454 #define EVENT_PRE_BEACON_LOST           0x00000031
455 #define EVENT_ADDBA                     0x00000033
456 #define EVENT_DELBA                     0x00000034
457 #define EVENT_BA_STREAM_TIEMOUT         0x00000037
458 #define EVENT_AMSDU_AGGR_CTRL           0x00000042
459 #define EVENT_UAP_BSS_IDLE              0x00000043
460 #define EVENT_UAP_BSS_ACTIVE            0x00000044
461 #define EVENT_WEP_ICV_ERR               0x00000046
462 #define EVENT_HS_ACT_REQ                0x00000047
463 #define EVENT_BW_CHANGE                 0x00000048
464 #define EVENT_UAP_MIC_COUNTERMEASURES   0x0000004c
465 #define EVENT_HOSTWAKE_STAIE            0x0000004d
466 #define EVENT_REMAIN_ON_CHAN_EXPIRED    0x0000005f
467
468 #define EVENT_ID_MASK                   0xffff
469 #define BSS_NUM_MASK                    0xf
470
471 #define EVENT_GET_BSS_NUM(event_cause)          \
472         (((event_cause) >> 16) & BSS_NUM_MASK)
473
474 #define EVENT_GET_BSS_TYPE(event_cause)         \
475         (((event_cause) >> 24) & 0x00ff)
476
477 #define MWIFIEX_MAX_PATTERN_LEN         20
478 #define MWIFIEX_MAX_OFFSET_LEN          50
479 #define STACK_NBYTES                    100
480 #define TYPE_DNUM                       1
481 #define TYPE_BYTESEQ                    2
482 #define MAX_OPERAND                     0x40
483 #define TYPE_EQ                         (MAX_OPERAND+1)
484 #define TYPE_EQ_DNUM                    (MAX_OPERAND+2)
485 #define TYPE_EQ_BIT                     (MAX_OPERAND+3)
486 #define TYPE_AND                        (MAX_OPERAND+4)
487 #define TYPE_OR                         (MAX_OPERAND+5)
488 #define MEF_MODE_HOST_SLEEP                     1
489 #define MEF_ACTION_ALLOW_AND_WAKEUP_HOST        3
490 #define MWIFIEX_CRITERIA_BROADCAST      BIT(0)
491 #define MWIFIEX_CRITERIA_UNICAST        BIT(1)
492 #define MWIFIEX_CRITERIA_MULTICAST      BIT(3)
493
494 struct mwifiex_ie_types_header {
495         __le16 type;
496         __le16 len;
497 } __packed;
498
499 struct mwifiex_ie_types_data {
500         struct mwifiex_ie_types_header header;
501         u8 data[1];
502 } __packed;
503
504 #define MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET 0x01
505 #define MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET 0x08
506
507 struct txpd {
508         u8 bss_type;
509         u8 bss_num;
510         __le16 tx_pkt_length;
511         __le16 tx_pkt_offset;
512         __le16 tx_pkt_type;
513         __le32 tx_control;
514         u8 priority;
515         u8 flags;
516         u8 pkt_delay_2ms;
517         u8 reserved1;
518 } __packed;
519
520 struct rxpd {
521         u8 bss_type;
522         u8 bss_num;
523         __le16 rx_pkt_length;
524         __le16 rx_pkt_offset;
525         __le16 rx_pkt_type;
526         __le16 seq_num;
527         u8 priority;
528         u8 rx_rate;
529         s8 snr;
530         s8 nf;
531
532         /* For: Non-802.11 AC cards
533          *
534          * Ht Info [Bit 0] RxRate format: LG=0, HT=1
535          * [Bit 1]  HT Bandwidth: BW20 = 0, BW40 = 1
536          * [Bit 2]  HT Guard Interval: LGI = 0, SGI = 1
537          *
538          * For: 802.11 AC cards
539          * [Bit 1] [Bit 0] RxRate format: legacy rate = 00 HT = 01 VHT = 10
540          * [Bit 3] [Bit 2] HT/VHT Bandwidth BW20 = 00 BW40 = 01
541          *                                              BW80 = 10  BW160 = 11
542          * [Bit 4] HT/VHT Guard interval LGI = 0 SGI = 1
543          * [Bit 5] STBC support Enabled = 1
544          * [Bit 6] LDPC support Enabled = 1
545          * [Bit 7] Reserved
546          */
547         u8 ht_info;
548         u8 reserved;
549 } __packed;
550
551 struct uap_txpd {
552         u8 bss_type;
553         u8 bss_num;
554         __le16 tx_pkt_length;
555         __le16 tx_pkt_offset;
556         __le16 tx_pkt_type;
557         __le32 tx_control;
558         u8 priority;
559         u8 flags;
560         u8 pkt_delay_2ms;
561         u8 reserved1;
562         __le32 reserved2;
563 };
564
565 struct uap_rxpd {
566         u8 bss_type;
567         u8 bss_num;
568         __le16 rx_pkt_length;
569         __le16 rx_pkt_offset;
570         __le16 rx_pkt_type;
571         __le16 seq_num;
572         u8 priority;
573         u8 reserved1;
574 };
575
576 enum mwifiex_chan_scan_mode_bitmasks {
577         MWIFIEX_PASSIVE_SCAN = BIT(0),
578         MWIFIEX_DISABLE_CHAN_FILT = BIT(1),
579 };
580
581 struct mwifiex_chan_scan_param_set {
582         u8 radio_type;
583         u8 chan_number;
584         u8 chan_scan_mode_bitmap;
585         __le16 min_scan_time;
586         __le16 max_scan_time;
587 } __packed;
588
589 struct mwifiex_ie_types_chan_list_param_set {
590         struct mwifiex_ie_types_header header;
591         struct mwifiex_chan_scan_param_set chan_scan_param[1];
592 } __packed;
593
594 struct chan_band_param_set {
595         u8 radio_type;
596         u8 chan_number;
597 };
598
599 struct mwifiex_ie_types_chan_band_list_param_set {
600         struct mwifiex_ie_types_header header;
601         struct chan_band_param_set chan_band_param[1];
602 } __packed;
603
604 struct mwifiex_ie_types_rates_param_set {
605         struct mwifiex_ie_types_header header;
606         u8 rates[1];
607 } __packed;
608
609 struct mwifiex_ie_types_ssid_param_set {
610         struct mwifiex_ie_types_header header;
611         u8 ssid[1];
612 } __packed;
613
614 struct mwifiex_ie_types_num_probes {
615         struct mwifiex_ie_types_header header;
616         __le16 num_probes;
617 } __packed;
618
619 struct mwifiex_ie_types_wildcard_ssid_params {
620         struct mwifiex_ie_types_header header;
621         u8 max_ssid_length;
622         u8 ssid[1];
623 } __packed;
624
625 #define TSF_DATA_SIZE            8
626 struct mwifiex_ie_types_tsf_timestamp {
627         struct mwifiex_ie_types_header header;
628         u8 tsf_data[1];
629 } __packed;
630
631 struct mwifiex_cf_param_set {
632         u8 cfp_cnt;
633         u8 cfp_period;
634         u16 cfp_max_duration;
635         u16 cfp_duration_remaining;
636 } __packed;
637
638 struct mwifiex_ibss_param_set {
639         u16 atim_window;
640 } __packed;
641
642 struct mwifiex_ie_types_ss_param_set {
643         struct mwifiex_ie_types_header header;
644         union {
645                 struct mwifiex_cf_param_set cf_param_set[1];
646                 struct mwifiex_ibss_param_set ibss_param_set[1];
647         } cf_ibss;
648 } __packed;
649
650 struct mwifiex_fh_param_set {
651         u16 dwell_time;
652         u8 hop_set;
653         u8 hop_pattern;
654         u8 hop_index;
655 } __packed;
656
657 struct mwifiex_ds_param_set {
658         u8 current_chan;
659 } __packed;
660
661 struct mwifiex_ie_types_phy_param_set {
662         struct mwifiex_ie_types_header header;
663         union {
664                 struct mwifiex_fh_param_set fh_param_set[1];
665                 struct mwifiex_ds_param_set ds_param_set[1];
666         } fh_ds;
667 } __packed;
668
669 struct mwifiex_ie_types_auth_type {
670         struct mwifiex_ie_types_header header;
671         __le16 auth_type;
672 } __packed;
673
674 struct mwifiex_ie_types_vendor_param_set {
675         struct mwifiex_ie_types_header header;
676         u8 ie[MWIFIEX_MAX_VSIE_LEN];
677 };
678
679 struct mwifiex_ie_types_rsn_param_set {
680         struct mwifiex_ie_types_header header;
681         u8 rsn_ie[1];
682 } __packed;
683
684 #define KEYPARAMSET_FIXED_LEN 6
685
686 struct mwifiex_ie_type_key_param_set {
687         __le16 type;
688         __le16 length;
689         __le16 key_type_id;
690         __le16 key_info;
691         __le16 key_len;
692         u8 key[50];
693 } __packed;
694
695 #define IGTK_PN_LEN             8
696
697 struct mwifiex_cmac_param {
698         u8 ipn[IGTK_PN_LEN];
699         u8 key[WLAN_KEY_LEN_AES_CMAC];
700 } __packed;
701
702 struct host_cmd_ds_802_11_key_material {
703         __le16 action;
704         struct mwifiex_ie_type_key_param_set key_param_set;
705 } __packed;
706
707 struct host_cmd_ds_gen {
708         u16 command;
709         u16 size;
710         u16 seq_num;
711         u16 result;
712 };
713
714 #define S_DS_GEN        sizeof(struct host_cmd_ds_gen)
715
716 enum sleep_resp_ctrl {
717         RESP_NOT_NEEDED = 0,
718         RESP_NEEDED,
719 };
720
721 struct mwifiex_ps_param {
722         __le16 null_pkt_interval;
723         __le16 multiple_dtims;
724         __le16 bcn_miss_timeout;
725         __le16 local_listen_interval;
726         __le16 adhoc_wake_period;
727         __le16 mode;
728         __le16 delay_to_ps;
729 };
730
731 #define BITMAP_AUTO_DS         0x01
732 #define BITMAP_STA_PS          0x10
733
734 struct mwifiex_ie_types_auto_ds_param {
735         struct mwifiex_ie_types_header header;
736         __le16 deep_sleep_timeout;
737 } __packed;
738
739 struct mwifiex_ie_types_ps_param {
740         struct mwifiex_ie_types_header header;
741         struct mwifiex_ps_param param;
742 } __packed;
743
744 struct host_cmd_ds_802_11_ps_mode_enh {
745         __le16 action;
746
747         union {
748                 struct mwifiex_ps_param opt_ps;
749                 __le16 ps_bitmap;
750         } params;
751 } __packed;
752
753 struct host_cmd_ds_get_hw_spec {
754         __le16 hw_if_version;
755         __le16 version;
756         __le16 reserved;
757         __le16 num_of_mcast_adr;
758         u8 permanent_addr[ETH_ALEN];
759         __le16 region_code;
760         __le16 number_of_antenna;
761         __le32 fw_release_number;
762         __le32 reserved_1;
763         __le32 reserved_2;
764         __le32 reserved_3;
765         __le32 fw_cap_info;
766         __le32 dot_11n_dev_cap;
767         u8 dev_mcs_support;
768         __le16 mp_end_port;     /* SDIO only, reserved for other interfacces */
769         __le16 mgmt_buf_count;  /* mgmt IE buffer count */
770         __le32 reserved_5;
771         __le32 reserved_6;
772         __le32 dot_11ac_dev_cap;
773         __le32 dot_11ac_mcs_support;
774 } __packed;
775
776 struct host_cmd_ds_802_11_rssi_info {
777         __le16 action;
778         __le16 ndata;
779         __le16 nbcn;
780         __le16 reserved[9];
781         long long reserved_1;
782 };
783
784 struct host_cmd_ds_802_11_rssi_info_rsp {
785         __le16 action;
786         __le16 ndata;
787         __le16 nbcn;
788         __le16 data_rssi_last;
789         __le16 data_nf_last;
790         __le16 data_rssi_avg;
791         __le16 data_nf_avg;
792         __le16 bcn_rssi_last;
793         __le16 bcn_nf_last;
794         __le16 bcn_rssi_avg;
795         __le16 bcn_nf_avg;
796         long long tsf_bcn;
797 };
798
799 struct host_cmd_ds_802_11_mac_address {
800         __le16 action;
801         u8 mac_addr[ETH_ALEN];
802 };
803
804 struct host_cmd_ds_mac_control {
805         __le16 action;
806         __le16 reserved;
807 };
808
809 struct host_cmd_ds_mac_multicast_adr {
810         __le16 action;
811         __le16 num_of_adrs;
812         u8 mac_list[MWIFIEX_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
813 } __packed;
814
815 struct host_cmd_ds_802_11_deauthenticate {
816         u8 mac_addr[ETH_ALEN];
817         __le16 reason_code;
818 } __packed;
819
820 struct host_cmd_ds_802_11_associate {
821         u8 peer_sta_addr[ETH_ALEN];
822         __le16 cap_info_bitmap;
823         __le16 listen_interval;
824         __le16 beacon_period;
825         u8 dtim_period;
826 } __packed;
827
828 struct ieee_types_assoc_rsp {
829         __le16 cap_info_bitmap;
830         __le16 status_code;
831         __le16 a_id;
832         u8 ie_buffer[1];
833 } __packed;
834
835 struct host_cmd_ds_802_11_associate_rsp {
836         struct ieee_types_assoc_rsp assoc_rsp;
837 } __packed;
838
839 struct ieee_types_cf_param_set {
840         u8 element_id;
841         u8 len;
842         u8 cfp_cnt;
843         u8 cfp_period;
844         u16 cfp_max_duration;
845         u16 cfp_duration_remaining;
846 } __packed;
847
848 struct ieee_types_ibss_param_set {
849         u8 element_id;
850         u8 len;
851         __le16 atim_window;
852 } __packed;
853
854 union ieee_types_ss_param_set {
855         struct ieee_types_cf_param_set cf_param_set;
856         struct ieee_types_ibss_param_set ibss_param_set;
857 } __packed;
858
859 struct ieee_types_fh_param_set {
860         u8 element_id;
861         u8 len;
862         __le16 dwell_time;
863         u8 hop_set;
864         u8 hop_pattern;
865         u8 hop_index;
866 } __packed;
867
868 struct ieee_types_ds_param_set {
869         u8 element_id;
870         u8 len;
871         u8 current_chan;
872 } __packed;
873
874 union ieee_types_phy_param_set {
875         struct ieee_types_fh_param_set fh_param_set;
876         struct ieee_types_ds_param_set ds_param_set;
877 } __packed;
878
879 struct ieee_types_oper_mode_ntf {
880         u8 element_id;
881         u8 len;
882         u8 oper_mode;
883 } __packed;
884
885 struct host_cmd_ds_802_11_ad_hoc_start {
886         u8 ssid[IEEE80211_MAX_SSID_LEN];
887         u8 bss_mode;
888         __le16 beacon_period;
889         u8 dtim_period;
890         union ieee_types_ss_param_set ss_param_set;
891         union ieee_types_phy_param_set phy_param_set;
892         u16 reserved1;
893         __le16 cap_info_bitmap;
894         u8 data_rate[HOSTCMD_SUPPORTED_RATES];
895 } __packed;
896
897 struct host_cmd_ds_802_11_ad_hoc_result {
898         u8 pad[3];
899         u8 bssid[ETH_ALEN];
900 } __packed;
901
902 struct adhoc_bss_desc {
903         u8 bssid[ETH_ALEN];
904         u8 ssid[IEEE80211_MAX_SSID_LEN];
905         u8 bss_mode;
906         __le16 beacon_period;
907         u8 dtim_period;
908         u8 time_stamp[8];
909         u8 local_time[8];
910         union ieee_types_phy_param_set phy_param_set;
911         union ieee_types_ss_param_set ss_param_set;
912         __le16 cap_info_bitmap;
913         u8 data_rates[HOSTCMD_SUPPORTED_RATES];
914
915         /*
916          *  DO NOT ADD ANY FIELDS TO THIS STRUCTURE.
917          *  It is used in the Adhoc join command and will cause a
918          *  binary layout mismatch with the firmware
919          */
920 } __packed;
921
922 struct host_cmd_ds_802_11_ad_hoc_join {
923         struct adhoc_bss_desc bss_descriptor;
924         u16 reserved1;
925         u16 reserved2;
926 } __packed;
927
928 struct host_cmd_ds_802_11_get_log {
929         __le32 mcast_tx_frame;
930         __le32 failed;
931         __le32 retry;
932         __le32 multi_retry;
933         __le32 frame_dup;
934         __le32 rts_success;
935         __le32 rts_failure;
936         __le32 ack_failure;
937         __le32 rx_frag;
938         __le32 mcast_rx_frame;
939         __le32 fcs_error;
940         __le32 tx_frame;
941         __le32 reserved;
942         __le32 wep_icv_err_cnt[4];
943 };
944
945 /* Enumeration for rate format */
946 enum _mwifiex_rate_format {
947         MWIFIEX_RATE_FORMAT_LG = 0,
948         MWIFIEX_RATE_FORMAT_HT,
949         MWIFIEX_RATE_FORMAT_VHT,
950         MWIFIEX_RATE_FORMAT_AUTO = 0xFF,
951 };
952
953 struct host_cmd_ds_tx_rate_query {
954         u8 tx_rate;
955         /* Tx Rate Info: For 802.11 AC cards
956          *
957          * [Bit 0-1] tx rate formate: LG = 0, HT = 1, VHT = 2
958          * [Bit 2-3] HT/VHT Bandwidth: BW20 = 0, BW40 = 1, BW80 = 2, BW160 = 3
959          * [Bit 4]   HT/VHT Guard Interval: LGI = 0, SGI = 1
960          *
961          * For non-802.11 AC cards
962          * Ht Info [Bit 0] RxRate format: LG=0, HT=1
963          * [Bit 1]  HT Bandwidth: BW20 = 0, BW40 = 1
964          * [Bit 2]  HT Guard Interval: LGI = 0, SGI = 1
965          */
966         u8 ht_info;
967 } __packed;
968
969 enum Host_Sleep_Action {
970         HS_CONFIGURE = 0x0001,
971         HS_ACTIVATE  = 0x0002,
972 };
973
974 struct mwifiex_hs_config_param {
975         __le32 conditions;
976         u8 gpio;
977         u8 gap;
978 } __packed;
979
980 struct hs_activate_param {
981         u16 resp_ctrl;
982 } __packed;
983
984 struct host_cmd_ds_802_11_hs_cfg_enh {
985         __le16 action;
986
987         union {
988                 struct mwifiex_hs_config_param hs_config;
989                 struct hs_activate_param hs_activate;
990         } params;
991 } __packed;
992
993 enum SNMP_MIB_INDEX {
994         OP_RATE_SET_I = 1,
995         DTIM_PERIOD_I = 3,
996         RTS_THRESH_I = 5,
997         SHORT_RETRY_LIM_I = 6,
998         LONG_RETRY_LIM_I = 7,
999         FRAG_THRESH_I = 8,
1000         DOT11D_I = 9,
1001 };
1002
1003 #define MAX_SNMP_BUF_SIZE   128
1004
1005 struct host_cmd_ds_802_11_snmp_mib {
1006         __le16 query_type;
1007         __le16 oid;
1008         __le16 buf_size;
1009         u8 value[1];
1010 } __packed;
1011
1012 struct mwifiex_rate_scope {
1013         __le16 type;
1014         __le16 length;
1015         __le16 hr_dsss_rate_bitmap;
1016         __le16 ofdm_rate_bitmap;
1017         __le16 ht_mcs_rate_bitmap[8];
1018 } __packed;
1019
1020 struct mwifiex_rate_drop_pattern {
1021         __le16 type;
1022         __le16 length;
1023         __le32 rate_drop_mode;
1024 } __packed;
1025
1026 struct host_cmd_ds_tx_rate_cfg {
1027         __le16 action;
1028         __le16 cfg_index;
1029 } __packed;
1030
1031 struct mwifiex_power_group {
1032         u8 modulation_class;
1033         u8 first_rate_code;
1034         u8 last_rate_code;
1035         s8 power_step;
1036         s8 power_min;
1037         s8 power_max;
1038         u8 ht_bandwidth;
1039         u8 reserved;
1040 } __packed;
1041
1042 struct mwifiex_types_power_group {
1043         u16 type;
1044         u16 length;
1045 } __packed;
1046
1047 struct host_cmd_ds_txpwr_cfg {
1048         __le16 action;
1049         __le16 cfg_index;
1050         __le32 mode;
1051 } __packed;
1052
1053 struct host_cmd_ds_rf_tx_pwr {
1054         __le16 action;
1055         __le16 cur_level;
1056         u8 max_power;
1057         u8 min_power;
1058 } __packed;
1059
1060 struct host_cmd_ds_rf_ant_mimo {
1061         __le16 action_tx;
1062         __le16 tx_ant_mode;
1063         __le16 action_rx;
1064         __le16 rx_ant_mode;
1065 };
1066
1067 struct host_cmd_ds_rf_ant_siso {
1068         __le16 action;
1069         __le16 ant_mode;
1070 };
1071
1072 struct mwifiex_bcn_param {
1073         u8 bssid[ETH_ALEN];
1074         u8 rssi;
1075         __le64 timestamp;
1076         __le16 beacon_period;
1077         __le16 cap_info_bitmap;
1078 } __packed;
1079
1080 #define MWIFIEX_USER_SCAN_CHAN_MAX             50
1081
1082 #define MWIFIEX_MAX_SSID_LIST_LENGTH         10
1083
1084 struct mwifiex_scan_cmd_config {
1085         /*
1086          *  BSS mode to be sent in the firmware command
1087          */
1088         u8 bss_mode;
1089
1090         /* Specific BSSID used to filter scan results in the firmware */
1091         u8 specific_bssid[ETH_ALEN];
1092
1093         /* Length of TLVs sent in command starting at tlvBuffer */
1094         u32 tlv_buf_len;
1095
1096         /*
1097          *  SSID TLV(s) and ChanList TLVs to be sent in the firmware command
1098          *
1099          *  TLV_TYPE_CHANLIST, mwifiex_ie_types_chan_list_param_set
1100          *  WLAN_EID_SSID, mwifiex_ie_types_ssid_param_set
1101          */
1102         u8 tlv_buf[1];  /* SSID TLV(s) and ChanList TLVs are stored
1103                                    here */
1104 } __packed;
1105
1106 struct mwifiex_user_scan_chan {
1107         u8 chan_number;
1108         u8 radio_type;
1109         u8 scan_type;
1110         u8 reserved;
1111         u32 scan_time;
1112 } __packed;
1113
1114 struct mwifiex_user_scan_cfg {
1115         /*
1116          *  BSS mode to be sent in the firmware command
1117          */
1118         u8 bss_mode;
1119         /* Configure the number of probe requests for active chan scans */
1120         u8 num_probes;
1121         u8 reserved;
1122         /* BSSID filter sent in the firmware command to limit the results */
1123         u8 specific_bssid[ETH_ALEN];
1124         /* SSID filter list used in the firmware to limit the scan results */
1125         struct cfg80211_ssid *ssid_list;
1126         u8 num_ssids;
1127         /* Variable number (fixed maximum) of channels to scan up */
1128         struct mwifiex_user_scan_chan chan_list[MWIFIEX_USER_SCAN_CHAN_MAX];
1129 } __packed;
1130
1131 struct ie_body {
1132         u8 grp_key_oui[4];
1133         u8 ptk_cnt[2];
1134         u8 ptk_body[4];
1135 } __packed;
1136
1137 struct host_cmd_ds_802_11_scan {
1138         u8 bss_mode;
1139         u8 bssid[ETH_ALEN];
1140         u8 tlv_buffer[1];
1141 } __packed;
1142
1143 struct host_cmd_ds_802_11_scan_rsp {
1144         __le16 bss_descript_size;
1145         u8 number_of_sets;
1146         u8 bss_desc_and_tlv_buffer[1];
1147 } __packed;
1148
1149 struct host_cmd_ds_802_11_bg_scan_query {
1150         u8 flush;
1151 } __packed;
1152
1153 struct host_cmd_ds_802_11_bg_scan_query_rsp {
1154         u32 report_condition;
1155         struct host_cmd_ds_802_11_scan_rsp scan_resp;
1156 } __packed;
1157
1158 struct mwifiex_ietypes_domain_param_set {
1159         struct mwifiex_ie_types_header header;
1160         u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
1161         struct ieee80211_country_ie_triplet triplet[1];
1162 } __packed;
1163
1164 struct host_cmd_ds_802_11d_domain_info {
1165         __le16 action;
1166         struct mwifiex_ietypes_domain_param_set domain;
1167 } __packed;
1168
1169 struct host_cmd_ds_802_11d_domain_info_rsp {
1170         __le16 action;
1171         struct mwifiex_ietypes_domain_param_set domain;
1172 } __packed;
1173
1174 struct host_cmd_ds_11n_addba_req {
1175         u8 add_req_result;
1176         u8 peer_mac_addr[ETH_ALEN];
1177         u8 dialog_token;
1178         __le16 block_ack_param_set;
1179         __le16 block_ack_tmo;
1180         __le16 ssn;
1181 } __packed;
1182
1183 struct host_cmd_ds_11n_addba_rsp {
1184         u8 add_rsp_result;
1185         u8 peer_mac_addr[ETH_ALEN];
1186         u8 dialog_token;
1187         __le16 status_code;
1188         __le16 block_ack_param_set;
1189         __le16 block_ack_tmo;
1190         __le16 ssn;
1191 } __packed;
1192
1193 struct host_cmd_ds_11n_delba {
1194         u8 del_result;
1195         u8 peer_mac_addr[ETH_ALEN];
1196         __le16 del_ba_param_set;
1197         __le16 reason_code;
1198         u8 reserved;
1199 } __packed;
1200
1201 struct host_cmd_ds_11n_batimeout {
1202         u8 tid;
1203         u8 peer_mac_addr[ETH_ALEN];
1204         u8 origninator;
1205 } __packed;
1206
1207 struct host_cmd_ds_11n_cfg {
1208         __le16 action;
1209         __le16 ht_tx_cap;
1210         __le16 ht_tx_info;
1211         __le16 misc_config;     /* Needed for 802.11AC cards only */
1212 } __packed;
1213
1214 struct host_cmd_ds_txbuf_cfg {
1215         __le16 action;
1216         __le16 buff_size;
1217         __le16 mp_end_port;     /* SDIO only, reserved for other interfacces */
1218         __le16 reserved3;
1219 } __packed;
1220
1221 struct host_cmd_ds_amsdu_aggr_ctrl {
1222         __le16 action;
1223         __le16 enable;
1224         __le16 curr_buf_size;
1225 } __packed;
1226
1227 struct mwifiex_ie_types_wmm_param_set {
1228         struct mwifiex_ie_types_header header;
1229         u8 wmm_ie[1];
1230 };
1231
1232 struct mwifiex_ie_types_wmm_queue_status {
1233         struct mwifiex_ie_types_header header;
1234         u8 queue_index;
1235         u8 disabled;
1236         u16 medium_time;
1237         u8 flow_required;
1238         u8 flow_created;
1239         u32 reserved;
1240 };
1241
1242 struct ieee_types_vendor_header {
1243         u8 element_id;
1244         u8 len;
1245         u8 oui[4];      /* 0~2: oui, 3: oui_type */
1246         u8 oui_subtype;
1247         u8 version;
1248 } __packed;
1249
1250 struct ieee_types_wmm_parameter {
1251         /*
1252          * WMM Parameter IE - Vendor Specific Header:
1253          *   element_id  [221/0xdd]
1254          *   Len         [24]
1255          *   Oui         [00:50:f2]
1256          *   OuiType     [2]
1257          *   OuiSubType  [1]
1258          *   Version     [1]
1259          */
1260         struct ieee_types_vendor_header vend_hdr;
1261         u8 qos_info_bitmap;
1262         u8 reserved;
1263         struct ieee_types_wmm_ac_parameters ac_params[IEEE80211_NUM_ACS];
1264 } __packed;
1265
1266 struct ieee_types_wmm_info {
1267
1268         /*
1269          * WMM Info IE - Vendor Specific Header:
1270          *   element_id  [221/0xdd]
1271          *   Len         [7]
1272          *   Oui         [00:50:f2]
1273          *   OuiType     [2]
1274          *   OuiSubType  [0]
1275          *   Version     [1]
1276          */
1277         struct ieee_types_vendor_header vend_hdr;
1278
1279         u8 qos_info_bitmap;
1280 } __packed;
1281
1282 struct host_cmd_ds_wmm_get_status {
1283         u8 queue_status_tlv[sizeof(struct mwifiex_ie_types_wmm_queue_status) *
1284                               IEEE80211_NUM_ACS];
1285         u8 wmm_param_tlv[sizeof(struct ieee_types_wmm_parameter) + 2];
1286 } __packed;
1287
1288 struct mwifiex_wmm_ac_status {
1289         u8 disabled;
1290         u8 flow_required;
1291         u8 flow_created;
1292 };
1293
1294 struct mwifiex_ie_types_htcap {
1295         struct mwifiex_ie_types_header header;
1296         struct ieee80211_ht_cap ht_cap;
1297 } __packed;
1298
1299 struct mwifiex_ie_types_vhtcap {
1300         struct mwifiex_ie_types_header header;
1301         struct ieee80211_vht_cap vht_cap;
1302 } __packed;
1303
1304 struct mwifiex_ie_types_oper_mode_ntf {
1305         struct mwifiex_ie_types_header header;
1306         u8 oper_mode;
1307 } __packed;
1308
1309 /* VHT Operations IE */
1310 struct mwifiex_ie_types_vht_oper {
1311         struct mwifiex_ie_types_header header;
1312         u8 chan_width;
1313         u8 chan_center_freq_1;
1314         u8 chan_center_freq_2;
1315         /* Basic MCS set map, each 2 bits stands for a NSS */
1316         u16 basic_mcs_map;
1317 } __packed;
1318
1319 struct mwifiex_ie_types_wmmcap {
1320         struct mwifiex_ie_types_header header;
1321         struct mwifiex_types_wmm_info wmm_info;
1322 } __packed;
1323
1324 struct mwifiex_ie_types_htinfo {
1325         struct mwifiex_ie_types_header header;
1326         struct ieee80211_ht_operation ht_oper;
1327 } __packed;
1328
1329 struct mwifiex_ie_types_2040bssco {
1330         struct mwifiex_ie_types_header header;
1331         u8 bss_co_2040;
1332 } __packed;
1333
1334 struct mwifiex_ie_types_extcap {
1335         struct mwifiex_ie_types_header header;
1336         u8 ext_cap;
1337 } __packed;
1338
1339 struct host_cmd_ds_mac_reg_access {
1340         __le16 action;
1341         __le16 offset;
1342         __le32 value;
1343 } __packed;
1344
1345 struct host_cmd_ds_bbp_reg_access {
1346         __le16 action;
1347         __le16 offset;
1348         u8 value;
1349         u8 reserved[3];
1350 } __packed;
1351
1352 struct host_cmd_ds_rf_reg_access {
1353         __le16 action;
1354         __le16 offset;
1355         u8 value;
1356         u8 reserved[3];
1357 } __packed;
1358
1359 struct host_cmd_ds_pmic_reg_access {
1360         __le16 action;
1361         __le16 offset;
1362         u8 value;
1363         u8 reserved[3];
1364 } __packed;
1365
1366 struct host_cmd_ds_802_11_eeprom_access {
1367         __le16 action;
1368
1369         __le16 offset;
1370         __le16 byte_count;
1371         u8 value;
1372 } __packed;
1373
1374 struct host_cmd_tlv {
1375         __le16 type;
1376         __le16 len;
1377 } __packed;
1378
1379 struct mwifiex_assoc_event {
1380         u8 sta_addr[ETH_ALEN];
1381         __le16 type;
1382         __le16 len;
1383         __le16 frame_control;
1384         __le16 cap_info;
1385         __le16 listen_interval;
1386         u8 data[0];
1387 } __packed;
1388
1389 struct host_cmd_ds_sys_config {
1390         __le16 action;
1391         u8 tlv[0];
1392 };
1393
1394 struct host_cmd_tlv_akmp {
1395         struct host_cmd_tlv tlv;
1396         __le16 key_mgmt;
1397         __le16 key_mgmt_operation;
1398 } __packed;
1399
1400 struct host_cmd_tlv_pwk_cipher {
1401         struct host_cmd_tlv tlv;
1402         __le16 proto;
1403         u8 cipher;
1404         u8 reserved;
1405 } __packed;
1406
1407 struct host_cmd_tlv_gwk_cipher {
1408         struct host_cmd_tlv tlv;
1409         u8 cipher;
1410         u8 reserved;
1411 } __packed;
1412
1413 struct host_cmd_tlv_passphrase {
1414         struct host_cmd_tlv tlv;
1415         u8 passphrase[0];
1416 } __packed;
1417
1418 struct host_cmd_tlv_wep_key {
1419         struct host_cmd_tlv tlv;
1420         u8 key_index;
1421         u8 is_default;
1422         u8 key[1];
1423 };
1424
1425 struct host_cmd_tlv_auth_type {
1426         struct host_cmd_tlv tlv;
1427         u8 auth_type;
1428 } __packed;
1429
1430 struct host_cmd_tlv_encrypt_protocol {
1431         struct host_cmd_tlv tlv;
1432         __le16 proto;
1433 } __packed;
1434
1435 struct host_cmd_tlv_ssid {
1436         struct host_cmd_tlv tlv;
1437         u8 ssid[0];
1438 } __packed;
1439
1440 struct host_cmd_tlv_rates {
1441         struct host_cmd_tlv tlv;
1442         u8 rates[0];
1443 } __packed;
1444
1445 struct host_cmd_tlv_bcast_ssid {
1446         struct host_cmd_tlv tlv;
1447         u8 bcast_ctl;
1448 } __packed;
1449
1450 struct host_cmd_tlv_beacon_period {
1451         struct host_cmd_tlv tlv;
1452         __le16 period;
1453 } __packed;
1454
1455 struct host_cmd_tlv_dtim_period {
1456         struct host_cmd_tlv tlv;
1457         u8 period;
1458 } __packed;
1459
1460 struct host_cmd_tlv_frag_threshold {
1461         struct host_cmd_tlv tlv;
1462         __le16 frag_thr;
1463 } __packed;
1464
1465 struct host_cmd_tlv_rts_threshold {
1466         struct host_cmd_tlv tlv;
1467         __le16 rts_thr;
1468 } __packed;
1469
1470 struct host_cmd_tlv_retry_limit {
1471         struct host_cmd_tlv tlv;
1472         u8 limit;
1473 } __packed;
1474
1475 struct host_cmd_tlv_mac_addr {
1476         struct host_cmd_tlv tlv;
1477         u8 mac_addr[ETH_ALEN];
1478 } __packed;
1479
1480 struct host_cmd_tlv_channel_band {
1481         struct host_cmd_tlv tlv;
1482         u8 band_config;
1483         u8 channel;
1484 } __packed;
1485
1486 struct host_cmd_tlv_ageout_timer {
1487         struct host_cmd_tlv tlv;
1488         __le32 sta_ao_timer;
1489 } __packed;
1490
1491 struct host_cmd_ds_version_ext {
1492         u8 version_str_sel;
1493         char version_str[128];
1494 } __packed;
1495
1496 struct host_cmd_ds_mgmt_frame_reg {
1497         __le16 action;
1498         __le32 mask;
1499 } __packed;
1500
1501 struct host_cmd_ds_p2p_mode_cfg {
1502         __le16 action;
1503         __le16 mode;
1504 } __packed;
1505
1506 struct host_cmd_ds_remain_on_chan {
1507         __le16 action;
1508         u8 status;
1509         u8 reserved;
1510         u8 band_cfg;
1511         u8 channel;
1512         __le32 duration;
1513 } __packed;
1514
1515 struct host_cmd_ds_802_11_ibss_status {
1516         __le16 action;
1517         __le16 enable;
1518         u8 bssid[ETH_ALEN];
1519         __le16 beacon_interval;
1520         __le16 atim_window;
1521         __le16 use_g_rate_protect;
1522 } __packed;
1523
1524 struct mwifiex_fw_mef_entry {
1525         u8 mode;
1526         u8 action;
1527         __le16 exprsize;
1528         u8 expr[0];
1529 } __packed;
1530
1531 struct host_cmd_ds_mef_cfg {
1532         __le32 criteria;
1533         __le16 num_entries;
1534         struct mwifiex_fw_mef_entry mef_entry[0];
1535 } __packed;
1536
1537 #define CONNECTION_TYPE_INFRA   0
1538 #define CONNECTION_TYPE_ADHOC   1
1539 #define CONNECTION_TYPE_AP      2
1540
1541 struct host_cmd_ds_set_bss_mode {
1542         u8 con_type;
1543 } __packed;
1544
1545 struct host_cmd_ds_pcie_details {
1546         /* TX buffer descriptor ring address */
1547         u32 txbd_addr_lo;
1548         u32 txbd_addr_hi;
1549         /* TX buffer descriptor ring count */
1550         u32 txbd_count;
1551
1552         /* RX buffer descriptor ring address */
1553         u32 rxbd_addr_lo;
1554         u32 rxbd_addr_hi;
1555         /* RX buffer descriptor ring count */
1556         u32 rxbd_count;
1557
1558         /* Event buffer descriptor ring address */
1559         u32 evtbd_addr_lo;
1560         u32 evtbd_addr_hi;
1561         /* Event buffer descriptor ring count */
1562         u32 evtbd_count;
1563
1564         /* Sleep cookie buffer physical address */
1565         u32 sleep_cookie_addr_lo;
1566         u32 sleep_cookie_addr_hi;
1567 } __packed;
1568
1569 struct mwifiex_ie_types_rssi_threshold {
1570         struct mwifiex_ie_types_header header;
1571         u8 abs_value;
1572         u8 evt_freq;
1573 } __packed;
1574
1575 struct host_cmd_ds_802_11_subsc_evt {
1576         __le16 action;
1577         __le16 events;
1578 } __packed;
1579
1580 struct mwifiex_ie {
1581         __le16 ie_index;
1582         __le16 mgmt_subtype_mask;
1583         __le16 ie_length;
1584         u8 ie_buffer[IEEE_MAX_IE_SIZE];
1585 } __packed;
1586
1587 #define MAX_MGMT_IE_INDEX       16
1588 struct mwifiex_ie_list {
1589         __le16 type;
1590         __le16 len;
1591         struct mwifiex_ie ie_list[MAX_MGMT_IE_INDEX];
1592 } __packed;
1593
1594 struct host_cmd_ds_command {
1595         __le16 command;
1596         __le16 size;
1597         __le16 seq_num;
1598         __le16 result;
1599         union {
1600                 struct host_cmd_ds_get_hw_spec hw_spec;
1601                 struct host_cmd_ds_mac_control mac_ctrl;
1602                 struct host_cmd_ds_802_11_mac_address mac_addr;
1603                 struct host_cmd_ds_mac_multicast_adr mc_addr;
1604                 struct host_cmd_ds_802_11_get_log get_log;
1605                 struct host_cmd_ds_802_11_rssi_info rssi_info;
1606                 struct host_cmd_ds_802_11_rssi_info_rsp rssi_info_rsp;
1607                 struct host_cmd_ds_802_11_snmp_mib smib;
1608                 struct host_cmd_ds_tx_rate_query tx_rate;
1609                 struct host_cmd_ds_tx_rate_cfg tx_rate_cfg;
1610                 struct host_cmd_ds_txpwr_cfg txp_cfg;
1611                 struct host_cmd_ds_rf_tx_pwr txp;
1612                 struct host_cmd_ds_rf_ant_mimo ant_mimo;
1613                 struct host_cmd_ds_rf_ant_siso ant_siso;
1614                 struct host_cmd_ds_802_11_ps_mode_enh psmode_enh;
1615                 struct host_cmd_ds_802_11_hs_cfg_enh opt_hs_cfg;
1616                 struct host_cmd_ds_802_11_scan scan;
1617                 struct host_cmd_ds_802_11_scan_rsp scan_resp;
1618                 struct host_cmd_ds_802_11_bg_scan_query bg_scan_query;
1619                 struct host_cmd_ds_802_11_bg_scan_query_rsp bg_scan_query_resp;
1620                 struct host_cmd_ds_802_11_associate associate;
1621                 struct host_cmd_ds_802_11_associate_rsp associate_rsp;
1622                 struct host_cmd_ds_802_11_deauthenticate deauth;
1623                 struct host_cmd_ds_802_11_ad_hoc_start adhoc_start;
1624                 struct host_cmd_ds_802_11_ad_hoc_result adhoc_result;
1625                 struct host_cmd_ds_802_11_ad_hoc_join adhoc_join;
1626                 struct host_cmd_ds_802_11d_domain_info domain_info;
1627                 struct host_cmd_ds_802_11d_domain_info_rsp domain_info_resp;
1628                 struct host_cmd_ds_11n_addba_req add_ba_req;
1629                 struct host_cmd_ds_11n_addba_rsp add_ba_rsp;
1630                 struct host_cmd_ds_11n_delba del_ba;
1631                 struct host_cmd_ds_txbuf_cfg tx_buf;
1632                 struct host_cmd_ds_amsdu_aggr_ctrl amsdu_aggr_ctrl;
1633                 struct host_cmd_ds_11n_cfg htcfg;
1634                 struct host_cmd_ds_wmm_get_status get_wmm_status;
1635                 struct host_cmd_ds_802_11_key_material key_material;
1636                 struct host_cmd_ds_version_ext verext;
1637                 struct host_cmd_ds_mgmt_frame_reg reg_mask;
1638                 struct host_cmd_ds_remain_on_chan roc_cfg;
1639                 struct host_cmd_ds_p2p_mode_cfg mode_cfg;
1640                 struct host_cmd_ds_802_11_ibss_status ibss_coalescing;
1641                 struct host_cmd_ds_mef_cfg mef_cfg;
1642                 struct host_cmd_ds_mac_reg_access mac_reg;
1643                 struct host_cmd_ds_bbp_reg_access bbp_reg;
1644                 struct host_cmd_ds_rf_reg_access rf_reg;
1645                 struct host_cmd_ds_pmic_reg_access pmic_reg;
1646                 struct host_cmd_ds_set_bss_mode bss_mode;
1647                 struct host_cmd_ds_pcie_details pcie_host_spec;
1648                 struct host_cmd_ds_802_11_eeprom_access eeprom;
1649                 struct host_cmd_ds_802_11_subsc_evt subsc_evt;
1650                 struct host_cmd_ds_sys_config uap_sys_config;
1651         } params;
1652 } __packed;
1653
1654 struct mwifiex_opt_sleep_confirm {
1655         __le16 command;
1656         __le16 size;
1657         __le16 seq_num;
1658         __le16 result;
1659         __le16 action;
1660         __le16 resp_ctrl;
1661 } __packed;
1662 #endif /* !_MWIFIEX_FW_H_ */