1 /*
2  * Copyright (c) 2012 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 
18 #ifndef FWIL_TYPES_H_
19 #define FWIL_TYPES_H_
20 
21 #include <linux/if_ether.h>
22 
23 
24 #define BRCMF_FIL_ACTION_FRAME_SIZE	1800
25 
26 /* ARP Offload feature flags for arp_ol iovar */
27 #define BRCMF_ARP_OL_AGENT		0x00000001
28 #define BRCMF_ARP_OL_SNOOP		0x00000002
29 #define BRCMF_ARP_OL_HOST_AUTO_REPLY	0x00000004
30 #define BRCMF_ARP_OL_PEER_AUTO_REPLY	0x00000008
31 
32 #define	BRCMF_BSS_INFO_VERSION	109 /* curr ver of brcmf_bss_info_le struct */
33 #define BRCMF_BSS_RSSI_ON_CHANNEL	0x0002
34 
35 #define BRCMF_STA_BRCM			0x00000001	/* Running a Broadcom driver */
36 #define BRCMF_STA_WME			0x00000002	/* WMM association */
37 #define BRCMF_STA_NONERP		0x00000004	/* No ERP */
38 #define BRCMF_STA_AUTHE			0x00000008	/* Authenticated */
39 #define BRCMF_STA_ASSOC			0x00000010	/* Associated */
40 #define BRCMF_STA_AUTHO			0x00000020	/* Authorized */
41 #define BRCMF_STA_WDS			0x00000040	/* Wireless Distribution System */
42 #define BRCMF_STA_WDS_LINKUP		0x00000080	/* WDS traffic/probes flowing properly */
43 #define BRCMF_STA_PS			0x00000100	/* STA is in power save mode from AP's viewpoint */
44 #define BRCMF_STA_APSD_BE		0x00000200	/* APSD delv/trigger for AC_BE is default enabled */
45 #define BRCMF_STA_APSD_BK		0x00000400	/* APSD delv/trigger for AC_BK is default enabled */
46 #define BRCMF_STA_APSD_VI		0x00000800	/* APSD delv/trigger for AC_VI is default enabled */
47 #define BRCMF_STA_APSD_VO		0x00001000	/* APSD delv/trigger for AC_VO is default enabled */
48 #define BRCMF_STA_N_CAP			0x00002000	/* STA 802.11n capable */
49 #define BRCMF_STA_SCBSTATS		0x00004000	/* Per STA debug stats */
50 #define BRCMF_STA_AMPDU_CAP		0x00008000	/* STA AMPDU capable */
51 #define BRCMF_STA_AMSDU_CAP		0x00010000	/* STA AMSDU capable */
52 #define BRCMF_STA_MIMO_PS		0x00020000	/* mimo ps mode is enabled */
53 #define BRCMF_STA_MIMO_RTS		0x00040000	/* send rts in mimo ps mode */
54 #define BRCMF_STA_RIFS_CAP		0x00080000	/* rifs enabled */
55 #define BRCMF_STA_VHT_CAP		0x00100000	/* STA VHT(11ac) capable */
56 #define BRCMF_STA_WPS			0x00200000	/* WPS state */
57 #define BRCMF_STA_DWDS_CAP		0x01000000	/* DWDS CAP */
58 #define BRCMF_STA_DWDS			0x02000000	/* DWDS active */
59 
60 /* size of brcmf_scan_params not including variable length array */
61 #define BRCMF_SCAN_PARAMS_FIXED_SIZE	64
62 
63 /* masks for channel and ssid count */
64 #define BRCMF_SCAN_PARAMS_COUNT_MASK	0x0000ffff
65 #define BRCMF_SCAN_PARAMS_NSSID_SHIFT	16
66 
67 /* scan type definitions */
68 #define BRCMF_SCANTYPE_DEFAULT		0xFF
69 #define BRCMF_SCANTYPE_ACTIVE		0
70 #define BRCMF_SCANTYPE_PASSIVE		1
71 
72 #define BRCMF_WSEC_MAX_PSK_LEN		32
73 #define	BRCMF_WSEC_PASSPHRASE		BIT(0)
74 
75 /* primary (ie tx) key */
76 #define BRCMF_PRIMARY_KEY		(1 << 1)
77 #define DOT11_BSSTYPE_ANY		2
78 #define BRCMF_ESCAN_REQ_VERSION		1
79 
80 #define BRCMF_MAXRATES_IN_SET		16	/* max # of rates in rateset */
81 
82 /* OBSS Coex Auto/On/Off */
83 #define BRCMF_OBSS_COEX_AUTO		(-1)
84 #define BRCMF_OBSS_COEX_OFF		0
85 #define BRCMF_OBSS_COEX_ON		1
86 
87 /* WOWL bits */
88 /* Wakeup on Magic packet: */
89 #define BRCMF_WOWL_MAGIC		(1 << 0)
90 /* Wakeup on Netpattern */
91 #define BRCMF_WOWL_NET			(1 << 1)
92 /* Wakeup on loss-of-link due to Disassoc/Deauth: */
93 #define BRCMF_WOWL_DIS			(1 << 2)
94 /* Wakeup on retrograde TSF: */
95 #define BRCMF_WOWL_RETR			(1 << 3)
96 /* Wakeup on loss of beacon: */
97 #define BRCMF_WOWL_BCN			(1 << 4)
98 /* Wakeup after test: */
99 #define BRCMF_WOWL_TST			(1 << 5)
100 /* Wakeup after PTK refresh: */
101 #define BRCMF_WOWL_M1			(1 << 6)
102 /* Wakeup after receipt of EAP-Identity Req: */
103 #define BRCMF_WOWL_EAPID		(1 << 7)
104 /* Wakeind via PME(0) or GPIO(1): */
105 #define BRCMF_WOWL_PME_GPIO		(1 << 8)
106 /* need tkip phase 1 key to be updated by the driver: */
107 #define BRCMF_WOWL_NEEDTKIP1		(1 << 9)
108 /* enable wakeup if GTK fails: */
109 #define BRCMF_WOWL_GTK_FAILURE		(1 << 10)
110 /* support extended magic packets: */
111 #define BRCMF_WOWL_EXTMAGPAT		(1 << 11)
112 /* support ARP/NS/keepalive offloading: */
113 #define BRCMF_WOWL_ARPOFFLOAD		(1 << 12)
114 /* read protocol version for EAPOL frames: */
115 #define BRCMF_WOWL_WPA2			(1 << 13)
116 /* If the bit is set, use key rotaton: */
117 #define BRCMF_WOWL_KEYROT		(1 << 14)
118 /* If the bit is set, frm received was bcast frame: */
119 #define BRCMF_WOWL_BCAST		(1 << 15)
120 /* If the bit is set, scan offload is enabled: */
121 #define BRCMF_WOWL_SCANOL		(1 << 16)
122 /* Wakeup on tcpkeep alive timeout: */
123 #define BRCMF_WOWL_TCPKEEP_TIME		(1 << 17)
124 /* Wakeup on mDNS Conflict Resolution: */
125 #define BRCMF_WOWL_MDNS_CONFLICT	(1 << 18)
126 /* Wakeup on mDNS Service Connect: */
127 #define BRCMF_WOWL_MDNS_SERVICE		(1 << 19)
128 /* tcp keepalive got data: */
129 #define BRCMF_WOWL_TCPKEEP_DATA		(1 << 20)
130 /* Firmware died in wowl mode: */
131 #define BRCMF_WOWL_FW_HALT		(1 << 21)
132 /* Enable detection of radio button changes: */
133 #define BRCMF_WOWL_ENAB_HWRADIO		(1 << 22)
134 /* Offloads detected MIC failure(s): */
135 #define BRCMF_WOWL_MIC_FAIL		(1 << 23)
136 /* Wakeup in Unassociated state (Net/Magic Pattern): */
137 #define BRCMF_WOWL_UNASSOC		(1 << 24)
138 /* Wakeup if received matched secured pattern: */
139 #define BRCMF_WOWL_SECURE		(1 << 25)
140 /* Wakeup on finding preferred network */
141 #define BRCMF_WOWL_PFN_FOUND		(1 << 27)
142 /* Wakeup on receiving pairwise key EAP packets: */
143 #define WIPHY_WOWL_EAP_PK		(1 << 28)
144 /* Link Down indication in WoWL mode: */
145 #define BRCMF_WOWL_LINKDOWN		(1 << 31)
146 
147 #define BRCMF_WOWL_MAXPATTERNS		8
148 #define BRCMF_WOWL_MAXPATTERNSIZE	128
149 
150 #define BRCMF_COUNTRY_BUF_SZ		4
151 #define BRCMF_ANT_MAX			4
152 
153 #define BRCMF_MAX_ASSOCLIST		128
154 
155 #define BRCMF_TXBF_SU_BFE_CAP		BIT(0)
156 #define BRCMF_TXBF_MU_BFE_CAP		BIT(1)
157 #define BRCMF_TXBF_SU_BFR_CAP		BIT(0)
158 #define BRCMF_TXBF_MU_BFR_CAP		BIT(1)
159 
160 #define	BRCMF_MAXPMKID			16	/* max # PMKID cache entries */
161 #define BRCMF_NUMCHANNELS		64
162 
163 #define BRCMF_PFN_MACADDR_CFG_VER	1
164 #define BRCMF_PFN_MAC_OUI_ONLY		BIT(0)
165 #define BRCMF_PFN_SET_MAC_UNASSOC	BIT(1)
166 
167 #define BRCMF_MCSSET_LEN		16
168 
169 #define BRCMF_RSN_KCK_LENGTH		16
170 #define BRCMF_RSN_KEK_LENGTH		16
171 #define BRCMF_RSN_REPLAY_LEN		8
172 
173 #define BRCMF_MFP_NONE			0
174 #define BRCMF_MFP_CAPABLE		1
175 #define BRCMF_MFP_REQUIRED		2
176 
177 #define BRCMF_VHT_CAP_MCS_MAP_NSS_MAX	8
178 
179 /* MAX_CHUNK_LEN is the maximum length for data passing to firmware in each
180  * ioctl. It is relatively small because firmware has small maximum size input
181  * playload restriction for ioctls.
182  */
183 #define MAX_CHUNK_LEN			1400
184 
185 #define DLOAD_HANDLER_VER		1	/* Downloader version */
186 #define DLOAD_FLAG_VER_MASK		0xf000	/* Downloader version mask */
187 #define DLOAD_FLAG_VER_SHIFT		12	/* Downloader version shift */
188 
189 #define DL_BEGIN			0x0002
190 #define DL_END				0x0004
191 
192 #define DL_TYPE_CLM			2
193 
194 /* join preference types for join_pref iovar */
195 enum brcmf_join_pref_types {
196 	BRCMF_JOIN_PREF_RSSI = 1,
197 	BRCMF_JOIN_PREF_WPA,
198 	BRCMF_JOIN_PREF_BAND,
199 	BRCMF_JOIN_PREF_RSSI_DELTA,
200 };
201 
202 enum brcmf_fil_p2p_if_types {
203 	BRCMF_FIL_P2P_IF_CLIENT,
204 	BRCMF_FIL_P2P_IF_GO,
205 	BRCMF_FIL_P2P_IF_DYNBCN_GO,
206 	BRCMF_FIL_P2P_IF_DEV,
207 };
208 
209 enum brcmf_wowl_pattern_type {
210 	BRCMF_WOWL_PATTERN_TYPE_BITMAP = 0,
211 	BRCMF_WOWL_PATTERN_TYPE_ARP,
212 	BRCMF_WOWL_PATTERN_TYPE_NA
213 };
214 
215 struct brcmf_fil_p2p_if_le {
216 	u8 addr[ETH_ALEN];
217 	__le16 type;
218 	__le16 chspec;
219 };
220 
221 struct brcmf_fil_chan_info_le {
222 	__le32 hw_channel;
223 	__le32 target_channel;
224 	__le32 scan_channel;
225 };
226 
227 struct brcmf_fil_action_frame_le {
228 	u8	da[ETH_ALEN];
229 	__le16	len;
230 	__le32	packet_id;
231 	u8	data[BRCMF_FIL_ACTION_FRAME_SIZE];
232 };
233 
234 struct brcmf_fil_af_params_le {
235 	__le32					channel;
236 	__le32					dwell_time;
237 	u8					bssid[ETH_ALEN];
238 	u8					pad[2];
239 	struct brcmf_fil_action_frame_le	action_frame;
240 };
241 
242 struct brcmf_fil_bss_enable_le {
243 	__le32 bsscfgidx;
244 	__le32 enable;
245 };
246 
247 struct brcmf_fil_bwcap_le {
248 	__le32 band;
249 	__le32 bw_cap;
250 };
251 
252 /**
253  * struct tdls_iovar - common structure for tdls iovars.
254  *
255  * @ea: ether address of peer station.
256  * @mode: mode value depending on specific tdls iovar.
257  * @chanspec: channel specification.
258  * @pad: unused (for future use).
259  */
260 struct brcmf_tdls_iovar_le {
261 	u8 ea[ETH_ALEN];		/* Station address */
262 	u8 mode;			/* mode: depends on iovar */
263 	__le16 chanspec;
264 	__le32 pad;			/* future */
265 };
266 
267 enum brcmf_tdls_manual_ep_ops {
268 	BRCMF_TDLS_MANUAL_EP_CREATE = 1,
269 	BRCMF_TDLS_MANUAL_EP_DELETE = 3,
270 	BRCMF_TDLS_MANUAL_EP_DISCOVERY = 6
271 };
272 
273 /* Pattern matching filter. Specifies an offset within received packets to
274  * start matching, the pattern to match, the size of the pattern, and a bitmask
275  * that indicates which bits within the pattern should be matched.
276  */
277 struct brcmf_pkt_filter_pattern_le {
278 	/*
279 	 * Offset within received packet to start pattern matching.
280 	 * Offset '0' is the first byte of the ethernet header.
281 	 */
282 	__le32 offset;
283 	/* Size of the pattern.  Bitmask must be the same size.*/
284 	__le32 size_bytes;
285 	/*
286 	 * Variable length mask and pattern data. mask starts at offset 0.
287 	 * Pattern immediately follows mask.
288 	 */
289 	u8 mask_and_pattern[1];
290 };
291 
292 /* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
293 struct brcmf_pkt_filter_le {
294 	__le32 id;		/* Unique filter id, specified by app. */
295 	__le32 type;		/* Filter type (WL_PKT_FILTER_TYPE_xxx). */
296 	__le32 negate_match;	/* Negate the result of filter matches */
297 	union {			/* Filter definitions */
298 		struct brcmf_pkt_filter_pattern_le pattern; /* Filter pattern */
299 	} u;
300 };
301 
302 /* IOVAR "pkt_filter_enable" parameter. */
303 struct brcmf_pkt_filter_enable_le {
304 	__le32 id;		/* Unique filter id */
305 	__le32 enable;		/* Enable/disable bool */
306 };
307 
308 /* BSS info structure
309  * Applications MUST CHECK ie_offset field and length field to access IEs and
310  * next bss_info structure in a vector (in struct brcmf_scan_results)
311  */
312 struct brcmf_bss_info_le {
313 	__le32 version;		/* version field */
314 	__le32 length;		/* byte length of data in this record,
315 				 * starting at version and including IEs
316 				 */
317 	u8 BSSID[ETH_ALEN];
318 	__le16 beacon_period;	/* units are Kusec */
319 	__le16 capability;	/* Capability information */
320 	u8 SSID_len;
321 	u8 SSID[32];
322 	struct {
323 		__le32 count;   /* # rates in this set */
324 		u8 rates[16]; /* rates in 500kbps units w/hi bit set if basic */
325 	} rateset;		/* supported rates */
326 	__le16 chanspec;	/* chanspec for bss */
327 	__le16 atim_window;	/* units are Kusec */
328 	u8 dtim_period;	/* DTIM period */
329 	__le16 RSSI;		/* receive signal strength (in dBm) */
330 	s8 phy_noise;		/* noise (in dBm) */
331 
332 	u8 n_cap;		/* BSS is 802.11N Capable */
333 	/* 802.11N BSS Capabilities (based on HT_CAP_*): */
334 	__le32 nbss_cap;
335 	u8 ctl_ch;		/* 802.11N BSS control channel number */
336 	__le32 reserved32[1];	/* Reserved for expansion of BSS properties */
337 	u8 flags;		/* flags */
338 	u8 reserved[3];	/* Reserved for expansion of BSS properties */
339 	u8 basic_mcs[BRCMF_MCSSET_LEN];	/* 802.11N BSS required MCS set */
340 
341 	__le16 ie_offset;	/* offset at which IEs start, from beginning */
342 	__le32 ie_length;	/* byte length of Information Elements */
343 	__le16 SNR;		/* average SNR of during frame reception */
344 	/* Add new fields here */
345 	/* variable length Information Elements */
346 };
347 
348 struct brcm_rateset_le {
349 	/* # rates in this set */
350 	__le32 count;
351 	/* rates in 500kbps units w/hi bit set if basic */
352 	u8 rates[BRCMF_MAXRATES_IN_SET];
353 };
354 
355 struct brcmf_ssid_le {
356 	__le32 SSID_len;
357 	unsigned char SSID[IEEE80211_MAX_SSID_LEN];
358 };
359 
360 struct brcmf_scan_params_le {
361 	struct brcmf_ssid_le ssid_le;	/* default: {0, ""} */
362 	u8 bssid[ETH_ALEN];	/* default: bcast */
363 	s8 bss_type;		/* default: any,
364 				 * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT
365 				 */
366 	u8 scan_type;	/* flags, 0 use default */
367 	__le32 nprobes;	  /* -1 use default, number of probes per channel */
368 	__le32 active_time;	/* -1 use default, dwell time per channel for
369 				 * active scanning
370 				 */
371 	__le32 passive_time;	/* -1 use default, dwell time per channel
372 				 * for passive scanning
373 				 */
374 	__le32 home_time;	/* -1 use default, dwell time for the
375 				 * home channel between channel scans
376 				 */
377 	__le32 channel_num;	/* count of channels and ssids that follow
378 				 *
379 				 * low half is count of channels in
380 				 * channel_list, 0 means default (use all
381 				 * available channels)
382 				 *
383 				 * high half is entries in struct brcmf_ssid
384 				 * array that follows channel_list, aligned for
385 				 * s32 (4 bytes) meaning an odd channel count
386 				 * implies a 2-byte pad between end of
387 				 * channel_list and first ssid
388 				 *
389 				 * if ssid count is zero, single ssid in the
390 				 * fixed parameter portion is assumed, otherwise
391 				 * ssid in the fixed portion is ignored
392 				 */
393 	__le16 channel_list[1];	/* list of chanspecs */
394 };
395 
396 struct brcmf_scan_results {
397 	u32 buflen;
398 	u32 version;
399 	u32 count;
400 	struct brcmf_bss_info_le bss_info_le[];
401 };
402 
403 struct brcmf_escan_params_le {
404 	__le32 version;
405 	__le16 action;
406 	__le16 sync_id;
407 	struct brcmf_scan_params_le params_le;
408 };
409 
410 struct brcmf_escan_result_le {
411 	__le32 buflen;
412 	__le32 version;
413 	__le16 sync_id;
414 	__le16 bss_count;
415 	struct brcmf_bss_info_le bss_info_le;
416 };
417 
418 #define WL_ESCAN_RESULTS_FIXED_SIZE (sizeof(struct brcmf_escan_result_le) - \
419 	sizeof(struct brcmf_bss_info_le))
420 
421 /* used for association with a specific BSSID and chanspec list */
422 struct brcmf_assoc_params_le {
423 	/* 00:00:00:00:00:00: broadcast scan */
424 	u8 bssid[ETH_ALEN];
425 	/* 0: all available channels, otherwise count of chanspecs in
426 	 * chanspec_list */
427 	__le32 chanspec_num;
428 	/* list of chanspecs */
429 	__le16 chanspec_list[1];
430 };
431 
432 /**
433  * struct join_pref params - parameters for preferred join selection.
434  *
435  * @type: preference type (see enum brcmf_join_pref_types).
436  * @len: length of bytes following (currently always 2).
437  * @rssi_gain: signal gain for selection (only when @type is RSSI_DELTA).
438  * @band: band to which selection preference applies.
439  *	This is used if @type is BAND or RSSI_DELTA.
440  */
441 struct brcmf_join_pref_params {
442 	u8 type;
443 	u8 len;
444 	u8 rssi_gain;
445 	u8 band;
446 };
447 
448 /* used for join with or without a specific bssid and channel list */
449 struct brcmf_join_params {
450 	struct brcmf_ssid_le ssid_le;
451 	struct brcmf_assoc_params_le params_le;
452 };
453 
454 /* scan params for extended join */
455 struct brcmf_join_scan_params_le {
456 	u8 scan_type;		/* 0 use default, active or passive scan */
457 	__le32 nprobes;		/* -1 use default, nr of probes per channel */
458 	__le32 active_time;	/* -1 use default, dwell time per channel for
459 				 * active scanning
460 				 */
461 	__le32 passive_time;	/* -1 use default, dwell time per channel
462 				 * for passive scanning
463 				 */
464 	__le32 home_time;	/* -1 use default, dwell time for the home
465 				 * channel between channel scans
466 				 */
467 };
468 
469 /* extended join params */
470 struct brcmf_ext_join_params_le {
471 	struct brcmf_ssid_le ssid_le;	/* {0, ""}: wildcard scan */
472 	struct brcmf_join_scan_params_le scan_le;
473 	struct brcmf_assoc_params_le assoc_le;
474 };
475 
476 struct brcmf_wsec_key {
477 	u32 index;		/* key index */
478 	u32 len;		/* key length */
479 	u8 data[WLAN_MAX_KEY_LEN];	/* key data */
480 	u32 pad_1[18];
481 	u32 algo;	/* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
482 	u32 flags;	/* misc flags */
483 	u32 pad_2[3];
484 	u32 iv_initialized;	/* has IV been initialized already? */
485 	u32 pad_3;
486 	/* Rx IV */
487 	struct {
488 		u32 hi;	/* upper 32 bits of IV */
489 		u16 lo;	/* lower 16 bits of IV */
490 	} rxiv;
491 	u32 pad_4[2];
492 	u8 ea[ETH_ALEN];	/* per station */
493 };
494 
495 /*
496  * dongle requires same struct as above but with fields in little endian order
497  */
498 struct brcmf_wsec_key_le {
499 	__le32 index;		/* key index */
500 	__le32 len;		/* key length */
501 	u8 data[WLAN_MAX_KEY_LEN];	/* key data */
502 	__le32 pad_1[18];
503 	__le32 algo;	/* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
504 	__le32 flags;	/* misc flags */
505 	__le32 pad_2[3];
506 	__le32 iv_initialized;	/* has IV been initialized already? */
507 	__le32 pad_3;
508 	/* Rx IV */
509 	struct {
510 		__le32 hi;	/* upper 32 bits of IV */
511 		__le16 lo;	/* lower 16 bits of IV */
512 	} rxiv;
513 	__le32 pad_4[2];
514 	u8 ea[ETH_ALEN];	/* per station */
515 };
516 
517 /**
518  * struct brcmf_wsec_pmk_le - firmware pmk material.
519  *
520  * @key_len: number of octets in key material.
521  * @flags: key handling qualifiers.
522  * @key: PMK key material.
523  */
524 struct brcmf_wsec_pmk_le {
525 	__le16  key_len;
526 	__le16  flags;
527 	u8 key[2 * BRCMF_WSEC_MAX_PSK_LEN + 1];
528 };
529 
530 /* Used to get specific STA parameters */
531 struct brcmf_scb_val_le {
532 	__le32 val;
533 	u8 ea[ETH_ALEN];
534 };
535 
536 /* channel encoding */
537 struct brcmf_channel_info_le {
538 	__le32 hw_channel;
539 	__le32 target_channel;
540 	__le32 scan_channel;
541 };
542 
543 struct brcmf_sta_info_le {
544 	__le16 ver;		/* version of this struct */
545 	__le16 len;		/* length in bytes of this structure */
546 	__le16 cap;		/* sta's advertised capabilities */
547 	__le32 flags;		/* flags defined below */
548 	__le32 idle;		/* time since data pkt rx'd from sta */
549 	u8 ea[ETH_ALEN];		/* Station address */
550 	__le32 count;			/* # rates in this set */
551 	u8 rates[BRCMF_MAXRATES_IN_SET];	/* rates in 500kbps units */
552 						/* w/hi bit set if basic */
553 	__le32 in;		/* seconds elapsed since associated */
554 	__le32 listen_interval_inms; /* Min Listen interval in ms for STA */
555 
556 	/* Fields valid for ver >= 3 */
557 	__le32 tx_pkts;	/* # of packets transmitted */
558 	__le32 tx_failures;	/* # of packets failed */
559 	__le32 rx_ucast_pkts;	/* # of unicast packets received */
560 	__le32 rx_mcast_pkts;	/* # of multicast packets received */
561 	__le32 tx_rate;	/* Rate of last successful tx frame */
562 	__le32 rx_rate;	/* Rate of last successful rx frame */
563 	__le32 rx_decrypt_succeeds;	/* # of packet decrypted successfully */
564 	__le32 rx_decrypt_failures;	/* # of packet decrypted failed */
565 
566 	/* Fields valid for ver >= 4 */
567 	__le32 tx_tot_pkts;    /* # of tx pkts (ucast + mcast) */
568 	__le32 rx_tot_pkts;    /* # of data packets recvd (uni + mcast) */
569 	__le32 tx_mcast_pkts;  /* # of mcast pkts txed */
570 	__le64 tx_tot_bytes;   /* data bytes txed (ucast + mcast) */
571 	__le64 rx_tot_bytes;   /* data bytes recvd (ucast + mcast) */
572 	__le64 tx_ucast_bytes; /* data bytes txed (ucast) */
573 	__le64 tx_mcast_bytes; /* # data bytes txed (mcast) */
574 	__le64 rx_ucast_bytes; /* data bytes recvd (ucast) */
575 	__le64 rx_mcast_bytes; /* data bytes recvd (mcast) */
576 	s8 rssi[BRCMF_ANT_MAX];   /* per antenna rssi */
577 	s8 nf[BRCMF_ANT_MAX];     /* per antenna noise floor */
578 	__le16 aid;                    /* association ID */
579 	__le16 ht_capabilities;        /* advertised ht caps */
580 	__le16 vht_flags;              /* converted vht flags */
581 	__le32 tx_pkts_retry_cnt;      /* # of frames where a retry was
582 					 * exhausted.
583 					 */
584 	__le32 tx_pkts_retry_exhausted; /* # of user frames where a retry
585 					 * was exhausted
586 					 */
587 	s8 rx_lastpkt_rssi[BRCMF_ANT_MAX]; /* Per antenna RSSI of last
588 					    * received data frame.
589 					    */
590 	/* TX WLAN retry/failure statistics:
591 	 * Separated for host requested frames and locally generated frames.
592 	 * Include unicast frame only where the retries/failures can be counted.
593 	 */
594 	__le32 tx_pkts_total;          /* # user frames sent successfully */
595 	__le32 tx_pkts_retries;        /* # user frames retries */
596 	__le32 tx_pkts_fw_total;       /* # FW generated sent successfully */
597 	__le32 tx_pkts_fw_retries;     /* # retries for FW generated frames */
598 	__le32 tx_pkts_fw_retry_exhausted;     /* # FW generated where a retry
599 						* was exhausted
600 						*/
601 	__le32 rx_pkts_retried;        /* # rx with retry bit set */
602 	__le32 tx_rate_fallback;       /* lowest fallback TX rate */
603 
604 	/* Fields valid for ver >= 5 */
605 	struct {
606 		__le32 count;					/* # rates in this set */
607 		u8 rates[BRCMF_MAXRATES_IN_SET];		/* rates in 500kbps units w/hi bit set if basic */
608 		u8 mcs[BRCMF_MCSSET_LEN];			/* supported mcs index bit map */
609 		__le16 vht_mcs[BRCMF_VHT_CAP_MCS_MAP_NSS_MAX];	/* supported mcs index bit map per nss */
610 	} rateset_adv;
611 };
612 
613 struct brcmf_chanspec_list {
614 	__le32	count;		/* # of entries */
615 	__le32	element[1];	/* variable length uint32 list */
616 };
617 
618 /*
619  * WLC_E_PROBRESP_MSG
620  * WLC_E_P2P_PROBREQ_MSG
621  * WLC_E_ACTION_FRAME_RX
622  */
623 struct brcmf_rx_mgmt_data {
624 	__be16	version;
625 	__be16	chanspec;
626 	__be32	rssi;
627 	__be32	mactime;
628 	__be32	rate;
629 };
630 
631 /**
632  * struct brcmf_fil_wowl_pattern_le - wowl pattern configuration struct.
633  *
634  * @cmd: "add", "del" or "clr".
635  * @masksize: Size of the mask in #of bytes
636  * @offset: Pattern byte offset in packet
637  * @patternoffset: Offset of start of pattern. Starting from field masksize.
638  * @patternsize: Size of the pattern itself in #of bytes
639  * @id: id
640  * @reasonsize: Size of the wakeup reason code
641  * @type: Type of pattern (enum brcmf_wowl_pattern_type)
642  */
643 struct brcmf_fil_wowl_pattern_le {
644 	u8	cmd[4];
645 	__le32	masksize;
646 	__le32	offset;
647 	__le32	patternoffset;
648 	__le32	patternsize;
649 	__le32	id;
650 	__le32	reasonsize;
651 	__le32	type;
652 	/* u8 mask[] - Mask follows the structure above */
653 	/* u8 pattern[] - Pattern follows the mask is at 'patternoffset' */
654 };
655 
656 struct brcmf_mbss_ssid_le {
657 	__le32	bsscfgidx;
658 	__le32	SSID_len;
659 	unsigned char SSID[32];
660 };
661 
662 /**
663  * struct brcmf_fil_country_le - country configuration structure.
664  *
665  * @country_abbrev: null-terminated country code used in the country IE.
666  * @rev: revision specifier for ccode. on set, -1 indicates unspecified.
667  * @ccode: null-terminated built-in country code.
668  */
669 struct brcmf_fil_country_le {
670 	char country_abbrev[BRCMF_COUNTRY_BUF_SZ];
671 	__le32 rev;
672 	char ccode[BRCMF_COUNTRY_BUF_SZ];
673 };
674 
675 /**
676  * struct brcmf_rev_info_le - device revision info.
677  *
678  * @vendorid: PCI vendor id.
679  * @deviceid: device id of chip.
680  * @radiorev: radio revision.
681  * @chiprev: chip revision.
682  * @corerev: core revision.
683  * @boardid: board identifier (usu. PCI sub-device id).
684  * @boardvendor: board vendor (usu. PCI sub-vendor id).
685  * @boardrev: board revision.
686  * @driverrev: driver version.
687  * @ucoderev: microcode version.
688  * @bus: bus type.
689  * @chipnum: chip number.
690  * @phytype: phy type.
691  * @phyrev: phy revision.
692  * @anarev: anacore rev.
693  * @chippkg: chip package info.
694  * @nvramrev: nvram revision number.
695  */
696 struct brcmf_rev_info_le {
697 	__le32 vendorid;
698 	__le32 deviceid;
699 	__le32 radiorev;
700 	__le32 chiprev;
701 	__le32 corerev;
702 	__le32 boardid;
703 	__le32 boardvendor;
704 	__le32 boardrev;
705 	__le32 driverrev;
706 	__le32 ucoderev;
707 	__le32 bus;
708 	__le32 chipnum;
709 	__le32 phytype;
710 	__le32 phyrev;
711 	__le32 anarev;
712 	__le32 chippkg;
713 	__le32 nvramrev;
714 };
715 
716 /**
717  * struct brcmf_assoclist_le - request assoc list.
718  *
719  * @count: indicates number of stations.
720  * @mac: MAC addresses of stations.
721  */
722 struct brcmf_assoclist_le {
723 	__le32 count;
724 	u8 mac[BRCMF_MAX_ASSOCLIST][ETH_ALEN];
725 };
726 
727 /**
728  * struct brcmf_wowl_wakeind_le - Wakeup indicators
729  *	Note: note both fields contain same information.
730  *
731  * @pci_wakeind: Whether PCI PMECSR PMEStatus bit was set.
732  * @ucode_wakeind: What wakeup-event indication was set by ucode
733  */
734 struct brcmf_wowl_wakeind_le {
735 	__le32 pci_wakeind;
736 	__le32 ucode_wakeind;
737 };
738 
739 /**
740  * struct brcmf_pmksa - PMK Security Association
741  *
742  * @bssid: The AP's BSSID.
743  * @pmkid: he PMK material itself.
744  */
745 struct brcmf_pmksa {
746 	u8 bssid[ETH_ALEN];
747 	u8 pmkid[WLAN_PMKID_LEN];
748 };
749 
750 /**
751  * struct brcmf_pmk_list_le - List of pmksa's.
752  *
753  * @npmk: Number of pmksa's.
754  * @pmk: PMK SA information.
755  */
756 struct brcmf_pmk_list_le {
757 	__le32 npmk;
758 	struct brcmf_pmksa pmk[BRCMF_MAXPMKID];
759 };
760 
761 /**
762  * struct brcmf_pno_param_le - PNO scan configuration parameters
763  *
764  * @version: PNO parameters version.
765  * @scan_freq: scan frequency.
766  * @lost_network_timeout: #sec. to declare discovered network as lost.
767  * @flags: Bit field to control features of PFN such as sort criteria auto
768  *	enable switch and background scan.
769  * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort
770  *	criteria.
771  * @bestn: number of best networks in each scan.
772  * @mscan: number of scans recorded.
773  * @repeat: minimum number of scan intervals before scan frequency changes
774  *	in adaptive scan.
775  * @exp: exponent of 2 for maximum scan interval.
776  * @slow_freq: slow scan period.
777  */
778 struct brcmf_pno_param_le {
779 	__le32 version;
780 	__le32 scan_freq;
781 	__le32 lost_network_timeout;
782 	__le16 flags;
783 	__le16 rssi_margin;
784 	u8 bestn;
785 	u8 mscan;
786 	u8 repeat;
787 	u8 exp;
788 	__le32 slow_freq;
789 };
790 
791 /**
792  * struct brcmf_pno_config_le - PNO channel configuration.
793  *
794  * @reporttype: determines what is reported.
795  * @channel_num: number of channels specified in @channel_list.
796  * @channel_list: channels to use in PNO scan.
797  * @flags: reserved.
798  */
799 struct brcmf_pno_config_le {
800 	__le32  reporttype;
801 	__le32  channel_num;
802 	__le16  channel_list[BRCMF_NUMCHANNELS];
803 	__le32  flags;
804 };
805 
806 /**
807  * struct brcmf_pno_net_param_le - scan parameters per preferred network.
808  *
809  * @ssid: ssid name and its length.
810  * @flags: bit2: hidden.
811  * @infra: BSS vs IBSS.
812  * @auth: Open vs Closed.
813  * @wpa_auth: WPA type.
814  * @wsec: wsec value.
815  */
816 struct brcmf_pno_net_param_le {
817 	struct brcmf_ssid_le ssid;
818 	__le32 flags;
819 	__le32 infra;
820 	__le32 auth;
821 	__le32 wpa_auth;
822 	__le32 wsec;
823 };
824 
825 /**
826  * struct brcmf_pno_net_info_le - information per found network.
827  *
828  * @bssid: BSS network identifier.
829  * @channel: channel number only.
830  * @SSID_len: length of ssid.
831  * @SSID: ssid characters.
832  * @RSSI: receive signal strength (in dBm).
833  * @timestamp: age in seconds.
834  */
835 struct brcmf_pno_net_info_le {
836 	u8 bssid[ETH_ALEN];
837 	u8 channel;
838 	u8 SSID_len;
839 	u8 SSID[32];
840 	__le16	RSSI;
841 	__le16	timestamp;
842 };
843 
844 /**
845  * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
846  *
847  * @version: PNO version identifier.
848  * @status: indicates completion status of PNO scan.
849  * @count: amount of brcmf_pno_net_info_le entries appended.
850  */
851 struct brcmf_pno_scanresults_le {
852 	__le32 version;
853 	__le32 status;
854 	__le32 count;
855 };
856 
857 struct brcmf_pno_scanresults_v2_le {
858 	__le32 version;
859 	__le32 status;
860 	__le32 count;
861 	__le32 scan_ch_bucket;
862 };
863 
864 /**
865  * struct brcmf_pno_macaddr_le - to configure PNO macaddr randomization.
866  *
867  * @version: PNO version identifier.
868  * @flags: Flags defining how mac addrss should be used.
869  * @mac: MAC address.
870  */
871 struct brcmf_pno_macaddr_le {
872 	u8 version;
873 	u8 flags;
874 	u8 mac[ETH_ALEN];
875 };
876 
877 /**
878  * struct brcmf_dload_data_le - data passing to firmware for downloading
879  * @flag: flags related to download data.
880  * @dload_type: type of download data.
881  * @len: length in bytes of download data.
882  * @crc: crc of download data.
883  * @data: download data.
884  */
885 struct brcmf_dload_data_le {
886 	__le16 flag;
887 	__le16 dload_type;
888 	__le32 len;
889 	__le32 crc;
890 	u8 data[1];
891 };
892 
893 /**
894  * struct brcmf_pno_bssid_le - bssid configuration for PNO scan.
895  *
896  * @bssid: BSS network identifier.
897  * @flags: flags for this BSSID.
898  */
899 struct brcmf_pno_bssid_le {
900 	u8 bssid[ETH_ALEN];
901 	__le16 flags;
902 };
903 
904 /**
905  * struct brcmf_pktcnt_le - packet counters.
906  *
907  * @rx_good_pkt: packets (MSDUs & MMPDUs) received from this station
908  * @rx_bad_pkt: failed rx packets
909  * @tx_good_pkt: packets (MSDUs & MMPDUs) transmitted to this station
910  * @tx_bad_pkt: failed tx packets
911  * @rx_ocast_good_pkt: unicast packets destined for others
912  */
913 struct brcmf_pktcnt_le {
914 	__le32 rx_good_pkt;
915 	__le32 rx_bad_pkt;
916 	__le32 tx_good_pkt;
917 	__le32 tx_bad_pkt;
918 	__le32 rx_ocast_good_pkt;
919 };
920 
921 /**
922  * struct brcmf_gtk_keyinfo_le - GTP rekey data
923  *
924  * @kck: key confirmation key.
925  * @kek: key encryption key.
926  * @replay_counter: replay counter.
927  */
928 struct brcmf_gtk_keyinfo_le {
929 	u8 kck[BRCMF_RSN_KCK_LENGTH];
930 	u8 kek[BRCMF_RSN_KEK_LENGTH];
931 	u8 replay_counter[BRCMF_RSN_REPLAY_LEN];
932 };
933 
934 #define BRCMF_PNO_REPORT_NO_BATCH	BIT(2)
935 
936 /**
937  * struct brcmf_gscan_bucket_config - configuration data for channel bucket.
938  *
939  * @bucket_end_index: last channel index in @channel_list in
940  *	@struct brcmf_pno_config_le.
941  * @bucket_freq_multiple: scan interval expressed in N * @scan_freq.
942  * @flag: channel bucket report flags.
943  * @reserved: for future use.
944  * @repeat: number of scan at interval for exponential scan.
945  * @max_freq_multiple: maximum scan interval for exponential scan.
946  */
947 struct brcmf_gscan_bucket_config {
948 	u8 bucket_end_index;
949 	u8 bucket_freq_multiple;
950 	u8 flag;
951 	u8 reserved;
952 	__le16 repeat;
953 	__le16 max_freq_multiple;
954 };
955 
956 /* version supported which must match firmware */
957 #define BRCMF_GSCAN_CFG_VERSION                     2
958 
959 /**
960  * enum brcmf_gscan_cfg_flags - bit values for gscan flags.
961  *
962  * @BRCMF_GSCAN_CFG_FLAGS_ALL_RESULTS: send probe responses/beacons to host.
963  * @BRCMF_GSCAN_CFG_ALL_BUCKETS_IN_1ST_SCAN: all buckets will be included in
964  *	first scan cycle.
965  * @BRCMF_GSCAN_CFG_FLAGS_CHANGE_ONLY: indicated only flags member is changed.
966  */
967 enum brcmf_gscan_cfg_flags {
968 	BRCMF_GSCAN_CFG_FLAGS_ALL_RESULTS = BIT(0),
969 	BRCMF_GSCAN_CFG_ALL_BUCKETS_IN_1ST_SCAN = BIT(3),
970 	BRCMF_GSCAN_CFG_FLAGS_CHANGE_ONLY = BIT(7),
971 };
972 
973 /**
974  * struct brcmf_gscan_config - configuration data for gscan.
975  *
976  * @version: version of the api to match firmware.
977  * @flags: flags according %enum brcmf_gscan_cfg_flags.
978  * @buffer_threshold: percentage threshold of buffer to generate an event.
979  * @swc_nbssid_threshold: number of BSSIDs with significant change that
980  *	will generate an event.
981  * @swc_rssi_window_size: size of rssi cache buffer (max=8).
982  * @count_of_channel_buckets: number of array members in @bucket.
983  * @retry_threshold: !unknown!
984  * @lost_ap_window: !unknown!
985  * @bucket: array of channel buckets.
986  */
987 struct brcmf_gscan_config {
988 	__le16 version;
989 	u8 flags;
990 	u8 buffer_threshold;
991 	u8 swc_nbssid_threshold;
992 	u8 swc_rssi_window_size;
993 	u8 count_of_channel_buckets;
994 	u8 retry_threshold;
995 	__le16  lost_ap_window;
996 	struct brcmf_gscan_bucket_config bucket[1];
997 };
998 
999 #endif /* FWIL_TYPES_H_ */
1000