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